summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Barnish <dave.barnish@arm.com>2014-03-07 13:22:56 +0000
committerDave Barnish <dave.barnish@arm.com>2014-03-25 16:37:15 +0000
commit15c001534587d5e6ab0a3c28a2681164869b2851 (patch)
tree7dee70fb9ffc75b614bae9d03ffc1d3890c69df4
parent1982d70faeb33d58d5327057b0748913d769ab7a (diff)
Fallback to 24 bit depth if 32 bit depth is not supported.
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
-rw-r--r--src/armsoc_dumb.c25
1 files 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;