Commit 9a3bf8d9 authored by Daniel Fenner's avatar Daniel Fenner Committed by Commit Bot

Add support for Logitech PTZ Pro 2 to webcam_private api.

The camera supports absolute positioning via an extension unit (as opposed to the camera terminal unit as many other cameras do). So before issuing a v4l2 command to do absolute positioning we map the command to that extension unit. In case the camera does not implement that extension unit (e.g. all non-logitech cameras) this mapping just silently fails.

BUG: 826296
Change-Id: I939de844375efc6b8a756efe0877cb4bf0dc9a56
Reviewed-on: https://chromium-review.googlesource.com/982056
Commit-Queue: Daniel Fenner <dfenner@google.com>
Reviewed-by: default avatarZachary Kuznia <zork@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548398}
parent 97544486
...@@ -35,17 +35,40 @@ const uvc_menu_info kLogitechCmdMenu[] = { ...@@ -35,17 +35,40 @@ const uvc_menu_info kLogitechCmdMenu[] = {
}; };
const uvc_xu_control_mapping kLogitechCmdMapping = { const uvc_xu_control_mapping kLogitechCmdMapping = {
V4L2_CID_PANTILT_CMD, V4L2_CID_PANTILT_CMD,
"Pan/Tilt Go", "Pan/Tilt Go",
UVC_GUID_LOGITECH_CC3000E_MOTORS, UVC_GUID_LOGITECH_CC3000E_MOTORS,
LOGITECH_MOTORCONTROL_PANTILT_CMD, LOGITECH_MOTORCONTROL_PANTILT_CMD,
8, 8,
0, 0,
V4L2_CTRL_TYPE_MENU, V4L2_CTRL_TYPE_MENU,
UVC_CTRL_DATA_TYPE_ENUM, UVC_CTRL_DATA_TYPE_ENUM,
const_cast<uvc_menu_info*>(&kLogitechCmdMenu[0]), const_cast<uvc_menu_info*>(&kLogitechCmdMenu[0]),
arraysize(kLogitechCmdMenu), arraysize(kLogitechCmdMenu),
}; };
const uvc_xu_control_mapping kLogitechPanAbsoluteMapping = {
V4L2_CID_PAN_ABSOLUTE,
"Pan (Absolute)",
UVC_GUID_LOGITECH_CC3000E_MOTORS,
12,
32,
0,
V4L2_CTRL_TYPE_INTEGER,
UVC_CTRL_DATA_TYPE_SIGNED,
};
const uvc_xu_control_mapping kLogitechTiltAbsoluteMapping = {
V4L2_CID_TILT_ABSOLUTE,
"Tilt (Absolute)",
UVC_GUID_LOGITECH_CC3000E_MOTORS,
12,
32,
32,
V4L2_CTRL_TYPE_INTEGER,
UVC_CTRL_DATA_TYPE_SIGNED,
};
} // namespace } // namespace
namespace extensions { namespace extensions {
...@@ -72,6 +95,15 @@ bool V4L2Webcam::EnsureLogitechCommandsMapped() { ...@@ -72,6 +95,15 @@ bool V4L2Webcam::EnsureLogitechCommandsMapped() {
} }
bool V4L2Webcam::SetWebcamParameter(int fd, uint32_t control_id, int value) { bool V4L2Webcam::SetWebcamParameter(int fd, uint32_t control_id, int value) {
// Try to map the V4L2 control to the Logitech extension unit. If the
// connected camera does not implement these extension unit this will just
// silently fail and the standard camera terminal controls will be used.
if (control_id == V4L2_CID_PAN_ABSOLUTE) {
HANDLE_EINTR(ioctl(fd, UVCIOC_CTRL_MAP, &kLogitechPanAbsoluteMapping));
} else if (control_id == V4L2_CID_TILT_ABSOLUTE) {
HANDLE_EINTR(ioctl(fd, UVCIOC_CTRL_MAP, &kLogitechTiltAbsoluteMapping));
}
struct v4l2_control v4l2_ctrl = {control_id, value}; struct v4l2_control v4l2_ctrl = {control_id, value};
int res = HANDLE_EINTR(ioctl(fd, VIDIOC_S_CTRL, &v4l2_ctrl)) >= 0; int res = HANDLE_EINTR(ioctl(fd, VIDIOC_S_CTRL, &v4l2_ctrl)) >= 0;
return res >= 0; return res >= 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment