Skip to contentSkip to conversation

media: i2c: Add support for alvium camera

PATCH Superseded Tommaso Merciai 2 participants 6 messages Jun 20, 2023 – Jun 28, 2023

Subsystems (3)

v7 of 15 Superseded Latest is v15 →

lore
Share & tools
lore

Tommaso Merciai

author maintainer
#0 lore raw

v7 cover media: i2c: Add support for alvium camera

Hello All,

This series add support for Allied Vision Alvium camera. The Alvium camera is shipped with sensor + isp in the same housing. The camera can be equipped with one out of various sensor and abstract the user from this. Camera is connected via MIPI CSI-2.

Working on top of Ideas on Board (branch: ideasonboard/v6.2/isi) I'm able to test the driver on imx8mp-evk.
I collect also some patches to enable HDMI on imx8mp-evk from Pengutronix (branch: pengutronix-imx8mp-hdmi)

I collect the patchset required to enable ISI + HDMI on imx8mp-evk into the following branch from Avnet Silica Software & Services EMEA [1].

Some documentation on testing ISP and ISI of imx8mp-evk here [2].

Thanks all for the great work!

[1] - https://github.com/avs-sas/linux/tree/tm/ideasonboard/v6.4.0-rc2/isi/imx8mp_evk/alvium_drv_skel1e_v1
[2] - https://gist.github.com/Scott31393/077a10024a6058536d3f2fdde476265a

Tommaso Merciai (3):
dt-bindings: vendor-prefixes: Add prefix alliedvision
media: dt-bindings: alvium: add document YAML binding
media: i2c: Add support for alvium camera

 .../media/i2c/alliedvision,alvium-csi2.yaml   |   97 +
 .../devicetree/bindings/vendor-prefixes.yaml  |    2 +
 MAINTAINERS                                   |    9 +
 drivers/media/i2c/Kconfig                     |   11 +
 drivers/media/i2c/Makefile                    |    1 +
 drivers/media/i2c/alvium-csi2.c               | 2767 +++++++++++++++++
 drivers/media/i2c/alvium-csi2.h               |  474 +++
 7 files changed, 3361 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/alliedvision,alvium-csi2.yaml
 create mode 100644 drivers/media/i2c/alvium-csi2.c
 create mode 100644 drivers/media/i2c/alvium-csi2.h
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH v7 1/3 dt-bindings: vendor-prefixes: Add prefix alliedvision

Add a vendor prefix entry for Allied Vision Inc.
(https://www.alliedvision.com)

---
Changes since v3:
- Collected tags from LPinchart, CDooley, KKozlowski

 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 82d39ab0231b..7bd678956b3d 100644
@@ -77,6 +77,8 @@ patternProperties:
     description: ALFA Network Inc.
   "^allegro,.*":
     description: Allegro DVT
+  "^alliedvision,.*":
+    description: Allied Vision Inc.
   "^allo,.*":
     description: Allo.com
   "^allwinner,.*":
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v7 2/3 media: dt-bindings: alvium: add document YAML binding

In reply to Tommaso Merciai

Add documentation of device tree in YAML schema for the ALVIUM Camera from Allied Vision Inc.

References:
- https://www.alliedvision.com/en/products/embedded-vision-solutions

---
Changes since v1:
- Fixed build error as suggested by RHerring bot

Changes since v2:
- Fixed License as suggested by KKozlowski/CDooley
- Removed rotation property as suggested by CDooley/LPinchart
- Fixed example node name as suggested by CDooley
- Fixed title as suggested by LPinchart
- Fixed compatible name as suggested by LPinchart
- Removed clock as suggested by LPinchart
- Removed gpios not as suggested by LPinchart
- Renamed property name streamon-delay into alliedvision,lp2hs-delay-us
- Fixed vendor prefix, unit append as suggested by KKozlowski
- Fixed data-lanes
- Fixed blank space + example indentation (from 6 -> 4 space) as suggested by KKozlowski
- Dropped status into example as suggested by KKozlowski
- Added vcc-ext-in supply as suggested by LPinchart
- Dropped pinctrl into example as suggested by LPinchart

Changes since v3:
- Fixed vcc-ext-in-supply description as suggested by LPinchart
- Fixed alliedvision,lp2hs-delay-us description as suggested by LPinchart
- Added maximum to alliedvision,lp2hs-delay-us as suggested by LPinchart
- Collected Reviewed-by tag from LPinchart

Changes since v4:
- Fixed id as reported by RHerring bot and LPinchart
- Add minimum into alliedvision,lp2hs-delay-us as suggested by CDooley
- Tested using make dt_binding_check DT_SCHEMA_FILES=alliedvision,alvium-csi2.yaml

Changes since v5:
- Fixed alliedvision,lp2hs-delay-us description as suggested by CDooley
- Collected CDooley Reviewed-by tag

 .../media/i2c/alliedvision,alvium-csi2.yaml   | 97 +++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/alliedvision,alvium-csi2.yaml
Documentation/devicetree/bindings/media/i2c/alliedvision,alvium-csi2.yaml new file +97 -0
new file mode 100644
index 000000000000..327cd5421257
@@ -0,0 +1,97 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/alliedvision,alvium-csi2.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allied Vision Alvium Camera
+
+maintainers:
+  - Tommaso Merciai <[email protected]>
+  - Martin Hecht <[email protected]>
+
+allOf:
+  - $ref: /schemas/media/video-interface-devices.yaml#
+
+properties:
+  compatible:
+    const: alliedvision,alvium-csi2
+
+  reg:
+    maxItems: 1
+
+  vcc-ext-in-supply:
+    description: |
+      The regulator that supplies power to the VCC_EXT_IN pins.
+
+  alliedvision,lp2hs-delay-us:
+    minimum: 1
+    maximum: 150000
+    description: |
+      Low power to high speed delay time.
+
+      If the value is present, the camera forces a reset of all
+      D-PHY lanes for the duration specified by this property. All lanes
+      will transition to the low-power state and back to the high-speed
+      state after the delay. Otherwise the lanes will transition to and
+      remain in the high-speed state immediately after power on.
+
+      This is meant to help CSI-2 receivers synchronizing their D-PHY
+      RX.
+
+  port:
+    description: Digital Output Port
+    $ref: /schemas/graph.yaml#/$defs/port-base
+    additionalProperties: false
+
+    properties:
+      endpoint:
+        $ref: /schemas/media/video-interfaces.yaml#
+        unevaluatedProperties: false
+
+        properties:
+          link-frequencies: true
+
+          data-lanes:
+            minItems: 1
+            items:
+              - const: 1
+              - const: 2
+              - const: 3
+              - const: 4
+
+        required:
+          - data-lanes
+          - link-frequencies
+
+required:
+  - compatible
+  - reg
+  - vcc-ext-in-supply
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        alvium: camera@3c {
+            compatible = "alliedvision,alvium-csi2";
+            reg = <0x3c>;
+            vcc-ext-in-supply = <&reg_vcc_ext_in>;
+            alliedvision,lp2hs-delay-us = <20>;
+
+            port {
+                alvium_out: endpoint {
+                    remote-endpoint = <&mipi_csi_0_in>;
+                    data-lanes = <1 2 3 4>;
+                    link-frequencies = /bits/ 64 <681250000>;
+                };
+            };
+        };
+    };
+
+...
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH v7 3/3 media: i2c: Add support for alvium camera

In reply to Tommaso Merciai

The Alvium camera is shipped with sensor + isp in the same housing. The camera can be equipped with one out of various sensor and abstract the user from this. Camera is connected via MIPI CSI-2.

Most of the camera module features are supported, with the main exception being fw update.

The driver provides all mandatory, optional and recommended V4L2 controls for maximum compatibility with libcamera

References:
- https://www.alliedvision.com/en/products/embedded-vision-solutions

