From 8c1bf9d8fe3948b72795984e625ef46b2f0bf654 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 3 Sep 2012 13:08:05 +1000 Subject: radeon: add pixmap sharing hooks. This hooks into EXA and the dirty tracking to add sharing and output offload support. Signed-off-by: Dave Airlie --- src/radeon_exa.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) (limited to 'src/radeon_exa.c') diff --git a/src/radeon_exa.c b/src/radeon_exa.c index 5c5d9979..0c427355 100644 --- a/src/radeon_exa.c +++ b/src/radeon_exa.c @@ -41,7 +41,7 @@ #include "radeon_probe.h" #include "radeon_version.h" #include "radeon_exa_shared.h" - +#include "radeon_bo_gem.h" #include "xf86.h" @@ -325,6 +325,79 @@ void RADEONEXADestroyPixmap(ScreenPtr pScreen, void *driverPriv) free(driverPriv); } +#ifdef RADEON_PIXMAP_SHARING +Bool RADEONEXASharePixmapBacking(PixmapPtr ppix, ScreenPtr slave, void **fd_handle) +{ + struct radeon_exa_pixmap_priv *driver_priv; + int ret; + int handle; + + driver_priv = exaGetPixmapDriverPrivate(ppix); + + ret = radeon_gem_prime_share_bo(driver_priv->bo, &handle); + if (ret) + return FALSE; + + driver_priv->shared = TRUE; + *fd_handle = (void *)(long)handle; + return TRUE; +} + +Bool RADEONEXASetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle) +{ + ScrnInfoPtr pScrn = xf86ScreenToScrn(ppix->drawable.pScreen); + RADEONInfoPtr info = RADEONPTR(pScrn); + struct radeon_exa_pixmap_priv *driver_priv; + struct radeon_bo *bo; + int ihandle = (int)(long)fd_handle; + uint32_t size = ppix->devKind * ppix->drawable.height; + struct radeon_surface surface; + + driver_priv = exaGetPixmapDriverPrivate(ppix); + + bo = radeon_gem_bo_open_prime(info->bufmgr, ihandle, size); + if (!bo) + return FALSE; + + memset(&surface, 0, sizeof(struct radeon_surface)); + + if (info->ChipFamily >= CHIP_FAMILY_R600 && info->surf_man) { + + surface.npix_x = ppix->drawable.width; + surface.npix_y = ppix->drawable.height; + surface.npix_z = 1; + surface.blk_w = 1; + surface.blk_h = 1; + surface.blk_d = 1; + surface.array_size = 1; + surface.bpe = ppix->drawable.bitsPerPixel / 8; + surface.nsamples = 1; + surface.flags |= RADEON_SURF_SET(RADEON_SURF_TYPE_2D, TYPE); + surface.flags |= RADEON_SURF_SET(RADEON_SURF_MODE_LINEAR, MODE); + if (radeon_surface_best(info->surf_man, &surface)) { + return FALSE; + } + if (radeon_surface_init(info->surf_man, &surface)) { + return FALSE; + } + /* we have to post hack the surface to reflect the actual size + of the shared pixmap */ + surface.level[0].pitch_bytes = ppix->devKind; + surface.level[0].nblk_x = ppix->devKind / surface.bpe; + } + driver_priv->surface = surface; + driver_priv->shared = TRUE; + driver_priv->tiling_flags = 0; + radeon_set_pixmap_bo(ppix, bo); + + close(ihandle); + /* we have a reference from the alloc and one from set pixmap bo, + drop one */ + radeon_bo_unref(bo); + return TRUE; +} +#endif + uint32_t radeon_get_pixmap_tiling(PixmapPtr pPix) { struct radeon_exa_pixmap_priv *driver_priv; -- cgit v1.2.3