Skip to contentSkip to conversation

Documentation: v4l: Document rotation and orientation for sensor drivers

PATCH Superseded Sakari Ailus 2 participants 2 messages Apr 5, 2023 – Apr 6, 2023

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Sakari Ailus

author maintainer
#0 lore raw

PATCH v4 1/1 Documentation: v4l: Document rotation and orientation for sensor drivers

Document how rotation and orientation should be taken into account in writing camera sensor drivers.

---
since v3:

- Add a missing paragraph on the ORIENTATION control. Use shall.

 .../driver-api/media/camera-sensor.rst        | 19 +++++++++++++++++++
 .../media/v4l/ext-ctrls-camera.rst            |  3 +++
 2 files changed, 22 insertions(+)
Documentation/driver-api/media/camera-sensor.rst +19 -0
index c7d4891bd24e..ad9accb3fd40 100644
@@ -151,3 +151,22 @@ used to obtain device's power state after the power state transition:
 The function returns a non-zero value if it succeeded getting the power count or
 runtime PM was disabled, in either of which cases the driver may proceed to
 access the device.
+
+Rotation and orientation
+------------------------
+
+Some systems have the camera sensor mounted upside down compared to its natural
+mounting rotation. In such cases, drivers shall expose the information to
+userspace with the :ref:`V4L2_CID_CAMERA_SENSOR_ROTATION
+<v4l2-camera-sensor-rotation>` control.
+
+Sensor drivers that have any vertical or horizontal flips embedded in the
+register programming sequences shall initialize the V4L2_CID_HFLIP and
+V4L2_CID_VFLIP controls with the values programmed by the register sequences.
+
+Sensor drivers shall also report the sensor's mounting orientation with the
+:ref:`V4L2_CID_CAMERA_SENSOR_ORIENTATION <v4l2-camera-sensor-orientation>`.
+
+Use ``v4l2_fwnode_device_parse()`` to obtain rotation and orientation
+information from system firmware and ``v4l2_ctrl_new_fwnode_properties()`` to
+register the appropriate controls.
Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst +3 -0
index daa4f40869f8..cdc515c60468 100644
@@ -506,6 +506,8 @@ enum v4l2_scene_mode -
     value down. A value of zero stops the motion if one is in progress
     and has no effect otherwise.
 
+.. _v4l2-camera-sensor-orientation:
+
 ``V4L2_CID_CAMERA_ORIENTATION (menu)``
     This read-only control describes the camera orientation by reporting its
     mounting position on the device where the camera is installed. The control
@@ -536,6 +538,7 @@ enum v4l2_scene_mode -
       - The camera is not directly attached to the device and is freely movable.
 
 
+.. _v4l2-camera-sensor-rotation:
 
 ``V4L2_CID_CAMERA_SENSOR_ROTATION (integer)``
     This read-only control describes the rotation correction in degrees in the
Signature · 1 line
2.30.2
#1 lore raw

Hi Sakari,

Thank you for the patch.

Quoted 23 lines · Sakari Ailus

Document how rotation and orientation should be taken into account in writing camera sensor drivers.

---
since v3:

- Add a missing paragraph on the ORIENTATION control. Use shall.

 .../driver-api/media/camera-sensor.rst        | 19 +++++++++++++++++++
 .../media/v4l/ext-ctrls-camera.rst            |  3 +++
 2 files changed, 22 insertions(+)
Documentation/driver-api/media/camera-sensor.rst +2 -0
index c7d4891bd24e..ad9accb3fd40 100644
@@ -151,3 +151,22 @@ used to obtain device's power state after the power state transition:
 The function returns a non-zero value if it succeeded getting the power count or
 runtime PM was disabled, in either of which cases the driver may proceed to
 access the device.
+
+Rotation and orientation

Documentation/driver-api/media/camera-sensor.rst used to obtain device's power state after the power state transition: · line 165

Quoted 10 lines
Documentation/driver-api/media/camera-sensor.rst +10 -0
+------------------------
+
+Some systems have the camera sensor mounted upside down compared to its natural
+mounting rotation. In such cases, drivers shall expose the information to
+userspace with the :ref:`V4L2_CID_CAMERA_SENSOR_ROTATION
+<v4l2-camera-sensor-rotation>` control.
+
+Sensor drivers that have any vertical or horizontal flips embedded in the
+register programming sequences shall initialize the V4L2_CID_HFLIP and
+V4L2_CID_VFLIP controls with the values programmed by the register sequences.

This feels out of place, as it covers flipping in the "Rotation and orientation" section, and sits between paragraphs related to rotation and orientation. I understand this paragraph relates to drivers enabling 180° rotation through h/v flip, but that's not clear enough.

Quoted 28 lines
Documentation/driver-api/media/camera-sensor.rst +7 -0
+
+Sensor drivers shall also report the sensor's mounting orientation with the
+:ref:`V4L2_CID_CAMERA_SENSOR_ORIENTATION <v4l2-camera-sensor-orientation>`.
+
+Use ``v4l2_fwnode_device_parse()`` to obtain rotation and orientation
+information from system firmware and ``v4l2_ctrl_new_fwnode_properties()`` to
+register the appropriate controls.
Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst +3 -0
index daa4f40869f8..cdc515c60468 100644
@@ -506,6 +506,8 @@ enum v4l2_scene_mode -
     value down. A value of zero stops the motion if one is in progress
     and has no effect otherwise.
 
+.. _v4l2-camera-sensor-orientation:
+
 ``V4L2_CID_CAMERA_ORIENTATION (menu)``
     This read-only control describes the camera orientation by reporting its
     mounting position on the device where the camera is installed. The control
@@ -536,6 +538,7 @@ enum v4l2_scene_mode -
       - The camera is not directly attached to the device and is freely movable.
 
 
+.. _v4l2-camera-sensor-rotation:
 
 ``V4L2_CID_CAMERA_SENSOR_ROTATION (integer)``
     This read-only control describes the rotation correction in degrees in the
Signature · 3 lines
Regards,

Laurent Pinchart