Commit 8be57683 authored by Tomohito Esaki's avatar Tomohito Esaki Committed by Daniel Vetter

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: default avatarTomohito Esaki <etom@igel.co.jp>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20220128060836.11216-3-etom@igel.co.jp
parent 2af10429
...@@ -237,6 +237,9 @@ static int __drm_universal_plane_init(struct drm_device *dev, ...@@ -237,6 +237,9 @@ static int __drm_universal_plane_init(struct drm_device *dev,
const char *name, va_list ap) const char *name, va_list ap)
{ {
struct drm_mode_config *config = &dev->mode_config; struct drm_mode_config *config = &dev->mode_config;
static const uint64_t default_modifiers[] = {
DRM_FORMAT_MOD_LINEAR,
};
unsigned int format_modifier_count = 0; unsigned int format_modifier_count = 0;
int ret; int ret;
...@@ -277,16 +280,16 @@ static int __drm_universal_plane_init(struct drm_device *dev, ...@@ -277,16 +280,16 @@ static int __drm_universal_plane_init(struct drm_device *dev,
while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID) while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
format_modifier_count++; format_modifier_count++;
} else {
if (!dev->mode_config.fb_modifiers_not_supported) {
format_modifiers = default_modifiers;
format_modifier_count = ARRAY_SIZE(default_modifiers);
}
} }
/* autoset the cap and check for consistency across all planes */ /* autoset the cap and check for consistency across all planes */
if (format_modifier_count) { drm_WARN_ON(dev, config->fb_modifiers_not_supported &&
drm_WARN_ON(dev, !config->allow_fb_modifiers && format_modifier_count);
!list_empty(&config->plane_list));
config->allow_fb_modifiers = true;
} else {
drm_WARN_ON(dev, config->allow_fb_modifiers);
}
plane->modifier_count = format_modifier_count; plane->modifier_count = format_modifier_count;
plane->modifiers = kmalloc_array(format_modifier_count, plane->modifiers = kmalloc_array(format_modifier_count,
...@@ -341,7 +344,7 @@ static int __drm_universal_plane_init(struct drm_device *dev, ...@@ -341,7 +344,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
drm_object_attach_property(&plane->base, config->prop_src_h, 0); drm_object_attach_property(&plane->base, config->prop_src_h, 0);
} }
if (config->allow_fb_modifiers) if (format_modifier_count)
create_in_format_blob(dev, plane); create_in_format_blob(dev, plane);
return 0; return 0;
...@@ -368,8 +371,8 @@ static int __drm_universal_plane_init(struct drm_device *dev, ...@@ -368,8 +371,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
* drm_universal_plane_init() to let the DRM managed resource infrastructure * drm_universal_plane_init() to let the DRM managed resource infrastructure
* take care of cleanup and deallocation. * take care of cleanup and deallocation.
* *
* Drivers supporting modifiers must set @format_modifiers on all their planes, * Drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set
* even those that only support DRM_FORMAT_MOD_LINEAR. * @format_modifiers to NULL. The plane will advertise the linear modifier.
* *
* Returns: * Returns:
* Zero on success, error code on failure. * Zero on success, error code on failure.
......
...@@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev, ...@@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
* *
* The @drm_plane_funcs.destroy hook must be NULL. * The @drm_plane_funcs.destroy hook must be NULL.
* *
* Drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set
* @format_modifiers to NULL. The plane will advertise the linear modifier.
*
* Returns: * Returns:
* Pointer to new plane, or ERR_PTR on failure. * Pointer to new plane, or ERR_PTR on failure.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment