]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm: Pass pixel_format+modifier to .get_format_info()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 1 Jul 2025 09:07:04 +0000 (12:07 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 16 Jul 2025 16:59:59 +0000 (19:59 +0300)
Decouple .get_format_info() from struct drm_mode_fb_cmd2 and just
pass the pixel format+modifier combo in by hand.

We may want to use .get_format_info() outside of the normal
addfb paths where we won't have a struct drm_mode_fb_cmd2, and
creating a temporary one just for this seems silly.

v2: Fix intel_fb_get_format_info() docs (Laurent)

Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Rodrigo Siqueira <siqueira@igalia.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250701090722.13645-2-ville.syrjala@linux.intel.com
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.h
drivers/gpu/drm/drm_fourcc.c
drivers/gpu/drm/i915/display/intel_fb.c
drivers/gpu/drm/i915/display/intel_fb.h
include/drm/drm_mode_config.h

index b7c6e8d13435017f1d449c5a5b85ff4a886b762d..eef51652ca3560301dcfe92c80b5a81f442a049d 100644 (file)
@@ -92,9 +92,9 @@ enum dm_micro_swizzle {
        MICRO_SWIZZLE_R = 3
 };
 
-const struct drm_format_info *amdgpu_dm_plane_get_format_info(const struct drm_mode_fb_cmd2 *cmd)
+const struct drm_format_info *amdgpu_dm_plane_get_format_info(u32 pixel_format, u64 modifier)
 {
-       return amdgpu_lookup_format_info(cmd->pixel_format, cmd->modifier[0]);
+       return amdgpu_lookup_format_info(pixel_format, modifier);
 }
 
 void amdgpu_dm_plane_fill_blending_from_plane_state(const struct drm_plane_state *plane_state,
index 615d2ab2b8034643476f81f576ca4aae976aec17..ea2619b507db733bd3727a7a000ee75e91347a3f 100644 (file)
@@ -58,7 +58,7 @@ int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
                         unsigned long possible_crtcs,
                         const struct dc_plane_cap *plane_cap);
 
-const struct drm_format_info *amdgpu_dm_plane_get_format_info(const struct drm_mode_fb_cmd2 *cmd);
+const struct drm_format_info *amdgpu_dm_plane_get_format_info(u32 pixel_format, u64 modifier);
 
 void amdgpu_dm_plane_fill_blending_from_plane_state(const struct drm_plane_state *plane_state,
                                    bool *per_pixel_alpha, bool *pre_multiplied_alpha,
index 2890e889dd15119b66ab5980bcf084385f055f5d..4b4444f6d504189b292cb9d32766a4f38bd2e708 100644 (file)
@@ -430,7 +430,8 @@ drm_get_format_info(struct drm_device *dev,
        const struct drm_format_info *info = NULL;
 
        if (dev->mode_config.funcs->get_format_info)
-               info = dev->mode_config.funcs->get_format_info(mode_cmd);
+               info = dev->mode_config.funcs->get_format_info(mode_cmd->pixel_format,
+                                                              mode_cmd->modifier[0]);
 
        if (!info)
                info = drm_format_info(mode_cmd->pixel_format);
index 79811f998e385319d5a92ba4e9bf32a570aa6efc..e221db072de23f9282f9674311550ee04780140b 100644 (file)
@@ -422,21 +422,22 @@ unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier)
 
 /**
  * intel_fb_get_format_info: Get a modifier specific format information
- * @cmd: FB add command structure
+ * @pixel_format: pixel format
+ * @modifier: modifier
  *
  * Returns:
- * Returns the format information for @cmd->pixel_format specific to @cmd->modifier[0],
+ * Returns the format information for @pixel_format specific to @modifier,
  * or %NULL if the modifier doesn't override the format.
  */
 const struct drm_format_info *
-intel_fb_get_format_info(const struct drm_mode_fb_cmd2 *cmd)
+intel_fb_get_format_info(u32 pixel_format, u64 modifier)
 {
-       const struct intel_modifier_desc *md = lookup_modifier_or_null(cmd->modifier[0]);
+       const struct intel_modifier_desc *md = lookup_modifier_or_null(modifier);
 
        if (!md || !md->formats)
                return NULL;
 
-       return lookup_format_info(md->formats, md->format_count, cmd->pixel_format);
+       return lookup_format_info(md->formats, md->format_count, pixel_format);
 }
 
 static bool plane_caps_contain_any(u8 caps, u8 mask)
index bdd76b3729578a5c1f92f593e6745e09250eb3e4..7d1267fbeee26a5a9ebe33d6f58b094871bbd822 100644 (file)
@@ -47,7 +47,7 @@ u64 *intel_fb_plane_get_modifiers(struct intel_display *display,
 bool intel_fb_plane_supports_modifier(struct intel_plane *plane, u64 modifier);
 
 const struct drm_format_info *
-intel_fb_get_format_info(const struct drm_mode_fb_cmd2 *cmd);
+intel_fb_get_format_info(u32 pixel_format, u64 modifier);
 
 bool
 intel_format_info_is_yuv_semiplanar(const struct drm_format_info *info,
index 9e524b51a001863772c08fcd51df1caa9e183c99..e971e1b8a850c9c0bd67131f1aaf6916618a1006 100644 (file)
@@ -95,7 +95,7 @@ struct drm_mode_config_funcs {
         * The format information specific to the given fb metadata, or
         * NULL if none is found.
         */
-       const struct drm_format_info *(*get_format_info)(const struct drm_mode_fb_cmd2 *mode_cmd);
+       const struct drm_format_info *(*get_format_info)(u32 pixel_format, u64 modifier);
 
        /**
         * @mode_valid: