summaryrefslogtreecommitdiff
path: root/driver/xf86-video-amdgpu/src
diff options
context:
space:
mode:
Diffstat (limited to 'driver/xf86-video-amdgpu/src')
-rw-r--r--driver/xf86-video-amdgpu/src/Makefile.in1
-rw-r--r--driver/xf86-video-amdgpu/src/amdgpu_bo_helper.c2
-rw-r--r--driver/xf86-video-amdgpu/src/amdgpu_dri3.c4
-rw-r--r--driver/xf86-video-amdgpu/src/amdgpu_drv.h12
-rw-r--r--driver/xf86-video-amdgpu/src/amdgpu_glamor.c20
-rw-r--r--driver/xf86-video-amdgpu/src/amdgpu_kms.c144
-rw-r--r--driver/xf86-video-amdgpu/src/amdgpu_probe.c258
-rw-r--r--driver/xf86-video-amdgpu/src/amdgpu_probe.h1
-rw-r--r--driver/xf86-video-amdgpu/src/compat-api.h6
-rw-r--r--driver/xf86-video-amdgpu/src/drmmode_display.c172
-rw-r--r--driver/xf86-video-amdgpu/src/drmmode_display.h30
11 files changed, 279 insertions, 371 deletions
diff --git a/driver/xf86-video-amdgpu/src/Makefile.in b/driver/xf86-video-amdgpu/src/Makefile.in
index 4afc362b7..2fd50a2a5 100644
--- a/driver/xf86-video-amdgpu/src/Makefile.in
+++ b/driver/xf86-video-amdgpu/src/Makefile.in
@@ -333,6 +333,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
diff --git a/driver/xf86-video-amdgpu/src/amdgpu_bo_helper.c b/driver/xf86-video-amdgpu/src/amdgpu_bo_helper.c
index 3f622142d..df32f5d75 100644
--- a/driver/xf86-video-amdgpu/src/amdgpu_bo_helper.c
+++ b/driver/xf86-video-amdgpu/src/amdgpu_bo_helper.c
@@ -79,7 +79,7 @@ struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width,
}
pixmap_buffer->ref_count = 1;
- if ( bitsPerPixel == pScrn->bitsPerPixel)
+ if (usage_hint & AMDGPU_CREATE_PIXMAP_SCANOUT)
bo_use |= GBM_BO_USE_SCANOUT;
#ifdef HAVE_GBM_BO_USE_LINEAR
diff --git a/driver/xf86-video-amdgpu/src/amdgpu_dri3.c b/driver/xf86-video-amdgpu/src/amdgpu_dri3.c
index 09e21126f..298626aea 100644
--- a/driver/xf86-video-amdgpu/src/amdgpu_dri3.c
+++ b/driver/xf86-video-amdgpu/src/amdgpu_dri3.c
@@ -47,7 +47,7 @@ extern int priv_open_device(const char *);
#define priv_open_device(n) open(n,O_RDWR|O_CLOEXEC)
#endif
-static int open_master_node(ScreenPtr screen, int *out)
+static int open_card_node(ScreenPtr screen, int *out)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
@@ -118,7 +118,7 @@ amdgpu_dri3_open(ScreenPtr screen, RRProviderPtr provider, int *out)
ret = open_render_node(screen, out);
if (ret != Success)
- ret = open_master_node(screen, out);
+ ret = open_card_node(screen, out);
return ret;
}
diff --git a/driver/xf86-video-amdgpu/src/amdgpu_drv.h b/driver/xf86-video-amdgpu/src/amdgpu_drv.h
index 0ae171fe6..e2e162e3a 100644
--- a/driver/xf86-video-amdgpu/src/amdgpu_drv.h
+++ b/driver/xf86-video-amdgpu/src/amdgpu_drv.h
@@ -168,18 +168,18 @@ typedef enum {
} AMDGPUOpts;
static inline ScreenPtr
-amdgpu_master_screen(ScreenPtr screen)
+amdgpu_primary_screen(ScreenPtr screen)
{
- if (screen->current_master)
- return screen->current_master;
+ if (screen->current_primary)
+ return screen->current_primary;
return screen;
}
static inline ScreenPtr
-amdgpu_dirty_master(PixmapDirtyUpdatePtr dirty)
+amdgpu_dirty_primary(PixmapDirtyUpdatePtr dirty)
{
- return amdgpu_master_screen(dirty->slave_dst->drawable.pScreen);
+ return amdgpu_primary_screen(dirty->secondary_dst->drawable.pScreen);
}
static inline DrawablePtr
@@ -248,8 +248,6 @@ extern DevScreenPrivateKeyRec amdgpu_device_private_key;
typedef struct {
EntityInfoPtr pEnt;
- struct pci_device *PciInfo;
- int Chipset;
uint32_t family;
struct gbm_device *gbm;
diff --git a/driver/xf86-video-amdgpu/src/amdgpu_glamor.c b/driver/xf86-video-amdgpu/src/amdgpu_glamor.c
index 5b8d5606b..fb7a46bcb 100644
--- a/driver/xf86-video-amdgpu/src/amdgpu_glamor.c
+++ b/driver/xf86-video-amdgpu/src/amdgpu_glamor.c
@@ -201,14 +201,16 @@ amdgpu_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
unsigned usage)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ PixmapFormatPtr format = xf86GetPixFormat(scrn, depth);
AMDGPUInfoPtr info = AMDGPUPTR(scrn);
struct amdgpu_pixmap *priv;
PixmapPtr pixmap, new_pixmap = NULL;
- if (!xf86GetPixFormat(scrn, depth))
+ if (!format)
return NULL;
- if (!AMDGPU_CREATE_PIXMAP_SHARED(usage)) {
+ if (!(usage & AMDGPU_CREATE_PIXMAP_SCANOUT) &&
+ !AMDGPU_CREATE_PIXMAP_SHARED(usage)) {
if (info->shadow_primary) {
if (usage != CREATE_PIXMAP_USAGE_BACKING_PIXMAP)
return fbCreatePixmap(screen, w, h, depth, usage);
@@ -216,9 +218,15 @@ amdgpu_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
usage |= AMDGPU_CREATE_PIXMAP_LINEAR |
AMDGPU_CREATE_PIXMAP_GTT;
} else if (usage != CREATE_PIXMAP_USAGE_BACKING_PIXMAP) {
- pixmap = glamor_create_pixmap(screen, w, h, depth, usage);
- if (pixmap)
- return pixmap;
+ if (w < scrn->virtualX || w > scrn->displayWidth ||
+ h != scrn->virtualY ||
+ format->bitsPerPixel != scrn->bitsPerPixel) {
+ pixmap = glamor_create_pixmap(screen, w, h, depth, usage);
+ if (pixmap)
+ return pixmap;
+ } else {
+ usage |= AMDGPU_CREATE_PIXMAP_SCANOUT;
+ }
}
}
@@ -342,7 +350,7 @@ amdgpu_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap)
static Bool
-amdgpu_glamor_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave,
+amdgpu_glamor_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr secondary,
void **handle_p)
{
ScreenPtr screen = pixmap->drawable.pScreen;
diff --git a/driver/xf86-video-amdgpu/src/amdgpu_kms.c b/driver/xf86-video-amdgpu/src/amdgpu_kms.c
index 6a60f5457..8997759be 100644
--- a/driver/xf86-video-amdgpu/src/amdgpu_kms.c
+++ b/driver/xf86-video-amdgpu/src/amdgpu_kms.c
@@ -283,6 +283,7 @@ static void AMDGPUFreeRec(ScrnInfoPtr pScrn)
amdgpu_unwrap_property_requests(pScrn);
amdgpu_device_deinitialize(pAMDGPUEnt->pDev);
amdgpu_kernel_close_fd(pAMDGPUEnt);
+ free(pAMDGPUEnt->busid);
free(pPriv->ptr);
pPriv->ptr = NULL;
}
@@ -519,8 +520,8 @@ amdgpu_sync_scanout_pixmaps(xf86CrtcPtr xf86_crtc, RegionPtr new_region,
int scanout_id)
{
drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
- DrawablePtr dst = &drmmode_crtc->scanout[scanout_id].pixmap->drawable;
- DrawablePtr src = &drmmode_crtc->scanout[scanout_id ^ 1].pixmap->drawable;
+ DrawablePtr dst = &drmmode_crtc->scanout[scanout_id]->drawable;
+ DrawablePtr src = &drmmode_crtc->scanout[scanout_id ^ 1]->drawable;
RegionPtr last_region = &drmmode_crtc->scanout_last_region;
ScrnInfoPtr scrn = xf86_crtc->scrn;
ScreenPtr pScreen = scrn->pScreen;
@@ -603,8 +604,8 @@ dirty_region(PixmapDirtyUpdatePtr dirty)
if (dirty->rotation != RR_Rotate_0) {
dstregion = transform_region(damageregion,
&dirty->f_inverse,
- dirty->slave_dst->drawable.width,
- dirty->slave_dst->drawable.height);
+ dirty->secondary_dst->drawable.width,
+ dirty->secondary_dst->drawable.height);
} else
#endif
{
@@ -612,7 +613,7 @@ dirty_region(PixmapDirtyUpdatePtr dirty)
dstregion = RegionDuplicate(damageregion);
RegionTranslate(dstregion, -dirty->x, -dirty->y);
- PixmapRegionInit(&pixregion, dirty->slave_dst);
+ PixmapRegionInit(&pixregion, dirty->secondary_dst);
RegionIntersect(dstregion, dstregion, &pixregion);
RegionUninit(&pixregion);
}
@@ -629,8 +630,8 @@ redisplay_dirty(PixmapDirtyUpdatePtr dirty, RegionPtr region)
if (RegionNil(region))
goto out;
- if (dirty->slave_dst->master_pixmap)
- DamageRegionAppend(&dirty->slave_dst->drawable, region);
+ if (dirty->secondary_dst->primary_pixmap)
+ DamageRegionAppend(&dirty->secondary_dst->drawable, region);
#ifdef HAS_DIRTYTRACKING_ROTATION
PixmapSyncDirtyHelper(dirty);
@@ -639,8 +640,8 @@ redisplay_dirty(PixmapDirtyUpdatePtr dirty, RegionPtr region)
#endif
amdgpu_glamor_flush(src_scrn);
- if (dirty->slave_dst->master_pixmap)
- DamageRegionProcessPending(&dirty->slave_dst->drawable);
+ if (dirty->secondary_dst->primary_pixmap)
+ DamageRegionProcessPending(&dirty->secondary_dst->drawable);
out:
DamageEmpty(dirty->damage);
@@ -657,12 +658,12 @@ amdgpu_prime_scanout_update_abort(xf86CrtcPtr crtc, void *event_data)
void
amdgpu_sync_shared_pixmap(PixmapDirtyUpdatePtr dirty)
{
- ScreenPtr master_screen = amdgpu_dirty_master(dirty);
+ ScreenPtr primary_screen = amdgpu_dirty_primary(dirty);
PixmapDirtyUpdatePtr ent;
RegionPtr region;
- xorg_list_for_each_entry(ent, &master_screen->pixmap_dirty_list, ent) {
- if (!amdgpu_dirty_src_equals(dirty, ent->slave_dst))
+ xorg_list_for_each_entry(ent, &primary_screen->pixmap_dirty_list, ent) {
+ if (!amdgpu_dirty_src_equals(dirty, ent->secondary_dst))
continue;
region = dirty_region(ent);
@@ -675,45 +676,45 @@ amdgpu_sync_shared_pixmap(PixmapDirtyUpdatePtr dirty)
#if HAS_SYNC_SHARED_PIXMAP
static Bool
-master_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)
+primary_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)
{
- ScreenPtr master_screen = amdgpu_dirty_master(dirty);
+ ScreenPtr primary_screen = amdgpu_dirty_primary(dirty);
- return master_screen->SyncSharedPixmap != NULL;
+ return primary_screen->SyncSharedPixmap != NULL;
}
static Bool
-slave_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)
+secondary_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)
{
- ScreenPtr slave_screen = dirty->slave_dst->drawable.pScreen;
+ ScreenPtr secondary_screen = dirty->secondary_dst->drawable.pScreen;
- return slave_screen->SyncSharedPixmap != NULL;
+ return secondary_screen->SyncSharedPixmap != NULL;
}
static void
call_sync_shared_pixmap(PixmapDirtyUpdatePtr dirty)
{
- ScreenPtr master_screen = amdgpu_dirty_master(dirty);
+ ScreenPtr primary_screen = amdgpu_dirty_primary(dirty);
- master_screen->SyncSharedPixmap(dirty);
+ primary_screen->SyncSharedPixmap(dirty);
}
#else /* !HAS_SYNC_SHARED_PIXMAP */
static Bool
-master_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)
+primary_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)
{
- ScrnInfoPtr master_scrn = xf86ScreenToScrn(amdgpu_dirty_master(dirty));
+ ScrnInfoPtr primary_scrn = xf86ScreenToScrn(amdgpu_dirty_primary(dirty));
- return master_scrn->driverName == scrn->driverName;
+ return primary_scrn->driverName == scrn->driverName;
}
static Bool
-slave_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)
+secondary_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)
{
- ScrnInfoPtr slave_scrn = xf86ScreenToScrn(dirty->slave_dst->drawable.pScreen);
+ ScrnInfoPtr secondary_scrn = xf86ScreenToScrn(dirty->secondary_dst->drawable.pScreen);
- return slave_scrn->driverName == scrn->driverName;
+ return secondary_scrn->driverName == scrn->driverName;
}
static void
@@ -728,12 +729,12 @@ call_sync_shared_pixmap(PixmapDirtyUpdatePtr dirty)
static xf86CrtcPtr
amdgpu_prime_dirty_to_crtc(PixmapDirtyUpdatePtr dirty)
{
- ScreenPtr screen = dirty->slave_dst->drawable.pScreen;
+ ScreenPtr screen = dirty->secondary_dst->drawable.pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
int c;
- /* Find the CRTC which is scanning out from this slave pixmap */
+ /* Find the CRTC which is scanning out from this secondary pixmap */
for (c = 0; c < xf86_config->num_crtc; c++) {
xf86CrtcPtr xf86_crtc = xf86_config->crtc[c];
drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
@@ -758,7 +759,7 @@ amdgpu_prime_scanout_do_update(xf86CrtcPtr crtc, unsigned scanout_id)
if (amdgpu_dirty_src_equals(dirty, drmmode_crtc->prime_scanout_pixmap)) {
RegionPtr region;
- if (master_has_sync_shared_pixmap(scrn, dirty))
+ if (primary_has_sync_shared_pixmap(scrn, dirty))
call_sync_shared_pixmap(dirty);
region = dirty_region(dirty);
@@ -771,7 +772,7 @@ amdgpu_prime_scanout_do_update(xf86CrtcPtr crtc, unsigned scanout_id)
amdgpu_glamor_flush(scrn);
RegionCopy(&drmmode_crtc->scanout_last_region, region);
RegionTranslate(region, -crtc->x, -crtc->y);
- dirty->slave_dst = drmmode_crtc->scanout[scanout_id].pixmap;
+ dirty->secondary_dst = drmmode_crtc->scanout[scanout_id];
}
redisplay_dirty(dirty, region);
@@ -798,7 +799,7 @@ amdgpu_prime_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t u
static void
amdgpu_prime_scanout_update(PixmapDirtyUpdatePtr dirty)
{
- ScreenPtr screen = dirty->slave_dst->drawable.pScreen;
+ ScreenPtr screen = dirty->secondary_dst->drawable.pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
xf86CrtcPtr xf86_crtc = amdgpu_prime_dirty_to_crtc(dirty);
@@ -810,7 +811,7 @@ amdgpu_prime_scanout_update(PixmapDirtyUpdatePtr dirty)
drmmode_crtc = xf86_crtc->driver_private;
if (drmmode_crtc->scanout_update_pending ||
- !drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap ||
+ !drmmode_crtc->scanout[drmmode_crtc->scanout_id] ||
drmmode_crtc->dpms_mode != DPMSModeOn)
return;
@@ -862,7 +863,7 @@ amdgpu_prime_scanout_update(PixmapDirtyUpdatePtr dirty)
static void
amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)
{
- ScreenPtr screen = ent->slave_dst->drawable.pScreen;
+ ScreenPtr screen = ent->secondary_dst->drawable.pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
xf86CrtcPtr crtc = amdgpu_prime_dirty_to_crtc(ent);
@@ -877,14 +878,14 @@ amdgpu_prime_scanout_flip(PixmapDirtyUpdatePtr ent)
drmmode_crtc = crtc->driver_private;
scanout_id = drmmode_crtc->scanout_id ^ 1;
if (drmmode_crtc->scanout_update_pending ||
- !drmmode_crtc->scanout[scanout_id].pixmap ||
+ !drmmode_crtc->scanout[scanout_id] ||
drmmode_crtc->dpms_mode != DPMSModeOn)
return;
if (!amdgpu_prime_scanout_do_update(crtc, scanout_id))
return;
- fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap);
+ fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id]);
if (!fb) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"Failed to get FB for PRIME flip.\n");
@@ -937,11 +938,11 @@ amdgpu_dirty_update(ScrnInfoPtr scrn)
if (screen->isGPU) {
PixmapDirtyUpdatePtr region_ent = ent;
- if (master_has_sync_shared_pixmap(scrn, ent)) {
- ScreenPtr master_screen = amdgpu_dirty_master(ent);
+ if (primary_has_sync_shared_pixmap(scrn, ent)) {
+ ScreenPtr primary_screen = amdgpu_dirty_primary(ent);
- xorg_list_for_each_entry(region_ent, &master_screen->pixmap_dirty_list, ent) {
- if (amdgpu_dirty_src_equals(ent, region_ent->slave_dst))
+ xorg_list_for_each_entry(region_ent, &primary_screen->pixmap_dirty_list, ent) {
+ if (amdgpu_dirty_src_equals(ent, region_ent->secondary_dst))
break;
}
}
@@ -965,7 +966,7 @@ amdgpu_dirty_update(ScrnInfoPtr scrn)
RegionDestroy(region);
} else {
- if (slave_has_sync_shared_pixmap(scrn, ent))
+ if (secondary_has_sync_shared_pixmap(scrn, ent))
continue;
region = dirty_region(ent);
@@ -975,6 +976,11 @@ amdgpu_dirty_update(ScrnInfoPtr scrn)
}
}
+static void
+amdgpuSourceValidate(DrawablePtr draw, int x, int y, int w, int h,
+ unsigned int subWindowMode)
+{
+}
Bool
amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
@@ -987,11 +993,11 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
DrawablePtr pDraw;
if (!xf86_crtc->enabled ||
- !drmmode_crtc->scanout[scanout_id].pixmap ||
+ !drmmode_crtc->scanout[scanout_id] ||
extents.x1 >= extents.x2 || extents.y1 >= extents.y2)
return FALSE;
- pDraw = &drmmode_crtc->scanout[scanout_id].pixmap->drawable;
+ pDraw = &drmmode_crtc->scanout[scanout_id]->drawable;
if (!amdgpu_scanout_extents_intersect(xf86_crtc, &extents))
return FALSE;
@@ -1031,7 +1037,7 @@ amdgpu_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
SetPicturePictFilter(src, xf86_crtc->filter, xf86_crtc->params,
xf86_crtc->nparams);
- pScreen->SourceValidate = NULL;
+ pScreen->SourceValidate = amdgpuSourceValidate;
CompositePicture(PictOpSrc,
src, NULL, dst,
extents.x1, extents.y1, 0, 0, extents.x1,
@@ -1192,7 +1198,7 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
amdgpu_glamor_flush(scrn);
RegionEmpty(region);
- fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap);
+ fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id]);
if (!fb) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"Failed to get FB for scanout flip.\n");
@@ -1225,8 +1231,7 @@ amdgpu_scanout_flip(ScreenPtr pScreen, AMDGPUInfoPtr info,
&drmmode_crtc->scanout_last_region);
RegionEmpty(&drmmode_crtc->scanout_last_region);
amdgpu_scanout_update(xf86_crtc);
- drmmode_crtc_scanout_destroy(drmmode_crtc->drmmode,
- &drmmode_crtc->scanout[scanout_id]);
+ drmmode_crtc_scanout_destroy(&drmmode_crtc->scanout[scanout_id]);
drmmode_crtc->tear_free = FALSE;
return;
}
@@ -1252,7 +1257,7 @@ static void AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
(*pScreen->BlockHandler) (BLOCKHANDLER_ARGS);
pScreen->BlockHandler = AMDGPUBlockHandler_KMS;
- if (!xf86ScreenToScrn(amdgpu_master_screen(pScreen))->vtSema)
+ if (!xf86ScreenToScrn(amdgpu_primary_screen(pScreen))->vtSema)
return;
if (!pScreen->isGPU)
@@ -1261,12 +1266,12 @@ static void AMDGPUBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
xf86CrtcPtr crtc = xf86_config->crtc[c];
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
- if (drmmode_crtc->rotate.pixmap)
+ if (drmmode_crtc->rotate)
continue;
if (drmmode_crtc->tear_free)
amdgpu_scanout_flip(pScreen, info, crtc);
- else if (drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap)
+ else if (drmmode_crtc->scanout[drmmode_crtc->scanout_id])
amdgpu_scanout_update(crtc);
}
}
@@ -1415,20 +1420,13 @@ static Bool AMDGPUPreInitChipType_KMS(ScrnInfoPtr pScrn,
AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
- info->Chipset = info->PciInfo->device_id;
pScrn->chipset = (char*)amdgpu_get_marketing_name(pAMDGPUEnt->pDev);
if (!pScrn->chipset)
pScrn->chipset = "Unknown AMD Radeon GPU";
- if (info->Chipset < 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Chipset \"%s\" is not recognized\n",
- pScrn->chipset);
- return FALSE;
- }
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
"Chipset: \"%s\" (ChipID = 0x%04x)\n",
- pScrn->chipset, info->Chipset);
+ pScrn->chipset, gpu_info->asic_id);
info->family = gpu_info->family_id;
@@ -1570,7 +1568,6 @@ Bool AMDGPUPreInit_KMS(ScrnInfoPtr pScrn, int flags)
xf86SetPrimInitDone(pScrn->entityList[0]);
}
- info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index);
pScrn->monitor = pScrn->confScreen->monitor;
if (!AMDGPUPreInitVisual(pScrn))
@@ -1853,7 +1850,7 @@ CARD32 cleanup_black_fb(OsTimerPtr timer, CARD32 now, pointer data)
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
int c;
- if (xf86ScreenToScrn(amdgpu_master_screen(screen))->vtSema)
+ if (xf86ScreenToScrn(amdgpu_primary_screen(screen))->vtSema)
return 0;
/* Unreference the all-black FB created by AMDGPULeaveVT_KMS. After
@@ -2209,6 +2206,7 @@ Bool AMDGPUEnterVT_KMS(ScrnInfoPtr pScrn)
struct amdgpu_buffer *front_buffer =
amdgpu_alloc_pixmap_bo(pScrn, pScrn->virtualX,
pScrn->virtualY, pScrn->depth,
+ AMDGPU_CREATE_PIXMAP_SCANOUT |
AMDGPU_CREATE_PIXMAP_LINEAR,
pScrn->bitsPerPixel,
&pitch);
@@ -2270,7 +2268,6 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
if (!info->shadow_fb) {
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- struct drmmode_scanout black_scanout = { .pixmap = NULL, .bo = NULL };
xf86CrtcPtr crtc;
drmmode_crtc_private_ptr drmmode_crtc;
unsigned w = 0, h = 0;
@@ -2296,11 +2293,15 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
/* Make all active CRTCs scan out from an all-black framebuffer */
if (w > 0 && h > 0) {
- if (drmmode_crtc_scanout_create(crtc, &black_scanout, w, h)) {
+ PixmapPtr black_scanout =
+ pScreen->CreatePixmap(pScreen, w, h, pScrn->depth,
+ AMDGPU_CREATE_PIXMAP_SCANOUT);
+
+ if (black_scanout) {
struct drmmode_fb *black_fb =
- amdgpu_pixmap_get_fb(black_scanout.pixmap);
+ amdgpu_pixmap_get_fb(black_scanout);
- amdgpu_pixmap_clear(black_scanout.pixmap);
+ amdgpu_pixmap_clear(black_scanout);
amdgpu_glamor_finish(pScrn);
for (i = 0; i < xf86_config->num_crtc; i++) {
@@ -2319,20 +2320,21 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
}
if (pScrn->is_gpu) {
- if (drmmode_crtc->scanout[0].pixmap)
- pixmap_unref_fb(drmmode_crtc->scanout[0].pixmap);
- if (drmmode_crtc->scanout[1].pixmap)
- pixmap_unref_fb(drmmode_crtc->scanout[1].pixmap);
+ if (drmmode_crtc->scanout[0])
+ pixmap_unref_fb(drmmode_crtc->scanout[0]);
+ if (drmmode_crtc->scanout[1])
+ pixmap_unref_fb(drmmode_crtc->scanout[1]);
} else {
drmmode_crtc_scanout_free(crtc);
}
}
}
+
+ pScreen->DestroyPixmap(black_scanout);
}
}
xf86RotateFreeShadow(pScrn);
- drmmode_crtc_scanout_destroy(&info->drmmode, &black_scanout);
/* Unreference FBs of all pixmaps. After this, the only FB remaining
* should be the all-black one being scanned out by active CRTCs
@@ -2415,12 +2417,12 @@ static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen)
if (!info->front_buffer) {
int pitch;
- int hint = 0;
+ int hint = AMDGPU_CREATE_PIXMAP_SCANOUT;
if (info->shadow_primary)
- hint = AMDGPU_CREATE_PIXMAP_LINEAR | AMDGPU_CREATE_PIXMAP_GTT;
+ hint |= AMDGPU_CREATE_PIXMAP_LINEAR | AMDGPU_CREATE_PIXMAP_GTT;
else if (!info->use_glamor)
- hint = AMDGPU_CREATE_PIXMAP_LINEAR;
+ hint |= AMDGPU_CREATE_PIXMAP_LINEAR;
info->front_buffer =
amdgpu_alloc_pixmap_bo(pScrn, pScrn->virtualX,
diff --git a/driver/xf86-video-amdgpu/src/amdgpu_probe.c b/driver/xf86-video-amdgpu/src/amdgpu_probe.c
index 2dc934ff6..71304668b 100644
--- a/driver/xf86-video-amdgpu/src/amdgpu_probe.c
+++ b/driver/xf86-video-amdgpu/src/amdgpu_probe.c
@@ -33,6 +33,8 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
/*
* Authors:
@@ -48,12 +50,17 @@
#include "xf86.h"
#include "xf86drmMode.h"
-#include "dri.h"
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <xf86_OSproc.h>
#endif
+#ifdef X_PRIVSEP
+extern int priv_open_device(const char *);
+#else
+#define priv_open_device(n) open(n,O_RDWR|O_CLOEXEC)
+#endif
+
#include <xf86platformBus.h>
_X_EXPORT int gAMDGPUEntityIndex = -1;
@@ -75,36 +82,34 @@ static void AMDGPUIdentify(int flags)
xf86PrintChipsets(AMDGPU_NAME, "Driver for AMD Radeon", AMDGPUAny);
}
-static char *amdgpu_bus_id(ScrnInfoPtr pScrn, struct pci_device *dev)
+static Bool amdgpu_device_matches(const drmDevicePtr device,
+ const struct pci_device *dev)
{
- char *busid;
-
- XNFasprintf(&busid, "pci:%04x:%02x:%02x.%d",
- dev->domain, dev->bus, dev->dev, dev->func);
-
- if (!busid)
- xf86DrvMsgVerb(pScrn->scrnIndex, X_ERROR, 0,
- "AMDGPU: Failed to generate bus ID string\n");
-
- return busid;
+ return (device->bustype == DRM_BUS_PCI &&
+ device->businfo.pci->domain == dev->domain &&
+ device->businfo.pci->bus == dev->bus &&
+ device->businfo.pci->dev == dev->dev &&
+ device->businfo.pci->func == dev->func);
}
-static Bool amdgpu_kernel_mode_enabled(ScrnInfoPtr pScrn, char *busIdString)
+static Bool amdgpu_kernel_mode_enabled(ScrnInfoPtr pScrn)
{
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
+ const char *busIdString = pAMDGPUEnt->busid;
int ret = drmCheckModesettingSupported(busIdString);
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
if (ret) {
if (xf86LoadKernelModule("amdgpukms"))
ret = drmCheckModesettingSupported(busIdString);
}
-#endif
if (ret) {
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
"[KMS] drm report modesetting isn't supported.\n");
return FALSE;
}
+#endif
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
"[KMS] Kernel modesetting enabled.\n");
return TRUE;
@@ -112,42 +117,66 @@ static Bool amdgpu_kernel_mode_enabled(ScrnInfoPtr pScrn, char *busIdString)
static int amdgpu_kernel_open_fd(ScrnInfoPtr pScrn,
struct pci_device *pci_dev,
- struct xf86_platform_device *platform_dev)
+ struct xf86_platform_device *platform_dev,
+ AMDGPUEntPtr pAMDGPUEnt)
{
+#define MAX_DRM_DEVICES 64
+ drmDevicePtr devices[MAX_DRM_DEVICES];
struct pci_device *dev;
- char *busid;
- int fd;
+ const char *path;
+ int fd = -1, i, ret;
+
+ if (platform_dev)
+ dev = platform_dev->pdev;
+ else
+ dev = pci_dev;
+
+ XNFasprintf(&pAMDGPUEnt->busid, "pci:%04x:%02x:%02x.%u",
+ dev->domain, dev->bus, dev->dev, dev->func);
-#ifdef ODEV_ATTRIB_FD
if (platform_dev) {
+#ifdef ODEV_ATTRIB_FD
fd = xf86_get_platform_device_int_attrib(platform_dev,
ODEV_ATTRIB_FD, -1);
if (fd != -1)
return fd;
- }
#endif
- if (platform_dev)
- dev = platform_dev->pdev;
- else
- dev = pci_dev;
+#ifdef ODEV_ATTRIB_PATH
+ path = xf86_get_platform_device_attrib(platform_dev,
+ ODEV_ATTRIB_PATH);
- busid = amdgpu_bus_id(pScrn, dev);
- if (!busid)
+ fd = priv_open_device(path);
+ if (fd != -1)
+ return fd;
+#endif
+ }
+
+ if (!amdgpu_kernel_mode_enabled(pScrn))
return -1;
- if (!amdgpu_kernel_mode_enabled(pScrn, busid)) {
- free(busid);
+ ret = drmGetDevices2(0, devices, ARRAY_SIZE(devices));
+ if (ret == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[drm] Failed to retrieve DRM devices information.\n");
return -1;
}
+ for (i = 0; i < ret; i++) {
+ if (amdgpu_device_matches(devices[i], dev) &&
+ devices[i]->available_nodes & (1 << DRM_NODE_PRIMARY)) {
+ path = devices[i]->nodes[DRM_NODE_PRIMARY];
+ fd = priv_open_device(path);
+ break;
+ }
+ }
+ drmFreeDevices(devices, ret);
- fd = drmOpen(NULL, busid);
if (fd == -1)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"[drm] Failed to open DRM device for %s: %s\n",
- busid, strerror(errno));
- free(busid);
+ pAMDGPUEnt->busid, strerror(errno));
return fd;
+#undef MAX_DRM_DEVICES
}
void amdgpu_kernel_close_fd(AMDGPUEntPtr pAMDGPUEnt)
@@ -156,32 +185,31 @@ void amdgpu_kernel_close_fd(AMDGPUEntPtr pAMDGPUEnt)
if (!(pAMDGPUEnt->platform_dev &&
pAMDGPUEnt->platform_dev->flags & XF86_PDEV_SERVER_FD))
#endif
- drmClose(pAMDGPUEnt->fd);
+ close(pAMDGPUEnt->fd);
pAMDGPUEnt->fd = -1;
}
-static Bool amdgpu_open_drm_master(ScrnInfoPtr pScrn, AMDGPUEntPtr pAMDGPUEnt,
- struct pci_device *pci_dev)
+/* Pull a local version of the helper. It's available since 2.4.98 yet
+ * it may be too new for some distributions.
+ */
+static int local_drmIsMaster(int fd)
{
- drmSetVersion sv;
- int err;
+ return drmAuthMagic(fd, 0) != -EACCES;
+}
- pAMDGPUEnt->fd = amdgpu_kernel_open_fd(pScrn, pci_dev, NULL);
+static Bool amdgpu_open_drm_master(ScrnInfoPtr pScrn,
+ struct pci_device *pci_dev,
+ struct xf86_platform_device *platform_dev,
+ AMDGPUEntPtr pAMDGPUEnt)
+{
+ pAMDGPUEnt->fd = amdgpu_kernel_open_fd(pScrn, pci_dev, platform_dev, pAMDGPUEnt);
if (pAMDGPUEnt->fd == -1)
return FALSE;
- /* Check that what we opened was a master or a master-capable FD,
- * by setting the version of the interface we'll use to talk to it.
- * (see DRIOpenDRMMaster() in DRI1)
- */
- sv.drm_di_major = 1;
- sv.drm_di_minor = 1;
- sv.drm_dd_major = -1;
- sv.drm_dd_minor = -1;
- err = drmSetInterfaceVersion(pAMDGPUEnt->fd, &sv);
- if (err != 0) {
+ /* Check that what we opened is a master or a master-capable FD */
+ if (!local_drmIsMaster(pAMDGPUEnt->fd)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "[drm] failed to set drm interface version.\n");
+ "[drm] device is not DRM master.\n");
amdgpu_kernel_close_fd(pAMDGPUEnt);
return FALSE;
}
@@ -189,16 +217,43 @@ static Bool amdgpu_open_drm_master(ScrnInfoPtr pScrn, AMDGPUEntPtr pAMDGPUEnt,
return TRUE;
}
-static Bool amdgpu_get_scrninfo(int entity_num, struct pci_device *pci_dev)
+static Bool amdgpu_device_setup(ScrnInfoPtr pScrn,
+ struct pci_device *pci_dev,
+ struct xf86_platform_device *platform_dev,
+ AMDGPUEntPtr pAMDGPUEnt)
+{
+ uint32_t major_version;
+ uint32_t minor_version;
+
+ pAMDGPUEnt->platform_dev = platform_dev;
+ if (!amdgpu_open_drm_master(pScrn, pci_dev, platform_dev,
+ pAMDGPUEnt))
+ return FALSE;
+
+ if (amdgpu_device_initialize(pAMDGPUEnt->fd,
+ &major_version,
+ &minor_version,
+ &pAMDGPUEnt->pDev)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "amdgpu_device_initialize failed\n");
+ goto error_amdgpu;
+ }
+
+ return TRUE;
+
+error_amdgpu:
+ amdgpu_kernel_close_fd(pAMDGPUEnt);
+ return FALSE;
+}
+
+static Bool
+amdgpu_probe(ScrnInfoPtr pScrn, int entity_num,
+ struct pci_device *pci_dev, struct xf86_platform_device *dev)
{
- ScrnInfoPtr pScrn = NULL;
EntityInfoPtr pEnt = NULL;
DevUnion *pPriv;
AMDGPUEntPtr pAMDGPUEnt;
- pScrn = xf86ConfigPciEntity(pScrn, 0, entity_num, NULL,
- NULL, NULL, NULL, NULL, NULL);
-
if (!pScrn)
return FALSE;
@@ -206,7 +261,6 @@ static Bool amdgpu_get_scrninfo(int entity_num, struct pci_device *pci_dev)
pScrn->driverName = AMDGPU_DRIVER_NAME;
pScrn->name = AMDGPU_NAME;
pScrn->Probe = NULL;
-
pScrn->PreInit = AMDGPUPreInit_KMS;
pScrn->ScreenInit = AMDGPUScreenInit_KMS;
pScrn->SwitchMode = AMDGPUSwitchMode_KMS;
@@ -229,27 +283,16 @@ static Bool amdgpu_get_scrninfo(int entity_num, struct pci_device *pci_dev)
pPriv = xf86GetEntityPrivate(pEnt->index, gAMDGPUEntityIndex);
if (!pPriv->ptr) {
- uint32_t major_version;
- uint32_t minor_version;
-
pPriv->ptr = xnfcalloc(sizeof(AMDGPUEntRec), 1);
if (!pPriv->ptr)
goto error;
pAMDGPUEnt = pPriv->ptr;
- if (!amdgpu_open_drm_master(pScrn, pAMDGPUEnt, pci_dev))
+ if (!amdgpu_device_setup(pScrn, pci_dev, dev, pAMDGPUEnt))
goto error;
pAMDGPUEnt->fd_ref = 1;
- if (amdgpu_device_initialize(pAMDGPUEnt->fd,
- &major_version,
- &minor_version,
- &pAMDGPUEnt->pDev)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "amdgpu_device_initialize failed\n");
- goto error_amdgpu;
- }
} else {
pAMDGPUEnt = pPriv->ptr;
@@ -271,8 +314,6 @@ static Bool amdgpu_get_scrninfo(int entity_num, struct pci_device *pci_dev)
return TRUE;
-error_amdgpu:
- amdgpu_kernel_close_fd(pAMDGPUEnt);
error:
free(pEnt);
return FALSE;
@@ -282,7 +323,10 @@ static Bool
amdgpu_pci_probe(DriverPtr pDriver,
int entity_num, struct pci_device *device, intptr_t match_data)
{
- return amdgpu_get_scrninfo(entity_num, device);
+ ScrnInfoPtr pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL,
+ NULL, NULL, NULL, NULL, NULL);
+
+ return amdgpu_probe(pScrn, entity_num, device, NULL);
}
static Bool AMDGPUDriverFunc(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
@@ -311,9 +355,6 @@ amdgpu_platform_probe(DriverPtr pDriver,
{
ScrnInfoPtr pScrn;
int scr_flags = 0;
- EntityInfoPtr pEnt = NULL;
- DevUnion *pPriv;
- AMDGPUEntPtr pAMDGPUEnt;
if (!dev->pdev)
return FALSE;
@@ -326,78 +367,7 @@ amdgpu_platform_probe(DriverPtr pDriver,
xf86SetEntityShared(entity_num);
xf86AddEntityToScreen(pScrn, entity_num);
- pScrn->driverVersion = AMDGPU_VERSION_CURRENT;
- pScrn->driverName = AMDGPU_DRIVER_NAME;
- pScrn->name = AMDGPU_NAME;
- pScrn->Probe = NULL;
- pScrn->PreInit = AMDGPUPreInit_KMS;
- pScrn->ScreenInit = AMDGPUScreenInit_KMS;
- pScrn->SwitchMode = AMDGPUSwitchMode_KMS;
- pScrn->AdjustFrame = AMDGPUAdjustFrame_KMS;
- pScrn->EnterVT = AMDGPUEnterVT_KMS;
- pScrn->LeaveVT = AMDGPULeaveVT_KMS;
- pScrn->FreeScreen = AMDGPUFreeScreen_KMS;
- pScrn->ValidMode = AMDGPUValidMode;
-
- pEnt = xf86GetEntityInfo(entity_num);
-
- /* Create a AMDGPUEntity for all chips, even with old single head
- * Radeon, need to use pAMDGPUEnt for new monitor detection routines.
- */
- xf86SetEntitySharable(entity_num);
-
- if (gAMDGPUEntityIndex == -1)
- gAMDGPUEntityIndex = xf86AllocateEntityPrivateIndex();
-
- pPriv = xf86GetEntityPrivate(pEnt->index, gAMDGPUEntityIndex);
-
- if (!pPriv->ptr) {
- uint32_t major_version;
- uint32_t minor_version;
-
- pPriv->ptr = xnfcalloc(sizeof(AMDGPUEntRec), 1);
- pAMDGPUEnt = pPriv->ptr;
- pAMDGPUEnt->platform_dev = dev;
- pAMDGPUEnt->fd = amdgpu_kernel_open_fd(pScrn, NULL, dev);
- if (pAMDGPUEnt->fd < 0)
- goto error;
-
- pAMDGPUEnt->fd_ref = 1;
-
- if (amdgpu_device_initialize(pAMDGPUEnt->fd,
- &major_version,
- &minor_version,
- &pAMDGPUEnt->pDev)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "amdgpu_device_initialize failed\n");
- goto error_amdgpu;
- }
- } else {
- pAMDGPUEnt = pPriv->ptr;
-
- if (pAMDGPUEnt->fd_ref == ARRAY_SIZE(pAMDGPUEnt->scrn)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Only up to %u Zaphod instances supported\n",
- (unsigned)ARRAY_SIZE(pAMDGPUEnt->scrn));
- goto error;
- }
-
- pAMDGPUEnt->fd_ref++;
- }
-
- xf86SetEntityInstanceForScreen(pScrn, pEnt->index,
- xf86GetNumEntityInstances(pEnt->
- index)
- - 1);
- free(pEnt);
-
- return TRUE;
-
-error_amdgpu:
- amdgpu_kernel_close_fd(pAMDGPUEnt);
-error:
- free(pEnt);
- return FALSE;
+ return amdgpu_probe(pScrn, entity_num, NULL, dev);
}
#endif
diff --git a/driver/xf86-video-amdgpu/src/amdgpu_probe.h b/driver/xf86-video-amdgpu/src/amdgpu_probe.h
index 306c9a521..fea4d394b 100644
--- a/driver/xf86-video-amdgpu/src/amdgpu_probe.h
+++ b/driver/xf86-video-amdgpu/src/amdgpu_probe.h
@@ -69,6 +69,7 @@ typedef struct {
ScrnInfoPtr scrn[6];
struct xf86_platform_device *platform_dev;
char *render_node;
+ char *busid;
} AMDGPUEntRec, *AMDGPUEntPtr;
extern void amdgpu_kernel_close_fd(AMDGPUEntPtr pAMDGPUEnt);
diff --git a/driver/xf86-video-amdgpu/src/compat-api.h b/driver/xf86-video-amdgpu/src/compat-api.h
index a703e5c8f..aca3b07b3 100644
--- a/driver/xf86-video-amdgpu/src/compat-api.h
+++ b/driver/xf86-video-amdgpu/src/compat-api.h
@@ -38,4 +38,10 @@
#define BLOCKHANDLER_ARGS pScreen, pTimeout, pReadmask
#endif
+#if ABI_VIDEODRV_VERSION < SET_ABI_VERSION(25, 2)
+#define current_primary current_master
+#define primary_pixmap master_pixmap
+#define secondary_dst slave_dst
+#endif
+
#endif
diff --git a/driver/xf86-video-amdgpu/src/drmmode_display.c b/driver/xf86-video-amdgpu/src/drmmode_display.c
index c410d0b97..b6cdde7e8 100644
--- a/driver/xf86-video-amdgpu/src/drmmode_display.c
+++ b/driver/xf86-video-amdgpu/src/drmmode_display.c
@@ -40,15 +40,13 @@
#include "mipointrst.h"
#include "xf86cmap.h"
#include "xf86Priv.h"
-#include "sarea.h"
+#include <xf86drm.h>
#include "drmmode_display.h"
#include "amdgpu_bo_helper.h"
#include "amdgpu_glamor.h"
#include "amdgpu_pixmap.h"
-#include <dri.h>
-
/* DPMS */
#ifdef HAVE_XEXTPROTO_71
#include <X11/extensions/dpmsconst.h>
@@ -97,42 +95,6 @@ AMDGPUZaphodStringMatches(ScrnInfoPtr pScrn, const char *s, char *output_name)
}
-static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn,
- int width, int height,
- int depth, int bpp,
- int pitch,
- struct amdgpu_buffer *bo)
-{
- ScreenPtr pScreen = pScrn->pScreen;
- PixmapPtr pixmap;
-
- pixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth,
- AMDGPU_CREATE_PIXMAP_SCANOUT);
- if (!pixmap)
- return NULL;
-
- if (!(*pScreen->ModifyPixmapHeader) (pixmap, width, height,
- depth, bpp, pitch, NULL))
- goto fail;
-
- if (!amdgpu_glamor_create_textured_pixmap(pixmap, bo))
- goto fail;
-
- if (amdgpu_set_pixmap_bo(pixmap, bo))
- return pixmap;
-
-fail:
- pScreen->DestroyPixmap(pixmap);
- return NULL;
-}
-
-static void drmmode_destroy_bo_pixmap(PixmapPtr pixmap)
-{
- ScreenPtr pScreen = pixmap->drawable.pScreen;
-
- (*pScreen->DestroyPixmap) (pixmap);
-}
-
static void
drmmode_ConvertFromKMode(ScrnInfoPtr scrn,
drmModeModeInfo * kmode, DisplayModePtr mode)
@@ -505,22 +467,6 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
}
void
-drmmode_crtc_scanout_destroy(drmmode_ptr drmmode,
- struct drmmode_scanout *scanout)
-{
-
- if (scanout->pixmap) {
- drmmode_destroy_bo_pixmap(scanout->pixmap);
- scanout->pixmap = NULL;
- }
-
- if (scanout->bo) {
- amdgpu_bo_unref(&scanout->bo);
- scanout->bo = NULL;
- }
-}
-
-void
drmmode_crtc_scanout_free(xf86CrtcPtr crtc)
{
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
@@ -532,60 +478,43 @@ drmmode_crtc_scanout_free(xf86CrtcPtr crtc)
amdgpu_drm_queue_handle_deferred(crtc);
}
- drmmode_crtc_scanout_destroy(drmmode_crtc->drmmode,
- &drmmode_crtc->scanout[0]);
- drmmode_crtc_scanout_destroy(drmmode_crtc->drmmode,
- &drmmode_crtc->scanout[1]);
+ drmmode_crtc_scanout_destroy(&drmmode_crtc->scanout[0]);
+ drmmode_crtc_scanout_destroy(&drmmode_crtc->scanout[1]);
if (drmmode_crtc->scanout_damage)
DamageDestroy(drmmode_crtc->scanout_damage);
}
-PixmapPtr
-drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
+static Bool
+drmmode_crtc_scanout_create(xf86CrtcPtr crtc, PixmapPtr *scanout,
int width, int height)
{
ScrnInfoPtr pScrn = crtc->scrn;
- drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
- drmmode_ptr drmmode = drmmode_crtc->drmmode;
- int pitch;
+ ScreenPtr screen = pScrn->pScreen;
- if (scanout->pixmap) {
- if (scanout->width == width && scanout->height == height)
- return scanout->pixmap;
+ if (*scanout) {
+ if ((*scanout)->drawable.width == width &&
+ (*scanout)->drawable.height == height)
+ return TRUE;
- drmmode_crtc_scanout_destroy(drmmode, scanout);
+ drmmode_crtc_scanout_destroy(scanout);
}
- scanout->bo = amdgpu_alloc_pixmap_bo(pScrn, width, height,
- pScrn->depth, 0,
- pScrn->bitsPerPixel, &pitch);
- if (!scanout->bo) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to allocate scanout buffer memory\n");
- return NULL;
- }
-
- scanout->pixmap = drmmode_create_bo_pixmap(pScrn,
- width, height,
- pScrn->depth,
- pScrn->bitsPerPixel,
- pitch, scanout->bo);
- if (!scanout->pixmap) {
+ *scanout = screen->CreatePixmap(screen, width, height, pScrn->depth,
+ AMDGPU_CREATE_PIXMAP_SCANOUT);
+ if (!*scanout) {
ErrorF("failed to create CRTC scanout pixmap\n");
goto error;
}
- if (amdgpu_pixmap_get_fb(scanout->pixmap)) {
- scanout->width = width;
- scanout->height = height;
- } else {
+ if (!amdgpu_pixmap_get_fb(*scanout)) {
ErrorF("failed to create CRTC scanout FB\n");
error:
- drmmode_crtc_scanout_destroy(drmmode, scanout);
+ drmmode_crtc_scanout_destroy(scanout);
+ return FALSE;
}
- return scanout->pixmap;
+ return TRUE;
}
static void
@@ -705,8 +634,7 @@ drmmode_crtc_prime_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
ScreenPtr screen = scrn->pScreen;
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
- if (drmmode_crtc->tear_free &&
- !drmmode_crtc->scanout[1].pixmap) {
+ if (drmmode_crtc->tear_free && !drmmode_crtc->scanout[1]) {
RegionPtr region;
BoxPtr box;
@@ -729,8 +657,8 @@ drmmode_crtc_prime_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
xorg_list_for_each_entry(dirty, &screen->pixmap_dirty_list,
ent) {
if (amdgpu_dirty_src_equals(dirty, drmmode_crtc->prime_scanout_pixmap)) {
- dirty->slave_dst =
- drmmode_crtc->scanout[scanout_id].pixmap;
+ dirty->secondary_dst =
+ drmmode_crtc->scanout[scanout_id];
break;
}
}
@@ -738,9 +666,9 @@ drmmode_crtc_prime_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
if (!drmmode_crtc->tear_free) {
GCPtr gc = GetScratchGC(scrn->depth, screen);
- ValidateGC(&drmmode_crtc->scanout[0].pixmap->drawable, gc);
- gc->ops->CopyArea(&drmmode_crtc->scanout[1].pixmap->drawable,
- &drmmode_crtc->scanout[0].pixmap->drawable,
+ ValidateGC(&drmmode_crtc->scanout[0]->drawable, gc);
+ gc->ops->CopyArea(&drmmode_crtc->scanout[1]->drawable,
+ &drmmode_crtc->scanout[0]->drawable,
gc, 0, 0, mode->HDisplay, mode->VDisplay,
0, 0);
FreeScratchGC(gc);
@@ -748,7 +676,7 @@ drmmode_crtc_prime_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
}
}
- *fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap);
+ *fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id]);
*x = *y = 0;
drmmode_crtc->scanout_id = scanout_id;
}
@@ -771,9 +699,9 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
mode->HDisplay, mode->VDisplay);
}
- if (drmmode_crtc->scanout[scanout_id].pixmap &&
+ if (drmmode_crtc->scanout[scanout_id] &&
(!drmmode_crtc->tear_free ||
- drmmode_crtc->scanout[scanout_id ^ 1].pixmap)) {
+ drmmode_crtc->scanout[scanout_id ^ 1])) {
BoxRec extents = { .x1 = 0, .y1 = 0,
.x2 = scrn->virtualX, .y2 = scrn->virtualY };
@@ -787,7 +715,7 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
drmmode_crtc->scanout_damage);
}
- *fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap);
+ *fb = amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id]);
*x = *y = 0;
if (amdgpu_scanout_do_update(crtc, scanout_id,
@@ -1370,7 +1298,6 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
Bool handle_deferred = FALSE;
unsigned scanout_id = 0;
- drmmode_ptr drmmode = drmmode_crtc->drmmode;
int saved_x, saved_y;
Rotation saved_rotation;
DisplayModeRec saved_mode;
@@ -1407,8 +1334,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
if (drmmode_crtc->prime_scanout_pixmap) {
drmmode_crtc_prime_scanout_update(crtc, mode, scanout_id,
&fb, &x, &y);
- } else if (drmmode_crtc->rotate.pixmap) {
- fb = amdgpu_pixmap_get_fb(drmmode_crtc->rotate.pixmap);
+ } else if (drmmode_crtc->rotate) {
+ fb = amdgpu_pixmap_get_fb(drmmode_crtc->rotate);
x = y = 0;
} else if (!pScreen->isGPU &&
@@ -1489,13 +1416,11 @@ done:
} else {
crtc->active = TRUE;
- if (drmmode_crtc->scanout[scanout_id].pixmap &&
- fb != amdgpu_pixmap_get_fb(drmmode_crtc->
- scanout[scanout_id].pixmap)) {
+ if (drmmode_crtc->scanout[scanout_id] &&
+ fb != amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id])) {
drmmode_crtc_scanout_free(crtc);
} else if (!drmmode_crtc->tear_free) {
- drmmode_crtc_scanout_destroy(drmmode,
- &drmmode_crtc->scanout[1]);
+ drmmode_crtc_scanout_destroy(&drmmode_crtc->scanout[1]);
}
}
@@ -1784,7 +1709,7 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc)
arg.hot_y = yhot;
ret = drmIoctl(pAMDGPUEnt->fd, DRM_IOCTL_MODE_CURSOR2, &arg);
- if (ret == -EINVAL)
+ if (ret == -1 && errno == EINVAL)
use_set_cursor2 = FALSE;
else
return;
@@ -1819,7 +1744,7 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
height);
}
- return drmmode_crtc->rotate.pixmap;
+ return drmmode_crtc->rotate;
}
static void
@@ -1827,9 +1752,8 @@ drmmode_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap,
void *data)
{
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
- drmmode_ptr drmmode = drmmode_crtc->drmmode;
- drmmode_crtc_scanout_destroy(drmmode, &drmmode_crtc->rotate);
+ drmmode_crtc_scanout_destroy(&drmmode_crtc->rotate);
}
static void
@@ -1865,7 +1789,7 @@ static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
xorg_list_for_each_entry(dirty, &screen->pixmap_dirty_list, ent) {
if (amdgpu_dirty_src_equals(dirty, drmmode_crtc->prime_scanout_pixmap)) {
- PixmapStopDirtyTracking(dirty->src, dirty->slave_dst);
+ PixmapStopDirtyTracking(dirty->src, dirty->secondary_dst);
break;
}
}
@@ -1893,16 +1817,16 @@ static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
#ifdef HAS_DIRTYTRACKING_DRAWABLE_SRC
PixmapStartDirtyTracking(&ppix->drawable,
- drmmode_crtc->scanout[scanout_id].pixmap,
+ drmmode_crtc->scanout[scanout_id],
0, 0, 0, 0, RR_Rotate_0);
#elif defined(HAS_DIRTYTRACKING_ROTATION)
- PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[scanout_id].pixmap,
+ PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[scanout_id],
0, 0, 0, 0, RR_Rotate_0);
#elif defined(HAS_DIRTYTRACKING2)
- PixmapStartDirtyTracking2(ppix, drmmode_crtc->scanout[scanout_id].pixmap,
+ PixmapStartDirtyTracking2(ppix, drmmode_crtc->scanout[scanout_id],
0, 0, 0, 0);
#else
- PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[scanout_id].pixmap, 0, 0);
+ PixmapStartDirtyTracking(ppix, drmmode_crtc->scanout[scanout_id], 0, 0);
#endif
return TRUE;
}
@@ -2975,8 +2899,8 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
int i, pitch, old_width, old_height, old_pitch;
int cpp = info->pixel_bytes;
PixmapPtr ppix = screen->GetScreenPixmap(screen);
+ int hint = AMDGPU_CREATE_PIXMAP_SCANOUT;
void *fb_shadow;
- int hint = 0;
if (scrn->virtualX == width && scrn->virtualY == height)
return TRUE;
@@ -2990,9 +2914,9 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
}
if (info->shadow_primary)
- hint = AMDGPU_CREATE_PIXMAP_LINEAR | AMDGPU_CREATE_PIXMAP_GTT;
+ hint |= AMDGPU_CREATE_PIXMAP_LINEAR | AMDGPU_CREATE_PIXMAP_GTT;
else if (!info->use_glamor)
- hint = AMDGPU_CREATE_PIXMAP_LINEAR;
+ hint |= AMDGPU_CREATE_PIXMAP_LINEAR;
xf86DrvMsg(scrn->scrnIndex, X_INFO,
"Allocate new frame buffer %dx%d\n", width, height);
@@ -3432,7 +3356,7 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
unsigned int crtcs_needed = 0;
unsigned int crtcs_got = 0;
drmModeResPtr mode_res;
- char *bus_id_string, *provider_name;
+ char *provider_name;
xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs);
@@ -3495,9 +3419,7 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
/* workout clones */
drmmode_clones_init(pScrn, drmmode, mode_res);
- bus_id_string = DRICreatePCIBusID(info->PciInfo);
- XNFasprintf(&provider_name, "%s @ %s", pScrn->chipset, bus_id_string);
- free(bus_id_string);
+ XNFasprintf(&provider_name, "%s @ %s", pScrn->chipset, pAMDGPUEnt->busid);
xf86ProviderSetup(pScrn, NULL, provider_name);
free(provider_name);
@@ -4127,7 +4049,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
}
drmmode_fb_reference(pAMDGPUEnt->fd, &flipdata->fb[crtc_id],
- amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap));
+ amdgpu_pixmap_get_fb(drmmode_crtc->scanout[scanout_id]));
if (!flipdata->fb[crtc_id]) {
ErrorF("Failed to get FB for TearFree flip\n");
goto error;
diff --git a/driver/xf86-video-amdgpu/src/drmmode_display.h b/driver/xf86-video-amdgpu/src/drmmode_display.h
index 9c0f25ac2..b7d540173 100644
--- a/driver/xf86-video-amdgpu/src/drmmode_display.h
+++ b/driver/xf86-video-amdgpu/src/drmmode_display.h
@@ -96,12 +96,6 @@ enum drmmode_scanout_status {
DRMMODE_SCANOUT_VBLANK_FAILED = 1u << 1,
};
-struct drmmode_scanout {
- struct amdgpu_buffer *bo;
- PixmapPtr pixmap;
- int width, height;
-};
-
typedef struct {
drmmode_ptr drmmode;
drmModeCrtcPtr mode_crtc;
@@ -115,8 +109,8 @@ typedef struct {
unsigned cursor_id;
struct amdgpu_buffer *cursor_buffer[2];
- struct drmmode_scanout rotate;
- struct drmmode_scanout scanout[2];
+ PixmapPtr rotate;
+ PixmapPtr scanout[2];
DamagePtr scanout_damage;
Bool ignore_damage;
RegionRec scanout_last_region;
@@ -202,9 +196,9 @@ drmmode_crtc_can_flip(xf86CrtcPtr crtc)
return crtc->enabled &&
drmmode_crtc->dpms_mode == DPMSModeOn &&
- !drmmode_crtc->rotate.bo &&
+ !drmmode_crtc->rotate &&
(drmmode_crtc->tear_free ||
- !drmmode_crtc->scanout[drmmode_crtc->scanout_id].bo);
+ !drmmode_crtc->scanout[drmmode_crtc->scanout_id]);
}
@@ -240,6 +234,17 @@ drmmode_fb_reference_loc(int drm_fd, struct drmmode_fb **old, struct drmmode_fb
drmmode_fb_reference_loc(fd, old, new, __func__, __LINE__)
+static inline void
+drmmode_crtc_scanout_destroy(PixmapPtr *scanout)
+{
+ if (!*scanout)
+ return;
+
+ (*scanout)->drawable.pScreen->DestroyPixmap(*scanout);
+ (*scanout) = NULL;
+}
+
+
extern int drmmode_page_flip_target_absolute(AMDGPUEntPtr pAMDGPUEnt,
drmmode_crtc_private_ptr drmmode_crtc,
int fb_id, uint32_t flags,
@@ -259,12 +264,7 @@ extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
-extern void drmmode_crtc_scanout_destroy(drmmode_ptr drmmode,
- struct drmmode_scanout *scanout);
void drmmode_crtc_scanout_free(xf86CrtcPtr crtc);
-PixmapPtr drmmode_crtc_scanout_create(xf86CrtcPtr crtc,
- struct drmmode_scanout *scanout,
- int width, int height);
extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);