Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: Add SIZE_HINTS property for cursors

Advertize more suitable cursor sizes via the new SIZE_HINTS
plane property.

We can't really enumerate all supported cursor sizes on
the platforms where the cursor height can vary freely, so
for simplicity we'll just expose all square+POT sizes between
each platform's min and max cursor limits.

Depending on the platform this will give us one of three
results:
- 64x64,128x128,256x256,512x512
- 64x64,128x128,256x256
- 64x64

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Sameer Lattannavar <sameer.lattannavar@intel.com>
Cc: Sebastian Wick <sebastian.wick@redhat.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240318204408.9687-3-ville.syrjala@linux.intel.com
Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>

+24
+24
drivers/gpu/drm/i915/display/intel_cursor.c
··· 821 821 .format_mod_supported = intel_cursor_format_mod_supported, 822 822 }; 823 823 824 + static void intel_cursor_add_size_hints_property(struct intel_plane *plane) 825 + { 826 + struct drm_i915_private *i915 = to_i915(plane->base.dev); 827 + const struct drm_mode_config *config = &i915->drm.mode_config; 828 + struct drm_plane_size_hint hints[4]; 829 + int size, max_size, num_hints = 0; 830 + 831 + max_size = min(config->cursor_width, config->cursor_height); 832 + 833 + /* for simplicity only enumerate the supported square+POT sizes */ 834 + for (size = 64; size <= max_size; size *= 2) { 835 + if (drm_WARN_ON(&i915->drm, num_hints >= ARRAY_SIZE(hints))) 836 + break; 837 + 838 + hints[num_hints].width = size; 839 + hints[num_hints].height = size; 840 + num_hints++; 841 + } 842 + 843 + drm_plane_add_size_hints_property(&plane->base, hints, num_hints); 844 + } 845 + 824 846 struct intel_plane * 825 847 intel_cursor_plane_create(struct drm_i915_private *dev_priv, 826 848 enum pipe pipe) ··· 900 878 DRM_MODE_ROTATE_0, 901 879 DRM_MODE_ROTATE_0 | 902 880 DRM_MODE_ROTATE_180); 881 + 882 + intel_cursor_add_size_hints_property(cursor); 903 883 904 884 zpos = DISPLAY_RUNTIME_INFO(dev_priv)->num_sprites[pipe] + 1; 905 885 drm_plane_create_zpos_immutable_property(&cursor->base, zpos);