---
Changes since v2:
- Removed gpios/clock handling as suggested by LPinchart
- Added vcc-ext-in supply support as suggested by LPinchart
- Fixed alvium_setup_mipi_fmt funct as suggested by CJAILLET
- Removed upside_down/hshake_bit priv data as suggested by CJAILLET
- Fixed commit body as suggested by LPinchart
- Mv alvium_set_streamon_delay to yalvium_set_lp2hs_delay
- Fixed comment on lp2hs prop as suggested by LPinchart
- Added pm resume/suspend functs as suggested by LPinchart
- Dropped alvium_link_setup/alvium_s_power as suggested by LPinchart
- Fixed regs defines as suggested by LPinchart
- Fixed typedef as suggested by LPinchart
- Dropped bcrm_v/fw_v from priv data as suggested by LPinchart
- Now driver use the subdev active state to store the active format and crop as suggested by LPinchart
- Dropped alvium_is_csi2/i2c_to_alvium as suggested by LPinchart

Changes since v3:
- Fixed warnings Reported-by: kernel test robot <[email protected]>

Changes since v4:
- Removed print into alvium_get_dt_data for alliedvision,lp2hs-delay-us as suggested by CDooley

Changes since v5:
- Used tab instead of space in .h as suggested by SAilus
- Added support for new CCI API from HDeGoede as suggested by SAilus
- Fixed alvium_write/alvium_read, functions now using the new CCI api, suggested by LPinchart
- Fixed alvium_get_feat_inq func as suggested by SAilus
- Fixed indentation/var-order/includes-order as suggested by SAilus
- Fixed alvium_csi2_fmts with MIPI_CSI2_DT_ defines as suggested by SAilus
- Fixed alvium_is_alive as suggested by SAilus
- Fixed alvium_code_to_pixfmt funct as suggested by SAilus
- Fixed alvium_get_dt_data function, now use only fwnode as suggested by SAilus
- Fixed autosuspend into the probe, is disable as default as suggested by SAilus
- Fixed alvium_get_dt_data function, assigned bus type before parsing the ep as suggested by SAilus
- Fixed alvium_power_off, removed wrong print as suggested by SAilus

Changes since v6:
- Fixed .h indentation
- Fixed function params indentation
- Added int *err params for alvium_read/alvium_write as suggested by LPinchart
- Removed dbg print from the driver, driver is now using dbg/err prints that comes from new cci API as suggested by LPinchart. This, fits SAilus suggestion on common pattern function.
- Fixed alvium_write_hshake, now use read_poll_timeout as suggested by LPinchart
- Removed useless includes
- Added maintainers file entries

 MAINTAINERS                     |    9 +
 drivers/media/i2c/Kconfig       |   11 +
 drivers/media/i2c/Makefile      |    1 +
 drivers/media/i2c/alvium-csi2.c | 2767 +++++++++++++++++++++++++++++++
 drivers/media/i2c/alvium-csi2.h |  474 ++++++
 5 files changed, 3262 insertions(+)
 create mode 100644 drivers/media/i2c/alvium-csi2.c
 create mode 100644 drivers/media/i2c/alvium-csi2.h
MAINTAINERS +9 -0
index 477bcc4557f9..ab4e97a33f77 100644
@@ -776,6 +776,15 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/media/allegro,al5e.yaml
 F:	drivers/media/platform/allegro-dvt/
 
+ALLIED VISION ALVIUM CAMERA DRIVER
+M:	Tommaso Merciai <[email protected]>
+M:	Martin Hecht <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/i2c/alliedvision,alvium-csi2.yaml
+F:	drivers/media/i2c/alvium-csi2.c
+F:	drivers/media/i2c/alvium-csi2.h
+
 ALLWINNER A10 CSI DRIVER
 M:	Maxime Ripard <[email protected]>
 L:	[email protected]
drivers/media/i2c/Kconfig +11 -0
index 256d55bb2b1d..d8633c8b351e 100644
@@ -34,6 +34,17 @@ config VIDEO_APTINA_PLL
 config VIDEO_CCS_PLL
 	tristate
 
+config VIDEO_ALVIUM_CSI2
+	tristate "Allied Vision ALVIUM MIPI CSI-2 camera support"
+	depends on I2C
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	select V4L2_CCI
+	help
+	  This is a Video4Linux2 sensor driver for the Allied Vision
+	  ALVIUM camera connected via MIPI CSI-2 interface.
+
 config VIDEO_AR0521
 	tristate "ON Semiconductor AR0521 sensor support"
 	depends on I2C && VIDEO_DEV
drivers/media/i2c/Makefile +1 -0
index b44dacf935f4..be4dddd6fd98 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_VIDEO_ADV7604) += adv7604.o
 obj-$(CONFIG_VIDEO_ADV7842) += adv7842.o
 obj-$(CONFIG_VIDEO_AK7375) += ak7375.o
 obj-$(CONFIG_VIDEO_AK881X) += ak881x.o
+obj-$(CONFIG_VIDEO_ALVIUM_CSI2) += alvium-csi2.o
 obj-$(CONFIG_VIDEO_APTINA_PLL) += aptina-pll.o
 obj-$(CONFIG_VIDEO_AR0521) += ar0521.o
 obj-$(CONFIG_VIDEO_BT819) += bt819.o
drivers/media/i2c/alvium-csi2.c new file +2767 -0

2,767 lines not on this page · raw message

drivers/media/i2c/alvium-csi2.h new file +474 -0

194 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.34.1

Part of the diff is not shown here. View the raw message.

#4 lore raw
kernel test robot noticed the following build errors:

Hi Tommaso,

kernel test robot noticed the following build errors:

[auto build test ERROR on media-tree/master]
[also build test ERROR on robh/for-next linus/master v6.4-rc7 next-20230622] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tommaso-Merciai/dt-bindings-vendor-prefixes-Add-prefix-alliedvision/20230620-202420
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20230620122225.58862-4-tomm.merciai%40gmail.com
patch subject: [PATCH v7 3/3] media: i2c: Add support for alvium camera
config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20230623/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20230623/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/media/i2c/alvium-csi2.c:10:
In file included from include/linux/i2c.h:19:
In file included from include/linux/regulator/consumer.h:35:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
In file included from include/linux/memcontrol.h:13:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/hexagon/include/asm/io.h:334:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]

     547 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     560 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from drivers/media/i2c/alvium-csi2.c:10:
   In file included from include/linux/i2c.h:19:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     573 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from drivers/media/i2c/alvium-csi2.c:10:
   In file included from include/linux/i2c.h:19:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     584 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     594 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     604 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   In file included from drivers/media/i2c/alvium-csi2.c:23:
>> drivers/media/i2c/alvium-csi2.h:15:10: fatal error: 'media/v4l2-cci.h' file not found
      15 | #include <media/v4l2-cci.h>
         |          ^~~~~~~~~~~~~~~~~~

6 warnings and 1 error generated.

vim +15 drivers/media/i2c/alvium-csi2.h

    12	
    13	#include <linux/kernel.h>
    14	#include <linux/regulator/consumer.h>
  > 15	#include <media/v4l2-cci.h>
    16	#include <media/v4l2-common.h>
    17	#include <media/v4l2-ctrls.h>
    18	#include <media/v4l2-fwnode.h>
    19	#include <media/v4l2-subdev.h>
    20	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#5 lore raw
In reply to Tommaso Merciai
kernel test robot noticed the following build errors:

Hi Tommaso,

kernel test robot noticed the following build errors:

[auto build test ERROR on media-tree/master]
[also build test ERROR on robh/for-next linus/master v6.4 next-20230627] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Tommaso-Merciai/dt-bindings-vendor-prefixes-Add-prefix-alliedvision/20230620-202420
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20230620122225.58862-4-tomm.merciai%40gmail.com
patch subject: [PATCH v7 3/3] media: i2c: Add support for alvium camera
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20230628/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230628/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/media/i2c/alvium-csi2.c:23:

>> drivers/media/i2c/alvium-csi2.h:15:10: fatal error: media/v4l2-cci.h: No such file or directory
      15 | #include <media/v4l2-cci.h>
         |          ^~~~~~~~~~~~~~~~~~

compilation terminated.

vim +15 drivers/media/i2c/alvium-csi2.h

    12	
    13	#include <linux/kernel.h>
    14	#include <linux/regulator/consumer.h>
  > 15	#include <media/v4l2-cci.h>
    16	#include <media/v4l2-common.h>
    17	#include <media/v4l2-ctrls.h>
    18	#include <media/v4l2-fwnode.h>
    19	#include <media/v4l2-subdev.h>
    20	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki