diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2014-09-03 20:47:48 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-09-21 19:24:42 -0400 |
commit | 3ea375239ca06014b8b421ab1d73d6628d22036f (patch) | |
tree | 71dbfe6ffcf21db6ca59d6b408ba76ec4976ceae /drivers/media/usb/uvc/uvc_ctrl.c | |
parent | e3d6eb1c16ef174a8fbbdd40770f5cbace0710e4 (diff) |
[media] v4l: uvcvideo: Add support for pan/tilt speed controls
Map V4L2_CID_TILT_SPEED and V4L2_CID_PAN_SPEED to the standard UVC
CT_PANTILT_RELATIVE_CONTROL terminal control request.
Tested by plugging a Logitech ConferenceCam C3000e USB camera
and controlling pan/tilt from the userspace using the VIDIOC_S_CTRL ioctl.
Verified that it can pan and tilt at the same time in both directions.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Pawel Osciak <posciak@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/usb/uvc/uvc_ctrl.c')
-rw-r--r-- | drivers/media/usb/uvc/uvc_ctrl.c | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 0eb82106d2ff..d2d1755145c8 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c | |||
@@ -309,9 +309,8 @@ static struct uvc_control_info uvc_ctrls[] = { | |||
309 | .selector = UVC_CT_PANTILT_RELATIVE_CONTROL, | 309 | .selector = UVC_CT_PANTILT_RELATIVE_CONTROL, |
310 | .index = 12, | 310 | .index = 12, |
311 | .size = 4, | 311 | .size = 4, |
312 | .flags = UVC_CTRL_FLAG_SET_CUR | UVC_CTRL_FLAG_GET_MIN | 312 | .flags = UVC_CTRL_FLAG_SET_CUR |
313 | | UVC_CTRL_FLAG_GET_MAX | UVC_CTRL_FLAG_GET_RES | 313 | | UVC_CTRL_FLAG_GET_RANGE |
314 | | UVC_CTRL_FLAG_GET_DEF | ||
315 | | UVC_CTRL_FLAG_AUTO_UPDATE, | 314 | | UVC_CTRL_FLAG_AUTO_UPDATE, |
316 | }, | 315 | }, |
317 | { | 316 | { |
@@ -391,6 +390,35 @@ static void uvc_ctrl_set_zoom(struct uvc_control_mapping *mapping, | |||
391 | data[2] = min((int)abs(value), 0xff); | 390 | data[2] = min((int)abs(value), 0xff); |
392 | } | 391 | } |
393 | 392 | ||
393 | static __s32 uvc_ctrl_get_rel_speed(struct uvc_control_mapping *mapping, | ||
394 | __u8 query, const __u8 *data) | ||
395 | { | ||
396 | unsigned int first = mapping->offset / 8; | ||
397 | __s8 rel = (__s8)data[first]; | ||
398 | |||
399 | switch (query) { | ||
400 | case UVC_GET_CUR: | ||
401 | return (rel == 0) ? 0 : (rel > 0 ? data[first+1] | ||
402 | : -data[first+1]); | ||
403 | case UVC_GET_MIN: | ||
404 | return -data[first+1]; | ||
405 | case UVC_GET_MAX: | ||
406 | case UVC_GET_RES: | ||
407 | case UVC_GET_DEF: | ||
408 | default: | ||
409 | return data[first+1]; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | static void uvc_ctrl_set_rel_speed(struct uvc_control_mapping *mapping, | ||
414 | __s32 value, __u8 *data) | ||
415 | { | ||
416 | unsigned int first = mapping->offset / 8; | ||
417 | |||
418 | data[first] = value == 0 ? 0 : (value > 0) ? 1 : 0xff; | ||
419 | data[first+1] = min_t(int, abs(value), 0xff); | ||
420 | } | ||
421 | |||
394 | static struct uvc_control_mapping uvc_ctrl_mappings[] = { | 422 | static struct uvc_control_mapping uvc_ctrl_mappings[] = { |
395 | { | 423 | { |
396 | .id = V4L2_CID_BRIGHTNESS, | 424 | .id = V4L2_CID_BRIGHTNESS, |
@@ -677,6 +705,30 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = { | |||
677 | .data_type = UVC_CTRL_DATA_TYPE_SIGNED, | 705 | .data_type = UVC_CTRL_DATA_TYPE_SIGNED, |
678 | }, | 706 | }, |
679 | { | 707 | { |
708 | .id = V4L2_CID_PAN_SPEED, | ||
709 | .name = "Pan (Speed)", | ||
710 | .entity = UVC_GUID_UVC_CAMERA, | ||
711 | .selector = UVC_CT_PANTILT_RELATIVE_CONTROL, | ||
712 | .size = 16, | ||
713 | .offset = 0, | ||
714 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
715 | .data_type = UVC_CTRL_DATA_TYPE_SIGNED, | ||
716 | .get = uvc_ctrl_get_rel_speed, | ||
717 | .set = uvc_ctrl_set_rel_speed, | ||
718 | }, | ||
719 | { | ||
720 | .id = V4L2_CID_TILT_SPEED, | ||
721 | .name = "Tilt (Speed)", | ||
722 | .entity = UVC_GUID_UVC_CAMERA, | ||
723 | .selector = UVC_CT_PANTILT_RELATIVE_CONTROL, | ||
724 | .size = 16, | ||
725 | .offset = 16, | ||
726 | .v4l2_type = V4L2_CTRL_TYPE_INTEGER, | ||
727 | .data_type = UVC_CTRL_DATA_TYPE_SIGNED, | ||
728 | .get = uvc_ctrl_get_rel_speed, | ||
729 | .set = uvc_ctrl_set_rel_speed, | ||
730 | }, | ||
731 | { | ||
680 | .id = V4L2_CID_PRIVACY, | 732 | .id = V4L2_CID_PRIVACY, |
681 | .name = "Privacy", | 733 | .name = "Privacy", |
682 | .entity = UVC_GUID_UVC_CAMERA, | 734 | .entity = UVC_GUID_UVC_CAMERA, |