backend/drm: improve logs in drm_fb_create

Downgrade errors to DEBUG level, because drm_fb_create is used in
test_buffer, so errors aren't always fatal. Add ERROR logs at call
sites where a failure is fatal, to make it clear something wrong
happened.
This commit is contained in:
Simon Ser 2021-04-01 21:14:38 +02:00
parent 511e42be5e
commit 1ec97bdf4f
2 changed files with 16 additions and 16 deletions

View File

@ -474,6 +474,7 @@ static bool drm_connector_commit_buffer(struct wlr_output *output) {
} }
if (!drm_fb_import(&plane->pending_fb, drm, buffer, if (!drm_fb_import(&plane->pending_fb, drm, buffer,
&crtc->primary->formats)) { &crtc->primary->formats)) {
wlr_log(WLR_ERROR, "Failed to import buffer");
return false; return false;
} }
break; break;

View File

@ -319,6 +319,9 @@ bool drm_plane_lock_surface(struct wlr_drm_plane *plane,
wlr_buffer_unlock(buf); wlr_buffer_unlock(buf);
bool ok = drm_fb_import(&plane->pending_fb, drm, local_buf, NULL); bool ok = drm_fb_import(&plane->pending_fb, drm, local_buf, NULL);
if (!ok) {
wlr_log(WLR_ERROR, "Failed to import buffer");
}
wlr_buffer_unlock(local_buf); wlr_buffer_unlock(local_buf);
return ok; return ok;
} }
@ -370,46 +373,42 @@ static struct wlr_drm_fb *drm_fb_create(struct wlr_drm_backend *drm,
struct wlr_buffer *buf, const struct wlr_drm_format_set *formats) { struct wlr_buffer *buf, const struct wlr_drm_format_set *formats) {
struct wlr_drm_fb *fb = calloc(1, sizeof(*fb)); struct wlr_drm_fb *fb = calloc(1, sizeof(*fb));
if (!fb) { if (!fb) {
wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL; return NULL;
} }
struct wlr_dmabuf_attributes attribs; struct wlr_dmabuf_attributes attribs;
if (!wlr_buffer_get_dmabuf(buf, &attribs)) { if (!wlr_buffer_get_dmabuf(buf, &attribs)) {
wlr_log(WLR_ERROR, "Failed to get DMA-BUF from buffer"); wlr_log(WLR_DEBUG, "Failed to get DMA-BUF from buffer");
goto error_get_dmabuf; goto error_get_dmabuf;
} }
if (formats && !wlr_drm_format_set_has(formats, attribs.format, if (formats && !wlr_drm_format_set_has(formats, attribs.format,
attribs.modifier)) { attribs.modifier)) {
const struct wlr_pixel_format_info *info =
drm_get_pixel_format_info(attribs.format);
if (!info) {
wlr_log(WLR_ERROR,
"Failed to fallback on DRM opaque substitute for format "
"0x%"PRIX32, attribs.format);
return false;
}
// The format isn't supported by the plane. Try stripping the alpha // The format isn't supported by the plane. Try stripping the alpha
// channel, if any. // channel, if any.
uint32_t format = info->opaque_substitute; const struct wlr_pixel_format_info *info =
if (wlr_drm_format_set_has(formats, format, attribs.modifier)) { drm_get_pixel_format_info(attribs.format);
attribs.format = format; if (info != NULL && info->opaque_substitute != DRM_FORMAT_INVALID &&
wlr_drm_format_set_has(formats, info->opaque_substitute, attribs.modifier)) {
attribs.format = info->opaque_substitute;
} else { } else {
wlr_log(WLR_ERROR, "Buffer format 0x%"PRIX32" cannot be scanned out", wlr_log(WLR_DEBUG, "Buffer format 0x%"PRIX32" with modifier "
attribs.format); "0x%"PRIX64" cannot be scanned out",
attribs.format, attribs.modifier);
goto error_get_dmabuf; goto error_get_dmabuf;
} }
} }
fb->bo = get_bo_for_dmabuf(drm->renderer.gbm, &attribs); fb->bo = get_bo_for_dmabuf(drm->renderer.gbm, &attribs);
if (!fb->bo) { if (!fb->bo) {
wlr_log(WLR_ERROR, "Failed to import DMA-BUF in GBM"); wlr_log(WLR_DEBUG, "Failed to import DMA-BUF in GBM");
goto error_get_dmabuf; goto error_get_dmabuf;
} }
fb->id = get_fb_for_bo(fb->bo, drm->addfb2_modifiers); fb->id = get_fb_for_bo(fb->bo, drm->addfb2_modifiers);
if (!fb->id) { if (!fb->id) {
wlr_log(WLR_ERROR, "Failed to import GBM BO in KMS"); wlr_log(WLR_DEBUG, "Failed to import GBM BO in KMS");
goto error_get_fb_for_bo; goto error_get_fb_for_bo;
} }