* [PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL
@ 2024-06-12 18:31 Gergo Koteles
2024-06-12 18:31 ` [PATCH 1/2] media: v4l2: ctrls: Add ROLL_ABSOLUTE control Gergo Koteles
2024-06-12 18:31 ` [PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergo Koteles
0 siblings, 2 replies; 5+ messages in thread
From: Gergo Koteles @ 2024-06-12 18:31 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Laurent Pinchart
Cc: linux-media, linux-kernel, Gergo Koteles
Hi,
Some new UVC cameras can report whether they are mounted in 'portrait
mode'.
In order to userspace getting to know this, this series maps
UVC_CT_ROLL_ABSOLUTE_CONTROL to V4L2_CID_ROLL_ABSOLUTE.
Tested with Logitech StreamCam and OBSBOT Tiny 2.
Gergo Koteles (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(+)
--
2.45.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] media: v4l2: ctrls: Add ROLL_ABSOLUTE control
2024-06-12 18:31 [PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergo Koteles
@ 2024-06-12 18:31 ` Gergo Koteles
2024-06-12 18:31 ` [PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergo Koteles
1 sibling, 0 replies; 5+ messages in thread
From: Gergo Koteles @ 2024-06-12 18:31 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Laurent Pinchart
Cc: linux-media, linux-kernel, Gergo Koteles
Add V4L2_CID_ROLL_ABSOLUTE as an integer control to
retrieve and set the camera roll in degrees, and its
documentation.
Signed-off-by: Gergo Koteles <soyer@irl.hu>
---
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(+)
diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst
index cdc515c60468..81bc31a4bf79 100644
--- a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst
+++ b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst
@@ -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.
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
index 8696eb1cdd61..0e8af56cb2a2 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c
@@ -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! */
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 99c3f5e99da7..a6d28e54bbc0 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -1087,6 +1087,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)
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL
2024-06-12 18:31 [PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergo Koteles
2024-06-12 18:31 ` [PATCH 1/2] media: v4l2: ctrls: Add ROLL_ABSOLUTE control Gergo Koteles
@ 2024-06-12 18:31 ` Gergo Koteles
2024-06-12 20:31 ` Laurent Pinchart
1 sibling, 1 reply; 5+ messages in thread
From: Gergo Koteles @ 2024-06-12 18:31 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Laurent Pinchart
Cc: linux-media, linux-kernel, Gergo Koteles
Some new UVC cameras can report whether they are mounted in 'portrait
mode'.
Current roll degrees (-90, 0, 90, 180) are reported with
UVC_CT_ROLL_ABSOLUTE_CONTROL.
Map UVC_CT_ROLL_ABSOLUTE_CONTROL to V4L2_CID_ROLL_ABSOLUTE to
make it available to userspace.
Signed-off-by: Gergo Koteles <soyer@irl.hu>
---
drivers/media/usb/uvc/uvc_ctrl.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 4b685f883e4d..bc3272b6ceb1 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -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 = {
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL
2024-06-12 18:31 ` [PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergo Koteles
@ 2024-06-12 20:31 ` Laurent Pinchart
2024-06-14 16:26 ` Gergo Koteles
0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2024-06-12 20:31 UTC (permalink / raw)
To: Gergo Koteles; +Cc: Mauro Carvalho Chehab, linux-media, linux-kernel
On Wed, Jun 12, 2024 at 08:31:14PM +0200, Gergo Koteles wrote:
> Some new UVC cameras can report whether they are mounted in 'portrait
> mode'.
>
> Current roll degrees (-90, 0, 90, 180) are reported with
> UVC_CT_ROLL_ABSOLUTE_CONTROL.
UVC_CT_ROLL_ABSOLUTE_CONTROL is about controlling the motion of the
camera along the roll axis, while this patch series sounds like you want
to support reporting the mounting orientation of the device, not cause
the device to rotate. Is that right ?
If that's the case, the right V4L2 control to use would be
V4L2_CID_CAMERA_SENSOR_ROTATION. Mapping it to
UVC_CT_ROLL_ABSOLUTE_CONTROL is problematic though, as
UVC_CT_ROLL_ABSOLUTE_CONTROL is not meant for this in the UVC spec. We
would likely need a quirk to control how it gets used.
> Map UVC_CT_ROLL_ABSOLUTE_CONTROL to V4L2_CID_ROLL_ABSOLUTE to
> make it available to userspace.
>
> Signed-off-by: Gergo Koteles <soyer@irl.hu>
> ---
> drivers/media/usb/uvc/uvc_ctrl.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
> index 4b685f883e4d..bc3272b6ceb1 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -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 = {
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL
2024-06-12 20:31 ` Laurent Pinchart
@ 2024-06-14 16:26 ` Gergo Koteles
0 siblings, 0 replies; 5+ messages in thread
From: Gergo Koteles @ 2024-06-14 16:26 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Mauro Carvalho Chehab, linux-media, linux-kernel
Hi Laurent,
On Wed, 2024-06-12 at 23:31 +0300, Laurent Pinchart wrote:
> On Wed, Jun 12, 2024 at 08:31:14PM +0200, Gergo Koteles wrote:
> > Some new UVC cameras can report whether they are mounted in 'portrait
> > mode'.
> >
> > Current roll degrees (-90, 0, 90, 180) are reported with
> > UVC_CT_ROLL_ABSOLUTE_CONTROL.
>
> UVC_CT_ROLL_ABSOLUTE_CONTROL is about controlling the motion of the
> camera along the roll axis, while this patch series sounds like you want
> to support reporting the mounting orientation of the device, not cause
> the device to rotate. Is that right ?
The SET_CUR of UVC_CT_ROLL_ABSOLUTE_CONTROL is optional, so I think
it's for reporting also.
The cameras I've tested before can't roll the sensor, they only report
the angle/orientation.
Yes, I was thinking to support the mounting orientation report, however
I tried a friend's DJI Osmo Pocket 3, which can roll the sensor in +-
30˚ with ROLL_ABSOLUTE UVC control. It can also be
Panned/Tilted/Zoomed, very cool.
I think mapping UVC_CT_ROLL_ABSOLUTE_CONTROL to V4L2_CID_ROLL_ABSOLUTE
would be useful. I can reword the commit message a bit if you'd like.
>
> If that's the case, the right V4L2 control to use would be
> V4L2_CID_CAMERA_SENSOR_ROTATION. Mapping it to
> UVC_CT_ROLL_ABSOLUTE_CONTROL is problematic though, as
> UVC_CT_ROLL_ABSOLUTE_CONTROL is not meant for this in the UVC spec. We
> would likely need a quirk to control how it gets used.
>
I can also create a quirk for the other two cameras to map
UVC_CT_ROLL_ABSOLUTE_CONTROL to V4L2_CID_CAMERA_SENSOR_ROTATION.
Maybe it can be detected if CT_ROLL_ABSOLUTE_CONTROL doesn't have
SET_CUR, default 0, step 90.
>
Best regards,
Gergo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-06-14 16:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-12 18:31 [PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergo Koteles
2024-06-12 18:31 ` [PATCH 1/2] media: v4l2: ctrls: Add ROLL_ABSOLUTE control Gergo Koteles
2024-06-12 18:31 ` [PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergo Koteles
2024-06-12 20:31 ` Laurent Pinchart
2024-06-14 16:26 ` Gergo Koteles
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox