summaryrefslogtreecommitdiff
path: root/src/radeon_exa.c
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2013-03-15 18:28:27 +0100
committerMichel Dänzer <michel@daenzer.net>2013-03-22 10:54:31 +0100
commitad1d8874fab30257ba8ec8bee8ffa42a8fa9b5c0 (patch)
tree5bd7c2aea76722936112d3a42b637c5ee3ba090f /src/radeon_exa.c
parent35b384a00a0c76ea556f55787fccc95ecd51bc0c (diff)
glamor: Initial PRIME pixmap sharing hooks.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=57200 Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Tested-by: Christoph Haag <haagch.christoph@googlemail.com> Tested-by: linedot <linedot@xcpp.org>
Diffstat (limited to 'src/radeon_exa.c')
-rw-r--r--src/radeon_exa.c63
1 files changed, 7 insertions, 56 deletions
diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index 22e2cefb..fcafb680 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -41,7 +41,6 @@
#include "radeon_probe.h"
#include "radeon_version.h"
#include "radeon_exa_shared.h"
-#include "radeon_bo_gem.h"
#include "xf86.h"
@@ -315,72 +314,24 @@ void RADEONEXADestroyPixmap(ScreenPtr pScreen, void *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;
+ struct radeon_exa_pixmap_priv *driver_priv = exaGetPixmapDriverPrivate(ppix);
- driver_priv = exaGetPixmapDriverPrivate(ppix);
-
- ret = radeon_gem_prime_share_bo(driver_priv->bo, &handle);
- if (ret)
+ if (!radeon_share_pixmap_backing(driver_priv->bo, fd_handle))
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;
+ struct radeon_exa_pixmap_priv *driver_priv = exaGetPixmapDriverPrivate(ppix);
+
+ if (!radeon_set_shared_pixmap_backing(ppix, fd_handle, &driver_priv->surface))
+ return FALSE;
+
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