[libcamera-devel,0/9] libcamera: camera_sensor: Centralize flips handling
mbox series

Message ID 20221124121220.47000-1-jacopo@jmondi.org
Headers show
Series
  • libcamera: camera_sensor: Centralize flips handling
Related show

Message

Jacopo Mondi Nov. 24, 2022, 12:12 p.m. UTC
Hello,
   this series takes in two patches from David and on top of them plumbs
flips handling in the CameraSensor class.

The discussion on how to handle flip reset/defaut configuration on David's
patches highlighted the need to centrlize their handling as the only two
platforms that support rotation do so by applying flips on the sensor, and the
code was copied from RPi pipeline handler to IPU3. As the RkISP1 platform needs
to support Transform as well, it is desirable to collect all the boilerplate
code in a central location in the CameraSensor class.

The series start with the two patches from David, on top of which the
CameraSensor class is extended to

1) Validate Transform:
   The same logic as implemented in the IPU3/RPi PH is moved in the CameraSensor
   class. The requested Transform is adjusted against the sensor's rotation and
   the sensor's capabilities. In example, if a sensor is 180 degrees rotated (as
   reported by V4L2_CID_ROTATION) and the Identity transform is requested, the
   resulting combined Transform is Rot180, to automatically correct the image
   rotation.

2) Apply flips at CameraSensor::setFormat() time
   Before applying a format, flips are operated according to the requested
   Transform. Applying flips before setting a format is crucial to obtain an
   up to data Bayer pattern order. In order to simplify setting a Transform
   on the camera sensor, a new "transform" member is added to
   V4L2SubdeviceFormat.

On top, after a few minor patches, Transform support is added to the RkISP1
pipeline handler.

Tested on i.MX8MP with a sensor that
- does not support flips
- support flips - no V4L2_CID_ROTATION
- support flips with V4L2_CID_ROTATION

Only compile tested on IPU3 and RPi.

Thanks
  j

David Plowman (2):
  libcamera: bayer_format: Add toMbusCode method
  libcamera: camera_sensor: Do not clear camera flips when listing
    formats

Jacopo Mondi (7):
  libcamera: bayer_format: Expand documentation
  libcamera: camera_sensor: Verify flips support
  libcamera: camera_sensor: Validate Transform
  libcamera: camera_sensor: Apply flips at setFormat()
  libcamera: rkisp1: Re-sort includes
  libcamera: rkisp1: Add support for Transform
  documentation: sensor_drivers: Document H/V flip

 Documentation/sensor_driver_requirements.rst  |  13 ++
 include/libcamera/internal/bayer_format.h     |   1 +
 include/libcamera/internal/camera_sensor.h    |   5 +
 include/libcamera/internal/v4l2_subdevice.h   |   2 +
 src/libcamera/bayer_format.cpp                |  31 +++-
 src/libcamera/camera_sensor.cpp               | 149 ++++++++++++++++--
 src/libcamera/pipeline/ipu3/cio2.cpp          |   6 +-
 src/libcamera/pipeline/ipu3/cio2.h            |   4 +-
 src/libcamera/pipeline/ipu3/ipu3.cpp          |  73 +--------
 .../pipeline/raspberrypi/raspberrypi.cpp      |  86 ++--------
 src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  19 ++-
 src/libcamera/v4l2_subdevice.cpp              |  10 ++
 12 files changed, 235 insertions(+), 164 deletions(-)

--
2.38.1