File 0022-UBUNTU-SAUCE-IPU6-skip-hwcfg-checking-for-platforms-.patch of Package intel-ipu6

From: You-Sheng Yang <vicamo.yang@canonical.com>
Date: Mon, 17 Jun 2024 15:00:39 +0800
Subject: UBUNTU: SAUCE: [IPU6] skip hwcfg checking for platforms with
 none/broken graph port nodes

This was supposed to be fix in upstream commit 5bd4edbb ("ACPI:
property: Ignore bad graph port nodes on Dell XPS 9315") that relies on
MIPI DisCo (https://www.mipi.org/specifications/disco) from v6.8
kernels. In order to address the same issue on older kernel versions, we
skip hwcfg checks for them instead.

Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com>
---
 drivers/media/i2c/hm11b1.c  | 31 ++++++++++++++++++++++++++-----
 drivers/media/i2c/ov01a10.c | 38 +++++++++++++++++++++++++++++++++-----
 drivers/media/i2c/ov01a1s.c | 31 ++++++++++++++++++++++++++-----
 3 files changed, 85 insertions(+), 15 deletions(-)

diff --git a/drivers/media/i2c/hm11b1.c b/drivers/media/i2c/hm11b1.c
index f3900d2..e61f2fb 100644
--- a/drivers/media/i2c/hm11b1.c
+++ b/drivers/media/i2c/hm11b1.c
@@ -4,6 +4,7 @@
 #include <asm/unaligned.h>
 #include <linux/acpi.h>
 #include <linux/delay.h>
+#include <linux/dmi.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
@@ -442,6 +443,20 @@ static const struct hm11b1_mode supported_modes[] = {
 	},
 };
 
+/* Fixed via MIPI DisCo since kernel v6.8 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
+static const struct dmi_system_id skip_hwcfg_check_dmi_table[] = {
+	{
+		.ident = "Dell Latitude 9420",
+		.matches = {
+			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Latitude 9420"),
+		},
+	},
+	{ }
+};
+#endif
+
 struct hm11b1 {
 	struct v4l2_subdev sd;
 	struct media_pad pad;
@@ -1201,12 +1216,18 @@ static int hm11b1_probe(struct i2c_client *client)
 	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;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
+	if (!dmi_check_system(skip_hwcfg_check_dmi_table)) {
+#endif
+		/* Check HW config */
+		ret = hm11b1_check_hwcfg(&client->dev);
+		if (ret) {
+			dev_err(&client->dev, "failed to check hwcfg: %d", ret);
+			return ret;
+		}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
 	}
+#endif
 
 	hm11b1 = devm_kzalloc(&client->dev, sizeof(*hm11b1), GFP_KERNEL);
 	if (!hm11b1)
diff --git a/drivers/media/i2c/ov01a10.c b/drivers/media/i2c/ov01a10.c
index d08fbe9..c188915 100644
--- a/drivers/media/i2c/ov01a10.c
+++ b/drivers/media/i2c/ov01a10.c
@@ -4,6 +4,7 @@
 #include <asm/unaligned.h>
 #include <linux/acpi.h>
 #include <linux/delay.h>
+#include <linux/dmi.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
@@ -278,6 +279,27 @@ static const struct ov01a10_mode supported_modes[] = {
 	},
 };
 
+/* Fixed via MIPI DisCo since kernel v6.8 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
+static const struct dmi_system_id skip_hwcfg_check_dmi_table[] = {
+	{
+		.ident = "Dell XPS 9315",
+		.matches = {
+			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "XPS 9315"),
+		},
+	},
+	{
+		.ident = "Dell XPS 9320",
+		.matches = {
+			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "XPS 9320"),
+		},
+	},
+	{ }
+};
+#endif
+
 struct ov01a10 {
 	struct v4l2_subdev sd;
 	struct media_pad pad;
@@ -1011,12 +1033,18 @@ static int ov01a10_probe(struct i2c_client *client)
 		return ret;
 #endif
 
-	/* Check HW config */
-	ret = ov01a10_check_hwcfg(&client->dev);
-	if (ret) {
-		dev_err(&client->dev, "failed to check hwcfg: %d", ret);
-		return ret;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
+	if (!dmi_check_system(skip_hwcfg_check_dmi_table)) {
+#endif
+		/* Check HW config */
+		ret = ov01a10_check_hwcfg(&client->dev);
+		if (ret) {
+			dev_err(&client->dev, "failed to check hwcfg: %d", ret);
+			return ret;
+		}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
 	}
+#endif
 
 	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..0c0d65b 100644
--- a/drivers/media/i2c/ov01a1s.c
+++ b/drivers/media/i2c/ov01a1s.c
@@ -4,6 +4,7 @@
 #include <asm/unaligned.h>
 #include <linux/acpi.h>
 #include <linux/delay.h>
+#include <linux/dmi.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
@@ -292,6 +293,20 @@ static const struct ov01a1s_mode supported_modes[] = {
 	},
 };
 
+/* Fixed via MIPI DisCo since kernel v6.8 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
+static const struct dmi_system_id skip_hwcfg_check_dmi_table[] = {
+	{
+		.ident = "Dell Latitude 9420",
+		.matches = {
+			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Latitude 9420"),
+		},
+	},
+	{ }
+};
+#endif
+
 struct ov01a1s {
 	struct v4l2_subdev sd;
 	struct media_pad pad;
@@ -1167,12 +1182,18 @@ static int ov01a1s_probe(struct i2c_client *client)
 		return ret;
 #endif
 
-	/* Check HW config */
-	ret = ov01a1s_check_hwcfg(&client->dev);
-	if (ret) {
-		dev_err(&client->dev, "failed to check hwcfg: %d", ret);
-		return ret;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
+	if (!dmi_check_system(skip_hwcfg_check_dmi_table)) {
+#endif
+		/* Check HW config */
+		ret = ov01a1s_check_hwcfg(&client->dev);
+		if (ret) {
+			dev_err(&client->dev, "failed to check hwcfg: %d", ret);
+			return ret;
+		}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
 	}
+#endif
 
 	ov01a1s = devm_kzalloc(&client->dev, sizeof(*ov01a1s), GFP_KERNEL);
 	if (!ov01a1s)
openSUSE Build Service is sponsored by