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

drm: add support modifiers for drivers whose planes only support linear layout

The LINEAR modifier is advertised as default if a driver doesn't specify
modifiers.

v2:
- rebase to the latest master branch (5.16.0+)
+ "drm/plane: Make format_mod_supported truly optional" patch [1]
[1] https://patchwork.freedesktop.org/patch/467940/?series=98255&rev=3

v3:
- change the order as follows:
1. add fb_modifiers_not_supported flag
2. add default modifiers
3. remove allow_fb_modifiers flag

v5:
- change default_modifiers array from non-static to static
- remove terminator in default_modifiers array
- use ARRAY_SIZE to get the format_modifier_count
- update sanity check in plane init func to use the
fb_modifiers_not_supported
- modify kernel docs

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20220128060836.11216-3-etom@igel.co.jp

authored by

Tomohito Esaki and committed by
Daniel Vetter
8be57683 2af10429

+16 -10
+13 -10
drivers/gpu/drm/drm_plane.c
··· 237 237 const char *name, va_list ap) 238 238 { 239 239 struct drm_mode_config *config = &dev->mode_config; 240 + static const uint64_t default_modifiers[] = { 241 + DRM_FORMAT_MOD_LINEAR, 242 + }; 240 243 unsigned int format_modifier_count = 0; 241 244 int ret; 242 245 ··· 280 277 281 278 while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID) 282 279 format_modifier_count++; 280 + } else { 281 + if (!dev->mode_config.fb_modifiers_not_supported) { 282 + format_modifiers = default_modifiers; 283 + format_modifier_count = ARRAY_SIZE(default_modifiers); 284 + } 283 285 } 284 286 285 287 /* autoset the cap and check for consistency across all planes */ 286 - if (format_modifier_count) { 287 - drm_WARN_ON(dev, !config->allow_fb_modifiers && 288 - !list_empty(&config->plane_list)); 289 - config->allow_fb_modifiers = true; 290 - } else { 291 - drm_WARN_ON(dev, config->allow_fb_modifiers); 292 - } 288 + drm_WARN_ON(dev, config->fb_modifiers_not_supported && 289 + format_modifier_count); 293 290 294 291 plane->modifier_count = format_modifier_count; 295 292 plane->modifiers = kmalloc_array(format_modifier_count, ··· 344 341 drm_object_attach_property(&plane->base, config->prop_src_h, 0); 345 342 } 346 343 347 - if (config->allow_fb_modifiers) 344 + if (format_modifier_count) 348 345 create_in_format_blob(dev, plane); 349 346 350 347 return 0; ··· 371 368 * drm_universal_plane_init() to let the DRM managed resource infrastructure 372 369 * take care of cleanup and deallocation. 373 370 * 374 - * Drivers supporting modifiers must set @format_modifiers on all their planes, 375 - * even those that only support DRM_FORMAT_MOD_LINEAR. 371 + * Drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set 372 + * @format_modifiers to NULL. The plane will advertise the linear modifier. 376 373 * 377 374 * Returns: 378 375 * Zero on success, error code on failure.
+3
include/drm/drm_plane.h
··· 803 803 * 804 804 * The @drm_plane_funcs.destroy hook must be NULL. 805 805 * 806 + * Drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set 807 + * @format_modifiers to NULL. The plane will advertise the linear modifier. 808 + * 806 809 * Returns: 807 810 * Pointer to new plane, or ERR_PTR on failure. 808 811 */