diff options
author | Simon Ser <contact@emersion.fr> | 2019-05-26 17:45:21 +0300 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-06-07 09:06:11 -0400 |
commit | d201fc3506f70f5417b6dc00c8093c14db80b52a (patch) | |
tree | cf46cf6bbcf600eaaa5f3431aa9d983ba5d21bde /backend/drm | |
parent | e8057bb60c4666d73ec776fa8f37ef4858c18fbe (diff) |
backend/drm: add support for multiplanar BOs
Diffstat (limited to 'backend/drm')
-rw-r--r-- | backend/drm/util.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/backend/drm/util.c b/backend/drm/util.c index 263f5a92..5d4d7ae1 100644 --- a/backend/drm/util.c +++ b/backend/drm/util.c @@ -190,12 +190,20 @@ uint32_t get_fb_for_bo(struct gbm_bo *bo, uint32_t drm_format, int fd = gbm_device_get_fd(gbm); uint32_t width = gbm_bo_get_width(bo); uint32_t height = gbm_bo_get_height(bo); - uint32_t handles[4] = {gbm_bo_get_handle(bo).u32}; - uint32_t strides[4] = {gbm_bo_get_stride(bo)}; - uint32_t offsets[4] = {gbm_bo_get_offset(bo, 0)}; + + uint32_t handles[4] = {0}; + uint32_t strides[4] = {0}; + uint32_t offsets[4] = {0}; + uint64_t modifiers[4] = {0}; + for (int i = 0; i < gbm_bo_get_plane_count(bo); i++) { + handles[i] = gbm_bo_get_handle_for_plane(bo, i).u32; + strides[i] = gbm_bo_get_stride_for_plane(bo, i); + offsets[i] = gbm_bo_get_offset(bo, i); + // KMS requires all BO planes to have the same modifier + modifiers[i] = gbm_bo_get_modifier(bo); + } if (with_modifiers && gbm_bo_get_modifier(bo) != DRM_FORMAT_MOD_INVALID) { - uint64_t modifiers[4] = {gbm_bo_get_modifier(bo)}; if (drmModeAddFB2WithModifiers(fd, width, height, drm_format, handles, strides, offsets, modifiers, &id, DRM_MODE_FB_MODIFIERS)) { wlr_log_errno(WLR_ERROR, "Unable to add DRM framebuffer"); |