From 7e003296bbf3377738bcc9dbab218045b71bb56b Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Thu, 17 Oct 2024 11:39:32 +0100 Subject: [PATCH] media: camera: Fix build for Linux v6.8+ In Linux v6.8, the 'g_frame_interval' and 's_frame_interval' function pointers were removed from the 'v4l2_subdev_video_ops' structure and replaced by 'get_frame_interval' and 'set_frame_interval' that were added to the 'v4l2_subdev_pad_ops' structure. This change was previously fixed for the Tegra CSI driver by adding the necessary conftest changes. A new update to the Tegra Cam V4L2 causes the build to fail for Linux v6.8+ kernels because of the same issue. Fix up the Tegra Cam V4L2 driver in the same way as the Tegra CSI driver, but update the name of the conftest test to indicate that this is applicable for both the 'get_frame_interval' and 'set_frame_interval' function pointers. Bug 4448428 Bug 4807063 Change-Id: Ica47f3aaece0bf81e2adc3c431056ea51b64a893 Signed-off-by: Jon Hunter (cherry picked from commit 91416b264c19dc49a1aae3d622ad6f0c96f4f6c3) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3284192 Reviewed-by: Amulya Yarlagadda Tested-by: Amulya Yarlagadda GVS: buildbot_gerritrpt --- drivers/media/platform/tegra/camera/csi/csi.c | 11 +++++----- .../platform/tegra/camera/tegracam_v4l2.c | 20 +++++++++++++++---- scripts/conftest/Makefile | 2 +- scripts/conftest/conftest.sh | 8 +++++--- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/tegra/camera/csi/csi.c b/drivers/media/platform/tegra/camera/csi/csi.c index fae679f5..7e3dfb3a 100644 --- a/drivers/media/platform/tegra/camera/csi/csi.c +++ b/drivers/media/platform/tegra/camera/csi/csi.c @@ -1,8 +1,7 @@ -// SPDX-License-Identifier: GPL-2.0 +// SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: Copyright (c) 2015-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. /* * NVIDIA Tegra CSI Device - * - * Copyright (c) 2015-2024, NVIDIA CORPORATION. All rights reserved. */ #include @@ -687,7 +686,7 @@ static int tegra_csi_set_format(struct v4l2_subdev *subdev, } static int tegra_csi_g_frame_interval(struct v4l2_subdev *sd, -#if defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_FRAME_INTERVAL) +#if defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_SET_FRAME_INTERVAL) struct v4l2_subdev_state *sd_state, #endif struct v4l2_subdev_frame_interval *vfi) @@ -721,13 +720,13 @@ static int tegra_csi_enum_mbus_code(struct v4l2_subdev *sd, static struct v4l2_subdev_video_ops tegra_csi_video_ops = { .s_stream = tegra_csi_s_stream, .g_input_status = tegra_csi_g_input_status, -#if !defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_FRAME_INTERVAL) +#if !defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_SET_FRAME_INTERVAL) .g_frame_interval = tegra_csi_g_frame_interval, #endif }; static struct v4l2_subdev_pad_ops tegra_csi_pad_ops = { -#if defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_FRAME_INTERVAL) +#if defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_SET_FRAME_INTERVAL) .get_frame_interval = tegra_csi_g_frame_interval, #endif .get_fmt = tegra_csi_get_format, diff --git a/drivers/media/platform/tegra/camera/tegracam_v4l2.c b/drivers/media/platform/tegra/camera/tegracam_v4l2.c index 28ef43fd..a5748c23 100644 --- a/drivers/media/platform/tegra/camera/tegracam_v4l2.c +++ b/drivers/media/platform/tegra/camera/tegracam_v4l2.c @@ -1,9 +1,11 @@ -// SPDX-License-Identifier: GPL-2.0 +// SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. /* * tegracam_v4l2 - tegra camera framework for v4l2 support - * - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. */ + +#include + #include #include #include @@ -112,7 +114,11 @@ static int v4l2sd_g_input_status(struct v4l2_subdev *sd, u32 *status) return 0; } -static int cam_g_frame_interval(struct v4l2_subdev *sd, struct v4l2_subdev_frame_interval *ival) +static int cam_g_frame_interval(struct v4l2_subdev *sd, +#if defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_SET_FRAME_INTERVAL) + struct v4l2_subdev_state *sd_state, +#endif + struct v4l2_subdev_frame_interval *ival) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct camera_common_data *s_data = to_camera_common_data(&client->dev); @@ -128,8 +134,10 @@ static int cam_g_frame_interval(struct v4l2_subdev *sd, struct v4l2_subdev_frame static struct v4l2_subdev_video_ops v4l2sd_video_ops = { .s_stream = v4l2sd_stream, .g_input_status = v4l2sd_g_input_status, +#if !defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_SET_FRAME_INTERVAL) .g_frame_interval = cam_g_frame_interval, .s_frame_interval = cam_g_frame_interval, +#endif }; static struct v4l2_subdev_core_ops v4l2sd_core_ops = { @@ -176,6 +184,10 @@ static int v4l2sd_set_fmt(struct v4l2_subdev *sd, } static struct v4l2_subdev_pad_ops v4l2sd_pad_ops = { +#if defined(NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_SET_FRAME_INTERVAL) + .get_frame_interval = cam_g_frame_interval, + .set_frame_interval = cam_g_frame_interval, +#endif .set_fmt = v4l2sd_set_fmt, .get_fmt = v4l2sd_get_fmt, .enum_mbus_code = camera_common_enum_mbus_code, diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 6aa86ae9..402c5f8c 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -181,7 +181,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += v4l2_async_subdev_nf_init NV_CONFTEST_FUNCTION_COMPILE_TESTS += v4l2_async_notifier_init NV_CONFTEST_FUNCTION_COMPILE_TESTS += v4l2_async_nf_init_has_v4l2_dev_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += __v4l2_async_nf_add_subdev -NV_CONFTEST_FUNCTION_COMPILE_TESTS += v4l2_subdev_pad_ops_struct_has_get_frame_interval +NV_CONFTEST_FUNCTION_COMPILE_TESTS += v4l2_subdev_pad_ops_struct_has_get_set_frame_interval NV_CONFTEST_FUNCTION_COMPILE_TESTS += v4l2_subdev_pad_ops_struct_has_dv_timings NV_CONFTEST_FUNCTION_COMPILE_TESTS += vm_area_struct_has_const_vm_flags NV_CONFTEST_GENERIC_COMPILE_TESTS += is_export_symbol_present_drm_gem_prime_fd_to_handle diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 60486c88..2346a86e 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -8082,10 +8082,12 @@ compile_test() { compile_check_conftest "$CODE" "NV_V4L2_ASYNC_NF_ADD_SUBDEV_PRESENT" "" "functions" ;; - v4l2_subdev_pad_ops_struct_has_get_frame_interval) + v4l2_subdev_pad_ops_struct_has_get_set_frame_interval) # # Determine if struct v4l2_subdev_pad_ops has the 'get_frame_interval' - # function pointer. + # and 'set_frame_interval' function pointers. Note that it is only + # necessary to check for the presence of one because both were added + # by the same commit. # # Added by commit 287fe160834a ("media: v4l2-subdev: Turn # .[gs]_frame_interval into pad operations") in Linux v6.8. @@ -8098,7 +8100,7 @@ compile_test() { } " compile_check_conftest "$CODE" \ - "NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_FRAME_INTERVAL" "" "types" + "NV_V4L2_SUBDEV_PAD_OPS_STRUCT_HAS_GET_SET_FRAME_INTERVAL" "" "types" ;; v4l2_subdev_pad_ops_struct_has_dv_timings)