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

DRI2: Rename all SunxiMaliDRI2 instances to 'mali' for clarity



Do this to keep the variables naming style consistent across the
source file (earlier these variables had different names like
'self', 'drvpriv', 'private').
Signed-off-by: default avatarSiarhei Siamashka <siarhei.siamashka@gmail.com>
parent 30b4ca27
...@@ -102,16 +102,16 @@ FancyTraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data) ...@@ -102,16 +102,16 @@ FancyTraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data)
static int static int
WindowWalker(WindowPtr pWin, pointer value) WindowWalker(WindowPtr pWin, pointer value)
{ {
SunxiMaliDRI2 *private = (SunxiMaliDRI2 *)value; SunxiMaliDRI2 *mali = (SunxiMaliDRI2 *)value;
if (private->bWalkingAboveOverlayWin) { if (mali->bWalkingAboveOverlayWin) {
if (pWin->mapped && pWin->realized && pWin->drawable.class != InputOnly) { if (pWin->mapped && pWin->realized && pWin->drawable.class != InputOnly) {
BoxRec sboxrec1; BoxRec sboxrec1;
BoxPtr sbox1 = WindowExtents(pWin, &sboxrec1); BoxPtr sbox1 = WindowExtents(pWin, &sboxrec1);
BoxRec sboxrec2; BoxRec sboxrec2;
BoxPtr sbox2 = WindowExtents(private->pOverlayWin, &sboxrec2); BoxPtr sbox2 = WindowExtents(mali->pOverlayWin, &sboxrec2);
if (BOXES_OVERLAP(sbox1, sbox2)) { if (BOXES_OVERLAP(sbox1, sbox2)) {
private->bOverlayWinOverlapped = TRUE; mali->bOverlayWinOverlapped = TRUE;
DebugMsg("overlapped by %p, x=%d, y=%d, w=%d, h=%d\n", pWin, DebugMsg("overlapped by %p, x=%d, y=%d, w=%d, h=%d\n", pWin,
pWin->drawable.x, pWin->drawable.y, pWin->drawable.x, pWin->drawable.y,
pWin->drawable.width, pWin->drawable.height); pWin->drawable.width, pWin->drawable.height);
...@@ -119,8 +119,8 @@ WindowWalker(WindowPtr pWin, pointer value) ...@@ -119,8 +119,8 @@ WindowWalker(WindowPtr pWin, pointer value)
} }
} }
} }
else if (pWin == private->pOverlayWin) { else if (pWin == mali->pOverlayWin) {
private->bWalkingAboveOverlayWin = TRUE; mali->bWalkingAboveOverlayWin = TRUE;
} }
return WT_WALKCHILDREN; return WT_WALKCHILDREN;
...@@ -132,12 +132,12 @@ MigratePixmapToUMP(PixmapPtr pPixmap) ...@@ -132,12 +132,12 @@ MigratePixmapToUMP(PixmapPtr pPixmap)
{ {
ScreenPtr pScreen = pPixmap->drawable.pScreen; ScreenPtr pScreen = pPixmap->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *self = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
UMPBufferInfoPtr umpbuf; UMPBufferInfoPtr umpbuf;
size_t pitch = ((pPixmap->devKind + 7) / 8) * 8; size_t pitch = ((pPixmap->devKind + 7) / 8) * 8;
size_t size = pitch * pPixmap->drawable.height; size_t size = pitch * pPixmap->drawable.height;
HASH_FIND_PTR(self->HashPixmapToUMP, &pPixmap, umpbuf); HASH_FIND_PTR(mali->HashPixmapToUMP, &pPixmap, umpbuf);
if (umpbuf) { if (umpbuf) {
DebugMsg("MigratePixmapToUMP %p, already exists = %p\n", pPixmap, umpbuf); DebugMsg("MigratePixmapToUMP %p, already exists = %p\n", pPixmap, umpbuf);
...@@ -182,7 +182,7 @@ MigratePixmapToUMP(PixmapPtr pPixmap) ...@@ -182,7 +182,7 @@ MigratePixmapToUMP(PixmapPtr pPixmap)
pPixmap->devKind = pitch; pPixmap->devKind = pitch;
pPixmap->devPrivate.ptr = umpbuf->addr; pPixmap->devPrivate.ptr = umpbuf->addr;
HASH_ADD_PTR(self->HashPixmapToUMP, pPixmap, umpbuf); HASH_ADD_PTR(mali->HashPixmapToUMP, pPixmap, umpbuf);
DebugMsg("MigratePixmapToUMP %p, new buf = %p\n", pPixmap, umpbuf); DebugMsg("MigratePixmapToUMP %p, new buf = %p\n", pPixmap, umpbuf);
return umpbuf; return umpbuf;
...@@ -256,7 +256,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -256,7 +256,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
DRI2Buffer2Ptr buffer; DRI2Buffer2Ptr buffer;
UMPBufferInfoPtr privates; UMPBufferInfoPtr privates;
ump_handle handle; ump_handle handle;
SunxiMaliDRI2 *private = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
sunxi_disp_t *disp = SUNXI_DISP(pScrn); sunxi_disp_t *disp = SUNXI_DISP(pScrn);
Bool can_use_overlay = TRUE; Bool can_use_overlay = TRUE;
PixmapPtr pWindowPixmap; PixmapPtr pWindowPixmap;
...@@ -327,16 +327,16 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -327,16 +327,16 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
/* ... and just return some dummy UMP buffer */ /* ... and just return some dummy UMP buffer */
privates->handle = UMP_INVALID_MEMORY_HANDLE; privates->handle = UMP_INVALID_MEMORY_HANDLE;
privates->addr = NULL; privates->addr = NULL;
buffer->name = private->ump_null_secure_id; buffer->name = mali->ump_null_secure_id;
return validate_dri2buf(buffer); return validate_dri2buf(buffer);
} }
/* We could not allocate disp layer or get framebuffer secure id */ /* We could not allocate disp layer or get framebuffer secure id */
if (!disp || private->ump_fb_secure_id == UMP_INVALID_SECURE_ID) if (!disp || mali->ump_fb_secure_id == UMP_INVALID_SECURE_ID)
can_use_overlay = FALSE; can_use_overlay = FALSE;
/* Overlay is already used by a different window */ /* Overlay is already used by a different window */
if (private->pOverlayWin && private->pOverlayWin != (void *)pDraw) if (mali->pOverlayWin && mali->pOverlayWin != (void *)pDraw)
can_use_overlay = FALSE; can_use_overlay = FALSE;
/* Don't waste overlay on some strange 1x1 window created by gnome-shell */ /* Don't waste overlay on some strange 1x1 window created by gnome-shell */
...@@ -354,11 +354,11 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -354,11 +354,11 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
} }
/* Allocate the DRI2-related window bookkeeping information */ /* Allocate the DRI2-related window bookkeeping information */
HASH_FIND_PTR(private->HashWindowState, &pDraw, window_state); HASH_FIND_PTR(mali->HashWindowState, &pDraw, window_state);
if (!window_state) { if (!window_state) {
window_state = calloc(1, sizeof(*window_state)); window_state = calloc(1, sizeof(*window_state));
window_state->pDraw = pDraw; window_state->pDraw = pDraw;
HASH_ADD_PTR(private->HashWindowState, pDraw, window_state); HASH_ADD_PTR(mali->HashWindowState, pDraw, window_state);
DebugMsg("Allocate DRI2 bookkeeping for window %p\n", pDraw); DebugMsg("Allocate DRI2 bookkeeping for window %p\n", pDraw);
if (disp && can_use_overlay) { if (disp && can_use_overlay) {
/* erase the offscreen part of the framebuffer */ /* erase the offscreen part of the framebuffer */
...@@ -380,7 +380,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -380,7 +380,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
!(window_state->buf_request_cnt & 1) && !(window_state->buf_request_cnt & 1) &&
(pDraw->width != window_state->width || (pDraw->width != window_state->width ||
pDraw->height != window_state->height) && pDraw->height != window_state->height) &&
private->ump_null_secure_id <= 2; mali->ump_null_secure_id <= 2;
if (can_use_overlay) { if (can_use_overlay) {
/* Release unneeded buffers */ /* Release unneeded buffers */
...@@ -392,7 +392,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -392,7 +392,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
privates->handle = UMP_INVALID_MEMORY_HANDLE; privates->handle = UMP_INVALID_MEMORY_HANDLE;
privates->addr = disp->framebuffer_addr; privates->addr = disp->framebuffer_addr;
buffer->name = private->ump_fb_secure_id; buffer->name = mali->ump_fb_secure_id;
if (window_state->buf_request_cnt & 1) { if (window_state->buf_request_cnt & 1) {
buffer->flags = disp->gfx_layer_size; buffer->flags = disp->gfx_layer_size;
...@@ -406,11 +406,11 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -406,11 +406,11 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
umpbuf_add_to_queue(window_state, privates); umpbuf_add_to_queue(window_state, privates);
privates->refcount++; privates->refcount++;
private->pOverlayWin = (WindowPtr)pDraw; mali->pOverlayWin = (WindowPtr)pDraw;
if (need_window_resize_bug_workaround) { if (need_window_resize_bug_workaround) {
DebugMsg("DRI2 buffers size mismatch detected, trying to recover\n"); DebugMsg("DRI2 buffers size mismatch detected, trying to recover\n");
buffer->name = private->ump_alternative_fb_secure_id; buffer->name = mali->ump_alternative_fb_secure_id;
} }
} }
else { else {
...@@ -431,7 +431,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -431,7 +431,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
privates->handle = UMP_INVALID_MEMORY_HANDLE; privates->handle = UMP_INVALID_MEMORY_HANDLE;
privates->addr = NULL; privates->addr = NULL;
buffer->name = private->ump_null_secure_id; buffer->name = mali->ump_null_secure_id;
return validate_dri2buf(buffer); return validate_dri2buf(buffer);
} }
...@@ -495,10 +495,10 @@ static void MaliDRI2DestroyBuffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer) ...@@ -495,10 +495,10 @@ static void MaliDRI2DestroyBuffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer)
UMPBufferInfoPtr privates; UMPBufferInfoPtr privates;
ScreenPtr pScreen = pDraw->pScreen; ScreenPtr pScreen = pDraw->pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *drvpriv = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
if (drvpriv->pOverlayDirtyUMP == buffer->driverPrivate) if (mali->pOverlayDirtyUMP == buffer->driverPrivate)
drvpriv->pOverlayDirtyUMP = NULL; mali->pOverlayDirtyUMP = NULL;
DebugMsg("DRI2DestroyBuffer %s=%p, buf=%p:%p, att=%d\n", DebugMsg("DRI2DestroyBuffer %s=%p, buf=%p:%p, att=%d\n",
pDraw->type == DRAWABLE_WINDOW ? "win" : "pix", pDraw->type == DRAWABLE_WINDOW ? "win" : "pix",
...@@ -559,14 +559,14 @@ static void MaliDRI2CopyRegion_copy(DrawablePtr pDraw, ...@@ -559,14 +559,14 @@ static void MaliDRI2CopyRegion_copy(DrawablePtr pDraw,
static void FlushOverlay(ScreenPtr pScreen) static void FlushOverlay(ScreenPtr pScreen)
{ {
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *self = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
if (self->pOverlayWin && self->pOverlayDirtyUMP) { if (mali->pOverlayWin && mali->pOverlayDirtyUMP) {
DebugMsg("Flushing overlay content from DRI2 buffer to window\n"); DebugMsg("Flushing overlay content from DRI2 buffer to window\n");
MaliDRI2CopyRegion_copy((DrawablePtr)self->pOverlayWin, MaliDRI2CopyRegion_copy((DrawablePtr)mali->pOverlayWin,
&pScreen->root->winSize, &pScreen->root->winSize,
self->pOverlayDirtyUMP); mali->pOverlayDirtyUMP);
self->pOverlayDirtyUMP = NULL; mali->pOverlayDirtyUMP = NULL;
} }
} }
...@@ -618,11 +618,11 @@ static void MaliDRI2CopyRegion(DrawablePtr pDraw, ...@@ -618,11 +618,11 @@ static void MaliDRI2CopyRegion(DrawablePtr pDraw,
{ {
ScreenPtr pScreen = pDraw->pScreen; ScreenPtr pScreen = pDraw->pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *drvpriv = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
UMPBufferInfoPtr umpbuf; UMPBufferInfoPtr umpbuf;
sunxi_disp_t *disp = SUNXI_DISP(xf86Screens[pScreen->myNum]); sunxi_disp_t *disp = SUNXI_DISP(xf86Screens[pScreen->myNum]);
DRI2WindowStatePtr window_state = NULL; DRI2WindowStatePtr window_state = NULL;
HASH_FIND_PTR(drvpriv->HashWindowState, &pDraw, window_state); HASH_FIND_PTR(mali->HashWindowState, &pDraw, window_state);
if (pDraw->type == DRAWABLE_PIXMAP) { if (pDraw->type == DRAWABLE_PIXMAP) {
DebugMsg("MaliDRI2CopyRegion has been called for pixmap %p\n", pDraw); DebugMsg("MaliDRI2CopyRegion has been called for pixmap %p\n", pDraw);
...@@ -677,14 +677,14 @@ static void MaliDRI2CopyRegion(DrawablePtr pDraw, ...@@ -677,14 +677,14 @@ static void MaliDRI2CopyRegion(DrawablePtr pDraw,
UpdateOverlay(pScreen); UpdateOverlay(pScreen);
if (!drvpriv->bOverlayWinEnabled || umpbuf->handle != UMP_INVALID_MEMORY_HANDLE) { if (!mali->bOverlayWinEnabled || umpbuf->handle != UMP_INVALID_MEMORY_HANDLE) {
MaliDRI2CopyRegion_copy(pDraw, pRegion, umpbuf); MaliDRI2CopyRegion_copy(pDraw, pRegion, umpbuf);
drvpriv->pOverlayDirtyUMP = NULL; mali->pOverlayDirtyUMP = NULL;
return; return;
} }
/* Mark the overlay as "dirty" and remember the last up to date UMP buffer */ /* Mark the overlay as "dirty" and remember the last up to date UMP buffer */
drvpriv->pOverlayDirtyUMP = umpbuf; mali->pOverlayDirtyUMP = umpbuf;
/* Activate the overlay */ /* Activate the overlay */
sunxi_layer_set_output_window(disp, pDraw->x, pDraw->y, pDraw->width, pDraw->height); sunxi_layer_set_output_window(disp, pDraw->x, pDraw->y, pDraw->width, pDraw->height);
...@@ -692,7 +692,7 @@ static void MaliDRI2CopyRegion(DrawablePtr pDraw, ...@@ -692,7 +692,7 @@ static void MaliDRI2CopyRegion(DrawablePtr pDraw,
umpbuf->height, umpbuf->pitch / 4); umpbuf->height, umpbuf->pitch / 4);
sunxi_layer_show(disp); sunxi_layer_show(disp);
if (drvpriv->bSwapbuffersWait) { if (mali->bSwapbuffersWait) {
/* FIXME: blocking here for up to 1/60 second is not nice */ /* FIXME: blocking here for up to 1/60 second is not nice */
sunxi_wait_for_vsync(disp); sunxi_wait_for_vsync(disp);
} }
...@@ -703,29 +703,29 @@ static void MaliDRI2CopyRegion(DrawablePtr pDraw, ...@@ -703,29 +703,29 @@ static void MaliDRI2CopyRegion(DrawablePtr pDraw,
static void UpdateOverlay(ScreenPtr pScreen) static void UpdateOverlay(ScreenPtr pScreen)
{ {
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *self = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
sunxi_disp_t *disp = SUNXI_DISP(pScrn); sunxi_disp_t *disp = SUNXI_DISP(pScrn);
if (!self->pOverlayWin || !disp) if (!mali->pOverlayWin || !disp)
return; return;
/* Disable overlays if the hardware cursor is not in use */ /* Disable overlays if the hardware cursor is not in use */
if (!self->bHardwareCursorIsInUse) { if (!mali->bHardwareCursorIsInUse) {
if (self->bOverlayWinEnabled) { if (mali->bOverlayWinEnabled) {
DebugMsg("Disabling overlay (no hardware cursor)\n"); DebugMsg("Disabling overlay (no hardware cursor)\n");
sunxi_layer_hide(disp); sunxi_layer_hide(disp);
self->bOverlayWinEnabled = FALSE; mali->bOverlayWinEnabled = FALSE;
} }
return; return;
} }
/* If the window is not mapped, make sure that the overlay is disabled */ /* If the window is not mapped, make sure that the overlay is disabled */
if (!self->pOverlayWin->mapped) if (!mali->pOverlayWin->mapped)
{ {
if (self->bOverlayWinEnabled) { if (mali->bOverlayWinEnabled) {
DebugMsg("Disabling overlay (window is not mapped)\n"); DebugMsg("Disabling overlay (window is not mapped)\n");
sunxi_layer_hide(disp); sunxi_layer_hide(disp);
self->bOverlayWinEnabled = FALSE; mali->bOverlayWinEnabled = FALSE;
} }
return; return;
} }
...@@ -736,38 +736,38 @@ static void UpdateOverlay(ScreenPtr pScreen) ...@@ -736,38 +736,38 @@ static void UpdateOverlay(ScreenPtr pScreen)
* for redirected windows). * for redirected windows).
*/ */
self->bWalkingAboveOverlayWin = FALSE; mali->bWalkingAboveOverlayWin = FALSE;
self->bOverlayWinOverlapped = FALSE; mali->bOverlayWinOverlapped = FALSE;
FancyTraverseTree(pScreen->root, WindowWalker, self); FancyTraverseTree(pScreen->root, WindowWalker, mali);
/* If the window got overlapped -> disable overlay */ /* If the window got overlapped -> disable overlay */
if (self->bOverlayWinOverlapped && self->bOverlayWinEnabled) { if (mali->bOverlayWinOverlapped && mali->bOverlayWinEnabled) {
DebugMsg("Disabling overlay (window is obscured)\n"); DebugMsg("Disabling overlay (window is obscured)\n");
FlushOverlay(pScreen); FlushOverlay(pScreen);
self->bOverlayWinEnabled = FALSE; mali->bOverlayWinEnabled = FALSE;
sunxi_layer_hide(disp); sunxi_layer_hide(disp);
return; return;
} }
/* If the window got moved -> update overlay position */ /* If the window got moved -> update overlay position */
if (!self->bOverlayWinOverlapped && if (!mali->bOverlayWinOverlapped &&
(self->overlay_x != self->pOverlayWin->drawable.x || (mali->overlay_x != mali->pOverlayWin->drawable.x ||
self->overlay_y != self->pOverlayWin->drawable.y)) mali->overlay_y != mali->pOverlayWin->drawable.y))
{ {
self->overlay_x = self->pOverlayWin->drawable.x; mali->overlay_x = mali->pOverlayWin->drawable.x;
self->overlay_y = self->pOverlayWin->drawable.y; mali->overlay_y = mali->pOverlayWin->drawable.y;
sunxi_layer_set_output_window(disp, self->pOverlayWin->drawable.x, sunxi_layer_set_output_window(disp, mali->pOverlayWin->drawable.x,
self->pOverlayWin->drawable.y, mali->pOverlayWin->drawable.y,
self->pOverlayWin->drawable.width, mali->pOverlayWin->drawable.width,
self->pOverlayWin->drawable.height); mali->pOverlayWin->drawable.height);
DebugMsg("Move overlay to (%d, %d)\n", self->overlay_x, self->overlay_y); DebugMsg("Move overlay to (%d, %d)\n", mali->overlay_x, mali->overlay_y);
} }
/* If the window got unobscured -> enable overlay */ /* If the window got unobscured -> enable overlay */
if (!self->bOverlayWinOverlapped && !self->bOverlayWinEnabled) { if (!mali->bOverlayWinOverlapped && !mali->bOverlayWinEnabled) {
DebugMsg("Enabling overlay (window is fully unobscured)\n"); DebugMsg("Enabling overlay (window is fully unobscured)\n");
self->bOverlayWinEnabled = TRUE; mali->bOverlayWinEnabled = TRUE;
sunxi_layer_show(disp); sunxi_layer_show(disp);
} }
} }
...@@ -777,14 +777,14 @@ DestroyWindow(WindowPtr pWin) ...@@ -777,14 +777,14 @@ DestroyWindow(WindowPtr pWin)
{ {
ScreenPtr pScreen = pWin->drawable.pScreen; ScreenPtr pScreen = pWin->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *private = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
Bool ret; Bool ret;
DrawablePtr pDraw = &pWin->drawable; DrawablePtr pDraw = &pWin->drawable;
DRI2WindowStatePtr window_state = NULL; DRI2WindowStatePtr window_state = NULL;
HASH_FIND_PTR(private->HashWindowState, &pDraw, window_state); HASH_FIND_PTR(mali->HashWindowState, &pDraw, window_state);
if (window_state) { if (window_state) {
DebugMsg("Free DRI2 bookkeeping for window %p\n", pWin); DebugMsg("Free DRI2 bookkeeping for window %p\n", pWin);
HASH_DEL(private->HashWindowState, window_state); HASH_DEL(mali->HashWindowState, window_state);
if (window_state->ump_mem_buffer_ptr) if (window_state->ump_mem_buffer_ptr)
unref_ump_buffer_info(window_state->ump_mem_buffer_ptr); unref_ump_buffer_info(window_state->ump_mem_buffer_ptr);
if (window_state->ump_back_buffer_ptr) if (window_state->ump_back_buffer_ptr)
...@@ -794,16 +794,16 @@ DestroyWindow(WindowPtr pWin) ...@@ -794,16 +794,16 @@ DestroyWindow(WindowPtr pWin)
free(window_state); free(window_state);
} }
if (pWin == private->pOverlayWin) { if (pWin == mali->pOverlayWin) {
sunxi_disp_t *disp = SUNXI_DISP(pScrn); sunxi_disp_t *disp = SUNXI_DISP(pScrn);
sunxi_layer_hide(disp); sunxi_layer_hide(disp);
private->pOverlayWin = NULL; mali->pOverlayWin = NULL;
DebugMsg("DestroyWindow %p\n", pWin); DebugMsg("DestroyWindow %p\n", pWin);
} }
pScreen->DestroyWindow = private->DestroyWindow; pScreen->DestroyWindow = mali->DestroyWindow;
ret = (*pScreen->DestroyWindow) (pWin); ret = (*pScreen->DestroyWindow) (pWin);
private->DestroyWindow = pScreen->DestroyWindow; mali->DestroyWindow = pScreen->DestroyWindow;
pScreen->DestroyWindow = DestroyWindow; pScreen->DestroyWindow = DestroyWindow;
return ret; return ret;
...@@ -814,12 +814,12 @@ PostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind) ...@@ -814,12 +814,12 @@ PostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind)
{ {
ScreenPtr pScreen = pWin ? pWin->drawable.pScreen : pLayerWin->drawable.pScreen; ScreenPtr pScreen = pWin ? pWin->drawable.pScreen : pLayerWin->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *private = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
if (private->PostValidateTree) { if (mali->PostValidateTree) {
pScreen->PostValidateTree = private->PostValidateTree; pScreen->PostValidateTree = mali->PostValidateTree;
(*pScreen->PostValidateTree) (pWin, pLayerWin, kind); (*pScreen->PostValidateTree) (pWin, pLayerWin, kind);
private->PostValidateTree = pScreen->PostValidateTree; mali->PostValidateTree = pScreen->PostValidateTree;
pScreen->PostValidateTree = PostValidateTree; pScreen->PostValidateTree = PostValidateTree;
} }
...@@ -836,16 +836,16 @@ GetImage(DrawablePtr pDrawable, int x, int y, int w, int h, ...@@ -836,16 +836,16 @@ GetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
{ {
ScreenPtr pScreen = pDrawable->pScreen; ScreenPtr pScreen = pDrawable->pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *private = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
/* FIXME: more precise check */ /* FIXME: more precise check */
if (private->pOverlayDirtyUMP) if (mali->pOverlayDirtyUMP)
FlushOverlay(pScreen); FlushOverlay(pScreen);
if (private->GetImage) { if (mali->GetImage) {
pScreen->GetImage = private->GetImage; pScreen->GetImage = mali->GetImage;
(*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d); (*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d);
private->GetImage = pScreen->GetImage; mali->GetImage = pScreen->GetImage;
pScreen->GetImage = GetImage; pScreen->GetImage = GetImage;
} }
} }
...@@ -855,10 +855,10 @@ DestroyPixmap(PixmapPtr pPixmap) ...@@ -855,10 +855,10 @@ DestroyPixmap(PixmapPtr pPixmap)
{ {
ScreenPtr pScreen = pPixmap->drawable.pScreen; ScreenPtr pScreen = pPixmap->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *self = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
Bool result; Bool result;
UMPBufferInfoPtr umpbuf; UMPBufferInfoPtr umpbuf;
HASH_FIND_PTR(self->HashPixmapToUMP, &pPixmap, umpbuf); HASH_FIND_PTR(mali->HashPixmapToUMP, &pPixmap, umpbuf);
if (umpbuf) { if (umpbuf) {
DebugMsg("DestroyPixmap %p for migrated UMP pixmap (UMP buffer=%p)\n", pPixmap, umpbuf); DebugMsg("DestroyPixmap %p for migrated UMP pixmap (UMP buffer=%p)\n", pPixmap, umpbuf);
...@@ -866,14 +866,14 @@ DestroyPixmap(PixmapPtr pPixmap) ...@@ -866,14 +866,14 @@ DestroyPixmap(PixmapPtr pPixmap)
pPixmap->devKind = umpbuf->BackupDevKind; pPixmap->devKind = umpbuf->BackupDevKind;
pPixmap->devPrivate.ptr = umpbuf->BackupDevPrivatePtr; pPixmap->devPrivate.ptr = umpbuf->BackupDevPrivatePtr;
HASH_DEL(self->HashPixmapToUMP, umpbuf); HASH_DEL(mali->HashPixmapToUMP, umpbuf);
umpbuf->pPixmap = NULL; umpbuf->pPixmap = NULL;
unref_ump_buffer_info(umpbuf); unref_ump_buffer_info(umpbuf);
} }
pScreen->DestroyPixmap = self->DestroyPixmap; pScreen->DestroyPixmap = mali->DestroyPixmap;
result = (*pScreen->DestroyPixmap) (pPixmap); result = (*pScreen->DestroyPixmap) (pPixmap);
self->DestroyPixmap = pScreen->DestroyPixmap; mali->DestroyPixmap = pScreen->DestroyPixmap;
pScreen->DestroyPixmap = DestroyPixmap; pScreen->DestroyPixmap = DestroyPixmap;
...@@ -882,40 +882,40 @@ DestroyPixmap(PixmapPtr pPixmap) ...@@ -882,40 +882,40 @@ DestroyPixmap(PixmapPtr pPixmap)
static void EnableHWCursor(ScrnInfoPtr pScrn) static void EnableHWCursor(ScrnInfoPtr pScrn)
{ {
SunxiMaliDRI2 *self = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn); SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn);
if (!self->bHardwareCursorIsInUse) { if (!mali->bHardwareCursorIsInUse) {
DebugMsg("EnableHWCursor\n"); DebugMsg("EnableHWCursor\n");
self->bHardwareCursorIsInUse = TRUE; mali->bHardwareCursorIsInUse = TRUE;
} }
UpdateOverlay(screenInfo.screens[pScrn->scrnIndex]); UpdateOverlay(screenInfo.screens[pScrn->scrnIndex]);
if (self->EnableHWCursor) { if (mali->EnableHWCursor) {
hwc->EnableHWCursor = self->EnableHWCursor; hwc->EnableHWCursor = mali->EnableHWCursor;
(*hwc->EnableHWCursor) (pScrn); (*hwc->EnableHWCursor) (pScrn);
self->EnableHWCursor = hwc->EnableHWCursor; mali->EnableHWCursor = hwc->EnableHWCursor;
hwc->EnableHWCursor = EnableHWCursor; hwc->EnableHWCursor = EnableHWCursor;
} }
} }
static void DisableHWCursor(ScrnInfoPtr pScrn) static void DisableHWCursor(ScrnInfoPtr pScrn)
{ {
SunxiMaliDRI2 *self = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn); SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn);
if (self->bHardwareCursorIsInUse) { if (mali->bHardwareCursorIsInUse) {
self->bHardwareCursorIsInUse = FALSE; mali->bHardwareCursorIsInUse = FALSE;
DebugMsg("DisableHWCursor\n"); DebugMsg("DisableHWCursor\n");
} }
UpdateOverlay(screenInfo.screens[pScrn->scrnIndex]); UpdateOverlay(screenInfo.screens[pScrn->scrnIndex]);
if (self->DisableHWCursor) { if (mali->DisableHWCursor) {
hwc->DisableHWCursor = self->DisableHWCursor; hwc->DisableHWCursor = mali->DisableHWCursor;
(*hwc->DisableHWCursor) (pScrn); (*hwc->DisableHWCursor) (pScrn);
self->DisableHWCursor = hwc->DisableHWCursor; mali->DisableHWCursor = hwc->DisableHWCursor;
hwc->DisableHWCursor = DisableHWCursor; hwc->DisableHWCursor = DisableHWCursor;
} }
} }
...@@ -926,7 +926,7 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, ...@@ -926,7 +926,7 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen,
{ {
int drm_fd; int drm_fd;
DRI2InfoRec info; DRI2InfoRec info;
SunxiMaliDRI2 *private; SunxiMaliDRI2 *mali;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
sunxi_disp_t *disp = SUNXI_DISP(pScrn); sunxi_disp_t *disp = SUNXI_DISP(pScrn);
...@@ -949,41 +949,41 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, ...@@ -949,41 +949,41 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen,
return NULL; return NULL;
} }
if (!(private = calloc(1, sizeof(SunxiMaliDRI2)))) { if (!(mali = calloc(1, sizeof(SunxiMaliDRI2)))) {
ErrorF("SunxiMaliDRI2_Init: calloc failed\n"); ErrorF("SunxiMaliDRI2_Init: calloc failed\n");
return NULL; return NULL;
} }
if (disp && bUseOverlay) { if (disp && bUseOverlay) {
/* Try to get UMP framebuffer wrapper with secure id 1 */ /* Try to get UMP framebuffer wrapper with secure id 1 */
ioctl(disp->fd_fb, GET_UMP_SECURE_ID_BUF1, &private->ump_alternative_fb_secure_id); ioctl(disp->fd_fb, GET_UMP_SECURE_ID_BUF1, &mali->ump_alternative_fb_secure_id);
/* Try to allocate a small dummy UMP buffer to secure id 2 */ /* Try to allocate a small dummy UMP buffer to secure id 2 */
private->ump_null_handle1 = ump_ref_drv_allocate(4096, UMP_REF_DRV_CONSTRAINT_NONE); mali->ump_null_handle1 = ump_ref_drv_allocate(4096, UMP_REF_DRV_CONSTRAINT_NONE);
if (private->ump_null_handle1 != UMP_INVALID_MEMORY_HANDLE) if (mali->ump_null_handle1 != UMP_INVALID_MEMORY_HANDLE)
private->ump_null_secure_id = ump_secure_id_get(private->ump_null_handle1); mali->ump_null_secure_id = ump_secure_id_get(mali->ump_null_handle1);
private->ump_null_handle2 = UMP_INVALID_MEMORY_HANDLE; mali->ump_null_handle2 = UMP_INVALID_MEMORY_HANDLE;
/* Try to get UMP framebuffer for the secure id other than 1 and 2 */ /* Try to get UMP framebuffer for the secure id other than 1 and 2 */
if (ioctl(disp->fd_fb, GET_UMP_SECURE_ID_SUNXI_FB, &private->ump_fb_secure_id) || if (ioctl(disp->fd_fb, GET_UMP_SECURE_ID_SUNXI_FB, &mali->ump_fb_secure_id) ||
private->ump_fb_secure_id == UMP_INVALID_SECURE_ID) { mali->ump_fb_secure_id == UMP_INVALID_SECURE_ID) {
xf86DrvMsg(pScreen->myNum, X_INFO, xf86DrvMsg(pScreen->myNum, X_INFO,
"GET_UMP_SECURE_ID_SUNXI_FB ioctl failed, overlays can't be used\n"); "GET_UMP_SECURE_ID_SUNXI_FB ioctl failed, overlays can't be used\n");
private->ump_fb_secure_id = UMP_INVALID_SECURE_ID; mali->ump_fb_secure_id = UMP_INVALID_SECURE_ID;
} }
} }
else { else {
/* Try to allocate small dummy UMP buffers to secure id 1 and 2 */ /* Try to allocate small dummy UMP buffers to secure id 1 and 2 */
private->ump_null_handle1 = ump_ref_drv_allocate(4096, UMP_REF_DRV_CONSTRAINT_NONE); mali->ump_null_handle1 = ump_ref_drv_allocate(4096, UMP_REF_DRV_CONSTRAINT_NONE);
if (private->ump_null_handle1 != UMP_INVALID_MEMORY_HANDLE) if (mali->ump_null_handle1 != UMP_INVALID_MEMORY_HANDLE)
private->ump_null_secure_id = ump_secure_id_get(private->ump_null_handle1); mali->ump_null_secure_id = ump_secure_id_get(mali->ump_null_handle1);
private->ump_null_handle2 = ump_ref_drv_allocate(4096, UMP_REF_DRV_CONSTRAINT_NONE); mali->ump_null_handle2 = ump_ref_drv_allocate(4096, UMP_REF_DRV_CONSTRAINT_NONE);
} }
if (private->ump_null_secure_id > 2) { if (mali->ump_null_secure_id > 2) {
xf86DrvMsg(pScreen->myNum, X_INFO, xf86DrvMsg(pScreen->myNum, X_INFO,
"warning, can't workaround Mali r3p0 window resize bug\n"); "warning, can't workaround Mali r3p0 window resize bug\n");
} }
if (disp && private->ump_fb_secure_id != UMP_INVALID_SECURE_ID) if (disp && mali->ump_fb_secure_id != UMP_INVALID_SECURE_ID)
xf86DrvMsg(pScreen->myNum, X_INFO, xf86DrvMsg(pScreen->myNum, X_INFO,
"enabled display controller hardware overlays for DRI2\n"); "enabled display controller hardware overlays for DRI2\n");
else if (bUseOverlay) else if (bUseOverlay)
...@@ -1008,61 +1008,61 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, ...@@ -1008,61 +1008,61 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen,
if (!DRI2ScreenInit(pScreen, &info)) { if (!DRI2ScreenInit(pScreen, &info)) {
drmClose(drm_fd); drmClose(drm_fd);
free(private); free(mali);
return NULL; return NULL;
} }
else { else {
SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn); SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn);
/* Wrap the current DestroyWindow function */ /* Wrap the current DestroyWindow function */
private->DestroyWindow = pScreen->DestroyWindow; mali->DestroyWindow = pScreen->DestroyWindow;
pScreen->DestroyWindow = DestroyWindow; pScreen->DestroyWindow = DestroyWindow;
/* Wrap the current PostValidateTree function */ /* Wrap the current PostValidateTree function */
private->PostValidateTree = pScreen->PostValidateTree; mali->PostValidateTree = pScreen->PostValidateTree;
pScreen->PostValidateTree = PostValidateTree; pScreen->PostValidateTree = PostValidateTree;
/* Wrap the current GetImage function */ /* Wrap the current GetImage function */
private->GetImage = pScreen->GetImage; mali->GetImage = pScreen->GetImage;
pScreen->GetImage = GetImage; pScreen->GetImage = GetImage;
/* Wrap the current DestroyPixmap function */ /* Wrap the current DestroyPixmap function */
private->DestroyPixmap = pScreen->DestroyPixmap; mali->DestroyPixmap = pScreen->DestroyPixmap;
pScreen->DestroyPixmap = DestroyPixmap; pScreen->DestroyPixmap = DestroyPixmap;
/* Wrap hardware cursor callback functions */ /* Wrap hardware cursor callback functions */
if (hwc) { if (hwc) {
private->EnableHWCursor = hwc->EnableHWCursor; mali->EnableHWCursor = hwc->EnableHWCursor;
hwc->EnableHWCursor = EnableHWCursor; hwc->EnableHWCursor = EnableHWCursor;
private->DisableHWCursor = hwc->DisableHWCursor; mali->DisableHWCursor = hwc->DisableHWCursor;
hwc->DisableHWCursor = DisableHWCursor; hwc->DisableHWCursor = DisableHWCursor;
} }
private->drm_fd = drm_fd; mali->drm_fd = drm_fd;
private->bSwapbuffersWait = bSwapbuffersWait; mali->bSwapbuffersWait = bSwapbuffersWait;
return private; return mali;
} }
} }
void SunxiMaliDRI2_Close(ScreenPtr pScreen) void SunxiMaliDRI2_Close(ScreenPtr pScreen)
{ {
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
SunxiMaliDRI2 *private = SUNXI_MALI_UMP_DRI2(pScrn); SunxiMaliDRI2 *mali = SUNXI_MALI_UMP_DRI2(pScrn);
SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn); SunxiDispHardwareCursor *hwc = SUNXI_DISP_HWC(pScrn);
/* Unwrap functions */ /* Unwrap functions */
pScreen->DestroyWindow = private->DestroyWindow; pScreen->DestroyWindow = mali->DestroyWindow;
pScreen->PostValidateTree = private->PostValidateTree; pScreen->PostValidateTree = mali->PostValidateTree;
pScreen->GetImage = private->GetImage; pScreen->GetImage = mali->GetImage;
pScreen->DestroyPixmap = private->DestroyPixmap; pScreen->DestroyPixmap = mali->DestroyPixmap;
if (hwc) { if (hwc) {
hwc->EnableHWCursor = private->EnableHWCursor; hwc->EnableHWCursor = mali->EnableHWCursor;
hwc->DisableHWCursor = private->DisableHWCursor; hwc->DisableHWCursor = mali->DisableHWCursor;
} }
if (private->ump_null_handle1 != UMP_INVALID_MEMORY_HANDLE) if (mali->ump_null_handle1 != UMP_INVALID_MEMORY_HANDLE)
ump_reference_release(private->ump_null_handle1); ump_reference_release(mali->ump_null_handle1);
if (private->ump_null_handle2 != UMP_INVALID_MEMORY_HANDLE) if (mali->ump_null_handle2 != UMP_INVALID_MEMORY_HANDLE)
ump_reference_release(private->ump_null_handle2); ump_reference_release(mali->ump_null_handle2);
drmClose(private->drm_fd); drmClose(mali->drm_fd);
DRI2CloseScreen(pScreen); DRI2CloseScreen(pScreen);
} }
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