Commit ba548ffb authored by Siarhei Siamashka's avatar Siarhei Siamashka
Browse files

Reuse the already existing xserver framebuffer mapping for sunxi_disp_t



Avoid creating a new mapping because that's a waste of the virtual address
space. Also we are going to use this xserver framebuffer mapping address
for testing whether window backing pixmaps are allocated in the framebuffer
and can be accelerated by G2D.
Signed-off-by: default avatarSiarhei Siamashka <siarhei.siamashka@gmail.com>
parent 5d9c791d
......@@ -930,7 +930,8 @@ FBDevScreenInit(SCREEN_INIT_ARGS_DECL)
#endif
fPtr->sunxi_disp_private = sunxi_disp_init(xf86FindOptionValue(
fPtr->pEnt->device->options,"fbdev"));
fPtr->pEnt->device->options,"fbdev"),
fPtr->fbmem);
if (!fPtr->sunxi_disp_private)
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
......
......@@ -36,7 +36,7 @@
/*****************************************************************************/
sunxi_disp_t *sunxi_disp_init(const char *device)
sunxi_disp_t *sunxi_disp_init(const char *device, void *xserver_fbmem)
{
sunxi_disp_t *ctx = calloc(sizeof(sunxi_disp_t), 1);
struct fb_var_screeninfo fb_var;
......@@ -58,6 +58,9 @@ sunxi_disp_t *sunxi_disp_init(const char *device)
return NULL;
}
/* store the already existing mapping done by xserver */
ctx->xserver_fbmem = xserver_fbmem;
ctx->fd_disp = open("/dev/disp", O_RDWR);
/* maybe it's even not a sunxi hardware */
......@@ -107,15 +110,21 @@ sunxi_disp_t *sunxi_disp_init(const char *device)
return NULL;
}
/* mmap framebuffer memory */
ctx->framebuffer_addr = (uint8_t *)mmap(0, ctx->framebuffer_size,
PROT_READ | PROT_WRITE,
MAP_SHARED, ctx->fd_fb, 0);
if (ctx->framebuffer_addr == MAP_FAILED) {
close(ctx->fd_fb);
close(ctx->fd_disp);
free(ctx);
return NULL;
if (ctx->xserver_fbmem) {
/* use already existing mapping */
ctx->framebuffer_addr = ctx->xserver_fbmem;
}
else {
/* mmap framebuffer memory */
ctx->framebuffer_addr = (uint8_t *)mmap(0, ctx->framebuffer_size,
PROT_READ | PROT_WRITE,
MAP_SHARED, ctx->fd_fb, 0);
if (ctx->framebuffer_addr == MAP_FAILED) {
close(ctx->fd_fb);
close(ctx->fd_disp);
free(ctx);
return NULL;
}
}
ctx->cursor_enabled = 0;
......@@ -147,7 +156,8 @@ int sunxi_disp_close(sunxi_disp_t *ctx)
if (ctx->cursor_enabled)
sunxi_hw_cursor_hide(ctx);
/* close descriptors */
munmap(ctx->framebuffer_addr, ctx->framebuffer_size);
if (!ctx->xserver_fbmem)
munmap(ctx->framebuffer_addr, ctx->framebuffer_size);
close(ctx->fd_fb);
close(ctx->fd_disp);
ctx->fd_disp = -1;
......
......@@ -43,6 +43,8 @@ typedef struct {
int framebuffer_height;/* virtual vertical resolution */
uint32_t gfx_layer_size; /* the size of the primary layer */
uint8_t *xserver_fbmem; /* framebuffer mapping done by xserver */
/* Hardware cursor support */
int cursor_enabled;
int cursor_x, cursor_y;
......@@ -52,7 +54,7 @@ typedef struct {
int layer_has_scaler;
} sunxi_disp_t;
sunxi_disp_t *sunxi_disp_init(const char *fb_device);
sunxi_disp_t *sunxi_disp_init(const char *fb_device, void *xserver_fbmem);
int sunxi_disp_close(sunxi_disp_t *ctx);
/*
......
......@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
{
int pos = 0, framenum = 0, yoffs, color;
disp = sunxi_disp_init("/dev/fb0");
disp = sunxi_disp_init("/dev/fb0", NULL);
/*
* setup the signal handler to catch Ctrl-C in order to prevent leaking
* the layer on process termination (that's a kernel bug).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment