The patch number 11273 was added via Mauro Carvalho Chehab <mche...@redhat.com> 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 <linux-me...@vger.kernel.org> ------ From: Mauro Carvalho Chehab <mche...@redhat.com> merge: http://linuxtv.org/hg/~tap/v4l-dvb Signed-off-by: Mauro Carvalho Chehab <mche...@redhat.com> --- linux/drivers/media/common/saa7146_video.c | 2 linux/drivers/media/video/bt8xx/bttv-driver.c | 2 linux/drivers/media/video/cafe_ccic.c | 14 linux/drivers/media/video/cx23885/cx23885-417.c | 29 linux/drivers/media/video/cx88/cx88-blackbird.c | 4 linux/drivers/media/video/gspca/gspca.c | 4 linux/drivers/media/video/meye.c | 31 linux/drivers/media/video/omap24xxcam.c | 6 linux/drivers/media/video/stk-webcam.c | 10 linux/drivers/media/video/usbvision/usbvision-video.c | 10 linux/drivers/media/video/v4l2-ioctl.c | 7 linux/drivers/media/video/vino.c | 334 ++++------ linux/drivers/media/video/zr364xx.c | 16 v4l/Makefile | 3 14 files changed, 158 insertions(+), 314 deletions(-) diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/common/saa7146_video.c --- a/linux/drivers/media/common/saa7146_video.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/common/saa7146_video.c Sun Mar 29 05:49:03 2009 -0300 @@ -724,8 +724,6 @@ static int vidioc_g_parm(struct file *fi struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; struct saa7146_vv *vv = dev->vv_data; - if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; parm->parm.capture.readbuffers = 1; v4l2_video_std_frame_period(vv->standard->id, &parm->parm.capture.timeperframe); diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/bt8xx/bttv-driver.c --- a/linux/drivers/media/video/bt8xx/bttv-driver.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/bt8xx/bttv-driver.c Sun Mar 29 05:49:03 2009 -0300 @@ -2956,8 +2956,6 @@ static int bttv_g_parm(struct file *file struct bttv_fh *fh = f; struct bttv *btv = fh->btv; - if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id, &parm->parm.capture.timeperframe); return 0; diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/cafe_ccic.c --- a/linux/drivers/media/video/cafe_ccic.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/cafe_ccic.c Sun Mar 29 05:49:03 2009 -0300 @@ -1152,8 +1152,6 @@ static int cafe_vidioc_reqbufs(struct fi * Make sure it's something we can do. User pointers could be * implemented without great pain, but that's not been done yet. */ - if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; if (req->memory != V4L2_MEMORY_MMAP) return -EINVAL; /* @@ -1217,9 +1215,7 @@ static int cafe_vidioc_querybuf(struct f int ret = -EINVAL; mutex_lock(&cam->s_mutex); - if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - goto out; - if (buf->index < 0 || buf->index >= cam->n_sbufs) + if (buf->index >= cam->n_sbufs) goto out; *buf = cam->sb_bufs[buf->index].v4lbuf; ret = 0; @@ -1237,9 +1233,7 @@ static int cafe_vidioc_qbuf(struct file unsigned long flags; mutex_lock(&cam->s_mutex); - if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - goto out; - if (buf->index < 0 || buf->index >= cam->n_sbufs) + if (buf->index >= cam->n_sbufs) goto out; sbuf = cam->sb_bufs + buf->index; if (sbuf->v4lbuf.flags & V4L2_BUF_FLAG_QUEUED) { @@ -1270,8 +1264,6 @@ static int cafe_vidioc_dqbuf(struct file unsigned long flags; mutex_lock(&cam->s_mutex); - if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - goto out_unlock; if (cam->state != S_STREAMING) goto out_unlock; if (list_empty(&cam->sb_full) && filp->f_flags & O_NONBLOCK) { @@ -1504,8 +1496,6 @@ static int cafe_vidioc_enum_fmt_vid_cap( struct cafe_camera *cam = priv; int ret; - if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; mutex_lock(&cam->s_mutex); ret = sensor_call(cam, video, enum_fmt, fmt); mutex_unlock(&cam->s_mutex); diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/cx23885/cx23885-417.c --- a/linux/drivers/media/video/cx23885/cx23885-417.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/cx23885/cx23885-417.c Sun Mar 29 05:49:03 2009 -0300 @@ -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 = diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/cx88/cx88-blackbird.c --- a/linux/drivers/media/video/cx88/cx88-blackbird.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/cx88/cx88-blackbird.c Sun Mar 29 05:49:03 2009 -0300 @@ -761,7 +761,6 @@ static int vidioc_enum_fmt_vid_cap (stru return -EINVAL; strlcpy(f->description, "MPEG", sizeof(f->description)); - f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; f->pixelformat = V4L2_PIX_FMT_MPEG; return 0; } @@ -772,7 +771,6 @@ static int vidioc_g_fmt_vid_cap (struct struct cx8802_fh *fh = priv; struct cx8802_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->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */ @@ -791,7 +789,6 @@ static int vidioc_try_fmt_vid_cap (struc struct cx8802_fh *fh = priv; struct cx8802_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->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */; @@ -808,7 +805,6 @@ static int vidioc_s_fmt_vid_cap (struct struct cx8802_dev *dev = fh->dev; struct cx88_core *core = dev->core; - 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->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */; diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/gspca/gspca.c --- a/linux/drivers/media/video/gspca/gspca.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/gspca/gspca.c Sun Mar 29 05:49:03 2009 -0300 @@ -777,7 +777,6 @@ static int vidioc_enum_fmt_vid_cap(struc fmtdesc->pixelformat = fmt_tb[index]; if (gspca_is_compressed(fmt_tb[index])) fmtdesc->flags = V4L2_FMT_FLAG_COMPRESSED; - fmtdesc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmtdesc->description[0] = fmtdesc->pixelformat & 0xff; fmtdesc->description[1] = (fmtdesc->pixelformat >> 8) & 0xff; fmtdesc->description[2] = (fmtdesc->pixelformat >> 16) & 0xff; @@ -973,8 +972,6 @@ static int vidioc_querycap(struct file * { struct gspca_dev *gspca_dev = priv; int ret; - - memset(cap, 0, sizeof *cap); /* protect the access to the usb device */ if (mutex_lock_interruptible(&gspca_dev->usb_lock)) @@ -1353,7 +1350,6 @@ static int vidioc_g_parm(struct file *fi { struct gspca_dev *gspca_dev = priv; - parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; parm->parm.capture.readbuffers = gspca_dev->nbufread; if (gspca_dev->sd_desc->get_streamparm) { diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/meye.c --- a/linux/drivers/media/video/meye.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/meye.c Sun Mar 29 05:49:03 2009 -0300 @@ -1261,18 +1261,13 @@ static int vidioc_enum_fmt_vid_cap(struc if (f->index > 1) return -EINVAL; - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - if (f->index == 0) { /* standard YUV 422 capture */ - f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; f->flags = 0; strcpy(f->description, "YUV422"); f->pixelformat = V4L2_PIX_FMT_YUYV; } else { /* compressed MJPEG capture */ - f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; f->flags = V4L2_FMT_FLAG_COMPRESSED; strcpy(f->description, "MJPEG"); f->pixelformat = V4L2_PIX_FMT_MJPEG; @@ -1284,9 +1279,6 @@ static int vidioc_try_fmt_vid_cap(struct static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) { - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV && f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG) return -EINVAL; @@ -1317,9 +1309,6 @@ static int vidioc_g_fmt_vid_cap(struct f static int vidioc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) { - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - switch (meye.mchip_mode) { case MCHIP_HIC_MODE_CONT_OUT: default: @@ -1343,9 +1332,6 @@ static int vidioc_s_fmt_vid_cap(struct f static int vidioc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) { - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV && f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG) return -EINVAL; @@ -1390,9 +1376,6 @@ static int vidioc_reqbufs(struct file *f struct v4l2_requestbuffers *req) { int i; - - if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; if (req->memory != V4L2_MEMORY_MMAP) return -EINVAL; @@ -1434,9 +1417,9 @@ static int vidioc_reqbufs(struct file *f static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) { - int index = buf->index; - - if (index < 0 || index >= gbuffers) + unsigned int index = buf->index; + + if (index >= gbuffers) return -EINVAL; buf->bytesused = meye.grab_buffer[index].size; @@ -1460,13 +1443,10 @@ static int vidioc_querybuf(struct file * static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) { - if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - if (buf->memory != V4L2_MEMORY_MMAP) return -EINVAL; - if (buf->index < 0 || buf->index >= gbuffers) + if (buf->index >= gbuffers) return -EINVAL; if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED) @@ -1485,9 +1465,6 @@ static int vidioc_dqbuf(struct file *fil static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) { int reqnr; - - if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; if (buf->memory != V4L2_MEMORY_MMAP) return -EINVAL; diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/omap24xxcam.c --- a/linux/drivers/media/video/omap24xxcam.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/omap24xxcam.c Sun Mar 29 05:49:03 2009 -0300 @@ -1285,9 +1285,6 @@ static int vidioc_g_parm(struct file *fi struct omap24xxcam_device *cam = ofh->cam; int rval; - if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - mutex_lock(&cam->mutex); rval = vidioc_int_g_parm(cam->sdev, a); mutex_unlock(&cam->mutex); @@ -1302,9 +1299,6 @@ static int vidioc_s_parm(struct file *fi struct omap24xxcam_device *cam = ofh->cam; struct v4l2_streamparm old_streamparm; int rval; - - if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; mutex_lock(&cam->mutex); if (cam->streaming) { diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/stk-webcam.c --- a/linux/drivers/media/video/stk-webcam.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/stk-webcam.c Sun Mar 29 05:49:03 2009 -0300 @@ -1113,8 +1113,6 @@ static int stk_vidioc_reqbufs(struct fil if (dev == NULL) return -ENODEV; - if (rb->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; if (rb->memory != V4L2_MEMORY_MMAP) return -EINVAL; if (is_streaming(dev) @@ -1153,8 +1151,6 @@ static int stk_vidioc_qbuf(struct file * struct stk_camera *dev = priv; struct stk_sio_buffer *sbuf; unsigned long flags; - if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; if (buf->memory != V4L2_MEMORY_MMAP) return -EINVAL; @@ -1181,8 +1177,7 @@ static int stk_vidioc_dqbuf(struct file unsigned long flags; int ret; - if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE - || !is_streaming(dev)) + if (!is_streaming(dev)) return -EINVAL; if (filp->f_flags & O_NONBLOCK && list_empty(&dev->sio_full)) @@ -1241,9 +1236,6 @@ static int stk_vidioc_g_parm(struct file static int stk_vidioc_g_parm(struct file *filp, void *priv, struct v4l2_streamparm *sp) { - if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - /*FIXME This is not correct */ sp->parm.capture.timeperframe.numerator = 1; sp->parm.capture.timeperframe.denominator = 30; diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/usbvision/usbvision-video.c --- a/linux/drivers/media/video/usbvision/usbvision-video.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/usbvision/usbvision-video.c Sun Mar 29 05:49:03 2009 -0300 @@ -757,8 +757,7 @@ static int vidioc_reqbufs (struct file * /* Check input validity: the user must do a VIDEO CAPTURE and MMAP method. */ - if((vr->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) || - (vr->memory != V4L2_MEMORY_MMAP)) + if (vr->memory != V4L2_MEMORY_MMAP) return -EINVAL; if(usbvision->streaming == Stream_On) { @@ -816,9 +815,6 @@ static int vidioc_qbuf (struct file *fil unsigned long lock_flags; /* FIXME : works only on VIDEO_CAPTURE MODE, MMAP. */ - if(vb->type != V4L2_CAP_VIDEO_CAPTURE) { - return -EINVAL; - } if(vb->index>=usbvision->num_frames) { return -EINVAL; } @@ -852,9 +848,6 @@ static int vidioc_dqbuf (struct file *fi int ret; struct usbvision_frame *f; unsigned long lock_flags; - - if (vb->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; if (list_empty(&(usbvision->outqueue))) { if (usbvision->streaming == Stream_Idle) @@ -921,7 +914,6 @@ static int vidioc_enum_fmt_vid_cap (stru if(vfd->index>=USBVISION_SUPPORTED_PALETTES-1) { return -EINVAL; } - vfd->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; strcpy(vfd->description,usbvision_v4l2_format[vfd->index].desc); vfd->pixelformat = usbvision_v4l2_format[vfd->index].format; return 0; diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/v4l2-ioctl.c --- a/linux/drivers/media/video/v4l2-ioctl.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/v4l2-ioctl.c Sun Mar 29 05:49:03 2009 -0300 @@ -1552,6 +1552,9 @@ static long __video_do_ioctl(struct file struct v4l2_streamparm *p = arg; if (ops->vidioc_g_parm) { + ret = check_fmt(ops, p->type); + if (ret) + break; ret = ops->vidioc_g_parm(file, fh, p); } else { if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) @@ -1571,6 +1574,10 @@ static long __video_do_ioctl(struct file if (!ops->vidioc_s_parm) break; + ret = check_fmt(ops, p->type); + if (ret) + break; + dbgarg(cmd, "type=%d\n", p->type); ret = ops->vidioc_s_parm(file, fh, p); break; diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/vino.c --- a/linux/drivers/media/video/vino.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/vino.c Sun Mar 29 05:49:03 2009 -0300 @@ -3106,22 +3106,14 @@ static int vino_enum_fmt_vid_cap(struct static int vino_enum_fmt_vid_cap(struct file *file, void *__fh, struct v4l2_fmtdesc *fd) { - enum v4l2_buf_type type = fd->type; - int index = fd->index; - - dprintk("format index = %d\n", index); - - if ((fd->index < 0) || - (fd->index >= VINO_DATA_FMT_COUNT)) + dprintk("format index = %d\n", fd->index); + + if (fd->index >= VINO_DATA_FMT_COUNT) return -EINVAL; - dprintk("format name = %s\n", - vino_data_formats[index].description); - - memset(fd, 0, sizeof(struct v4l2_fmtdesc)); - fd->index = index; - fd->type = type; - fd->pixelformat = vino_data_formats[index].pixelformat; - strcpy(fd->description, vino_data_formats[index].description); + dprintk("format name = %s\n", vino_data_formats[fd->index].description); + + fd->pixelformat = vino_data_formats[fd->index].pixelformat; + strcpy(fd->description, vino_data_formats[fd->index].description); return 0; } @@ -3331,28 +3323,18 @@ static int vino_g_parm(struct file *file { struct vino_channel_settings *vcs = video_drvdata(file); unsigned long flags; - - switch (sp->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: { - struct v4l2_captureparm *cp = &sp->parm.capture; - memset(cp, 0, sizeof(struct v4l2_captureparm)); - - cp->capability = V4L2_CAP_TIMEPERFRAME; - cp->timeperframe.numerator = 1; - - spin_lock_irqsave(&vino_drvdata->input_lock, flags); - - cp->timeperframe.denominator = vcs->fps; - - spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); - - // TODO: cp->readbuffers = xxx; - break; - } - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - default: - return -EINVAL; - } + struct v4l2_captureparm *cp = &sp->parm.capture; + + cp->capability = V4L2_CAP_TIMEPERFRAME; + cp->timeperframe.numerator = 1; + + spin_lock_irqsave(&vino_drvdata->input_lock, flags); + + cp->timeperframe.denominator = vcs->fps; + + spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); + + /* TODO: cp->readbuffers = xxx; */ return 0; } @@ -3362,31 +3344,20 @@ static int vino_s_parm(struct file *file { struct vino_channel_settings *vcs = video_drvdata(file); unsigned long flags; - - switch (sp->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: { - struct v4l2_captureparm *cp = &sp->parm.capture; - - spin_lock_irqsave(&vino_drvdata->input_lock, flags); - - if ((cp->timeperframe.numerator == 0) || - (cp->timeperframe.denominator == 0)) { - /* reset framerate */ - vino_set_default_framerate(vcs); - } else { - vino_set_framerate(vcs, cp->timeperframe.denominator / - cp->timeperframe.numerator); - } - - spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); - - // TODO: set buffers according to cp->readbuffers - break; - } - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - default: - return -EINVAL; - } + struct v4l2_captureparm *cp = &sp->parm.capture; + + spin_lock_irqsave(&vino_drvdata->input_lock, flags); + + if ((cp->timeperframe.numerator == 0) || + (cp->timeperframe.denominator == 0)) { + /* reset framerate */ + vino_set_default_framerate(vcs); + } else { + vino_set_framerate(vcs, cp->timeperframe.denominator / + cp->timeperframe.numerator); + } + + spin_unlock_irqrestore(&vino_drvdata->input_lock, flags); return 0; } @@ -3395,42 +3366,35 @@ static int vino_reqbufs(struct file *fil struct v4l2_requestbuffers *rb) { struct vino_channel_settings *vcs = video_drvdata(file); + if (vcs->reading) return -EBUSY; - switch (rb->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: { - // TODO: check queue type - if (rb->memory != V4L2_MEMORY_MMAP) { - dprintk("type not mmap\n"); - return -EINVAL; - } - - dprintk("count = %d\n", rb->count); - if (rb->count > 0) { - if (vino_is_capturing(vcs)) { - dprintk("busy, capturing\n"); - return -EBUSY; - } - - if (vino_queue_has_mapped_buffers(&vcs->fb_queue)) { - dprintk("busy, buffers still mapped\n"); - return -EBUSY; - } else { - vcs->streaming = 0; - vino_queue_free(&vcs->fb_queue); - vino_queue_init(&vcs->fb_queue, &rb->count); - } + /* TODO: check queue type */ + if (rb->memory != V4L2_MEMORY_MMAP) { + dprintk("type not mmap\n"); + return -EINVAL; + } + + dprintk("count = %d\n", rb->count); + if (rb->count > 0) { + if (vino_is_capturing(vcs)) { + dprintk("busy, capturing\n"); + return -EBUSY; + } + + if (vino_queue_has_mapped_buffers(&vcs->fb_queue)) { + dprintk("busy, buffers still mapped\n"); + return -EBUSY; } else { vcs->streaming = 0; - vino_capture_stop(vcs); vino_queue_free(&vcs->fb_queue); - } - break; - } - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - default: - return -EINVAL; + vino_queue_init(&vcs->fb_queue, &rb->count); + } + } else { + vcs->streaming = 0; + vino_capture_stop(vcs); + vino_queue_free(&vcs->fb_queue); } return 0; @@ -3478,34 +3442,26 @@ static int vino_querybuf(struct file *fi struct v4l2_buffer *b) { struct vino_channel_settings *vcs = video_drvdata(file); + struct vino_framebuffer *fb; + if (vcs->reading) return -EBUSY; - switch (b->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: { - struct vino_framebuffer *fb; - - // TODO: check queue type - if (b->index >= vino_queue_get_length(&vcs->fb_queue)) { - dprintk("invalid index = %d\n", - b->index); - return -EINVAL; - } - - fb = vino_queue_get_buffer(&vcs->fb_queue, - b->index); - if (fb == NULL) { - dprintk("vino_queue_get_buffer() failed"); - return -EINVAL; - } - - vino_v4l2_get_buffer_status(vcs, fb, b); - break; - } - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - default: + /* TODO: check queue type */ + if (b->index >= vino_queue_get_length(&vcs->fb_queue)) { + dprintk("invalid index = %d\n", + b->index); return -EINVAL; } + + fb = vino_queue_get_buffer(&vcs->fb_queue, + b->index); + if (fb == NULL) { + dprintk("vino_queue_get_buffer() failed"); + return -EINVAL; + } + + vino_v4l2_get_buffer_status(vcs, fb, b); return 0; } @@ -3514,36 +3470,28 @@ static int vino_qbuf(struct file *file, struct v4l2_buffer *b) { struct vino_channel_settings *vcs = video_drvdata(file); + struct vino_framebuffer *fb; + int ret; + if (vcs->reading) return -EBUSY; - switch (b->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: { - struct vino_framebuffer *fb; - int ret; - - // TODO: check queue type - if (b->memory != V4L2_MEMORY_MMAP) { - dprintk("type not mmap\n"); - return -EINVAL; - } - - fb = vino_capture_enqueue(vcs, b->index); - if (fb == NULL) - return -EINVAL; - - vino_v4l2_get_buffer_status(vcs, fb, b); - - if (vcs->streaming) { - ret = vino_capture_next(vcs, 1); - if (ret) - return ret; - } - break; - } - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - default: + /* TODO: check queue type */ + if (b->memory != V4L2_MEMORY_MMAP) { + dprintk("type not mmap\n"); return -EINVAL; + } + + fb = vino_capture_enqueue(vcs, b->index); + if (fb == NULL) + return -EINVAL; + + vino_v4l2_get_buffer_status(vcs, fb, b); + + if (vcs->streaming) { + ret = vino_capture_next(vcs, 1); + if (ret) + return ret; } return 0; @@ -3554,73 +3502,63 @@ static int vino_dqbuf(struct file *file, { struct vino_channel_settings *vcs = video_drvdata(file); unsigned int nonblocking = file->f_flags & O_NONBLOCK; + struct vino_framebuffer *fb; + unsigned int incoming, outgoing; + int err; + if (vcs->reading) return -EBUSY; - switch (b->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: { - struct vino_framebuffer *fb; - unsigned int incoming, outgoing; - int err; - - // TODO: check queue type - - err = vino_queue_get_incoming(&vcs->fb_queue, &incoming); + /* TODO: check queue type */ + + err = vino_queue_get_incoming(&vcs->fb_queue, &incoming); + if (err) { + dprintk("vino_queue_get_incoming() failed\n"); + return -EINVAL; + } + err = vino_queue_get_outgoing(&vcs->fb_queue, &outgoing); + if (err) { + dprintk("vino_queue_get_outgoing() failed\n"); + return -EINVAL; + } + + dprintk("incoming = %d, outgoing = %d\n", incoming, outgoing); + + if (outgoing == 0) { + if (incoming == 0) { + dprintk("no incoming or outgoing buffers\n"); + return -EINVAL; + } + if (nonblocking) { + dprintk("non-blocking I/O was selected and " + "there are no buffers to dequeue\n"); + return -EAGAIN; + } + + err = vino_wait_for_frame(vcs); if (err) { - dprintk("vino_queue_get_incoming() failed\n"); - return -EINVAL; - } - err = vino_queue_get_outgoing(&vcs->fb_queue, &outgoing); - if (err) { - dprintk("vino_queue_get_outgoing() failed\n"); - return -EINVAL; - } - - dprintk("incoming = %d, outgoing = %d\n", incoming, outgoing); - - if (outgoing == 0) { - if (incoming == 0) { - dprintk("no incoming or outgoing buffers\n"); - return -EINVAL; - } - if (nonblocking) { - dprintk("non-blocking I/O was selected and " - "there are no buffers to dequeue\n"); - return -EAGAIN; - } - err = vino_wait_for_frame(vcs); if (err) { - err = vino_wait_for_frame(vcs); - if (err) { - /* interrupted or - * no frames captured because - * of frame skipping */ - // vino_capture_failed(vcs); - return -EIO; - } + /* interrupted or no frames captured because of + * frame skipping */ + /* vino_capture_failed(vcs); */ + return -EIO; } } - - fb = vino_queue_remove(&vcs->fb_queue, &b->index); - if (fb == NULL) { - dprintk("vino_queue_remove() failed\n"); - return -EINVAL; - } - - err = vino_check_buffer(vcs, fb); - - vino_v4l2_get_buffer_status(vcs, fb, b); - - if (err) - return -EIO; - - break; - } - case V4L2_BUF_TYPE_VIDEO_OVERLAY: - default: + } + + fb = vino_queue_remove(&vcs->fb_queue, &b->index); + if (fb == NULL) { + dprintk("vino_queue_remove() failed\n"); return -EINVAL; } + + err = vino_check_buffer(vcs, fb); + + vino_v4l2_get_buffer_status(vcs, fb, b); + + if (err) + return -EIO; return 0; } diff -r ce3000494981 -r db89ef4fec56 linux/drivers/media/video/zr364xx.c --- a/linux/drivers/media/video/zr364xx.c Sun Mar 29 05:42:13 2009 -0300 +++ b/linux/drivers/media/video/zr364xx.c Sun Mar 29 05:49:03 2009 -0300 @@ -427,7 +427,6 @@ static int zr364xx_vidioc_querycap(struc static int zr364xx_vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { - memset(cap, 0, sizeof(*cap)); strcpy(cap->driver, DRIVER_DESC); cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE; return 0; @@ -438,8 +437,6 @@ static int zr364xx_vidioc_enum_input(str { if (i->index != 0) return -EINVAL; - memset(i, 0, sizeof(*i)); - i->index = 0; strcpy(i->name, DRIVER_DESC " Camera"); i->type = V4L2_INPUT_TYPE_CAMERA; return 0; @@ -531,11 +528,6 @@ static int zr364xx_vidioc_enum_fmt_vid_c { if (f->index > 0) return -EINVAL; - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - memset(f, 0, sizeof(*f)); - f->index = 0; - f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; f->flags = V4L2_FMT_FLAG_COMPRESSED; strcpy(f->description, "JPEG"); f->pixelformat = V4L2_PIX_FMT_JPEG; @@ -552,8 +544,6 @@ static int zr364xx_vidioc_try_fmt_vid_ca return -ENODEV; cam = video_get_drvdata(vdev); - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) return -EINVAL; if (f->fmt.pix.field != V4L2_FIELD_ANY && @@ -579,10 +569,6 @@ static int zr364xx_vidioc_g_fmt_vid_cap( return -ENODEV; cam = video_get_drvdata(vdev); - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format)); - f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; f->fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG; f->fmt.pix.field = V4L2_FIELD_NONE; f->fmt.pix.width = cam->width; @@ -604,8 +590,6 @@ static int zr364xx_vidioc_s_fmt_vid_cap( return -ENODEV; cam = video_get_drvdata(vdev); - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) return -EINVAL; if (f->fmt.pix.field != V4L2_FIELD_ANY && diff -r ce3000494981 -r db89ef4fec56 v4l/Makefile --- a/v4l/Makefile Sun Mar 29 05:42:13 2009 -0300 +++ b/v4l/Makefile Sun Mar 29 05:49:03 2009 -0300 @@ -240,7 +240,8 @@ ifneq ($(DIR),) -e ' elsif (/^PATCHLEVEL\s*=\s*(\d+)/){ $$level=$$1; }' \ -e ' elsif (/^SUBLEVEL\s*=\s*(\d+)/){ $$sublevel=$$1; }' \ -e ' elsif (/^EXTRAVERSION\s*=\s*(\S+)\n/){ $$extra=$$1; }' \ - -e ' elsif (/^KERNELSRC\s*:=\s*(\S.*)\n/){ $$o=$$d; $$d=$$1; goto S; }' \ + -e ' elsif (/^KERNELSRC\s*:=\s*(\S.*)\n/ || /^MAKEARGS\s*:=\s*-C\s*(\S.*)\n/)' \ + -e ' { $$o=$$d; $$d=$$1; goto S; }' \ -e '};' \ -e 'printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s%s\n",' \ -e ' $$version,$$level,$$sublevel,$$version,$$level,$$sublevel,$$extra);' \ --- Patch is available at: http://linuxtv.org/hg/v4l-dvb/rev/db89ef4fec56541619424d818e5a316dd434eb48 _______________________________________________ linuxtv-commits mailing list linuxtv-commits@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits