public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL
@ 2023-08-03 21:28 Gergő Köteles
  2023-08-03 21:28 ` [RFC PATCH 1/2] media: v4l2: ctrls: Add ROLL_ABSOLUTE control Gergő Köteles
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Gergő Köteles @ 2023-08-03 21:28 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Laurent Pinchart
  Cc: linux-media, linux-kernel, 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.

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
-- 
2.41.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC PATCH 1/2] media: v4l2: ctrls: Add ROLL_ABSOLUTE control
  2023-08-03 21:28 [RFC PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergő Köteles
@ 2023-08-03 21:28 ` Gergő Köteles
  2023-08-03 21:28 ` [RFC PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergő Köteles
  2023-08-04 18:45 ` [RFC PATCH 0/2] " Michael Riesch
  2 siblings, 0 replies; 5+ messages in thread
From: Gergő Köteles @ 2023-08-03 21:28 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Laurent Pinchart
  Cc: linux-media, linux-kernel, Gergő Köteles

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

Signed-off-by: Gergő Köteles <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 c3604a0a3e30..5131711ea873 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -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)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL
  2023-08-03 21:28 [RFC PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergő Köteles
  2023-08-03 21:28 ` [RFC PATCH 1/2] media: v4l2: ctrls: Add ROLL_ABSOLUTE control Gergő Köteles
@ 2023-08-03 21:28 ` Gergő Köteles
  2023-08-04 18:45 ` [RFC PATCH 0/2] " Michael Riesch
  2 siblings, 0 replies; 5+ messages in thread
From: Gergő Köteles @ 2023-08-03 21:28 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Laurent Pinchart
  Cc: linux-media, linux-kernel, 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.

Signed-off-by: Gergő Köteles <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 5e9d3da862dd..2801a1ee04a2 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.41.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL
  2023-08-03 21:28 [RFC PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergő Köteles
  2023-08-03 21:28 ` [RFC PATCH 1/2] media: v4l2: ctrls: Add ROLL_ABSOLUTE control Gergő Köteles
  2023-08-03 21:28 ` [RFC PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergő Köteles
@ 2023-08-04 18:45 ` Michael Riesch
  2023-08-04 21:33   ` Gergő Köteles
  2 siblings, 1 reply; 5+ messages in thread
From: Michael Riesch @ 2023-08-04 18:45 UTC (permalink / raw)
  To: Gergő Köteles, Mauro Carvalho Chehab, Laurent Pinchart
  Cc: linux-media, linux-kernel

Hi Gergő,

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

On 8/3/23 23:28, Gergő Köteles wrote:
> 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.

> Is it better to use V4L2_CID_CAMERA_SENSOR_ROTATION for this?

IMHO that would make sense.

Best regards,
Michael

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL
  2023-08-04 18:45 ` [RFC PATCH 0/2] " Michael Riesch
@ 2023-08-04 21:33   ` Gergő Köteles
  0 siblings, 0 replies; 5+ messages in thread
From: Gergő Köteles @ 2023-08-04 21:33 UTC (permalink / raw)
  To: Michael Riesch, Mauro Carvalho Chehab, Laurent Pinchart
  Cc: linux-media, linux-kernel

Hi Michael,

On Fri, 2023-08-04 at 20:45 +0200, Michael Riesch wrote:
> 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. :)

> On 8/3/23 23:28, Gergő Köteles wrote:
> > 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?
> 

They are there with V4L2_CID_PAN_ABSOLUTE and V4L2_CID_TILT_ABSOLUTE.

> 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?

> > Is it better to use V4L2_CID_CAMERA_SENSOR_ROTATION for this?
> 
> IMHO that would make sense.
> 
> Best regards,
> Michael
> 
> > 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-04 21:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 21:28 [RFC PATCH 0/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergő Köteles
2023-08-03 21:28 ` [RFC PATCH 1/2] media: v4l2: ctrls: Add ROLL_ABSOLUTE control Gergő Köteles
2023-08-03 21:28 ` [RFC PATCH 2/2] media: v4l2: map UVC_CT_ROLL_ABSOLUTE_CONTROL Gergő Köteles
2023-08-04 18:45 ` [RFC PATCH 0/2] " Michael Riesch
2023-08-04 21:33   ` Gergő Köteles

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox