media: i2c: imx290: Support for the Sony IMX290 sensor
media: i2c: imx290: set the format before VIDIOC_SUBDEV_G_FMT is called Commit d46cfdc8 upstream. With the current driver 'media-ctl -p' issued right after the imx290 driver is loaded prints: pad0: Source [fmt:unknown/0x0] The format value of zero is due to the current_format field of the imx290 struct not being initialized yet. As imx290_entity_init_cfg() calls imx290_set_fmt(), the current_mode field is also initialized, so the line which set current_mode to a default value in driver's probe() function is no longer needed. Signed-off-by:Andrey Konovalov <andrey.konovalov@linaro.org> Reviewed-by:
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by:
Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by:
Mauro Carvalho Chehab <mchehab+huawei@kernel.org> media: i2c: imx290: Add support for 74.25MHz clock The existing driver only supported a clock of 37.125MHz, but the sensor also supports 74.25MHz. Add the relevant register modifications to support this alternate clock frequency. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Correct range for V4L2_CID_GAIN to 0-238 The datasheet lists the gain as being 0.0 to 72.0dB in 0.3dB steps, which makes 238 steps total. Correct the 0-72 range defined in the driver. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Convert HMAX setting into V4L2_CID_HBLANK Userspace needs to know HBLANK if it is to work out exposure times and frame rates, therefore convert it to map onto V4L2_CID_HBLANK Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Add support for V4L2_CID_VBLANK In order to calculate framerate and durations userspace needs the vertical blanking information. This can be configurable, and indeed the datasheet lists different values for VBLANK for the 1080p and 720p modes. Add the new control, and adopt the datasheet values for each mode. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Add exposure control to the driver. Adds support for V4L2_CID_EXPOSURE so that userspace can control the sensor exposure time. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Add H and V flip controls The sensor supports horizontal and vertical flips, so support them through V4L2_CID_HFLIP and V4L2_CID_VFLIP. This sensor does NOT change the Bayer order when changing the direction of readout, therefore no special handling is required for that. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: dt-bindings: media: i2c: Add mono version to IMX290 bindings The IMX290 module is available as either monochrome or colour and the variant is not detectable at runtime. Add a new compatible string for the monochrome version. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media : i2c: imx290: Add support for the mono sensor variant. The IMX290 module is available as either mono or colour (Bayer). Update the driver so that it can advertise the correct mono formats instead of the colour ones. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Switch set_hmax to use imx290_write_buffered_reg imx290_set_hmax was using two independent writes to set up hmax, when all other multi-register writes were using imx290_write_buffered_reg which claims the group hold first. Switch imx290_set_hmax to using imx290_write_buffered_reg too. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Add support for g_selection to report cropping Userspace needs to know the cropping arrangements for each mode, so expose this through g_selection. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Set the colorspace fields in the format The colorspace fields were left untouched in imx290_set_fmt which lead to a v4l2-compliance failure. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Replace V4L2_CID_GAIN with V4L2_CID_ANALOGUE_GAIN Most software (including libcamera) requires V4L2_CID_ANALOGUE_GAIN, not V4L2_CID_GAIN. The range for the control is 0 to 100 for which the sensor uses only analogue gain; higher values would involve digital gain which this control should not apply. Signed-off-by:
David Plowman <david.plowman@raspberrypi.com> media: i2c: imx290: Fix number of controls in v4l2_ctrl_handler_init The number is only a hint, but may as well be correct. Fixes: 471e0029 ("media: i2c: imx290: Convert HMAX setting into V4L2_CID_HBLANK") Fixes: be0b9b7a ("media: i2c: imx290: Add support for V4L2_CID_VBLANK") Fixes: 8483f0d7 ("media: i2c: imx290: Add exposure control to the driver.") Fixes: 9764f345 ("media: i2c: imx290: Add H and V flip controls") Signed-off-by:
David Plowman <david.plowman@raspberrypi.com> media: i2c: imx290: Fix up exposure calcuations and ranges Should now correspond exactly to the datasheet. Signed-off-by:
David Plowman <david.plowman@raspberrypi.com> media: i2c: imx290: Handle exposure correctly when vblank changes When vblank changes we must modify the exposure range. Also, with this sensor, the effective exposure time implicitly changes when vblank does, so we have to reset it after every vblank update. Signed-off-by:
David Plowman <david.plowman@raspberrypi.com> media: i2c: imx290: Support 60fps in 2 lane operation Commit "97589ad6 media: i2c: imx290: Add support for 2 data lanes" added support for running in two lane mode (instead of 4), but without changing the link frequency that resulted in a max of 30fps. Commit "98e0500e media: i2c: imx290: Add configurable link frequency and pixel rate" then doubled the link frequency when in 2 lane mode, but didn't undo the correction for running at only 30fps, just extending horizontal blanking instead. It also didn't update the CSI timing registers in accordance with the datasheet. Remove the 30fps limit on 2 lane by correcting the register config in accordance with the datasheet for 60fps operation over 2 lanes. Frame rate control (via V4L2_CID_VBLANK or HBLANK) can still reduce the frame rate on 2 lanes back to 30fps. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Fix the pixel rate at 148.5Mpix/s Whilst the datasheet lists the link frequency changing between 1080p and 720p modes, reality is that with the default blanking we have (1920 + 280) * (1080 + 45) * 60fps = 148.5MPix/s and (1280 + 2020) * (720 + 30) * 60fps = 148.5MPix/s and this reflects reality whether in 10 or 12 bit readout modes. How this relates to link frequency is unclear as it differs from the datasheet, but all exposure and frame rate calcs need the pixel rate to be correct, so make it so. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Fix clock setup register assignments When the clock setups were added for the alternate external clocks, the settings for 2 lane 720p and 4 lane 1080p were transposed. 2 lane 720p still worked, but 4 lane 1080p didn't. Correct the assignments. Fixes: 6b0c094a (media: i2c: imx290: Add support for 74.25MHz clock") Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Add fwnode properties controls Add call to v4l2_ctrl_new_fwnode_properties to read and create the fwnode based controls. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Sensor should report RAW color space Tested on Raspberry Pi running libcamera. Signed-off-by:
David Plowman <david.plowman@raspberrypi.com> media: i2c: imx290: Add compatible strings for IMX327 and IMX462 IMX327 is the previous generation to IMX290, and supports up to 1080p60 as 10 or 12 bit. IMX290 adds 1080p120 in 10 bit mode. IMX462 adds 1080p120 in both 10 and 12 bit modes. Add compatible strings for all variants. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Updating VBLANK should update exposure in all states The code to update the range of the exposure control was after a check that the sensor was powered up. This is incorrect as the range should be updated under all conditions. Move the range update code to the correct place. Fixes: 52d076ea "media: i2c: imx290: Handle exposure correctly when vblank changes" Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Drop incorrect comment about pixelrate commit b5eca6fd ("media: i2c: imx290: Fix the pixel rate at 148.5Mpix/s") corrected imx290_calc_pixel_rate to always return the correct pixle rate of 148.5Mpix/s, but didn't remove the comment that said it relied on some other parameters. Drop that comment. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Do not reset exposure time from set_fmt V4L2 controls are meant to be persistent, and only altered if the values break hardware constraints. In imx290_set_fmt the CID_VBLANK parameter was being reset to the mode default, and therefore the maximum exposure value potentially also changed. VBLANK is no longer reset, and even if it is, then the set_ctrl that will be called will alter the range for the exposure control. Therefore there is no need to reset the exposure time from set_fmt. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com> media: i2c: imx290: Correct min HBLANK. In the 720p mode the CSI link is run at a lower frequency, and the minimum HBLANK value has to be increased to avoid generating more data from the sensor than the link can carry. Set the minimum based on the mode. Signed-off-by:
Dave Stevenson <dave.stevenson@raspberrypi.com>
Loading
Please register or sign in to comment