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

V4L/DVB (11266): vino: Remove code for things already done by video_ioctl2

The v4l2-ioctl core only allows buffer types for which the corresponding
->vidioc_try_fmt_xxx() methods are defined to be used in vidioc_(g|s)_parm,
vidioc_(q|dq|query)buf, and vidioc_reqbufs.

Remove buffer type checking from vino_g_parm(), vino_s_parm(),
vino_reqbufs(), vino_querybuf(), vino_qbuf(), and vino_dqbuf().  This
reduced the indent level of the code so a few lines can be wrapped better.
Also fixed the C++ type comments.

The v4l2-ioctl core also provides structs that have been pre-zeroed for all
fields that driver is supposed to fill in, so remove zeroing code from
vino_enum_fmt_vid_cap().  Also, the format index is unsigned so it's not
necessary to check if it's less than zero.
Signed-off-by: default avatarTrent Piepho <xyzzy@speakeasy.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 2509e1cb
......@@ -3102,22 +3102,14 @@ static int vino_s_std(struct file *file, void *__fh,
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", fd->index);
dprintk("format index = %d\n", index);
if ((fd->index < 0) ||
(fd->index >= VINO_DATA_FMT_COUNT))
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;
}
......@@ -3327,11 +3319,7 @@ static int vino_g_parm(struct file *file, void *__fh,
{
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;
......@@ -3342,13 +3330,7 @@ static int vino_g_parm(struct file *file, void *__fh,
spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
// TODO: cp->readbuffers = xxx;
break;
}
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
default:
return -EINVAL;
}
/* TODO: cp->readbuffers = xxx; */
return 0;
}
......@@ -3358,9 +3340,6 @@ static int vino_s_parm(struct file *file, void *__fh,
{
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);
......@@ -3376,14 +3355,6 @@ static int vino_s_parm(struct file *file, void *__fh,
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;
}
return 0;
}
......@@ -3391,12 +3362,11 @@ static int vino_reqbufs(struct file *file, void *__fh,
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
/* TODO: check queue type */
if (rb->memory != V4L2_MEMORY_MMAP) {
dprintk("type not mmap\n");
return -EINVAL;
......@@ -3422,12 +3392,6 @@ static int vino_reqbufs(struct file *file, void *__fh,
vino_capture_stop(vcs);
vino_queue_free(&vcs->fb_queue);
}
break;
}
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
default:
return -EINVAL;
}
return 0;
}
......@@ -3474,14 +3438,12 @@ static int vino_querybuf(struct file *file, void *__fh,
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
/* TODO: check queue type */
if (b->index >= vino_queue_get_length(&vcs->fb_queue)) {
dprintk("invalid index = %d\n",
b->index);
......@@ -3496,12 +3458,6 @@ static int vino_querybuf(struct file *file, void *__fh,
}
vino_v4l2_get_buffer_status(vcs, fb, b);
break;
}
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
default:
return -EINVAL;
}
return 0;
}
......@@ -3510,15 +3466,13 @@ static int vino_qbuf(struct file *file, void *__fh,
struct v4l2_buffer *b)
{
struct vino_channel_settings *vcs = video_drvdata(file);
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 (vcs->reading)
return -EBUSY;
/* TODO: check queue type */
if (b->memory != V4L2_MEMORY_MMAP) {
dprintk("type not mmap\n");
return -EINVAL;
......@@ -3535,12 +3489,6 @@ static int vino_qbuf(struct file *file, void *__fh,
if (ret)
return ret;
}
break;
}
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
default:
return -EINVAL;
}
return 0;
}
......@@ -3550,16 +3498,14 @@ static int vino_dqbuf(struct file *file, void *__fh,
{
struct vino_channel_settings *vcs = video_drvdata(file);
unsigned int nonblocking = file->f_flags & O_NONBLOCK;
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
if (vcs->reading)
return -EBUSY;
/* TODO: check queue type */
err = vino_queue_get_incoming(&vcs->fb_queue, &incoming);
if (err) {
......@@ -3589,10 +3535,9 @@ static int vino_dqbuf(struct file *file, void *__fh,
if (err) {
err = vino_wait_for_frame(vcs);
if (err) {
/* interrupted or
* no frames captured because
* of frame skipping */
// vino_capture_failed(vcs);
/* interrupted or no frames captured because of
* frame skipping */
/* vino_capture_failed(vcs); */
return -EIO;
}
}
......@@ -3611,13 +3556,6 @@ static int vino_dqbuf(struct file *file, void *__fh,
if (err)
return -EIO;
break;
}
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
default:
return -EINVAL;
}
return 0;
}
......
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