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: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
2509e1cb33
commit
4f5a7444ba
@@ -3102,22 +3102,14 @@ out:
|
|||||||
static int vino_enum_fmt_vid_cap(struct file *file, void *__fh,
|
static int vino_enum_fmt_vid_cap(struct file *file, void *__fh,
|
||||||
struct v4l2_fmtdesc *fd)
|
struct v4l2_fmtdesc *fd)
|
||||||
{
|
{
|
||||||
enum v4l2_buf_type type = fd->type;
|
dprintk("format index = %d\n", fd->index);
|
||||||
int index = fd->index;
|
|
||||||
|
|
||||||
dprintk("format index = %d\n", index);
|
if (fd->index >= VINO_DATA_FMT_COUNT)
|
||||||
|
|
||||||
if ((fd->index < 0) ||
|
|
||||||
(fd->index >= VINO_DATA_FMT_COUNT))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
dprintk("format name = %s\n",
|
dprintk("format name = %s\n", vino_data_formats[fd->index].description);
|
||||||
vino_data_formats[index].description);
|
|
||||||
|
|
||||||
memset(fd, 0, sizeof(struct v4l2_fmtdesc));
|
fd->pixelformat = vino_data_formats[fd->index].pixelformat;
|
||||||
fd->index = index;
|
strcpy(fd->description, vino_data_formats[fd->index].description);
|
||||||
fd->type = type;
|
|
||||||
fd->pixelformat = vino_data_formats[index].pixelformat;
|
|
||||||
strcpy(fd->description, vino_data_formats[index].description);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3327,11 +3319,7 @@ static int vino_g_parm(struct file *file, void *__fh,
|
|||||||
{
|
{
|
||||||
struct vino_channel_settings *vcs = video_drvdata(file);
|
struct vino_channel_settings *vcs = video_drvdata(file);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
switch (sp->type) {
|
|
||||||
case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
|
|
||||||
struct v4l2_captureparm *cp = &sp->parm.capture;
|
struct v4l2_captureparm *cp = &sp->parm.capture;
|
||||||
memset(cp, 0, sizeof(struct v4l2_captureparm));
|
|
||||||
|
|
||||||
cp->capability = V4L2_CAP_TIMEPERFRAME;
|
cp->capability = V4L2_CAP_TIMEPERFRAME;
|
||||||
cp->timeperframe.numerator = 1;
|
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);
|
spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
|
||||||
|
|
||||||
// TODO: cp->readbuffers = xxx;
|
/* TODO: cp->readbuffers = xxx; */
|
||||||
break;
|
|
||||||
}
|
|
||||||
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -3358,9 +3340,6 @@ static int vino_s_parm(struct file *file, void *__fh,
|
|||||||
{
|
{
|
||||||
struct vino_channel_settings *vcs = video_drvdata(file);
|
struct vino_channel_settings *vcs = video_drvdata(file);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
switch (sp->type) {
|
|
||||||
case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
|
|
||||||
struct v4l2_captureparm *cp = &sp->parm.capture;
|
struct v4l2_captureparm *cp = &sp->parm.capture;
|
||||||
|
|
||||||
spin_lock_irqsave(&vino_drvdata->input_lock, flags);
|
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);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3391,12 +3362,11 @@ static int vino_reqbufs(struct file *file, void *__fh,
|
|||||||
struct v4l2_requestbuffers *rb)
|
struct v4l2_requestbuffers *rb)
|
||||||
{
|
{
|
||||||
struct vino_channel_settings *vcs = video_drvdata(file);
|
struct vino_channel_settings *vcs = video_drvdata(file);
|
||||||
|
|
||||||
if (vcs->reading)
|
if (vcs->reading)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
switch (rb->type) {
|
/* TODO: check queue type */
|
||||||
case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
|
|
||||||
// TODO: check queue type
|
|
||||||
if (rb->memory != V4L2_MEMORY_MMAP) {
|
if (rb->memory != V4L2_MEMORY_MMAP) {
|
||||||
dprintk("type not mmap\n");
|
dprintk("type not mmap\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -3422,12 +3392,6 @@ static int vino_reqbufs(struct file *file, void *__fh,
|
|||||||
vino_capture_stop(vcs);
|
vino_capture_stop(vcs);
|
||||||
vino_queue_free(&vcs->fb_queue);
|
vino_queue_free(&vcs->fb_queue);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -3474,14 +3438,12 @@ static int vino_querybuf(struct file *file, void *__fh,
|
|||||||
struct v4l2_buffer *b)
|
struct v4l2_buffer *b)
|
||||||
{
|
{
|
||||||
struct vino_channel_settings *vcs = video_drvdata(file);
|
struct vino_channel_settings *vcs = video_drvdata(file);
|
||||||
|
struct vino_framebuffer *fb;
|
||||||
|
|
||||||
if (vcs->reading)
|
if (vcs->reading)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
switch (b->type) {
|
/* TODO: check queue 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)) {
|
if (b->index >= vino_queue_get_length(&vcs->fb_queue)) {
|
||||||
dprintk("invalid index = %d\n",
|
dprintk("invalid index = %d\n",
|
||||||
b->index);
|
b->index);
|
||||||
@@ -3496,12 +3458,6 @@ static int vino_querybuf(struct file *file, void *__fh,
|
|||||||
}
|
}
|
||||||
|
|
||||||
vino_v4l2_get_buffer_status(vcs, fb, b);
|
vino_v4l2_get_buffer_status(vcs, fb, b);
|
||||||
break;
|
|
||||||
}
|
|
||||||
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -3510,15 +3466,13 @@ static int vino_qbuf(struct file *file, void *__fh,
|
|||||||
struct v4l2_buffer *b)
|
struct v4l2_buffer *b)
|
||||||
{
|
{
|
||||||
struct vino_channel_settings *vcs = video_drvdata(file);
|
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;
|
struct vino_framebuffer *fb;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// TODO: check queue type
|
if (vcs->reading)
|
||||||
|
return -EBUSY;
|
||||||
|
|
||||||
|
/* TODO: check queue type */
|
||||||
if (b->memory != V4L2_MEMORY_MMAP) {
|
if (b->memory != V4L2_MEMORY_MMAP) {
|
||||||
dprintk("type not mmap\n");
|
dprintk("type not mmap\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -3535,12 +3489,6 @@ static int vino_qbuf(struct file *file, void *__fh,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -3550,16 +3498,14 @@ static int vino_dqbuf(struct file *file, void *__fh,
|
|||||||
{
|
{
|
||||||
struct vino_channel_settings *vcs = video_drvdata(file);
|
struct vino_channel_settings *vcs = video_drvdata(file);
|
||||||
unsigned int nonblocking = file->f_flags & O_NONBLOCK;
|
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;
|
struct vino_framebuffer *fb;
|
||||||
unsigned int incoming, outgoing;
|
unsigned int incoming, outgoing;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
// TODO: check queue type
|
if (vcs->reading)
|
||||||
|
return -EBUSY;
|
||||||
|
|
||||||
|
/* TODO: check queue type */
|
||||||
|
|
||||||
err = vino_queue_get_incoming(&vcs->fb_queue, &incoming);
|
err = vino_queue_get_incoming(&vcs->fb_queue, &incoming);
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -3589,10 +3535,9 @@ static int vino_dqbuf(struct file *file, void *__fh,
|
|||||||
if (err) {
|
if (err) {
|
||||||
err = vino_wait_for_frame(vcs);
|
err = vino_wait_for_frame(vcs);
|
||||||
if (err) {
|
if (err) {
|
||||||
/* interrupted or
|
/* interrupted or no frames captured because of
|
||||||
* no frames captured because
|
* frame skipping */
|
||||||
* of frame skipping */
|
/* vino_capture_failed(vcs); */
|
||||||
// vino_capture_failed(vcs);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3611,13 +3556,6 @@ static int vino_dqbuf(struct file *file, void *__fh,
|
|||||||
if (err)
|
if (err)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user