summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2017-08-24 17:10:29 +0900
committerMichel Dänzer <michel@daenzer.net>2017-08-29 16:34:54 +0900
commit20f6b56fdb74d88086e8e094013fedbb14e50a24 (patch)
tree08d49caa0eaff62a0e5bf9c035ab475fd9fd4cae
parent4bc992c31059eb50e22df4ebf5b92d08411f41ef (diff)
Create radeon_pixmap_get_fb_ptr helper
Preparatory, no functional change intended yet. Also inline radeon_pixmap_create_fb into radeon_pixmap_get_fb, since there's only one call-site anymore. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--src/radeon.h53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/radeon.h b/src/radeon.h
index 71123c7c..5ce9999a 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -842,24 +842,10 @@ radeon_fb_create(int drm_fd, uint32_t width, uint32_t height, uint8_t depth,
return NULL;
}
-static inline struct drmmode_fb*
-radeon_pixmap_create_fb(int drm_fd, PixmapPtr pix)
-{
- uint32_t handle;
-
- if (!radeon_get_pixmap_handle(pix, &handle))
- return NULL;
-
- return radeon_fb_create(drm_fd, pix->drawable.width, pix->drawable.height,
- pix->drawable.depth, pix->drawable.bitsPerPixel,
- pix->devKind, handle);
-}
-
-static inline struct drmmode_fb*
-radeon_pixmap_get_fb(PixmapPtr pix)
+static inline struct drmmode_fb**
+radeon_pixmap_get_fb_ptr(PixmapPtr pix)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(pix->drawable.pScreen);
- RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
RADEONInfoPtr info = RADEONPTR(scrn);
#ifdef USE_GLAMOR
@@ -869,10 +855,7 @@ radeon_pixmap_get_fb(PixmapPtr pix)
if (!priv)
return NULL;
- if (!priv->fb)
- priv->fb = radeon_pixmap_create_fb(pRADEONEnt->fd, pix);
-
- return priv->fb;
+ return &priv->fb;
} else
#endif
if (info->accelOn)
@@ -883,15 +866,37 @@ radeon_pixmap_get_fb(PixmapPtr pix)
if (!driver_priv)
return NULL;
- if (!driver_priv->fb)
- driver_priv->fb = radeon_pixmap_create_fb(pRADEONEnt->fd, pix);
-
- return driver_priv->fb;
+ return &driver_priv->fb;
}
return NULL;
}
+static inline struct drmmode_fb*
+radeon_pixmap_get_fb(PixmapPtr pix)
+{
+ struct drmmode_fb **fb_ptr = radeon_pixmap_get_fb_ptr(pix);
+
+ if (!fb_ptr)
+ return NULL;
+
+ if (!*fb_ptr) {
+ uint32_t handle;
+
+ if (radeon_get_pixmap_handle(pix, &handle)) {
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pix->drawable.pScreen);
+ RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
+
+ *fb_ptr = radeon_fb_create(pRADEONEnt->fd, pix->drawable.width,
+ pix->drawable.height, pix->drawable.depth,
+ pix->drawable.bitsPerPixel, pix->devKind,
+ handle);
+ }
+ }
+
+ return *fb_ptr;
+}
+
#define CP_PACKET0(reg, n) \
(RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2))
#define CP_PACKET1(reg0, reg1) \