linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [media] soc_camera: Support VIDIOC_EXPBUF ioctl
@ 2014-09-11  6:09 Kazunori Kobayashi
  2014-09-20  7:50 ` Guennadi Liakhovetski
  0 siblings, 1 reply; 3+ messages in thread
From: Kazunori Kobayashi @ 2014-09-11  6:09 UTC (permalink / raw)
  To: g.liakhovetski, m.chehab; +Cc: dhobsong, linux-media, Kazunori Kobayashi

This patch allows for exporting a dmabuf descriptor from soc_camera drivers.

Signed-off-by: Kazunori Kobayashi <kkobayas@igel.co.jp>
---
 drivers/media/platform/soc_camera/soc_camera.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index f4308fe..9d7b8ea 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -437,6 +437,19 @@ static int soc_camera_prepare_buf(struct file *file, void *priv,
 		return vb2_prepare_buf(&icd->vb2_vidq, b);
 }
 
+static int soc_camera_expbuf(struct file *file, void *priv,
+			     struct v4l2_exportbuffer *p)
+{
+	struct soc_camera_device *icd = file->private_data;
+	struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
+
+	/* videobuf2 only */
+	if (ici->ops->init_videobuf)
+		return -EINVAL;
+	else
+		return vb2_expbuf(&icd->vb2_vidq, p);
+}
+
 /* Always entered with .host_lock held */
 static int soc_camera_init_user_formats(struct soc_camera_device *icd)
 {
@@ -2085,6 +2098,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = {
 	.vidioc_dqbuf		 = soc_camera_dqbuf,
 	.vidioc_create_bufs	 = soc_camera_create_bufs,
 	.vidioc_prepare_buf	 = soc_camera_prepare_buf,
+	.vidioc_expbuf		 = soc_camera_expbuf,
 	.vidioc_streamon	 = soc_camera_streamon,
 	.vidioc_streamoff	 = soc_camera_streamoff,
 	.vidioc_cropcap		 = soc_camera_cropcap,
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] [media] soc_camera: Support VIDIOC_EXPBUF ioctl
  2014-09-11  6:09 [PATCH] [media] soc_camera: Support VIDIOC_EXPBUF ioctl Kazunori Kobayashi
@ 2014-09-20  7:50 ` Guennadi Liakhovetski
  2014-09-22  2:51   ` Kazunori Kobayashi
  0 siblings, 1 reply; 3+ messages in thread
From: Guennadi Liakhovetski @ 2014-09-20  7:50 UTC (permalink / raw)
  To: Kazunori Kobayashi; +Cc: m.chehab, dhobsong, linux-media

Hi Kobayashi-san,

Thanks for the patch. In principle it looks good, just one question below:

On Thu, 11 Sep 2014, Kazunori Kobayashi wrote:

> This patch allows for exporting a dmabuf descriptor from soc_camera drivers.
> 
> Signed-off-by: Kazunori Kobayashi <kkobayas@igel.co.jp>
> ---
>  drivers/media/platform/soc_camera/soc_camera.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index f4308fe..9d7b8ea 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -437,6 +437,19 @@ static int soc_camera_prepare_buf(struct file *file, void *priv,
>  		return vb2_prepare_buf(&icd->vb2_vidq, b);
>  }
>  
> +static int soc_camera_expbuf(struct file *file, void *priv,
> +			     struct v4l2_exportbuffer *p)
> +{
> +	struct soc_camera_device *icd = file->private_data;
> +	struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
> +
> +	/* videobuf2 only */
> +	if (ici->ops->init_videobuf)
> +		return -EINVAL;
> +	else
> +		return vb2_expbuf(&icd->vb2_vidq, p);

Many soc-camera queue management functions, like queuing, dequeuing a 
buffer check, that the caller is indeed the process, that is controlling 
the device. This is done for the case, when two (or more) processes open a 
video device node, some of them only want to monitor it, or control 
parameters like exposure etc. Whereas only one process is allowed to 
perform critical operations, like setting a video format, starting and 
stopping streaming, queuing and dequeuing buffers. Should this function 
too use such a check

	if (icd->streamer != file)
		return -EBUSY;

If you agree, I can just add it myself, no need to resubmit.

Thanks
Guennadi

> +}
> +
>  /* Always entered with .host_lock held */
>  static int soc_camera_init_user_formats(struct soc_camera_device *icd)
>  {
> @@ -2085,6 +2098,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = {
>  	.vidioc_dqbuf		 = soc_camera_dqbuf,
>  	.vidioc_create_bufs	 = soc_camera_create_bufs,
>  	.vidioc_prepare_buf	 = soc_camera_prepare_buf,
> +	.vidioc_expbuf		 = soc_camera_expbuf,
>  	.vidioc_streamon	 = soc_camera_streamon,
>  	.vidioc_streamoff	 = soc_camera_streamoff,
>  	.vidioc_cropcap		 = soc_camera_cropcap,
> -- 
> 1.8.1.2
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [media] soc_camera: Support VIDIOC_EXPBUF ioctl
  2014-09-20  7:50 ` Guennadi Liakhovetski
