From d021a4fbae824de63e736444c86c7fabd1c54d76 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Mon, 2 Oct 2023 12:25:59 +0100 Subject: [PATCH] drm/tegra: Fix build for Linux v6.4 In Linux v6.4, the various drm_scdc_get/set functions were updated to take an argument of type 'struct drm_connector'. Add a new test to the conftest script that checks if this argument is used and use the definition created by conftest to select which version of the function is used. Bug 4221847 Change-Id: Id6b6396bbe875a0268f8fe2f68ae08f78a32c954 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2989035 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/drm/tegra/sor.c | 16 +++++++++++++++- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 23 +++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c index ed7f5bbd..629db1c4 100644 --- a/drivers/gpu/drm/tegra/sor.c +++ b/drivers/gpu/drm/tegra/sor.c @@ -2152,11 +2152,15 @@ static void tegra_sor_hdmi_disable_scrambling(struct tegra_sor *sor) static void tegra_sor_hdmi_scdc_disable(struct tegra_sor *sor) { +#if defined(NV_DRM_SCDC_GET_SET_HAS_STRUCT_DRM_CONNECTOR_ARG) /* Linux v6.4 */ + drm_scdc_set_high_tmds_clock_ratio(&sor->output.connector, false); + drm_scdc_set_scrambling(&sor->output.connector, false); +#else struct i2c_adapter *ddc = sor->output.ddc; drm_scdc_set_high_tmds_clock_ratio(ddc, false); drm_scdc_set_scrambling(ddc, false); - +#endif tegra_sor_hdmi_disable_scrambling(sor); } @@ -2180,10 +2184,15 @@ static void tegra_sor_hdmi_enable_scrambling(struct tegra_sor *sor) static void tegra_sor_hdmi_scdc_enable(struct tegra_sor *sor) { +#if defined(NV_DRM_SCDC_GET_SET_HAS_STRUCT_DRM_CONNECTOR_ARG) /* Linux v6.4 */ + drm_scdc_set_high_tmds_clock_ratio(&sor->output.connector, true); + drm_scdc_set_scrambling(&sor->output.connector, true); +#else struct i2c_adapter *ddc = sor->output.ddc; drm_scdc_set_high_tmds_clock_ratio(ddc, true); drm_scdc_set_scrambling(ddc, true); +#endif tegra_sor_hdmi_enable_scrambling(sor); } @@ -2191,9 +2200,14 @@ static void tegra_sor_hdmi_scdc_enable(struct tegra_sor *sor) static void tegra_sor_hdmi_scdc_work(struct work_struct *work) { struct tegra_sor *sor = container_of(work, struct tegra_sor, scdc.work); + +#if defined(NV_DRM_SCDC_GET_SET_HAS_STRUCT_DRM_CONNECTOR_ARG) /* Linux v6.4 */ + if (!drm_scdc_get_scrambling_status(&sor->output.connector)) { +#else struct i2c_adapter *ddc = sor->output.ddc; if (!drm_scdc_get_scrambling_status(ddc)) { +#endif DRM_DEBUG_KMS("SCDC not scrambled\n"); tegra_sor_hdmi_scdc_enable(sor); } diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index ced9110e..e707fc57 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -100,6 +100,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_prepare_has_preferred_bpp_ar NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_unregister_info NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_struct_has_info_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_mode_config_struct_has_fb_base_arg +NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_scdc_get_set_has_struct_drm_connector_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_coalesce_has_coal_and_extack_args NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_ringparam_has_ringparam_and_extack_args NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index d691d54f..4aaddbc8 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -6517,6 +6517,29 @@ compile_test() { compile_check_conftest "$CODE" "NV_DRM_MODE_CONFIG_STRUCT_HAS_FB_BASE_ARG" "" "types" ;; + drm_scdc_get_set_has_struct_drm_connector_arg) + # + # Determine if the functions drm_scdc_get_scrambling_status(), + # drm_scdc_set_scrambling() and drm_scdc_set_high_tmds_clock_ratio() + # have the 'struct drm_connector' argument. + # + # In Linux v6.4, commit 5d844091f237 ("drm/scdc-helper: Pimp SCDC debugs") + # updated these drm_scdc_get/set functions to take an argument on type + # 'struct drm_connector'. + CODE=" + #if defined(NV_DRM_DISPLAY_DRM_SCDC_HELPER_H_PRESENT) + #include + #else + #include + #endif + bool conftest_drm_scdc_get_set_has_struct_drm_connector_arg(struct drm_connector *c) { + return drm_scdc_get_scrambling_status(c); + }" + + compile_check_conftest "$CODE" \ + "NV_DRM_SCDC_GET_SET_HAS_STRUCT_DRM_CONNECTOR_ARG" "" "types" + ;; + ethtool_ops_get_set_coalesce_has_coal_and_extack_args) # # Determine if the 'get_coalesce' and 'set_coalesce' ethtool_ops