diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/changelog ipu6-drivers-0~git202404110253.97c94720/debian/changelog --- ipu6-drivers-0~git202311240921.07f0612e/debian/changelog 2024-02-21 22:02:47.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/changelog 2024-04-11 18:38:46.000000000 +0800 @@ -1,3 +1,14 @@ +ipu6-drivers (0~git202404110253.97c94720-0ubuntu1~ppa.1) noble; urgency=medium + + [ You-Sheng Yang ] + * New upstream Release_20240409 release (LP: #2061747) + - drop upstreamed "backport: replace strlcpy with strscpy" patch + - debian: refresh patches + - UBUNTU: SAUCE: firmware: fallback to old firmware path + - UBUNTU: SAUCE: don't fail probing at hwcfg checks + + -- You-Sheng Yang Thu, 11 Apr 2024 18:38:46 +0800 + ipu6-drivers (0~git202311240921.07f0612e-0ubuntu2) noble; urgency=medium [ You-Sheng Yang ] diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0003-build-fix-kernel-feature-macro-definitions.patch ipu6-drivers-0~git202404110253.97c94720/debian/patches/0003-build-fix-kernel-feature-macro-definitions.patch --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0003-build-fix-kernel-feature-macro-definitions.patch 2023-12-02 00:45:55.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/0003-build-fix-kernel-feature-macro-definitions.patch 2024-04-11 18:38:46.000000000 +0800 @@ -12,39 +12,101 @@ Signed-off-by: You-Sheng Yang (vicamo) --- - Makefile | 17 +++++++---------- - 1 file changed, 7 insertions(+), 10 deletions(-) + Makefile | 59 ++++++++++++++++++----------------------------------------- + 1 file changed, 18 insertions(+), 41 deletions(-) diff --git a/Makefile b/Makefile -index bb7e220..a6d4095 100644 +index e133c34..ccd1d49 100644 --- a/Makefile +++ b/Makefile -@@ -32,12 +32,11 @@ mei_pse-y := drivers/misc/ivsc/mei_pse.o +@@ -2,32 +2,17 @@ + # Copyright (c) 2022 Intel Corporation. + + KERNELRELEASE ?= $(shell uname -r) +-KERNEL_VERSION := $(shell echo $(KERNELRELEASE) | sed 's/[^0-9.]*\([0-9.]*\).*/\1/') +- +-version_lt = $(shell \ +- v1=$(1); \ +- v2=$(2); \ +- IFS='.'; \ +- set -- $$v1; i=$$1; j=$$2; k=$$3; \ +- set -- $$v2; a=$$1; b=$$2; c=$$3; \ +- if [ "$$i" -lt "$$a" ]; then \ +- echo "true"; \ +- elif [ "$$i" -eq "$$a" ] && [ "$$j" -lt "$$b" ]; then \ +- echo "true"; \ +- elif [ "$$i" -eq "$$a" ] && [ "$$j" -eq "$$b" ] && [ "$$k" -lt "$$c" ]; then \ +- echo "true"; \ +- else \ +- echo "false"; \ +- fi) +- +-KV_IVSC := 6.6.0 +-KV_IPU_BRIDGE := 6.6.0 ++KERNEL_VERSION = $(word 1,$(subst -, ,$(KERNELRELEASE))) ++ ++version_lt = $(filter-out $(1),$(shell { echo $(1); echo $(2); } | sort -V | tail -1)) ++ + KV_OV2740 := 6.8.0 + + KERNEL_SRC ?= /lib/modules/$(KERNELRELEASE)/build ++KERNEL_CONFIG ?= $(KERNEL_SRC)/.config + MODSRC := $(shell pwd) + +-ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_IVSC)),true) ++ifeq ($(shell grep ^CONFIG_INTEL_VSC=[ym] $(KERNEL_CONFIG)),) + $(warning build ljca ivsc) + obj-m += ljca.o + ljca-y := drivers/mfd/ljca.o +@@ -60,17 +45,19 @@ mei_pse-y := drivers/misc/ivsc/mei_pse.o obj-m += mei_ace_debug.o mei_ace_debug-y := drivers/misc/ivsc/mei_ace_debug.o -export CONFIG_INTEL_VSC = y +export CONFIG_INTEL_VSC = m ++subdir-ccflags-$(CONFIG_INTEL_VSC) += \ ++ -DCONFIG_INTEL_VSC_MODULE=1 ++ ++ccflags-y += -I$(src)/backport-include/drivers/misc/mei/ + + endif export CONFIG_VIDEO_INTEL_IPU6 = m - export CONFIG_IPU_ISYS_BRIDGE = y export CONFIG_IPU_SINGLE_BE_SOC_DEVICE = n -export CONFIG_INTEL_SKL_INT3472 = m + # export CONFIG_POWER_CTRL_LOGIC = m +-ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_IPU_BRIDGE)),true) ++ifeq ($(shell grep ^CONFIG_IPU_BRIDGE=[ym] $(KERNEL_CONFIG)),) + export CONFIG_IPU_ISYS_BRIDGE = y +-export CONFIG_IPU_BRIDGE = n + endif obj-y += drivers/media/pci/intel/ - export CONFIG_VIDEO_HM11B1 = m -@@ -59,18 +58,16 @@ MODSRC := $(shell pwd) - ccflags-y += -I$(src)/backport-include/drivers/misc/mei/ +@@ -83,31 +70,21 @@ export CONFIG_VIDEO_HM2170 = m + export CONFIG_VIDEO_HM2172 = m + export CONFIG_VIDEO_HI556 = m +-ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true) ++ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),$(KV_OV2740)) + export CONFIG_VIDEO_OV2740 = m + export CONFIG_VIDEO_GC5035 = m + endif + obj-y += drivers/media/i2c/ + +-ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_IVSC)),true) +-ccflags-y += -I$(src)/backport-include/drivers/misc/mei/ +-endif +- subdir-ccflags-y += -I$(src)/include/ \ - -DCONFIG_VIDEO_V4L2_SUBDEV_API + -DCONFIG_VIDEO_V4L2_SUBDEV_API=1 - subdir-ccflags-$(CONFIG_INTEL_VSC) += \ +-subdir-ccflags-$(CONFIG_INTEL_VSC) += \ - -DCONFIG_INTEL_VSC -+ -DCONFIG_INTEL_VSC_MODULE=1 subdir-ccflags-$(CONFIG_IPU_ISYS_BRIDGE) += \ - -DCONFIG_IPU_ISYS_BRIDGE +-subdir-ccflags-$(CONFIG_IPU_BRIDGE) += \ +- -DCONFIG_IPU_BRIDGE + -DCONFIG_IPU_ISYS_BRIDGE=1 subdir-ccflags-$(CONFIG_IPU_SINGLE_BE_SOC_DEVICE) += \ - -DCONFIG_IPU_SINGLE_BE_SOC_DEVICE diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0004-build-drop-inlined-vsc-builds.patch ipu6-drivers-0~git202404110253.97c94720/debian/patches/0004-build-drop-inlined-vsc-builds.patch --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0004-build-drop-inlined-vsc-builds.patch 2023-12-02 00:45:55.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/0004-build-drop-inlined-vsc-builds.patch 2024-04-11 18:38:46.000000000 +0800 @@ -4,18 +4,19 @@ Signed-off-by: You-Sheng Yang (vicamo) --- - Makefile | 33 ----------------- - dkms.conf | 125 ++++++++++++++++++++++++-------------------------------------- - 2 files changed, 48 insertions(+), 110 deletions(-) + Makefile | 35 ----------------- + dkms.conf | 128 +++++++++++++++++++------------------------------------------- + 2 files changed, 39 insertions(+), 124 deletions(-) diff --git a/Makefile b/Makefile -index fdb8fa1..93b01d7 100644 +index 66402bf..d76c90e 100644 --- a/Makefile +++ b/Makefile -@@ -1,37 +1,6 @@ - # SPDX-License-Identifier: GPL-2.0 - # Copyright (c) 2022 Intel Corporation. +@@ -13,44 +13,9 @@ KERNEL_CONFIG ?= $(KERNEL_SRC)/.config + MODSRC := $(shell pwd) + ifeq ($(shell grep ^CONFIG_INTEL_VSC=[ym] $(KERNEL_CONFIG)),) +-$(warning build ljca ivsc) -obj-m += ljca.o -ljca-y := drivers/mfd/ljca.o - @@ -48,149 +49,167 @@ -mei_ace_debug-y := drivers/misc/ivsc/mei_ace_debug.o - export CONFIG_INTEL_VSC = m - - export CONFIG_VIDEO_INTEL_IPU6 = m -@@ -56,8 +25,6 @@ KERNELRELEASE ?= $(shell uname -r) - KERNEL_SRC ?= /lib/modules/$(KERNELRELEASE)/build - MODSRC := $(shell pwd) - + subdir-ccflags-$(CONFIG_INTEL_VSC) += \ + -DCONFIG_INTEL_VSC_MODULE=1 +- -ccflags-y += -I$(src)/backport-include/drivers/misc/mei/ - - subdir-ccflags-y += -I$(src)/include/ \ - -DCONFIG_VIDEO_V4L2_SUBDEV_API=1 + endif + export CONFIG_VIDEO_INTEL_IPU6 = m diff --git a/dkms.conf b/dkms.conf -index 9bdf320..43045fe 100644 +index 0c7abc2..6a7cdea 100644 --- a/dkms.conf +++ b/dkms.conf -@@ -4,82 +4,53 @@ PACKAGE_VERSION="#MODULE_VERSION#" - MAKE="make KERNELRELEASE=$kernelver KERNEL_SRC=$kernel_source_dir" - CLEAN="make KERNELRELEASE=$kernelver KERNEL_SRC=$kernel_source_dir clean" +@@ -6,112 +6,62 @@ CLEAN="make KERNELRELEASE=$kernelver KERNEL_SRC=$kernel_source_dir clean" + AUTOINSTALL="yes" + + version_lt() { +- IFS='.' read -r i j k <<< "$1" +- IFS='.' read -r a b c <<< "$2" +- i=${i:-0} +- j=${j:-0} +- k=${k:-0} +- a=${a:-0} +- b=${b:-0} +- c=${c:-0} +- if [ "$i" -lt "$a" ]; then ++ if [ "$({ echo "$1"; echo "$2"; } | sort -V | tail -1)" != "$1" ]; then + return 0 +- elif [ "$i" -eq "$a" ]; then +- if [ "$j" -lt "$b" ]; then +- return 0 +- elif [ "$j" -eq "$b" ]; then +- if [ "$k" -lt "$c" ]; then +- return 0 +- fi +- fi + fi + return 1 + } + +- +-KERNEL_VERSION=$(echo ${kernelver} | sed 's/[^0-9.]*\([0-9.]*\).*/\1/') +-KV_IVSC=6.6.0 ++KERNEL_VERSION=${kernelver%%-*} + KV_OV2740=6.8.0 --BUILT_MODULE_NAME[0]="ljca" +-BUILT_MODULE_NAME[0]="intel-ipu6" +-BUILT_MODULE_LOCATION[0]="drivers/media/pci/intel/ipu6" -DEST_MODULE_LOCATION[0]="/updates" - --BUILT_MODULE_NAME[1]="spi-ljca" +-BUILT_MODULE_NAME[1]="intel-ipu6-isys" +-BUILT_MODULE_LOCATION[1]="drivers/media/pci/intel/ipu6" -DEST_MODULE_LOCATION[1]="/updates" -- --BUILT_MODULE_NAME[2]="gpio-ljca" --DEST_MODULE_LOCATION[2]="/updates" -- --BUILT_MODULE_NAME[3]="i2c-ljca" --DEST_MODULE_LOCATION[3]="/updates" -- --BUILT_MODULE_NAME[4]="mei-vsc" --DEST_MODULE_LOCATION[4]="/updates" -- --BUILT_MODULE_NAME[5]="intel_vsc" --DEST_MODULE_LOCATION[5]="/updates" -- --BUILT_MODULE_NAME[6]="mei_csi" --DEST_MODULE_LOCATION[6]="/updates" -- --BUILT_MODULE_NAME[7]="mei_ace" --DEST_MODULE_LOCATION[7]="/updates" -- --BUILT_MODULE_NAME[8]="mei_pse" --DEST_MODULE_LOCATION[8]="/updates" -- --BUILT_MODULE_NAME[9]="mei_ace_debug" --DEST_MODULE_LOCATION[9]="/updates" -- --BUILT_MODULE_NAME[10]="intel-ipu6" --BUILT_MODULE_LOCATION[10]="drivers/media/pci/intel/ipu6" --DEST_MODULE_LOCATION[10]="/updates" -- --BUILT_MODULE_NAME[11]="intel-ipu6-isys" --BUILT_MODULE_LOCATION[11]="drivers/media/pci/intel/ipu6" --DEST_MODULE_LOCATION[11]="/updates" -- --BUILT_MODULE_NAME[12]="intel-ipu6-psys" --BUILT_MODULE_LOCATION[12]="drivers/media/pci/intel/ipu6" --DEST_MODULE_LOCATION[12]="/updates" -- --BUILT_MODULE_NAME[13]="hm11b1" --BUILT_MODULE_LOCATION[13]="drivers/media/i2c" --DEST_MODULE_LOCATION[13]="/updates" -- --BUILT_MODULE_NAME[14]="ov01a1s" --BUILT_MODULE_LOCATION[14]="drivers/media/i2c" --DEST_MODULE_LOCATION[14]="/updates" -- --BUILT_MODULE_NAME[15]="ov01a10" --BUILT_MODULE_LOCATION[15]="drivers/media/i2c" --DEST_MODULE_LOCATION[15]="/updates" -- --BUILT_MODULE_NAME[16]="ov02c10" --BUILT_MODULE_LOCATION[16]="drivers/media/i2c" --DEST_MODULE_LOCATION[16]="/updates" -- --BUILT_MODULE_NAME[17]="ov2740" --BUILT_MODULE_LOCATION[17]="drivers/media/i2c" --DEST_MODULE_LOCATION[17]="/updates" -- --BUILT_MODULE_NAME[18]="hm2170" --BUILT_MODULE_LOCATION[18]="drivers/media/i2c" --DEST_MODULE_LOCATION[18]="/updates" -- --BUILT_MODULE_NAME[19]="hm2172" --BUILT_MODULE_LOCATION[19]="drivers/media/i2c" --DEST_MODULE_LOCATION[19]="/updates" -- --BUILT_MODULE_NAME[20]="hi556" --BUILT_MODULE_LOCATION[20]="drivers/media/i2c" --DEST_MODULE_LOCATION[20]="/updates" -- --BUILT_MODULE_NAME[21]="ov02e10" --BUILT_MODULE_LOCATION[21]="drivers/media/i2c" --DEST_MODULE_LOCATION[21]="/updates" +i=0 +BUILT_MODULE_NAME[$i]="intel-ipu6" +BUILT_MODULE_LOCATION[$i]="drivers/media/pci/intel/ipu6" +DEST_MODULE_LOCATION[$i]="/updates" -+ + +-BUILT_MODULE_NAME[2]="intel-ipu6-psys" +-BUILT_MODULE_LOCATION[2]="drivers/media/pci/intel/ipu6" +-DEST_MODULE_LOCATION[2]="/updates" +BUILT_MODULE_NAME[$((++i))]="intel-ipu6-isys" +BUILT_MODULE_LOCATION[$i]="drivers/media/pci/intel/ipu6" +DEST_MODULE_LOCATION[$i]="/updates" -+ + +-BUILT_MODULE_NAME[3]="hm11b1" +-BUILT_MODULE_LOCATION[3]="drivers/media/i2c" +-DEST_MODULE_LOCATION[3]="/updates" +BUILT_MODULE_NAME[$((++i))]="intel-ipu6-psys" +BUILT_MODULE_LOCATION[$i]="drivers/media/pci/intel/ipu6" +DEST_MODULE_LOCATION[$i]="/updates" -+ + +-BUILT_MODULE_NAME[4]="ov01a1s" +-BUILT_MODULE_LOCATION[4]="drivers/media/i2c" +-DEST_MODULE_LOCATION[4]="/updates" +BUILT_MODULE_NAME[$((++i))]="hm11b1" +BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" +DEST_MODULE_LOCATION[$i]="/updates" -+ + +-BUILT_MODULE_NAME[5]="ov01a10" +-BUILT_MODULE_LOCATION[5]="drivers/media/i2c" +-DEST_MODULE_LOCATION[5]="/updates" +BUILT_MODULE_NAME[$((++i))]="ov01a1s" +BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" +DEST_MODULE_LOCATION[$i]="/updates" -+ + +-BUILT_MODULE_NAME[6]="ov02c10" +-BUILT_MODULE_LOCATION[6]="drivers/media/i2c" +-DEST_MODULE_LOCATION[6]="/updates" +BUILT_MODULE_NAME[$((++i))]="ov01a10" +BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" +DEST_MODULE_LOCATION[$i]="/updates" -+ + +-BUILT_MODULE_NAME[7]="ov02e10" +-BUILT_MODULE_LOCATION[7]="drivers/media/i2c" +-DEST_MODULE_LOCATION[7]="/updates" +BUILT_MODULE_NAME[$((++i))]="ov02c10" +BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" +DEST_MODULE_LOCATION[$i]="/updates" -+ -+BUILT_MODULE_NAME[$((++i))]="ov2740" + +-BUILT_MODULE_NAME[8]="hm2170" +-BUILT_MODULE_LOCATION[8]="drivers/media/i2c" +-DEST_MODULE_LOCATION[8]="/updates" ++BUILT_MODULE_NAME[$((++i))]="ov02e10" +BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" +DEST_MODULE_LOCATION[$i]="/updates" -+ + +-BUILT_MODULE_NAME[9]="hm2172" +-BUILT_MODULE_LOCATION[9]="drivers/media/i2c" +-DEST_MODULE_LOCATION[9]="/updates" +BUILT_MODULE_NAME[$((++i))]="hm2170" +BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" +DEST_MODULE_LOCATION[$i]="/updates" -+ + +-BUILT_MODULE_NAME[10]="hi556" +-BUILT_MODULE_LOCATION[10]="drivers/media/i2c" +-DEST_MODULE_LOCATION[10]="/updates" +BUILT_MODULE_NAME[$((++i))]="hm2172" +BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" +DEST_MODULE_LOCATION[$i]="/updates" -+ + +BUILT_MODULE_NAME[$((++i))]="hi556" +BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" +DEST_MODULE_LOCATION[$i]="/updates" -+ -+BUILT_MODULE_NAME[$((++i))]="ov02e10" -+BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" -+DEST_MODULE_LOCATION[$i]="/updates" - AUTOINSTALL="yes" + if version_lt ${KERNEL_VERSION} ${KV_OV2740}; then +- BUILT_MODULE_NAME[11]="ov2740" +- BUILT_MODULE_LOCATION[11]="drivers/media/i2c" +- DEST_MODULE_LOCATION[11]="/updates" +-fi +- +-if version_lt ${KERNEL_VERSION} ${KV_IVSC}; then +- BUILT_MODULE_NAME[12]="ljca" +- DEST_MODULE_LOCATION[12]="/updates" +- +- BUILT_MODULE_NAME[13]="spi-ljca" +- DEST_MODULE_LOCATION[13]="/updates" +- +- BUILT_MODULE_NAME[14]="gpio-ljca" +- DEST_MODULE_LOCATION[14]="/updates" +- +- BUILT_MODULE_NAME[15]="i2c-ljca" +- DEST_MODULE_LOCATION[15]="/updates" +- +- BUILT_MODULE_NAME[16]="mei-vsc" +- DEST_MODULE_LOCATION[16]="/updates" +- +- BUILT_MODULE_NAME[17]="intel_vsc" +- DEST_MODULE_LOCATION[17]="/updates" +- +- BUILT_MODULE_NAME[18]="mei_csi" +- DEST_MODULE_LOCATION[18]="/updates" +- +- BUILT_MODULE_NAME[19]="mei_ace" +- DEST_MODULE_LOCATION[19]="/updates" +- +- BUILT_MODULE_NAME[20]="mei_pse" +- DEST_MODULE_LOCATION[20]="/updates" +- +- BUILT_MODULE_NAME[21]="mei_ace_debug" +- DEST_MODULE_LOCATION[21]="/updates" ++ BUILT_MODULE_NAME[$((++i))]="ov2740" ++ BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" ++ DEST_MODULE_LOCATION[$i]="/updates" + fi diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0006-ivsc-load-symbols-by-kprobe.patch ipu6-drivers-0~git202404110253.97c94720/debian/patches/0006-ivsc-load-symbols-by-kprobe.patch --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0006-ivsc-load-symbols-by-kprobe.patch 2023-12-02 00:45:55.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/0006-ivsc-load-symbols-by-kprobe.patch 2024-04-11 18:38:46.000000000 +0800 @@ -6,22 +6,22 @@ --- Makefile | 4 ++- backport-include/linux/vsc.h | 63 ++++++++++++++++++++++++++++++++++++++++---- - drivers/media/i2c/hi556.c | 6 +++++ - drivers/media/i2c/hm2170.c | 6 +++++ - drivers/media/i2c/hm2172.c | 6 +++++ - drivers/media/i2c/ov01a10.c | 6 +++++ - drivers/media/i2c/ov01a1s.c | 6 +++++ - drivers/media/i2c/ov02c10.c | 6 +++++ - drivers/media/i2c/ov02e10.c | 6 +++++ - 9 files changed, 103 insertions(+), 6 deletions(-) + drivers/media/i2c/hi556.c | 7 +++++ + drivers/media/i2c/hm2170.c | 7 +++++ + drivers/media/i2c/hm2172.c | 7 +++++ + drivers/media/i2c/ov01a10.c | 7 +++++ + drivers/media/i2c/ov01a1s.c | 7 +++++ + drivers/media/i2c/ov02c10.c | 7 +++++ + drivers/media/i2c/ov02e10.c | 7 +++++ + 9 files changed, 110 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile -index 93b01d7..d1b1db6 100644 +index d76c90e..c30a457 100644 --- a/Makefile +++ b/Makefile -@@ -25,7 +25,9 @@ KERNELRELEASE ?= $(shell uname -r) - KERNEL_SRC ?= /lib/modules/$(KERNELRELEASE)/build - MODSRC := $(shell pwd) +@@ -41,7 +41,9 @@ export CONFIG_VIDEO_GC5035 = m + endif + obj-y += drivers/media/i2c/ -subdir-ccflags-y += -I$(src)/include/ \ +subdir-ccflags-y += \ @@ -29,7 +29,7 @@ + -I$(src)/include/ \ -DCONFIG_VIDEO_V4L2_SUBDEV_API=1 - subdir-ccflags-$(CONFIG_INTEL_VSC) += \ + subdir-ccflags-$(CONFIG_IPU_ISYS_BRIDGE) += \ diff --git a/backport-include/linux/vsc.h b/backport-include/linux/vsc.h index 8f8d404..71486dd 100644 --- a/backport-include/linux/vsc.h @@ -125,14 +125,15 @@ #endif diff --git a/drivers/media/i2c/hi556.c b/drivers/media/i2c/hi556.c -index 97c821c..e268c94 100644 +index 4fc020b..a67df87 100644 --- a/drivers/media/i2c/hi556.c +++ b/drivers/media/i2c/hi556.c -@@ -1350,6 +1350,12 @@ static int hi556_probe(struct i2c_client *client) +@@ -1369,6 +1369,13 @@ static int hi556_probe(struct i2c_client *client) bool full_power; int ret; -+#if IS_ENABLED(CONFIG_INTEL_VSC) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ ++ IS_ENABLED(CONFIG_INTEL_VSC) + ret = init_vsc_symbols(); + if (ret) + return ret; @@ -142,104 +143,110 @@ if (ret) return dev_err_probe(&client->dev, ret, diff --git a/drivers/media/i2c/hm2170.c b/drivers/media/i2c/hm2170.c -index 7463855..284067e 100644 +index 102eec2..19d3734 100644 --- a/drivers/media/i2c/hm2170.c +++ b/drivers/media/i2c/hm2170.c -@@ -1225,6 +1225,12 @@ static int hm2170_probe(struct i2c_client *client) +@@ -1309,6 +1309,13 @@ static int hm2170_probe(struct i2c_client *client) struct hm2170 *hm2170; int ret = 0; -+#if IS_ENABLED(CONFIG_INTEL_VSC) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ ++ IS_ENABLED(CONFIG_INTEL_VSC) + ret = init_vsc_symbols(); + if (ret) + return ret; +#endif + - hm2170 = devm_kzalloc(&client->dev, sizeof(*hm2170), GFP_KERNEL); - if (!hm2170) { - ret = -ENOMEM; + /* Check HW config */ + ret = hm2170_check_hwcfg(&client->dev); + if (ret) { diff --git a/drivers/media/i2c/hm2172.c b/drivers/media/i2c/hm2172.c -index 71cef03..3d8d58f 100644 +index 3362d31..a10f9ad 100644 --- a/drivers/media/i2c/hm2172.c +++ b/drivers/media/i2c/hm2172.c -@@ -1650,6 +1650,12 @@ static int hm2172_probe(struct i2c_client *client) +@@ -1737,6 +1737,13 @@ static int hm2172_probe(struct i2c_client *client) struct hm2172 *hm217; int ret; -+#if IS_ENABLED(CONFIG_INTEL_VSC) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ ++ IS_ENABLED(CONFIG_INTEL_VSC) + ret = init_vsc_symbols(); + if (ret) + return ret; +#endif + - hm217 = devm_kzalloc(&client->dev, sizeof(*hm217), GFP_KERNEL); - if (!hm217) - return -ENOMEM; + /* Check HW config */ + ret = hm2172_check_hwcfg(&client->dev); + if (ret) { diff --git a/drivers/media/i2c/ov01a10.c b/drivers/media/i2c/ov01a10.c -index ae8024e..e7ac490 100644 +index 78ae018..d08fbe9 100644 --- a/drivers/media/i2c/ov01a10.c +++ b/drivers/media/i2c/ov01a10.c -@@ -926,6 +926,12 @@ static int ov01a10_probe(struct i2c_client *client) +@@ -1004,6 +1004,13 @@ static int ov01a10_probe(struct i2c_client *client) struct ov01a10 *ov01a10; int ret = 0; -+#if IS_ENABLED(CONFIG_INTEL_VSC) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ ++ IS_ENABLED(CONFIG_INTEL_VSC) + ret = init_vsc_symbols(); + if (ret) + return ret; +#endif + - ov01a10 = devm_kzalloc(&client->dev, sizeof(*ov01a10), GFP_KERNEL); - if (!ov01a10) - return -ENOMEM; + /* Check HW config */ + ret = ov01a10_check_hwcfg(&client->dev); + if (ret) { diff --git a/drivers/media/i2c/ov01a1s.c b/drivers/media/i2c/ov01a1s.c -index 0dcce8b..8c8911b 100644 +index f7cf221..eb2b792 100644 --- a/drivers/media/i2c/ov01a1s.c +++ b/drivers/media/i2c/ov01a1s.c -@@ -1078,6 +1078,12 @@ static int ov01a1s_probe(struct i2c_client *client) +@@ -1160,6 +1160,13 @@ static int ov01a1s_probe(struct i2c_client *client) struct ov01a1s *ov01a1s; int ret = 0; -+#if IS_ENABLED(CONFIG_INTEL_VSC) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ ++ IS_ENABLED(CONFIG_INTEL_VSC) + ret = init_vsc_symbols(); + if (ret) + return ret; +#endif + - ov01a1s = devm_kzalloc(&client->dev, sizeof(*ov01a1s), GFP_KERNEL); - if (!ov01a1s) - return -ENOMEM; + /* Check HW config */ + ret = ov01a1s_check_hwcfg(&client->dev); + if (ret) { diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c -index 3f62744..e9969da 100644 +index 95e1638..a6194f4 100644 --- a/drivers/media/i2c/ov02c10.c +++ b/drivers/media/i2c/ov02c10.c -@@ -1420,6 +1420,12 @@ static int ov02c10_probe(struct i2c_client *client) +@@ -1491,6 +1491,13 @@ static int ov02c10_probe(struct i2c_client *client) struct ov02c10 *ov02c10; int ret = 0; -+#if IS_ENABLED(CONFIG_INTEL_VSC) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ ++ IS_ENABLED(CONFIG_INTEL_VSC) + ret = init_vsc_symbols(); + if (ret) + return ret; +#endif + - ov02c10 = devm_kzalloc(&client->dev, sizeof(*ov02c10), GFP_KERNEL); - if (!ov02c10) - return -ENOMEM; + /* Check HW config */ + ret = ov02c10_check_hwcfg(&client->dev); + if (ret) { diff --git a/drivers/media/i2c/ov02e10.c b/drivers/media/i2c/ov02e10.c -index ccdb7da..fb7993b 100644 +index 916def9..7004354 100644 --- a/drivers/media/i2c/ov02e10.c +++ b/drivers/media/i2c/ov02e10.c -@@ -1037,6 +1037,12 @@ static int ov02e10_probe(struct i2c_client *client) +@@ -1124,6 +1124,13 @@ static int ov02e10_probe(struct i2c_client *client) struct ov02e10 *ov02e; int ret; -+#if IS_ENABLED(CONFIG_INTEL_VSC) ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ ++ IS_ENABLED(CONFIG_INTEL_VSC) + ret = init_vsc_symbols(); + if (ret) + return ret; +#endif + - ov02e = devm_kzalloc(&client->dev, sizeof(*ov02e), GFP_KERNEL); - if (!ov02e) - return -ENOMEM; + /* Check HW config */ + ret = ov02e10_check_hwcfg(&client->dev); + if (ret) { diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0007-dkms-add-CONFIG_VIDEO_V4L2_I2C-to-BUILD_EXCLUSIVE_CO.patch ipu6-drivers-0~git202404110253.97c94720/debian/patches/0007-dkms-add-CONFIG_VIDEO_V4L2_I2C-to-BUILD_EXCLUSIVE_CO.patch --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0007-dkms-add-CONFIG_VIDEO_V4L2_I2C-to-BUILD_EXCLUSIVE_CO.patch 2023-12-02 00:45:55.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/0007-dkms-add-CONFIG_VIDEO_V4L2_I2C-to-BUILD_EXCLUSIVE_CO.patch 2024-04-11 18:38:46.000000000 +0800 @@ -9,11 +9,14 @@ 1 file changed, 1 insertion(+) diff --git a/dkms.conf b/dkms.conf -index 43045fe..e9e9a2b 100644 +index 6da6e59..f23345d 100644 --- a/dkms.conf +++ b/dkms.conf -@@ -54,3 +54,4 @@ BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" - DEST_MODULE_LOCATION[$i]="/updates" - +@@ -4,6 +4,7 @@ PACKAGE_VERSION="#MODULE_VERSION#" + MAKE="make KERNELRELEASE=$kernelver KERNEL_SRC=$kernel_source_dir" + CLEAN="make KERNELRELEASE=$kernelver KERNEL_SRC=$kernel_source_dir clean" AUTOINSTALL="yes" +BUILD_EXCLUSIVE_CONFIG="CONFIG_VIDEO_V4L2_I2C" + + version_lt() { + if [ "$({ echo "$1"; echo "$2"; } | sort -V | tail -1)" != "$1" ]; then diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0011-UBUNTU-SAUCE-i2c-compile-omitted-sensor-drivers.patch ipu6-drivers-0~git202404110253.97c94720/debian/patches/0011-UBUNTU-SAUCE-i2c-compile-omitted-sensor-drivers.patch --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0011-UBUNTU-SAUCE-i2c-compile-omitted-sensor-drivers.patch 2023-12-02 00:45:55.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/0011-UBUNTU-SAUCE-i2c-compile-omitted-sensor-drivers.patch 2024-04-11 18:38:46.000000000 +0800 @@ -8,40 +8,28 @@ dkms.conf | 16 +++++++++++++ drivers/media/i2c/Makefile | 6 ++++- drivers/media/i2c/ov08a10.c | 1 + - drivers/media/i2c/ov13858_intel.c | 47 +++++++++++++++++++++++++++++++++++++-- - 5 files changed, 70 insertions(+), 3 deletions(-) + drivers/media/i2c/ov13858_intel.c | 49 +++++++++++++++++++++++++++++++++------ + 5 files changed, 67 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile -index d1b1db6..3eb9b59 100644 +index c30a457..7809010 100644 --- a/Makefile +++ b/Makefile -@@ -14,7 +14,10 @@ export CONFIG_VIDEO_OV01A1S = m +@@ -31,6 +31,9 @@ export CONFIG_VIDEO_OV01A1S = m export CONFIG_VIDEO_OV01A10 = m export CONFIG_VIDEO_OV02C10 = m export CONFIG_VIDEO_OV02E10 = m +export CONFIG_VIDEO_OV08A10 = m +export CONFIG_VIDEO_OV13858 = m - export CONFIG_VIDEO_OV2740 = m +export CONFIG_VIDEO_OV8856 = m export CONFIG_VIDEO_HM2170 = m export CONFIG_VIDEO_HM2172 = m export CONFIG_VIDEO_HI556 = m diff --git a/dkms.conf b/dkms.conf -index e9e9a2b..1474485 100644 +index a2b55f8..2b08eca 100644 --- a/dkms.conf +++ b/dkms.conf -@@ -21,6 +21,10 @@ BUILT_MODULE_NAME[$((++i))]="hm11b1" - BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" - DEST_MODULE_LOCATION[$i]="/updates" - -+BUILT_MODULE_NAME[$((++i))]="gc5035" -+BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" -+DEST_MODULE_LOCATION[$i]="/updates" -+ - BUILT_MODULE_NAME[$((++i))]="ov01a1s" - BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" - DEST_MODULE_LOCATION[$i]="/updates" -@@ -33,10 +37,22 @@ BUILT_MODULE_NAME[$((++i))]="ov02c10" +@@ -49,6 +49,18 @@ BUILT_MODULE_NAME[$((++i))]="ov02e10" BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" DEST_MODULE_LOCATION[$i]="/updates" @@ -53,10 +41,6 @@ +BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" +DEST_MODULE_LOCATION[$i]="/updates" + - BUILT_MODULE_NAME[$((++i))]="ov2740" - BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" - DEST_MODULE_LOCATION[$i]="/updates" - +BUILT_MODULE_NAME[$((++i))]="ov8856" +BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" +DEST_MODULE_LOCATION[$i]="/updates" @@ -64,6 +48,15 @@ BUILT_MODULE_NAME[$((++i))]="hm2170" BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" DEST_MODULE_LOCATION[$i]="/updates" +@@ -65,4 +77,8 @@ if version_lt ${KERNEL_VERSION} ${KV_OV2740}; then + BUILT_MODULE_NAME[$((++i))]="ov2740" + BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" + DEST_MODULE_LOCATION[$i]="/updates" ++ ++ BUILT_MODULE_NAME[$((++i))]="gc5035" ++ BUILT_MODULE_LOCATION[$i]="drivers/media/i2c" ++ DEST_MODULE_LOCATION[$i]="/updates" + fi diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index 1f39544..b8b37e8 100644 --- a/drivers/media/i2c/Makefile @@ -83,7 +76,7 @@ obj-$(CONFIG_VIDEO_HI556) += hi556.o obj-$(CONFIG_POWER_CTRL_LOGIC) += power_ctrl_logic.o diff --git a/drivers/media/i2c/ov08a10.c b/drivers/media/i2c/ov08a10.c -index d474735..c6e67ee 100644 +index 6a12f07..7df05ac 100644 --- a/drivers/media/i2c/ov08a10.c +++ b/drivers/media/i2c/ov08a10.c @@ -9,6 +9,7 @@ @@ -95,12 +88,12 @@ #include #include diff --git a/drivers/media/i2c/ov13858_intel.c b/drivers/media/i2c/ov13858_intel.c -index 43885cf..596368b 100644 +index 4e57428..8b8a3ba 100644 --- a/drivers/media/i2c/ov13858_intel.c +++ b/drivers/media/i2c/ov13858_intel.c -@@ -1381,7 +1381,11 @@ static int ov13858_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - { +@@ -1382,11 +1382,15 @@ static int ov13858_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) struct ov13858 *ov13858 = to_ov13858(sd); + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) struct v4l2_mbus_framefmt *try_fmt = v4l2_subdev_get_try_format(sd, +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) fh->pad, @@ -108,9 +101,14 @@ + fh->state, +#endif 0); + #else + struct v4l2_mbus_framefmt *try_fmt = v4l2_subdev_state_get_format( +- fh->pad, ++ fh->state, + 0); + #endif - mutex_lock(&ov13858->mutex); -@@ -1516,7 +1520,11 @@ static const struct v4l2_ctrl_ops ov13858_ctrl_ops = { +@@ -1522,7 +1526,11 @@ static const struct v4l2_ctrl_ops ov13858_ctrl_ops = { }; static int ov13858_enum_mbus_code(struct v4l2_subdev *sd, @@ -122,7 +120,7 @@ struct v4l2_subdev_mbus_code_enum *code) { /* Only one bayer order(GRBG) is supported */ -@@ -1529,7 +1537,11 @@ static int ov13858_enum_mbus_code(struct v4l2_subdev *sd, +@@ -1535,7 +1543,11 @@ static int ov13858_enum_mbus_code(struct v4l2_subdev *sd, } static int ov13858_enum_frame_size(struct v4l2_subdev *sd, @@ -134,7 +132,7 @@ struct v4l2_subdev_frame_size_enum *fse) { if (fse->index >= ARRAY_SIZE(supported_modes)) -@@ -1556,14 +1568,22 @@ static void ov13858_update_pad_format(const struct ov13858_mode *mode, +@@ -1562,17 +1574,21 @@ static void ov13858_update_pad_format(const struct ov13858_mode *mode, } static int ov13858_do_get_pad_format(struct ov13858 *ov13858, @@ -149,15 +147,16 @@ struct v4l2_subdev *sd = &ov13858->sd; if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { +-#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); -+#else + #else +- framefmt = v4l2_subdev_state_get_format(cfg, fmt->pad); + framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); -+#endif + #endif fmt->format = *framefmt; } else { - ov13858_update_pad_format(ov13858->cur_mode, fmt); -@@ -1573,14 +1593,22 @@ static int ov13858_do_get_pad_format(struct ov13858 *ov13858, +@@ -1583,14 +1599,22 @@ static int ov13858_do_get_pad_format(struct ov13858 *ov13858, } static int ov13858_get_pad_format(struct v4l2_subdev *sd, @@ -180,7 +179,7 @@ mutex_unlock(&ov13858->mutex); return ret; -@@ -1588,7 +1616,11 @@ static int ov13858_get_pad_format(struct v4l2_subdev *sd, +@@ -1598,7 +1622,11 @@ static int ov13858_get_pad_format(struct v4l2_subdev *sd, static int ov13858_set_pad_format(struct v4l2_subdev *sd, @@ -192,19 +191,20 @@ struct v4l2_subdev_format *fmt) { struct ov13858 *ov13858 = to_ov13858(sd); -@@ -1612,7 +1644,11 @@ ov13858_set_pad_format(struct v4l2_subdev *sd, +@@ -1622,10 +1650,10 @@ ov13858_set_pad_format(struct v4l2_subdev *sd, fmt->format.width, fmt->format.height); ov13858_update_pad_format(mode, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { +-#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); -+#else + #else +- framefmt = v4l2_subdev_state_get_format(cfg, fmt->pad); + framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); -+#endif + #endif *framefmt = fmt->format; } else { - ov13858->cur_mode = mode; -@@ -1944,8 +1980,7 @@ static void ov13858_free_controls(struct ov13858 *ov13858) +@@ -1958,8 +1986,7 @@ static void ov13858_free_controls(struct ov13858 *ov13858) mutex_destroy(&ov13858->mutex); } @@ -214,7 +214,7 @@ { struct ov13858 *ov13858; int ret; -@@ -1990,7 +2025,11 @@ static int ov13858_probe(struct i2c_client *client, +@@ -2004,7 +2031,11 @@ static int ov13858_probe(struct i2c_client *client, goto error_handler_free; } @@ -226,7 +226,7 @@ if (ret < 0) goto error_media_entity; -@@ -2060,7 +2099,11 @@ static struct i2c_driver ov13858_i2c_driver = { +@@ -2074,7 +2105,11 @@ static struct i2c_driver ov13858_i2c_driver = { .pm = &ov13858_pm_ops, .acpi_match_table = ACPI_PTR(ov13858_acpi_ids), }, diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0012-backport-replace-strlcpy-with-strscpy.patch ipu6-drivers-0~git202404110253.97c94720/debian/patches/0012-backport-replace-strlcpy-with-strscpy.patch --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0012-backport-replace-strlcpy-with-strscpy.patch 2024-02-21 22:02:47.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/0012-backport-replace-strlcpy-with-strscpy.patch 1970-01-01 08:00:00.000000000 +0800 @@ -1,109 +0,0 @@ -From: You-Sheng Yang -Date: Wed, 21 Feb 2024 14:51:02 +0800 -Subject: backport: replace strlcpy with strscpy - -BugLink: https://bugs.launchpad.net/bug/2054516 - -With Linux v6.8-rcX commit d26270061ae6 ("string: Remove strlcpy()"), -strlcpy should be replaced by strscpy introduced in v4.3, commit -30035e45753b ("string: provide strscpy()"). - -Signed-off-by: You-Sheng Yang ---- - Makefile | 3 ++- - backport-include/linux/string.h | 10 ++++++++++ - drivers/media/pci/intel/ipu-isys-video.c | 6 +++--- - drivers/media/pci/intel/ipu-isys.c | 4 ++-- - drivers/media/pci/intel/ipu-psys.c | 2 +- - 5 files changed, 18 insertions(+), 7 deletions(-) - create mode 100644 backport-include/linux/string.h - -diff --git a/Makefile b/Makefile -index 3eb9b59..1874cb1 100644 ---- a/Makefile -+++ b/Makefile -@@ -28,8 +28,9 @@ KERNELRELEASE ?= $(shell uname -r) - KERNEL_SRC ?= /lib/modules/$(KERNELRELEASE)/build - MODSRC := $(shell pwd) - -+NOSTDINC_FLAGS += \ -+ -I$(src)/backport-include - subdir-ccflags-y += \ -- -I$(src)/backport-include/ \ - -I$(src)/include/ \ - -DCONFIG_VIDEO_V4L2_SUBDEV_API=1 - -diff --git a/backport-include/linux/string.h b/backport-include/linux/string.h -new file mode 100644 -index 0000000..c039a8a ---- /dev/null -+++ b/backport-include/linux/string.h -@@ -0,0 +1,10 @@ -+#ifndef __BACKPORT_LINUX_STRING_H -+#define __BACKPORT_LINUX_STRING_H -+#include_next -+#include -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) -+#define strscpy strlcpy -+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) */ -+ -+#endif /* __BACKPORT_LINUX_STRING_H */ -diff --git a/drivers/media/pci/intel/ipu-isys-video.c b/drivers/media/pci/intel/ipu-isys-video.c -index 3ee79af..11f17cd 100644 ---- a/drivers/media/pci/intel/ipu-isys-video.c -+++ b/drivers/media/pci/intel/ipu-isys-video.c -@@ -359,8 +359,8 @@ int ipu_isys_vidioc_querycap(struct file *file, void *fh, - { - struct ipu_isys_video *av = video_drvdata(file); - -- strlcpy(cap->driver, IPU_ISYS_NAME, sizeof(cap->driver)); -- strlcpy(cap->card, av->isys->media_dev.model, sizeof(cap->card)); -+ strscpy(cap->driver, IPU_ISYS_NAME, sizeof(cap->driver)); -+ strscpy(cap->card, av->isys->media_dev.model, sizeof(cap->card)); - snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", - av->isys->media_dev.bus_info); - return 0; -@@ -586,7 +586,7 @@ static int vidioc_enum_input(struct file *file, void *fh, - { - if (input->index > 0) - return -EINVAL; -- strlcpy(input->name, "camera", sizeof(input->name)); -+ strscpy(input->name, "camera", sizeof(input->name)); - input->type = V4L2_INPUT_TYPE_CAMERA; - - return 0; -diff --git a/drivers/media/pci/intel/ipu-isys.c b/drivers/media/pci/intel/ipu-isys.c -index 3cc38d4..ac90ce4 100644 ---- a/drivers/media/pci/intel/ipu-isys.c -+++ b/drivers/media/pci/intel/ipu-isys.c -@@ -976,14 +976,14 @@ static int isys_register_devices(struct ipu_isys *isys) - #else - isys->media_dev.link_notify = v4l2_pipeline_link_notify; - #endif -- strlcpy(isys->media_dev.model, -+ strscpy(isys->media_dev.model, - IPU_MEDIA_DEV_MODEL_NAME, sizeof(isys->media_dev.model)); - #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) - isys->media_dev.driver_version = LINUX_VERSION_CODE; - #endif - snprintf(isys->media_dev.bus_info, sizeof(isys->media_dev.bus_info), - "pci:%s", dev_name(isys->adev->dev.parent->parent)); -- strlcpy(isys->v4l2_dev.name, isys->media_dev.model, -+ strscpy(isys->v4l2_dev.name, isys->media_dev.model, - sizeof(isys->v4l2_dev.name)); - - #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) -diff --git a/drivers/media/pci/intel/ipu-psys.c b/drivers/media/pci/intel/ipu-psys.c -index 8e8e200..a698edb 100644 ---- a/drivers/media/pci/intel/ipu-psys.c -+++ b/drivers/media/pci/intel/ipu-psys.c -@@ -1647,7 +1647,7 @@ static int ipu_psys_probe(struct ipu_bus_device *adev) - } - - /* Add the hw stepping information to caps */ -- strlcpy(psys->caps.dev_model, IPU_MEDIA_DEV_MODEL_NAME, -+ strscpy(psys->caps.dev_model, IPU_MEDIA_DEV_MODEL_NAME, - sizeof(psys->caps.dev_model)); - - pm_runtime_set_autosuspend_delay(&psys->adev->dev, diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0013-backport-Switch-to-stream-aware-state-functions.patch ipu6-drivers-0~git202404110253.97c94720/debian/patches/0013-backport-Switch-to-stream-aware-state-functions.patch --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0013-backport-Switch-to-stream-aware-state-functions.patch 2024-02-21 22:02:47.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/0013-backport-Switch-to-stream-aware-state-functions.patch 2024-04-11 18:38:46.000000000 +0800 @@ -11,501 +11,63 @@ Signed-off-by: You-Sheng Yang --- - backport-include/media/v4l2-subdev.h | 18 ++++++++++++++++++ - drivers/media/i2c/gc5035.c | 4 ++-- - drivers/media/i2c/hi556.c | 8 +++----- - drivers/media/i2c/hm11b1.c | 7 +++---- - drivers/media/i2c/hm2170.c | 7 +++---- - drivers/media/i2c/hm2172.c | 7 +++---- - drivers/media/i2c/ov01a10.c | 7 +++---- - drivers/media/i2c/ov01a1s.c | 7 +++---- - drivers/media/i2c/ov02c10.c | 7 +++---- - drivers/media/i2c/ov02e10.c | 7 +++---- - drivers/media/i2c/ov08a10.c | 9 +++------ - drivers/media/i2c/ov13858_intel.c | 11 +++++------ - drivers/media/i2c/ov2740.c | 7 +++---- - drivers/media/i2c/ov8856.c | 7 +++---- - drivers/media/pci/intel/ipu-isys-subdev.c | 12 ++++++------ - 15 files changed, 64 insertions(+), 61 deletions(-) - create mode 100644 backport-include/media/v4l2-subdev.h + drivers/media/i2c/gc5035.c | 8 ++++++++ + drivers/media/i2c/ov13858_intel.c | 8 ++++++-- + 2 files changed, 14 insertions(+), 2 deletions(-) -diff --git a/backport-include/media/v4l2-subdev.h b/backport-include/media/v4l2-subdev.h -new file mode 100644 -index 0000000..e2e5d53 ---- /dev/null -+++ b/backport-include/media/v4l2-subdev.h -@@ -0,0 +1,18 @@ -+#ifndef __BACKPORT_MEDIA_V4L2_SUBDEV_H -+#define __BACKPORT_MEDIA_V4L2_SUBDEV_H -+#include_next -+#include -+ -+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) \ -+ && LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) -+ -+#define v4l2_subdev_state_get_format(state, pad) \ -+ v4l2_subdev_get_try_format(sd, state, pad) -+#define v4l2_subdev_state_get_crop(state, pad) \ -+ v4l2_subdev_get_try_crop(sd, state, pad) -+#define v4l2_subdev_state_get_compose(state, pad) \ -+ v4l2_subdev_get_try_compose(sd, state, pad) -+ -+#endif /* KERNEL_VERSION(5, 14, 0) <= LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) */ -+ -+#endif /* __BACKPORT_MEDIA_V4L2_SUBDEV_H */ diff --git a/drivers/media/i2c/gc5035.c b/drivers/media/i2c/gc5035.c -index 16bbd48..c9f8f2b 100644 +index 16bbd48..812611b 100644 --- a/drivers/media/i2c/gc5035.c +++ b/drivers/media/i2c/gc5035.c -@@ -1497,7 +1497,7 @@ static int gc5035_set_fmt(struct v4l2_subdev *sd, +@@ -1497,7 +1497,11 @@ static int gc5035_set_fmt(struct v4l2_subdev *sd, mutex_lock(&gc5035->mutex); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) + *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; ++#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; ++#endif } else { gc5035->cur_mode = mode; h_blank = mode->hts_def - mode->width; -@@ -1522,7 +1522,7 @@ static int gc5035_get_fmt(struct v4l2_subdev *sd, +@@ -1522,7 +1526,11 @@ static int gc5035_get_fmt(struct v4l2_subdev *sd, mutex_lock(&gc5035->mutex); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { -- fmt->format = *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) + fmt->format = *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); ++#else + fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); ++#endif } else { fmt->format.width = mode->width; fmt->format.height = mode->height; -diff --git a/drivers/media/i2c/hi556.c b/drivers/media/i2c/hi556.c -index e268c94..4b606d5 100644 ---- a/drivers/media/i2c/hi556.c -+++ b/drivers/media/i2c/hi556.c -@@ -1059,7 +1059,7 @@ static int hi556_set_format(struct v4l2_subdev *sd, - #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) - *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; - #else -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; - #endif - } else { - hi556->cur_mode = mode; -@@ -1102,9 +1102,7 @@ static int hi556_get_format(struct v4l2_subdev *sd, - fmt->format = - *v4l2_subdev_get_try_format(&hi556->sd, cfg, fmt->pad); - #else -- fmt->format = *v4l2_subdev_get_try_format(&hi556->sd, -- sd_state, -- fmt->pad); -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - #endif - else - hi556_assign_pad_format(hi556->cur_mode, &fmt->format); -@@ -1162,7 +1160,7 @@ static int hi556_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - v4l2_subdev_get_try_format(sd, fh->pad, 0)); - #else - hi556_assign_pad_format(&supported_modes[0], -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - #endif - mutex_unlock(&hi556->mutex); - -diff --git a/drivers/media/i2c/hm11b1.c b/drivers/media/i2c/hm11b1.c -index fa9da1b..316d00d 100644 ---- a/drivers/media/i2c/hm11b1.c -+++ b/drivers/media/i2c/hm11b1.c -@@ -921,7 +921,7 @@ static int hm11b1_set_format(struct v4l2_subdev *sd, - #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) - *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; - #else -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; - #endif - } else { - hm11b1->cur_mode = mode; -@@ -962,8 +962,7 @@ static int hm11b1_get_format(struct v4l2_subdev *sd, - fmt->format = *v4l2_subdev_get_try_format(&hm11b1->sd, cfg, - fmt->pad); - #else -- fmt->format = *v4l2_subdev_get_try_format(&hm11b1->sd, -- sd_state, fmt->pad); -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - #endif - else - hm11b1_update_pad_format(hm11b1->cur_mode, &fmt->format); -@@ -1020,7 +1019,7 @@ static int hm11b1_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) - v4l2_subdev_get_try_format(sd, fh->pad, 0)); - #else -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - #endif - mutex_unlock(&hm11b1->mutex); - -diff --git a/drivers/media/i2c/hm2170.c b/drivers/media/i2c/hm2170.c -index 284067e..dae3f4f 100644 ---- a/drivers/media/i2c/hm2170.c -+++ b/drivers/media/i2c/hm2170.c -@@ -1065,7 +1065,7 @@ static int hm2170_set_format(struct v4l2_subdev *sd, - mutex_lock(&hm2170->mutex); - hm2170_update_pad_format(mode, &fmt->format); - if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; - } else { - hm2170->cur_mode = mode; - __v4l2_ctrl_s_ctrl(hm2170->link_freq, mode->link_freq_index); -@@ -1097,8 +1097,7 @@ static int hm2170_get_format(struct v4l2_subdev *sd, - - mutex_lock(&hm2170->mutex); - if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) -- fmt->format = *v4l2_subdev_get_try_format(&hm2170->sd, -- sd_state, fmt->pad); -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - else - hm2170_update_pad_format(hm2170->cur_mode, &fmt->format); - -@@ -1145,7 +1144,7 @@ static int hm2170_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - - mutex_lock(&hm2170->mutex); - hm2170_update_pad_format(&supported_modes[hm2170->rev][0], -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - mutex_unlock(&hm2170->mutex); - - return 0; -diff --git a/drivers/media/i2c/hm2172.c b/drivers/media/i2c/hm2172.c -index 3d8d58f..4eb8cab 100644 ---- a/drivers/media/i2c/hm2172.c -+++ b/drivers/media/i2c/hm2172.c -@@ -1494,7 +1494,7 @@ static int hm2172_set_format(struct v4l2_subdev *sd, - mutex_lock(&hm2172->mutex); - hm2172_update_pad_format(mode, &fmt->format); - if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; - } else { - hm2172->cur_mode = mode; - __v4l2_ctrl_s_ctrl(hm2172->link_freq, mode->link_freq_index); -@@ -1526,8 +1526,7 @@ static int hm2172_get_format(struct v4l2_subdev *sd, - - mutex_lock(&hm2172->mutex); - if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) -- fmt->format = *v4l2_subdev_get_try_format(&hm2172->sd, -- sd_state, fmt->pad); -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - else - hm2172_update_pad_format(hm2172->cur_mode, &fmt->format); - -@@ -1572,7 +1571,7 @@ static int hm2172_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - - mutex_lock(&hm2172->mutex); - hm2172_update_pad_format(&supported_modes[0], -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - mutex_unlock(&hm2172->mutex); - - return 0; -diff --git a/drivers/media/i2c/ov01a10.c b/drivers/media/i2c/ov01a10.c -index e7ac490..a3a3fd0 100644 ---- a/drivers/media/i2c/ov01a10.c -+++ b/drivers/media/i2c/ov01a10.c -@@ -753,7 +753,7 @@ static int ov01a10_set_format(struct v4l2_subdev *sd, - #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) - *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; - #else -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; - #endif - } else { - ov01a10->cur_mode = mode; -@@ -792,8 +792,7 @@ static int ov01a10_get_format(struct v4l2_subdev *sd, - fmt->format = *v4l2_subdev_get_try_format(&ov01a10->sd, cfg, - fmt->pad); - #else -- fmt->format = *v4l2_subdev_get_try_format(&ov01a10->sd, -- sd_state, fmt->pad); -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - #endif - else - ov01a10_update_pad_format(ov01a10->cur_mode, &fmt->format); -@@ -851,7 +850,7 @@ static int ov01a10_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - v4l2_subdev_get_try_format(sd, fh->pad, 0)); - #else - ov01a10_update_pad_format(&supported_modes[0], -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - #endif - mutex_unlock(&ov01a10->mutex); - -diff --git a/drivers/media/i2c/ov01a1s.c b/drivers/media/i2c/ov01a1s.c -index 8c8911b..15f98fd 100644 ---- a/drivers/media/i2c/ov01a1s.c -+++ b/drivers/media/i2c/ov01a1s.c -@@ -833,7 +833,7 @@ static int ov01a1s_set_format(struct v4l2_subdev *sd, - #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) - *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; - #else -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; - #endif - } else { - ov01a1s->cur_mode = mode; -@@ -872,8 +872,7 @@ static int ov01a1s_get_format(struct v4l2_subdev *sd, - fmt->format = *v4l2_subdev_get_try_format(&ov01a1s->sd, cfg, - fmt->pad); - #else -- fmt->format = *v4l2_subdev_get_try_format(&ov01a1s->sd, -- sd_state, fmt->pad); -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - #endif - else - ov01a1s_update_pad_format(ov01a1s->cur_mode, &fmt->format); -@@ -931,7 +930,7 @@ static int ov01a1s_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - v4l2_subdev_get_try_format(sd, fh->pad, 0)); - #else - ov01a1s_update_pad_format(&supported_modes[0], -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - #endif - mutex_unlock(&ov01a1s->mutex); - -diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c -index e9969da..a3bebbf 100644 ---- a/drivers/media/i2c/ov02c10.c -+++ b/drivers/media/i2c/ov02c10.c -@@ -1177,7 +1177,7 @@ static int ov02c10_set_format(struct v4l2_subdev *sd, - #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) - *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; - #else -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; - #endif - } else { - ov02c10->cur_mode = mode; -@@ -1216,8 +1216,7 @@ static int ov02c10_get_format(struct v4l2_subdev *sd, - fmt->format = *v4l2_subdev_get_try_format(&ov02c10->sd, cfg, - fmt->pad); - #else -- fmt->format = *v4l2_subdev_get_try_format(&ov02c10->sd, -- sd_state, fmt->pad); -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - #endif - else - ov02c10_update_pad_format(ov02c10->cur_mode, &fmt->format); -@@ -1275,7 +1274,7 @@ static int ov02c10_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - v4l2_subdev_get_try_format(sd, fh->pad, 0)); - #else - ov02c10_update_pad_format(&supported_modes[0], -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - #endif - mutex_unlock(&ov02c10->mutex); - -diff --git a/drivers/media/i2c/ov02e10.c b/drivers/media/i2c/ov02e10.c -index fb7993b..3034f2d 100644 ---- a/drivers/media/i2c/ov02e10.c -+++ b/drivers/media/i2c/ov02e10.c -@@ -877,7 +877,7 @@ static int ov02e10_set_format(struct v4l2_subdev *sd, - mutex_lock(&ov02e10->mutex); - ov02e10_update_pad_format(mode, &fmt->format); - if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = - fmt->format; - } else { - ov02e10->cur_mode = mode; -@@ -910,8 +910,7 @@ static int ov02e10_get_format(struct v4l2_subdev *sd, - - mutex_lock(&ov02e10->mutex); - if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) -- fmt->format = *v4l2_subdev_get_try_format(&ov02e10->sd, -- sd_state, fmt->pad); -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - else - ov02e10_update_pad_format(ov02e10->cur_mode, &fmt->format); - -@@ -956,7 +955,7 @@ static int ov02e10_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - - mutex_lock(&ov02e10->mutex); - ov02e10_update_pad_format(&supported_modes[0], -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - mutex_unlock(&ov02e10->mutex); - - return 0; -diff --git a/drivers/media/i2c/ov08a10.c b/drivers/media/i2c/ov08a10.c -index c6e67ee..d09e68e 100644 ---- a/drivers/media/i2c/ov08a10.c -+++ b/drivers/media/i2c/ov08a10.c -@@ -859,8 +859,7 @@ static int ov08a10_set_format(struct v4l2_subdev *sd, - mutex_lock(&ov08a10->mutex); - ov08a10_update_pad_format(mode, &fmt->format); - if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { -- *v4l2_subdev_get_try_format(sd, sd_state, -- fmt->pad) = fmt->format; -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; - } else { - ov08a10->cur_mode = mode; - __v4l2_ctrl_s_ctrl(ov08a10->link_freq, mode->link_freq_index); -@@ -893,9 +892,7 @@ static int ov08a10_get_format(struct v4l2_subdev *sd, - - mutex_lock(&ov08a10->mutex); - if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) -- fmt->format = *v4l2_subdev_get_try_format(&ov08a10->sd, -- sd_state, -- fmt->pad); -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - else - ov08a10_update_pad_format(ov08a10->cur_mode, &fmt->format); - -@@ -940,7 +937,7 @@ static int ov08a10_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - - mutex_lock(&ov08a10->mutex); - ov08a10_update_pad_format(&supported_modes[0], -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - mutex_unlock(&ov08a10->mutex); - - return 0; diff --git a/drivers/media/i2c/ov13858_intel.c b/drivers/media/i2c/ov13858_intel.c -index 596368b..a36b8d1 100644 +index 8b8a3ba..b9f9ff2 100644 --- a/drivers/media/i2c/ov13858_intel.c +++ b/drivers/media/i2c/ov13858_intel.c -@@ -1380,13 +1380,12 @@ static int ov13858_write_reg_list(struct ov13858 *ov13858, - static int ov13858_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - { - struct ov13858 *ov13858 = to_ov13858(sd); -- struct v4l2_mbus_framefmt *try_fmt = v4l2_subdev_get_try_format(sd, -+ struct v4l2_mbus_framefmt *try_fmt; - #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) -- fh->pad, -+ try_fmt = v4l2_subdev_get_try_format(sd, fh->pad, 0); - #else -- fh->state, -+ try_fmt = v4l2_subdev_state_get_format(fh->state, 0); - #endif -- 0); - - mutex_lock(&ov13858->mutex); - -@@ -1582,7 +1581,7 @@ static int ov13858_do_get_pad_format(struct ov13858 *ov13858, +@@ -1587,8 +1587,10 @@ static int ov13858_do_get_pad_format(struct ov13858 *ov13858, + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); - #else -- framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); +-#else ++#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) + framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); ++#else + framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad); #endif fmt->format = *framefmt; } else { -@@ -1647,7 +1646,7 @@ ov13858_set_pad_format(struct v4l2_subdev *sd, +@@ -1652,8 +1654,10 @@ ov13858_set_pad_format(struct v4l2_subdev *sd, + if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); - #else -- framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); +-#else ++#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) + framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); ++#else + framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad); #endif *framefmt = fmt->format; } else { -diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c -index f117173..2a217c2 100644 ---- a/drivers/media/i2c/ov2740.c -+++ b/drivers/media/i2c/ov2740.c -@@ -1116,7 +1116,7 @@ static int ov2740_set_format(struct v4l2_subdev *sd, - #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) - *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; - #else -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; - #endif - } else { - ov2740->cur_mode = mode; -@@ -1158,8 +1158,7 @@ static int ov2740_get_format(struct v4l2_subdev *sd, - cfg, - fmt->pad); - #else -- fmt->format = *v4l2_subdev_get_try_format(&ov2740->sd, -- sd_state, -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, - fmt->pad); - #endif - else -@@ -1232,7 +1231,7 @@ static int ov2740_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - v4l2_subdev_get_try_format(sd, fh->pad, 0)); - #else - ov2740_update_pad_format(ov2740->cur_mode, -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - #endif - mutex_unlock(&ov2740->mutex); - -diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c -index b1e938e..89b45ce 100644 ---- a/drivers/media/i2c/ov8856.c -+++ b/drivers/media/i2c/ov8856.c -@@ -1044,7 +1044,7 @@ static int ov8856_set_format(struct v4l2_subdev *sd, - #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) - *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; - #else -- *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; -+ *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; - #endif - } else { - ov8856->cur_mode = mode; -@@ -1086,8 +1086,7 @@ static int ov8856_get_format(struct v4l2_subdev *sd, - fmt->format = *v4l2_subdev_get_try_format(&ov8856->sd, cfg, - fmt->pad); - #else -- fmt->format = *v4l2_subdev_get_try_format(&ov8856->sd, -- sd_state, fmt->pad); -+ fmt->format = *v4l2_subdev_state_get_format(sd_state, fmt->pad); - #endif - else - ov8856_update_pad_format(ov8856->cur_mode, &fmt->format); -@@ -1146,7 +1145,7 @@ static int ov8856_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - v4l2_subdev_get_try_format(sd, fh->pad, 0)); - #else - ov8856_update_pad_format(&supported_modes[0], -- v4l2_subdev_get_try_format(sd, fh->state, 0)); -+ v4l2_subdev_state_get_format(fh->state, 0)); - #endif - mutex_unlock(&ov8856->mutex); - -diff --git a/drivers/media/pci/intel/ipu-isys-subdev.c b/drivers/media/pci/intel/ipu-isys-subdev.c -index b9f48d4..e097755 100644 ---- a/drivers/media/pci/intel/ipu-isys-subdev.c -+++ b/drivers/media/pci/intel/ipu-isys-subdev.c -@@ -163,7 +163,7 @@ struct v4l2_mbus_framefmt *__ipu_isys_get_ffmt(struct v4l2_subdev *sd, - #elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) - return v4l2_subdev_get_try_format(sd, cfg, pad); - #else -- return v4l2_subdev_get_try_format(sd, state, pad); -+ return v4l2_subdev_state_get_format(state, pad); - #endif - } - -@@ -201,9 +201,9 @@ struct v4l2_rect *__ipu_isys_get_selection(struct v4l2_subdev *sd, - return v4l2_subdev_get_try_compose(sd, cfg, pad); - #else - case V4L2_SEL_TGT_CROP: -- return v4l2_subdev_get_try_crop(sd, state, pad); -+ return v4l2_subdev_state_get_crop(state, pad); - case V4L2_SEL_TGT_COMPOSE: -- return v4l2_subdev_get_try_compose(sd, state, pad); -+ return v4l2_subdev_state_get_compose(state, pad); - #endif - } - } -@@ -757,11 +757,11 @@ int ipu_isys_subdev_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) - v4l2_subdev_get_try_compose(sd, fh->pad, i); - #else - struct v4l2_mbus_framefmt *try_fmt = -- v4l2_subdev_get_try_format(sd, fh->state, i); -+ v4l2_subdev_state_get_format(fh->state, i); - struct v4l2_rect *try_crop = -- v4l2_subdev_get_try_crop(sd, fh->state, i); -+ v4l2_subdev_state_get_crop(fh->state, i); - struct v4l2_rect *try_compose = -- v4l2_subdev_get_try_compose(sd, fh->state, i); -+ v4l2_subdev_state_get_compose(fh->state, i); - #endif - - *try_fmt = asd->ffmt[i]; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0014-backport-media-v4l2-subdev-Rename-.init_cfg-operatio.patch ipu6-drivers-0~git202404110253.97c94720/debian/patches/0014-backport-media-v4l2-subdev-Rename-.init_cfg-operatio.patch --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0014-backport-media-v4l2-subdev-Rename-.init_cfg-operatio.patch 2024-02-21 22:02:47.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/0014-backport-media-v4l2-subdev-Rename-.init_cfg-operatio.patch 2024-04-11 18:38:46.000000000 +0800 @@ -15,10 +15,10 @@ 1 file changed, 15 insertions(+) diff --git a/drivers/media/i2c/gc5035.c b/drivers/media/i2c/gc5035.c -index c9f8f2b..72f6a0f 100644 +index 812611b..f534a61 100644 --- a/drivers/media/i2c/gc5035.c +++ b/drivers/media/i2c/gc5035.c -@@ -1686,7 +1686,11 @@ static int gc5035_runtime_suspend(struct device *dev) +@@ -1694,7 +1694,11 @@ static int gc5035_runtime_suspend(struct device *dev) return 0; } @@ -30,7 +30,7 @@ struct v4l2_subdev_state *sd_state) { struct v4l2_subdev_format fmt = { -@@ -1714,7 +1718,9 @@ static const struct v4l2_subdev_video_ops gc5035_video_ops = { +@@ -1722,7 +1726,9 @@ static const struct v4l2_subdev_video_ops gc5035_video_ops = { }; static const struct v4l2_subdev_pad_ops gc5035_pad_ops = { @@ -40,7 +40,7 @@ .enum_mbus_code = gc5035_enum_mbus_code, .enum_frame_size = gc5035_enum_frame_sizes, .get_fmt = gc5035_get_fmt, -@@ -1726,6 +1732,12 @@ static const struct v4l2_subdev_ops gc5035_subdev_ops = { +@@ -1734,6 +1740,12 @@ static const struct v4l2_subdev_ops gc5035_subdev_ops = { .pad = &gc5035_pad_ops, }; @@ -53,7 +53,7 @@ static const struct media_entity_operations gc5035_subdev_entity_ops = { .link_validate = v4l2_subdev_link_validate, }; -@@ -2091,6 +2103,9 @@ static int gc5035_probe(struct i2c_client *client) +@@ -2099,6 +2111,9 @@ static int gc5035_probe(struct i2c_client *client) mutex_init(&gc5035->mutex); sd = &gc5035->subdev; v4l2_i2c_subdev_init(sd, client, &gc5035_subdev_ops); diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0015-UBUNTU-SAUCE-firmware-fallback-to-old-firmware-path.patch ipu6-drivers-0~git202404110253.97c94720/debian/patches/0015-UBUNTU-SAUCE-firmware-fallback-to-old-firmware-path.patch --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0015-UBUNTU-SAUCE-firmware-fallback-to-old-firmware-path.patch 1970-01-01 08:00:00.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/0015-UBUNTU-SAUCE-firmware-fallback-to-old-firmware-path.patch 2024-04-11 18:38:46.000000000 +0800 @@ -0,0 +1,66 @@ +From: You-Sheng Yang +Date: Fri, 12 Apr 2024 16:45:31 +0800 +Subject: UBUNTU: SAUCE: firmware: fallback to old firmware path + +Upstream linux-firmware commit dbc294d3e ("Intel IPU6: Move firmware +binaries under ipu/") adopted an additional directory ipu for IPU +firmware blobs. + +Signed-off-by: You-Sheng Yang +--- + drivers/media/pci/intel/ipu.c | 14 +++++++++++--- + drivers/media/pci/intel/ipu6/ipu-platform.h | 14 +++++++------- + 2 files changed, 18 insertions(+), 10 deletions(-) + +diff --git a/drivers/media/pci/intel/ipu.c b/drivers/media/pci/intel/ipu.c +index ea16408..e9200ec 100644 +--- a/drivers/media/pci/intel/ipu.c ++++ b/drivers/media/pci/intel/ipu.c +@@ -414,11 +414,19 @@ int request_cpd_fw(const struct firmware **firmware_p, const char *name, + { + const struct firmware *fw; + struct firmware *tmp; ++ char buf[32]; + int ret; + +- ret = request_firmware(&fw, name, device); +- if (ret) +- return ret; ++ snprintf(buf, sizeof(buf), "intel/ipu/%s", name); ++ ret = request_firmware(&fw, buf, device); ++ if (ret) { ++ if (ret == -ENOENT) { ++ snprintf(buf, sizeof(buf), "intel/%s", name); ++ ret = request_firmware(&fw, buf, device); ++ } ++ if (ret) ++ return ret; ++ } + + if (is_vmalloc_addr(fw->data)) { + *firmware_p = fw; +diff --git a/drivers/media/pci/intel/ipu6/ipu-platform.h b/drivers/media/pci/intel/ipu6/ipu-platform.h +index 9d2b993..660066e 100644 +--- a/drivers/media/pci/intel/ipu6/ipu-platform.h ++++ b/drivers/media/pci/intel/ipu6/ipu-platform.h +@@ -6,13 +6,13 @@ + + #define IPU_NAME "intel-ipu6" + +-#define IPU6SE_FIRMWARE_NAME "intel/ipu6se_fw.bin" +-#define IPU6EP_FIRMWARE_NAME "intel/ipu6ep_fw.bin" +-#define IPU6EPES_FIRMWARE_NAME "intel/ipu6epes_fw.bin" +-#define IPU6_FIRMWARE_NAME "intel/ipu6_fw.bin" +-#define IPU6EPMTL_FIRMWARE_NAME "intel/ipu6epmtl_fw.bin" +-#define IPU6EPMTLES_FIRMWARE_NAME "intel/ipu6epmtles_fw.bin" +-#define IPU6EPADLN_FIRMWARE_NAME "intel/ipu6epadln_fw.bin" ++#define IPU6SE_FIRMWARE_NAME "ipu6se_fw.bin" ++#define IPU6EP_FIRMWARE_NAME "ipu6ep_fw.bin" ++#define IPU6EPES_FIRMWARE_NAME "ipu6epes_fw.bin" ++#define IPU6_FIRMWARE_NAME "ipu6_fw.bin" ++#define IPU6EPMTL_FIRMWARE_NAME "ipu6epmtl_fw.bin" ++#define IPU6EPMTLES_FIRMWARE_NAME "ipu6epmtles_fw.bin" ++#define IPU6EPADLN_FIRMWARE_NAME "ipu6epadln_fw.bin" + + /* + * The following definitions are encoded to the media_device's model field so diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0016-UBUNTU-SAUCE-don-t-fail-probing-at-hwcfg-checks.patch ipu6-drivers-0~git202404110253.97c94720/debian/patches/0016-UBUNTU-SAUCE-don-t-fail-probing-at-hwcfg-checks.patch --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/0016-UBUNTU-SAUCE-don-t-fail-probing-at-hwcfg-checks.patch 1970-01-01 08:00:00.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/0016-UBUNTU-SAUCE-don-t-fail-probing-at-hwcfg-checks.patch 2024-04-11 18:38:46.000000000 +0800 @@ -0,0 +1,178 @@ +From: You-Sheng Yang +Date: Wed, 17 Apr 2024 00:51:38 +0800 +Subject: UBUNTU: SAUCE: don't fail probing at hwcfg checks + +Signed-off-by: You-Sheng Yang +--- + drivers/media/i2c/hi556.c | 5 ++--- + drivers/media/i2c/hm11b1.c | 4 +--- + drivers/media/i2c/hm2170.c | 4 +--- + drivers/media/i2c/hm2172.c | 4 +--- + drivers/media/i2c/ov01a10.c | 4 +--- + drivers/media/i2c/ov01a1s.c | 4 +--- + drivers/media/i2c/ov02c10.c | 4 +--- + drivers/media/i2c/ov02e10.c | 4 +--- + drivers/media/i2c/ov08a10.c | 4 +--- + drivers/media/i2c/ov2740.c | 5 ++--- + 10 files changed, 12 insertions(+), 30 deletions(-) + +diff --git a/drivers/media/i2c/hi556.c b/drivers/media/i2c/hi556.c +index a67df87..148be4c 100644 +--- a/drivers/media/i2c/hi556.c ++++ b/drivers/media/i2c/hi556.c +@@ -1378,9 +1378,8 @@ static int hi556_probe(struct i2c_client *client) + + ret = hi556_check_hwcfg(&client->dev); + if (ret) +- return dev_err_probe(&client->dev, ret, +- "failed to check HW configuration: %d", +- ret); ++ dev_err(&client->dev, ++ "failed to check HW configuration: %d", ret); + + hi556 = devm_kzalloc(&client->dev, sizeof(*hi556), GFP_KERNEL); + if (!hi556) { +diff --git a/drivers/media/i2c/hm11b1.c b/drivers/media/i2c/hm11b1.c +index f3900d2..e90bc68 100644 +--- a/drivers/media/i2c/hm11b1.c ++++ b/drivers/media/i2c/hm11b1.c +@@ -1203,10 +1203,8 @@ static int hm11b1_probe(struct i2c_client *client) + + /* Check HW config */ + ret = hm11b1_check_hwcfg(&client->dev); +- if (ret) { ++ if (ret) + dev_err(&client->dev, "failed to check hwcfg: %d", ret); +- return ret; +- } + + hm11b1 = devm_kzalloc(&client->dev, sizeof(*hm11b1), GFP_KERNEL); + if (!hm11b1) +diff --git a/drivers/media/i2c/hm2170.c b/drivers/media/i2c/hm2170.c +index 19d3734..3c72587 100644 +--- a/drivers/media/i2c/hm2170.c ++++ b/drivers/media/i2c/hm2170.c +@@ -1318,10 +1318,8 @@ static int hm2170_probe(struct i2c_client *client) + + /* Check HW config */ + ret = hm2170_check_hwcfg(&client->dev); +- if (ret) { ++ if (ret) + dev_err(&client->dev, "failed to check hwcfg: %d", ret); +- return ret; +- } + + hm2170 = devm_kzalloc(&client->dev, sizeof(*hm2170), GFP_KERNEL); + if (!hm2170) { +diff --git a/drivers/media/i2c/hm2172.c b/drivers/media/i2c/hm2172.c +index a10f9ad..2f034e9 100644 +--- a/drivers/media/i2c/hm2172.c ++++ b/drivers/media/i2c/hm2172.c +@@ -1746,10 +1746,8 @@ static int hm2172_probe(struct i2c_client *client) + + /* Check HW config */ + ret = hm2172_check_hwcfg(&client->dev); +- if (ret) { ++ if (ret) + dev_err(&client->dev, "failed to check hwcfg: %d", ret); +- return ret; +- } + + hm217 = devm_kzalloc(&client->dev, sizeof(*hm217), GFP_KERNEL); + if (!hm217) +diff --git a/drivers/media/i2c/ov01a10.c b/drivers/media/i2c/ov01a10.c +index d08fbe9..c199ae7 100644 +--- a/drivers/media/i2c/ov01a10.c ++++ b/drivers/media/i2c/ov01a10.c +@@ -1013,10 +1013,8 @@ static int ov01a10_probe(struct i2c_client *client) + + /* Check HW config */ + ret = ov01a10_check_hwcfg(&client->dev); +- if (ret) { ++ if (ret) + dev_err(&client->dev, "failed to check hwcfg: %d", ret); +- return ret; +- } + + ov01a10 = devm_kzalloc(&client->dev, sizeof(*ov01a10), GFP_KERNEL); + if (!ov01a10) +diff --git a/drivers/media/i2c/ov01a1s.c b/drivers/media/i2c/ov01a1s.c +index eb2b792..514f115 100644 +--- a/drivers/media/i2c/ov01a1s.c ++++ b/drivers/media/i2c/ov01a1s.c +@@ -1169,10 +1169,8 @@ static int ov01a1s_probe(struct i2c_client *client) + + /* Check HW config */ + ret = ov01a1s_check_hwcfg(&client->dev); +- if (ret) { ++ if (ret) + dev_err(&client->dev, "failed to check hwcfg: %d", ret); +- return ret; +- } + + ov01a1s = devm_kzalloc(&client->dev, sizeof(*ov01a1s), GFP_KERNEL); + if (!ov01a1s) +diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c +index a6194f4..b8299fb 100644 +--- a/drivers/media/i2c/ov02c10.c ++++ b/drivers/media/i2c/ov02c10.c +@@ -1500,10 +1500,8 @@ static int ov02c10_probe(struct i2c_client *client) + + /* Check HW config */ + ret = ov02c10_check_hwcfg(&client->dev); +- if (ret) { ++ if (ret) + dev_err(&client->dev, "failed to check hwcfg: %d", ret); +- return ret; +- } + + ov02c10 = devm_kzalloc(&client->dev, sizeof(*ov02c10), GFP_KERNEL); + if (!ov02c10) +diff --git a/drivers/media/i2c/ov02e10.c b/drivers/media/i2c/ov02e10.c +index 7004354..b52ec91 100644 +--- a/drivers/media/i2c/ov02e10.c ++++ b/drivers/media/i2c/ov02e10.c +@@ -1133,10 +1133,8 @@ static int ov02e10_probe(struct i2c_client *client) + + /* Check HW config */ + ret = ov02e10_check_hwcfg(&client->dev); +- if (ret) { ++ if (ret) + dev_err(&client->dev, "failed to check hwcfg: %d", ret); +- return ret; +- } + + ov02e = devm_kzalloc(&client->dev, sizeof(*ov02e), GFP_KERNEL); + if (!ov02e) +diff --git a/drivers/media/i2c/ov08a10.c b/drivers/media/i2c/ov08a10.c +index 7df05ac..e005756 100644 +--- a/drivers/media/i2c/ov08a10.c ++++ b/drivers/media/i2c/ov08a10.c +@@ -1127,10 +1127,8 @@ static int ov08a10_probe(struct i2c_client *client) + + /* Check HW config */ + ret = ov08a10_check_hwcfg(&client->dev); +- if (ret) { ++ if (ret) + dev_err(&client->dev, "failed to check hwcfg: %d", ret); +- return ret; +- } + + ov08a10 = devm_kzalloc(&client->dev, sizeof(*ov08a10), GFP_KERNEL); + if (!ov08a10) +diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c +index 2b2fbf2..4d76469 100644 +--- a/drivers/media/i2c/ov2740.c ++++ b/drivers/media/i2c/ov2740.c +@@ -1518,9 +1518,8 @@ static int ov2740_probe(struct i2c_client *client) + + ret = ov2740_check_hwcfg(&client->dev); + if (ret) +- return dev_err_probe(&client->dev, ret, +- "failed to check HW configuration: %d", +- ret); ++ dev_err(&client->dev, ++ "failed to check HW configuration: %d", ret); + + v4l2_i2c_subdev_init(&ov2740->sd, client, &ov2740_subdev_ops); + diff -Nru ipu6-drivers-0~git202311240921.07f0612e/debian/patches/series ipu6-drivers-0~git202404110253.97c94720/debian/patches/series --- ipu6-drivers-0~git202311240921.07f0612e/debian/patches/series 2024-02-21 22:02:47.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/debian/patches/series 2024-04-11 18:38:46.000000000 +0800 @@ -6,6 +6,7 @@ fix-ftbfs-v5.19.patch 0007-dkms-add-CONFIG_VIDEO_V4L2_I2C-to-BUILD_EXCLUSIVE_CO.patch 0011-UBUNTU-SAUCE-i2c-compile-omitted-sensor-drivers.patch -0012-backport-replace-strlcpy-with-strscpy.patch 0013-backport-Switch-to-stream-aware-state-functions.patch 0014-backport-media-v4l2-subdev-Rename-.init_cfg-operatio.patch +0015-UBUNTU-SAUCE-firmware-fallback-to-old-firmware-path.patch +0016-UBUNTU-SAUCE-don-t-fail-probing-at-hwcfg-checks.patch diff -Nru ipu6-drivers-0~git202311240921.07f0612e/dkms.conf ipu6-drivers-0~git202404110253.97c94720/dkms.conf --- ipu6-drivers-0~git202311240921.07f0612e/dkms.conf 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/dkms.conf 2024-04-11 10:53:09.000000000 +0800 @@ -3,83 +3,115 @@ MAKE="make KERNELRELEASE=$kernelver KERNEL_SRC=$kernel_source_dir" CLEAN="make KERNELRELEASE=$kernelver KERNEL_SRC=$kernel_source_dir clean" +AUTOINSTALL="yes" + +version_lt() { + IFS='.' read -r i j k <<< "$1" + IFS='.' read -r a b c <<< "$2" + i=${i:-0} + j=${j:-0} + k=${k:-0} + a=${a:-0} + b=${b:-0} + c=${c:-0} + if [ "$i" -lt "$a" ]; then + return 0 + elif [ "$i" -eq "$a" ]; then + if [ "$j" -lt "$b" ]; then + return 0 + elif [ "$j" -eq "$b" ]; then + if [ "$k" -lt "$c" ]; then + return 0 + fi + fi + fi + return 1 +} + + +KERNEL_VERSION=$(echo ${kernelver} | sed 's/[^0-9.]*\([0-9.]*\).*/\1/') +KV_IVSC=6.6.0 +KV_OV2740=6.8.0 -BUILT_MODULE_NAME[0]="ljca" +BUILT_MODULE_NAME[0]="intel-ipu6" +BUILT_MODULE_LOCATION[0]="drivers/media/pci/intel/ipu6" DEST_MODULE_LOCATION[0]="/updates" -BUILT_MODULE_NAME[1]="spi-ljca" +BUILT_MODULE_NAME[1]="intel-ipu6-isys" +BUILT_MODULE_LOCATION[1]="drivers/media/pci/intel/ipu6" DEST_MODULE_LOCATION[1]="/updates" -BUILT_MODULE_NAME[2]="gpio-ljca" +BUILT_MODULE_NAME[2]="intel-ipu6-psys" +BUILT_MODULE_LOCATION[2]="drivers/media/pci/intel/ipu6" DEST_MODULE_LOCATION[2]="/updates" -BUILT_MODULE_NAME[3]="i2c-ljca" +BUILT_MODULE_NAME[3]="hm11b1" +BUILT_MODULE_LOCATION[3]="drivers/media/i2c" DEST_MODULE_LOCATION[3]="/updates" -BUILT_MODULE_NAME[4]="mei-vsc" +BUILT_MODULE_NAME[4]="ov01a1s" +BUILT_MODULE_LOCATION[4]="drivers/media/i2c" DEST_MODULE_LOCATION[4]="/updates" -BUILT_MODULE_NAME[5]="intel_vsc" +BUILT_MODULE_NAME[5]="ov01a10" +BUILT_MODULE_LOCATION[5]="drivers/media/i2c" DEST_MODULE_LOCATION[5]="/updates" -BUILT_MODULE_NAME[6]="mei_csi" +BUILT_MODULE_NAME[6]="ov02c10" +BUILT_MODULE_LOCATION[6]="drivers/media/i2c" DEST_MODULE_LOCATION[6]="/updates" -BUILT_MODULE_NAME[7]="mei_ace" +BUILT_MODULE_NAME[7]="ov02e10" +BUILT_MODULE_LOCATION[7]="drivers/media/i2c" DEST_MODULE_LOCATION[7]="/updates" -BUILT_MODULE_NAME[8]="mei_pse" +BUILT_MODULE_NAME[8]="hm2170" +BUILT_MODULE_LOCATION[8]="drivers/media/i2c" DEST_MODULE_LOCATION[8]="/updates" -BUILT_MODULE_NAME[9]="mei_ace_debug" +BUILT_MODULE_NAME[9]="hm2172" +BUILT_MODULE_LOCATION[9]="drivers/media/i2c" DEST_MODULE_LOCATION[9]="/updates" -BUILT_MODULE_NAME[10]="intel-ipu6" -BUILT_MODULE_LOCATION[10]="drivers/media/pci/intel/ipu6" +BUILT_MODULE_NAME[10]="hi556" +BUILT_MODULE_LOCATION[10]="drivers/media/i2c" DEST_MODULE_LOCATION[10]="/updates" -BUILT_MODULE_NAME[11]="intel-ipu6-isys" -BUILT_MODULE_LOCATION[11]="drivers/media/pci/intel/ipu6" -DEST_MODULE_LOCATION[11]="/updates" - -BUILT_MODULE_NAME[12]="intel-ipu6-psys" -BUILT_MODULE_LOCATION[12]="drivers/media/pci/intel/ipu6" -DEST_MODULE_LOCATION[12]="/updates" - -BUILT_MODULE_NAME[13]="hm11b1" -BUILT_MODULE_LOCATION[13]="drivers/media/i2c" -DEST_MODULE_LOCATION[13]="/updates" - -BUILT_MODULE_NAME[14]="ov01a1s" -BUILT_MODULE_LOCATION[14]="drivers/media/i2c" -DEST_MODULE_LOCATION[14]="/updates" - -BUILT_MODULE_NAME[15]="ov01a10" -BUILT_MODULE_LOCATION[15]="drivers/media/i2c" -DEST_MODULE_LOCATION[15]="/updates" - -BUILT_MODULE_NAME[16]="ov02c10" -BUILT_MODULE_LOCATION[16]="drivers/media/i2c" -DEST_MODULE_LOCATION[16]="/updates" - -BUILT_MODULE_NAME[17]="ov2740" -BUILT_MODULE_LOCATION[17]="drivers/media/i2c" -DEST_MODULE_LOCATION[17]="/updates" - -BUILT_MODULE_NAME[18]="hm2170" -BUILT_MODULE_LOCATION[18]="drivers/media/i2c" -DEST_MODULE_LOCATION[18]="/updates" - -BUILT_MODULE_NAME[19]="hm2172" -BUILT_MODULE_LOCATION[19]="drivers/media/i2c" -DEST_MODULE_LOCATION[19]="/updates" - -BUILT_MODULE_NAME[20]="hi556" -BUILT_MODULE_LOCATION[20]="drivers/media/i2c" -DEST_MODULE_LOCATION[20]="/updates" - -BUILT_MODULE_NAME[21]="ov02e10" -BUILT_MODULE_LOCATION[21]="drivers/media/i2c" -DEST_MODULE_LOCATION[21]="/updates" -AUTOINSTALL="yes" +if version_lt ${KERNEL_VERSION} ${KV_OV2740}; then + BUILT_MODULE_NAME[11]="ov2740" + BUILT_MODULE_LOCATION[11]="drivers/media/i2c" + DEST_MODULE_LOCATION[11]="/updates" +fi + +if version_lt ${KERNEL_VERSION} ${KV_IVSC}; then + BUILT_MODULE_NAME[12]="ljca" + DEST_MODULE_LOCATION[12]="/updates" + + BUILT_MODULE_NAME[13]="spi-ljca" + DEST_MODULE_LOCATION[13]="/updates" + + BUILT_MODULE_NAME[14]="gpio-ljca" + DEST_MODULE_LOCATION[14]="/updates" + + BUILT_MODULE_NAME[15]="i2c-ljca" + DEST_MODULE_LOCATION[15]="/updates" + + BUILT_MODULE_NAME[16]="mei-vsc" + DEST_MODULE_LOCATION[16]="/updates" + + BUILT_MODULE_NAME[17]="intel_vsc" + DEST_MODULE_LOCATION[17]="/updates" + + BUILT_MODULE_NAME[18]="mei_csi" + DEST_MODULE_LOCATION[18]="/updates" + + BUILT_MODULE_NAME[19]="mei_ace" + DEST_MODULE_LOCATION[19]="/updates" + + BUILT_MODULE_NAME[20]="mei_pse" + DEST_MODULE_LOCATION[20]="/updates" + + BUILT_MODULE_NAME[21]="mei_ace_debug" + DEST_MODULE_LOCATION[21]="/updates" +fi diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/hi556.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/hi556.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/hi556.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/hi556.c 2024-04-11 10:53:09.000000000 +0800 @@ -12,7 +12,8 @@ #include #include #include -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) #include static const struct acpi_device_id cvfd_ids[] = { @@ -509,7 +510,8 @@ /* Clock provider */ struct clk *img_clk; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) struct vsc_mipi_config conf; struct vsc_camera_status status; struct v4l2_ctrl *privacy_status; @@ -525,7 +527,8 @@ /* True if the device has been identified */ bool identified; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) bool use_intel_vsc; #endif }; @@ -701,7 +704,8 @@ ret = hi556_test_pattern(hi556, ctrl->val); break; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) case V4L2_CID_PRIVACY: dev_dbg(&client->dev, "set privacy to %d", ctrl->val); break; @@ -728,7 +732,8 @@ int ret; ctrl_hdlr = &hi556->ctrl_handler; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ret = v4l2_ctrl_handler_init(ctrl_hdlr, 9); #else ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); @@ -766,7 +771,8 @@ h_blank); if (hi556->hblank) hi556->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) hi556->privacy_status = v4l2_ctrl_new_std(ctrl_hdlr, &hi556_ctrl_ops, V4L2_CID_PRIVACY, 0, 1, 1, !(hi556->status.status)); @@ -830,7 +836,8 @@ return 0; } -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) static void hi556_vsc_privacy_callback(void *handle, enum vsc_privacy_status status) { @@ -929,7 +936,8 @@ struct hi556 *hi556 = to_hi556(sd); int ret = 0; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) if (hi556->use_intel_vsc) { ret = vsc_release_camera_sensor(&hi556->status); if (ret && ret != -EAGAIN) @@ -953,7 +961,8 @@ struct hi556 *hi556 = to_hi556(sd); int ret; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) if (hi556->use_intel_vsc) { hi556->conf.lane_num = HI556_DATA_LANES; /* frequency unit 100k */ @@ -1058,8 +1067,10 @@ if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; #endif } else { hi556->cur_mode = mode; @@ -1101,10 +1112,14 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) fmt->format = *v4l2_subdev_get_try_format(&hi556->sd, cfg, fmt->pad); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&hi556->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, + fmt->pad); #endif else hi556_assign_pad_format(hi556->cur_mode, &fmt->format); @@ -1160,9 +1175,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) hi556_assign_pad_format(&supported_modes[0], v4l2_subdev_get_try_format(sd, fh->pad, 0)); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) hi556_assign_pad_format(&supported_modes[0], v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + hi556_assign_pad_format(&supported_modes[0], + v4l2_subdev_state_get_format(fh->state, 0)); #endif mutex_unlock(&hi556->mutex); @@ -1199,7 +1217,8 @@ struct hi556 *hi556 = to_hi556(sd); int ret; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) acpi_handle handle = ACPI_HANDLE(dev); struct acpi_handle_list dep_devices; acpi_status status; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/hm11b1.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/hm11b1.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/hm11b1.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/hm11b1.c 2024-04-11 10:53:09.000000000 +0800 @@ -920,8 +920,10 @@ if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; #endif } else { hm11b1->cur_mode = mode; @@ -961,9 +963,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) fmt->format = *v4l2_subdev_get_try_format(&hm11b1->sd, cfg, fmt->pad); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&hm11b1->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, fmt->pad); #endif else hm11b1_update_pad_format(hm11b1->cur_mode, &fmt->format); @@ -1019,8 +1024,10 @@ hm11b1_update_pad_format(&supported_modes[0], #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) v4l2_subdev_get_try_format(sd, fh->pad, 0)); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + v4l2_subdev_state_get_format(fh->state, 0)); #endif mutex_unlock(&hm11b1->mutex); @@ -1070,6 +1077,70 @@ return 0; } +static int hm11b1_check_hwcfg(struct device *dev) +{ + struct v4l2_fwnode_endpoint bus_cfg = { + .bus_type = V4L2_MBUS_CSI2_DPHY + }; + struct fwnode_handle *ep; + struct fwnode_handle *fwnode = dev_fwnode(dev); + unsigned int i, j; + int ret; + u32 ext_clk; + + if (!fwnode) + return -ENXIO; + + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (!ep) + return -EPROBE_DEFER; + + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &ext_clk); + if (ret) { + dev_err(dev, "can't get clock frequency"); + return ret; + } + + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) + return ret; + + if (bus_cfg.bus.mipi_csi2.num_data_lanes != HM11B1_DATA_LANES) { + dev_err(dev, "number of CSI2 data lanes %d is not supported", + bus_cfg.bus.mipi_csi2.num_data_lanes); + ret = -EINVAL; + goto out_err; + } + + if (!bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequencies defined"); + ret = -EINVAL; + goto out_err; + } + + for (i = 0; i < ARRAY_SIZE(link_freq_menu_items); i++) { + for (j = 0; j < bus_cfg.nr_of_link_frequencies; j++) { + if (link_freq_menu_items[i] == + bus_cfg.link_frequencies[j]) + break; + } + + if (j == bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequency %lld supported", + link_freq_menu_items[i]); + ret = -EINVAL; + goto out_err; + } + } + +out_err: + v4l2_fwnode_endpoint_free(&bus_cfg); + + return ret; +} + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) static int hm11b1_remove(struct i2c_client *client) #else @@ -1130,6 +1201,13 @@ struct hm11b1 *hm11b1; int ret = 0; + /* Check HW config */ + ret = hm11b1_check_hwcfg(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to check hwcfg: %d", ret); + return ret; + } + hm11b1 = devm_kzalloc(&client->dev, sizeof(*hm11b1), GFP_KERNEL); if (!hm11b1) return -ENOMEM; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/hm2170.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/hm2170.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/hm2170.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/hm2170.c 2024-04-11 10:53:09.000000000 +0800 @@ -13,7 +13,8 @@ #include #include #include -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) #include #endif @@ -614,7 +615,8 @@ struct v4l2_ctrl *vblank; struct v4l2_ctrl *hblank; struct v4l2_ctrl *exposure; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) struct vsc_mipi_config conf; struct vsc_camera_status status; struct v4l2_ctrl *privacy_status; @@ -790,7 +792,8 @@ ret = hm2170_test_pattern(hm2170, ctrl->val); break; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) case V4L2_CID_PRIVACY: dev_dbg(&client->dev, "set privacy to %d", ctrl->val); break; @@ -822,7 +825,8 @@ int ret = 0; ctrl_hdlr = &hm2170->ctrl_handler; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ret = v4l2_ctrl_handler_init(ctrl_hdlr, 9); #else ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); @@ -860,7 +864,8 @@ h_blank); if (hm2170->hblank) hm2170->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) hm2170->privacy_status = v4l2_ctrl_new_std(ctrl_hdlr, &hm2170_ctrl_ops, V4L2_CID_PRIVACY, 0, 1, 1, !(hm2170->status.status)); @@ -899,7 +904,8 @@ fmt->field = V4L2_FIELD_NONE; } -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) static void hm2170_vsc_privacy_callback(void *handle, enum vsc_privacy_status status) { @@ -978,7 +984,8 @@ return ret; } -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) static int hm2170_power_off(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); @@ -1065,7 +1072,11 @@ mutex_lock(&hm2170->mutex); hm2170_update_pad_format(mode, &fmt->format); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; +#endif } else { hm2170->cur_mode = mode; __v4l2_ctrl_s_ctrl(hm2170->link_freq, mode->link_freq_index); @@ -1097,8 +1108,13 @@ mutex_lock(&hm2170->mutex); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&hm2170->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, fmt->pad); +#endif else hm2170_update_pad_format(hm2170->cur_mode, &fmt->format); @@ -1145,7 +1161,11 @@ mutex_lock(&hm2170->mutex); hm2170_update_pad_format(&supported_modes[hm2170->rev][0], +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + v4l2_subdev_state_get_format(fh->state, 0)); +#endif mutex_unlock(&hm2170->mutex); return 0; @@ -1200,6 +1220,70 @@ return 0; } +static int hm2170_check_hwcfg(struct device *dev) +{ + struct v4l2_fwnode_endpoint bus_cfg = { + .bus_type = V4L2_MBUS_CSI2_DPHY + }; + struct fwnode_handle *ep; + struct fwnode_handle *fwnode = dev_fwnode(dev); + unsigned int i, j; + int ret; + u32 ext_clk; + + if (!fwnode) + return -ENXIO; + + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (!ep) + return -EPROBE_DEFER; + + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &ext_clk); + if (ret) { + dev_err(dev, "can't get clock frequency"); + return ret; + } + + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) + return ret; + + if (bus_cfg.bus.mipi_csi2.num_data_lanes != HM2170_DATA_LANES) { + dev_err(dev, "number of CSI2 data lanes %d is not supported", + bus_cfg.bus.mipi_csi2.num_data_lanes); + ret = -EINVAL; + goto out_err; + } + + if (!bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequencies defined"); + ret = -EINVAL; + goto out_err; + } + + for (i = 0; i < ARRAY_SIZE(link_freq_menu_items); i++) { + for (j = 0; j < bus_cfg.nr_of_link_frequencies; j++) { + if (link_freq_menu_items[i] == + bus_cfg.link_frequencies[j]) + break; + } + + if (j == bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequency %lld supported", + link_freq_menu_items[i]); + ret = -EINVAL; + goto out_err; + } + } + +out_err: + v4l2_fwnode_endpoint_free(&bus_cfg); + + return ret; +} + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) static int hm2170_remove(struct i2c_client *client) #else @@ -1225,6 +1309,13 @@ struct hm2170 *hm2170; int ret = 0; + /* Check HW config */ + ret = hm2170_check_hwcfg(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to check hwcfg: %d", ret); + return ret; + } + hm2170 = devm_kzalloc(&client->dev, sizeof(*hm2170), GFP_KERNEL); if (!hm2170) { ret = -ENOMEM; @@ -1232,7 +1323,8 @@ } v4l2_i2c_subdev_init(&hm2170->sd, client, &hm2170_subdev_ops); -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) hm2170->conf.lane_num = HM2170_DATA_LANES; /* frequency unit 100k */ hm2170->conf.freq = HM2170_LINK_FREQ_384MHZ / 100000; @@ -1297,7 +1389,8 @@ mutex_destroy(&hm2170->mutex); probe_error_ret: -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) hm2170_power_off(&client->dev); #endif @@ -1306,7 +1399,8 @@ static const struct dev_pm_ops hm2170_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(hm2170_suspend, hm2170_resume) -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) SET_RUNTIME_PM_OPS(hm2170_power_off, hm2170_power_on, NULL) #endif }; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/hm2172.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/hm2172.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/hm2172.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/hm2172.c 2024-04-11 10:53:09.000000000 +0800 @@ -15,7 +15,8 @@ #include #include #include -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) #include static const struct acpi_device_id cvfd_ids[] = { @@ -926,7 +927,8 @@ struct gpio_desc *reset; struct gpio_desc *handshake; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) struct vsc_mipi_config conf; struct vsc_camera_status status; struct v4l2_ctrl *privacy_status; @@ -940,7 +942,8 @@ /* Streaming on/off */ bool streaming; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) bool use_intel_vsc; #endif }; @@ -1106,7 +1109,8 @@ ret = hm2172_test_pattern(hm2172, ctrl->val); break; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) case V4L2_CID_PRIVACY: dev_dbg(&client->dev, "set privacy to %d", ctrl->val); break; @@ -1138,7 +1142,8 @@ int ret = 0; ctrl_hdlr = &hm2172->ctrl_handler; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ret = v4l2_ctrl_handler_init(ctrl_hdlr, 9); #else ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); @@ -1178,7 +1183,8 @@ if (hm2172->hblank) hm2172->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) hm2172->privacy_status = v4l2_ctrl_new_std(ctrl_hdlr, &hm2172_ctrl_ops, V4L2_CID_PRIVACY, 0, 1, 1, !(hm2172->status.status)); @@ -1217,7 +1223,8 @@ fmt->field = V4L2_FIELD_NONE; } -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) static void hm2172_vsc_privacy_callback(void *handle, enum vsc_privacy_status status) { @@ -1302,7 +1309,8 @@ struct hm2172 *hm2172 = to_hm2172(sd); int ret = 0; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) if (hm2172->use_intel_vsc) { ret = vsc_release_camera_sensor(&hm2172->status); if (ret && ret != -EAGAIN) @@ -1328,7 +1336,8 @@ struct hm2172 *hm2172 = to_hm2172(sd); int ret; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) if (hm2172->use_intel_vsc) { hm2172->conf.lane_num = HM2172_DATA_LANES; /* frequency unit 100k */ @@ -1383,7 +1392,8 @@ struct hm2172 *hm2172 = to_hm2172(sd); int ret = 0; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) acpi_handle handle = ACPI_HANDLE(dev); struct acpi_handle_list dep_devices; acpi_status status; @@ -1494,7 +1504,11 @@ mutex_lock(&hm2172->mutex); hm2172_update_pad_format(mode, &fmt->format); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; +#endif } else { hm2172->cur_mode = mode; __v4l2_ctrl_s_ctrl(hm2172->link_freq, mode->link_freq_index); @@ -1526,8 +1540,13 @@ mutex_lock(&hm2172->mutex); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&hm2172->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, fmt->pad); +#endif else hm2172_update_pad_format(hm2172->cur_mode, &fmt->format); @@ -1572,7 +1591,11 @@ mutex_lock(&hm2172->mutex); hm2172_update_pad_format(&supported_modes[0], +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + v4l2_subdev_state_get_format(fh->state, 0)); +#endif mutex_unlock(&hm2172->mutex); return 0; @@ -1625,6 +1648,70 @@ return 0; } +static int hm2172_check_hwcfg(struct device *dev) +{ + struct v4l2_fwnode_endpoint bus_cfg = { + .bus_type = V4L2_MBUS_CSI2_DPHY + }; + struct fwnode_handle *ep; + struct fwnode_handle *fwnode = dev_fwnode(dev); + unsigned int i, j; + int ret; + u32 ext_clk; + + if (!fwnode) + return -ENXIO; + + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (!ep) + return -EPROBE_DEFER; + + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &ext_clk); + if (ret) { + dev_err(dev, "can't get clock frequency"); + return ret; + } + + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) + return ret; + + if (bus_cfg.bus.mipi_csi2.num_data_lanes != HM2172_DATA_LANES) { + dev_err(dev, "number of CSI2 data lanes %d is not supported", + bus_cfg.bus.mipi_csi2.num_data_lanes); + ret = -EINVAL; + goto out_err; + } + + if (!bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequencies defined"); + ret = -EINVAL; + goto out_err; + } + + for (i = 0; i < ARRAY_SIZE(link_freq_menu_items); i++) { + for (j = 0; j < bus_cfg.nr_of_link_frequencies; j++) { + if (link_freq_menu_items[i] == + bus_cfg.link_frequencies[j]) + break; + } + + if (j == bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequency %lld supported", + link_freq_menu_items[i]); + ret = -EINVAL; + goto out_err; + } + } + +out_err: + v4l2_fwnode_endpoint_free(&bus_cfg); + + return ret; +} + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) static int hm2172_remove(struct i2c_client *client) #else @@ -1650,6 +1737,13 @@ struct hm2172 *hm217; int ret; + /* Check HW config */ + ret = hm2172_check_hwcfg(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to check hwcfg: %d", ret); + return ret; + } + hm217 = devm_kzalloc(&client->dev, sizeof(*hm217), GFP_KERNEL); if (!hm217) return -ENOMEM; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov01a10.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov01a10.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov01a10.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov01a10.c 2024-04-11 10:53:09.000000000 +0800 @@ -11,7 +11,8 @@ #include #include #include -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) #include #endif @@ -295,7 +296,8 @@ /* To serialize asynchronus callbacks */ struct mutex mutex; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) struct vsc_mipi_config conf; struct vsc_camera_status status; struct v4l2_ctrl *privacy_status; @@ -467,7 +469,8 @@ ret = ov01a10_test_pattern(ov01a10, ctrl->val); break; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) case V4L2_CID_PRIVACY: dev_dbg(&client->dev, "set privacy to %d", ctrl->val); break; @@ -497,7 +500,8 @@ int ret = 0; ctrl_hdlr = &ov01a10->ctrl_handler; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ret = v4l2_ctrl_handler_init(ctrl_hdlr, 9); #else ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); @@ -535,7 +539,8 @@ if (ov01a10->hblank) ov01a10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ov01a10->privacy_status = v4l2_ctrl_new_std(ctrl_hdlr, &ov01a10_ctrl_ops, V4L2_CID_PRIVACY, 0, 1, 1, @@ -656,7 +661,8 @@ return ret; } -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) static void ov01a10_vsc_privacy_callback(void *handle, enum vsc_privacy_status status) { @@ -752,8 +758,10 @@ if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; #endif } else { ov01a10->cur_mode = mode; @@ -791,9 +799,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) fmt->format = *v4l2_subdev_get_try_format(&ov01a10->sd, cfg, fmt->pad); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&ov01a10->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, fmt->pad); #endif else ov01a10_update_pad_format(ov01a10->cur_mode, &fmt->format); @@ -849,9 +860,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) ov01a10_update_pad_format(&supported_modes[0], v4l2_subdev_get_try_format(sd, fh->pad, 0)); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) ov01a10_update_pad_format(&supported_modes[0], v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + ov01a10_update_pad_format(&supported_modes[0], + v4l2_subdev_state_get_format(fh->state, 0)); #endif mutex_unlock(&ov01a10->mutex); @@ -901,6 +915,70 @@ return 0; } +static int ov01a10_check_hwcfg(struct device *dev) +{ + struct v4l2_fwnode_endpoint bus_cfg = { + .bus_type = V4L2_MBUS_CSI2_DPHY + }; + struct fwnode_handle *ep; + struct fwnode_handle *fwnode = dev_fwnode(dev); + unsigned int i, j; + int ret; + u32 ext_clk; + + if (!fwnode) + return -ENXIO; + + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (!ep) + return -EPROBE_DEFER; + + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &ext_clk); + if (ret) { + dev_err(dev, "can't get clock frequency"); + return ret; + } + + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) + return ret; + + if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV01A10_DATA_LANES) { + dev_err(dev, "number of CSI2 data lanes %d is not supported", + bus_cfg.bus.mipi_csi2.num_data_lanes); + ret = -EINVAL; + goto out_err; + } + + if (!bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequencies defined"); + ret = -EINVAL; + goto out_err; + } + + for (i = 0; i < ARRAY_SIZE(link_freq_menu_items); i++) { + for (j = 0; j < bus_cfg.nr_of_link_frequencies; j++) { + if (link_freq_menu_items[i] == + bus_cfg.link_frequencies[j]) + break; + } + + if (j == bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequency %lld supported", + link_freq_menu_items[i]); + ret = -EINVAL; + goto out_err; + } + } + +out_err: + v4l2_fwnode_endpoint_free(&bus_cfg); + + return ret; +} + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) static int ov01a10_remove(struct i2c_client *client) #else @@ -926,12 +1004,20 @@ struct ov01a10 *ov01a10; int ret = 0; + /* Check HW config */ + ret = ov01a10_check_hwcfg(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to check hwcfg: %d", ret); + return ret; + } + ov01a10 = devm_kzalloc(&client->dev, sizeof(*ov01a10), GFP_KERNEL); if (!ov01a10) return -ENOMEM; v4l2_i2c_subdev_init(&ov01a10->sd, client, &ov01a10_subdev_ops); -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ov01a10->conf.lane_num = OV01A10_DATA_LANES; /* frequency unit 100k */ ov01a10->conf.freq = OV01A10_LINK_FREQ_400MHZ / 100000; @@ -996,7 +1082,8 @@ mutex_destroy(&ov01a10->mutex); probe_error_ret: -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ov01a10_power_off(&client->dev); #endif @@ -1005,7 +1092,8 @@ static const struct dev_pm_ops ov01a10_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(ov01a10_suspend, ov01a10_resume) -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) SET_RUNTIME_PM_OPS(ov01a10_power_off, ov01a10_power_on, NULL) #endif }; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov01a1s.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov01a1s.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov01a1s.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov01a1s.c 2024-04-11 10:53:09.000000000 +0800 @@ -17,7 +17,8 @@ #elif IS_ENABLED(CONFIG_POWER_CTRL_LOGIC) #include "power_ctrl_logic.h" #endif -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) #include #endif @@ -302,7 +303,8 @@ struct v4l2_ctrl *vblank; struct v4l2_ctrl *hblank; struct v4l2_ctrl *exposure; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) struct v4l2_ctrl *privacy_status; /* VSC settings */ @@ -335,7 +337,8 @@ #if IS_ENABLED(CONFIG_INTEL_SKL_INT3472) || IS_ENABLED(CONFIG_POWER_CTRL_LOGIC) OV01A1S_USE_INT3472 = 1, #endif -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) OV01A1S_USE_INTEL_VSC = 2, #endif } power_type; @@ -505,7 +508,8 @@ ret = ov01a1s_test_pattern(ov01a1s, ctrl->val); break; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) case V4L2_CID_PRIVACY: dev_dbg(&client->dev, "set privacy to %d", ctrl->val); break; @@ -535,7 +539,8 @@ int ret = 0; ctrl_hdlr = &ov01a1s->ctrl_handler; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ret = v4l2_ctrl_handler_init(ctrl_hdlr, 9); #else ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); @@ -572,7 +577,8 @@ 1, h_blank); if (ov01a1s->hblank) ov01a1s->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ov01a1s->privacy_status = v4l2_ctrl_new_std(ctrl_hdlr, &ov01a1s_ctrl_ops, V4L2_CID_PRIVACY, @@ -613,7 +619,8 @@ fmt->field = V4L2_FIELD_NONE; } -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) static void ov01a1s_vsc_privacy_callback(void *handle, enum vsc_privacy_status status) { @@ -722,7 +729,8 @@ if (ov01a1s->power_type == OV01A1S_USE_INT3472) ret = power_ctrl_logic_set_power(0); #endif -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) if (ov01a1s->power_type == OV01A1S_USE_INTEL_VSC) { ret = vsc_release_camera_sensor(&ov01a1s->status); if (ret && ret != -EAGAIN) @@ -756,7 +764,8 @@ if (ov01a1s->power_type == OV01A1S_USE_INT3472) ret = power_ctrl_logic_set_power(1); #endif -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) if (ov01a1s->power_type == OV01A1S_USE_INTEL_VSC) { ret = vsc_acquire_camera_sensor(&ov01a1s->conf, ov01a1s_vsc_privacy_callback, @@ -832,8 +841,10 @@ if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; #endif } else { ov01a1s->cur_mode = mode; @@ -871,9 +882,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) fmt->format = *v4l2_subdev_get_try_format(&ov01a1s->sd, cfg, fmt->pad); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&ov01a1s->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, fmt->pad); #endif else ov01a1s_update_pad_format(ov01a1s->cur_mode, &fmt->format); @@ -929,9 +943,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) ov01a1s_update_pad_format(&supported_modes[0], v4l2_subdev_get_try_format(sd, fh->pad, 0)); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) ov01a1s_update_pad_format(&supported_modes[0], v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + ov01a1s_update_pad_format(&supported_modes[0], + v4l2_subdev_state_get_format(fh->state, 0)); #endif mutex_unlock(&ov01a1s->mutex); @@ -981,6 +998,70 @@ return 0; } +static int ov01a1s_check_hwcfg(struct device *dev) +{ + struct v4l2_fwnode_endpoint bus_cfg = { + .bus_type = V4L2_MBUS_CSI2_DPHY + }; + struct fwnode_handle *ep; + struct fwnode_handle *fwnode = dev_fwnode(dev); + unsigned int i, j; + int ret; + u32 ext_clk; + + if (!fwnode) + return -ENXIO; + + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (!ep) + return -EPROBE_DEFER; + + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &ext_clk); + if (ret) { + dev_err(dev, "can't get clock frequency"); + return ret; + } + + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) + return ret; + + if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV01A1S_DATA_LANES) { + dev_err(dev, "number of CSI2 data lanes %d is not supported", + bus_cfg.bus.mipi_csi2.num_data_lanes); + ret = -EINVAL; + goto out_err; + } + + if (!bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequencies defined"); + ret = -EINVAL; + goto out_err; + } + + for (i = 0; i < ARRAY_SIZE(link_freq_menu_items); i++) { + for (j = 0; j < bus_cfg.nr_of_link_frequencies; j++) { + if (link_freq_menu_items[i] == + bus_cfg.link_frequencies[j]) + break; + } + + if (j == bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequency %lld supported", + link_freq_menu_items[i]); + ret = -EINVAL; + goto out_err; + } + } + +out_err: + v4l2_fwnode_endpoint_free(&bus_cfg); + + return ret; +} + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) static int ov01a1s_remove(struct i2c_client *client) #else @@ -1044,7 +1125,8 @@ { int ret = 0; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ov01a1s->conf.lane_num = OV01A1S_DATA_LANES; /* frequency unit 100k */ ov01a1s->conf.freq = OV01A1S_LINK_FREQ_400MHZ / 100000; @@ -1078,6 +1160,13 @@ struct ov01a1s *ov01a1s; int ret = 0; + /* Check HW config */ + ret = ov01a1s_check_hwcfg(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to check hwcfg: %d", ret); + return ret; + } + ov01a1s = devm_kzalloc(&client->dev, sizeof(*ov01a1s), GFP_KERNEL); if (!ov01a1s) return -ENOMEM; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov02c10.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov02c10.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov02c10.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov02c10.c 2024-04-11 10:53:09.000000000 +0800 @@ -11,7 +11,8 @@ #include #include #include -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) #include #endif @@ -680,7 +681,8 @@ struct v4l2_ctrl *vblank; struct v4l2_ctrl *hblank; struct v4l2_ctrl *exposure; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) struct vsc_mipi_config conf; struct vsc_camera_status status; struct v4l2_ctrl *privacy_status; @@ -834,7 +836,8 @@ ret = ov02c10_test_pattern(ov02c10, ctrl->val); break; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) case V4L2_CID_PRIVACY: dev_dbg(&client->dev, "set privacy to %d", ctrl->val); break; @@ -864,7 +867,8 @@ int ret = 0; ctrl_hdlr = &ov02c10->ctrl_handler; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ret = v4l2_ctrl_handler_init(ctrl_hdlr, 9); #else ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); @@ -901,7 +905,8 @@ 1, h_blank); if (ov02c10->hblank) ov02c10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ov02c10->privacy_status = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops, V4L2_CID_PRIVACY, 0, 1, 1, @@ -1067,7 +1072,8 @@ return ret; } -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) static void ov02c10_vsc_privacy_callback(void *handle, enum vsc_privacy_status status) { @@ -1176,8 +1182,10 @@ if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; #endif } else { ov02c10->cur_mode = mode; @@ -1215,9 +1223,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) fmt->format = *v4l2_subdev_get_try_format(&ov02c10->sd, cfg, fmt->pad); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&ov02c10->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, fmt->pad); #endif else ov02c10_update_pad_format(ov02c10->cur_mode, &fmt->format); @@ -1273,9 +1284,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) ov02c10_update_pad_format(&supported_modes[0], v4l2_subdev_get_try_format(sd, fh->pad, 0)); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) ov02c10_update_pad_format(&supported_modes[0], v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + ov02c10_update_pad_format(&supported_modes[0], + v4l2_subdev_state_get_format(fh->state, 0)); #endif mutex_unlock(&ov02c10->mutex); @@ -1366,6 +1380,63 @@ return 0; } +static int ov02c10_check_hwcfg(struct device *dev) +{ + struct v4l2_fwnode_endpoint bus_cfg = { + .bus_type = V4L2_MBUS_CSI2_DPHY + }; + struct fwnode_handle *ep; + struct fwnode_handle *fwnode = dev_fwnode(dev); + unsigned int i, j; + int ret; + u32 ext_clk; + + if (!fwnode) + return -ENXIO; + + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (!ep) + return -EPROBE_DEFER; + + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &ext_clk); + if (ret) { + dev_err(dev, "can't get clock frequency"); + return ret; + } + + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) + return ret; + + if (!bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequencies defined"); + ret = -EINVAL; + goto out_err; + } + + for (i = 0; i < ARRAY_SIZE(link_freq_menu_items); i++) { + for (j = 0; j < bus_cfg.nr_of_link_frequencies; j++) { + if (link_freq_menu_items[i] == + bus_cfg.link_frequencies[j]) + break; + } + + if (j == bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequency %lld supported", + link_freq_menu_items[i]); + ret = -EINVAL; + goto out_err; + } + } + +out_err: + v4l2_fwnode_endpoint_free(&bus_cfg); + + return ret; +} + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) static int ov02c10_remove(struct i2c_client *client) #else @@ -1420,6 +1491,13 @@ struct ov02c10 *ov02c10; int ret = 0; + /* Check HW config */ + ret = ov02c10_check_hwcfg(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to check hwcfg: %d", ret); + return ret; + } + ov02c10 = devm_kzalloc(&client->dev, sizeof(*ov02c10), GFP_KERNEL); if (!ov02c10) return -ENOMEM; @@ -1427,7 +1505,8 @@ v4l2_i2c_subdev_init(&ov02c10->sd, client, &ov02c10_subdev_ops); ov02c10_read_module_name(ov02c10); -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ov02c10->mipi_lanes = OV02C10_DATA_LANES; ov02c10->conf.lane_num = ov02c10->mipi_lanes; /* frequency unit 100k */ @@ -1496,7 +1575,8 @@ mutex_destroy(&ov02c10->mutex); probe_error_ret: -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ov02c10_power_off(&client->dev); #endif @@ -1505,7 +1585,8 @@ static const struct dev_pm_ops ov02c10_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(ov02c10_suspend, ov02c10_resume) -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) SET_RUNTIME_PM_OPS(ov02c10_power_off, ov02c10_power_on, NULL) #endif }; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov02e10.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov02e10.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov02e10.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov02e10.c 2024-04-11 10:53:09.000000000 +0800 @@ -3,16 +3,18 @@ #include #include +#include #include +#include #include #include #include #include #include #include -#include -#include -#if IS_ENABLED(CONFIG_INTEL_VSC) +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) #include static const struct acpi_device_id cvfd_ids[] = { @@ -287,7 +289,8 @@ struct gpio_desc *reset; struct gpio_desc *handshake; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) struct vsc_mipi_config conf; struct vsc_camera_status status; struct v4l2_ctrl *privacy_status; @@ -301,7 +304,8 @@ /* Streaming on/off */ bool streaming; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) bool use_intel_vsc; #endif }; @@ -482,7 +486,8 @@ ret = ov02e10_test_pattern(ov02e10, ctrl->val); break; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) case V4L2_CID_PRIVACY: dev_dbg(&client->dev, "set privacy to %d", ctrl->val); break; @@ -515,7 +520,8 @@ int ret; ctrl_hdlr = &ov02e10->ctrl_handler; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ret = v4l2_ctrl_handler_init(ctrl_hdlr, 9); #else ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); @@ -555,7 +561,8 @@ if (ov02e10->hblank) ov02e10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) ov02e10->privacy_status = v4l2_ctrl_new_std(ctrl_hdlr, &ov02e10_ctrl_ops, V4L2_CID_PRIVACY, 0, 1, 1, !(ov02e10->status.status)); @@ -595,7 +602,8 @@ fmt->field = V4L2_FIELD_NONE; } -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) static void ov02e10_vsc_privacy_callback(void *handle, enum vsc_privacy_status status) { @@ -688,7 +696,8 @@ struct ov02e10 *ov02e10 = to_ov02e10(sd); int ret; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) acpi_handle handle = ACPI_HANDLE(dev); struct acpi_handle_list dep_devices; acpi_status status; @@ -754,7 +763,8 @@ struct ov02e10 *ov02e10 = to_ov02e10(sd); int ret = 0; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) if (ov02e10->use_intel_vsc) { ret = vsc_release_camera_sensor(&ov02e10->status); if (ret && ret != -EAGAIN) @@ -780,7 +790,8 @@ struct ov02e10 *ov02e10 = to_ov02e10(sd); int ret; -#if IS_ENABLED(CONFIG_INTEL_VSC) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && \ + IS_ENABLED(CONFIG_INTEL_VSC) if (ov02e10->use_intel_vsc) { ov02e10->conf.lane_num = OV02E10_DATA_LANES; /* frequency unit 100k */ @@ -877,8 +888,13 @@ mutex_lock(&ov02e10->mutex); ov02e10_update_pad_format(mode, &fmt->format); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = + fmt->format; +#endif } else { ov02e10->cur_mode = mode; __v4l2_ctrl_s_ctrl(ov02e10->link_freq, mode->link_freq_index); @@ -910,8 +926,13 @@ mutex_lock(&ov02e10->mutex); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&ov02e10->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, fmt->pad); +#endif else ov02e10_update_pad_format(ov02e10->cur_mode, &fmt->format); @@ -956,7 +977,11 @@ mutex_lock(&ov02e10->mutex); ov02e10_update_pad_format(&supported_modes[0], +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + v4l2_subdev_state_get_format(fh->state, 0)); +#endif mutex_unlock(&ov02e10->mutex); return 0; @@ -1010,6 +1035,70 @@ return 0; } +static int ov02e10_check_hwcfg(struct device *dev) +{ + struct v4l2_fwnode_endpoint bus_cfg = { + .bus_type = V4L2_MBUS_CSI2_DPHY + }; + struct fwnode_handle *ep; + struct fwnode_handle *fwnode = dev_fwnode(dev); + unsigned int i, j; + int ret; + u32 ext_clk; + + if (!fwnode) + return -ENXIO; + + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (!ep) + return -EPROBE_DEFER; + + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &ext_clk); + if (ret) { + dev_err(dev, "can't get clock frequency"); + return ret; + } + + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) + return ret; + + if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV02E10_DATA_LANES) { + dev_err(dev, "number of CSI2 data lanes %d is not supported", + bus_cfg.bus.mipi_csi2.num_data_lanes); + ret = -EINVAL; + goto out_err; + } + + if (!bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequencies defined"); + ret = -EINVAL; + goto out_err; + } + + for (i = 0; i < ARRAY_SIZE(link_freq_menu_items); i++) { + for (j = 0; j < bus_cfg.nr_of_link_frequencies; j++) { + if (link_freq_menu_items[i] == + bus_cfg.link_frequencies[j]) + break; + } + + if (j == bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequency %lld supported", + link_freq_menu_items[i]); + ret = -EINVAL; + goto out_err; + } + } + +out_err: + v4l2_fwnode_endpoint_free(&bus_cfg); + + return ret; +} + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) static int ov02e10_remove(struct i2c_client *client) #else @@ -1030,13 +1119,18 @@ #endif } -// After this module is loaded, probe function is called -// if this device HID is enumerated by ACPI table. static int ov02e10_probe(struct i2c_client *client) { struct ov02e10 *ov02e; int ret; + /* Check HW config */ + ret = ov02e10_check_hwcfg(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to check hwcfg: %d", ret); + return ret; + } + ov02e = devm_kzalloc(&client->dev, sizeof(*ov02e), GFP_KERNEL); if (!ov02e) return -ENOMEM; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov08a10.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov08a10.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov08a10.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov08a10.c 2024-04-11 10:53:09.000000000 +0800 @@ -858,8 +858,13 @@ mutex_lock(&ov08a10->mutex); ov08a10_update_pad_format(mode, &fmt->format); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, + fmt->pad) = fmt->format; +#endif } else { ov08a10->cur_mode = mode; __v4l2_ctrl_s_ctrl(ov08a10->link_freq, mode->link_freq_index); @@ -892,9 +897,15 @@ mutex_lock(&ov08a10->mutex); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&ov08a10->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, + fmt->pad); +#endif else ov08a10_update_pad_format(ov08a10->cur_mode, &fmt->format); @@ -939,7 +950,11 @@ mutex_lock(&ov08a10->mutex); ov08a10_update_pad_format(&supported_modes[0], +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + v4l2_subdev_state_get_format(fh->state, 0)); +#endif mutex_unlock(&ov08a10->mutex); return 0; @@ -994,6 +1009,70 @@ return 0; } +static int ov08a10_check_hwcfg(struct device *dev) +{ + struct v4l2_fwnode_endpoint bus_cfg = { + .bus_type = V4L2_MBUS_CSI2_DPHY + }; + struct fwnode_handle *ep; + struct fwnode_handle *fwnode = dev_fwnode(dev); + unsigned int i, j; + int ret; + u32 ext_clk; + + if (!fwnode) + return -ENXIO; + + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); + if (!ep) + return -EPROBE_DEFER; + + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &ext_clk); + if (ret) { + dev_err(dev, "can't get clock frequency"); + return ret; + } + + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) + return ret; + + if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV08A10_DATA_LANES) { + dev_err(dev, "number of CSI2 data lanes %d is not supported", + bus_cfg.bus.mipi_csi2.num_data_lanes); + ret = -EINVAL; + goto out_err; + } + + if (!bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequencies defined"); + ret = -EINVAL; + goto out_err; + } + + for (i = 0; i < ARRAY_SIZE(link_freq_menu_items); i++) { + for (j = 0; j < bus_cfg.nr_of_link_frequencies; j++) { + if (link_freq_menu_items[i] == + bus_cfg.link_frequencies[j]) + break; + } + + if (j == bus_cfg.nr_of_link_frequencies) { + dev_err(dev, "no link frequency %lld supported", + link_freq_menu_items[i]); + ret = -EINVAL; + goto out_err; + } + } + +out_err: + v4l2_fwnode_endpoint_free(&bus_cfg); + + return ret; +} + #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) static int ov08a10_remove(struct i2c_client *client) #else @@ -1045,6 +1124,13 @@ struct ov08a10 *ov08a10; int ret = 0; + /* Check HW config */ + ret = ov08a10_check_hwcfg(&client->dev); + if (ret) { + dev_err(&client->dev, "failed to check hwcfg: %d", ret); + return ret; + } + ov08a10 = devm_kzalloc(&client->dev, sizeof(*ov08a10), GFP_KERNEL); if (!ov08a10) return -ENOMEM; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov13858_intel.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov13858_intel.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov13858_intel.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov13858_intel.c 2024-04-11 10:53:09.000000000 +0800 @@ -1380,9 +1380,15 @@ static int ov13858_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) { struct ov13858 *ov13858 = to_ov13858(sd); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) struct v4l2_mbus_framefmt *try_fmt = v4l2_subdev_get_try_format(sd, fh->pad, 0); +#else + struct v4l2_mbus_framefmt *try_fmt = v4l2_subdev_state_get_format( + fh->pad, + 0); +#endif mutex_lock(&ov13858->mutex); @@ -1563,7 +1569,11 @@ struct v4l2_subdev *sd = &ov13858->sd; if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); +#else + framefmt = v4l2_subdev_state_get_format(cfg, fmt->pad); +#endif fmt->format = *framefmt; } else { ov13858_update_pad_format(ov13858->cur_mode, fmt); @@ -1612,7 +1622,11 @@ fmt->format.width, fmt->format.height); ov13858_update_pad_format(mode, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) framefmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); +#else + framefmt = v4l2_subdev_state_get_format(cfg, fmt->pad); +#endif *framefmt = fmt->format; } else { ov13858->cur_mode = mode; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov2740.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov2740.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov2740.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov2740.c 2024-04-11 10:53:09.000000000 +0800 @@ -1115,8 +1115,10 @@ if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; #endif } else { ov2740->cur_mode = mode; @@ -1157,10 +1159,14 @@ fmt->format = *v4l2_subdev_get_try_format(&ov2740->sd, cfg, fmt->pad); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&ov2740->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, + fmt->pad); #endif else ov2740_update_pad_format(ov2740->cur_mode, &fmt->format); @@ -1230,9 +1236,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) ov2740_update_pad_format(ov2740->cur_mode, v4l2_subdev_get_try_format(sd, fh->pad, 0)); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) ov2740_update_pad_format(ov2740->cur_mode, v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + ov2740_update_pad_format(ov2740->cur_mode, + v4l2_subdev_state_get_format(fh->state, 0)); #endif mutex_unlock(&ov2740->mutex); diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov8856.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov8856.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/i2c/ov8856.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/i2c/ov8856.c 2024-04-11 10:53:09.000000000 +0800 @@ -1043,8 +1043,10 @@ if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) *v4l2_subdev_get_try_format(sd, sd_state, fmt->pad) = fmt->format; +#else + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format; #endif } else { ov8856->cur_mode = mode; @@ -1085,9 +1087,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) fmt->format = *v4l2_subdev_get_try_format(&ov8856->sd, cfg, fmt->pad); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) fmt->format = *v4l2_subdev_get_try_format(&ov8856->sd, sd_state, fmt->pad); +#else + fmt->format = *v4l2_subdev_state_get_format( + sd_state, fmt->pad); #endif else ov8856_update_pad_format(ov8856->cur_mode, &fmt->format); @@ -1144,9 +1149,12 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) ov8856_update_pad_format(&supported_modes[0], v4l2_subdev_get_try_format(sd, fh->pad, 0)); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) ov8856_update_pad_format(&supported_modes[0], v4l2_subdev_get_try_format(sd, fh->state, 0)); +#else + ov8856_update_pad_format(&supported_modes[0], + v4l2_subdev_state_get_format(fh->state, 0)); #endif mutex_unlock(&ov8856->mutex); diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/cio2-bridge.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/cio2-bridge.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/cio2-bridge.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/cio2-bridge.c 2024-04-11 10:53:09.000000000 +0800 @@ -55,6 +55,8 @@ CIO2_SENSOR_CONFIG("OVTI13B1", 1, 560000000), /* Omnivision ov08a10 */ CIO2_SENSOR_CONFIG("OVTI08A1", 0, 0), + /* Omnivision ov08x40 */ + CIO2_SENSOR_CONFIG("OVTI08F4", 1, 400000000), }; static const struct cio2_property_names prop_names = { diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2018 - 2021 Intel Corporation +// Copyright (C) 2018 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6ep-fw-resources.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6ep-fw-resources.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6ep-fw-resources.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6ep-fw-resources.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6ep-platform-resources.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6ep-platform-resources.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6ep-platform-resources.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6ep-platform-resources.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2020 Intel Corporation */ +/* Copyright (C) 2020 - 2024 Intel Corporation */ #ifndef IPU6EP_PLATFORM_RESOURCES_H #define IPU6EP_PLATFORM_RESOURCES_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-fw-resources.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-fw-resources.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-fw-resources.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-fw-resources.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2015 - 2021 Intel Corporation +// Copyright (C) 2015 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2020 - 2022 Intel Corporation +// Copyright (C) 2020 - 2024 Intel Corporation #include #include @@ -450,14 +450,18 @@ struct ipu_isys_pipeline *ip = container_of(media_entity_pipeline(&sd->entity), struct ipu_isys_pipeline, pipe); - struct ipu_isys_csi2_config *cfg = - v4l2_get_subdev_hostdata(media_entity_to_v4l2_subdev - (ip->external->entity)); + struct v4l2_subdev *esd = + media_entity_to_v4l2_subdev(ip->external->entity); + struct ipu_isys_csi2_config *cfg; unsigned int port, port_max; int ret = 0; u32 mask = 0; unsigned int i; + if (!esd) + return -EPIPE; + + cfg = v4l2_get_subdev_hostdata(esd); port = cfg->port; dev_dbg(&isys->adev->dev, "for port %u with %u lanes\n", port, nlanes); diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2020 Intel Corporation */ +/* Copyright (C) 2020 - 2024 Intel Corporation */ #ifndef IPU6_ISYS_CSI2_H #define IPU6_ISYS_CSI2_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-dwc-phy.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-dwc-phy.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-dwc-phy.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-dwc-phy.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2013 - 2020 Intel Corporation + * Copyright (C) 2013 - 2024 Intel Corporation */ #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-dwc-phy.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-dwc-phy.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-dwc-phy.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-dwc-phy.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (C) 2013 - 2022 Intel Corporation + * Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU6_ISYS_DWC_PHY_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-gpc.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-gpc.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-gpc.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-gpc.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020 - 2024 Intel Corporation #ifdef CONFIG_DEBUG_FS #include @@ -78,8 +78,8 @@ isys_gpcs->gpc[i].route = 0; isys_gpcs->gpc[i].source = 0; } - pm_runtime_mark_last_busy(&isys->adev->dev); - pm_runtime_put_autosuspend(&isys->adev->dev); + + pm_runtime_put(&isys->adev->dev); } else { /* * Set gpc reg and start all gpc here. diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-phy.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-phy.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-phy.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-phy.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2013 - 2020 Intel Corporation + * Copyright (C) 2013 - 2024 Intel Corporation */ #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-phy.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-phy.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-isys-phy.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-isys-phy.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (C) 2013 - 2020 Intel Corporation + * Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU6_ISYS_PHY_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-l-scheduler.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-l-scheduler.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-l-scheduler.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-l-scheduler.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020 - 2024 Intel Corporation #include "ipu-psys.h" #include "ipu6-ppg.h" diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-platform-resources.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-platform-resources.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-platform-resources.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-platform-resources.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2018 - 2020 Intel Corporation */ +/* Copyright (C) 2018 - 2024 Intel Corporation */ #ifndef IPU6_PLATFORM_RESOURCES_H #define IPU6_PLATFORM_RESOURCES_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-ppg.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-ppg.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-ppg.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-ppg.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020 - 2024 Intel Corporation #include #include @@ -511,7 +511,7 @@ continue; } - ret = pm_runtime_put_autosuspend(&psys->adev->dev); + ret = pm_runtime_put(&psys->adev->dev); if (ret < 0) { dev_err(&psys->adev->dev, "failed to power gating off\n"); diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-ppg.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-ppg.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-ppg.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-ppg.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020 - 2024 Intel Corporation */ #ifndef IPU6_PPG_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-psys.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-psys.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-psys.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-psys.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2022 Intel Corporation +// Copyright (C) 2020 - 2024 Intel Corporation #include #include @@ -848,7 +848,7 @@ mutex_init(&sched->bs_mutex); INIT_LIST_HEAD(&sched->buf_sets); INIT_LIST_HEAD(&sched->ppgs); - pm_runtime_dont_use_autosuspend(&psys->adev->dev); + /* allocate and map memory for buf_sets */ for (i = 0; i < IPU_PSYS_BUF_SET_POOL_SIZE; i++) { kbuf_set = kzalloc(sizeof(*kbuf_set), GFP_KERNEL); diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-psys-gpc.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-psys-gpc.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6-psys-gpc.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6-psys-gpc.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020 - 2024 Intel Corporation #ifdef CONFIG_DEBUG_FS #include @@ -81,8 +81,8 @@ psys_gpcs->gpc[idx].route = 0; psys_gpcs->gpc[idx].source = 0; } - pm_runtime_mark_last_busy(&psys->adev->dev); - pm_runtime_put_autosuspend(&psys->adev->dev); + + pm_runtime_put(&psys->adev->dev); } else { /* Set gpc reg and start all gpc here. * RST free running local timer. diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6se-fw-resources.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6se-fw-resources.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6se-fw-resources.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6se-fw-resources.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2015 - 2019 Intel Corporation +// Copyright (C) 2015 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6se-platform-resources.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6se-platform-resources.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu6se-platform-resources.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu6se-platform-resources.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2018 - 2020 Intel Corporation */ +/* Copyright (C) 2018 - 2024 Intel Corporation */ #ifndef IPU6SE_PLATFORM_RESOURCES_H #define IPU6SE_PLATFORM_RESOURCES_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-fw-resources.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-fw-resources.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-fw-resources.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-fw-resources.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2015 - 2019 Intel Corporation +// Copyright (C) 2015 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-buttress-regs.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-buttress-regs.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-buttress-regs.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-buttress-regs.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2020 Intel Corporation */ +/* Copyright (C) 2020 - 2024 Intel Corporation */ #ifndef IPU_PLATFORM_BUTTRESS_REGS_H #define IPU_PLATFORM_BUTTRESS_REGS_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2020 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_PLATFORM_H #define IPU_PLATFORM_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-isys-csi2-reg.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-isys-csi2-reg.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-isys-csi2-reg.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-isys-csi2-reg.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2020 Intel Corporation */ +/* Copyright (C) 2020 - 2024 Intel Corporation */ #ifndef IPU_PLATFORM_ISYS_CSI2_REG_H #define IPU_PLATFORM_ISYS_CSI2_REG_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-isys.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-isys.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-isys.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-isys.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2022 Intel Corporation */ +/* Copyright (C) 2020 - 2024 Intel Corporation */ #ifndef IPU_PLATFORM_ISYS_H #define IPU_PLATFORM_ISYS_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-psys.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-psys.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-psys.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-psys.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2020 Intel Corporation */ +/* Copyright (C) 2020 - 2024 Intel Corporation */ #ifndef IPU_PLATFORM_PSYS_H #define IPU_PLATFORM_PSYS_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-regs.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-regs.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-regs.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-regs.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2018 - 2020 Intel Corporation */ +/* Copyright (C) 2018 - 2024 Intel Corporation */ #ifndef IPU_PLATFORM_REGS_H #define IPU_PLATFORM_REGS_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-resources.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-resources.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-platform-resources.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-platform-resources.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2018 - 2020 Intel Corporation */ +/* Copyright (C) 2018 - 2024 Intel Corporation */ #ifndef IPU_PLATFORM_RESOURCES_COMMON_H #define IPU_PLATFORM_RESOURCES_COMMON_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-resources.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-resources.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/ipu-resources.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/ipu-resources.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2015 - 2022 Intel Corporation +// Copyright (C) 2015 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/Kconfig ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/Kconfig --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu6/Kconfig 1970-01-01 08:00:00.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu6/Kconfig 2024-04-11 10:53:09.000000000 +0800 @@ -0,0 +1,49 @@ +config VIDEO_INTEL_IPU6 + tristate "Intel IPU driver" + depends on ACPI + depends on MEDIA_SUPPORT + depends on MEDIA_PCI_SUPPORT + depends on X86_64 + select IOMMU_API + select IOMMU_IOVA + select X86_DEV_DMA_OPS if X86 + select VIDEOBUF2_DMA_CONTIG + select V4L2_FWNODE + select PHYS_ADDR_T_64BIT + select COMMON_CLK + help + This is the Intel imaging processing unit, found in Intel SoCs and + used for capturing images and video from a camera sensor. + + To compile this driver, say Y here! It contains 3 modules - + intel_ipu6, intel_ipu6_isys and intel_ipu6_psys. + +config VIDEO_INTEL_IPU_TPG + bool "Compile for TPG driver" + depends on VIDEO_INTEL_IPU6 + help + If selected, TPG device nodes would be created. + + Recommended for driver developers only. + + If you want to the TPG devices exposed to user as media entity, + you must select this option, otherwise no. + +config IPU_ISYS_BRIDGE + bool "Intel IPU driver bridge" + default y + depends on VIDEO_INTEL_IPU6 + help + If selected, IPU isys bridge would be enabled. + + If you want supported sensors can be registered as IPU subdevices, + select y here. + +config IPU_SINGLE_BE_SOC_DEVICE + bool "Intel IPU uses only one BE SOC device" + default n + depends on VIDEO_INTEL_IPU6 + help + If selected, IPU exports only one BE SOC device. + + If you don't need multiple camera streaming, select y here. diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-bus.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-bus.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-bus.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-bus.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2022 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-bus.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-bus.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-bus.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-bus.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2022 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_BUS_H #define IPU_BUS_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-buttress.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-buttress.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-buttress.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-buttress.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2022 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-buttress.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-buttress.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-buttress.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-buttress.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2022 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_BUTTRESS_H #define IPU_BUTTRESS_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2022 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include @@ -14,6 +14,7 @@ #include #include #include +#include #include "ipu.h" #include "ipu-buttress.h" @@ -26,7 +27,10 @@ #include "ipu-platform-regs.h" #include "ipu-platform-isys-csi2-reg.h" #include "ipu-trace.h" -#if defined(CONFIG_IPU_ISYS_BRIDGE) +#if IS_ENABLED(CONFIG_IPU_BRIDGE) && \ +LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) +#include +#elif defined(CONFIG_IPU_ISYS_BRIDGE) #include "cio2-bridge.h" #endif @@ -34,7 +38,9 @@ enum ipu_version ipu_ver; EXPORT_SYMBOL(ipu_ver); -#if defined(CONFIG_IPU_ISYS_BRIDGE) +#if IS_ENABLED(CONFIG_IPU_BRIDGE) && \ +LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) || \ +defined(CONFIG_IPU_ISYS_BRIDGE) static int ipu_isys_check_fwnode_graph(struct fwnode_handle *fwnode) { struct fwnode_handle *endpoint; @@ -63,8 +69,10 @@ struct ipu_bus_device *isys; struct ipu_isys_pdata *pdata; int ret; -#if defined(CONFIG_IPU_ISYS_BRIDGE) - struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev); +#if IS_ENABLED(CONFIG_IPU_BRIDGE) && \ +LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) || \ +defined(CONFIG_IPU_ISYS_BRIDGE) +struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev); ret = ipu_isys_check_fwnode_graph(fwnode); if (ret) { @@ -74,12 +82,21 @@ return ERR_PTR(-EINVAL); } +#if defined(CONFIG_IPU_ISYS_BRIDGE) ret = cio2_bridge_init(pdev); if (ret) { dev_err_probe(&pdev->dev, ret, "ipu_isys_bridge_init() failed\n"); return ERR_PTR(ret); } +#else + ret = ipu_bridge_init(&pdev->dev, ipu_bridge_parse_ssdb); + if (ret) { + dev_err_probe(&pdev->dev, ret, + "IPU bridge init failed\n"); + return ERR_PTR(ret); + } +#endif } #endif @@ -928,6 +945,10 @@ module_init(ipu_init); module_exit(ipu_exit); +#if IS_ENABLED(CONFIG_IPU_BRIDGE) && \ +LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) +MODULE_IMPORT_NS(INTEL_IPU_BRIDGE); +#endif MODULE_AUTHOR("Sakari Ailus "); MODULE_AUTHOR("Jouni Högander "); MODULE_AUTHOR("Antti Laakso "); diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-cpd.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-cpd.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-cpd.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-cpd.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2015 - 2020 Intel Corporation +// Copyright (C) 2015 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-cpd.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-cpd.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-cpd.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-cpd.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2015 - 2020 Intel Corporation */ +/* Copyright (C) 2015 - 2024 Intel Corporation */ #ifndef IPU_CPD_H #define IPU_CPD_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-dma.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-dma.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-dma.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-dma.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2021 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include @@ -335,6 +335,7 @@ struct vm_info *info; size_t count = PAGE_ALIGN(size) >> PAGE_SHIFT; size_t i; + int ret; info = get_vm_info(mmu, iova); if (!info) @@ -349,9 +350,12 @@ if (size > info->size) return -EFAULT; - for (i = 0; i < count; i++) - vm_insert_page(vma, vma->vm_start + (i << PAGE_SHIFT), - info->pages[i]); + for (i = 0; i < count; i++) { + ret = vm_insert_page(vma, vma->vm_start + (i << PAGE_SHIFT), + info->pages[i]); + if (ret < 0) + return ret; + } return 0; } @@ -439,7 +443,7 @@ struct scatterlist *sg; struct iova *iova; size_t npages = 0; - u32 iova_addr; + unsigned long iova_addr; int i, count; dev_dbg(dev, "pci_dma_map_sg trying to map %d ents\n", nents); @@ -467,7 +471,7 @@ int rval; dev_dbg(dev, "mapping entry %d: iova 0x%lx phy %pad size %d\n", - i, (unsigned long)iova_addr << PAGE_SHIFT, + i, iova_addr << PAGE_SHIFT, &sg_dma_address(sg), sg_dma_len(sg)); dev_dbg(dev, "mapping entry %d: sg->length = %d\n", i, diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-dma.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-dma.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-dma.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-dma.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2020 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_DMA_H #define IPU_DMA_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-com.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-com.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-com.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-com.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2022 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-com.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-com.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-com.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-com.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2020 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_FW_COM_H #define IPU_FW_COM_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-isys.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-isys.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-isys.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-isys.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2021 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-isys.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-isys.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-isys.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-isys.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2023 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_FW_ISYS_H #define IPU_FW_ISYS_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-psys.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-psys.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-psys.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-psys.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2016 - 2020 Intel Corporation +// Copyright (C) 2016 - 2024 Intel Corporation #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-psys.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-psys.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-fw-psys.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-fw-psys.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2016 - 2020 Intel Corporation */ +/* Copyright (C) 2016 - 2024 Intel Corporation */ #ifndef IPU_FW_PSYS_H #define IPU_FW_PSYS_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2020 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_H #define IPU_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2023 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include @@ -976,14 +976,14 @@ #else isys->media_dev.link_notify = v4l2_pipeline_link_notify; #endif - strlcpy(isys->media_dev.model, + strscpy(isys->media_dev.model, IPU_MEDIA_DEV_MODEL_NAME, sizeof(isys->media_dev.model)); #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) isys->media_dev.driver_version = LINUX_VERSION_CODE; #endif snprintf(isys->media_dev.bus_info, sizeof(isys->media_dev.bus_info), "pci:%s", dev_name(isys->adev->dev.parent->parent)); - strlcpy(isys->v4l2_dev.name, isys->media_dev.model, + strscpy(isys->v4l2_dev.name, isys->media_dev.model, sizeof(isys->v4l2_dev.name)); #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) @@ -1572,6 +1572,7 @@ isys_iwake_watermark_cleanup(isys); isys_unregister_devices(isys); out_remove_pkg_dir_shared_buffer: + cpu_latency_qos_remove_request(&isys->pm_qos); if (!isp->secure_mode) ipu_cpd_free_pkg_dir(adev, isys->pkg_dir, isys->pkg_dir_dma_addr, diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-csi2-be.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-csi2-be.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-csi2-be.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-csi2-be.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2014 - 2020 Intel Corporation +// Copyright (C) 2014 - 2024 Intel Corporation #include #include @@ -303,13 +303,13 @@ rval = ipu_isys_subdev_init(&csi2_be->asd, &csi2_be_sd_ops, 0, NR_OF_CSI2_BE_PADS, NR_OF_CSI2_BE_SOURCE_PADS, - NR_OF_CSI2_BE_SINK_PADS, 0); + NR_OF_CSI2_BE_SINK_PADS, 0, + CSI2_BE_PAD_SOURCE, + CSI2_BE_PAD_SINK); if (rval) goto fail; - csi2_be->asd.pad[CSI2_BE_PAD_SINK].flags = MEDIA_PAD_FL_SINK - | MEDIA_PAD_FL_MUST_CONNECT; - csi2_be->asd.pad[CSI2_BE_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; + csi2_be->asd.pad[CSI2_BE_PAD_SINK].flags |= MEDIA_PAD_FL_MUST_CONNECT; csi2_be->asd.valid_tgts[CSI2_BE_PAD_SOURCE].crop = true; csi2_be->asd.set_ffmt = csi2_be_set_ffmt; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-csi2-be.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-csi2-be.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-csi2-be.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-csi2-be.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2014 - 2022 Intel Corporation */ +/* Copyright (C) 2014 - 2024 Intel Corporation */ #ifndef IPU_ISYS_CSI2_BE_H #define IPU_ISYS_CSI2_BE_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-csi2-be-soc.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-csi2-be-soc.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-csi2-be-soc.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-csi2-be-soc.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2014 - 2022 Intel Corporation +// Copyright (C) 2014 - 2024 Intel Corporation #include #include @@ -294,13 +294,12 @@ &csi2_be_soc_sd_ops, 0, NR_OF_CSI2_BE_SOC_PADS, NR_OF_CSI2_BE_SOC_SOURCE_PADS, - NR_OF_CSI2_BE_SOC_SINK_PADS, 0); + NR_OF_CSI2_BE_SOC_SINK_PADS, 0, + CSI2_BE_SOC_PAD_SOURCE, + CSI2_BE_SOC_PAD_SINK); if (rval) goto fail; - csi2_be_soc->asd.pad[CSI2_BE_SOC_PAD_SINK].flags = MEDIA_PAD_FL_SINK; - csi2_be_soc->asd.pad[CSI2_BE_SOC_PAD_SOURCE].flags = - MEDIA_PAD_FL_SOURCE; csi2_be_soc->asd.valid_tgts[CSI2_BE_SOC_PAD_SOURCE].crop = true; for (i = 0; i < NR_OF_CSI2_BE_SOC_PADS; i++) diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-csi2.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-csi2.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-csi2.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-csi2.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2023 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include @@ -529,14 +529,13 @@ rval = ipu_isys_subdev_init(&csi2->asd, &csi2_sd_ops, 0, NR_OF_CSI2_PADS, NR_OF_CSI2_SOURCE_PADS, - NR_OF_CSI2_SINK_PADS, - 0); + NR_OF_CSI2_SINK_PADS, 0, + CSI2_PAD_SOURCE, + CSI2_PAD_SINK); if (rval) goto fail; - csi2->asd.pad[CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK - | MEDIA_PAD_FL_MUST_CONNECT; - csi2->asd.pad[CSI2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; + csi2->asd.pad[CSI2_PAD_SINK].flags |= MEDIA_PAD_FL_MUST_CONNECT; src = index; csi2->asd.source = IPU_FW_ISYS_STREAM_SRC_CSI2_PORT0 + src; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-csi2.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-csi2.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-csi2.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-csi2.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2022 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_ISYS_CSI2_H #define IPU_ISYS_CSI2_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2020 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_ISYS_H #define IPU_ISYS_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-media.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-media.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-media.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-media.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2016 - 2020 Intel Corporation */ +/* Copyright (C) 2016 - 2024 Intel Corporation */ #ifndef IPU_ISYS_MEDIA_H #define IPU_ISYS_MEDIA_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-queue.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-queue.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-queue.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-queue.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2020 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include @@ -863,7 +863,7 @@ struct ipu_isys_pipeline *ip = to_ipu_isys_pipeline(media_entity_pipeline(&av->vdev.entity)); struct ipu_isys_video *pipe_av = - container_of(ip, struct ipu_isys_video, ip); + container_of(ip, struct ipu_isys_video, ip); if (pipe_av != av) { mutex_unlock(&av->mutex); @@ -1052,7 +1052,6 @@ first = false; continue; } - if (info->error_info.error == IPU_FW_ISYS_ERROR_HW_REPORTED_STR2MMIO) { /* @@ -1074,7 +1073,6 @@ spin_unlock_irqrestore(&aq->lock, flags); ipu_isys_buf_calc_sequence_time(ib, info); - /* * For interlaced buffers, the notification to user space * is postponed to capture_done event since the field diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-queue.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-queue.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-queue.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-queue.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2020 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_ISYS_QUEUE_H #define IPU_ISYS_QUEUE_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-subdev.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-subdev.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-subdev.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-subdev.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2023 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include @@ -162,8 +162,10 @@ return v4l2_subdev_get_try_format(cfg, pad); #elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) return v4l2_subdev_get_try_format(sd, cfg, pad); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) return v4l2_subdev_get_try_format(sd, state, pad); +#else + return v4l2_subdev_state_get_format(state, pad); #endif } @@ -199,11 +201,16 @@ return v4l2_subdev_get_try_crop(sd, cfg, pad); case V4L2_SEL_TGT_COMPOSE: return v4l2_subdev_get_try_compose(sd, cfg, pad); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) case V4L2_SEL_TGT_CROP: return v4l2_subdev_get_try_crop(sd, state, pad); case V4L2_SEL_TGT_COMPOSE: return v4l2_subdev_get_try_compose(sd, state, pad); +#else + case V4L2_SEL_TGT_CROP: + return v4l2_subdev_state_get_crop(state, pad); + case V4L2_SEL_TGT_COMPOSE: + return v4l2_subdev_state_get_compose(state, pad); #endif } } @@ -755,13 +762,20 @@ v4l2_subdev_get_try_crop(sd, fh->pad, i); struct v4l2_rect *try_compose = v4l2_subdev_get_try_compose(sd, fh->pad, i); -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0) struct v4l2_mbus_framefmt *try_fmt = v4l2_subdev_get_try_format(sd, fh->state, i); struct v4l2_rect *try_crop = v4l2_subdev_get_try_crop(sd, fh->state, i); struct v4l2_rect *try_compose = v4l2_subdev_get_try_compose(sd, fh->state, i); +#else + struct v4l2_mbus_framefmt *try_fmt = + v4l2_subdev_state_get_format(fh->state, i); + struct v4l2_rect *try_crop = + v4l2_subdev_state_get_crop(fh->state, i); + struct v4l2_rect *try_compose = + v4l2_subdev_state_get_compose(fh->state, i); #endif *try_fmt = asd->ffmt[i]; @@ -785,8 +799,11 @@ unsigned int num_pads, unsigned int num_source, unsigned int num_sink, - unsigned int sd_flags) + unsigned int sd_flags, + int src_pad_idx, + int sink_pad_idx) { + int i; int rval = -EINVAL; mutex_init(&asd->mutex); @@ -803,6 +820,19 @@ asd->pad = devm_kcalloc(&asd->isys->adev->dev, num_pads, sizeof(*asd->pad), GFP_KERNEL); + /* + * Out of range IDX means that this particular type of pad + * does not exist. + */ + if (src_pad_idx != ISYS_SUBDEV_NO_PAD) { + for (i = 0; i < num_source; i++) + asd->pad[src_pad_idx + i].flags = MEDIA_PAD_FL_SOURCE; + } + if (sink_pad_idx != ISYS_SUBDEV_NO_PAD) { + for (i = 0; i < num_sink; i++) + asd->pad[sink_pad_idx + i].flags = MEDIA_PAD_FL_SINK; + } + asd->ffmt = devm_kcalloc(&asd->isys->adev->dev, num_pads, sizeof(*asd->ffmt), GFP_KERNEL); diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-subdev.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-subdev.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-subdev.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-subdev.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2020 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_ISYS_SUBDEV_H #define IPU_ISYS_SUBDEV_H @@ -204,12 +204,17 @@ int ipu_isys_subdev_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh); int ipu_isys_subdev_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh); + +#define ISYS_SUBDEV_NO_PAD (-1) + int ipu_isys_subdev_init(struct ipu_isys_subdev *asd, struct v4l2_subdev_ops *ops, unsigned int nr_ctrls, unsigned int num_pads, unsigned int num_source, unsigned int num_sink, - unsigned int sd_flags); + unsigned int sd_flags, + int src_pad_idx, + int sink_pad_idx); void ipu_isys_subdev_cleanup(struct ipu_isys_subdev *asd); #endif /* IPU_ISYS_SUBDEV_H */ diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-tpg.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-tpg.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-tpg.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-tpg.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2020 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include @@ -278,11 +278,14 @@ tpg->asd.ctrl_init = ipu_isys_tpg_init_controls; tpg->asd.isys = isys; + /* Note: there is no FL_SINK pad here */ rval = ipu_isys_subdev_init(&tpg->asd, &tpg_sd_ops, 5, NR_OF_TPG_PADS, NR_OF_TPG_SOURCE_PADS, NR_OF_TPG_SINK_PADS, - V4L2_SUBDEV_FL_HAS_EVENTS); + V4L2_SUBDEV_FL_HAS_EVENTS, + TPG_PAD_SOURCE, + ISYS_SUBDEV_NO_PAD); if (rval) return rval; @@ -291,7 +294,6 @@ #else tpg->asd.sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; #endif - tpg->asd.pad[TPG_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; tpg->asd.source = IPU_FW_ISYS_STREAM_SRC_MIPIGEN_PORT0 + index; tpg->asd.supported_codes = tpg_supported_codes; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-tpg.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-tpg.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-tpg.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-tpg.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2023 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_ISYS_TPG_H #define IPU_ISYS_TPG_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-video.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-video.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-video.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-video.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2023 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include @@ -359,8 +359,8 @@ { struct ipu_isys_video *av = video_drvdata(file); - strlcpy(cap->driver, IPU_ISYS_NAME, sizeof(cap->driver)); - strlcpy(cap->card, av->isys->media_dev.model, sizeof(cap->card)); + strscpy(cap->driver, IPU_ISYS_NAME, sizeof(cap->driver)); + strscpy(cap->card, av->isys->media_dev.model, sizeof(cap->card)); snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", av->isys->media_dev.bus_info); return 0; @@ -492,6 +492,7 @@ /* overwrite bpl/height with compression alignment */ if (av->compression) { u32 planar_tile_status_size, tile_status_size; + u64 planar_bytes; mpix->plane_fmt[0].bytesperline = ALIGN(mpix->plane_fmt[0].bytesperline, @@ -504,10 +505,11 @@ IPU_ISYS_COMPRESSION_PAGE_ALIGN); /* ISYS compression only for RAW and single plannar */ + planar_bytes = + mul_u32_u32(mpix->plane_fmt[0].bytesperline, mpix->height); planar_tile_status_size = - DIV_ROUND_UP_ULL((mpix->plane_fmt[0].bytesperline * - mpix->height / - IPU_ISYS_COMPRESSION_TILE_SIZE_BYTES) * + DIV_ROUND_UP_ULL((planar_bytes / + IPU_ISYS_COMPRESSION_TILE_SIZE_BYTES) * IPU_ISYS_COMPRESSION_TILE_STATUS_BITS, BITS_PER_BYTE); tile_status_size = ALIGN(planar_tile_status_size, @@ -586,7 +588,7 @@ { if (input->index > 0) return -EINVAL; - strlcpy(input->name, "camera", sizeof(input->name)); + strscpy(input->name, "camera", sizeof(input->name)); input->type = V4L2_INPUT_TYPE_CAMERA; return 0; @@ -1106,6 +1108,7 @@ struct media_pad *source_pad = media_pad_remote_pad_first(&av->pad); #endif struct ipu_fw_isys_cropping_abi *crop; + enum ipu_fw_isys_send_type send_type; int rval, rvalout, tout; rval = get_external_facing_format(ip, &source_fmt); @@ -1256,8 +1259,22 @@ reinit_completion(&ip->stream_start_completion); - rval = ipu_fw_isys_simple_cmd(av->isys, ip->stream_handle, - IPU_FW_ISYS_SEND_TYPE_STREAM_START); + if (bl) { + send_type = IPU_FW_ISYS_SEND_TYPE_STREAM_START_AND_CAPTURE; + ipu_fw_isys_dump_frame_buff_set(dev, buf, + stream_cfg->nof_output_pins); + rval = ipu_fw_isys_complex_cmd(av->isys, + ip->stream_handle, + buf, to_dma_addr(msg), + sizeof(*buf), + send_type); + } else { + send_type = IPU_FW_ISYS_SEND_TYPE_STREAM_START; + rval = ipu_fw_isys_simple_cmd(av->isys, + ip->stream_handle, + send_type); + } + if (rval < 0) { dev_err(dev, "can't start streaming (%d)\n", rval); goto out_stream_close; @@ -1276,18 +1293,7 @@ goto out_stream_close; } - if (!bl) - return 0; - - ipu_fw_isys_dump_frame_buff_set(dev, buf, stream_cfg->nof_output_pins); - rval = ipu_fw_isys_complex_cmd(av->isys, ip->stream_handle, buf, - to_dma_addr(msg), sizeof(*buf), - IPU_FW_ISYS_SEND_TYPE_STREAM_CAPTURE); - if (rval < 0) { - dev_err(dev, "can't queue buffers (%d)\n", rval); - goto out_stream_close; - } - + dev_dbg(dev, "start stream: complete\n"); return 0; out_stream_close: @@ -1932,6 +1938,7 @@ av->pfmt = av->try_fmt_vid_mplane(av, &av->mpix); + av->initialized = true; mutex_unlock(&av->mutex); return rval; @@ -1953,9 +1960,13 @@ void ipu_isys_video_cleanup(struct ipu_isys_video *av) { + if (!av->initialized) + return; + kfree(av->watermark); video_unregister_device(&av->vdev); media_entity_cleanup(&av->vdev.entity); mutex_destroy(&av->mutex); ipu_isys_queue_cleanup(&av->aq); + av->initialized = false; } diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-video.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-video.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-isys-video.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-isys-video.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2022 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_ISYS_VIDEO_H #define IPU_ISYS_VIDEO_H @@ -125,6 +125,7 @@ unsigned int streaming; bool packed; bool compression; + bool initialized; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *compression_ctrl; unsigned int ts_offsets[VIDEO_MAX_PLANES]; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-mmu.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-mmu.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-mmu.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-mmu.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2021 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include @@ -243,75 +243,99 @@ return pt; } +static size_t l2_unmap(struct ipu_mmu_info *mmu_info, unsigned long iova, + phys_addr_t dummy, size_t size); static int l2_map(struct ipu_mmu_info *mmu_info, unsigned long iova, phys_addr_t paddr, size_t size) { - u32 l1_idx = iova >> ISP_L1PT_SHIFT; + struct device *dev = mmu_info->dev; + u32 l1_idx; u32 l1_entry; u32 *l2_pt, *l2_virt; - u32 iova_start = iova; unsigned int l2_idx; unsigned long flags; dma_addr_t dma; - - dev_dbg(mmu_info->dev, - "mapping l2 page table for l1 index %u (iova %8.8x)\n", - l1_idx, (u32)iova); + unsigned int l2_entries; + size_t mapped_size = 0; + int err = 0; spin_lock_irqsave(&mmu_info->lock, flags); - l1_entry = mmu_info->l1_pt[l1_idx]; - if (l1_entry == mmu_info->dummy_l2_pteval) { - l2_virt = mmu_info->l2_pts[l1_idx]; - if (likely(!l2_virt)) { - l2_virt = alloc_l2_pt(mmu_info); - if (!l2_virt) { + + paddr = ALIGN(paddr, ISP_PAGE_SIZE); + for (l1_idx = iova >> ISP_L1PT_SHIFT; + size > 0 && l1_idx < ISP_L1PT_PTES; l1_idx++) { + dev_dbg(dev, + "mapping l2 page table for l1 index %u (iova %8.8x)\n", + l1_idx, (u32)iova); + + l1_entry = mmu_info->l1_pt[l1_idx]; + if (l1_entry == mmu_info->dummy_l2_pteval) { + l2_virt = mmu_info->l2_pts[l1_idx]; + if (likely(!l2_virt)) { + l2_virt = alloc_l2_pt(mmu_info); + if (!l2_virt) { + spin_unlock_irqrestore(&mmu_info->lock, + flags); + err = -ENOMEM; + goto error; + } + } + + dma = map_single(mmu_info, l2_virt); + if (!dma) { + dev_err(dev, "Failed to map l2pt page\n"); + free_page((unsigned long)l2_virt); + spin_unlock_irqrestore(&mmu_info->lock, flags); - return -ENOMEM; + err = -EINVAL; + goto error; } - } - dma = map_single(mmu_info, l2_virt); - if (!dma) { - dev_err(mmu_info->dev, "Failed to map l2pt page\n"); - free_page((unsigned long)l2_virt); - spin_unlock_irqrestore(&mmu_info->lock, flags); - return -EINVAL; - } + l1_entry = dma >> ISP_PADDR_SHIFT; - l1_entry = dma >> ISP_PADDR_SHIFT; + dev_dbg(dev, "page for l1_idx %u %p allocated\n", + l1_idx, l2_virt); + mmu_info->l1_pt[l1_idx] = l1_entry; + mmu_info->l2_pts[l1_idx] = l2_virt; - dev_dbg(mmu_info->dev, "page for l1_idx %u %p allocated\n", - l1_idx, l2_virt); - mmu_info->l1_pt[l1_idx] = l1_entry; - mmu_info->l2_pts[l1_idx] = l2_virt; - clflush_cache_range(&mmu_info->l1_pt[l1_idx], - sizeof(mmu_info->l1_pt[l1_idx])); - } + clflush_cache_range(&mmu_info->l1_pt[l1_idx], + sizeof(mmu_info->l1_pt[l1_idx])); + } - l2_pt = mmu_info->l2_pts[l1_idx]; + l2_pt = mmu_info->l2_pts[l1_idx]; + l2_entries = 0; - dev_dbg(mmu_info->dev, "l2_pt at %p with dma 0x%x\n", l2_pt, l1_entry); + for (l2_idx = (iova & ISP_L2PT_MASK) >> ISP_L2PT_SHIFT; + size > 0 && l2_idx < ISP_L2PT_PTES; l2_idx++) { + l2_pt[l2_idx] = paddr >> ISP_PADDR_SHIFT; - paddr = ALIGN(paddr, ISP_PAGE_SIZE); + dev_dbg(dev, "l2 index %u mapped as 0x%8.8x\n", l2_idx, + l2_pt[l2_idx]); - l2_idx = (iova_start & ISP_L2PT_MASK) >> ISP_L2PT_SHIFT; + iova += ISP_PAGE_SIZE; + paddr += ISP_PAGE_SIZE; + mapped_size += ISP_PAGE_SIZE; + size -= ISP_PAGE_SIZE; - dev_dbg(mmu_info->dev, "l2_idx %u, phys 0x%8.8x\n", l2_idx, - l2_pt[l2_idx]); - if (l2_pt[l2_idx] != mmu_info->dummy_page_pteval) { - spin_unlock_irqrestore(&mmu_info->lock, flags); - return -EINVAL; - } + l2_entries++; + } - l2_pt[l2_idx] = paddr >> ISP_PADDR_SHIFT; + if (l2_entries) + clflush_cache_range(&l2_pt[l2_idx - l2_entries], + sizeof(l2_pt[0]) * l2_entries); + } - clflush_cache_range(&l2_pt[l2_idx], sizeof(l2_pt[l2_idx])); spin_unlock_irqrestore(&mmu_info->lock, flags); - dev_dbg(mmu_info->dev, "l2 index %u mapped as 0x%8.8x\n", l2_idx, - l2_pt[l2_idx]); - return 0; + +error: + /* unroll mapping in case something went wrong */ + if (size && mapped_size) + l2_unmap(mmu_info, iova - mapped_size, paddr - mapped_size, + mapped_size); + + return err; } static int __ipu_mmu_map(struct ipu_mmu_info *mmu_info, unsigned long iova, @@ -330,37 +354,49 @@ static size_t l2_unmap(struct ipu_mmu_info *mmu_info, unsigned long iova, phys_addr_t dummy, size_t size) { - u32 l1_idx = iova >> ISP_L1PT_SHIFT; + u32 l1_idx; u32 *l2_pt; - u32 iova_start = iova; unsigned int l2_idx; + unsigned int l2_entries; size_t unmapped = 0; unsigned long flags; - dev_dbg(mmu_info->dev, "unmapping l2 page table for l1 index %u (iova 0x%8.8lx)\n", - l1_idx, iova); - spin_lock_irqsave(&mmu_info->lock, flags); - if (mmu_info->l1_pt[l1_idx] == mmu_info->dummy_l2_pteval) { - spin_unlock_irqrestore(&mmu_info->lock, flags); - dev_err(mmu_info->dev, - "unmap iova 0x%8.8lx l1 idx %u which was not mapped\n", - iova, l1_idx); - return 0; - } + for (l1_idx = iova >> ISP_L1PT_SHIFT; + size > 0 && l1_idx < ISP_L1PT_PTES; l1_idx++) { + dev_dbg(mmu_info->dev, + "unmapping l2 page table for l1 index %u (iova 0x%8.8lx)\n", + l1_idx, iova); - for (l2_idx = (iova_start & ISP_L2PT_MASK) >> ISP_L2PT_SHIFT; - (iova_start & ISP_L1PT_MASK) + (l2_idx << ISP_PAGE_SHIFT) - < iova_start + size && l2_idx < ISP_L2PT_PTES; l2_idx++) { + if (mmu_info->l1_pt[l1_idx] == mmu_info->dummy_l2_pteval) { + spin_unlock_irqrestore(&mmu_info->lock, flags); + dev_err(mmu_info->dev, + "unmap iova 0x%8.8lx l1 idx %u which was not mapped\n", + iova, l1_idx); + return unmapped << ISP_PAGE_SHIFT; + } l2_pt = mmu_info->l2_pts[l1_idx]; - dev_dbg(mmu_info->dev, - "unmap l2 index %u with pteval 0x%10.10llx\n", - l2_idx, TBL_PHYS_ADDR(l2_pt[l2_idx])); - l2_pt[l2_idx] = mmu_info->dummy_page_pteval; - clflush_cache_range(&l2_pt[l2_idx], sizeof(l2_pt[l2_idx])); - unmapped++; + l2_entries = 0; + for (l2_idx = (iova & ISP_L2PT_MASK) >> ISP_L2PT_SHIFT; + size > 0 && l2_idx < ISP_L2PT_PTES; l2_idx++) { + dev_dbg(mmu_info->dev, + "unmap l2 index %u with pteval 0x%10.10llx\n", + l2_idx, TBL_PHYS_ADDR(l2_pt[l2_idx])); + l2_pt[l2_idx] = mmu_info->dummy_page_pteval; + + iova += ISP_PAGE_SIZE; + size -= ISP_PAGE_SIZE; + l2_entries++; + } + + if (l2_entries) { + clflush_cache_range(&l2_pt[l2_idx - l2_entries], + sizeof(l2_pt[0]) * l2_entries); + unmapped += l2_entries; + } } + spin_unlock_irqrestore(&mmu_info->lock, flags); return unmapped << ISP_PAGE_SHIFT; @@ -622,50 +658,14 @@ return phy_addr; } -/* - * The following four functions are implemented based on iommu.c - * drivers/iommu/iommu.c:iommu_pgsize(). - */ -static size_t ipu_mmu_pgsize(unsigned long pgsize_bitmap, - unsigned long addr_merge, size_t size) -{ - unsigned int pgsize_idx; - size_t pgsize; - - /* Max page size that still fits into 'size' */ - pgsize_idx = __fls(size); - - /* need to consider alignment requirements ? */ - if (likely(addr_merge)) { - /* Max page size allowed by address */ - unsigned int align_pgsize_idx = __ffs(addr_merge); - - pgsize_idx = min(pgsize_idx, align_pgsize_idx); - } - - /* build a mask of acceptable page sizes */ - pgsize = (1UL << (pgsize_idx + 1)) - 1; - - /* throw away page sizes not supported by the hardware */ - pgsize &= pgsize_bitmap; - - /* make sure we're still sane */ - WARN_ON(!pgsize); - - /* pick the biggest page */ - pgsize_idx = __fls(pgsize); - pgsize = 1UL << pgsize_idx; - - return pgsize; -} - /* drivers/iommu/iommu.c:iommu_unmap() */ size_t ipu_mmu_unmap(struct ipu_mmu_info *mmu_info, unsigned long iova, size_t size) { - size_t unmapped_page, unmapped = 0; unsigned int min_pagesz; + dev_dbg(mmu_info->dev, "unmapping iova 0x%lx size 0x%zx\n", iova, size); + /* find out the minimum page size supported */ min_pagesz = 1 << __ffs(mmu_info->pgsize_bitmap); @@ -680,36 +680,14 @@ return -EINVAL; } - /* - * Keep iterating until we either unmap 'size' bytes (or more) - * or we hit an area that isn't mapped. - */ - while (unmapped < size) { - size_t pgsize = ipu_mmu_pgsize(mmu_info->pgsize_bitmap, - iova, size - unmapped); - - unmapped_page = __ipu_mmu_unmap(mmu_info, iova, pgsize); - if (!unmapped_page) - break; - - dev_dbg(mmu_info->dev, "unmapped: iova 0x%lx size 0x%zx\n", - iova, unmapped_page); - - iova += unmapped_page; - unmapped += unmapped_page; - } - - return unmapped; + return __ipu_mmu_unmap(mmu_info, iova, size); } /* drivers/iommu/iommu.c:iommu_map() */ int ipu_mmu_map(struct ipu_mmu_info *mmu_info, unsigned long iova, phys_addr_t paddr, size_t size) { - unsigned long orig_iova = iova; unsigned int min_pagesz; - size_t orig_size = size; - int ret = 0; if (mmu_info->pgsize_bitmap == 0UL) return -ENODEV; @@ -732,28 +710,7 @@ dev_dbg(mmu_info->dev, "map: iova 0x%lx pa %pa size 0x%zx\n", iova, &paddr, size); - while (size) { - size_t pgsize = ipu_mmu_pgsize(mmu_info->pgsize_bitmap, - iova | paddr, size); - - dev_dbg(mmu_info->dev, - "mapping: iova 0x%lx pa %pa pgsize 0x%zx\n", - iova, &paddr, pgsize); - - ret = __ipu_mmu_map(mmu_info, iova, paddr, pgsize); - if (ret) - break; - - iova += pgsize; - paddr += pgsize; - size -= pgsize; - } - - /* unroll mapping in case something went wrong */ - if (ret) - ipu_mmu_unmap(mmu_info, orig_iova, orig_size - size); - - return ret; + return __ipu_mmu_map(mmu_info, iova, paddr, size); } static void ipu_mmu_destroy(struct ipu_mmu *mmu) @@ -793,7 +750,7 @@ } free_dummy_page(mmu_info); - dma_unmap_single(mmu_info->dev, mmu_info->l1_pt_dma << ISP_PADDR_SHIFT, + dma_unmap_single(mmu_info->dev, TBL_PHYS_ADDR(mmu_info->l1_pt_dma), PAGE_SIZE, DMA_BIDIRECTIONAL); free_page((unsigned long)mmu_info->dummy_l2_pt); free_page((unsigned long)mmu_info->l1_pt); diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-mmu.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-mmu.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-mmu.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-mmu.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2021 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_MMU_H #define IPU_MMU_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-pdata.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-pdata.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-pdata.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-pdata.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2021 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_PDATA_H #define IPU_PDATA_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-psys.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-psys.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-psys.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-psys.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2022 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include @@ -47,21 +47,9 @@ MODULE_PARM_DESC(async_fw_init, "Enable asynchronous firmware initialization"); #define IPU_PSYS_NUM_DEVICES 4 -#define IPU_PSYS_AUTOSUSPEND_DELAY 2000 -#ifdef CONFIG_PM static int psys_runtime_pm_resume(struct device *dev); static int psys_runtime_pm_suspend(struct device *dev); -#else -#define pm_runtime_dont_use_autosuspend(d) -#define pm_runtime_use_autosuspend(d) -#define pm_runtime_set_autosuspend_delay(d, f) 0 -#define pm_runtime_get_sync(d) 0 -#define pm_runtime_put(d) 0 -#define pm_runtime_put_sync(d) 0 -#define pm_runtime_put_noidle(d) 0 -#define pm_runtime_put_autosuspend(d) 0 -#endif static dev_t ipu_psys_dev_t; static DECLARE_BITMAP(ipu_psys_devices, IPU_PSYS_NUM_DEVICES); @@ -1116,10 +1104,6 @@ if (!psys) return 0; - /* - * In runtime autosuspend mode, if the psys is in power on state, no - * need to resume again. - */ spin_lock_irqsave(&psys->ready_lock, flags); if (psys->ready) { spin_unlock_irqrestore(&psys->ready_lock, flags); @@ -1647,14 +1631,9 @@ } /* Add the hw stepping information to caps */ - strlcpy(psys->caps.dev_model, IPU_MEDIA_DEV_MODEL_NAME, + strscpy(psys->caps.dev_model, IPU_MEDIA_DEV_MODEL_NAME, sizeof(psys->caps.dev_model)); - pm_runtime_set_autosuspend_delay(&psys->adev->dev, - IPU_PSYS_AUTOSUSPEND_DELAY); - pm_runtime_use_autosuspend(&psys->adev->dev); - pm_runtime_mark_last_busy(&psys->adev->dev); - mutex_unlock(&ipu_psys_mutex); #ifdef CONFIG_DEBUG_FS @@ -1713,8 +1692,6 @@ psys->sched_cmd_thread = NULL; } - pm_runtime_dont_use_autosuspend(&psys->adev->dev); - mutex_lock(&ipu_psys_mutex); list_for_each_entry_safe(kpg, kpg0, &psys->pgs, list) { @@ -1769,8 +1746,7 @@ ipu_psys_handle_events(psys); } - pm_runtime_mark_last_busy(&psys->adev->dev); - pm_runtime_put_autosuspend(&psys->adev->dev); + pm_runtime_put(&psys->adev->dev); mutex_unlock(&psys->mutex); return status ? IRQ_HANDLED : IRQ_NONE; diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-psys-compat32.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-psys-compat32.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-psys-compat32.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-psys-compat32.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2013 - 2020 Intel Corporation +// Copyright (C) 2013 - 2024 Intel Corporation #include #include diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-psys.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-psys.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-psys.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-psys.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2013 - 2020 Intel Corporation */ +/* Copyright (C) 2013 - 2024 Intel Corporation */ #ifndef IPU_PSYS_H #define IPU_PSYS_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-trace.c ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-trace.c --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-trace.c 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-trace.c 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2014 - 2021 Intel Corporation +// Copyright (C) 2014 - 2024 Intel Corporation #include #include @@ -465,7 +465,8 @@ struct ipu_device *isp = file->private_data; struct device *psys_dev = isp->psys ? &isp->psys->dev : NULL; struct device *isys_dev = isp->isys ? &isp->isys->dev : NULL; - int pm_rval = -EINVAL; + int isys_pm_rval = -EINVAL; + int psys_pm_rval = -EINVAL; /* * Turn devices on outside trace->lock mutex. PM transition may @@ -478,21 +479,9 @@ if (file->f_mode & FMODE_WRITE) { if (isys_dev) - pm_rval = pm_runtime_get_sync(isys_dev); - - if (pm_rval >= 0) { - /* ISYS ok or missing */ - if (psys_dev) - pm_rval = pm_runtime_get_sync(psys_dev); - - if (pm_rval < 0) { - pm_runtime_put_noidle(psys_dev); - if (isys_dev) - pm_runtime_put(isys_dev); - } - } else { - pm_runtime_put_noidle(&isp->isys->dev); - } + isys_pm_rval = pm_runtime_resume_and_get(isys_dev); + if (isys_pm_rval >= 0 && psys_dev) + psys_pm_rval = pm_runtime_resume_and_get(psys_dev); } mutex_lock(&isp->trace->lock); @@ -500,30 +489,25 @@ vfree(isp->trace->conf_dump_buffer); isp->trace->conf_dump_buffer = NULL; - if (pm_rval >= 0) { - /* Update new cfg to HW */ - if (isys_dev) { - __ipu_trace_stop(isys_dev); - clear_trace_buffer(isp->isys->trace_cfg); - __ipu_trace_restore(isys_dev); - } - - if (psys_dev) { - __ipu_trace_stop(psys_dev); - clear_trace_buffer(isp->psys->trace_cfg); - __ipu_trace_restore(psys_dev); - } + /* Update new cfg to HW */ + if (isys_pm_rval >= 0) { + __ipu_trace_stop(isys_dev); + clear_trace_buffer(isp->isys->trace_cfg); + __ipu_trace_restore(isys_dev); } + if (psys_pm_rval >= 0) { + __ipu_trace_stop(psys_dev); + clear_trace_buffer(isp->psys->trace_cfg); + __ipu_trace_restore(psys_dev); + } mutex_unlock(&isp->trace->lock); - if (pm_rval >= 0) { - /* Again - this must be done with trace->lock not taken */ - if (psys_dev) - pm_runtime_put(psys_dev); - if (isys_dev) - pm_runtime_put(isys_dev); - } + if (psys_pm_rval >= 0) + pm_runtime_put(psys_dev); + if (isys_pm_rval >= 0) + pm_runtime_put(isys_dev); + return 0; } diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-trace.h ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-trace.h --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/ipu-trace.h 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/ipu-trace.h 2024-04-11 10:53:09.000000000 +0800 @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2014 - 2021 Intel Corporation */ +/* Copyright (C) 2014 - 2024 Intel Corporation */ #ifndef IPU_TRACE_H #define IPU_TRACE_H diff -Nru ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/Kconfig ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/Kconfig --- ipu6-drivers-0~git202311240921.07f0612e/drivers/media/pci/intel/Kconfig 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/drivers/media/pci/intel/Kconfig 1970-01-01 08:00:00.000000000 +0800 @@ -1,51 +0,0 @@ -config VIDEO_INTEL_IPU6 - tristate "Intel IPU driver" - depends on ACPI - depends on MEDIA_SUPPORT - depends on MEDIA_PCI_SUPPORT - depends on X86_64 - select IOMMU_API - select IOMMU_IOVA - select X86_DEV_DMA_OPS if X86 - select VIDEOBUF2_DMA_CONTIG - select V4L2_FWNODE - select PHYS_ADDR_T_64BIT - select COMMON_CLK - help - This is the Intel imaging processing unit, found in Intel SoCs and - used for capturing images and video from a camera sensor. - - To compile this driver, say Y here! It contains 3 modules - - intel_ipu6, intel_ipu6_isys and intel_ipu6_psys. - -config VIDEO_INTEL_IPU_TPG - bool "Compile for TPG driver" - depends on VIDEO_INTEL_IPU6 - help - If selected, TPG device nodes would be created. - - Recommended for driver developers only. - - If you want to the TPG devices exposed to user as media entity, - you must select this option, otherwise no. - -config IPU_ISYS_BRIDGE - bool "Intel IPU driver bridge" - default y - depends on VIDEO_INTEL_IPU6 - help - If selected, IPU isys bridge would be enabled. - - If you want supported sensors can be registered as IPU subdevices, - select y here. - -config IPU_SINGLE_BE_SOC_DEVICE - bool "Intel IPU uses only one BE SOC device" - default n - depends on VIDEO_INTEL_IPU6 - help - If selected, IPU exports only one BE SOC device. - - If you don't need multiple camera streaming, select y here. - -source "drivers/media/pci/intel/ipu3/Kconfig" diff -Nru ipu6-drivers-0~git202311240921.07f0612e/.github/workflows/test.yml ipu6-drivers-0~git202404110253.97c94720/.github/workflows/test.yml --- ipu6-drivers-0~git202311240921.07f0612e/.github/workflows/test.yml 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/.github/workflows/test.yml 2024-04-11 10:53:09.000000000 +0800 @@ -4,16 +4,19 @@ pull_request: schedule: - cron: '30 1 * * *' #every day at 1:30am + +permissions: {} + jobs: Ubuntu-2204-dkms: runs-on: ubuntu-latest container: ubuntu:22.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout ivsc-driver repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: intel/ivsc-driver path: ivsc-driver @@ -83,10 +86,10 @@ container: ubuntu:rolling steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout ivsc-driver repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: intel/ivsc-driver path: ivsc-driver @@ -155,10 +158,10 @@ container: debian:sid steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout ivsc-driver repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: intel/ivsc-driver path: ivsc-driver diff -Nru ipu6-drivers-0~git202311240921.07f0612e/Makefile ipu6-drivers-0~git202404110253.97c94720/Makefile --- ipu6-drivers-0~git202311240921.07f0612e/Makefile 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/Makefile 2024-04-11 10:53:09.000000000 +0800 @@ -1,6 +1,34 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2022 Intel Corporation. +KERNELRELEASE ?= $(shell uname -r) +KERNEL_VERSION := $(shell echo $(KERNELRELEASE) | sed 's/[^0-9.]*\([0-9.]*\).*/\1/') + +version_lt = $(shell \ + v1=$(1); \ + v2=$(2); \ + IFS='.'; \ + set -- $$v1; i=$$1; j=$$2; k=$$3; \ + set -- $$v2; a=$$1; b=$$2; c=$$3; \ + if [ "$$i" -lt "$$a" ]; then \ + echo "true"; \ + elif [ "$$i" -eq "$$a" ] && [ "$$j" -lt "$$b" ]; then \ + echo "true"; \ + elif [ "$$i" -eq "$$a" ] && [ "$$j" -eq "$$b" ] && [ "$$k" -lt "$$c" ]; then \ + echo "true"; \ + else \ + echo "false"; \ + fi) + +KV_IVSC := 6.6.0 +KV_IPU_BRIDGE := 6.6.0 +KV_OV2740 := 6.8.0 + +KERNEL_SRC ?= /lib/modules/$(KERNELRELEASE)/build +MODSRC := $(shell pwd) + +ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_IVSC)),true) +$(warning build ljca ivsc) obj-m += ljca.o ljca-y := drivers/mfd/ljca.o @@ -34,30 +62,36 @@ export CONFIG_INTEL_VSC = y +endif + export CONFIG_VIDEO_INTEL_IPU6 = m -export CONFIG_IPU_ISYS_BRIDGE = y export CONFIG_IPU_SINGLE_BE_SOC_DEVICE = n export CONFIG_INTEL_SKL_INT3472 = m +# export CONFIG_POWER_CTRL_LOGIC = m +ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_IPU_BRIDGE)),true) +export CONFIG_IPU_ISYS_BRIDGE = y +export CONFIG_IPU_BRIDGE = n +endif obj-y += drivers/media/pci/intel/ export CONFIG_VIDEO_HM11B1 = m -export CONFIG_VIDEO_GC5035 = m export CONFIG_VIDEO_OV01A1S = m export CONFIG_VIDEO_OV01A10 = m export CONFIG_VIDEO_OV02C10 = m export CONFIG_VIDEO_OV02E10 = m -export CONFIG_VIDEO_OV2740 = m export CONFIG_VIDEO_HM2170 = m export CONFIG_VIDEO_HM2172 = m export CONFIG_VIDEO_HI556 = m -# export CONFIG_POWER_CTRL_LOGIC = m -obj-y += drivers/media/i2c/ -KERNELRELEASE ?= $(shell uname -r) -KERNEL_SRC ?= /lib/modules/$(KERNELRELEASE)/build -MODSRC := $(shell pwd) +ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_OV2740)),true) +export CONFIG_VIDEO_OV2740 = m +export CONFIG_VIDEO_GC5035 = m +endif +obj-y += drivers/media/i2c/ +ifeq ($(call version_lt,$(KERNEL_VERSION),$(KV_IVSC)),true) ccflags-y += -I$(src)/backport-include/drivers/misc/mei/ +endif subdir-ccflags-y += -I$(src)/include/ \ -DCONFIG_VIDEO_V4L2_SUBDEV_API @@ -66,6 +100,8 @@ -DCONFIG_INTEL_VSC subdir-ccflags-$(CONFIG_IPU_ISYS_BRIDGE) += \ -DCONFIG_IPU_ISYS_BRIDGE +subdir-ccflags-$(CONFIG_IPU_BRIDGE) += \ + -DCONFIG_IPU_BRIDGE subdir-ccflags-$(CONFIG_IPU_SINGLE_BE_SOC_DEVICE) += \ -DCONFIG_IPU_SINGLE_BE_SOC_DEVICE subdir-ccflags-$(CONFIG_INTEL_SKL_INT3472) += \ diff -Nru ipu6-drivers-0~git202311240921.07f0612e/patch/linux-firmware/0001-Add-symbolic-link-for-Intel-IPU6-firmwares.patch ipu6-drivers-0~git202404110253.97c94720/patch/linux-firmware/0001-Add-symbolic-link-for-Intel-IPU6-firmwares.patch --- ipu6-drivers-0~git202311240921.07f0612e/patch/linux-firmware/0001-Add-symbolic-link-for-Intel-IPU6-firmwares.patch 1970-01-01 08:00:00.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/patch/linux-firmware/0001-Add-symbolic-link-for-Intel-IPU6-firmwares.patch 2024-04-11 10:53:09.000000000 +0800 @@ -0,0 +1,29 @@ +From f3721fd8b5eed61ba575e3e535e4de736a41c04d Mon Sep 17 00:00:00 2001 +From: Hao Yao +Date: Wed, 10 Apr 2024 19:51:49 +0800 +Subject: [PATCH] Add symbolic link for Intel IPU6 firmwares + +Signed-off-by: Hao Yao +--- + WHENCE | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/WHENCE b/WHENCE +index 9f089996..b38452c0 100644 +--- a/WHENCE ++++ b/WHENCE +@@ -1194,6 +1194,11 @@ Version: scci_master_20230926_0007 + File: intel/ipu/ipu6se_fw.bin + Version: scci_master_20210502_1459 + ++Link: intel/ipu6epadln_fw.bin -> ipu/ipu6epadln_fw.bin ++Link: intel/ipu6ep_fw.bin -> ipu/ipu6ep_fw.bin ++Link: intel/ipu6epmtl_fw.bin -> ipu/ipu6epmtl_fw.bin ++Link: intel/ipu6_fw.bin -> ipu/ipu6_fw.bin ++ + Licence: Redistributable. See LICENSE.ivsc for details + + -------------------------------------------------------------------------- +-- +2.43.2 + diff -Nru ipu6-drivers-0~git202311240921.07f0612e/patch/ov08x40-v6.5/0001-media-i2c-Add-new-sensor-OV08X40-driver.patch ipu6-drivers-0~git202404110253.97c94720/patch/ov08x40-v6.5/0001-media-i2c-Add-new-sensor-OV08X40-driver.patch --- ipu6-drivers-0~git202311240921.07f0612e/patch/ov08x40-v6.5/0001-media-i2c-Add-new-sensor-OV08X40-driver.patch 1970-01-01 08:00:00.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/patch/ov08x40-v6.5/0001-media-i2c-Add-new-sensor-OV08X40-driver.patch 2024-04-11 10:53:09.000000000 +0800 @@ -0,0 +1,408 @@ +From ec2a596e8c7e12a3f655a652bcf6cf84bd318201 Mon Sep 17 00:00:00 2001 +From: Serin Yeh +Date: Tue, 19 Mar 2024 17:43:56 +0800 +Subject: [PATCH] media/i2c:Add new sensor OV08X40 driver + +Add new sensor OV08X40 driver. Add Tline calculation and handshake +pin support for sensor + +Change-Id: I4cf3f683dcedbbd9b882e48d948ab121f9d5d33c +Tracked-On: #JILCCI-19 +Signed-off-by: Serin Yeh +--- + drivers/media/i2c/ov08x40.c | 199 +++++++++++++++++++++++++++++++----- + 1 file changed, 172 insertions(+), 27 deletions(-) + +diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c +index 77bcdcd082..b9d0b6b4be 100644 +--- a/drivers/media/i2c/ov08x40.c ++++ b/drivers/media/i2c/ov08x40.c +@@ -5,6 +5,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -34,7 +35,7 @@ + + /* V_TIMING internal */ + #define OV08X40_REG_VTS 0x380e +-#define OV08X40_VTS_30FPS 0x1388 ++#define OV08X40_VTS_30FPS 0x09c4 + #define OV08X40_VTS_BIN_30FPS 0x115c + #define OV08X40_VTS_MAX 0x7fff + +@@ -44,8 +45,9 @@ + + /* Exposure control */ + #define OV08X40_REG_EXPOSURE 0x3500 +-#define OV08X40_EXPOSURE_MAX_MARGIN 31 +-#define OV08X40_EXPOSURE_MIN 1 ++#define OV08X40_EXPOSURE_MAX_MARGIN 8 ++#define OV08X40_EXPOSURE_BIN_MAX_MARGIN 2 ++#define OV08X40_EXPOSURE_MIN 4 + #define OV08X40_EXPOSURE_STEP 1 + #define OV08X40_EXPOSURE_DEFAULT 0x40 + +@@ -127,11 +129,17 @@ struct ov08x40_mode { + /* V-timing */ + u32 vts_def; + u32 vts_min; ++ /* Line Length Pixels */ ++ u32 llp; + + /* Index of Link frequency config to be used */ + u32 link_freq_index; + /* Default register values */ + struct ov08x40_reg_list reg_list; ++ ++ /* Exposure calculation */ ++ u16 exposure_margin; ++ u16 exposure_shift; + }; + + static const struct ov08x40_reg mipi_data_rate_800mbps[] = { +@@ -2353,7 +2361,7 @@ static const char * const ov08x40_test_pattern_menu[] = { + + /* Configurations for supported link frequencies */ + #define OV08X40_LINK_FREQ_400MHZ 400000000ULL +- ++#define OV08X40_SCLK_96MHZ 96000000ULL + #define OV08X40_EXT_CLK 19200000 + #define OV08X40_DATA_LANES 4 + +@@ -2391,24 +2399,30 @@ static const struct ov08x40_mode supported_modes[] = { + .height = 2416, + .vts_def = OV08X40_VTS_30FPS, + .vts_min = OV08X40_VTS_30FPS, ++ .llp = 0x10aa, /* in normal mode, tline time = 2 * HTS / SCLK */ + .lanes = 4, + .reg_list = { + .num_of_regs = ARRAY_SIZE(mode_3856x2416_regs), + .regs = mode_3856x2416_regs, + }, + .link_freq_index = OV08X40_LINK_FREQ_400MHZ_INDEX, ++ .exposure_shift = 1, ++ .exposure_margin = OV08X40_EXPOSURE_MAX_MARGIN, + }, + { + .width = 1928, + .height = 1208, + .vts_def = OV08X40_VTS_BIN_30FPS, + .vts_min = OV08X40_VTS_BIN_30FPS, ++ .llp = 0x960, + .lanes = 4, + .reg_list = { + .num_of_regs = ARRAY_SIZE(mode_1928x1208_regs), + .regs = mode_1928x1208_regs, + }, + .link_freq_index = OV08X40_LINK_FREQ_400MHZ_INDEX, ++ .exposure_shift = 0, ++ .exposure_margin = OV08X40_EXPOSURE_BIN_MAX_MARGIN, + }, + }; + +@@ -2424,6 +2438,15 @@ struct ov08x40 { + struct v4l2_ctrl *hblank; + struct v4l2_ctrl *exposure; + ++ /* GPIO for reset */ ++ struct gpio_desc *reset; ++ /* GPIO for Lattice handshake */ ++ struct gpio_desc *handshake; ++ /* regulator */ ++ struct regulator *avdd; ++ /* Clock provider */ ++ struct clk *img_clk; ++ + /* Current mode */ + const struct ov08x40_mode *cur_mode; + +@@ -2664,13 +2687,24 @@ static int ov08x40_set_ctrl(struct v4l2_ctrl *ctrl) + struct ov08x40, ctrl_handler); + struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); + s64 max; ++ int exp; ++ int fll; + int ret = 0; + + /* Propagate change of current control to all related controls */ + switch (ctrl->id) { + case V4L2_CID_VBLANK: + /* Update max exposure while meeting expected vblanking */ +- max = ov08x->cur_mode->height + ctrl->val - OV08X40_EXPOSURE_MAX_MARGIN; ++ // max = ov08x->cur_mode->height + ctrl->val - OV08X40_EXPOSURE_MAX_MARGIN; ++ /* ++ * because in normal mode, 1 HTS = 0.5 tline ++ * fps = sclk / hts / vts ++ * so the vts value needs to be double ++ */ ++ max = ((ov08x->cur_mode->height + ctrl->val) << ++ ov08x->cur_mode->exposure_shift) - ++ ov08x->cur_mode->exposure_margin; ++ + __v4l2_ctrl_modify_range(ov08x->exposure, + ov08x->exposure->minimum, + max, ov08x->exposure->step, max); +@@ -2694,15 +2728,20 @@ static int ov08x40_set_ctrl(struct v4l2_ctrl *ctrl) + ret = ov08x40_update_digital_gain(ov08x, ctrl->val); + break; + case V4L2_CID_EXPOSURE: ++ exp = (ctrl->val << ov08x->cur_mode->exposure_shift) - ++ ov08x->cur_mode->exposure_margin; ++ + ret = ov08x40_write_reg(ov08x, OV08X40_REG_EXPOSURE, +- OV08X40_REG_VALUE_24BIT, +- ctrl->val); ++ OV08X40_REG_VALUE_24BIT, ++ exp); + break; + case V4L2_CID_VBLANK: ++ fll = ((ov08x->cur_mode->height + ctrl->val) << ++ ov08x->cur_mode->exposure_shift); ++ + ret = ov08x40_write_reg(ov08x, OV08X40_REG_VTS, + OV08X40_REG_VALUE_16BIT, +- ov08x->cur_mode->height +- + ctrl->val); ++ fll); + break; + case V4L2_CID_TEST_PATTERN: + ret = ov08x40_enable_test_pattern(ov08x, ctrl->val); +@@ -2813,6 +2852,7 @@ ov08x40_set_pad_format(struct v4l2_subdev *sd, + s64 h_blank; + s64 pixel_rate; + s64 link_freq; ++ u64 steps; + + mutex_lock(&ov08x->mutex); + +@@ -2840,15 +2880,22 @@ ov08x40_set_pad_format(struct v4l2_subdev *sd, + ov08x->cur_mode->height; + vblank_min = ov08x->cur_mode->vts_min - + ov08x->cur_mode->height; ++ ++ /* ++ * The frame length line should be aligned to a multiple of 4, ++ * as provided by the sensor vendor, in normal mode. ++ */ ++ steps = mode->exposure_shift == 1 ? 4 : 1; ++ + __v4l2_ctrl_modify_range(ov08x->vblank, vblank_min, + OV08X40_VTS_MAX + - ov08x->cur_mode->height, +- 1, ++ steps, + vblank_def); + __v4l2_ctrl_s_ctrl(ov08x->vblank, vblank_def); +- h_blank = +- link_freq_configs[mode->link_freq_index].pixels_per_line +- - ov08x->cur_mode->width; ++ ++ h_blank = ov08x->cur_mode->llp - ov08x->cur_mode->width; ++ + __v4l2_ctrl_modify_range(ov08x->hblank, h_blank, + h_blank, 1, h_blank); + } +@@ -2949,6 +2996,51 @@ static int ov08x40_set_stream(struct v4l2_subdev *sd, int enable) + return ret; + } + ++static int ov08x40_power_off(struct device *dev) ++{ ++ struct v4l2_subdev *sd = dev_get_drvdata(dev); ++ struct ov08x40 *ov08x40 = to_ov08x40(sd); ++ int ret = 0; ++ ++ gpiod_set_value_cansleep(ov08x40->reset, 1); ++ gpiod_set_value_cansleep(ov08x40->handshake, 0); ++ if (ov08x40->avdd) ++ ret = regulator_disable(ov08x40->avdd); ++ clk_disable_unprepare(ov08x40->img_clk); ++ ++ return ret; ++} ++ ++static int ov08x40_power_on(struct device *dev) ++{ ++ struct v4l2_subdev *sd = dev_get_drvdata(dev); ++ struct ov08x40 *ov08x40 = to_ov08x40(sd); ++ int ret; ++ ++ ret = clk_prepare_enable(ov08x40->img_clk); ++ if (ret < 0) { ++ dev_err(dev, "failed to enable imaging clock: %d", ret); ++ return ret; ++ } ++ if (ov08x40->avdd) { ++ ret = regulator_enable(ov08x40->avdd); ++ if (ret < 0) { ++ dev_err(dev, "failed to enable avdd: %d", ret); ++ clk_disable_unprepare(ov08x40->img_clk); ++ return ret; ++ } ++ } ++ gpiod_set_value_cansleep(ov08x40->handshake, 1); ++ gpiod_set_value_cansleep(ov08x40->reset, 0); ++ ++ /* Lattice MIPI aggregator with some version FW needs longer delay ++ after handshake triggered. We set 25ms as a safe value and wait ++ for a stable version FW. */ ++ msleep_interruptible(25); ++ ++ return ret; ++} ++ + static int __maybe_unused ov08x40_suspend(struct device *dev) + { + struct v4l2_subdev *sd = dev_get_drvdata(dev); +@@ -3074,8 +3166,8 @@ static int ov08x40_init_controls(struct ov08x40 *ov08x) + OV08X40_VTS_MAX - mode->height, 1, + vblank_def); + +- hblank = link_freq_configs[mode->link_freq_index].pixels_per_line - +- mode->width; ++ hblank = ov08x->cur_mode->llp - ov08x->cur_mode->width; ++ + ov08x->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov08x40_ctrl_ops, + V4L2_CID_HBLANK, + hblank, hblank, 1, hblank); +@@ -3141,6 +3233,41 @@ static void ov08x40_free_controls(struct ov08x40 *ov08x) + mutex_destroy(&ov08x->mutex); + } + ++ ++static int ov08x40_get_pm_resources(struct device *dev) ++{ ++ struct v4l2_subdev *sd = dev_get_drvdata(dev); ++ struct ov08x40 *ov08x40 = to_ov08x40(sd); ++ int ret; ++ ++ ov08x40->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); ++ if (IS_ERR(ov08x40->reset)) ++ return dev_err_probe(dev, PTR_ERR(ov08x40->reset), ++ "failed to get reset gpio\n"); ++ ++ ov08x40->handshake = devm_gpiod_get_optional(dev, "handshake", ++ GPIOD_OUT_LOW); ++ if (IS_ERR(ov08x40->handshake)) ++ return dev_err_probe(dev, PTR_ERR(ov08x40->handshake), ++ "failed to get handshake gpio\n"); ++ ++ ov08x40->img_clk = devm_clk_get_optional(dev, NULL); ++ if (IS_ERR(ov08x40->img_clk)) ++ return dev_err_probe(dev, PTR_ERR(ov08x40->img_clk), ++ "failed to get imaging clock\n"); ++ ++ ov08x40->avdd = devm_regulator_get_optional(dev, "avdd"); ++ if (IS_ERR(ov08x40->avdd)) { ++ ret = PTR_ERR(ov08x40->avdd); ++ ov08x40->avdd = NULL; ++ if (ret != -ENODEV) ++ return dev_err_probe(dev, ret, ++ "failed to get avdd regulator\n"); ++ } ++ ++ return 0; ++} ++ + static int ov08x40_check_hwcfg(struct device *dev) + { + struct v4l2_fwnode_endpoint bus_cfg = { +@@ -3152,8 +3279,10 @@ static int ov08x40_check_hwcfg(struct device *dev) + int ret; + u32 ext_clk; + +- if (!fwnode) +- return -ENXIO; ++ ep = fwnode_graph_get_next_endpoint(fwnode, NULL); ++ dev_dbg(dev, "fwnode_graph_get_next_endpoint = %d\n", ep); ++ if (!ep) ++ return -EPROBE_DEFER; + + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &ext_clk); +@@ -3168,10 +3297,6 @@ static int ov08x40_check_hwcfg(struct device *dev) + return -EINVAL; + } + +- ep = fwnode_graph_get_next_endpoint(fwnode, NULL); +- if (!ep) +- return -ENXIO; +- + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) +@@ -3214,6 +3339,7 @@ static int ov08x40_check_hwcfg(struct device *dev) + static int ov08x40_probe(struct i2c_client *client) + { + struct ov08x40 *ov08x; ++ bool full_power; + int ret; + + /* Check HW config */ +@@ -3229,12 +3355,25 @@ static int ov08x40_probe(struct i2c_client *client) + + /* Initialize subdev */ + v4l2_i2c_subdev_init(&ov08x->sd, client, &ov08x40_subdev_ops); ++ full_power = acpi_dev_state_d0(&client->dev); ++ if (full_power) { ++ dev_err(&client->dev, "start full_power\n"); ++ ret = ov08x40_get_pm_resources(&client->dev); ++ if (ret) ++ return ret; ++ ret = ov08x40_power_on(&client->dev); ++ if (ret) { ++ dev_err_probe(&client->dev, ret, ++ "failed to power on\n"); ++ goto probe_error_ret; ++ } + +- /* Check module identity */ +- ret = ov08x40_identify_module(ov08x); +- if (ret) { +- dev_err(&client->dev, "failed to find sensor: %d\n", ret); +- return ret; ++ /* Check module identity */ ++ ret = ov08x40_identify_module(ov08x); ++ if (ret) { ++ dev_err(&client->dev, "failed to find sensor: %d\n", ret); ++ return ret; ++ } + } + + /* Set default mode to max resolution */ +@@ -3266,7 +3405,10 @@ static int ov08x40_probe(struct i2c_client *client) + * Device is already turned on by i2c-core with ACPI domain PM. + * Enable runtime PM and turn off the device. + */ +- pm_runtime_set_active(&client->dev); ++ ++ /* Set the device's state to active if it's in D0 state. */ ++ if (full_power) ++ pm_runtime_set_active(&client->dev); + pm_runtime_enable(&client->dev); + pm_runtime_idle(&client->dev); + +@@ -3278,6 +3420,8 @@ static int ov08x40_probe(struct i2c_client *client) + error_handler_free: + ov08x40_free_controls(ov08x); + ++probe_error_ret: ++ ov08x40_power_off(&client->dev); + return ret; + } + +@@ -3320,6 +3464,7 @@ static struct i2c_driver ov08x40_i2c_driver = { + module_i2c_driver(ov08x40_i2c_driver); + + MODULE_AUTHOR("Jason Chen "); ++MODULE_AUTHOR("Qingwu Zhang "); + MODULE_AUTHOR("Shawn Tu "); + MODULE_DESCRIPTION("OmniVision OV08X40 sensor driver"); + MODULE_LICENSE("GPL"); +-- +2.43.2 + diff -Nru ipu6-drivers-0~git202311240921.07f0612e/patch/v6.8/0001-media-ov08x40-Add-Tline-calculation-and-handshake-pi.patch ipu6-drivers-0~git202404110253.97c94720/patch/v6.8/0001-media-ov08x40-Add-Tline-calculation-and-handshake-pi.patch --- ipu6-drivers-0~git202311240921.07f0612e/patch/v6.8/0001-media-ov08x40-Add-Tline-calculation-and-handshake-pi.patch 1970-01-01 08:00:00.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/patch/v6.8/0001-media-ov08x40-Add-Tline-calculation-and-handshake-pi.patch 2024-04-11 10:53:09.000000000 +0800 @@ -0,0 +1,407 @@ +From 3f1e304628f1de6aa650777b738c0a0041eb38a7 Mon Sep 17 00:00:00 2001 +From: Hao Yao +Date: Tue, 26 Mar 2024 11:17:06 +0800 +Subject: [PATCH 1/5] media: ov08x40: Add Tline calculation and handshake pin + support + +Signed-off-by: Hao Yao +--- + drivers/media/i2c/ov08x40.c | 203 ++++++++++++++++++++++++++++++------ + 1 file changed, 173 insertions(+), 30 deletions(-) + +diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c +index abbb0b774d43..aac42ad2ae3a 100644 +--- a/drivers/media/i2c/ov08x40.c ++++ b/drivers/media/i2c/ov08x40.c +@@ -5,6 +5,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -34,7 +35,7 @@ + + /* V_TIMING internal */ + #define OV08X40_REG_VTS 0x380e +-#define OV08X40_VTS_30FPS 0x1388 ++#define OV08X40_VTS_30FPS 0x09c4 + #define OV08X40_VTS_BIN_30FPS 0x115c + #define OV08X40_VTS_MAX 0x7fff + +@@ -44,8 +45,9 @@ + + /* Exposure control */ + #define OV08X40_REG_EXPOSURE 0x3500 +-#define OV08X40_EXPOSURE_MAX_MARGIN 31 +-#define OV08X40_EXPOSURE_MIN 1 ++#define OV08X40_EXPOSURE_MAX_MARGIN 8 ++#define OV08X40_EXPOSURE_BIN_MAX_MARGIN 2 ++#define OV08X40_EXPOSURE_MIN 4 + #define OV08X40_EXPOSURE_STEP 1 + #define OV08X40_EXPOSURE_DEFAULT 0x40 + +@@ -125,14 +127,17 @@ struct ov08x40_mode { + /* V-timing */ + u32 vts_def; + u32 vts_min; +- +- /* HTS */ +- u32 hts; ++ /* Line Length Pixels */ ++ u32 llp; + + /* Index of Link frequency config to be used */ + u32 link_freq_index; + /* Default register values */ + struct ov08x40_reg_list reg_list; ++ ++ /* Exposure calculation */ ++ u16 exposure_margin; ++ u16 exposure_shift; + }; + + static const struct ov08x40_reg mipi_data_rate_800mbps[] = { +@@ -2354,7 +2359,7 @@ static const char * const ov08x40_test_pattern_menu[] = { + + /* Configurations for supported link frequencies */ + #define OV08X40_LINK_FREQ_400MHZ 400000000ULL +- ++#define OV08X40_SCLK_96MHZ 96000000ULL + #define OV08X40_EXT_CLK 19200000 + #define OV08X40_DATA_LANES 4 + +@@ -2392,26 +2397,30 @@ static const struct ov08x40_mode supported_modes[] = { + .height = 2416, + .vts_def = OV08X40_VTS_30FPS, + .vts_min = OV08X40_VTS_30FPS, +- .hts = 640, ++ .llp = 0x10aa, /* in normal mode, tline time = 2 * HTS / SCLK */ + .lanes = 4, + .reg_list = { + .num_of_regs = ARRAY_SIZE(mode_3856x2416_regs), + .regs = mode_3856x2416_regs, + }, + .link_freq_index = OV08X40_LINK_FREQ_400MHZ_INDEX, ++ .exposure_shift = 1, ++ .exposure_margin = OV08X40_EXPOSURE_MAX_MARGIN, + }, + { + .width = 1928, + .height = 1208, + .vts_def = OV08X40_VTS_BIN_30FPS, + .vts_min = OV08X40_VTS_BIN_30FPS, +- .hts = 720, ++ .llp = 0x960, + .lanes = 4, + .reg_list = { + .num_of_regs = ARRAY_SIZE(mode_1928x1208_regs), + .regs = mode_1928x1208_regs, + }, + .link_freq_index = OV08X40_LINK_FREQ_400MHZ_INDEX, ++ .exposure_shift = 0, ++ .exposure_margin = OV08X40_EXPOSURE_BIN_MAX_MARGIN, + }, + }; + +@@ -2427,6 +2436,15 @@ struct ov08x40 { + struct v4l2_ctrl *hblank; + struct v4l2_ctrl *exposure; + ++ /* GPIO for reset */ ++ struct gpio_desc *reset; ++ /* GPIO for Lattice handshake */ ++ struct gpio_desc *handshake; ++ /* regulator */ ++ struct regulator *avdd; ++ /* Clock provider */ ++ struct clk *img_clk; ++ + /* Current mode */ + const struct ov08x40_mode *cur_mode; + +@@ -2664,13 +2682,24 @@ static int ov08x40_set_ctrl(struct v4l2_ctrl *ctrl) + struct ov08x40, ctrl_handler); + struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd); + s64 max; ++ int exp; ++ int fll; + int ret = 0; + + /* Propagate change of current control to all related controls */ + switch (ctrl->id) { + case V4L2_CID_VBLANK: + /* Update max exposure while meeting expected vblanking */ +- max = ov08x->cur_mode->height + ctrl->val - OV08X40_EXPOSURE_MAX_MARGIN; ++ // max = ov08x->cur_mode->height + ctrl->val - OV08X40_EXPOSURE_MAX_MARGIN; ++ /* ++ * because in normal mode, 1 HTS = 0.5 tline ++ * fps = sclk / hts / vts ++ * so the vts value needs to be double ++ */ ++ max = ((ov08x->cur_mode->height + ctrl->val) << ++ ov08x->cur_mode->exposure_shift) - ++ ov08x->cur_mode->exposure_margin; ++ + __v4l2_ctrl_modify_range(ov08x->exposure, + ov08x->exposure->minimum, + max, ov08x->exposure->step, max); +@@ -2694,15 +2723,20 @@ static int ov08x40_set_ctrl(struct v4l2_ctrl *ctrl) + ret = ov08x40_update_digital_gain(ov08x, ctrl->val); + break; + case V4L2_CID_EXPOSURE: ++ exp = (ctrl->val << ov08x->cur_mode->exposure_shift) - ++ ov08x->cur_mode->exposure_margin; ++ + ret = ov08x40_write_reg(ov08x, OV08X40_REG_EXPOSURE, +- OV08X40_REG_VALUE_24BIT, +- ctrl->val); ++ OV08X40_REG_VALUE_24BIT, ++ exp); + break; + case V4L2_CID_VBLANK: ++ fll = ((ov08x->cur_mode->height + ctrl->val) << ++ ov08x->cur_mode->exposure_shift); ++ + ret = ov08x40_write_reg(ov08x, OV08X40_REG_VTS, + OV08X40_REG_VALUE_16BIT, +- ov08x->cur_mode->height +- + ctrl->val); ++ fll); + break; + case V4L2_CID_TEST_PATTERN: + ret = ov08x40_enable_test_pattern(ov08x, ctrl->val); +@@ -2812,6 +2846,7 @@ ov08x40_set_pad_format(struct v4l2_subdev *sd, + s64 h_blank; + s64 pixel_rate; + s64 link_freq; ++ u64 steps; + + mutex_lock(&ov08x->mutex); + +@@ -2839,13 +2874,22 @@ ov08x40_set_pad_format(struct v4l2_subdev *sd, + ov08x->cur_mode->height; + vblank_min = ov08x->cur_mode->vts_min - + ov08x->cur_mode->height; ++ ++ /* ++ * The frame length line should be aligned to a multiple of 4, ++ * as provided by the sensor vendor, in normal mode. ++ */ ++ steps = mode->exposure_shift == 1 ? 4 : 1; ++ + __v4l2_ctrl_modify_range(ov08x->vblank, vblank_min, + OV08X40_VTS_MAX + - ov08x->cur_mode->height, +- 1, ++ steps, + vblank_def); + __v4l2_ctrl_s_ctrl(ov08x->vblank, vblank_def); +- h_blank = ov08x->cur_mode->hts; ++ ++ h_blank = ov08x->cur_mode->llp - ov08x->cur_mode->width; ++ + __v4l2_ctrl_modify_range(ov08x->hblank, h_blank, + h_blank, 1, h_blank); + } +@@ -2941,6 +2985,51 @@ static int ov08x40_set_stream(struct v4l2_subdev *sd, int enable) + return ret; + } + ++static int ov08x40_power_off(struct device *dev) ++{ ++ struct v4l2_subdev *sd = dev_get_drvdata(dev); ++ struct ov08x40 *ov08x40 = to_ov08x40(sd); ++ int ret = 0; ++ ++ gpiod_set_value_cansleep(ov08x40->reset, 1); ++ gpiod_set_value_cansleep(ov08x40->handshake, 0); ++ if (ov08x40->avdd) ++ ret = regulator_disable(ov08x40->avdd); ++ clk_disable_unprepare(ov08x40->img_clk); ++ ++ return ret; ++} ++ ++static int ov08x40_power_on(struct device *dev) ++{ ++ struct v4l2_subdev *sd = dev_get_drvdata(dev); ++ struct ov08x40 *ov08x40 = to_ov08x40(sd); ++ int ret; ++ ++ ret = clk_prepare_enable(ov08x40->img_clk); ++ if (ret < 0) { ++ dev_err(dev, "failed to enable imaging clock: %d", ret); ++ return ret; ++ } ++ if (ov08x40->avdd) { ++ ret = regulator_enable(ov08x40->avdd); ++ if (ret < 0) { ++ dev_err(dev, "failed to enable avdd: %d", ret); ++ clk_disable_unprepare(ov08x40->img_clk); ++ return ret; ++ } ++ } ++ gpiod_set_value_cansleep(ov08x40->handshake, 1); ++ gpiod_set_value_cansleep(ov08x40->reset, 0); ++ ++ /* Lattice MIPI aggregator with some version FW needs longer delay ++ after handshake triggered. We set 25ms as a safe value and wait ++ for a stable version FW. */ ++ msleep_interruptible(25); ++ ++ return ret; ++} ++ + /* Verify chip ID */ + static int ov08x40_identify_module(struct ov08x40 *ov08x) + { +@@ -3035,7 +3124,8 @@ static int ov08x40_init_controls(struct ov08x40 *ov08x) + OV08X40_VTS_MAX - mode->height, 1, + vblank_def); + +- hblank = ov08x->cur_mode->hts; ++ hblank = ov08x->cur_mode->llp - ov08x->cur_mode->width; ++ + ov08x->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov08x40_ctrl_ops, + V4L2_CID_HBLANK, + hblank, hblank, 1, hblank); +@@ -3101,6 +3191,41 @@ static void ov08x40_free_controls(struct ov08x40 *ov08x) + mutex_destroy(&ov08x->mutex); + } + ++ ++static int ov08x40_get_pm_resources(struct device *dev) ++{ ++ struct v4l2_subdev *sd = dev_get_drvdata(dev); ++ struct ov08x40 *ov08x40 = to_ov08x40(sd); ++ int ret; ++ ++ ov08x40->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); ++ if (IS_ERR(ov08x40->reset)) ++ return dev_err_probe(dev, PTR_ERR(ov08x40->reset), ++ "failed to get reset gpio\n"); ++ ++ ov08x40->handshake = devm_gpiod_get_optional(dev, "handshake", ++ GPIOD_OUT_LOW); ++ if (IS_ERR(ov08x40->handshake)) ++ return dev_err_probe(dev, PTR_ERR(ov08x40->handshake), ++ "failed to get handshake gpio\n"); ++ ++ ov08x40->img_clk = devm_clk_get_optional(dev, NULL); ++ if (IS_ERR(ov08x40->img_clk)) ++ return dev_err_probe(dev, PTR_ERR(ov08x40->img_clk), ++ "failed to get imaging clock\n"); ++ ++ ov08x40->avdd = devm_regulator_get_optional(dev, "avdd"); ++ if (IS_ERR(ov08x40->avdd)) { ++ ret = PTR_ERR(ov08x40->avdd); ++ ov08x40->avdd = NULL; ++ if (ret != -ENODEV) ++ return dev_err_probe(dev, ret, ++ "failed to get avdd regulator\n"); ++ } ++ ++ return 0; ++} ++ + static int ov08x40_check_hwcfg(struct device *dev) + { + struct v4l2_fwnode_endpoint bus_cfg = { +@@ -3112,8 +3237,10 @@ static int ov08x40_check_hwcfg(struct device *dev) + int ret; + u32 ext_clk; + +- if (!fwnode) +- return -ENXIO; ++ ep = fwnode_graph_get_next_endpoint(fwnode, NULL); ++ dev_dbg(dev, "fwnode_graph_get_next_endpoint = %d\n", ep); ++ if (!ep) ++ return -EPROBE_DEFER; + + ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", + &ext_clk); +@@ -3128,10 +3255,6 @@ static int ov08x40_check_hwcfg(struct device *dev) + return -EINVAL; + } + +- ep = fwnode_graph_get_next_endpoint(fwnode, NULL); +- if (!ep) +- return -ENXIO; +- + ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg); + fwnode_handle_put(ep); + if (ret) +@@ -3174,6 +3297,7 @@ static int ov08x40_check_hwcfg(struct device *dev) + static int ov08x40_probe(struct i2c_client *client) + { + struct ov08x40 *ov08x; ++ bool full_power; + int ret; + + /* Check HW config */ +@@ -3189,12 +3313,25 @@ static int ov08x40_probe(struct i2c_client *client) + + /* Initialize subdev */ + v4l2_i2c_subdev_init(&ov08x->sd, client, &ov08x40_subdev_ops); ++ full_power = acpi_dev_state_d0(&client->dev); ++ if (full_power) { ++ dev_err(&client->dev, "start full_power\n"); ++ ret = ov08x40_get_pm_resources(&client->dev); ++ if (ret) ++ return ret; ++ ret = ov08x40_power_on(&client->dev); ++ if (ret) { ++ dev_err_probe(&client->dev, ret, ++ "failed to power on\n"); ++ goto probe_error_ret; ++ } + +- /* Check module identity */ +- ret = ov08x40_identify_module(ov08x); +- if (ret) { +- dev_err(&client->dev, "failed to find sensor: %d\n", ret); +- return ret; ++ /* Check module identity */ ++ ret = ov08x40_identify_module(ov08x); ++ if (ret) { ++ dev_err(&client->dev, "failed to find sensor: %d\n", ret); ++ return ret; ++ } + } + + /* Set default mode to max resolution */ +@@ -3226,7 +3363,10 @@ static int ov08x40_probe(struct i2c_client *client) + * Device is already turned on by i2c-core with ACPI domain PM. + * Enable runtime PM and turn off the device. + */ +- pm_runtime_set_active(&client->dev); ++ ++ /* Set the device's state to active if it's in D0 state. */ ++ if (full_power) ++ pm_runtime_set_active(&client->dev); + pm_runtime_enable(&client->dev); + pm_runtime_idle(&client->dev); + +@@ -3238,6 +3378,8 @@ static int ov08x40_probe(struct i2c_client *client) + error_handler_free: + ov08x40_free_controls(ov08x); + ++probe_error_ret: ++ ov08x40_power_off(&client->dev); + return ret; + } + +@@ -3275,6 +3417,7 @@ static struct i2c_driver ov08x40_i2c_driver = { + module_i2c_driver(ov08x40_i2c_driver); + + MODULE_AUTHOR("Jason Chen "); +-MODULE_AUTHOR("Shawn Tu"); ++MODULE_AUTHOR("Qingwu Zhang "); ++MODULE_AUTHOR("Shawn Tu "); + MODULE_DESCRIPTION("OmniVision OV08X40 sensor driver"); + MODULE_LICENSE("GPL"); +-- +2.43.2 + diff -Nru ipu6-drivers-0~git202311240921.07f0612e/patch/v6.8/0002-media-Add-IPU6-and-supported-sensors-config.patch ipu6-drivers-0~git202404110253.97c94720/patch/v6.8/0002-media-Add-IPU6-and-supported-sensors-config.patch --- ipu6-drivers-0~git202311240921.07f0612e/patch/v6.8/0002-media-Add-IPU6-and-supported-sensors-config.patch 1970-01-01 08:00:00.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/patch/v6.8/0002-media-Add-IPU6-and-supported-sensors-config.patch 2024-04-11 10:53:09.000000000 +0800 @@ -0,0 +1,149 @@ +From e39d4c99e2bf1002cd61faf79db86b95257a4a3e Mon Sep 17 00:00:00 2001 +From: Hao Yao +Date: Mon, 25 Mar 2024 14:40:09 +0800 +Subject: [PATCH 2/5] media: Add IPU6 and supported sensors config + +Signed-off-by: Hao Yao +--- + drivers/media/i2c/Kconfig | 60 ++++++++++++++++++++++++++++++++ + drivers/media/i2c/Makefile | 7 ++++ + drivers/media/pci/intel/Kconfig | 1 + + drivers/media/pci/intel/Makefile | 1 + + 4 files changed, 69 insertions(+) + +diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig +index 4c3435921f19..6b5c33bcec7f 100644 +--- a/drivers/media/i2c/Kconfig ++++ b/drivers/media/i2c/Kconfig +@@ -107,6 +107,33 @@ config VIDEO_HI847 + To compile this driver as a module, choose M here: the + module will be called hi847. + ++config VIDEO_HM11B1 ++ tristate "Himax HM11B1 sensor support" ++ help ++ This is a Video4Linux2 sensor driver for the Himax ++ HM11B1 camera. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called hm11b1. ++ ++config VIDEO_HM2170 ++ tristate "Himax HM2170 sensor support" ++ help ++ This is a Video4Linux2 sensor driver for the Himax ++ HM2170 camera. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called hm2170. ++ ++config VIDEO_HM2172 ++ tristate "Himax HM2172 sensor support" ++ help ++ This is a Video4Linux2 sensor driver for the Himax ++ HM2172 camera. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called hm2172. ++ + config VIDEO_IMX208 + tristate "Sony IMX208 sensor support" + help +@@ -313,6 +340,15 @@ config VIDEO_OV01A10 + To compile this driver as a module, choose M here: the + module will be called ov01a10. + ++config VIDEO_OV01A1S ++ tristate "OmniVision OV01A1S sensor support" ++ help ++ This is a Video4Linux2 sensor driver for the OmniVision ++ OV01A1S camera. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called ov01a1s. ++ + config VIDEO_OV02A10 + tristate "OmniVision OV02A10 sensor support" + help +@@ -322,6 +358,30 @@ config VIDEO_OV02A10 + To compile this driver as a module, choose M here: the + module will be called ov02a10. + ++config VIDEO_OV02C10 ++ tristate "OmniVision OV02C10 sensor support" ++ help ++ This is a Video4Linux2 sensor driver for the OmniVision ++ OV02C10 camera. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called ov02c10. ++ ++config VIDEO_OV02E10 ++ tristate "OmniVision OV02E10 sensor support" ++ help ++ This is a Video4Linux2 sensor driver for the OmniVision ++ ov02e10 camera. ++ ++config VIDEO_OV08A10 ++ tristate "OmniVision OV08A10 sensor support" ++ help ++ This is a Video4Linux2 sensor driver for the OmniVision ++ OV08A10 camera sensor. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called ov08a10. ++ + config VIDEO_OV08D10 + tristate "OmniVision OV08D10 sensor support" + help +diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile +index dfbe6448b549..32dd623c6c81 100644 +--- a/drivers/media/i2c/Makefile ++++ b/drivers/media/i2c/Makefile +@@ -42,6 +42,9 @@ obj-$(CONFIG_VIDEO_GC2145) += gc2145.o + obj-$(CONFIG_VIDEO_HI556) += hi556.o + obj-$(CONFIG_VIDEO_HI846) += hi846.o + obj-$(CONFIG_VIDEO_HI847) += hi847.o ++obj-$(CONFIG_VIDEO_HM11B1) += hm11b1.o ++obj-$(CONFIG_VIDEO_HM2170) += hm2170.o ++obj-$(CONFIG_VIDEO_HM2172) += hm2172.o + obj-$(CONFIG_VIDEO_I2C) += video-i2c.o + obj-$(CONFIG_VIDEO_IMX208) += imx208.o + obj-$(CONFIG_VIDEO_IMX214) += imx214.o +@@ -76,7 +79,11 @@ obj-$(CONFIG_VIDEO_MT9V032) += mt9v032.o + obj-$(CONFIG_VIDEO_MT9V111) += mt9v111.o + obj-$(CONFIG_VIDEO_OG01A1B) += og01a1b.o + obj-$(CONFIG_VIDEO_OV01A10) += ov01a10.o ++obj-$(CONFIG_VIDEO_OV01A1S) += ov01a1s.o + obj-$(CONFIG_VIDEO_OV02A10) += ov02a10.o ++obj-$(CONFIG_VIDEO_OV02C10) += ov02c10.o ++obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o ++obj-$(CONFIG_VIDEO_OV08A10) += ov08a10.o + obj-$(CONFIG_VIDEO_OV08D10) += ov08d10.o + obj-$(CONFIG_VIDEO_OV08X40) += ov08x40.o + obj-$(CONFIG_VIDEO_OV13858) += ov13858.o +diff --git a/drivers/media/pci/intel/Kconfig b/drivers/media/pci/intel/Kconfig +index ee4684159d3d..04cb3d253486 100644 +--- a/drivers/media/pci/intel/Kconfig ++++ b/drivers/media/pci/intel/Kconfig +@@ -1,6 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0-only + + source "drivers/media/pci/intel/ipu3/Kconfig" ++source "drivers/media/pci/intel/ipu6/Kconfig" + source "drivers/media/pci/intel/ivsc/Kconfig" + + config IPU_BRIDGE +diff --git a/drivers/media/pci/intel/Makefile b/drivers/media/pci/intel/Makefile +index f199a97e1d78..0ac987a40da5 100644 +--- a/drivers/media/pci/intel/Makefile ++++ b/drivers/media/pci/intel/Makefile +@@ -4,4 +4,5 @@ + # + obj-$(CONFIG_IPU_BRIDGE) += ipu-bridge.o + obj-y += ipu3/ ++obj-y += ipu6/ + obj-y += ivsc/ +-- +2.43.2 + diff -Nru ipu6-drivers-0~git202311240921.07f0612e/patch/v6.8/0003-media-ipu-bridge-Support-more-sensors.patch ipu6-drivers-0~git202404110253.97c94720/patch/v6.8/0003-media-ipu-bridge-Support-more-sensors.patch --- ipu6-drivers-0~git202311240921.07f0612e/patch/v6.8/0003-media-ipu-bridge-Support-more-sensors.patch 1970-01-01 08:00:00.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/patch/v6.8/0003-media-ipu-bridge-Support-more-sensors.patch 2024-04-11 10:53:09.000000000 +0800 @@ -0,0 +1,45 @@ +From fd6e61b885b92eb666870949fac0921143e3fa6f Mon Sep 17 00:00:00 2001 +From: Hao Yao +Date: Tue, 26 Mar 2024 10:50:41 +0800 +Subject: [PATCH 3/5] media: ipu-bridge: Support more sensors + +Signed-off-by: Hao Yao +--- + drivers/media/pci/intel/ipu-bridge.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c +index f980e3125a7b..2ac59e02b839 100644 +--- a/drivers/media/pci/intel/ipu-bridge.c ++++ b/drivers/media/pci/intel/ipu-bridge.c +@@ -58,8 +58,27 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = { + IPU_SENSOR_CONFIG("INT3537", 1, 437000000), + /* Omnivision ov13b10 */ + IPU_SENSOR_CONFIG("OVTIDB10", 1, 560000000), ++ IPU_SENSOR_CONFIG("OVTI13B1", 1, 560000000), + /* GalaxyCore GC0310 */ + IPU_SENSOR_CONFIG("INT0310", 0), ++ /* Omnivision ov01a10 */ ++ IPU_SENSOR_CONFIG("OVTI01A0", 1, 400000000), ++ /* Omnivision ov08x40 */ ++ IPU_SENSOR_CONFIG("OVTI08F4", 1, 400000000), ++ /* Himax hm11b1 */ ++ IPU_SENSOR_CONFIG("HIMX11B1", 1, 384000000), ++ /* Himax hm2170 */ ++ IPU_SENSOR_CONFIG("HIMX2170", 1, 384000000), ++ /* Himax hm2172 */ ++ IPU_SENSOR_CONFIG("HIMX2172", 1, 384000000), ++ /* Omnivision ov01a1s */ ++ IPU_SENSOR_CONFIG("OVTI01AS", 1, 400000000), ++ /* Omnivision ov02c10 */ ++ IPU_SENSOR_CONFIG("OVTI02C1", 1, 400000000), ++ /* Omnivision ov02e10 */ ++ IPU_SENSOR_CONFIG("OVTI02E1", 1, 360000000), ++ /* Omnivision ov08a10 */ ++ IPU_SENSOR_CONFIG("OVTI08A1", 1, 500000000), + }; + + static const struct ipu_property_names prop_names = { +-- +2.43.2 + diff -Nru ipu6-drivers-0~git202311240921.07f0612e/patch/v6.8/0004-ACPI-scan-Defer-enumeration-of-devices-with-a-_DEP-p.patch ipu6-drivers-0~git202404110253.97c94720/patch/v6.8/0004-ACPI-scan-Defer-enumeration-of-devices-with-a-_DEP-p.patch --- ipu6-drivers-0~git202311240921.07f0612e/patch/v6.8/0004-ACPI-scan-Defer-enumeration-of-devices-with-a-_DEP-p.patch 1970-01-01 08:00:00.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/patch/v6.8/0004-ACPI-scan-Defer-enumeration-of-devices-with-a-_DEP-p.patch 2024-04-11 10:53:09.000000000 +0800 @@ -0,0 +1,46 @@ +From f71be295d188e89f5eab1648467e65010a9daf28 Mon Sep 17 00:00:00 2001 +From: Wentong Wu +Date: Wed, 7 Feb 2024 08:59:08 +0800 +Subject: [PATCH 4/5] ACPI: scan: Defer enumeration of devices with a _DEP + pointing to IVSC device + +Inside IVSC, switching ownership requires an interface with two +different hardware modules, ACE and CSI. The software interface +to these modules is based on Intel MEI framework. Usually mei +client devices are dynamically created, so the info of consumers +depending on mei client devices is not present in the firmware +tables. + +This causes problems with the probe ordering with respect to +drivers for consumers of these MEI client devices. But on these +camera sensor devices, the ACPI nodes describing the sensors all +have a _DEP dependency on the matching MEI bus ACPI device, so +adding IVSC MEI bus ACPI device to acpi_honor_dep_ids allows +solving the probe-ordering problem by deferring the enumeration of +ACPI-devices which have a _DEP dependency on an IVSC mei bus ACPI +device. + +Add INTC10CF, the HID of IVSC MEI bus ACPI device on MTL platform, +to acpi_honor_dep_ids. + +Signed-off-by: Wentong Wu +Signed-off-by: Rafael J. Wysocki +--- + drivers/acpi/scan.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c +index 617f3e0e963d..dd817e9ed2e5 100644 +--- a/drivers/acpi/scan.c ++++ b/drivers/acpi/scan.c +@@ -794,6 +794,7 @@ static const char * const acpi_honor_dep_ids[] = { + "INTC1059", /* IVSC (TGL) driver must be loaded to allow i2c access to camera sensors */ + "INTC1095", /* IVSC (ADL) driver must be loaded to allow i2c access to camera sensors */ + "INTC100A", /* IVSC (RPL) driver must be loaded to allow i2c access to camera sensors */ ++ "INTC10CF", /* IVSC (MTL) driver must be loaded to allow i2c access to camera sensors */ + NULL + }; + +-- +2.43.2 + diff -Nru ipu6-drivers-0~git202311240921.07f0612e/patch/v6.8/0005-mei-vsc-Unregister-interrupt-handler-for-system-susp.patch ipu6-drivers-0~git202404110253.97c94720/patch/v6.8/0005-mei-vsc-Unregister-interrupt-handler-for-system-susp.patch --- ipu6-drivers-0~git202311240921.07f0612e/patch/v6.8/0005-mei-vsc-Unregister-interrupt-handler-for-system-susp.patch 1970-01-01 08:00:00.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/patch/v6.8/0005-mei-vsc-Unregister-interrupt-handler-for-system-susp.patch 2024-04-11 10:53:09.000000000 +0800 @@ -0,0 +1,216 @@ +From a1e3360ca97c88a822e8c30b827c673de626b127 Mon Sep 17 00:00:00 2001 +From: Sakari Ailus +Date: Mon, 18 Mar 2024 10:01:26 +0200 +Subject: [PATCH 5/5] mei: vsc: Unregister interrupt handler for system suspend + +Unregister the MEI VSC interrupt handler before system suspend and +re-register it at system resume time. This mirrors implementation of other +MEI devices. + +This patch fixes the bug that causes continuous stream of MEI VSC errors +after system resume. + +Fixes: 386a766c4169 ("mei: Add MEI hardware support for IVSC device") +Cc: stable@vger.kernel.org # for 6.8 +Reported-by: Dominik Brodowski +Signed-off-by: Wentong Wu +Signed-off-by: Sakari Ailus +--- + drivers/misc/mei/platform-vsc.c | 17 ++++++- + drivers/misc/mei/vsc-tp.c | 84 +++++++++++++++++++++++---------- + drivers/misc/mei/vsc-tp.h | 3 ++ + 3 files changed, 78 insertions(+), 26 deletions(-) + +diff --git a/drivers/misc/mei/platform-vsc.c b/drivers/misc/mei/platform-vsc.c +index 8d303c6c0000..8db0fcf24e70 100644 +--- a/drivers/misc/mei/platform-vsc.c ++++ b/drivers/misc/mei/platform-vsc.c +@@ -402,25 +402,40 @@ static int mei_vsc_remove(struct platform_device *pdev) + static int mei_vsc_suspend(struct device *dev) + { + struct mei_device *mei_dev = dev_get_drvdata(dev); ++ struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev); + + mei_stop(mei_dev); + ++ mei_disable_interrupts(mei_dev); ++ ++ vsc_tp_free_irq(hw->tp); ++ + return 0; + } + + static int mei_vsc_resume(struct device *dev) + { + struct mei_device *mei_dev = dev_get_drvdata(dev); ++ struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev); + int ret; + +- ret = mei_restart(mei_dev); ++ ret = vsc_tp_request_irq(hw->tp); + if (ret) + return ret; + ++ ret = mei_restart(mei_dev); ++ if (ret) ++ goto err_free; ++ + /* start timer if stopped in suspend */ + schedule_delayed_work(&mei_dev->timer_work, HZ); + + return 0; ++ ++err_free: ++ vsc_tp_free_irq(hw->tp); ++ ++ return ret; + } + + static DEFINE_SIMPLE_DEV_PM_OPS(mei_vsc_pm_ops, mei_vsc_suspend, mei_vsc_resume); +diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c +index 682c62c635b6..d612b3391191 100644 +--- a/drivers/misc/mei/vsc-tp.c ++++ b/drivers/misc/mei/vsc-tp.c +@@ -94,6 +94,27 @@ static const struct acpi_gpio_mapping vsc_tp_acpi_gpios[] = { + {} + }; + ++static irqreturn_t vsc_tp_isr(int irq, void *data) ++{ ++ struct vsc_tp *tp = data; ++ ++ atomic_inc(&tp->assert_cnt); ++ ++ return IRQ_WAKE_THREAD; ++} ++ ++static irqreturn_t vsc_tp_thread_isr(int irq, void *data) ++{ ++ struct vsc_tp *tp = data; ++ ++ wake_up(&tp->xfer_wait); ++ ++ if (tp->event_notify) ++ tp->event_notify(tp->event_notify_context); ++ ++ return IRQ_HANDLED; ++} ++ + /* wakeup firmware and wait for response */ + static int vsc_tp_wakeup_request(struct vsc_tp *tp) + { +@@ -383,6 +404,37 @@ int vsc_tp_register_event_cb(struct vsc_tp *tp, vsc_tp_event_cb_t event_cb, + } + EXPORT_SYMBOL_NS_GPL(vsc_tp_register_event_cb, VSC_TP); + ++/** ++ * vsc_tp_request_irq - request irq for vsc_tp device ++ * @tp: vsc_tp device handle ++ */ ++int vsc_tp_request_irq(struct vsc_tp *tp) ++{ ++ struct spi_device *spi = tp->spi; ++ struct device *dev = &spi->dev; ++ int ret; ++ ++ irq_set_status_flags(spi->irq, IRQ_DISABLE_UNLAZY); ++ ret = request_threaded_irq(spi->irq, vsc_tp_isr, vsc_tp_thread_isr, ++ IRQF_TRIGGER_FALLING | IRQF_ONESHOT, ++ dev_name(dev), tp); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++EXPORT_SYMBOL_NS_GPL(vsc_tp_request_irq, VSC_TP); ++ ++/** ++ * vsc_tp_free_irq - free irq for vsc_tp device ++ * @tp: vsc_tp device handle ++ */ ++void vsc_tp_free_irq(struct vsc_tp *tp) ++{ ++ free_irq(tp->spi->irq, tp); ++} ++EXPORT_SYMBOL_NS_GPL(vsc_tp_free_irq, VSC_TP); ++ + /** + * vsc_tp_intr_synchronize - synchronize vsc_tp interrupt + * @tp: vsc_tp device handle +@@ -413,27 +465,6 @@ void vsc_tp_intr_disable(struct vsc_tp *tp) + } + EXPORT_SYMBOL_NS_GPL(vsc_tp_intr_disable, VSC_TP); + +-static irqreturn_t vsc_tp_isr(int irq, void *data) +-{ +- struct vsc_tp *tp = data; +- +- atomic_inc(&tp->assert_cnt); +- +- return IRQ_WAKE_THREAD; +-} +- +-static irqreturn_t vsc_tp_thread_isr(int irq, void *data) +-{ +- struct vsc_tp *tp = data; +- +- wake_up(&tp->xfer_wait); +- +- if (tp->event_notify) +- tp->event_notify(tp->event_notify_context); +- +- return IRQ_HANDLED; +-} +- + static int vsc_tp_match_any(struct acpi_device *adev, void *data) + { + struct acpi_device **__adev = data; +@@ -485,10 +516,9 @@ static int vsc_tp_probe(struct spi_device *spi) + tp->spi = spi; + + irq_set_status_flags(spi->irq, IRQ_DISABLE_UNLAZY); +- ret = devm_request_threaded_irq(dev, spi->irq, vsc_tp_isr, +- vsc_tp_thread_isr, +- IRQF_TRIGGER_FALLING | IRQF_ONESHOT, +- dev_name(dev), tp); ++ ret = request_threaded_irq(spi->irq, vsc_tp_isr, vsc_tp_thread_isr, ++ IRQF_TRIGGER_FALLING | IRQF_ONESHOT, ++ dev_name(dev), tp); + if (ret) + return ret; + +@@ -522,6 +552,8 @@ static int vsc_tp_probe(struct spi_device *spi) + err_destroy_lock: + mutex_destroy(&tp->mutex); + ++ free_irq(spi->irq, tp); ++ + return ret; + } + +@@ -532,6 +564,8 @@ static void vsc_tp_remove(struct spi_device *spi) + platform_device_unregister(tp->pdev); + + mutex_destroy(&tp->mutex); ++ ++ free_irq(spi->irq, tp); + } + + static const struct acpi_device_id vsc_tp_acpi_ids[] = { +diff --git a/drivers/misc/mei/vsc-tp.h b/drivers/misc/mei/vsc-tp.h +index f9513ddc3e40..14ca195cbddc 100644 +--- a/drivers/misc/mei/vsc-tp.h ++++ b/drivers/misc/mei/vsc-tp.h +@@ -37,6 +37,9 @@ int vsc_tp_xfer(struct vsc_tp *tp, u8 cmd, const void *obuf, size_t olen, + int vsc_tp_register_event_cb(struct vsc_tp *tp, vsc_tp_event_cb_t event_cb, + void *context); + ++int vsc_tp_request_irq(struct vsc_tp *tp); ++void vsc_tp_free_irq(struct vsc_tp *tp); ++ + void vsc_tp_intr_enable(struct vsc_tp *tp); + void vsc_tp_intr_disable(struct vsc_tp *tp); + void vsc_tp_intr_synchronize(struct vsc_tp *tp); +-- +2.43.2 + diff -Nru ipu6-drivers-0~git202311240921.07f0612e/README.md ipu6-drivers-0~git202404110253.97c94720/README.md --- ipu6-drivers-0~git202311240921.07f0612e/README.md 2023-11-24 17:56:06.000000000 +0800 +++ ipu6-drivers-0~git202404110253.97c94720/README.md 2024-04-11 10:53:09.000000000 +0800 @@ -26,7 +26,7 @@ 3. and build with dkms ### 1. Build with kernel source tree -- Tested with kernel v6.4 +- Tested with kernel v6.8 - Check out kernel - Apply patches: ```sh @@ -44,144 +44,20 @@ # For kernel version >= 6.3 and using ov13b10 patch/ov13b10-v6.3/*.patch - ``` -- Copy repo content to kernel source **(except Makefile and drivers/media/i2c/{Kconfig,Makefile}, will change manually next)** -- Modify related Kconfig and Makefile -- Add config in LinuxRoot/drivers/media/i2c/Kconfig *(for kernel version < 5.18, use `VIDEO_V4L2` instead of `VIDEO_DEV` in `depends on` section)* - ```conf - config POWER_CTRL_LOGIC - tristate "power control logic driver" - depends on GPIO_ACPI - help - This is a power control logic driver for sensor, the design - depends on camera sensor connections. - This driver controls power by getting and using managed GPIO - pins from ACPI config for sensors, such as HM11B1, OV01A1S. - - To compile this driver as a module, choose M here: the - module will be called power_ctrl_logic. - - config VIDEO_OV01A1S - tristate "OmniVision OV01A1S sensor support" - depends on VIDEO_DEV && I2C - depends on ACPI || COMPILE_TEST - select MEDIA_CONTROLLER - select VIDEO_V4L2_SUBDEV_API - select V4L2_FWNODE - help - This is a Video4Linux2 sensor driver for the OmniVision - OV01A1S camera. - - To compile this driver as a module, choose M here: the - module will be called ov01a1s. - - config VIDEO_HM11B1 - tristate "Himax HM11B1 sensor support" - depends on VIDEO_DEV && I2C - select MEDIA_CONTROLLER - select VIDEO_V4L2_SUBDEV_API - select V4L2_FWNODE - help - This is a Video4Linux2 sensor driver for the Himax - HM11B1 camera. - - To compile this driver as a module, choose M here: the - module will be called hm11b1. - - config VIDEO_OV01A10 - tristate "OmniVision OV01A10 sensor support" - depends on VIDEO_DEV && I2C - depends on ACPI || COMPILE_TEST - select MEDIA_CONTROLLER - select VIDEO_V4L2_SUBDEV_API - select V4L2_FWNODE - help - This is a Video4Linux2 sensor driver for the OmniVision - OV01A10 camera. - - To compile this driver as a module, choose M here: the - module will be called ov01a10. - - config VIDEO_OV02C10 - tristate "OmniVision OV02C10 sensor support" - depends on VIDEO_DEV && I2C - depends on ACPI || COMPILE_TEST - select MEDIA_CONTROLLER - select VIDEO_V4L2_SUBDEV_API - select V4L2_FWNODE - help - This is a Video4Linux2 sensor driver for the OmniVision - OV02C10 camera. - - To compile this driver as a module, choose M here: the - module will be called ov02c10. - - config VIDEO_OV02E10 - tristate "OmniVision OV02E10 sensor support" - depends on VIDEO_DEV && I2C - depends on ACPI || COMPILE_TEST - select MEDIA_CONTROLLER - select VIDEO_V4L2_SUBDEV_API - select V4L2_FWNODE - help - This is a Video4Linux2 sensor driver for the OmniVision - OV02E10 camera. - - To compile this driver as a module, choose M here: the - module will be called ov02e10. - - config VIDEO_HM2170 - tristate "Himax HM2170 sensor support" - depends on VIDEO_DEV && I2C - select MEDIA_CONTROLLER - select VIDEO_V4L2_SUBDEV_API - select V4L2_FWNODE - help - This is a Video4Linux2 sensor driver for the Himax - HM2170 camera. - - To compile this driver as a module, choose M here: the - module will be called hm2170. - - config VIDEO_HM2172 - tristate "Himax HM2172 sensor support" - depends on VIDEO_DEV && I2C - select MEDIA_CONTROLLER - select VIDEO_V4L2_SUBDEV_API - select V4L2_FWNODE - help - This is a Video4Linux2 sensor driver for the Himax - HM2170 camera. - - To compile this driver as a module, choose M here: the - module will be called hm2172. - - ``` - -- Add to drivers/media/i2c/Makefile - ```makefile - obj-$(CONFIG_POWER_CTRL_LOGIC) += power_ctrl_logic.o - obj-$(CONFIG_VIDEO_OV01A1S) += ov01a1s.o - obj-$(CONFIG_VIDEO_HM11B1) += hm11b1.o - obj-$(CONFIG_VIDEO_OV01A10) += ov01a10.o - obj-$(CONFIG_VIDEO_OV02C10) += ov02c10.o - obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o - obj-$(CONFIG_VIDEO_HM2170) += hm2170.o - obj-$(CONFIG_VIDEO_HM2170) += hm2172.o - ``` -- Modify drivers/media/pci/Kconfig - ```conf - # replace line: - # source "drivers/media/pci/intel/ipu3/Kconfig" - # with line: - source "drivers/media/pci/intel/Kconfig" + # For kernel version v6.8 + patch/v6.8/*.patch ``` +- For kernel v6.8. patch/v6.8/0002-media-Add-IPU6-and-supported-sensors-config.patch will change the related Kconfig & Makefile. +- For latest linux-firmware repo, apply patch/linux-firmware/0001-Add-symbolic-link-for-Intel-IPU6-firmwares.patch to it to make driver work. +- Copy repo content to kernel source **(except Kconfig & Makefile at drivers/media/pci/intel and drivers/media/i2c as they are modified by patches in previous step)**. - Enable the following settings in .config ```conf CONFIG_VIDEO_INTEL_IPU6=m CONFIG_IPU_ISYS_BRIDGE=y + # For kernel >= v6.8 please use IPU_BRIDGE instead of IPU_ISYS_BRIDGE + CONFIG_IPU_BRIDGE=m CONFIG_VIDEO_OV01A1S=m CONFIG_VIDEO_OV01A10=m CONFIG_VIDEO_HM11B1=m @@ -194,13 +70,15 @@ # If your kernel < 5.15 or not set CONFIG_INTEL_SKL_INT3472, please set this # CONFIG_POWER_CTRL_LOGIC=m ``` -- LJCA and CVF part as below, please check details at https://github.com/intel/ivsc-driver/blob/main/README.md +- LJCA and CVF part as below, please check details at https://github.com/intel/ivsc-driver/blob/main/README.md. ```conf CONFIG_MFD_LJCA=m CONFIG_I2C_LJCA=m CONFIG_SPI_LJCA=m CONFIG_GPIO_LJCA=m + CONFIG_USB_LJCA=m CONFIG_INTEL_MEI_VSC=m + CONFIG_INTEL_MEI_VSC_HW=m CONFIG_INTEL_VSC=m CONFIG_INTEL_VSC_CSI=m CONFIG_INTEL_VSC_ACE=m @@ -209,8 +87,8 @@ ``` ### 2. Build outside kernel source tree - Requires kernel header installed on build machine -- Requires iVSC driver be built together -- To prepare dependency: +- For kernel >= v6.8, still need to patch kernel by patch/v6.8/0004 & 0005 to make upstream iVSC driver work correctly. For kernel <= v6.6, requires iVSC out-of-tree driver be built together. +- To prepare out-of-tree iVSC driver under kernel <= v6.6: ```sh cd ipu6-drivers git clone https://github.com/intel/ivsc-driver.git @@ -224,7 +102,7 @@ ``` ### 3. Build with dkms -- Prepare dependency: +- Prepare out-of-tree iVSC driver under kernel <= v6.6: ```sh cd ipu6-drivers git clone https://github.com/intel/ivsc-driver.git