IMX334 Camera Sensor Driver
Subsystems (4)
v5 cover IMX334 Camera Sensor Driver
From: Martina Krasteva <[email protected]>
Hello,
This patch series contains Sony imx334 sensor driver and device tree binding document.
A v4l2 sub-device driver for the Sony imx334 image sensor is added. This is a camera sensor using the i2c bus for control and the csi-2 bus for data.
The following features are supported:
- manual exposure and analog gain control support
- vblank/hblank/pixel rate control support
- supported resolution:
- 3840x2160 @ 60fps
- supported bayer order output:
- SRGGB12
v1: https://patchwork.kernel.org/project/linux-media/list/?series=388393
v1->v2:
- dt-bindings doc fixes
- minor cosmetic changes
- improvement in write_reg()
- set all media bus format fields to pass v4l2-compliance test
- remove link_validate from source entity
v2: https://patchwork.kernel.org/project/linux-media/list/?series=396393
v2->v3:
- small cosmetic changes
v3: https://patchwork.kernel.org/project/linux-media/list/?series=397689
v3->v4:
- fix read/write_reg() functions
v4: https://patchwork.kernel.org/project/linux-media/list/?series=400459
v4->v5:
- add link-frequencies in dt-bindings doc
- edit required properties in db-bindings doc
- fix data_buf overrun in read_reg()
- add function to parse dt configuration
- allow cahnging vblank in power off state
- change lpfr and ppln with vblank and hblank in mode description
Best Regards,
Martina
Martina Krasteva (2):
dt-bindings: media: Add bindings for imx334
media: i2c: Add imx334 camera sensor driver
.../devicetree/bindings/media/i2c/sony,imx334.yaml | 77 ++ MAINTAINERS | 9 + drivers/media/i2c/Kconfig | 14 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/imx334.c | 1097 ++++++++++++++++++++ 5 files changed, 1198 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml create mode 100644 drivers/media/i2c/imx334.c
base-commit: fd821bf0ed9a7db09d2e007df697f4d9ecfda99a
Signature · 1 line
2.11.0
PATCH v5 1/2 dt-bindings: media: Add bindings for imx334
From: Martina Krasteva <[email protected]>
- Add dt-bindings documentation for Sony imx334 sensor driver.
- Add MAINTAINERS entry for Sony imx334 binding documentation.
--- .../devicetree/bindings/media/i2c/sony,imx334.yaml | 77 ++++++++++++++++++++++ MAINTAINERS | 8 +++ 2 files changed, 85 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml
Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml new file +77 -0
@@ -0,0 +1,77 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2021 Intel Corporation +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/sony,imx334.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony IMX334 Sensor + +maintainers: + - Paul J. Murphy <[email protected]> + - Daniele Alessandrelli <[email protected]> + +description: + IMX334 sensor is a Sony CMOS active pixel digital image sensor with an active + array size of 3864H x 2202V. 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,imx334 + reg: + description: I2C address + maxItems: 1 + + port: + type: object + additionalProperties: false + $ref: /schemas/graph.yaml#/properties/port + + properties: + endpoint: + type: object + properties: + data-lanes: + $ref: ../video-interfaces.yaml#/properties/data-lanes + link-frequencies: + $ref: ../video-interfaces.yaml#/properties/link-frequencies + description: + Allowed data bus frequencies are 891000000, 594000000 and + 455500000 Hz. + + required: + - data-lanes + - link-frequencies + + required: + - endpoint + +required: + - compatible + - reg + - port + +additionalProperties: false + +examples: + - | + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + camera@1a { + compatible = "sony,imx334"; + reg = <0x1a>; + + port { + imx334: endpoint { + remote-endpoint = <&cam>; + data-lanes = <1 2 3 4>; + link-frequencies = /bits/ 64 <891000000>; + }; + }; + }; + }; +...
MAINTAINERS +8 -0
@@ -16589,6 +16589,14 @@ S: Maintained T: git git://linuxtv.org/media_tree.git F: drivers/media/i2c/imx319.c +SONY IMX334 SENSOR DRIVER +M: Paul J. Murphy <[email protected]> +M: Daniele Alessandrelli <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media_tree.git +F: Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml + SONY IMX355 SENSOR DRIVER M: Tianshu Qiu <[email protected]> L: [email protected]
Signature · 1 line
2.11.0
Sakari Ailus
maintainerRe: [PATCH v5 1/2] dt-bindings: media: Add bindings for imx334
Hi Martina,
Quoted 37 lines · Martina Krasteva
From: Martina Krasteva <[email protected]>
- Add dt-bindings documentation for Sony imx334 sensor driver.
- AddMAINTAINERSentry for Sony imx334 binding documentation.Signed-off-by Martina Krasteva <[email protected]>Reviewed-by Gjorgji Rosikopulos <[email protected]>Acked-by Paul J. Murphy <[email protected]>Reviewed-by Rob Herring <[email protected]>--- .../devicetree/bindings/media/i2c/sony,imx334.yaml | 77 ++++++++++++++++++++++ MAINTAINERS | 8 +++ 2 files changed, 85 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/sony,imx334.yamlDocumentation/devicetree/bindings/media/i2c/sony,imx334.yaml new file +15
-0@@ -0,0 +1,77 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2021 Intel Corporation +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/sony,imx334.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sony IMX334 Sensor + +maintainers: + - Paul J. Murphy <[email protected]> + - Daniele Alessandrelli <[email protected]> + +description: + IMX334 sensor is a Sony CMOS active pixel digital image sensor with an active
Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml line 25
Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml new file +10
-0+ array size of 3864H x 2202V. 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,imx334 + reg: + description: I2C address + maxItems: 1
Could you also add the clock properties such as in here:
Quoted 7 lines
Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml new file +7
-0+ + port: + type: object + additionalProperties: false + $ref: /schemas/graph.yaml#/properties/port + + properties:
Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml line 42
Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml new file +10
-0+ endpoint: + type: object + properties: + data-lanes: + $ref: ../video-interfaces.yaml#/properties/data-lanes + link-frequencies: + $ref: ../video-interfaces.yaml#/properties/link-frequencies + description: + Allowed data bus frequencies are 891000000, 594000000 and + 455500000 Hz.
These frequencies are those supported by the driver, aren't they, not those supported by the sensor (of which many support virtually almost the entire range from some 100 MHz to 1 GHz, depending on the external clock frequency)?
If so, please drop the description from link-frequencies, or adjust it to what the sensor actually supports.
Quoted 54 lines
Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml new file +35
-0+ + required: + - data-lanes + - link-frequencies + + required: + - endpoint + +required: + - compatible + - reg + - port + +additionalProperties: false + +examples: + - | + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + camera@1a { + compatible = "sony,imx334"; + reg = <0x1a>; + + port { + imx334: endpoint { + remote-endpoint = <&cam>; + data-lanes = <1 2 3 4>; + link-frequencies = /bits/ 64 <891000000>; + }; + }; + }; + }; +...MAINTAINERS +8
-0@@ -16589,6 +16589,14 @@ S: Maintained T: git git://linuxtv.org/media_tree.git F: drivers/media/i2c/imx319.c +SONY IMX334 SENSOR DRIVER +M: Paul J. Murphy <[email protected]> +M: Daniele Alessandrelli <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media_tree.git +F: Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml + SONY IMX355 SENSOR DRIVER M: Tianshu Qiu <[email protected]> L: [email protected]
Signature · 3 lines
Kind regards, Sakari Ailus
PATCH v5 2/2 media: i2c: Add imx334 camera sensor driver
In reply to Martina KrastevaFrom: Martina Krasteva <[email protected]>
Add a v4l2 sub-device driver for the Sony imx334 image sensor. This is a camera sensor using the i2c bus for control and the csi-2 bus for data.
The following features are supported:
- manual exposure and analog gain control support
- vblank/hblank/pixel rate control support
- supported resolution:
- 3840x2160 @ 60fps
- supported bayer order output:
- SRGGB12
--- MAINTAINERS | 1 + drivers/media/i2c/Kconfig | 14 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/imx334.c | 1097 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1113 insertions(+) create mode 100644 drivers/media/i2c/imx334.c
MAINTAINERS +1 -0
@@ -16596,6 +16596,7 @@ L: [email protected] S: Maintained T: git git://linuxtv.org/media_tree.git F: Documentation/devicetree/bindings/media/i2c/sony,imx334.yaml +F: drivers/media/i2c/imx334.c SONY IMX355 SENSOR DRIVER M: Tianshu Qiu <[email protected]>
drivers/media/i2c/Kconfig +14 -0
@@ -813,6 +813,20 @@ config VIDEO_IMX319 To compile this driver as a module, choose M here: the module will be called imx319. +config VIDEO_IMX334 + tristate "Sony IMX334 sensor support" + depends on OF_GPIO + depends on I2C && VIDEO_V4L2 + select VIDEO_V4L2_SUBDEV_API + select MEDIA_CONTROLLER + select V4L2_FWNODE + help + This is a Video4Linux2 sensor driver for the Sony + IMX334 camera. + + To compile this driver as a module, choose M here: the + module will be called imx334. + config VIDEO_IMX355 tristate "Sony IMX355 sensor support" depends on I2C && VIDEO_V4L2
drivers/media/i2c/Makefile +1 -0
@@ -122,6 +122,7 @@ obj-$(CONFIG_VIDEO_IMX258) += imx258.o obj-$(CONFIG_VIDEO_IMX274) += imx274.o obj-$(CONFIG_VIDEO_IMX290) += imx290.o obj-$(CONFIG_VIDEO_IMX319) += imx319.o +obj-$(CONFIG_VIDEO_IMX334) += imx334.o obj-$(CONFIG_VIDEO_IMX355) += imx355.o obj-$(CONFIG_VIDEO_MAX9286) += max9286.o rdacm20-camera_module-objs := rdacm20.o max9271.o
drivers/media/i2c/imx334.c new file +1097 -0
1,097 lines not on this page · raw message
Signature · 1 line
2.11.0
kernel test robot
build botRe: [PATCH v5 2/2] media: i2c: Add imx334 camera sensor driver
Thank you for the patch! Perhaps something to improve:
Hi Martina,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on fd821bf0ed9a7db09d2e007df697f4d9ecfda99a]
url: https://github.com/0day-ci/linux/commits/Martina-Krasteva/IMX334-Camera-Sensor-Driver/20210202-094552 base: fd821bf0ed9a7db09d2e007df697f4d9ecfda99a config: nds32-randconfig-r031-20210202 (attached as .config) compiler: nds32le-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/57bf371289c42fe7cc648f2de6cd6680df675f09
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Martina-Krasteva/IMX334-Camera-Sensor-Driver/20210202-094552 git checkout 57bf371289c42fe7cc648f2de6cd6680df675f09
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/media/i2c/imx334.c:751:5: warning: no previous prototype for 'imx334_parse_hw_config' [-Wmissing-prototypes]
751 | int imx334_parse_hw_config(struct imx334 *imx334)
| ^~~~~~~~~~~~~~~~~~~~~~vim +/imx334_parse_hw_config +751 drivers/media/i2c/imx334.c
744
745 /**
746 * imx334_parse_hw_config() - Parse HW configuration and check if supported
747 * @imx334: pointer to imx334 device
748 *
749 * Return: 0 if successful, error code otherwise.
750 */
> 751 int imx334_parse_hw_config(struct imx334 *imx334)
752 {
753 struct fwnode_handle *fwnode = dev_fwnode(imx334->dev);
754 struct v4l2_fwnode_endpoint bus_cfg = {
755 .bus_type = V4L2_MBUS_CSI2_DPHY
756 };
757 struct fwnode_handle *ep;
758 unsigned long rate;
759 int ret;
760 int i;
761
762 if (!fwnode)
763 return -ENXIO;
764
765 /* Request optional reset pin */
766 imx334->reset_gpio = devm_gpiod_get_optional(imx334->dev, "reset",
767 GPIOD_OUT_LOW);
768 if (IS_ERR(imx334->reset_gpio)) {
769 dev_err(imx334->dev, "failed to get reset gpio %d", ret);
770 return PTR_ERR(imx334->reset_gpio);
771 }
772
773 /* Get sensor input clock */
774 imx334->inclk = devm_clk_get(imx334->dev, "inclk");
775 if (IS_ERR(imx334->inclk)) {
776 dev_err(imx334->dev, "could not get inclk");
777 return PTR_ERR(imx334->inclk);
778 }
779
780 rate = clk_get_rate(imx334->inclk);
781 if (rate != IMX334_INCLK_RATE) {
782 dev_err(imx334->dev, "inclk frequency mismatch");
783 return -EINVAL;
784 }
785
786 ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
787 if (!ep)
788 return -ENXIO;
789
790 ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
791 fwnode_handle_put(ep);
792 if (ret)
793 return ret;
794
795 if (bus_cfg.bus.mipi_csi2.num_data_lanes != IMX334_NUM_DATA_LANES) {
796 dev_err(imx334->dev,
797 "number of CSI2 data lanes %d is not supported",
798 bus_cfg.bus.mipi_csi2.num_data_lanes);
799 ret = -EINVAL;
800 goto done_endpoint_free;
801 }
802
803 if (!bus_cfg.nr_of_link_frequencies) {
804 dev_err(imx334->dev, "no link frequencies defined");
805 ret = -EINVAL;
806 goto done_endpoint_free;
807 }
808
809 for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++)
810 if (bus_cfg.link_frequencies[i] == IMX334_LINK_FREQ)
811 goto done_endpoint_free;
812
813 ret = -EINVAL;
814
815 done_endpoint_free:
816 v4l2_fwnode_endpoint_free(&bus_cfg);
817
818 return ret;
819 }
820
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
kernel test robot
build botRe: [PATCH v5 2/2] media: i2c: Add imx334 camera sensor driver
In reply to Martina KrastevaThank you for the patch! Perhaps something to improve:
Hi Martina,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on fd821bf0ed9a7db09d2e007df697f4d9ecfda99a]
url: https://github.com/0day-ci/linux/commits/Martina-Krasteva/IMX334-Camera-Sensor-Driver/20210202-094552 base: fd821bf0ed9a7db09d2e007df697f4d9ecfda99a config: arm-randconfig-r026-20210202 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 275c6af7d7f1ed63a03d05b4484413e447133269)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/0day-ci/linux/commit/57bf371289c42fe7cc648f2de6cd6680df675f09
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Martina-Krasteva/IMX334-Camera-Sensor-Driver/20210202-094552 git checkout 57bf371289c42fe7cc648f2de6cd6680df675f09
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/media/i2c/imx334.c:751:5: warning: no previous prototype for function 'imx334_parse_hw_config' [-Wmissing-prototypes]
int imx334_parse_hw_config(struct imx334 *imx334)
^
drivers/media/i2c/imx334.c:751:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int imx334_parse_hw_config(struct imx334 *imx334)
^
static
>> drivers/media/i2c/imx334.c:769:55: warning: variable 'ret' is uninitialized when used here [-Wuninitialized]
dev_err(imx334->dev, "failed to get reset gpio %d", ret);
^~~
include/linux/dev_printk.h:112:32: note: expanded from macro 'dev_err'
_dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
drivers/media/i2c/imx334.c:759:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 02 warnings generated.
vim +/imx334_parse_hw_config +751 drivers/media/i2c/imx334.c
744
745 /**
746 * imx334_parse_hw_config() - Parse HW configuration and check if supported
747 * @imx334: pointer to imx334 device
748 *
749 * Return: 0 if successful, error code otherwise.
750 */
> 751 int imx334_parse_hw_config(struct imx334 *imx334)
752 {
753 struct fwnode_handle *fwnode = dev_fwnode(imx334->dev);
754 struct v4l2_fwnode_endpoint bus_cfg = {
755 .bus_type = V4L2_MBUS_CSI2_DPHY
756 };
757 struct fwnode_handle *ep;
758 unsigned long rate;
759 int ret;
760 int i;
761
762 if (!fwnode)
763 return -ENXIO;
764
765 /* Request optional reset pin */
766 imx334->reset_gpio = devm_gpiod_get_optional(imx334->dev, "reset",
767 GPIOD_OUT_LOW);
768 if (IS_ERR(imx334->reset_gpio)) {
> 769 dev_err(imx334->dev, "failed to get reset gpio %d", ret); 770 return PTR_ERR(imx334->reset_gpio);
771 }
772
773 /* Get sensor input clock */
774 imx334->inclk = devm_clk_get(imx334->dev, "inclk");
775 if (IS_ERR(imx334->inclk)) {
776 dev_err(imx334->dev, "could not get inclk");
777 return PTR_ERR(imx334->inclk);
778 }
779
780 rate = clk_get_rate(imx334->inclk);
781 if (rate != IMX334_INCLK_RATE) {
782 dev_err(imx334->dev, "inclk frequency mismatch");
783 return -EINVAL;
784 }
785
786 ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
787 if (!ep)
788 return -ENXIO;
789
790 ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
791 fwnode_handle_put(ep);
792 if (ret)
793 return ret;
794
795 if (bus_cfg.bus.mipi_csi2.num_data_lanes != IMX334_NUM_DATA_LANES) {
796 dev_err(imx334->dev,
797 "number of CSI2 data lanes %d is not supported",
798 bus_cfg.bus.mipi_csi2.num_data_lanes);
799 ret = -EINVAL;
800 goto done_endpoint_free;
801 }
802
803 if (!bus_cfg.nr_of_link_frequencies) {
804 dev_err(imx334->dev, "no link frequencies defined");
805 ret = -EINVAL;
806 goto done_endpoint_free;
807 }
808
809 for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++)
810 if (bus_cfg.link_frequencies[i] == IMX334_LINK_FREQ)
811 goto done_endpoint_free;
812
813 ret = -EINVAL;
814
815 done_endpoint_free:
816 v4l2_fwnode_endpoint_free(&bus_cfg);
817
818 return ret;
819 }
820
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]