diff options
author | Jason Ekstrand <[email protected]> | 2017-08-16 11:54:11 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-09-14 14:47:39 -0700 |
commit | 8824141b8d48d9120ddbf542d6fb661046c41c62 (patch) | |
tree | 1a66a913fabdc536e3bc96c3b0a88684dcef4ff7 /src/gbm/backends | |
parent | 0a25a417ce9b9c7e500baeabade87bd1114ac2a8 (diff) |
gbm: Add a gbm_device_get_format_modifier_plane_count function
This allows the user to query the number of planes required by a given
format+modifier combination without having to create a bo or surface.
Reviewed-by: Emil Velikov <[email protected]>
Reviewed-by: Daniel Stone <[email protected]>
Diffstat (limited to 'src/gbm/backends')
-rw-r--r-- | src/gbm/backends/dri/gbm_dri.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 46285245658..0a4853bf63d 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -640,6 +640,30 @@ gbm_dri_is_format_supported(struct gbm_device *gbm, } static int +gbm_dri_get_format_modifier_plane_count(struct gbm_device *gbm, + uint32_t format, + uint64_t modifier) +{ + struct gbm_dri_device *dri = gbm_dri_device(gbm); + uint64_t plane_count; + + if (dri->image->base.version < 16 || + !dri->image->queryDmaBufFormatModifierAttribs) + return -1; + + format = gbm_format_canonicalize(format); + if (gbm_format_to_dri_format(format) == 0) + return -1; + + if (!dri->image->queryDmaBufFormatModifierAttribs( + dri->screen, format, modifier, + __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT, &plane_count)) + return -1; + + return plane_count; +} + +static int gbm_dri_bo_write(struct gbm_bo *_bo, const void *buf, size_t count) { struct gbm_dri_bo *bo = gbm_dri_bo(_bo); @@ -1350,6 +1374,8 @@ dri_device_create(int fd) dri->base.bo_map = gbm_dri_bo_map; dri->base.bo_unmap = gbm_dri_bo_unmap; dri->base.is_format_supported = gbm_dri_is_format_supported; + dri->base.get_format_modifier_plane_count = + gbm_dri_get_format_modifier_plane_count; dri->base.bo_write = gbm_dri_bo_write; dri->base.bo_get_fd = gbm_dri_bo_get_fd; dri->base.bo_get_planes = gbm_dri_bo_get_planes; |