diff mbox

OV5642: fix VIDIOC_S_GROP ioctl

Message ID 20121106141845.4641954a@wker (mailing list archive)
State New, archived
Headers show

Commit Message

Anatolij Gustschin Nov. 6, 2012, 1:18 p.m. UTC
On Tue, 6 Nov 2012 12:45:51 +0100 (CET)
Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:

> On Tue, 6 Nov 2012, Anatolij Gustschin wrote:
> 
> > VIDIOC_S_GROP ioctl doesn't work, soc-camera driver reports:
> > 
> > soc-camera-pdrv soc-camera-pdrv.0: S_CROP denied: getting current crop failed
> > 
> > The issue is caused by checking for V4L2_BUF_TYPE_VIDEO_CAPTURE type
> > in driver's g_crop callback. This check should be in s_crop instead,
> > g_crop should just set the type field to V4L2_BUF_TYPE_VIDEO_CAPTURE
> > as other drivers do. Move the V4L2_BUF_TYPE_VIDEO_CAPTURE type check
> > to s_crop callback.
> 
> I'm not sure this is correct:
> 
> http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-crop.html
> 
> Or is the .g_crop() subdev operation using a different semantics? Where is 
> that documented?

I do not know if it is documented somewhere. But it seems natural to me
that a sensor driver sets the type field to V4L2_BUF_TYPE_VIDEO_CAPTURE
in its .g_crop(). A sensor is a capture device, not an output or overlay
device. And this ioctl is a query operation.

OTOH I'm fine with this type checking in .g_crop() and it can help
to discover bugs in user space apps. The VIDIOC_G_CROP documentation
states that the type field needs to be set to the respective buffer type
when querying, so the check in .g_crop() is perfectly valid. But then
I need following patch to fix the observed issue:

What do you think?

And the type field should be checked in .s_crop() anyway, I think.

Thanks,
Anatolij
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Guennadi Liakhovetski Nov. 26, 2012, 3:20 p.m. UTC | #1
Hi Anatolij

Sorry for a delay

On Tue, 6 Nov 2012, Anatolij Gustschin wrote:

> On Tue, 6 Nov 2012 12:45:51 +0100 (CET)
> Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:
> 
> > On Tue, 6 Nov 2012, Anatolij Gustschin wrote:
> > 
> > > VIDIOC_S_GROP ioctl doesn't work, soc-camera driver reports:
> > > 
> > > soc-camera-pdrv soc-camera-pdrv.0: S_CROP denied: getting current crop failed
> > > 
> > > The issue is caused by checking for V4L2_BUF_TYPE_VIDEO_CAPTURE type
> > > in driver's g_crop callback. This check should be in s_crop instead,
> > > g_crop should just set the type field to V4L2_BUF_TYPE_VIDEO_CAPTURE
> > > as other drivers do. Move the V4L2_BUF_TYPE_VIDEO_CAPTURE type check
> > > to s_crop callback.
> > 
> > I'm not sure this is correct:
> > 
> > http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-crop.html
> > 
> > Or is the .g_crop() subdev operation using a different semantics? Where is 
> > that documented?
> 
> I do not know if it is documented somewhere. But it seems natural to me
> that a sensor driver sets the type field to V4L2_BUF_TYPE_VIDEO_CAPTURE
> in its .g_crop(). A sensor is a capture device, not an output or overlay
> device. And this ioctl is a query operation.
> 
> OTOH I'm fine with this type checking in .g_crop() and it can help
> to discover bugs in user space apps. The VIDIOC_G_CROP documentation
> states that the type field needs to be set to the respective buffer type
> when querying, so the check in .g_crop() is perfectly valid. But then
> I need following patch to fix the observed issue:
> 
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -902,6 +902,8 @@ static int soc_camera_s_crop(struct file *file, void *fh,
>         dev_dbg(icd->pdev, "S_CROP(%ux%u@%u:%u)\n",
>                 rect->width, rect->height, rect->left, rect->top);
>  
> +       current_crop.type = a->type;
> +
>         /* If get_crop fails, we'll let host and / or client drivers decide */
>         ret = ici->ops->get_crop(icd, &current_crop);
>  
> What do you think?

Yes, this makes sense. Please, submit a patch.

> And the type field should be checked in .s_crop() anyway, I think.

It is checked in soc_camera_s_crop() just a couple of lines above the 
snippet above. Or what do you mean?

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Anatolij Gustschin Nov. 28, 2012, 8:18 p.m. UTC | #2
Hi Guennadi,

On Mon, 26 Nov 2012 16:20:14 +0100 (CET)
Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:
...
> > --- a/drivers/media/platform/soc_camera/soc_camera.c
> > +++ b/drivers/media/platform/soc_camera/soc_camera.c
> > @@ -902,6 +902,8 @@ static int soc_camera_s_crop(struct file *file, void *fh,
> >         dev_dbg(icd->pdev, "S_CROP(%ux%u@%u:%u)\n",
> >                 rect->width, rect->height, rect->left, rect->top);
> >  
> > +       current_crop.type = a->type;
> > +
> >         /* If get_crop fails, we'll let host and / or client drivers decide */
> >         ret = ici->ops->get_crop(icd, &current_crop);
> >  
> > What do you think?
> 
> Yes, this makes sense. Please, submit a patch.

Done.

> 
> > And the type field should be checked in .s_crop() anyway, I think.
> 
> It is checked in soc_camera_s_crop() just a couple of lines above the 
> snippet above. Or what do you mean?

Yes, you are right! Okay, then there is no need to check it again
in the subdevice driver.

Thanks,

Anatolij
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -902,6 +902,8 @@  static int soc_camera_s_crop(struct file *file, void *fh,
        dev_dbg(icd->pdev, "S_CROP(%ux%u@%u:%u)\n",
                rect->width, rect->height, rect->left, rect->top);
 
+       current_crop.type = a->type;
+
        /* If get_crop fails, we'll let host and / or client drivers decide */
        ret = ici->ops->get_crop(icd, &current_crop);