File 0027-ov08x40-fix-build-against-kernel-6.8.patch of Package intel-ipu6

From: You-Sheng Yang <vicamo.yang@canonical.com>
Date: Tue, 25 Jun 2024 21:50:04 +0800
Subject: ov08x40: fix build against kernel < 6.8

BugLink: https://bugs.launchpad.net/bugs/2060101
Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com>
---
 drivers/media/i2c/ov08x40.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index 14bb46b..486c58f 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -8,6 +8,7 @@
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/pm_runtime.h>
+#include <linux/version.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-fwnode.h>
@@ -1447,7 +1448,11 @@ static int ov08x40_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 	const struct ov08x40_mode *default_mode = &supported_modes[0];
 	struct ov08x40 *ov08x = to_ov08x40(sd);
 	struct v4l2_mbus_framefmt *try_fmt =
+#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_lock(&ov08x->mutex);
 
@@ -1702,7 +1707,12 @@ static int ov08x40_do_get_pad_format(struct ov08x40 *ov08x,
 	struct v4l2_mbus_framefmt *framefmt;
 
 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 8, 0)
+		framefmt = v4l2_subdev_get_try_format(&ov08x->sd, sd_state,
+						      fmt->pad);
+#else
 		framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad);
+#endif
 		fmt->format = *framefmt;
 	} else {
 		ov08x40_update_pad_format(ov08x->cur_mode, fmt);
@@ -1752,7 +1762,11 @@ ov08x40_set_pad_format(struct v4l2_subdev *sd,
 				      fmt->format.width, fmt->format.height);
 	ov08x40_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, sd_state, fmt->pad);
+#else
 		framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad);
+#endif
 		*framefmt = fmt->format;
 	} else {
 		ov08x->cur_mode = mode;
openSUSE Build Service is sponsored by