[v2,0/5] media: Add ST VGXY61 camera sensor driver

Message ID 20220415111845.27130-1-benjamin.mugnier@foss.st.com (mailing list archive)
Headers
Series media: Add ST VGXY61 camera sensor driver |

Message

Benjamin Mugnier April 15, 2022, 11:18 a.m. UTC
  Hello,

This series adds a driver for the ST VGXY61 camera sensor. This camera sensor is using the i2c bus
for control and the csi-2 bus for data.
DT bindings are in 4/5, and the driver in 5/5.
Other commits, in order, introduce the MEDIA_BUS_FMT_Y16_1X16 as a media bus format, a v4l2 standard
control to retrieve sensor temperature, and reserve 16 user controls for the driver (required to set
the HDR mode).
Tested on DragonBoard 410c and on Raspberry Pi 4.

The vblank and hblank support required some work to make sure some v4l2 controls update their
minimum and maximum values to avoid crashing the sensor. This required some time to wrap my head
around, I apologize for the delay.

Here are some observations after the first review:
- The sensor requires patch at boot time. Therefore the pm_runtime power_on function applies the
  patch every time it needs to wake up the sensor. The delay is barely noticeable for the user, and
  we benefit from the power management functionalities.
- After changing wrong SGBRG* media bus formats to proper Y*, as this is a monochrome sensor, I
  noticed that my test target db410c offers limited support for monochrome pixel formats as only
  Y10P pixel format is supported. Moreover, Y10P does not seem to be supported by some viewers
  (qv4l2 for instance returns an unknown pixel format error). v4l-ctl and yavta are doing fine but
  do not offer a video preview, and I couldn't find a tool to unpack the captured packed raw frame.
  As advised by Sakari on irc, adding other monochrome pixel formats to the db410c should not be
  really complicated, neither adding support in v4l-convert for monochrome formats to benefit qv4l2.
  But this leaves me without the ability to preview a video on this specific platform for now on. I
  would like to have your opinions on this matter, maybe I missed something.

Thanks a lot.

v1->v2:
- Move temperature control to v4l2-controls.h as a standard control
- Reserve controls in v4l2-controls.h for HDR control
- Remove GPIO strobbing controls
- Remove references to unused controls in sensor struct
- Use v4l2_find_nearest_size
- Use V4L2_COLORSPACE_RAW instead of V4L2_COLORSPACE_SRGB
- Fill ycbcr_enc, quantization, and xfer_func in v4l2_mbus_framefmt
- Change gain from formula to a register RAW write
- Change temperature control value directly
- Remove clock-name and clock-lanes from device tree bindings
- Declare crop zones in mode_info structure
- Remove frame_interval functions and add hblank and vblank instead
- Update controls dependencies on change
- Fix first exposure rule of thumb being too restrictive
- Disable hflip and vflip controls while streaming
- Change RGB media bus code to Y as the sensor is monochrome
- Add Y16 format to v4l2 media bus formats
- Add get_selection API
- Fix timeout errors while disabling streaming on high framerates
- Support pm_runtime
- Rebase on master

Benjamin Mugnier (5):
  media: v4l: Add 1X16 16-bit greyscale media bus code definition
  media: v4l: ctrls: Add a control for temperature
  media: v4l: ctrls: Add user control base for st-vgxy61 controls
  media: dt-bindings: media: i2c: Add ST VGXY61 camera sensor binding
  media: i2c: Add driver for ST VGXY61 camera sensor

 .../bindings/media/i2c/st,st-vgxy61.yaml      |  125 ++
 .../media/v4l/ext-ctrls-camera.rst            |    3 +
 .../media/v4l/subdev-formats.rst              |   37 +
 MAINTAINERS                                   |    9 +
 drivers/media/i2c/Kconfig                     |   10 +
 drivers/media/i2c/Makefile                    |    1 +
 drivers/media/i2c/st-vgxy61.c                 | 1997 +++++++++++++++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c     |    4 +
 include/uapi/linux/media-bus-format.h         |    3 +-
 include/uapi/linux/v4l2-controls.h            |    7 +
 10 files changed, 2195 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/st,st-vgxy61.yaml
 create mode 100644 drivers/media/i2c/st-vgxy61.c