The patch number 11268 was added via Trent Piepho <[email protected]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <[email protected]>

------

From: Trent Piepho  <[email protected]>
cx23885-417: Don't need to zero ioctl parameter fields


The v4l2 core code in v4l2_ioctl will zero out the structure the driver is
supposed to fill in for read-only ioctls.  For read/write ioctls, all the
fields which aren't supplied from userspace will be zeroed out.

Zeroing code is removed from enum_input, g_tuner, g_frequency, querycap,
enum_fmt_vid_cap, g_fmt_vid_cap, and try_fmt_vid_cap.

The ->vidioc_(s|g|try|enum)_fmt_vid_cap() methods are only called on
VIDEO_CAPTURE buffers.  Thus, there is no need to check or set the buffer's
'type' field since it must already be set to VIDEO_CAPTURE.

There also appeared to be a copy and paste error in
vidioc_try_fmt_vid_cap() that would set f->fmt.pix.sizeimage to zero.

Note that the s_fmt_vid_cap method doesn't appear to actually do anything.
Whatever parameters were requested are just silently ignored.  Was this
intentional?  Who knows, as the commit log entry for the driver just says,
"Add generic cx23417 hardware encoder support." There are no docs.  A
comment like "this driver totally ignores the v4l2 spec w.r.t.
VIDIOC_S_FMT because ..." would have gone a long way.

Priority: normal

Signed-off-by: Trent Piepho <[email protected]>
CC: Steven Toth <[email protected]>


---

 linux/drivers/media/video/cx23885/cx23885-417.c |   29 ++--------------
 1 file changed, 5 insertions(+), 24 deletions(-)

diff -r e698f5e2e1db -r 76e7154479e4 
linux/drivers/media/video/cx23885/cx23885-417.c
--- a/linux/drivers/media/video/cx23885/cx23885-417.c   Sat Mar 28 18:25:36 
2009 -0700
+++ b/linux/drivers/media/video/cx23885/cx23885-417.c   Sat Mar 28 18:25:36 
2009 -0700
@@ -1206,20 +1206,15 @@ static int vidioc_enum_input(struct file
        struct cx23885_fh  *fh  = file->private_data;
        struct cx23885_dev *dev = fh->dev;
        struct cx23885_input *input;
-       unsigned int n;
-
-       n = i->index;
-
-       if (n >= 4)
+       int n;
+
+       if (i->index >= 4)
                return -EINVAL;
 
-       input = &cx23885_boards[dev->board].input[n];
+       input = &cx23885_boards[dev->board].input[i->index];
 
        if (input->type == 0)
                return -EINVAL;
-
-       memset(i, 0, sizeof(*i));
-       i->index = n;
 
        /* FIXME
         * strcpy(i->name, input->name); */
@@ -1263,7 +1258,6 @@ static int vidioc_g_tuner(struct file *f
                return -EINVAL;
        if (0 != t->index)
                return -EINVAL;
-       memset(t, 0, sizeof(*t));
        strcpy(t->name, "Television");
        cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_TUNER, t);
        cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t);
@@ -1294,7 +1288,6 @@ static int vidioc_g_frequency(struct fil
        struct cx23885_fh  *fh  = file->private_data;
        struct cx23885_dev *dev = fh->dev;
 
-       memset(f, 0, sizeof(*f));
        if (UNSET == dev->tuner_type)
                return -EINVAL;
        f->type = V4L2_TUNER_ANALOG_TV;
@@ -1354,7 +1347,6 @@ static int vidioc_querycap(struct file *
        struct cx23885_dev *dev = fh->dev;
        struct cx23885_tsport  *tsport = &dev->ts1;
 
-       memset(cap, 0, sizeof(*cap));
        strcpy(cap->driver, dev->name);
        strlcpy(cap->card, cx23885_boards[tsport->dev->board].name,
                sizeof(cap->card));
@@ -1374,16 +1366,10 @@ static int vidioc_enum_fmt_vid_cap(struc
 static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
                                        struct v4l2_fmtdesc *f)
 {
-       int index;
-
-       index = f->index;
-       if (index != 0)
+       if (f->index != 0)
                return -EINVAL;
 
-       memset(f, 0, sizeof(*f));
-       f->index = index;
        strlcpy(f->description, "MPEG", sizeof(f->description));
-       f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        f->pixelformat = V4L2_PIX_FMT_MPEG;
 
        return 0;
@@ -1395,8 +1381,6 @@ static int vidioc_g_fmt_vid_cap(struct f
        struct cx23885_fh  *fh  = file->private_data;
        struct cx23885_dev *dev = fh->dev;
 
-       memset(f, 0, sizeof(*f));
-       f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
        f->fmt.pix.bytesperline = 0;
        f->fmt.pix.sizeimage    =
@@ -1416,12 +1400,10 @@ static int vidioc_try_fmt_vid_cap(struct
        struct cx23885_fh  *fh  = file->private_data;
        struct cx23885_dev *dev = fh->dev;
 
-       f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
        f->fmt.pix.bytesperline = 0;
        f->fmt.pix.sizeimage    =
                dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
-       f->fmt.pix.sizeimage    =
        f->fmt.pix.colorspace   = 0;
        dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
                dev->ts1.width, dev->ts1.height, fh->mpegq.field);
@@ -1434,7 +1416,6 @@ static int vidioc_s_fmt_vid_cap(struct f
        struct cx23885_fh  *fh  = file->private_data;
        struct cx23885_dev *dev = fh->dev;
 
-       f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
        f->fmt.pix.bytesperline = 0;
        f->fmt.pix.sizeimage    =


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/76e7154479e46a91fe79aac36a26dcc40a0bce79

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to