From: Hans de Goede Date: Fri, 28 May 2010 08:31:11 +0000 (+0200) Subject: libv4l1: Remove code duplication VIDIOCSCHAN X-Git-Tag: v4l-utils-0.8.1~44 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62b24d6588fcb79b65118c2d1a2590445dc27495;p=platform%2Fupstream%2Fv4l-utils.git libv4l1: Remove code duplication VIDIOCSCHAN Signed-off-by: Hans de Goede --- diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c index 9ee4a6d..0a2b9b3 100644 --- a/lib/libv4l1/libv4l1.c +++ b/lib/libv4l1/libv4l1.c @@ -700,14 +700,25 @@ int v4l1_ioctl(int fd, unsigned long int request, ...) case VIDIOCSCHAN: { struct video_channel *chan = arg; - if ((devices[index].flags & V4L1_SUPPORTS_ENUMINPUT) && - (devices[index].flags & V4L1_SUPPORTS_ENUMSTD)) { - - v4l2_std_id sid = 0; + if (devices[index].flags & V4L1_SUPPORTS_ENUMINPUT) { result = v4l2_ioctl(fd, VIDIOC_S_INPUT, &chan->channel); if (result < 0) break; + } else { + /* No ENUMINPUT support, assume a single input */ + if (chan->channel != 0) { + errno = EINVAL; + result = -1; + break; + } + result = 0; + } + + /* In case of no ENUMSTD support, ignore the norm member of the + channel struct */ + if (devices[index].flags & V4L1_SUPPORTS_ENUMSTD) { + v4l2_std_id sid = 0; switch (chan->norm) { case VIDEO_MODE_PAL: @@ -726,20 +737,6 @@ int v4l1_ioctl(int fd, unsigned long int request, ...) if (sid) result = v4l2_ioctl(fd, VIDIOC_S_STD, &sid); - break; - } - /* In case of no ENUMSTD support, ignore the norm member of the - channel struct */ - if (devices[index].flags & V4L1_SUPPORTS_ENUMINPUT) { - result = v4l2_ioctl(fd, VIDIOC_S_INPUT, &chan->channel); - break; - } - /* No ENUMINPUT support, fake it (assume its a Camera in this case) */ - if (chan->channel == 0) { - result = 0; - } else { - errno = EINVAL; - result = -1; } break; }