Re: [RFC v5 10/15] media: v4l: uapi: Add a control for colour pattern flipping effect

Dave Stevenson
2025-02-11T16:00:36Z

Hi Mirela and Sakari

On Mon, 10 Feb 2025 at 13:53, Sakari Ailus <sakari.ailus@linux.intel.com> wrote:
>
> Hi Mirela,
>
> On Sun, Feb 09, 2025 at 07:23:10PM +0200, Mirela Rabulea wrote:
> > Hi Sakari,
> >
> > On 03.02.2025 10:58, Sakari Ailus wrote:
> > > Add a bitmask control (V4L2_CID_COLOUR_PATTERN_FLIP) to tell whether
> > > flipping results in a change in the sensor's colour pattern, separately
> > > horizontally and vertically. The information is essential for raw formats
> > > when using generic raw mbus codes.
> >
> > Is this control really necessary? Are there cases when V4L2_CID_HFLIP or/and
> > V4L2_CID_VFLIP is enabled and the CFA pattern does not change?
>
> Some sensors have some tricks in firmware to avoid changing the pattern (I
> suppose in reality they crop one line / column) but this may not be
> controllable by the driver, so this possibility should be taken into
> account.

To give examples of sensors I've encountered that do this.
Sony IMX327, IMX290, IMX462, IMX415 and probably most of the Starvis range.
OnSemi AR0144 and AR0234.

Sony's datasheets do explicitly show the pixel array as being an odd
number of pixels in each direction, and that it therefore has the same
colour pixel (generally red) in each of the 4 corners. The flip
registers will be shifting readout by 1 pixel.
Readout mode restrictions generally say that the width and height must
be at least a multiple of 4, and offsets must be even, so there is no
way to read out that extra border pixel.

Dave

> >
> > Could a raw sensor driver be capable of reporting the
> > V4L2_CID_COLOUR_PATTERN based on current values of the HFLIP/VFLIP? I'm not
> > sure I understood all the aspects of patch #7 (V4L2_CID_COLOUR_PATTERN).
>
> In principle it could. The two were originally made independent also
> because there was an inconvenient dependency between mbus codes and
> controls. If the pattern control does not specify the native pattern but an
> active pattern (whatever has an effect on it), the userspace also must
> check that configuration to determine the native pattern. My understanding
> is the preference on that side is the native pattern.
>
> --
> Regards,
>
> Sakari Ailus