mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
backend/drm: fallback to drmModeAddFB2
This commit is contained in:
parent
e07ffaa249
commit
e8057bb60c
5 changed files with 25 additions and 11 deletions
|
|
@ -178,7 +178,8 @@ static void free_fb(struct gbm_bo *bo, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t get_fb_for_bo(struct gbm_bo *bo, uint32_t drm_format) {
|
||||
uint32_t get_fb_for_bo(struct gbm_bo *bo, uint32_t drm_format,
|
||||
bool with_modifiers) {
|
||||
uint32_t id = (uintptr_t)gbm_bo_get_user_data(bo);
|
||||
if (id) {
|
||||
return id;
|
||||
|
|
@ -192,11 +193,18 @@ uint32_t get_fb_for_bo(struct gbm_bo *bo, uint32_t drm_format) {
|
|||
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)};
|
||||
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");
|
||||
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");
|
||||
}
|
||||
} else {
|
||||
if (drmModeAddFB2(fd, width, height, drm_format, handles, strides,
|
||||
offsets, &id, 0)) {
|
||||
wlr_log_errno(WLR_ERROR, "Unable to add DRM framebuffer");
|
||||
}
|
||||
}
|
||||
|
||||
gbm_bo_set_user_data(bo, (void *)(uintptr_t)id, free_fb);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue