Skip to contentSkip to conversation

media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL

RFC PATCH In review Gergő Köteles 2 participants 5 messages Aug 3, 2023 – Aug 4, 2023

Subsystems (2)
lore
Share & tools
lore
#2 lore raw

RFC PATCH 2/2 media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL

In reply to Gergő Köteles

Logitech Streamcam can be mounted in 'portrait mode' as well. It reports the current roll (-90, 0, 90, 180) with UVC_CT_ROLL_ABSOLUTE_CONTROL.

Map UVC_CT_ROLL_ABSOLUTE_CONTROL to V4L2_CID_ROLL_ABSOLUTE to make it available to userspace.

---
 drivers/media/usb/uvc/uvc_ctrl.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/media/usb/uvc/uvc_ctrl.c +9 -0
index 5e9d3da862dd..2801a1ee04a2 100644
@@ -748,6 +748,15 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = {
 		.v4l2_type	= V4L2_CTRL_TYPE_BOOLEAN,
 		.data_type	= UVC_CTRL_DATA_TYPE_BOOLEAN,
 	},
+	{
+		.id		= V4L2_CID_ROLL_ABSOLUTE,
+		.entity		= UVC_GUID_UVC_CAMERA,
+		.selector	= UVC_CT_ROLL_ABSOLUTE_CONTROL,
+		.size		= 16,
+		.offset		= 0,
+		.v4l2_type	= V4L2_CTRL_TYPE_INTEGER,
+		.data_type	= UVC_CTRL_DATA_TYPE_SIGNED,
+	},
 };
 
 const struct uvc_control_mapping uvc_ctrl_power_line_mapping_limited = {
Signature · 1 line
2.41.0
#1 lore raw

RFC PATCH 1/2 media: v4l2: ctrls: Add ROLL_ABSOLUTE control

In reply to Gergő Köteles

Add V4L2_CID_ROLL_ABSOLUTE as an integer control to retrieve and set the camera roll in degrees, and its documentation.

---
 Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst | 5 +++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c                  | 1 +
 include/uapi/linux/v4l2-controls.h                         | 2 ++
 3 files changed, 8 insertions(+)
Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst +5 -0
index cdc515c60468..81bc31a4bf79 100644
@@ -672,3 +672,8 @@ enum v4l2_scene_mode -
 
     As modes differ for each sensor, menu items are not standardized by this
     control and are left to the programmer.
+
+``V4L2_CID_ROLL_ABSOLUTE (integer)``
+    This control describes the camera rotation along the image viewing axis in
+    degrees. Values range from -180 to +180, the default is zero. Positive
+    values rotate the camera clockwise, negative values counter-clockwise.
drivers/media/v4l2-core/v4l2-ctrls-defs.c +1 -0
index 8696eb1cdd61..0e8af56cb2a2 100644
@@ -1086,6 +1086,7 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_CAMERA_ORIENTATION:	return "Camera Orientation";
 	case V4L2_CID_CAMERA_SENSOR_ROTATION:	return "Camera Sensor Rotation";
 	case V4L2_CID_HDR_SENSOR_MODE:		return "HDR Sensor Mode";
+	case V4L2_CID_ROLL_ABSOLUTE:		return "Roll, Absolute";
 
 	/* FM Radio Modulator controls */
 	/* Keep the order of the 'case's the same as in v4l2-controls.h! */
include/uapi/linux/v4l2-controls.h +2 -0
index c3604a0a3e30..5131711ea873 100644
@@ -1075,6 +1075,8 @@ enum v4l2_auto_focus_range {
 
 #define V4L2_CID_HDR_SENSOR_MODE		(V4L2_CID_CAMERA_CLASS_BASE+36)
 
+#define V4L2_CID_ROLL_ABSOLUTE			(V4L2_CID_CAMERA_CLASS_BASE+37)
+
 /* FM Modulator class control IDs */
 
 #define V4L2_CID_FM_TX_CLASS_BASE		(V4L2_CTRL_CLASS_FM_TX | 0x900)
Signature · 1 line
2.41.0
#0 lore raw

cover media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL

Hi,

Logitech Streamcam can be mounted in 'portrait mode' as well. It reports the current roll (-90, 0, 90, 180) with UVC_CT_ROLL_ABSOLUTE_CONTROL.

This RFC defines V4L2_CID_ROLL_ABSOLUTE, and maps UVC_CT_ROLL_ABSOLUTE_CONTROL to make it available to userspace.
Then, the userspace can rotate the stream based on the roll.

Is it better to use V4L2_CID_CAMERA_SENSOR_ROTATION for this? The value set matches that control.
If yes, is it worth mapping UVC_CT_ROLL_ABSOLUTE_CONTROL to V4L2_CID_CAMERA_SENSOR_ROTATION for this camera only?

Any feedback is greately appreciated.

Gergő Köteles (2):
media: v4l2: ctrls: Add ROLL_ABSOLUTE control
media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL

 .../userspace-api/media/v4l/ext-ctrls-camera.rst         | 5 +++++
 drivers/media/usb/uvc/uvc_ctrl.c                         | 9 +++++++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c                | 1 +
 include/uapi/linux/v4l2-controls.h                       | 2 ++
 4 files changed, 17 insertions(+)

base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5

Signature · 1 line
2.41.0
#3 lore raw

Hi Gergő,

Interesting work! I would guess that there are a lot of cameras with an accelerometer or gyroscope that could report the rotation.

Quoted 10 lines · Gergő Köteles

Hi,

Logitech Streamcam can be mounted in 'portrait mode' as well. It reports the current roll (-90, 0, 90, 180) with UVC_CT_ROLL_ABSOLUTE_CONTROL.

This RFC defines V4L2_CID_ROLL_ABSOLUTE, and maps UVC_CT_ROLL_ABSOLUTE_CONTROL to make it available to userspace.
Then, the userspace can rotate the stream based on the roll.

Should we also discuss pitch and yaw while we are at it?

As far as I know there are controls to set pan and tilt of a PTZ camera, but there are no controls that report those angles.

Quoted 1 line

Is it better to use V4L2_CID_CAMERA_SENSOR_ROTATION for this?

IMHO that would make sense.

Best regards,
Michael

Quoted 19 lines

The value set matches that control.
If yes, is it worth mapping UVC_CT_ROLL_ABSOLUTE_CONTROL to V4L2_CID_CAMERA_SENSOR_ROTATION for this camera only?

Any feedback is greately appreciated.

Gergő Köteles (2):
media: v4l2: ctrls: Add ROLL_ABSOLUTE control
media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL

 .../userspace-api/media/v4l/ext-ctrls-camera.rst         | 5 +++++
 drivers/media/usb/uvc/uvc_ctrl.c                         | 9 +++++++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c                | 1 +
 include/uapi/linux/v4l2-controls.h                       | 2 ++
 4 files changed, 17 insertions(+)

base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5

#4 lore raw

Hi Michael,

Quoted 5 lines · Michael Riesch

Hi Gergő,

Interesting work! I would guess that there are a lot of cameras with an accelerometer or gyroscope that could report the rotation.

I think only the Streamcam in the UVC world, but who knows. :)

Quoted 7 lines · Gergő Köteles
Quoted 6 lines

Hi,

Logitech Streamcam can be mounted in 'portrait mode' as well. It reports the current roll (-90, 0, 90, 180) with UVC_CT_ROLL_ABSOLUTE_CONTROL.

Quoted 7 lines
Quoted 4 lines

This RFC defines V4L2_CID_ROLL_ABSOLUTE, and maps UVC_CT_ROLL_ABSOLUTE_CONTROL to make it available to userspace.
Then, the userspace can rotate the stream based on the roll.

Should we also discuss pitch and yaw while we are at it?

They are there with V4L2_CID_PAN_ABSOLUTE and V4L2_CID_TILT_ABSOLUTE.

Quoted 3 lines

As far as I know there are controls to set pan and tilt of a PTZ camera, but there are no controls that report those angles.

Aren't real PTZ cameras using the CT_PANTILT_ABSOLUTE_CONTROL for panning and tilting? Or just to move the crop window?

Quoted 26 lines
Quoted 1 line

Is it better to use V4L2_CID_CAMERA_SENSOR_ROTATION for this?

IMHO that would make sense.

Best regards,
Michael

Quoted 19 lines

The value set matches that control.
If yes, is it worth mapping UVC_CT_ROLL_ABSOLUTE_CONTROL to V4L2_CID_CAMERA_SENSOR_ROTATION for this camera only?

Any feedback is greately appreciated.

Gergő Köteles (2):
media: v4l2: ctrls: Add ROLL_ABSOLUTE control
media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL

 .../userspace-api/media/v4l/ext-ctrls-camera.rst         | 5 +++++
 drivers/media/usb/uvc/uvc_ctrl.c                         | 9 +++++++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c                | 1 +
 include/uapi/linux/v4l2-controls.h                       | 2 ++
 4 files changed, 17 insertions(+)

base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5