diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2015-03-27 12:16:44 +0900 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2015-03-30 10:59:20 +0900 |
commit | ccbda955ebae1d457d35293833f12791e0f9fb0b (patch) | |
tree | ea684f130acf1a6813fad69148ce1904a1086533 /src | |
parent | de5ddd09db82141b263338dcf0c28e01f58268ee (diff) |
Move get_pixmap_handle helper to radeon_bo_helper.c
No functional change.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Tested-by: Nick Sarnie <commendsarnex@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/radeon_bo_helper.c | 49 | ||||
-rw-r--r-- | src/radeon_bo_helper.h | 3 | ||||
-rw-r--r-- | src/radeon_present.c | 53 |
3 files changed, 55 insertions, 50 deletions
diff --git a/src/radeon_bo_helper.c b/src/radeon_bo_helper.c index c3a2d631..f45aa767 100644 --- a/src/radeon_bo_helper.c +++ b/src/radeon_bo_helper.c @@ -25,6 +25,7 @@ #endif #include "radeon.h" +#include "radeon_glamor.h" #ifdef RADEON_PIXMAP_SHARING #include "radeon_bo_gem.h" @@ -187,6 +188,54 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth, return bo; } +/* Get GEM handle for the pixmap */ +Bool radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle) +{ + struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap); +#ifdef USE_GLAMOR + ScreenPtr screen = pixmap->drawable.pScreen; + RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(screen)); +#endif + + if (bo) { + *handle = bo->handle; + return TRUE; + } + +#ifdef USE_GLAMOR + if (info->use_glamor) { + struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); + CARD16 stride; + CARD32 size; + int fd, r; + + if (!priv) { + priv = calloc(1, sizeof(*priv)); + radeon_set_pixmap_private(pixmap, priv); + } + + if (priv->handle_valid) { + *handle = priv->handle; + return TRUE; + } + + fd = glamor_fd_from_pixmap(screen, pixmap, &stride, &size); + if (fd < 0) + return FALSE; + + r = drmPrimeFDToHandle(info->dri2.drm_fd, fd, &priv->handle); + close(fd); + if (r == 0) { + priv->handle_valid = TRUE; + *handle = priv->handle; + return TRUE; + } + } +#endif + + return FALSE; +} + #ifdef RADEON_PIXMAP_SHARING Bool radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p) diff --git a/src/radeon_bo_helper.h b/src/radeon_bo_helper.h index 9c3d73f9..89ad4be0 100644 --- a/src/radeon_bo_helper.h +++ b/src/radeon_bo_helper.h @@ -29,6 +29,9 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth, struct radeon_surface *new_surface, uint32_t *new_tiling); extern Bool +radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle); + +extern Bool radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p); extern Bool diff --git a/src/radeon_present.c b/src/radeon_present.c index 711b45d3..b4021107 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -42,6 +42,7 @@ #include <time.h> #include <errno.h> +#include "radeon_bo_helper.h" #include "radeon_glamor.h" #include "radeon_video.h" @@ -217,54 +218,6 @@ get_drmmode_crtc(ScrnInfoPtr scrn, RRCrtcPtr crtc) return NULL; } -static Bool -radeon_present_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle) -{ - struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap); -#ifdef USE_GLAMOR - ScreenPtr screen = pixmap->drawable.pScreen; - RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(screen)); -#endif - - if (bo) { - *handle = bo->handle; - return TRUE; - } - -#ifdef USE_GLAMOR - if (info->use_glamor) { - struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); - CARD16 stride; - CARD32 size; - int fd, r; - - if (!priv) { - priv = calloc(1, sizeof(*priv)); - radeon_set_pixmap_private(pixmap, priv); - } - - if (priv->handle_valid) { - *handle = priv->handle; - return TRUE; - } - - fd = glamor_fd_from_pixmap(screen, pixmap, &stride, &size); - if (fd < 0) - return FALSE; - - r = drmPrimeFDToHandle(info->dri2.drm_fd, fd, &priv->handle); - close(fd); - if (r == 0) { - priv->handle_valid = TRUE; - *handle = priv->handle; - return TRUE; - } - } -#endif - - return FALSE; -} - /* * Test to see if page flipping is possible on the target crtc */ @@ -340,7 +293,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, if (!radeon_present_check_flip(crtc, screen->root, pixmap, sync_flip)) return FALSE; - if (!radeon_present_get_pixmap_handle(pixmap, &handle)) + if (!radeon_get_pixmap_handle(pixmap, &handle)) return FALSE; event = calloc(1, sizeof(struct radeon_present_vblank_event)); @@ -374,7 +327,7 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id) if (!radeon_present_check_flip(NULL, screen->root, pixmap, TRUE)) return; - if (!radeon_present_get_pixmap_handle(pixmap, &handle)) + if (!radeon_get_pixmap_handle(pixmap, &handle)) return; event = calloc(1, sizeof(struct radeon_present_vblank_event)); |