drm: use IMPORT_FD for INVALID modifier

GBM_BO_IMPORT_FD_MODIFIER doesn't accept the INVALID modifier.
This commit is contained in:
Ivan Molodetskikh 2019-09-26 22:52:35 +03:00 committed by Simon Ser
parent ebeef0fbe8
commit 5f78ea20fa
1 changed files with 33 additions and 18 deletions

View File

@ -1,4 +1,5 @@
#include <assert.h>
#include <drm_fourcc.h>
#include <gbm.h>
#include <stdbool.h>
#include <stdlib.h>
@ -165,6 +166,19 @@ void post_drm_surface(struct wlr_drm_surface *surf) {
struct gbm_bo *import_gbm_bo(struct wlr_drm_renderer *renderer,
struct wlr_dmabuf_attributes *attribs) {
if (attribs->modifier == DRM_FORMAT_MOD_INVALID && attribs->n_planes == 1
&& attribs->offset[0] == 0) {
struct gbm_import_fd_data data = {
.fd = attribs->fd[0],
.width = attribs->width,
.height = attribs->height,
.stride = attribs->stride[0],
.format = attribs->format,
};
return gbm_bo_import(renderer->gbm, GBM_BO_IMPORT_FD,
&data, GBM_BO_USE_SCANOUT);
} else {
struct gbm_import_fd_modifier_data data = {
.width = attribs->width,
.height = attribs->height,
@ -185,6 +199,7 @@ struct gbm_bo *import_gbm_bo(struct wlr_drm_renderer *renderer,
return gbm_bo_import(renderer->gbm, GBM_BO_IMPORT_FD_MODIFIER,
&data, GBM_BO_USE_SCANOUT);
}
}
bool export_drm_bo(struct gbm_bo *bo, struct wlr_dmabuf_attributes *attribs) {