summaryrefslogtreecommitdiff
path: root/hw/xfree86
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2018-03-29 01:07:25 -0400
committerAdam Jackson <ajax@redhat.com>2018-04-02 14:58:52 -0400
commitce7d5087cfe1d2df756d93b7f567b3c0b0a7f6a8 (patch)
tree354237f7f64f474fee97ade100f5131771da2159 /hw/xfree86
parent85b3fc18606e56d01734defb0e9fa04182f9fc1c (diff)
modesetting: Ignore alpha channel when importing BOs for modesetting
Fixes a regression caused by modifiers support. For some hw to continue working even if not supporting ARGB8888 and ARGB2101010 formats, we assume that all imported BOs are opaque. Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com> Tested-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'hw/xfree86')
-rw-r--r--hw/xfree86/drivers/modesetting/drmmode_display.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 03d2fa226..09eec0814 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -70,12 +70,28 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
}
+static uint32_t
+get_opaque_format(uint32_t format)
+{
+ switch (format) {
+ case DRM_FORMAT_ARGB8888:
+ return DRM_FORMAT_XRGB8888;
+ case DRM_FORMAT_ARGB2101010:
+ return DRM_FORMAT_XRGB2101010;
+ default:
+ return format;
+ }
+}
+
Bool
drmmode_is_format_supported(ScrnInfoPtr scrn, uint32_t format, uint64_t modifier)
{
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
int c, i, j;
+ /* BO are imported as opaque surface, so let's pretend there is no alpha */
+ format = get_opaque_format(format);
+
for (c = 0; c < xf86_config->num_crtc; c++) {
xf86CrtcPtr crtc = xf86_config->crtc[c];
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
@@ -123,6 +139,9 @@ get_modifiers_set(ScrnInfoPtr scrn, uint32_t format, uint64_t **modifiers,
int c, i, j, k, count_modifiers = 0;
uint64_t *tmp, *ret = NULL;
+ /* BOs are imported as opaque surfaces, so pretend the same thing here */
+ format = get_opaque_format(format);
+
*modifiers = NULL;
for (c = 0; c < xf86_config->num_crtc; c++) {
xf86CrtcPtr crtc = xf86_config->crtc[c];
@@ -684,6 +703,7 @@ drmmode_bo_import(drmmode_ptr drmmode, drmmode_bo *bo,
memset(modifiers, 0, sizeof(modifiers));
format = gbm_bo_get_format(bo->gbm);
+ format = get_opaque_format(format);
for (i = 0; i < num_fds; i++) {
handles[i] = gbm_bo_get_handle_for_plane(bo->gbm, i).u32;
strides[i] = gbm_bo_get_stride_for_plane(bo->gbm, i);