backend-drm: default to XRGB2101010 for HDR

Trying to do HDR with XRGB8888 is a bit like using RGB565 on SDR: you
get visible color quantization and banding in gradients (without dithering
which Weston does not implement yet, and might not work too well for HDR
anyway).

Therefore, on any HDR mode, default output framebuffer format to 10 bpc
instead of 8 bpc.

Ideally we'd also optionally try 16F or 16 bpc formats, but automatic
fallbacks for those are more complicated to arrange. You can still
configure 16F or 16 bpc manually.

This patch also moves the default format setting from
drm_output_set_gbm_format() to drm_output_enable(), because setting the
default now requires eotf_mode. Frontends may call set_gbm_format()
first and set eotf_mode next. This does create an awkward situation for
outputs that a frontend disables and re-enables. This patch here makes
sure that the old output configuration remains, but changing eotf_mode
may not change the default format. One needs to call
set_gbm_format(NULL) to re-evaluate the default format. Resetting the
format on drm_output_deinit() would lose the current setting.

DRM_FORMAT_INVALID was introduced in libdrm 2.4.95 which we already
hard-depend on.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 3 years ago committed by Pekka Paalanen
parent 33d553f833
commit e6a9e3c4ee
  1. 14
      libweston/backend-drm/drm.c
  2. 7
      man/weston-drm.man

@ -1416,10 +1416,10 @@ drm_output_set_gbm_format(struct weston_output *base,
const char *gbm_format) const char *gbm_format)
{ {
struct drm_output *output = to_drm_output(base); struct drm_output *output = to_drm_output(base);
struct drm_backend *b = to_drm_backend(base->compositor);
if (parse_gbm_format(gbm_format, b->gbm_format, &output->gbm_format) == -1) if (parse_gbm_format(gbm_format,
output->gbm_format = b->gbm_format; DRM_FORMAT_INVALID, &output->gbm_format) == -1)
output->gbm_format = DRM_FORMAT_INVALID;
} }
static void static void
@ -1855,6 +1855,13 @@ drm_output_enable(struct weston_output *base)
assert(!output->virtual); assert(!output->virtual);
if (output->gbm_format == DRM_FORMAT_INVALID) {
if (output->base.eotf_mode != WESTON_EOTF_MODE_SDR)
output->gbm_format = DRM_FORMAT_XRGB2101010;
else
output->gbm_format = b->gbm_format;
}
ret = drm_output_attach_crtc(output); ret = drm_output_attach_crtc(output);
if (ret < 0) if (ret < 0)
return -1; return -1;
@ -2301,6 +2308,7 @@ drm_output_create(struct weston_compositor *compositor, const char *name)
output->backend = b; output->backend = b;
output->crtc = NULL; output->crtc = NULL;
output->gbm_format = DRM_FORMAT_INVALID;
#ifdef BUILD_DRM_GBM #ifdef BUILD_DRM_GBM
output->gbm_bo_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; output->gbm_bo_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
#endif #endif

@ -57,7 +57,8 @@ The actually supported pixel formats depend on the DRM driver and hardware,
and the renderer used. Using Pixman-renderer, DRM-backend supports only and the renderer used. Using Pixman-renderer, DRM-backend supports only
.BR xrgb8888 " and " rgb565 . .BR xrgb8888 " and " rgb565 .
The formats supported with GL-renderer depend on the EGL and OpenGL ES 2 or 3 The formats supported with GL-renderer depend on the EGL and OpenGL ES 2 or 3
implementations. The names are case-insensitive. implementations. The names are case-insensitive. This setting applies only to
.RB "outputs in SDR mode, see " eotf-mode " in " weston.ini (5).
.RB "If not specified, " xrgb8888 " is used. See also " gbm-format " in" .RB "If not specified, " xrgb8888 " is used. See also " gbm-format " in"
.BR output " section." .BR output " section."
@ -134,9 +135,11 @@ and possibly flipped. Possible values are
.TP .TP
\fBgbm-format\fR=\fIformat\fR \fBgbm-format\fR=\fIformat\fR
Set the DRM KMS framebuffer format for this specific output. If not set, Set the DRM KMS framebuffer format for this specific output. If not set,
.RB "the value from " gbm-format " option in " core " section is used." .RB "the value from " gbm-format " option in " core " section is used"
.RB "for SDR mode outputs and " xrgb2101010 " for other modes."
.RI "For the possible values for " format " see " .RI "For the possible values for " format " see "
.BR gbm-format " option in " core " section." .BR gbm-format " option in " core " section."
.RB "For SDR mode, see " eotf-mode " in " weston.ini (7).
.TP .TP
\fBpixman-shadow\fR=\fIboolean\fR \fBpixman-shadow\fR=\fIboolean\fR
If using the Pixman-renderer, use shadow framebuffers. Defaults to If using the Pixman-renderer, use shadow framebuffers. Defaults to

Loading…
Cancel
Save