aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlia Mirkin <imirkin@alum.mit.edu>2018-02-03 14:11:23 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2018-02-23 07:51:42 -0500
commitc20bb155c2c5acb775f68be5d84fe679687c3c1e (patch)
treefebffbe7b900db3467d757e05e939d2825918d88
parentdfe8db22372873d205c78a9fd5370b1b088a2b87 (diff)
drm/nouveau: prefer XBGR2101010 for addfb ioctl
Nouveau only exposes support for XBGR2101010. Prior to the atomic conversion, drm would pass in the wrong format in the framebuffer, but it was always ignored -- both userspace (xf86-video-nouveau) and the kernel driver agreed on the layout, so the fact that the format was wrong didn't matter. With the atomic conversion, nouveau all of a sudden started caring about the exact format, and so the previously-working code in xf86-video-nouveau no longer functioned since the (internally-assigned) format from the addfb ioctl was wrong. This change adds infrastructure to allow a drm driver to specify that it prefers the XBGR format variant for the addfb ioctl, and makes nouveau's nv50 display driver set it. (Prior gens had no support for 30bpp at all.) Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Cc: stable@vger.kernel.org # v4.10+ Acked-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20180203191123.31507-1-imirkin@alum.mit.edu
-rw-r--r--drivers/gpu/drm/drm_framebuffer.c4
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c1
-rw-r--r--include/drm/drm_drv.h1
3 files changed, 6 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 5a13ff29f4f0..c0530a1af5e3 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -121,6 +121,10 @@ int drm_mode_addfb(struct drm_device *dev,
121 r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth); 121 r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth);
122 r.handles[0] = or->handle; 122 r.handles[0] = or->handle;
123 123
124 if (r.pixel_format == DRM_FORMAT_XRGB2101010 &&
125 dev->driver->driver_features & DRIVER_PREFER_XBGR_30BPP)
126 r.pixel_format = DRM_FORMAT_XBGR2101010;
127
124 ret = drm_mode_addfb2(dev, &r, file_priv); 128 ret = drm_mode_addfb2(dev, &r, file_priv);
125 if (ret) 129 if (ret)
126 return ret; 130 return ret;
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index dd8d4352ed99..caddce88d2d8 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -4477,6 +4477,7 @@ nv50_display_create(struct drm_device *dev)
4477 nouveau_display(dev)->fini = nv50_display_fini; 4477 nouveau_display(dev)->fini = nv50_display_fini;
4478 disp->disp = &nouveau_display(dev)->disp; 4478 disp->disp = &nouveau_display(dev)->disp;
4479 dev->mode_config.funcs = &nv50_disp_func; 4479 dev->mode_config.funcs = &nv50_disp_func;
4480 dev->driver->driver_features |= DRIVER_PREFER_XBGR_30BPP;
4480 if (nouveau_atomic) 4481 if (nouveau_atomic)
4481 dev->driver->driver_features |= DRIVER_ATOMIC; 4482 dev->driver->driver_features |= DRIVER_ATOMIC;
4482 4483
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index d32b688eb346..d23dcdd1bd95 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -56,6 +56,7 @@ struct drm_printer;
56#define DRIVER_ATOMIC 0x10000 56#define DRIVER_ATOMIC 0x10000
57#define DRIVER_KMS_LEGACY_CONTEXT 0x20000 57#define DRIVER_KMS_LEGACY_CONTEXT 0x20000
58#define DRIVER_SYNCOBJ 0x40000 58#define DRIVER_SYNCOBJ 0x40000
59#define DRIVER_PREFER_XBGR_30BPP 0x80000
59 60
60/** 61/**
61 * struct drm_driver - DRM driver structure 62 * struct drm_driver - DRM driver structure