diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index b602361d..886f004e 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -216,11 +216,17 @@ bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer); int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer, struct tegra_bo_tiling *tiling); struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, +#if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG) /* Linux v6.17 */ + const struct drm_format_info *info, +#endif const struct drm_mode_fb_cmd2 *mode_cmd, struct tegra_bo **planes, unsigned int num_planes); struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, struct drm_file *file, +#if defined(NV_DRM_MODE_CONFIG_FUNCS_STRUCT_FB_CREATE_HAS_INFO_ARG) /* Linux v6.17 */ + const struct drm_format_info *info, +#endif const struct drm_mode_fb_cmd2 *cmd); #if defined(NV_DRM_DRIVER_HAS_FBDEV_PROBE) /* Linux v6.13 */ diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index 46170753..2e466213 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -102,6 +102,9 @@ static const struct drm_framebuffer_funcs tegra_fb_funcs = { }; struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, +#if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG) /* Linux v6.17 */ + const struct drm_format_info *info, +#endif const struct drm_mode_fb_cmd2 *mode_cmd, struct tegra_bo **planes, unsigned int num_planes) @@ -114,7 +117,11 @@ struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, if (!fb) return ERR_PTR(-ENOMEM); +#if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG) /* Linux v6.17 */ + drm_helper_mode_fill_fb_struct(drm, fb, info, mode_cmd); +#else drm_helper_mode_fill_fb_struct(drm, fb, mode_cmd); +#endif for (i = 0; i < fb->format->num_planes; i++) fb->obj[i] = &planes[i]->gem; @@ -132,9 +139,14 @@ struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm, struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, struct drm_file *file, +#if defined(NV_DRM_MODE_CONFIG_FUNCS_STRUCT_FB_CREATE_HAS_INFO_ARG) /* Linux v6.17 */ + const struct drm_format_info *info, +#endif const struct drm_mode_fb_cmd2 *cmd) { +#if !defined(NV_DRM_MODE_CONFIG_FUNCS_STRUCT_FB_CREATE_HAS_INFO_ARG) /* Linux v6.17 */ const struct drm_format_info *info = drm_get_format_info(drm, cmd); +#endif struct tegra_bo *planes[4]; struct drm_gem_object *gem; struct drm_framebuffer *fb; @@ -166,7 +178,11 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, planes[i] = to_tegra_bo(gem); } +#if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG) /* Linux v6.17 */ + fb = tegra_fb_alloc(drm, info, cmd, planes, i); +#else fb = tegra_fb_alloc(drm, cmd, planes, i); +#endif if (IS_ERR(fb)) { err = PTR_ERR(fb); goto unreference; diff --git a/drivers/gpu/drm/tegra/fbdev.c b/drivers/gpu/drm/tegra/fbdev.c index 87cffafc..f7865dd5 100644 --- a/drivers/gpu/drm/tegra/fbdev.c +++ b/drivers/gpu/drm/tegra/fbdev.c @@ -134,7 +134,11 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper, return PTR_ERR(info); } - fb = tegra_fb_alloc(drm, &cmd, &bo, 1); + fb = tegra_fb_alloc(drm, +#if defined(NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG) /* Linux v6.17 */ + drm_get_format_info(drm, cmd.pixel_format, cmd.modifier[0]), +#endif + &cmd, &bo, 1); if (IS_ERR(fb)) { err = PTR_ERR(fb); dev_err(drm->dev, "failed to allocate DRM framebuffer: %d\n", diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index de77aacc..b61a0133 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -139,7 +139,9 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_alloc_info NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_fb_helper_prepare_has_preferred_bpp_arg 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_helper_mode_fill_fb_struct_has_info_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_mode_config_struct_has_fb_base_arg +NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_mode_config_funcs_struct_fb_create_has_info_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_plane_helper_funcs_struct_atomic_async_check_has_bool_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_scdc_get_set_has_struct_drm_connector_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_keee_struct_present diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index c8b9c10d..b0612000 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7442,6 +7442,27 @@ compile_test() { compile_check_conftest "$CODE" "NV_DRM_FB_HELPER_UNREGISTER_INFO_PRESENT" "" "functions" ;; + drm_helper_mode_fill_fb_struct_has_info_arg) + # + # Determine if the function 'drm_helper_mode_fill_fb_struct' has the + # argument 'info'. + # + # Commit a34cc7bf1034 ("drm: Allow the caller to pass in the format + # info to drm_helper_mode_fill_fb_struct()") made this change in + # Linux v6.17. + # + CODE=" + #undef CONFIG_ACPI + #include + void conftest(struct drm_device *dev, struct drm_framebuffer *fb, + const struct drm_format_info *info, + const struct drm_mode_fb_cmd2 *mode_cmd) { + drm_helper_mode_fill_fb_struct(dev, fb, info, mode_cmd); + }" + + compile_check_conftest "$CODE" "NV_DRM_HELPER_MODE_FILL_FB_STRUCT_HAS_INFO_ARG" "" "types" + ;; + drm_mode_config_struct_has_fb_base_arg) # # Determine if the 'drm_mode_config' structure has the 'fb_base' argument. @@ -7458,6 +7479,24 @@ compile_test() { compile_check_conftest "$CODE" "NV_DRM_MODE_CONFIG_STRUCT_HAS_FB_BASE_ARG" "" "types" ;; + drm_mode_config_funcs_struct_fb_create_has_info_arg) + # + # Determine if the 'fb_create' function pointer has an 'info' argument. + # + # Commit 81112eaac559 ("drm: Pass the format info to .fb_create()") + # made this change in Linux v6.17. + # + CODE=" + #include + void conftest(struct drm_mode_config_funcs *f) { + struct drm_framebuffer *(*fn)(struct drm_device *, struct drm_file *, + const struct drm_format_info *, + const struct drm_mode_fb_cmd2 *) = f->fb_create; + }" + + compile_check_conftest "$CODE" "NV_DRM_MODE_CONFIG_FUNCS_STRUCT_FB_CREATE_HAS_INFO_ARG" "" "types" + ;; + drm_plane_helper_funcs_struct_atomic_async_check_has_bool_arg) # # Determine if the 'atomic_async_check' function pointer has a bool argument.