summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <mdaenzer@redhat.com>2020-04-21 18:48:06 +0200
committerMichel Dänzer <michel@daenzer.net>2020-05-27 15:41:22 +0000
commitcfce4b3e6b05b1be14b7ce716dbfb9a15e7e21f4 (patch)
treea8650be16434423e7641b060a824acf678f251b7
parent680b9a2976f9eb8010c8160c425c2194fb5429d1 (diff)
Drop bo/width/height members from struct drmmode_scanout
The pixmap is all we really need.
-rw-r--r--src/amdgpu_kms.c2
-rw-r--r--src/drmmode_display.c76
-rw-r--r--src/drmmode_display.h6
3 files changed, 14 insertions, 70 deletions
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 54238c4..786a2de 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -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, .bo = NULL };
+ struct drmmode_scanout black_scanout = { .pixmap = NULL };
xf86CrtcPtr crtc;
drmmode_crtc_private_ptr drmmode_crtc;
unsigned w = 0, h = 0;
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 09649dd..3768871 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -97,42 +97,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)
@@ -508,16 +472,11 @@ void
drmmode_crtc_scanout_destroy(drmmode_ptr drmmode,
struct drmmode_scanout *scanout)
{
+ if (!scanout->pixmap)
+ return;
- if (scanout->pixmap) {
- drmmode_destroy_bo_pixmap(scanout->pixmap);
- scanout->pixmap = NULL;
- }
-
- if (scanout->bo) {
- amdgpu_bo_unref(&scanout->bo);
- scanout->bo = NULL;
- }
+ scanout->pixmap->drawable.pScreen->DestroyPixmap(scanout->pixmap);
+ scanout->pixmap = NULL;
}
void
@@ -548,38 +507,25 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
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)
+ if (scanout->pixmap->drawable.width == width &&
+ scanout->pixmap->drawable.height == height)
return scanout->pixmap;
drmmode_crtc_scanout_destroy(drmmode, scanout);
}
- scanout->bo = amdgpu_alloc_pixmap_bo(pScrn, width, height, pScrn->depth,
- AMDGPU_CREATE_PIXMAP_SCANOUT,
- 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);
+ scanout->pixmap = screen->CreatePixmap(screen, width, height,
+ pScrn->depth,
+ AMDGPU_CREATE_PIXMAP_SCANOUT);
if (!scanout->pixmap) {
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->pixmap)) {
ErrorF("failed to create CRTC scanout FB\n");
error:
drmmode_crtc_scanout_destroy(drmmode, scanout);
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 9c0f25a..67f5f1f 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -97,9 +97,7 @@ enum drmmode_scanout_status {
};
struct drmmode_scanout {
- struct amdgpu_buffer *bo;
PixmapPtr pixmap;
- int width, height;
};
typedef struct {
@@ -202,9 +200,9 @@ drmmode_crtc_can_flip(xf86CrtcPtr crtc)
return crtc->enabled &&
drmmode_crtc->dpms_mode == DPMSModeOn &&
- !drmmode_crtc->rotate.bo &&
+ !drmmode_crtc->rotate.pixmap &&
(drmmode_crtc->tear_free ||
- !drmmode_crtc->scanout[drmmode_crtc->scanout_id].bo);
+ !drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap);
}