Add support for the Sony Exmor-RS IMX300 camera sensor
Subsystems (3)
cover Add support for the Sony Exmor-RS IMX300 camera sensor
From: AngeloGioacchino Del Regno <[email protected]>
This patch series adds support for the IMX300 camera sensor, (one of the) first Exmor-RS Stacked CMOS sensor(s), with support for both of the supported aspect ratios (4:3 and 16:9).
This driver came out from reverse engineering of so called "userspace drivers" from Sony Xperia smartphones.
I tried to document all of my findings and giving a sense to the registers as much as possible, but that was only partially possible and resembles some names from the IMX219 public datasheet, even though the addresses are basically completely different.
This camera sensor driver was tested with all the resolutions declared in it on two phones: Sony Xperia XA2 and XA2 Ultra, on a SDM630 SoC (camss patches for this SoC will come in a later series) and is working great.
AngeloGioacchino Del Regno (2):
media: i2c: Add driver for the Sony Exmor-RS IMX300 camera sensor
media: dt-bindings: media: i2c: Add IMX300 CMOS sensor binding
.../devicetree/bindings/media/i2c/imx300.yaml | 115 + MAINTAINERS | 8 + drivers/media/i2c/Kconfig | 13 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/imx300.c | 3087 +++++++++++++++++ 5 files changed, 3224 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/imx300.yaml create mode 100644 drivers/media/i2c/imx300.c
Signature · 1 line
2.28.0
PATCH 1/2 media: i2c: Add driver for the Sony Exmor-RS IMX300 camera sensor
From: AngeloGioacchino Del Regno <[email protected]>
This is a custom multi-aspect 25MegaPixels sensor from Sony, found in many Sony Xperia smartphones from various eras.
The camera assembly for this sensor usually (at least in Xperia phones) has a lens that does not cover the entire sensor area, which means that the real corners are blind and that, in many lighting conditions, some more pixels in the corners are very getting obscured (as no decent amount of light can get in)... so, the maximum resolution that can produce a good image is:
- In 4:3 aspect ratio, 5520x4160 (23.0MP)
- In 16:9 aspect ratio, 5984x3392 (20.3MP).
This sensor supports high frame rates (>=60FPS) when in binning mode and both RAW8 and RAW10 output modes.
In this version of the driver, support has been provided for the following resolutions:
W x H SZ MAX_FPS BINNING
- 5520x4160 23.0MP 23 No - 5984x3392 20.3MP 26 No - 2992x1696 3.8MP 60 Yes - 1424x800 1.2MP 120 Yes
Note 1: The "standard" camera assy for IMX300 also contains an actuator (to focus the image), but this driver only manages the actual image sensor.
Note 2: The command tables for this sensor were reverse engineered from a downstream "userspace driver" that has been released in various versions on various Xperia smartphones. Register layout seems to be only vaguely similar to IMX219, which has a public datasheet from where some names for the figured out registers were taken and added to the driver:
these names are probably not the right ones, but they surely represent the intended thing.
--- drivers/media/i2c/Kconfig | 13 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/imx300.c | 3087 ++++++++++++++++++++++++++++++++++++ 3 files changed, 3101 insertions(+) create mode 100644 drivers/media/i2c/imx300.c
drivers/media/i2c/Kconfig +13 -0
@@ -801,6 +801,19 @@ config VIDEO_IMX290 To compile this driver as a module, choose M here: the module will be called imx290. +config VIDEO_IMX300 + tristate "Sony IMX300 Exmor RS sensor support" + depends on I2C && VIDEO_V4L2 + select MEDIA_CONTROLLER + select VIDEO_V4L2_SUBDEV_API + select V4L2_FWNODE + help + This is a Video4Linux2 sensor driver for the Sony + IMX300 Exmor RS multi-aspect sensor. + + To compile this driver as a module, choose M here: the + module will be called imx300. + config VIDEO_IMX319 tristate "Sony IMX319 sensor support" depends on I2C && VIDEO_V4L2
drivers/media/i2c/Makefile +1 -0
@@ -117,6 +117,7 @@ obj-$(CONFIG_VIDEO_IMX219) += imx219.o obj-$(CONFIG_VIDEO_IMX258) += imx258.o obj-$(CONFIG_VIDEO_IMX274) += imx274.o obj-$(CONFIG_VIDEO_IMX290) += imx290.o +obj-$(CONFIG_VIDEO_IMX300) += imx300.o obj-$(CONFIG_VIDEO_IMX319) += imx319.o obj-$(CONFIG_VIDEO_IMX355) += imx355.o obj-$(CONFIG_VIDEO_MAX9286) += max9286.o
drivers/media/i2c/imx300.c new file +3087 -0
2,974 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.28.0
Part of the diff is not shown here. View the raw message.
Re: [PATCH 1/2] media: i2c: Add driver for the Sony Exmor-RS IMX300 camera sensor
Hi,
url: https://github.com/0day-ci/linux/commits/kholk11-gmail-com/Add-support-for-the-Sony-Exmor-RS-IMX300-camera-sensor/20201018-203244 base: git://linuxtv.org/media_tree.git master config: x86_64-randconfig-m001-20201022 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
smatch warnings:drivers/media/i2c/imx300.c:2413 imx300_set_framefmt() error: uninitialized symbol 'ret'.
vim +/ret +2413 drivers/media/i2c/imx300.c
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2377 static int imx300_set_framefmt(struct imx300 *imx300)
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2378 {
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2379 int ret;
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2380
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2381 switch (imx300->fmt.code) {
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2382 case MEDIA_BUS_FMT_SRGGB8_1X8:
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2383 fallthrough;
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2384 case MEDIA_BUS_FMT_SGRBG8_1X8:
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2385 fallthrough;
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2386 case MEDIA_BUS_FMT_SGBRG8_1X8:
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2387 fallthrough;These fallthrough annotations are not required.
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2388 case MEDIA_BUS_FMT_SBGGR8_1X8: c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2389 ret = imx300_write_regs(imx300, raw8_framefmt_regs, c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2390 ARRAY_SIZE(raw8_framefmt_regs)); c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2391 if (ret) c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2392 return ret; c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2393 imx300->cur_bps = 8; c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2394 break; c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2395 case MEDIA_BUS_FMT_SRGGB10_1X10: c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2396 fallthrough; c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2397 case MEDIA_BUS_FMT_SGRBG10_1X10: c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2398 fallthrough; c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2399 case MEDIA_BUS_FMT_SGBRG10_1X10: c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2400 fallthrough;
It would look a lot nicer with the annotations removed. Fall through is assumed with an empty label.
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2401 case MEDIA_BUS_FMT_SBGGR10_1X10: c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2402 ret = imx300_write_regs(imx300, raw10_framefmt_regs, c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2403 ARRAY_SIZE(raw10_framefmt_regs)); c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2404 if (ret) c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2405 return ret; c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2406 imx300->cur_bps = 10; c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2407 break;
No default case.
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2408 } c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2409 c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2410 /* Update the pixel rate to eventually save some power */ c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2411 __v4l2_ctrl_s_ctrl_int64(imx300->pixel_rate, get_pixel_rate(imx300)); c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2412
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 @2413 return ret;
Just "return 0;" It's more readable to return a literal.
c82629fb21ade4 AngeloGioacchino Del Regno 2020-10-18 2414 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 2/2 media: dt-bindings: media: i2c: Add IMX300 CMOS sensor binding
In reply to [email protected]From: AngeloGioacchino Del Regno <[email protected]>
Add YAML device tree binding for IMX300 CMOS image sensor, and the relevant MAINTAINERS entries.
--- .../devicetree/bindings/media/i2c/imx300.yaml | 115 ++++++++++++++++++ MAINTAINERS | 8 ++ 2 files changed, 123 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/imx300.yaml
Documentation/devicetree/bindings/media/i2c/imx300.yaml new file +115 -0
@@ -0,0 +1,115 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/imx300.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony 1/2.3-Inch 8Mpixel Stacked CMOS Digital Image Sensor + +maintainers: + - AngeloGioacchino Del Regno <[email protected]> + +description: |- + The Sony IMX300 is a 1/2.3-inch Stacked CMOS (Exmor-RS) digital image + sensor with a pixel size of 1.08um and an active array size of + 5948H x 4140V. It is programmable through I2C interface at address 0x10. + Image data is sent through MIPI CSI-2, which is configured as either 2 or + 4 data lanes. + +properties: + compatible: + const: sony,imx300 + + reg: + description: I2C device address + maxItems: 1 + + clocks: + maxItems: 1 + + VDIG-supply: + description: + Digital I/O voltage supply, 1.15-1.20 volts + + VANA-supply: + description: + Analog voltage supply, 2.2 volts + + VDDL-supply: + description: + Digital core voltage supply, 1.8 volts + + reset-gpios: + description: |- + Reference to the GPIO connected to the xclr pin, if any. + Must be released (set high) after all supplies are applied. + + # See ../video-interfaces.txt for more details + port: + type: object + properties: + endpoint: + type: object + properties: + data-lanes: + description: |- + The sensor supports either two-lane, or four-lane operation. + If this property is omitted four-lane operation is assumed. + For four-lane operation the property must be set to <0 1 2 3>. + items: + - const: 0 + - const: 1 + - const: 2 + - const: 3 + + clock-noncontinuous: + type: boolean + description: |- + MIPI CSI-2 clock is non-continuous if this property is present, + otherwise it's continuous. + + link-frequencies: + $ref: /schemas/types.yaml#/definitions/uint64-array + description: + Allowed data bus frequencies. + + required: + - link-frequencies + +required: + - compatible + - reg + - clocks + - VANA-supply + - VDIG-supply + - VDDL-supply + - port + +additionalProperties: false + +examples: + - | + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + imx300: sensor@10 { + compatible = "sony,imx300"; + reg = <0x10>; + clocks = <&imx300_xclk>; + VANA-supply = <&imx300_vana>; /* 2.2v */ + VDIG-supply = <&imx300_vdig>; /* 1.2v */ + VDDL-supply = <&imx300_vddl>; /* 1.8v */ + + port { + imx300_0: endpoint { + remote-endpoint = <&csi1_ep>; + data-lanes = <0 1 2 3>; + clock-noncontinuous; + link-frequencies = /bits/ 64 <780000000 480000000>; + }; + }; + }; + }; + +...
MAINTAINERS +8 -0
@@ -16279,6 +16279,14 @@ T: git git://linuxtv.org/media_tree.git F: Documentation/devicetree/bindings/media/i2c/imx290.txt F: drivers/media/i2c/imx290.c +SONY IMX300 SENSOR DRIVER +M: AngeloGioacchino Del Regno <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media_tree.git +F: Documentation/devicetree/bindings/media/i2c/imx300.yaml +F: drivers/media/i2c/imx300.c + SONY IMX319 SENSOR DRIVER M: Bingbu Cao <[email protected]> L: [email protected]
Signature · 1 line
2.28.0
Re: [PATCH 2/2] media: dt-bindings: media: i2c: Add IMX300 CMOS sensor binding
Quoted 33 lines · On Sun, 18 Oct 2020 at 14:36, <[email protected]> wrote:
From: AngeloGioacchino Del Regno <[email protected]>
Add YAML device tree binding for IMX300 CMOS image sensor, and the relevant
MAINTAINERSentries.Signed-off-by AngeloGioacchino Del Regno <[email protected]>--- .../devicetree/bindings/media/i2c/imx300.yaml | 115 ++++++++++++++++++ MAINTAINERS | 8 ++ 2 files changed, 123 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/imx300.yamlDocumentation/devicetree/bindings/media/i2c/imx300.yaml new file +14
-0@@ -0,0 +1,115 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/imx300.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony 1/2.3-Inch 8Mpixel Stacked CMOS Digital Image Sensor + +maintainers: + - AngeloGioacchino Del Regno <[email protected]> + +description: |- + The Sony IMX300 is a 1/2.3-inch Stacked CMOS (Exmor-RS) digital image + sensor with a pixel size of 1.08um and an active array size of
Documentation/devicetree/bindings/media/i2c/imx300.yaml line 24
Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/imx300.yaml new file +10
-0+ 5948H x 4140V. It is programmable through I2C interface at address 0x10. + Image data is sent through MIPI CSI-2, which is configured as either 2 or + 4 data lanes. + +properties: + compatible: + const: sony,imx300 + + reg: + description: I2C device address
Skip the description, it is obvious.
Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/imx300.yaml new file +4
-0+ maxItems: 1 + + clocks: + maxItems: 1
Documentation/devicetree/bindings/media/i2c/imx300.yaml line 38
Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/imx300.yaml new file +10
-0+ + VDIG-supply: + description: + Digital I/O voltage supply, 1.15-1.20 volts + + VANA-supply: + description: + Analog voltage supply, 2.2 volts + + VDDL-supply:
Lower-case for all three supplies.
Quoted 15 lines
Documentation/devicetree/bindings/media/i2c/imx300.yaml new file +15
-0+ description: + Digital core voltage supply, 1.8 volts + + reset-gpios: + description: |- + Reference to the GPIO connected to the xclr pin, if any. + Must be released (set high) after all supplies are applied. + + # See ../video-interfaces.txt for more details + port: + type: object + properties: + endpoint: + type: object + properties:
Documentation/devicetree/bindings/media/i2c/imx300.yaml line 63
Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/imx300.yaml new file +10
-0+ data-lanes: + description: |- + The sensor supports either two-lane, or four-lane operation. + If this property is omitted four-lane operation is assumed. + For four-lane operation the property must be set to <0 1 2 3>. + items: + - const: 0 + - const: 1 + - const: 2 + - const: 3
You miss here two-lane option (oneOf). Seems there is a default, so you could add here "default: <0 1 2 3>
Quoted 57 lines
Documentation/devicetree/bindings/media/i2c/imx300.yaml new file +52
-0+ + clock-noncontinuous: + type: boolean + description: |- + MIPI CSI-2 clock is non-continuous if this property is present, + otherwise it's continuous. + + link-frequencies: + $ref: /schemas/types.yaml#/definitions/uint64-array + description: + Allowed data bus frequencies. + + required: + - link-frequencies + +required: + - compatible + - reg + - clocks + - VANA-supply + - VDIG-supply + - VDDL-supply + - port + +additionalProperties: false + +examples: + - | + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + imx300: sensor@10 { + compatible = "sony,imx300"; + reg = <0x10>; + clocks = <&imx300_xclk>; + VANA-supply = <&imx300_vana>; /* 2.2v */ + VDIG-supply = <&imx300_vdig>; /* 1.2v */ + VDDL-supply = <&imx300_vddl>; /* 1.8v */ + + port { + imx300_0: endpoint { + remote-endpoint = <&csi1_ep>; + data-lanes = <0 1 2 3>; + clock-noncontinuous; + link-frequencies = /bits/ 64 <780000000 480000000>; + }; + }; + }; + }; + +...MAINTAINERS +0
-0
MAINTAINERS T: git git://linuxtv.org/media_tree.git · line 16286
Quoted 8 lines
MAINTAINERS +5
-0@@ -16279,6 +16279,14 @@ T: git git://linuxtv.org/media_tree.git F: Documentation/devicetree/bindings/media/i2c/imx290.txt F: drivers/media/i2c/imx290.c +SONY IMX300 SENSOR DRIVER +M: AngeloGioacchino Del Regno <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media_tree.git
Skip the Git tree, unless you manage it.
Best regards,
Krzysztof
Rob Herring
maintainerRe: [PATCH 2/2] media: dt-bindings: media: i2c: Add IMX300 CMOS sensor binding
In reply to [email protected]Quoted 8 lines · On Sun, Oct 18, 2020 at 02:31:06PM +0200, [email protected] wrote:
From: AngeloGioacchino Del Regno <[email protected]>
Add YAML device tree binding for IMX300 CMOS image sensor, and the relevant
MAINTAINERSentries.Signed-off-by AngeloGioacchino Del Regno <[email protected]>--- .../devicetree/bindings/media/i2c/imx300.yaml | 115 ++++++++++++++++++
sony,imx300.yaml
Quoted 69 lines
MAINTAINERS | 8 ++ 2 files changed, 123 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/imx300.yamlDocumentation/devicetree/bindings/media/i2c/imx300.yaml new file +59
-0@@ -0,0 +1,115 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/imx300.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony 1/2.3-Inch 8Mpixel Stacked CMOS Digital Image Sensor + +maintainers: + - AngeloGioacchino Del Regno <[email protected]> + +description: |- + The Sony IMX300 is a 1/2.3-inch Stacked CMOS (Exmor-RS) digital image + sensor with a pixel size of 1.08um and an active array size of + 5948H x 4140V. It is programmable through I2C interface at address 0x10. + Image data is sent through MIPI CSI-2, which is configured as either 2 or + 4 data lanes. + +properties: + compatible: + const: sony,imx300 + + reg: + description: I2C device address + maxItems: 1 + + clocks: + maxItems: 1 + + VDIG-supply: + description: + Digital I/O voltage supply, 1.15-1.20 volts + + VANA-supply: + description: + Analog voltage supply, 2.2 volts + + VDDL-supply: + description: + Digital core voltage supply, 1.8 volts + + reset-gpios: + description: |- + Reference to the GPIO connected to the xclr pin, if any. + Must be released (set high) after all supplies are applied. + + # See ../video-interfaces.txt for more details + port: + type: object + properties: + endpoint: + type: object + properties: + data-lanes: + description: |- + The sensor supports either two-lane, or four-lane operation. + If this property is omitted four-lane operation is assumed. + For four-lane operation the property must be set to <0 1 2 3>. + items:
Documentation/devicetree/bindings/media/i2c/imx300.yaml line 69
Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/imx300.yaml new file +10
-0+ - const: 0 + - const: 1 + - const: 2 + - const: 3 + + clock-noncontinuous: + type: boolean + description: |- + MIPI CSI-2 clock is non-continuous if this property is present, + otherwise it's continuous.
No need to redefine a common property. Just 'clock-noncontinuous: true' to indicate using it.
Documentation/devicetree/bindings/media/i2c/imx300.yaml line 74
Quoted 5 lines
Documentation/devicetree/bindings/media/i2c/imx300.yaml new file +5
-0+ + link-frequencies: + $ref: /schemas/types.yaml#/definitions/uint64-array + description: + Allowed data bus frequencies.
Any constraints on frequencies?
Quoted 63 lines
Documentation/devicetree/bindings/media/i2c/imx300.yaml new file +41
-0+ + required: + - link-frequencies + +required: + - compatible + - reg + - clocks + - VANA-supply + - VDIG-supply + - VDDL-supply + - port + +additionalProperties: false + +examples: + - | + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + imx300: sensor@10 { + compatible = "sony,imx300"; + reg = <0x10>; + clocks = <&imx300_xclk>; + VANA-supply = <&imx300_vana>; /* 2.2v */ + VDIG-supply = <&imx300_vdig>; /* 1.2v */ + VDDL-supply = <&imx300_vddl>; /* 1.8v */ + + port { + imx300_0: endpoint { + remote-endpoint = <&csi1_ep>; + data-lanes = <0 1 2 3>; + clock-noncontinuous; + link-frequencies = /bits/ 64 <780000000 480000000>; + }; + }; + }; + }; + +...MAINTAINERS +8
-0@@ -16279,6 +16279,14 @@ T: git git://linuxtv.org/media_tree.git F: Documentation/devicetree/bindings/media/i2c/imx290.txt F: drivers/media/i2c/imx290.c +SONY IMX300 SENSOR DRIVER +M: AngeloGioacchino Del Regno <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media_tree.git +F: Documentation/devicetree/bindings/media/i2c/imx300.yaml +F: drivers/media/i2c/imx300.c + SONY IMX319 SENSOR DRIVER M: Bingbu Cao <[email protected]> L: [email protected]Signature · 1 line
2.28.0