static inline Bool
canexchange(DrawablePtr pDraw, struct armsoc_bo *src_bo, struct armsoc_bo *dst_bo)
{
	Bool ret = FALSE;
	ScreenPtr pScreen = pDraw->pScreen;
	PixmapPtr pRootPixmap, pWindowPixmap;
	int src_fb_id, dst_fb_id;

	pRootPixmap = pScreen->GetWindowPixmap(pScreen->root);
	pWindowPixmap = pDraw->type == DRAWABLE_PIXMAP ? (PixmapPtr)pDraw : pScreen->GetWindowPixmap((WindowPtr)pDraw);

	src_fb_id = armsoc_bo_get_fb(src_bo);
	dst_fb_id = armsoc_bo_get_fb(dst_bo);

	if (pRootPixmap != pWindowPixmap &&
	    armsoc_bo_width(src_bo) == armsoc_bo_width(dst_bo) &&
	    armsoc_bo_height(src_bo) == armsoc_bo_height(dst_bo) &&
	    armsoc_bo_bpp(src_bo) == armsoc_bo_bpp(dst_bo) &&
	    armsoc_bo_width(src_bo) == pDraw->width &&
	    armsoc_bo_height(src_bo) == pDraw->height &&
	    armsoc_bo_bpp(src_bo) == pDraw->bitsPerPixel &&
	    src_fb_id == 0 && dst_fb_id == 0) {
		ret = TRUE;
	}

	return ret;
}
Exemplo n.º 2
0
void
ExaCheckCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
    DrawablePtr pDrawable = &pWin->drawable;
    ScreenPtr pScreen = pDrawable->pScreen;

    EXA_PRE_FALLBACK(pScreen);
    EXA_FALLBACK(("from %p\n", pWin));

    /* Only need the source bits, the destination region will be overwritten */
    if (pExaScr->prepare_access_reg) {
        PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
        int xoff, yoff;

        exaGetDrawableDeltas(&pWin->drawable, pPixmap, &xoff, &yoff);
        RegionTranslate(prgnSrc, xoff, yoff);
        pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, prgnSrc);
        RegionTranslate(prgnSrc, -xoff, -yoff);
    }
    else
        exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);

    swap(pExaScr, pScreen, CopyWindow);
    pScreen->CopyWindow(pWin, ptOldOrg, prgnSrc);
    swap(pExaScr, pScreen, CopyWindow);
    exaFinishAccess(pDrawable, EXA_PREPARE_SRC);
    EXA_POST_FALLBACK(pScreen);
}
Exemplo n.º 3
0
Arquivo: dri2.c Projeto: csulmone/X11
static unsigned long
DRI2DrawableSerial(DrawablePtr pDraw)
{
    ScreenPtr pScreen = pDraw->pScreen;
    PixmapPtr pPix;

    if (pDraw->type != DRAWABLE_WINDOW)
        return pDraw->serialNumber;

    pPix = pScreen->GetWindowPixmap((WindowPtr) pDraw);
    return pPix->drawable.serialNumber;
}
Exemplo n.º 4
0
static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr  pDraw,
        unsigned int attachment,
        unsigned int format)
{
    ScreenPtr                pScreen  = pDraw->pScreen;
    ScrnInfoPtr              pScrn    = xf86Screens[pScreen->myNum];
    PixmapPtr                pPixmap  = NULL;
    DRI2Buffer2Ptr           buffer   = calloc(1, sizeof *buffer);
    MaliDRI2BufferPrivatePtr privates = calloc(1, sizeof *privates);
    ump_handle               handle;
    size_t                   size;

    if (pDraw->type == DRAWABLE_WINDOW) {
        pPixmap = pScreen->GetWindowPixmap((WindowPtr)pDraw);
    } else {
        ErrorF("Unexpected pDraw->type (%d) in MaliDRI2CreateBuffer\n", pDraw->type);
        return NULL;
    }

    /* initialize buffer info to default values */
    buffer->attachment    = attachment;
    buffer->driverPrivate = privates;
    buffer->format        = format;
    buffer->flags         = 0;
    buffer->cpp           = pPixmap->drawable.bitsPerPixel / 8;
    buffer->pitch         = PixmapBytePad(pDraw->width, pDraw->depth);

    /* allocate UMP buffer */
    size   = pDraw->height * buffer->pitch;
    handle = ump_ref_drv_allocate(size, UMP_REF_DRV_CONSTRAINT_PHYSICALLY_LINEAR |
                                  UMP_REF_DRV_CONSTRAINT_USE_CACHE);
    if (handle == UMP_INVALID_MEMORY_HANDLE) {
        ErrorF("invalid UMP handle, bufsize=%d\n", (int)size);
    }

    privates->size   = size;
    privates->handle = handle;
    privates->addr   = ump_mapped_pointer_get(handle);
    privates->width  = pDraw->width;
    privates->height = pDraw->height;
    privates->depth  = pDraw->depth;

    buffer->name     = ump_secure_id_get(handle);
    buffer->flags    = 0; /* offset */

//    ErrorF("MaliDRI2CreateBuffer attachment=%d %p, format=%d, cpp=%d, depth=%d\n",
//           attachment, buffer, format, buffer->cpp, privates->depth);
    return buffer;
}
Exemplo n.º 5
0
static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr  pDraw,
                                           unsigned int attachment,
                                           unsigned int format)
{
    ScreenPtr                pScreen  = pDraw->pScreen;
    ScrnInfoPtr              pScrn    = xf86Screens[pScreen->myNum];
    DRI2Buffer2Ptr           buffer;
    MaliDRI2BufferPrivatePtr privates;
    ump_handle               handle;
    FBDevPtr pMxv = FBDEVPTR(pScrn);
    Rk30MaliPtr rk_3d = pMxv->Rk30Mali;
    OvlHWPtr overlay = pMxv->OvlHW;
    Bool                     can_use_overlay = TRUE;
    PixmapPtr                pWindowPixmap;

    if (pDraw->type == DRAWABLE_WINDOW &&
        (pWindowPixmap = pScreen->GetWindowPixmap((WindowPtr)pDraw)))
    {
        DebugMsg("win=%p (w=%d, h=%d, x=%d, y=%d) has backing pix=%p (w=%d, h=%d, screen_x=%d, screen_y=%d)\n",
                 pDraw, pDraw->width, pDraw->height, pDraw->x, pDraw->y,
                 pWindowPixmap, pWindowPixmap->drawable.width, pWindowPixmap->drawable.height,
                 pWindowPixmap->screen_x, pWindowPixmap->screen_y);
    }

    if(attachment != DRI2BufferBackLeft && rk_3d->buf_back != NULL){
	DebugMsg("DRI2 return NullBuffer\n");
	return rk_3d->buf_back;
    }

    if (!(buffer = calloc(1, sizeof *buffer))) {
        ErrorF("MaliDRI2CreateBuffer: calloc failed\n");
        return NULL;
    }


    /* If it is a pixmap, just migrate this pixmap to UMP buffer */
    if (pDraw->type == DRAWABLE_PIXMAP)
    {
        if (!(privates = MigratePixmapToUMP((PixmapPtr)pDraw))) {
            ErrorF("MaliDRI2CreateBuffer: MigratePixmapToUMP failed\n");
            free(buffer);
            return NULL;
        }
        privates->refcount++;
        buffer->attachment    = attachment;
        buffer->driverPrivate = privates;
        buffer->format        = format;
        buffer->flags         = 0;
        buffer->cpp           = pDraw->bitsPerPixel / 8;
        buffer->pitch         = ((PixmapPtr)pDraw)->devKind;
        buffer->name = ump_secure_id_get(privates->handle);

        DebugMsg("DRI2CreateBuffer pix=%p, buf=%p:%p, att=%d, ump=%d:%d, w=%d, h=%d, cpp=%d, depth=%d\n",
                 pDraw, buffer, privates, attachment, buffer->name, buffer->flags,
                 privates->width, privates->height, buffer->cpp, privates->depth);

        return buffer;
    }

    /* The drawable must be a window for using hardware overlays */
    if (pDraw->type != DRAWABLE_WINDOW){
        ErrorF("Unexpected pDraw->type (%d) in MaliDRI2CreateBuffer\n", pDraw->type);
        return NULL;
    }

    if (!(privates = calloc(1, sizeof *privates))) {
        ErrorF("MaliDRI2CreateBuffer: calloc failed\n");
        free(buffer);
        return NULL;
    }

    /* We could not get framebuffer secure id */
    if (rk_3d->ump_fb_secure_id1 == UMP_INVALID_SECURE_ID)
        can_use_overlay = FALSE;

    /* Overlay is already used by a different window */
    if (rk_3d->pOverlayWin && rk_3d->pOverlayWin != (void *)pDraw)
        can_use_overlay = FALSE;

    /* TODO: try to support other color depths later */
    if (pDraw->bitsPerPixel != 32)
        can_use_overlay = FALSE;

    /* The default common values */
    buffer->attachment    = attachment;
    buffer->driverPrivate = privates;
    buffer->format        = format;
    buffer->flags         = 0;
    buffer->cpp           = pDraw->bitsPerPixel / 8;
    /* Stride must be 8 bytes aligned for Mali400 */
//    buffer->pitch         = ((buffer->cpp * pDraw->width + 7) / 8) * 8;
    buffer->pitch         = ((buffer->cpp * overlay->cur_var.xres_virtual + 7) / 8) * 8;
    privates->size     = pDraw->height * buffer->pitch;
    privates->width    = pDraw->width;
    privates->height   = pDraw->height;
    privates->depth    = pDraw->depth;

/*    if (disp && disp->framebuffer_size - disp->gfx_layer_size < privates->size) {
        DebugMsg("Not enough space in the offscreen framebuffer (wanted %d for DRI2)\n",
                 privates->size);
        can_use_overlay = FALSE;
    }
*/
/*
    if((pDraw->width+pDraw->x) > overlay->cur_var.xres ||
		(pDraw->height+pDraw->y) > overlay->cur_var.yres)
        can_use_overlay = FALSE;
*/
    if(pDraw->width < 2 || pDraw->height < 2){
     can_use_overlay = FALSE;
    }

    if(attachment != DRI2BufferBackLeft){
//     can_use_overlay = FALSE;
	free(privates);
	buffer->driverPrivate = NULL;
	buffer->name = UMP_INVALID_SECURE_ID;
	if(rk_3d->buf_back == NULL)
	    rk_3d->buf_back = buffer;
	goto end;
    }

    if(rk_3d->OvlPg == ERRORL){
	rk_3d->OvlPg = OvlAllocLay(pScrn, ANYL);
	if(rk_3d->OvlPg == ERRORL)
	    can_use_overlay = FALSE;
	else{//init
	    OvlSetupFb(pScrn, 0, 0, rk_3d->OvlPg);
	    OvlEnable(pScrn, rk_3d->OvlPg, 1);
	}
    }

    rk_3d->bOverlayWinEnabled = can_use_overlay;

    if (can_use_overlay)
        rk_3d->pOverlayWin = (WindowPtr)pDraw;
//	buffer->pitch         = ((buffer->cpp * overlay->OvlLay[rk_3d->OvlPg].var.xres_virtual + 7) / 8) * 8;
//	rk_3d->bOverlayWinEnabled = TRUE;


// Stride must be 8 bytes aligned for Mali400
//	privates->size   = pDraw->height * buffer->pitch;
//	buffer->flags = 0;

	privates->handle = UMP_INVALID_MEMORY_HANDLE;
	privates->addr = NULL;
	buffer->name = rk_3d->ump_fb_secure_id1;
	privates->handle = ump_handle_create_from_secure_id(buffer->name);
	privates->addr = ump_mapped_pointer_get(privates->handle);
//        privates->addr = NULL;//(void*)0x94000000;
/*    }
    else
    {
//	rk_3d->bOverlayWinEnabled = FALSE;
//        Allocate UMP memory buffer
#ifdef HAVE_LIBUMP_CACHE_CONTROL
        privates->handle = ump_ref_drv_allocate(privates->size,
                                    UMP_REF_DRV_CONSTRAINT_PHYSICALLY_LINEAR |
                                    UMP_REF_DRV_CONSTRAINT_USE_CACHE);
        ump_cache_operations_control(UMP_CACHE_OP_START);
        ump_switch_hw_usage_secure_id(ump_secure_id_get(privates->handle),
                                      UMP_USED_BY_MALI);
        ump_cache_operations_control(UMP_CACHE_OP_FINISH);
#else
        privates->handle = ump_ref_drv_allocate(privates->size,
                                    UMP_REF_DRV_CONSTRAINT_PHYSICALLY_LINEAR);
#endif
        if (privates->handle == UMP_INVALID_MEMORY_HANDLE) {
            ErrorF("Failed to allocate UMP buffer (size=%d)\n",
                   (int)privates->size);
        }
        privates->addr = ump_mapped_pointer_get(privates->handle);
        buffer->name = ump_secure_id_get(privates->handle);
        buffer->flags = 0;

    }
*/
end:
    DebugMsg("DRI2CreateBuffer win=%p, buf=%p:%p, att=%d, ump=%d:%d, w=%d, h=%d, cpp=%d, depth=%d adr=%p\n",
             pDraw, buffer, privates, attachment, buffer->name, buffer->flags,
             privates->width, privates->height, buffer->cpp, privates->depth,privates->addr);

    return buffer;
}