[PATCH 1/2] Move get_pixmap_handle helper to radeon_bo_helper.c

Alex Deucher alexdeucher at gmail.com
Fri Mar 27 08:12:03 PDT 2015


On Thu, Mar 26, 2015 at 11:37 PM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> No functional change.
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

For the series:
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  src/radeon_bo_helper.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
>  src/radeon_bo_helper.h |  3 +++
>  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 c3a2d63..f45aa76 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 9c3d73f..89ad4be 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 711b45d..b402110 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));
> --
> 2.1.4
>
> _______________________________________________
> xorg-driver-ati mailing list
> xorg-driver-ati at lists.x.org
> http://lists.x.org/mailman/listinfo/xorg-driver-ati


More information about the xorg-driver-ati mailing list