mirror of
https://github.com/X11Libre/xf86-video-amdgpu.git
synced 2026-03-24 01:24:31 +00:00
Create amdgpu_pixmap_get_fb_ptr helper
Preparatory, no functional change intended yet. Also inline amdgpu_pixmap_create_fb into amdgpu_pixmap_get_fb, since there's only one call-site. (Ported from radeon commit 20f6b56fdb74d88086e8e094013fedbb14e50a24) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Michel Dänzer
parent
5af396253f
commit
6b376c8d73
@@ -121,24 +121,10 @@ amdgpu_fb_create(int drm_fd, uint32_t width, uint32_t height, uint8_t depth,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct drmmode_fb*
|
||||
amdgpu_pixmap_create_fb(int drm_fd, PixmapPtr pix)
|
||||
{
|
||||
uint32_t handle;
|
||||
|
||||
if (!amdgpu_pixmap_get_handle(pix, &handle))
|
||||
return NULL;
|
||||
|
||||
return amdgpu_fb_create(drm_fd, pix->drawable.width, pix->drawable.height,
|
||||
pix->drawable.depth, pix->drawable.bitsPerPixel,
|
||||
pix->devKind, handle);
|
||||
}
|
||||
|
||||
static inline struct drmmode_fb*
|
||||
amdgpu_pixmap_get_fb(PixmapPtr pix)
|
||||
static inline struct drmmode_fb**
|
||||
amdgpu_pixmap_get_fb_ptr(PixmapPtr pix)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(pix->drawable.pScreen);
|
||||
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
|
||||
AMDGPUInfoPtr info = AMDGPUPTR(scrn);
|
||||
|
||||
if (info->use_glamor) {
|
||||
@@ -147,15 +133,37 @@ amdgpu_pixmap_get_fb(PixmapPtr pix)
|
||||
if (!priv)
|
||||
return NULL;
|
||||
|
||||
if (!priv->fb)
|
||||
priv->fb = amdgpu_pixmap_create_fb(pAMDGPUEnt->fd, pix);
|
||||
|
||||
return priv->fb;
|
||||
return &priv->fb;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct drmmode_fb*
|
||||
amdgpu_pixmap_get_fb(PixmapPtr pix)
|
||||
{
|
||||
struct drmmode_fb **fb_ptr = amdgpu_pixmap_get_fb_ptr(pix);
|
||||
|
||||
if (!fb_ptr)
|
||||
return NULL;
|
||||
|
||||
if (!*fb_ptr) {
|
||||
uint32_t handle;
|
||||
|
||||
if (amdgpu_pixmap_get_handle(pix, &handle)) {
|
||||
ScrnInfoPtr scrn = xf86ScreenToScrn(pix->drawable.pScreen);
|
||||
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
|
||||
|
||||
*fb_ptr = amdgpu_fb_create(pAMDGPUEnt->fd, pix->drawable.width,
|
||||
pix->drawable.height, pix->drawable.depth,
|
||||
pix->drawable.bitsPerPixel, pix->devKind,
|
||||
handle);
|
||||
}
|
||||
}
|
||||
|
||||
return *fb_ptr;
|
||||
}
|
||||
|
||||
enum {
|
||||
AMDGPU_CREATE_PIXMAP_DRI2 = 0x08000000,
|
||||
AMDGPU_CREATE_PIXMAP_LINEAR = 0x04000000,
|
||||
|
||||
Reference in New Issue
Block a user