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);
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,
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;
}
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) /