[PATCH v2 2/6] modesetting: Use a gbm buffer for shadow if we are using glamor
Jason Ekstrand
jason at jlekstrand.net
Wed Jan 7 15:59:07 PST 2015
The drmmode_create_bo function already checks whether we're using glamor or
not and makes the right choice about gbm vs. dumb buffers for us. We just
need to call it.
Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
---
hw/xfree86/drivers/modesetting/driver.c | 4 +--
hw/xfree86/drivers/modesetting/drmmode_display.c | 43 +++++++++++++++---------
hw/xfree86/drivers/modesetting/drmmode_display.h | 3 +-
3 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 25d2d45..cf2232d 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -895,8 +895,8 @@ CreateScreenResources(ScreenPtr pScreen)
rootPixmap = pScreen->GetScreenPixmap(pScreen);
- if (ms->drmmode.shadow_enable)
- pixels = ms->drmmode.shadow_fb;
+ if (ms->drmmode.shadow_enable && !ms->drmmode.gbm)
+ pixels = drmmode_map_shadow_bo(&ms->drmmode);
if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels))
FatalError("Couldn't adjust screen pixmap\n");
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 534341d..f6690bc 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1168,7 +1168,7 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
drmmode_crtc_private_ptr
drmmode_crtc = xf86_config->crtc[0]->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
- drmmode_bo old_front;
+ drmmode_bo old_front, old_shadow;
Bool ret;
ScreenPtr screen = xf86ScrnToScreen(scrn);
uint32_t old_fb_id;
@@ -1193,6 +1193,7 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
old_pitch = drmmode_bo_get_pitch(&drmmode->front_bo);
old_fb_id = drmmode->fb_id;
old_front = drmmode->front_bo;
+ old_shadow = drmmode->shadow_bo;
if (!drmmode_create_bo(drmmode, &drmmode->front_bo,
width, height, scrn->bitsPerPixel))
@@ -1218,13 +1219,9 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
}
if (drmmode->shadow_enable) {
- uint32_t size = scrn->displayWidth * scrn->virtualY *
- ((scrn->bitsPerPixel + 7) >> 3);
- new_pixels = calloc(1, size);
- if (new_pixels == NULL)
+ if (!drmmode_create_bo(drmmode, &drmmode->shadow_bo,
+ width, height, scrn->bitsPerPixel))
goto fail;
- free(drmmode->shadow_fb);
- drmmode->shadow_fb = new_pixels;
}
screen->ModifyPixmapHeader(ppix, width, height, -1, -1, pitch, new_pixels);
@@ -1252,6 +1249,7 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
fail:
drmmode_bo_destroy(drmmode, &drmmode->front_bo);
drmmode->front_bo = old_front;
+ drmmode->shadow_bo = old_shadow;
scrn->virtualX = old_width;
scrn->virtualY = old_height;
scrn->displayWidth = old_pitch / cpp;
@@ -1540,13 +1538,10 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
return FALSE;
pScrn->displayWidth = drmmode_bo_get_pitch(&drmmode->front_bo) / cpp;
- if (drmmode->shadow_enable) {
- drmmode->shadow_fb =
- calloc(1,
- pScrn->displayWidth * pScrn->virtualY *
- ((pScrn->bitsPerPixel + 7) >> 3));
- if (!drmmode->shadow_fb)
- drmmode->shadow_enable = FALSE;
+ if (drmmode->shadow_enable &&
+ !drmmode_create_bo(drmmode, &drmmode->shadow_bo, width, height, bpp)) {
+ drmmode_bo_destroy(drmmode, &drmmode->front_bo);
+ return FALSE;
}
width = ms->cursor_width;
@@ -1579,6 +1574,22 @@ drmmode_map_front_bo(drmmode_ptr drmmode)
}
void *
+drmmode_map_shadow_bo(drmmode_ptr drmmode)
+{
+ int ret;
+
+ if (drmmode->shadow_bo.dumb->ptr)
+ return drmmode->shadow_bo.dumb->ptr;
+
+ ret = dumb_bo_map(drmmode->fd, drmmode->shadow_bo.dumb);
+ if (ret)
+ return NULL;
+
+ return drmmode->shadow_bo.dumb->ptr;
+
+}
+
+void *
drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv)
{
int ret;
@@ -1624,8 +1635,8 @@ drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
if (drmmode->shadow_enable) {
shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
- free(drmmode->shadow_fb);
- drmmode->shadow_fb = NULL;
+ drmmode_bo_destroy(drmmode, &drmmode->shadow_bo);
+ drmmode->shadow_enable = FALSE;
}
drmmode_bo_destroy(drmmode, &drmmode->front_bo);
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 66d0ca2..bbc3806 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -64,7 +64,7 @@ typedef struct {
Bool glamor;
Bool shadow_enable;
- void *shadow_fb;
+ drmmode_bo shadow_bo;
/**
* A screen-sized pixmap when we're doing triple-buffered DRI2
@@ -154,6 +154,7 @@ extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
void *drmmode_map_front_bo(drmmode_ptr drmmode);
+void *drmmode_map_shadow_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,
--
2.2.0
More information about the xorg-devel
mailing list