This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/v4l-utils.git tree:
Subject: libv4l: Make v4l2_get_control report errors Author: Hans de Goede <[email protected]> Date: Tue Jun 8 10:01:20 2010 +0200 And handle those errors at the places calling v4l2_get_control. Signed-off-by: Hans de Goede <[email protected]> lib/include/libv4l2.h | 4 ++-- lib/libv4l1/libv4l1.c | 36 +++++++++++++++++++++++------------- lib/libv4l2/libv4l2.c | 10 ++++++---- 3 files changed, 31 insertions(+), 19 deletions(-) --- http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=fff9b6a0415c1c60e7c7a7a44cd9d33ae865c9e1 diff --git a/lib/include/libv4l2.h b/lib/include/libv4l2.h index 3ebc781..cc0ab4a 100644 --- a/lib/include/libv4l2.h +++ b/lib/include/libv4l2.h @@ -81,8 +81,8 @@ LIBV4L_PUBLIC int v4l2_munmap(void *_start, size_t length); LIBV4L_PUBLIC int v4l2_set_control(int fd, int cid, int value); /* This function returns a value of 0 - 65535, scaled to from the actual range - of the given v4l control id. when the cid does not exist, could not be - accessed for some reason, or some error occured 0 is returned. */ + of the given v4l control id. When the cid does not exist, or could not be + accessed -1 is returned. */ LIBV4L_PUBLIC int v4l2_get_control(int fd, int cid); diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c index 7f006bb..cb53899 100644 --- a/lib/libv4l1/libv4l1.c +++ b/lib/libv4l1/libv4l1.c @@ -567,14 +567,15 @@ int v4l1_ioctl(int fd, unsigned long int request, ...) case VIDIOCGPICT: { struct video_picture *pic = arg; + int i; - /* If our v4l2 pixformat has no corresponding v4l1 palette, and the - app has not touched the pixformat sofar, try setting a palette which - does (and which we emulate when necessary) so that applications - which just query the current format and then take whatever they get - will work */ + /* If our v4l2 pixformat has no corresponding v4l1 palette, and + the app has not touched the pixformat sofar, try setting a + palette which does (and which we emulate when necessary) so + that applications which just query the current format and + then take whatever they get will work */ if (!(devices[index].flags & V4L1_PIX_FMT_TOUCHED) && - !pixelformat_to_palette(devices[index].v4l2_pixfmt)) + !pixelformat_to_palette(devices[index].v4l2_pixfmt)) v4l1_set_format(index, devices[index].width, devices[index].height, VIDEO_PALETTE_RGB24, @@ -583,15 +584,24 @@ int v4l1_ioctl(int fd, unsigned long int request, ...) devices[index].flags |= V4L1_PIX_FMT_TOUCHED; + memset(pic, 0, sizeof(*pic)); pic->depth = devices[index].depth; pic->palette = devices[index].v4l1_pal; - pic->hue = v4l2_get_control(devices[index].fd, V4L2_CID_HUE); - pic->colour = v4l2_get_control(devices[index].fd, V4L2_CID_SATURATION); - pic->contrast = v4l2_get_control(devices[index].fd, V4L2_CID_CONTRAST); - pic->whiteness = v4l2_get_control(devices[index].fd, - V4L2_CID_WHITENESS); - pic->brightness = v4l2_get_control(devices[index].fd, - V4L2_CID_BRIGHTNESS); + i = v4l2_get_control(devices[index].fd, V4L2_CID_HUE); + if (i >= 0) + pic->hue = i; + i = v4l2_get_control(devices[index].fd, V4L2_CID_SATURATION); + if (i >= 0) + pic->colour = i; + i = v4l2_get_control(devices[index].fd, V4L2_CID_CONTRAST); + if (i >= 0) + pic->contrast = i; + i = v4l2_get_control(devices[index].fd, V4L2_CID_WHITENESS); + if (i >= 0) + pic->whiteness = i; + i = v4l2_get_control(devices[index].fd, V4L2_CID_BRIGHTNESS); + if (i >= 0) + pic->brightness = i; result = 0; break; diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c index 7c595bf..ab85ea7 100644 --- a/lib/libv4l2/libv4l2.c +++ b/lib/libv4l2/libv4l2.c @@ -1418,13 +1418,15 @@ int v4l2_get_control(int fd, int cid) } if (v4lconvert_vidioc_queryctrl(devices[index].convert, &qctrl)) - return 0; + return -1; - if (qctrl.flags & V4L2_CTRL_FLAG_DISABLED) - return 0; + if (qctrl.flags & V4L2_CTRL_FLAG_DISABLED) { + errno = EINVAL; + return -1; + } if (v4lconvert_vidioc_g_ctrl(devices[index].convert, &ctrl)) - return 0; + return -1; return ((ctrl.value - qctrl.minimum) * 65535 + (qctrl.maximum - qctrl.minimum) / 2) / _______________________________________________ linuxtv-commits mailing list [email protected] http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
