Commit f29816bc authored by Trent Piepho's avatar Trent Piepho Committed by Mauro Carvalho Chehab

V4L/DVB (11268): 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.

Cc: Steven Toth <stoth@hauppauge.com>
Signed-off-by: default avatarTrent Piepho <xyzzy@speakeasy.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent e33ee31a
...@@ -1198,21 +1198,16 @@ static int vidioc_enum_input(struct file *file, void *priv, ...@@ -1198,21 +1198,16 @@ static int vidioc_enum_input(struct file *file, void *priv,
struct cx23885_fh *fh = file->private_data; struct cx23885_fh *fh = file->private_data;
struct cx23885_dev *dev = fh->dev; struct cx23885_dev *dev = fh->dev;
struct cx23885_input *input; struct cx23885_input *input;
unsigned int n; int n;
n = i->index; if (i->index >= 4)
if (n >= 4)
return -EINVAL; return -EINVAL;
input = &cx23885_boards[dev->board].input[n]; input = &cx23885_boards[dev->board].input[i->index];
if (input->type == 0) if (input->type == 0)
return -EINVAL; return -EINVAL;
memset(i, 0, sizeof(*i));
i->index = n;
/* FIXME /* FIXME
* strcpy(i->name, input->name); */ * strcpy(i->name, input->name); */
strcpy(i->name, "unset"); strcpy(i->name, "unset");
...@@ -1255,7 +1250,6 @@ static int vidioc_g_tuner(struct file *file, void *priv, ...@@ -1255,7 +1250,6 @@ static int vidioc_g_tuner(struct file *file, void *priv,
return -EINVAL; return -EINVAL;
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
memset(t, 0, sizeof(*t));
strcpy(t->name, "Television"); strcpy(t->name, "Television");
cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_TUNER, t); cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_TUNER, t);
cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t); cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t);
...@@ -1286,7 +1280,6 @@ static int vidioc_g_frequency(struct file *file, void *priv, ...@@ -1286,7 +1280,6 @@ static int vidioc_g_frequency(struct file *file, void *priv,
struct cx23885_fh *fh = file->private_data; struct cx23885_fh *fh = file->private_data;
struct cx23885_dev *dev = fh->dev; struct cx23885_dev *dev = fh->dev;
memset(f, 0, sizeof(*f));
if (UNSET == dev->tuner_type) if (UNSET == dev->tuner_type)
return -EINVAL; return -EINVAL;
f->type = V4L2_TUNER_ANALOG_TV; f->type = V4L2_TUNER_ANALOG_TV;
...@@ -1346,7 +1339,6 @@ static int vidioc_querycap(struct file *file, void *priv, ...@@ -1346,7 +1339,6 @@ static int vidioc_querycap(struct file *file, void *priv,
struct cx23885_dev *dev = fh->dev; struct cx23885_dev *dev = fh->dev;
struct cx23885_tsport *tsport = &dev->ts1; struct cx23885_tsport *tsport = &dev->ts1;
memset(cap, 0, sizeof(*cap));
strcpy(cap->driver, dev->name); strcpy(cap->driver, dev->name);
strlcpy(cap->card, cx23885_boards[tsport->dev->board].name, strlcpy(cap->card, cx23885_boards[tsport->dev->board].name,
sizeof(cap->card)); sizeof(cap->card));
...@@ -1366,16 +1358,10 @@ static int vidioc_querycap(struct file *file, void *priv, ...@@ -1366,16 +1358,10 @@ static int vidioc_querycap(struct file *file, void *priv,
static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f) struct v4l2_fmtdesc *f)
{ {
int index; if (f->index != 0)
index = f->index;
if (index != 0)
return -EINVAL; return -EINVAL;
memset(f, 0, sizeof(*f));
f->index = index;
strlcpy(f->description, "MPEG", sizeof(f->description)); strlcpy(f->description, "MPEG", sizeof(f->description));
f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
f->pixelformat = V4L2_PIX_FMT_MPEG; f->pixelformat = V4L2_PIX_FMT_MPEG;
return 0; return 0;
...@@ -1387,8 +1373,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, ...@@ -1387,8 +1373,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
struct cx23885_fh *fh = file->private_data; struct cx23885_fh *fh = file->private_data;
struct cx23885_dev *dev = fh->dev; 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.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.bytesperline = 0; f->fmt.pix.bytesperline = 0;
f->fmt.pix.sizeimage = f->fmt.pix.sizeimage =
...@@ -1408,12 +1392,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, ...@@ -1408,12 +1392,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
struct cx23885_fh *fh = file->private_data; struct cx23885_fh *fh = file->private_data;
struct cx23885_dev *dev = fh->dev; struct cx23885_dev *dev = fh->dev;
f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.bytesperline = 0; f->fmt.pix.bytesperline = 0;
f->fmt.pix.sizeimage = f->fmt.pix.sizeimage =
dev->ts1.ts_packet_size * dev->ts1.ts_packet_count; dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
f->fmt.pix.sizeimage =
f->fmt.pix.colorspace = 0; f->fmt.pix.colorspace = 0;
dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n", dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
dev->ts1.width, dev->ts1.height, fh->mpegq.field); dev->ts1.width, dev->ts1.height, fh->mpegq.field);
...@@ -1426,7 +1408,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -1426,7 +1408,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
struct cx23885_fh *fh = file->private_data; struct cx23885_fh *fh = file->private_data;
struct cx23885_dev *dev = fh->dev; struct cx23885_dev *dev = fh->dev;
f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.bytesperline = 0; f->fmt.pix.bytesperline = 0;
f->fmt.pix.sizeimage = f->fmt.pix.sizeimage =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment