xf86-video-modesetting: 2 commits - src/driver.c src/drmmode_display.c src/drmmode_display.h
Dave Airlie
airlied at kemper.freedesktop.org
Tue May 1 09:19:19 PDT 2012
src/driver.c | 62 ++++++++++++++++++++++++++------------------------
src/drmmode_display.c | 47 +++++++++++++++++++++++++++++++++++++
src/drmmode_display.h | 10 ++++++++
3 files changed, 90 insertions(+), 29 deletions(-)
New commits:
commit d12d9ac5cae7a4287e7ba1f137209574bc0c5b17
Author: Dave Airlie <airlied at redhat.com>
Date: Tue May 1 17:12:29 2012 +0100
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 at redhat.com>
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
commit 288d197f706804194ef9977baa50d566142e2acc
Author: Dave Airlie <airlied at redhat.com>
Date: Tue May 1 16:52:18 2012 +0100
modesetting: move opening kernel device to before setting depth
due to interaction between option handling and set depth, we need
to what fbdev does to get the device path early.
Signed-off-by: Dave Airlie <airlied at redhat.com>
diff --git a/src/driver.c b/src/driver.c
index 827438a..fb4b410 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -437,6 +437,28 @@ PreInit(ScrnInfoPtr pScrn, int flags)
pScrn->progClock = TRUE;
pScrn->rgbBits = 8;
+ ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
+ if (ms->PciInfo) {
+ BusID = malloc(64);
+ sprintf(BusID, "PCI:%d:%d:%d",
+#if XSERVER_LIBPCIACCESS
+ ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
+ ms->PciInfo->dev, ms->PciInfo->func
+#else
+ ((pciConfigPtr) ms->PciInfo->thisCard)->busnum,
+ ((pciConfigPtr) ms->PciInfo->thisCard)->devnum,
+ ((pciConfigPtr) ms->PciInfo->thisCard)->funcnum
+#endif
+ );
+
+ ms->fd = drmOpen(NULL, BusID);
+ } else {
+ devicename = xf86FindOptionValue(ms->pEnt->device->options, "kmsdev");
+ ms->fd = open_hw(devicename);
+ }
+ if (ms->fd < 0)
+ return FALSE;
+
if (!xf86SetDepthBpp
(pScrn, 0, 0, 0,
PreferConvert24to32 | SupportConvert24to32 | Support32bppFb))
@@ -462,28 +484,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
memcpy(ms->Options, Options, sizeof(Options));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);
- ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
- if (ms->PciInfo) {
- BusID = malloc(64);
- sprintf(BusID, "PCI:%d:%d:%d",
-#if XSERVER_LIBPCIACCESS
- ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
- ms->PciInfo->dev, ms->PciInfo->func
-#else
- ((pciConfigPtr) ms->PciInfo->thisCard)->busnum,
- ((pciConfigPtr) ms->PciInfo->thisCard)->devnum,
- ((pciConfigPtr) ms->PciInfo->thisCard)->funcnum
-#endif
- );
-
- ms->fd = drmOpen(NULL, BusID);
- } else {
- devicename = xf86GetOptValString(ms->Options, OPTION_DEVICE_PATH);
- ms->fd = open_hw(devicename);
- }
- if (ms->fd < 0)
- return FALSE;
-
if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight))
return FALSE;
if (!xf86SetDefaultVisual(pScrn, -1))
More information about the xorg-commit
mailing list