media: i2c: imx258: Support for the Sony IMX258 sensor
media: i2c: imx258: Remove unused defines The IMX258_FLL_* defines are unused. Remove them. Signed-off-by:Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Make image geometry meet sensor requirements The output image is defined as being 4208x3118 pixels in size. Y_ADD_STA register was set to 0, and Y_ADD_END to 3118, giving 3119 lines total. The datasheet lists a requirement for Y_ADD_STA to be a multiple of a power of 2 depending on binning/scaling mode (2 for full pixel, 4 for x2-bin/scale, 8 for (x2-bin)+(x2-subsample) or x4-bin, or 16 for (x4-bin)+(x2-subsample)). (Y_ADD_END – Y_ADD_STA + 1) also has to be a similar power of 2. The current configuration for the full res modes breaks that second requirement, and we can't increase Y_ADD_STA to 1 to retain exactly the same field of view as that then breaks the first requirement. For the binned modes, they are worse off as 3118 is not a multiple of 4. Increase the main mode to 4208x3120 so that it is the same FOV as the binned modes, with Y_ADD_STA at 0. Fix Y_ADD_STA and Y_ADD_END for the binned modes so that they meet the sensor requirements. This does change the Bayer order as the default configuration is for H&V flips to be enabled, so readout is from Y_STA_END to Y_ADD_STA, and this patch has changed Y_STA_END. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Disable digital cropping on binned modes The binned modes set DIG_CROP_X_OFFSET and DIG_CROP_IMAGE_WIDTH to less than the full image, even though the image being captured is meant to be a scaled version of the full array size. Reduce X_OFFSET to 0, and increase IMAGE_WIDTH to the full array. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Implement HFLIP and VFLIP controls. The sensor supports H & V flips, so implement the relevant controls. Note that the Bayer order changes with these flips, therefore they set the V4L2_CTRL_FLAG_MODIFY_LAYOUT property. As we now support flips, remove the restriction of the sensor only probing if rotated 180 degrees, but do take that value and initialise VFLIP and HFLIP based on it. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Remove redundant I2C writes. Registers 0x0202 and 0x0203 are written via the control handler for V4L2_CID_EXPOSURE, so are not needed from the mode lists. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Add regulator control The device tree bindings define the relevant regulators for the sensor, so update the driver to request the regulators and control them at the appropriate times. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Make V4L2_CID_VBLANK configurable. The values and ranges of V4L2_CID_VBLANK are all computed, so there is no reason for it to be a read only control. Remove the register values from the mode lists, add the handler, and remove the read only flag. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Register the ctrls from fwnode properties Use v4l2_ctrl_new_fwnode_properties to register the standard fwnode properties for the driver. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Add support for 24MHz clock There's no reason why the clock must be 19.2MHz and nothing else (indeed this isn't even a frequency listed in the datasheet), so add support for 24MHz as well. The PLL settings result in slightly different link frequencies, so parameterise those. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Add support for running on 2 CSI data lanes Extends the driver to also support 2 data lanes. Frame rates are obviously more restricted on 2 lanes, but some hardware simply hasn't wired more up. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Follow normal V4L2 behaviours for clipping exposure V4L2 sensor drivers are expected are expected to clip the supported exposure range based on the VBLANK configured. IMX258 wasn't doing that as register 0x350 (FRM_LENGTH_CTL) switches it to a mode where frame length tracks coarse exposure time. Disable this mode and clip the range for V4L2_CID_EXPOSURE appropriately based on V4L2_CID_VBLANK. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Add get_selection for pixel array information Libcamera requires the cropping information for each mode, so add this information to the driver. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Allow configuration of clock lane behaviour The sensor supports the clock lane either remaining in HS mode during frame blanking, or dropping to LP11. Add configuration of the mode via V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Correct max FRM_LENGTH_LINES value The data sheet states that the maximum value for registers 0x0340/0x0341 FRM_LENGTH_LINES is 65525(decimal), not the 0xFFFF defined in this driver. Correct this limit. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Add support for long exposure modes The sensor has a register CIT_LSHIFT which extends the exposure and frame times by the specified power of 2 for longer exposure times. Add support for this by configuring this register via V4L2_CID_VBLANK and extending the V4L2_CID_EXPOSURE range accordingly. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Issue reset before starting streaming Whilst not documented, register 0x0103 bit 0 is the soft reset for the sensor, so send it before trying to configure the sensor. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Set pixel_rate range to the same as the value With a read only control there is limited point in advertising a minimum and maximum for the control, so change to set the value, min, and max all to the selected pixel rate. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Support faster pixel rate on binned modes With the binned modes, there is little point in faithfully reproducing the horizontal line length of 5352 pixels on the CSI2 bus, and the FIFO between the pixel array and MIPI serialiser allows us to remove that dependency. Allow the pixel array to run with the normal settings, with the MIPI serialiser at half the rate. This requires some additional information for the link frequency to pixel rate function that needs to be added to the configuration tables. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: dt-bindings: imx258: Add alternate compatible strings There are a number of variants of the imx258 modules that can not be differentiated at runtime, so add compatible strings for them. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx258: Change register settings for variants of the sensor Sony have advised that there are variants of the IMX258 sensor which require slightly different register configuration to the mainline imx258 driver defaults. There is no available run-time detection for the variant, so add configuration via the DT compatible string. The Vision Components imx258 module supports PDAF, so add the register differences for that variant Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com>
Loading
Please register or sign in to comment