media: i2c: Add imx283 camera sensor driver
Subsystems (4)
cover media: i2c: Add imx283 camera sensor driver
Add a v4l2 subdevice driver for the Sony IMX283 image sensor.
The IMX283 is a 20MP Diagonal 15.86 mm (Type 1) CMOS Image Sensor with Square Pixel for Color Cameras.
The following features are supported:
- Manual exposure an gain control support
- vblank/hblank/link freq control support
- Test pattern support control
- Arbitrary horizontal and vertical cropping
- Supported resolution:
- 5472x3648 @ 20fps (SRGGB12)
- 5472x3648 @ 25fps (SRGGB10)
- 2736x1824 @ 50fps (SRGGB12)
The driver is tested on mainline branch v6.8-rc2 on IMX8MP Debix-SOM-A. Additional testing has been done on RPi5 with the downstream BSP.
Changes in v4:
- fix 32-bit build error around u64 divisions (use do_div)
- Fix hmax default and minimum values
Changes in v3:
- fix headers includes
- Improve #define(s) readability
- Drop __func__ from error logs
- Use HZ_PER_MHZ instead of MEGA
- mdsel* variables should be u8
- Use container_of_const() instead of container_of()
- Use clamp() used of clamp_t variant
- Use streams API imx283_{enable|disable}_streams (**NOTE**)
- Properly fix PM runtime handling
(pm_ptr(), DEFINE_RUNTIME_DEV_PM_OPS,
imx283_runtime_suspend, imx283_runtime_resume)
- Fix format modifiers, signed-ness at various places
changes in v2 (summary):
- Use u32 wherever possible
- Use MEGA macro instead of self defined MHZ() macro
- Properly refine regs using CCI
- Drop tracking of current mode. Shifted to infer from active state directly. (Laurent's review)
- Cont. from above: Pass the struct imx283_mode to functions whereever required.
- Remove unused comments
- Remove custom mutex. Use control handler one instead.
- Drop imx283_reset_colorspace() and inline
- Set colorspace field properly (drop _DEFAULTS)
- Use __maybe_unused for imx283_power_on() and imx283_power_off()
- Store controls v4l2_ctrl handles for those required, not all.
- Drop imx283_free_controls(). Use v4l2_ctrl_handler_free
- fix reset-gpios handling and add it to DT schema
- fix data-lanes property in DT schema
- fix IMX283 Kconfig
- Remove unused macros
- Alphabetical case consistency
---
Kieran Bingham (1):
media: i2c: Add imx283 camera sensor driver
Umang Jain (2):
media: dt-bindings: media: Add bindings for IMX283 fixups
.../devicetree/bindings/media/i2c/sony,imx283.yaml | 107 ++ MAINTAINERS | 9 + drivers/media/i2c/Kconfig | 10 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/imx283.c | 1605 ++++++++++++++++++++ 5 files changed, 1732 insertions(+)
---
base-commit: 54ee11761885407056f4ca60309739e2db6b02dc
change-id: 20240402-kernel-name-extraversion-2b08d441e08c
Best regards,
Signature · 1 line
Umang Jain <[email protected]>
PATCH 1/3 media: dt-bindings: media: Add bindings for IMX283
- Add dt-bindings documentation for Sony IMX283 sensor driver
- Add MAINTAINERS entry for Sony IMX283 binding documentation
--- .../devicetree/bindings/media/i2c/sony,imx283.yaml | 107 +++++++++++++++++++++ MAINTAINERS | 8 ++ 2 files changed, 115 insertions(+)
Documentation/devicetree/bindings/media/i2c/sony,imx283.yaml new file +107 -0
@@ -0,0 +1,107 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2024 Ideas on Board Oy +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/sony,imx283.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony IMX283 Sensor + +maintainers: + - Kieran Bingham <[email protected]> + - Umang Jain <[email protected]> + +description: + IMX283 sensor is a Sony CMOS active pixel digital image sensor with an active + array size of 5472H x 3648V. It is programmable through I2C interface. The + I2C client address is fixed to 0x1a as per sensor data sheet. Image data is + sent through MIPI CSI-2. + +properties: + compatible: + const: sony,imx283 + + reg: + maxItems: 1 + + clocks: + description: Clock frequency from 6 to 24 MHz. + maxItems: 1 + + vadd-supply: + description: Analog power supply (2.9V) + + vdd1-supply: + description: Interface power supply (1.8V) + + vdd2-supply: + description: Digital power supply (1.2V) + + reset-gpios: + description: Sensor reset (XCLR) GPIO + maxItems: 1 + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + properties: + data-lanes: + anyOf: + - items: + - const: 1 + - const: 2 + - const: 3 + - const: 4 + + link-frequencies: true + + required: + - data-lanes + - link-frequencies + + required: + - endpoint + +required: + - compatible + - reg + - clocks + - port + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + camera@1a { + compatible = "sony,imx283"; + reg = <0x1a>; + clocks = <&imx283_clk>; + + assigned-clocks = <&imx283_clk>; + assigned-clock-parents = <&imx283_clk_parent>; + assigned-clock-rates = <12000000>; + + vadd-supply = <&camera_vadd_2v9>; + vdd1-supply = <&camera_vdd1_1v8>; + vdd2-supply = <&camera_vdd2_1v2>; + + port { + imx283: endpoint { + remote-endpoint = <&cam>; + data-lanes = <1 2 3 4>; + link-frequencies = /bits/ 64 <360000000>; + }; + }; + }; + }; +...
MAINTAINERS +8 -0
@@ -20367,6 +20367,14 @@ T: git git://linuxtv.org/media_tree.git F: Documentation/devicetree/bindings/media/i2c/sony,imx274.yaml F: drivers/media/i2c/imx274.c +SONY IMX283 SENSOR DRIVER +M: Kieran Bingham <[email protected]> +M: Umang Jain <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media_tree.git +F: Documentation/devicetree/bindings/media/i2c/sony,imx283.yaml + SONY IMX290 SENSOR DRIVER M: Manivannan Sadhasivam <[email protected]> L: [email protected]
Signature · 1 line
2.43.0
PATCH 2/3 media: i2c: Add imx283 camera sensor driver
In reply to Umang JainFrom: Kieran Bingham <[email protected]>
Add a v4l2 subdevice driver for the Sony IMX283 image sensor.
The IMX283 is a 20MP Diagonal 15.86 mm (Type 1) CMOS Image Sensor with Square Pixel for Color Cameras.
The following features are supported:
- Manual exposure an gain control support
- vblank/hblank/link freq control support
- Test pattern support control
- Arbitrary horizontal and vertical cropping
- Supported resolution:
- 5472x3648 @ 20fps (SRGGB12)
- 5472x3648 @ 25fps (SRGGB10)
- 2736x1824 @ 50fps (SRGGB12)
--- MAINTAINERS | 1 + drivers/media/i2c/Kconfig | 10 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/imx283.c | 1596 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1608 insertions(+)
MAINTAINERS +1 -0
@@ -20374,6 +20374,7 @@ L: [email protected] S: Maintained T: git git://linuxtv.org/media_tree.git F: Documentation/devicetree/bindings/media/i2c/sony,imx283.yaml +F: drivers/media/i2c/imx283.c SONY IMX290 SENSOR DRIVER M: Manivannan Sadhasivam <[email protected]>
drivers/media/i2c/Kconfig +10 -0
@@ -163,6 +163,16 @@ config VIDEO_IMX274 This is a V4L2 sensor driver for the Sony IMX274 CMOS image sensor. +config VIDEO_IMX283 + tristate "Sony IMX283 sensor support" + select V4L2_CCI_I2C + help + This is a V4L2 sensor driver for the Sony IMX283 + CMOS image sensor. + + To compile this driver as a module, choose M here: the + module will be called imx283. + config VIDEO_IMX290 tristate "Sony IMX290 sensor support" select REGMAP_I2C
drivers/media/i2c/Makefile +1 -0
@@ -49,6 +49,7 @@ obj-$(CONFIG_VIDEO_IMX214) += imx214.o obj-$(CONFIG_VIDEO_IMX219) += imx219.o obj-$(CONFIG_VIDEO_IMX258) += imx258.o obj-$(CONFIG_VIDEO_IMX274) += imx274.o +obj-$(CONFIG_VIDEO_IMX283) += imx283.o obj-$(CONFIG_VIDEO_IMX290) += imx290.o obj-$(CONFIG_VIDEO_IMX296) += imx296.o obj-$(CONFIG_VIDEO_IMX319) += imx319.o
drivers/media/i2c/imx283.c new file +1596 -0
1,596 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 3/3 fixups
In reply to Umang Jain--- drivers/media/i2c/imx283.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/media/i2c/imx283.c +17 -8
@@ -450,12 +450,12 @@ static const struct imx283_mode supported_modes_12bit[] = { .bpp = 12, .width = 2736, .height = 1824, - .min_hmax = 1870, /* Pixels (362 * 360/72 + padding) */ + .min_hmax = 2414, /* Pixels (362 * 480MHz/72MHz + padding) */ .min_vmax = 3840, /* Lines *//* 50.00 FPS */ - .default_hmax = 1870, /* 362 @ 360MHz/72MHz */ - .default_vmax = 3960, + .default_hmax = 2500, /* 375 @ 480MHz/72Mhz */ + .default_vmax = 3840, .veff = 1824, .vst = 0,
@@ -483,7 +483,7 @@ static const struct imx283_mode supported_modes_10bit[] = { .min_vmax = 3793,/* 25.00 FPS */ - .default_hmax = 1500, /* 750 @ 576MHz / 72MHz */ + .default_hmax = 6000, /* 750 @ 576MHz / 72MHz */ .default_vmax = 3840, .min_shr = 10,
@@ -568,12 +568,15 @@ static inline void get_mode_table(unsigned int code,static u64 imx283_pixel_rate (struct imx283 *imx283,const struct imx283_mode *mode) { +u64 link_frequency = link_frequencies[__ffs (imx283->link_freq_bitmap)];unsigned int bpp = mode->bpp;const unsigned int ddr =2 ;/* Double Data Rate */ const unsigned int lanes =4 ;/* Only 4 lane support */ -u64 link_frequency = link_frequencies[__ffs (imx283->link_freq_bitmap)]; +u64 numerator = link_frequency * ddr * lanes; -return link_frequency * ddr * lanes / bpp; +do_div (numerator, bpp); + +return numerator; }/* Convert from a variable pixel_rate to 72 MHz clock cycles */
@@ -588,8 +591,11 @@ static u64 imx283_internal_clock(unsigned int pixel_rate, unsigned int pixels)*/ const u32 iclk_pre =72 ;const u32 pclk_pre = pixel_rate /HZ_PER_MHZ ; +u64 numerator = pixels * iclk_pre; + +do_div (numerator, pclk_pre); -return pixels * iclk_pre / pclk_pre; +return numerator; }/* Internal clock (72MHz) to Pixel Rate clock (Variable) */
@@ -604,8 +610,11 @@ static u64 imx283_iclk_to_pix(unsigned int pixel_rate, unsigned int cycles)*/ const u32 iclk_pre =72 ;const u32 pclk_pre = pixel_rate /HZ_PER_MHZ ; +u64 numerator = cycles * pclk_pre; + +do_div (numerator, iclk_pre); -return cycles * pclk_pre / iclk_pre; +return numerator; }/* Determine the exposure based on current hmax, vmax and a given SHR */
Signature · 1 line
2.43.0
Re: [PATCH 3/3] fixups
Quoted 3 lines · Umang Jain
--- drivers/media/i2c/imx283.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
Patch should be squashed.
Best regards,
Krzysztof
Hi all,
PLease ignore the series, I was testing/learning the b4 tool.
I did pass --offline-mode but it has sent the patches anyway :-//
Quoted 76 lines · Umang Jain
Add a v4l2 subdevice driver for the Sony IMX283 image sensor.
The IMX283 is a 20MP Diagonal 15.86 mm (Type 1) CMOS Image Sensor with Square Pixel for Color Cameras.
The following features are supported:
- Manual exposure an gain control support
- vblank/hblank/link freq control support
- Test pattern support control
- Arbitrary horizontal and vertical cropping
- Supported resolution:
- 5472x3648 @ 20fps (SRGGB12)
- 5472x3648 @ 25fps (SRGGB10)
- 2736x1824 @ 50fps (SRGGB12)The driver is tested on mainline branch v6.8-rc2 on IMX8MP Debix-SOM-A. Additional testing has been done on RPi5 with the downstream BSP.
Changes in v4:
- fix 32-bit build error around u64 divisions (usedo_div)
- Fix hmax default and minimum valuesChanges in v3:
- fix headers includes
- Improve #define(s) readability
- Drop__func__from error logs
- UseHZ_PER_MHZinstead of MEGA
- mdsel* variables should be u8
- Usecontainer_of_const()instead ofcontainer_of()
- Useclamp()used ofclamp_tvariant
- Use streams API imx283_{enable|disable}_streams (**NOTE**)
- Properly fix PM runtime handling
(pm_ptr(),DEFINE_RUNTIME_DEV_PM_OPS,imx283_runtime_suspend, imx283_runtime_resume)- Fix format modifiers, signed-ness at various places
changes in v2 (summary):
- Use u32 wherever possible
- Use MEGA macro instead of self definedMHZ()macro
- Properly refine regs using CCI
- Drop tracking of current mode. Shifted to infer from active state directly. (Laurent's review)
- Cont. from above: Pass the structimx283_modeto functions whereever required.
- Remove unused comments
- Remove custom mutex. Use control handler one instead.
- Dropimx283_reset_colorspace()and inline
- Set colorspace field properly (drop_DEFAULTS)
- Use__maybe_unusedforimx283_power_on()andimx283_power_off()
- Store controlsv4l2_ctrlhandles for those required, not all.
- Dropimx283_free_controls(). Usev4l2_ctrl_handler_free
- fix reset-gpios handling and add it to DT schema
- fix data-lanes property in DT schema
- fix IMX283Kconfig
- Remove unused macros
- Alphabetical case consistencySigned-off-by Umang Jain <[email protected]>---
Kieran Bingham (1):
media: i2c: Add imx283 camera sensor driverUmang Jain (2):
media: dt-bindings: media: Add bindings for IMX283 fixups.../devicetree/bindings/media/i2c/sony,imx283.yaml | 107 ++ MAINTAINERS | 9 + drivers/media/i2c/Kconfig | 10 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/imx283.c | 1605 ++++++++++++++++++++ 5 files changed, 1732 insertions(+)---
base-commit:54ee11761885407056f4ca60309739e2db6b02dc
change-id: 20240402-kernel-name-extraversion-2b08d441e08cBest regards,
Quoted 5 lines · Umang Jain
Hi all,
PLease ignore the series, I was testing/learning the b4 tool.
I did pass --offline-mode but it has sent the patches anyway :-//
Hm... I see why this would be confusing and I will try to fix this.
(the --offline-mode flag is to prevent b4 from querying lore.kernel.org, but it should also bubble up to other functionality that calls remote services, like b4 send).
-K