@ 2014-09-22  2:51   ` Kazunori Kobayashi
  0 siblings, 0 replies; 3+ messages in thread
From: Kazunori Kobayashi @ 2014-09-22  2:51 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: m.chehab, dhobsong, linux-media

Hi Guennadi,

Thank you for your review.

(2014/09/20 16:50), Guennadi Liakhovetski wrote:
> Hi Kobayashi-san,
> 
> Thanks for the patch. In principle it looks good, just one question below:
> 
> On Thu, 11 Sep 2014, Kazunori Kobayashi wrote:
> 
>> This patch allows for exporting a dmabuf descriptor from soc_camera drivers.
>>
>> Signed-off-by: Kazunori Kobayashi <kkobayas@igel.co.jp>
>> ---
>>  drivers/media/platform/soc_camera/soc_camera.c | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
>> index f4308fe..9d7b8ea 100644
>> --- a/drivers/media/platform/soc_camera/soc_camera.c
>> +++ b/drivers/media/platform/soc_camera/soc_camera.c
>> @@ -437,6 +437,19 @@ static int soc_camera_prepare_buf(struct file *file, void *priv,
>>  		return vb2_prepare_buf(&icd->vb2_vidq, b);
>>  }
>>  
>> +static int soc_camera_expbuf(struct file *file, void *priv,
>> +			     struct v4l2_exportbuffer *p)
>> +{
>> +	struct soc_camera_device *icd = file->private_data;
>> +	struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
>> +
>> +	/* videobuf2 only */
>> +	if (ici->ops->init_videobuf)
>> +		return -EINVAL;
>> +	else
>> +		return vb2_expbuf(&icd->vb2_vidq, p);
> 
> Many soc-camera queue management functions, like queuing, dequeuing a 
> buffer check, that the caller is indeed the process, that is controlling 
> the device. This is done for the case, when two (or more) processes open a 
> video device node, some of them only want to monitor it, or control 
> parameters like exposure etc. Whereas only one process is allowed to 
> perform critical operations, like setting a video format, starting and 
> stopping streaming, queuing and dequeuing buffers. Should this function 
> too use such a check
> 
> 	if (icd->streamer != file)
> 		return -EBUSY;
> 
> If you agree, I can just add it myself, no need to resubmit.
I think that's appropriate suggestion.
The dmabuf exporting should be restricted to the process that
operates the video streaming.
Please add the check.

> 
> Thanks
> Guennadi
> 
>> +}
>> +
>>  /* Always entered with .host_lock held */
>>  static int soc_camera_init_user_formats(struct soc_camera_device *icd)
>>  {
>> @@ -2085,6 +2098,7 @@ static const struct v4l2_ioctl_ops soc_camera_ioctl_ops = {
>>  	.vidioc_dqbuf		 = soc_camera_dqbuf,
>>  	.vidioc_create_bufs	 = soc_camera_create_bufs,
>>  	.vidioc_prepare_buf	 = soc_camera_prepare_buf,
>> +	.vidioc_expbuf		 = soc_camera_expbuf,
>>  	.vidioc_streamon	 = soc_camera_streamon,
>>  	.vidioc_streamoff	 = soc_camera_streamoff,
>>  	.vidioc_cropcap		 = soc_camera_cropcap,
>> -- 
>> 1.8.1.2
>>


-- 
---------------------------------
IGEL Co.,Ltd. Kazunori Kobayashi
kkobayas@igel.co.jp
http://www.igel.co.jp/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-22  2:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-11  6:09 [PATCH] [media] soc_camera: Support VIDIOC_EXPBUF ioctl Kazunori Kobayashi
2014-09-20  7:50 ` Guennadi Liakhovetski
2014-09-22  2:51   ` Kazunori Kobayashi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).