summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-05-01 17:12:29 +0100
committerDave Airlie <airlied@redhat.com>2012-05-01 17:12:29 +0100
commitd12d9ac5cae7a4287e7ba1f137209574bc0c5b17 (patch)
treeeaf596eacbe7bea7f9fd40efd3b1ed3bfa271594
parent288d197f706804194ef9977baa50d566142e2acc (diff)
modesetting: attempt to work out if we want 24 or 32bpp
the cirrus driver presents certain challenges, and this is a workaround, until we can possibly agree some sane interface for exposing this information. Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--src/driver.c18
-rw-r--r--src/drmmode_display.c47
-rw-r--r--src/drmmode_display.h10
3 files changed, 68 insertions, 7 deletions
diff --git a/src/driver.c b/src/driver.c
index fb4b410..2c9878c 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -59,10 +59,6 @@
#include "driver.h"
-#ifndef DRM_CAP_DUMB_PREFER_SHADOW
-#define DRM_CAP_DUMB_PREFER_SHADOW 4
-#endif
-
static void AdjustFrame(int scrnIndex, int x, int y, int flags);
static Bool CloseScreen(int scrnIndex, ScreenPtr pScreen);
static Bool EnterVT(int scrnIndex, int flags);
@@ -397,6 +393,8 @@ PreInit(ScrnInfoPtr pScrn, int flags)
Bool prefer_shadow = TRUE;
uint64_t value = 0;
int ret;
+ int bppflags;
+ int defaultdepth, defaultbpp;
if (pScrn->numEntities != 1)
return FALSE;
@@ -459,9 +457,16 @@ PreInit(ScrnInfoPtr pScrn, int flags)
if (ms->fd < 0)
return FALSE;
+ ms->drmmode.fd = ms->fd;
+
+ drmmode_get_default_bpp(pScrn, &ms->drmmode, &defaultdepth, &defaultbpp);
+ if (defaultdepth == 24 && defaultbpp == 24)
+ bppflags = Support24bppFb;
+ else
+ bppflags = PreferConvert24to32 | SupportConvert24to32 | Support32bppFb;
+
if (!xf86SetDepthBpp
- (pScrn, 0, 0, 0,
- PreferConvert24to32 | SupportConvert24to32 | Support32bppFb))
+ (pScrn, defaultdepth, defaultdepth, defaultbpp, bppflags))
return FALSE;
switch (pScrn->depth) {
@@ -501,7 +506,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
ms->drmmode.shadow_enable = xf86ReturnOptValBool(ms->Options, OPTION_SHADOW_FB, prefer_shadow);
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ShadowFB: preferred %s, enabled %s\n", prefer_shadow ? "YES" : "NO", ms->drmmode.shadow_enable ? "YES" : "NO");
- ms->drmmode.fd = ms->fd;
if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
goto fail;
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 7fa933a..71f2e02 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1355,3 +1355,50 @@ void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
dumb_bo_destroy(drmmode->fd, drmmode_crtc->cursor_bo);
}
}
+
+/* ugly workaround to see if we can create 32bpp */
+void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int *depth, int *bpp)
+{
+ drmModeResPtr mode_res;
+ uint64_t value;
+ struct dumb_bo *bo;
+ uint32_t fb_id;
+ int ret;
+
+ /* 16 is fine */
+ ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_PREFERRED_DEPTH, &value);
+ if (!ret && (value == 16 || value == 8)) {
+ *depth = value;
+ *bpp = value;
+ return;
+ }
+
+ *depth = 24;
+ mode_res = drmModeGetResources(drmmode->fd);
+ if (!mode_res)
+ return;
+
+ /*create a bo */
+ bo = dumb_bo_create(drmmode->fd, mode_res->min_width, mode_res->min_height, 32);
+ if (!bo) {
+ *bpp = 24;
+ goto out;
+ }
+
+ ret = drmModeAddFB(drmmode->fd, mode_res->min_width, mode_res->min_height,
+ 24, 32, bo->pitch, bo->handle, &fb_id);
+
+ if (ret) {
+ *bpp = 24;
+ dumb_bo_destroy(drmmode->fd, bo);
+ goto out;
+ }
+
+ drmModeRmFB(drmmode->fd, fb_id);
+ *bpp = 32;
+
+ dumb_bo_destroy(drmmode->fd, bo);
+out:
+ drmModeFreeResources(mode_res);
+ return;
+}
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index e83167b..fa280bd 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -103,4 +103,14 @@ Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
void *drmmode_map_front_bo(drmmode_ptr drmmode);
Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
+void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode, int *depth, int *bpp);
+
+#ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
+#define DRM_CAP_DUMB_PREFERRED_DEPTH 3
+#endif
+#ifndef DRM_CAP_DUMB_PREFER_SHADOW
+#define DRM_CAP_DUMB_PREFER_SHADOW 4
+#endif
+
+
#endif