Commit 83dae7e1 authored by Eugeniy Paltsev's avatar Eugeniy Paltsev

compositor-drm: check capabilities before gbm modifiers setup

Commit 244244d1 ("compositor-drm: Use GBM modifier API")
force using of fb modifiers without runtime check.

As some modeset drivers don't support fb modifiers that
may lead to following error during weston initialization:
-------------------->8-------------------------
failed to create kms fb: No such file or directory
failed to get drm_fb for bo
-------------------->8-------------------------

Fix it by checking DRM_CAP_ADDFB2_MODIFIERS capability and rollback
to legacy (non gbm modifiers) codepath if required.

Fixes: 244244d1 ("compositor-drm: Use GBM modifier API")
Signed-off-by: 's avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Eugeniy Paltsev's avatarEugeniy Paltsev <PaltsevEvgeniy@gmail.com>
parent f709d220
Pipeline #7183 passed with stage
in 4 minutes and 31 seconds
...@@ -1239,14 +1239,42 @@ err_free: ...@@ -1239,14 +1239,42 @@ err_free:
return NULL; return NULL;
} }
static void
drm_fb_setup_gbm_modifier(struct gbm_bo *bo, struct drm_backend *backend,
struct drm_fb *fb)
{
#ifdef HAVE_GBM_MODIFIERS
uint64_t cap;
int ret, i;
ret = drmGetCap(backend->drm.fd, DRM_CAP_ADDFB2_MODIFIERS, &cap);
if (ret != 0 || cap != 1)
goto no_gbm_modifiers;
fb->modifier = gbm_bo_get_modifier(bo);
fb->num_planes = gbm_bo_get_plane_count(bo);
for (i = 0; i < fb->num_planes; i++) {
fb->strides[i] = gbm_bo_get_stride_for_plane(bo, i);
fb->handles[i] = gbm_bo_get_handle_for_plane(bo, i).u32;
fb->offsets[i] = gbm_bo_get_offset(bo, i);
}
return;
no_gbm_modifiers:
#endif
fb->num_planes = 1;
fb->strides[0] = gbm_bo_get_stride(bo);
fb->handles[0] = gbm_bo_get_handle(bo).u32;
fb->modifier = DRM_FORMAT_MOD_INVALID;
}
static struct drm_fb * static struct drm_fb *
drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend, drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend,
bool is_opaque, enum drm_fb_type type) bool is_opaque, enum drm_fb_type type)
{ {
struct drm_fb *fb = gbm_bo_get_user_data(bo); struct drm_fb *fb = gbm_bo_get_user_data(bo);
#ifdef HAVE_GBM_MODIFIERS
int i;
#endif
if (fb) { if (fb) {
assert(fb->type == type); assert(fb->type == type);
...@@ -1267,27 +1295,14 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend, ...@@ -1267,27 +1295,14 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend,
fb->format = pixel_format_get_info(gbm_bo_get_format(bo)); fb->format = pixel_format_get_info(gbm_bo_get_format(bo));
fb->size = 0; fb->size = 0;
#ifdef HAVE_GBM_MODIFIERS
fb->modifier = gbm_bo_get_modifier(bo);
fb->num_planes = gbm_bo_get_plane_count(bo);
for (i = 0; i < fb->num_planes; i++) {
fb->strides[i] = gbm_bo_get_stride_for_plane(bo, i);
fb->handles[i] = gbm_bo_get_handle_for_plane(bo, i).u32;
fb->offsets[i] = gbm_bo_get_offset(bo, i);
}
#else
fb->num_planes = 1;
fb->strides[0] = gbm_bo_get_stride(bo);
fb->handles[0] = gbm_bo_get_handle(bo).u32;
fb->modifier = DRM_FORMAT_MOD_INVALID;
#endif
if (!fb->format) { if (!fb->format) {
weston_log("couldn't look up format 0x%lx\n", weston_log("couldn't look up format 0x%lx\n",
(unsigned long) gbm_bo_get_format(bo)); (unsigned long) gbm_bo_get_format(bo));
goto err_free; goto err_free;
} }
drm_fb_setup_gbm_modifier(bo, backend, fb);
/* We can scanout an ARGB buffer if the surface's opaque region covers /* We can scanout an ARGB buffer if the surface's opaque region covers
* the whole output, but we have to use XRGB as the KMS format code. */ * the whole output, but we have to use XRGB as the KMS format code. */
if (is_opaque) if (is_opaque)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment