File 0013-backport-Switch-to-stream-aware-state-functions.patch of Package intel-ipu6

From: You-Sheng Yang <vicamo.yang@canonical.com>
Date: Wed, 21 Feb 2024 21:46:53 +0800
Subject: backport: Switch to stream-aware state functions

BugLink: https://bugs.launchpad.net/bug/2054516

With Linux v6.8-rcX commit bc0e8d91feec ("media: v4l: subdev: Switch to
stream-aware state functions"),
v4l2_subdev_get_try_{format,crop,compose} are renamed to
v4l2_subdev_state_get_{format,crop,compose}.

Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com>
---
 drivers/media/i2c/gc5035.c        | 8 ++++++++
 drivers/media/i2c/ov13858_intel.c | 8 ++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/gc5035.c b/drivers/media/i2c/gc5035.c
index 16bbd48..812611b 100644
--- a/drivers/media/i2c/gc5035.c
+++ b/drivers/media/i2c/gc5035.c
@@ -1497,7 +1497,11 @@ static int gc5035_set_fmt(struct v4l2_subdev *sd,
 
 	mutex_lock(&gc5035->mutex);
 	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 {
 		gc5035->cur_mode = mode;
 		h_blank = mode->hts_def - mode->width;
@@ -1522,7 +1526,11 @@ static int gc5035_get_fmt(struct v4l2_subdev *sd,
 
 	mutex_lock(&gc5035->mutex);
 	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
+#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/ov13858_intel.c b/drivers/media/i2c/ov13858_intel.c
index 8b8a3ba..b9f9ff2 100644
--- a/drivers/media/i2c/ov13858_intel.c
+++ b/drivers/media/i2c/ov13858_intel.c
@@ -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
+#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 {
@@ -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
+#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 {
openSUSE Build Service is sponsored by