summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <mdaenzer@redhat.com>2020-04-21 19:02:41 +0200
committerMichel Dänzer <michel@daenzer.net>2020-05-27 15:41:22 +0000
commit99f3c82e940e35642757ccd6dc5267004e1122f6 (patch)
tree04f7ddf8bf3bb0c52df0388db555d746d0085366
parentcfce4b3e6b05b1be14b7ce716dbfb9a15e7e21f4 (diff)
Drop struct drmmode_scanout altogether in favour of PixmapPtrs
-rw-r--r--src/amdgpu_kms.c36
-rw-r--r--src/drmmode_display.c70
-rw-r--r--src/drmmode_display.h17
3 files changed, 57 insertions, 66 deletions
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 786a2de..f3c6aac 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -520,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;
@@ -772,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->slave_dst = drmmode_crtc->scanout[scanout_id];
}
redisplay_dirty(dirty, region);
@@ -811,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;
@@ -878,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");
@@ -993,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;
@@ -1198,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");
@@ -1267,12 +1267,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);
}
}
@@ -2269,7 +2269,7 @@ 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 };
+ PixmapPtr black_scanout = NULL;
xf86CrtcPtr crtc;
drmmode_crtc_private_ptr drmmode_crtc;
unsigned w = 0, h = 0;
@@ -2297,9 +2297,9 @@ void AMDGPULeaveVT_KMS(ScrnInfoPtr pScrn)
if (w > 0 && h > 0) {
if (drmmode_crtc_scanout_create(crtc, &black_scanout, w, h)) {
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++) {
@@ -2318,10 +2318,10 @@ 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);
}
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 3768871..5b0ec52 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -469,14 +469,13 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
}
void
-drmmode_crtc_scanout_destroy(drmmode_ptr drmmode,
- struct drmmode_scanout *scanout)
+drmmode_crtc_scanout_destroy(drmmode_ptr drmmode, PixmapPtr *scanout)
{
- if (!scanout->pixmap)
+ if (!*scanout)
return;
- scanout->pixmap->drawable.pScreen->DestroyPixmap(scanout->pixmap);
- scanout->pixmap = NULL;
+ (*scanout)->drawable.pScreen->DestroyPixmap(*scanout);
+ (*scanout) = NULL;
}
void
@@ -501,7 +500,7 @@ drmmode_crtc_scanout_free(xf86CrtcPtr crtc)
}
PixmapPtr
-drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
+drmmode_crtc_scanout_create(xf86CrtcPtr crtc, PixmapPtr *scanout,
int width, int height)
{
ScrnInfoPtr pScrn = crtc->scrn;
@@ -509,29 +508,28 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
drmmode_ptr drmmode = drmmode_crtc->drmmode;
ScreenPtr screen = pScrn->pScreen;
- if (scanout->pixmap) {
- if (scanout->pixmap->drawable.width == width &&
- scanout->pixmap->drawable.height == height)
- return scanout->pixmap;
+ if (*scanout) {
+ if ((*scanout)->drawable.width == width &&
+ (*scanout)->drawable.height == height)
+ return *scanout;
drmmode_crtc_scanout_destroy(drmmode, scanout);
}
- scanout->pixmap = screen->CreatePixmap(screen, width, height,
- pScrn->depth,
- AMDGPU_CREATE_PIXMAP_SCANOUT);
- 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)) {
+ if (!amdgpu_pixmap_get_fb(*scanout)) {
ErrorF("failed to create CRTC scanout FB\n");
error:
drmmode_crtc_scanout_destroy(drmmode, scanout);
}
- return scanout->pixmap;
+ return *scanout;
}
static void
@@ -651,8 +649,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;
@@ -676,7 +673,7 @@ drmmode_crtc_prime_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
ent) {
if (amdgpu_dirty_src_equals(dirty, drmmode_crtc->prime_scanout_pixmap)) {
dirty->slave_dst =
- drmmode_crtc->scanout[scanout_id].pixmap;
+ drmmode_crtc->scanout[scanout_id];
break;
}
}
@@ -684,9 +681,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);
@@ -694,7 +691,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;
}
@@ -717,9 +714,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 };
@@ -733,7 +730,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,
@@ -1353,8 +1350,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 &&
@@ -1435,9 +1432,8 @@ 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,
@@ -1765,7 +1761,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
@@ -1839,16 +1835,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;
}
@@ -4071,7 +4067,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/src/drmmode_display.h b/src/drmmode_display.h
index 67f5f1f..8f132c3 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -96,10 +96,6 @@ enum drmmode_scanout_status {
DRMMODE_SCANOUT_VBLANK_FAILED = 1u << 1,
};
-struct drmmode_scanout {
- PixmapPtr pixmap;
-};
-
typedef struct {
drmmode_ptr drmmode;
drmModeCrtcPtr mode_crtc;
@@ -113,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;
@@ -200,9 +196,9 @@ drmmode_crtc_can_flip(xf86CrtcPtr crtc)
return crtc->enabled &&
drmmode_crtc->dpms_mode == DPMSModeOn &&
- !drmmode_crtc->rotate.pixmap &&
+ !drmmode_crtc->rotate &&
(drmmode_crtc->tear_free ||
- !drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap);
+ !drmmode_crtc->scanout[drmmode_crtc->scanout_id]);
}
@@ -258,10 +254,9 @@ 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);
+ PixmapPtr *scanout);
void drmmode_crtc_scanout_free(xf86CrtcPtr crtc);
-PixmapPtr drmmode_crtc_scanout_create(xf86CrtcPtr crtc,
- struct drmmode_scanout *scanout,
+PixmapPtr drmmode_crtc_scanout_create(xf86CrtcPtr crtc, PixmapPtr *scanout,
int width, int height);
extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);