[Xf86-video-armsoc] [PATCH 1/1] Fallback to 24 bit depth if 32 bit depth is not supported.
armsoc-bugs at arm.com
armsoc-bugs at arm.com
Tue Apr 1 03:08:37 PDT 2014
From: Dave Barnish <dave.barnish at arm.com>
If the DRM does not support 32 bit depth at 32 bpp we fallback
to 24 bit depth at 32 bpp. The display controller will effectively
ignore the alpha channel.
Change-Id: Ia142aa50a1d22f6ff3d99e3b45f87273d9f6f953
---
src/armsoc_dumb.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/armsoc_dumb.c b/src/armsoc_dumb.c
index f27728c..33f9b44 100644
--- a/src/armsoc_dumb.c
+++ b/src/armsoc_dumb.c
@@ -39,6 +39,8 @@
struct armsoc_device {
int fd;
int (*create_custom_gem)(int fd, struct armsoc_create_gem *create_gem);
+ Bool alpha_supported;
+
};
struct armsoc_bo {
@@ -74,6 +76,7 @@ struct armsoc_device *armsoc_device_new(int fd,
new_dev->fd = fd;
new_dev->create_custom_gem = create_custom_gem;
+ new_dev->alpha_supported = TRUE;
return new_dev;
}
@@ -336,13 +339,29 @@ int armsoc_bo_cpu_fini(struct armsoc_bo *bo, enum armsoc_gem_op op)
int armsoc_bo_add_fb(struct armsoc_bo *bo)
{
- int ret;
+ int ret, depth = bo->depth;
assert(bo->refcnt > 0);
assert(bo->fb_id == 0);
- ret = drmModeAddFB(bo->dev->fd, bo->width, bo->height, bo->depth,
- bo->bpp, bo->pitch, bo->handle, &bo->fb_id);
+ if (bo->bpp == 32 && bo->depth == 32 && !bo->dev->alpha_supported)
+ depth = 24;
+
+ ret = drmModeAddFB(bo->dev->fd, bo->width, bo->height, depth,
+ bo->bpp, bo->pitch, bo->handle, &bo->fb_id);
+
+ if (ret < 0 && bo->bpp == 32 && bo->depth == 32 && bo->dev->alpha_supported) {
+ /* The DRM driver may not support an alpha channel but it is possible
+ * to continue by ignoring the alpha, so if an attempt to create
+ * a depth 32, bpp 32 framebuffer fails we retry with depth 24, bpp 32
+ */
+ xf86DrvMsg(-1, X_WARNING,
+ "depth 32 FB unsupported : falling back to depth 24\n");
+ bo->dev->alpha_supported = FALSE;
+ ret = drmModeAddFB(bo->dev->fd, bo->width, bo->height, 24,
+ bo->bpp, bo->pitch, bo->handle, &bo->fb_id);
+ }
+
if (ret < 0) {
bo->fb_id = 0;
return ret;
--
1.7.9.5
More information about the Xf86-video-armsoc
mailing list