diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2018-10-29 14:34:52 -0400 |
---|---|---|
committer | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2018-11-06 14:34:22 -0500 |
commit | e7afb623b4fb82089c9a50c733c740522b8220bc (patch) | |
tree | 881e5747b55073c6da147abb8866df0bd4b96da6 | |
parent | 968029057192e46dd78e807b81c2aba2d7648c38 (diff) |
drm: Add drm_any_plane_has_format()
Add a function to check whether there is at least one plane that
supports a specific format and modifier combination. Drivers can
use this to reject unsupported formats/modifiers in .fb_create().
v2: Accept anyformat if the driver doesn't do planes (Eric)
s/planes_have_format/any_plane_has_format/ (Eric)
Check the modifier as well since we already have a function
that does both
v3: Don't do the check in the core since we may not know the
modifier yet, instead export the function and let drivers
call it themselves
Cc: Eric Anholt <eric@anholt.net>
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181029183453.28541-1-ville.syrjala@linux.intel.com
-rw-r--r-- | drivers/gpu/drm/drm_plane.c | 23 | ||||
-rw-r--r-- | include/drm/drm_mode_config.h | 6 | ||||
-rw-r--r-- | include/drm/drm_plane.h | 2 |
3 files changed, 31 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index 1fa98bd12003..679455e36829 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c | |||
@@ -636,6 +636,29 @@ static int __setplane_check(struct drm_plane *plane, | |||
636 | return 0; | 636 | return 0; |
637 | } | 637 | } |
638 | 638 | ||
639 | /** | ||
640 | * drm_any_plane_has_format - Check whether any plane supports this format and modifier combination | ||
641 | * @dev: DRM device | ||
642 | * @format: pixel format (DRM_FORMAT_*) | ||
643 | * @modifier: data layout modifier | ||
644 | * | ||
645 | * Returns: | ||
646 | * Whether at least one plane supports the specified format and modifier combination. | ||
647 | */ | ||
648 | bool drm_any_plane_has_format(struct drm_device *dev, | ||
649 | u32 format, u64 modifier) | ||
650 | { | ||
651 | struct drm_plane *plane; | ||
652 | |||
653 | drm_for_each_plane(plane, dev) { | ||
654 | if (drm_plane_check_pixel_format(plane, format, modifier) == 0) | ||
655 | return true; | ||
656 | } | ||
657 | |||
658 | return false; | ||
659 | } | ||
660 | EXPORT_SYMBOL(drm_any_plane_has_format); | ||
661 | |||
639 | /* | 662 | /* |
640 | * __setplane_internal - setplane handler for internal callers | 663 | * __setplane_internal - setplane handler for internal callers |
641 | * | 664 | * |
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index d643d268693e..5dbeabdbaf91 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h | |||
@@ -52,6 +52,12 @@ struct drm_mode_config_funcs { | |||
52 | * requested metadata, but most of that is left to the driver. See | 52 | * requested metadata, but most of that is left to the driver. See |
53 | * &struct drm_mode_fb_cmd2 for details. | 53 | * &struct drm_mode_fb_cmd2 for details. |
54 | * | 54 | * |
55 | * To validate the pixel format and modifier drivers can use | ||
56 | * drm_any_plane_has_format() to make sure at least one plane supports | ||
57 | * the requested values. Note that the driver must first determine the | ||
58 | * actual modifier used if the request doesn't have it specified, | ||
59 | * ie. when (@mode_cmd->flags & DRM_MODE_FB_MODIFIERS) == 0. | ||
60 | * | ||
55 | * If the parameters are deemed valid and the backing storage objects in | 61 | * If the parameters are deemed valid and the backing storage objects in |
56 | * the underlying memory manager all exist, then the driver allocates | 62 | * the underlying memory manager all exist, then the driver allocates |
57 | * a new &drm_framebuffer structure, subclassed to contain | 63 | * a new &drm_framebuffer structure, subclassed to contain |
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index 0a0834bef8bd..3701f56c3362 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h | |||
@@ -798,5 +798,7 @@ static inline struct drm_plane *drm_plane_find(struct drm_device *dev, | |||
798 | #define drm_for_each_plane(plane, dev) \ | 798 | #define drm_for_each_plane(plane, dev) \ |
799 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) | 799 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) |
800 | 800 | ||
801 | bool drm_any_plane_has_format(struct drm_device *dev, | ||
802 | u32 format, u64 modifier); | ||
801 | 803 | ||
802 | #endif | 804 | #endif |