summaryrefslogtreecommitdiff
path: root/src/drmmode_display.c
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2018-05-28 18:35:32 +0200
committerMichel Dänzer <michel@daenzer.net>2018-07-09 18:26:57 +0200
commit5da2bf43e64f2d702fe05016263f617c10f8f134 (patch)
treea21dfdcc08fc89621ff0932b803562755b162b70 /src/drmmode_display.c
parentba5d5402b3e2e807d7e47205ac83f930b6c8caf5 (diff)
Factor out radeon_surface_initialize helper
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src/drmmode_display.c')
-rw-r--r--src/drmmode_display.c66
1 files changed, 5 insertions, 61 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 8dc776fa..c7bec59c 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -116,7 +116,6 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn,
RADEONInfoPtr info = RADEONPTR(pScrn);
ScreenPtr pScreen = pScrn->pScreen;
PixmapPtr pixmap;
- uint32_t tiling;
pixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth,
RADEON_CREATE_PIXMAP_SCANOUT);
@@ -137,37 +136,8 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn,
if (info->surf_man && !info->use_glamor) {
struct radeon_surface *surface = radeon_get_pixmap_surface(pixmap);
- memset(surface, 0, sizeof(struct radeon_surface));
- surface->npix_x = width;
- surface->npix_y = height;
- surface->npix_z = 1;
- surface->blk_w = 1;
- surface->blk_h = 1;
- surface->blk_d = 1;
- surface->array_size = 1;
- surface->last_level = 0;
- surface->bpe = bpp / 8;
- surface->nsamples = 1;
- surface->flags = RADEON_SURF_SCANOUT;
- /* we are requiring a recent enough libdrm version */
- surface->flags |= RADEON_SURF_HAS_TILE_MODE_INDEX;
- surface->flags |= RADEON_SURF_SET(RADEON_SURF_TYPE_2D, TYPE);
- surface->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_LINEAR_ALIGNED, MODE);
- tiling = radeon_get_pixmap_tiling_flags(pixmap);
-
- if (tiling & RADEON_TILING_MICRO) {
- surface->flags = RADEON_SURF_CLR(surface->flags, MODE);
- surface->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_1D, MODE);
- }
- if (tiling & RADEON_TILING_MACRO) {
- surface->flags = RADEON_SURF_CLR(surface->flags, MODE);
- surface->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_2D, MODE);
- }
-
- if (radeon_surface_best(info->surf_man, surface))
- goto fail;
-
- if (radeon_surface_init(info->surf_man, surface))
+ if (!radeon_surface_initialize(info, surface, width, height, bpp / 8,
+ radeon_get_pixmap_tiling_flags(pixmap), 0))
goto fail;
}
@@ -2301,36 +2271,10 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
base_align = 4096;
if (info->surf_man) {
- memset(&surface, 0, sizeof(struct radeon_surface));
- surface.npix_x = width;
- surface.npix_y = height;
- surface.npix_z = 1;
- surface.blk_w = 1;
- surface.blk_h = 1;
- surface.blk_d = 1;
- surface.array_size = 1;
- surface.last_level = 0;
- surface.bpe = cpp;
- surface.nsamples = 1;
- surface.flags = RADEON_SURF_SCANOUT;
- /* we are requiring a recent enough libdrm version */
- surface.flags |= RADEON_SURF_HAS_TILE_MODE_INDEX;
- surface.flags |= RADEON_SURF_SET(RADEON_SURF_TYPE_2D, TYPE);
- surface.flags |= RADEON_SURF_SET(RADEON_SURF_MODE_LINEAR_ALIGNED, MODE);
- if (tiling_flags & RADEON_TILING_MICRO) {
- surface.flags = RADEON_SURF_CLR(surface.flags, MODE);
- surface.flags |= RADEON_SURF_SET(RADEON_SURF_MODE_1D, MODE);
- }
- if (tiling_flags & RADEON_TILING_MACRO) {
- surface.flags = RADEON_SURF_CLR(surface.flags, MODE);
- surface.flags |= RADEON_SURF_SET(RADEON_SURF_MODE_2D, MODE);
- }
- if (radeon_surface_best(info->surf_man, &surface)) {
- return FALSE;
- }
- if (radeon_surface_init(info->surf_man, &surface)) {
+ if (!radeon_surface_initialize(info, &surface, width, height,
+ cpp, tiling_flags, 0))
return FALSE;
- }
+
screen_size = surface.bo_size;
base_align = surface.bo_alignment;
pitch = surface.level[0].pitch_bytes;