Module Name:    xsrc
Committed By:   mrg
Date:           Sun Dec 30 07:34:43 UTC 2018

Modified Files:
        xsrc/external/mit/xf86-video-ati-kms/dist/src: radeon_kms.c
        xsrc/external/mit/xf86-video-ati-kms/include: config.h

Log Message:
merge ati driver 18.1.0.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
    xsrc/external/mit/xf86-video-ati-kms/dist/src/radeon_kms.c
cvs rdiff -u -r1.6 -r1.7 \
    xsrc/external/mit/xf86-video-ati-kms/include/config.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xf86-video-ati-kms/dist/src/radeon_kms.c
diff -u xsrc/external/mit/xf86-video-ati-kms/dist/src/radeon_kms.c:1.6 xsrc/external/mit/xf86-video-ati-kms/dist/src/radeon_kms.c:1.7
--- xsrc/external/mit/xf86-video-ati-kms/dist/src/radeon_kms.c:1.6	Sun Mar 11 19:43:59 2018
+++ xsrc/external/mit/xf86-video-ati-kms/dist/src/radeon_kms.c	Sun Dec 30 07:34:43 2018
@@ -212,6 +212,11 @@ static void RADEONFreeRec(ScrnInfoPtr pS
 	    info->accel_state = NULL;
 	}
 
+#ifdef USE_GLAMOR
+	if (info->gbm)
+	    gbm_device_destroy(info->gbm);
+#endif
+
 	pEnt = info->pEnt;
 	free(pScrn->driverPrivate);
 	pScrn->driverPrivate = NULL;
@@ -254,7 +259,7 @@ radeonShadowWindow(ScreenPtr screen, CAR
     stride = (pScrn->displayWidth * pScrn->bitsPerPixel) / 8;
     *size = stride;
 
-    return ((uint8_t *)info->front_bo->ptr + row * stride + offset);
+    return ((uint8_t *)info->front_buffer->bo.radeon->ptr + row * stride + offset);
 }
 
 static void
@@ -326,7 +331,6 @@ static Bool RADEONCreateScreenResources_
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     RADEONInfoPtr  info   = RADEONPTR(pScrn);
     PixmapPtr pixmap;
-    struct radeon_surface *surface;
 
     pScreen->CreateScreenResources = info->CreateScreenResources;
     if (!(*pScreen->CreateScreenResources)(pScreen))
@@ -360,14 +364,13 @@ static Bool RADEONCreateScreenResources_
     }
 
     if (info->dri2.enabled || info->use_glamor) {
-	if (info->front_bo) {
+	if (info->front_buffer) {
 	    PixmapPtr pPix = pScreen->GetScreenPixmap(pScreen);
-	    if (!radeon_set_pixmap_bo(pPix, info->front_bo))
+	    if (!radeon_set_pixmap_bo(pPix, info->front_buffer))
 		return FALSE;
-	    surface = radeon_get_pixmap_surface(pPix);
-	    if (surface) {
-		*surface = info->front_surface;
-	    }
+
+	    if (info->surf_man && !info->use_glamor)
+		*radeon_get_pixmap_surface(pPix) = info->front_surface;
 	}
     }
 
@@ -523,7 +526,7 @@ radeon_scanout_flip_abort(xf86CrtcPtr cr
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(crtc->scrn);
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-    drmmode_crtc->scanout_update_pending = FALSE;
+    drmmode_crtc->scanout_update_pending = 0;
     drmmode_fb_reference(pRADEONEnt->fd, &drmmode_crtc->flip_pending,
 			 NULL);
 }
@@ -538,15 +541,6 @@ radeon_scanout_flip_handler(xf86CrtcPtr 
     drmmode_fb_reference(pRADEONEnt->fd, &drmmode_crtc->fb,
 			 drmmode_crtc->flip_pending);
     radeon_scanout_flip_abort(crtc, event_data);
-
-#ifdef HAVE_PRESENT_H
-    if (drmmode_crtc->present_vblank_event_id) {
-	present_event_notify(drmmode_crtc->present_vblank_event_id,
-			     drmmode_crtc->present_vblank_usec,
-			     drmmode_crtc->present_vblank_msc);
-	drmmode_crtc->present_vblank_event_id = 0;
-    }
-#endif
 }
 
 
@@ -608,7 +602,7 @@ radeon_prime_scanout_update_abort(xf86Cr
 {
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-    drmmode_crtc->scanout_update_pending = FALSE;
+    drmmode_crtc->scanout_update_pending = 0;
 }
 
 void
@@ -636,7 +630,7 @@ master_has_sync_shared_pixmap(ScrnInfoPt
 {
     ScreenPtr master_screen = radeon_dirty_master(dirty);
 
-    return master_screen->SyncSharedPixmap != NULL;
+    return !!master_screen->SyncSharedPixmap;
 }
 
 static Bool
@@ -644,7 +638,7 @@ slave_has_sync_shared_pixmap(ScrnInfoPtr
 {
     ScreenPtr slave_screen = dirty->slave_dst->drawable.pScreen;
 
-    return slave_screen->SyncSharedPixmap != NULL;
+    return !!slave_screen->SyncSharedPixmap;
 }
 
 static void
@@ -749,7 +743,7 @@ radeon_prime_scanout_update_handler(xf86
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
     radeon_prime_scanout_do_update(crtc, 0);
-    drmmode_crtc->scanout_update_pending = FALSE;
+    drmmode_crtc->scanout_update_pending = 0;
 }
 
 static void
@@ -790,7 +784,7 @@ radeon_prime_scanout_update(PixmapDirtyU
 	return;
     }
 
-    drmmode_crtc->scanout_update_pending = TRUE;
+    drmmode_crtc->scanout_update_pending = drm_queue_seq;
 }
 
 static void
@@ -848,7 +842,7 @@ radeon_prime_scanout_flip(PixmapDirtyUpd
     }
 
     drmmode_crtc->scanout_id = scanout_id;
-    drmmode_crtc->scanout_update_pending = TRUE;
+    drmmode_crtc->scanout_update_pending = drm_queue_seq;
 }
 
 static void
@@ -903,10 +897,10 @@ radeon_dirty_update(ScrnInfoPtr scrn)
 
 Bool
 radeon_scanout_do_update(xf86CrtcPtr xf86_crtc, int scanout_id,
-			 PixmapPtr src_pix, BoxPtr extents)
+			 PixmapPtr src_pix, BoxRec extents)
 {
     drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
-    RegionRec region = { .extents = *extents, .data = NULL };
+    RegionRec region = { .extents = extents, .data = NULL };
     ScrnInfoPtr scrn = xf86_crtc->scrn;
     ScreenPtr pScreen = scrn->pScreen;
     RADEONInfoPtr info = RADEONPTR(scrn);
@@ -915,11 +909,11 @@ radeon_scanout_do_update(xf86CrtcPtr xf8
 
     if (!xf86_crtc->enabled ||
 	!drmmode_crtc->scanout[scanout_id].pixmap ||
-	extents->x1 >= extents->x2 || extents->y1 >= extents->y2)
+	extents.x1 >= extents.x2 || extents.y1 >= extents.y2)
 	return FALSE;
 
     pDraw = &drmmode_crtc->scanout[scanout_id].pixmap->drawable;
-    if (!radeon_scanout_extents_intersect(xf86_crtc, extents))
+    if (!radeon_scanout_extents_intersect(xf86_crtc, &extents))
 	return FALSE;
 
     if (drmmode_crtc->tear_free) {
@@ -965,9 +959,9 @@ radeon_scanout_do_update(xf86CrtcPtr xf8
 	pScreen->SourceValidate = NULL;
 	CompositePicture(PictOpSrc,
 			 src, NULL, dst,
-			 extents->x1, extents->y1, 0, 0, extents->x1,
-			 extents->y1, extents->x2 - extents->x1,
-			 extents->y2 - extents->y1);
+			 extents.x1, extents.y1, 0, 0, extents.x1,
+			 extents.y1, extents.x2 - extents.x1,
+			 extents.y2 - extents.y1);
 	pScreen->SourceValidate = SourceValidate;
 
  free_dst:
@@ -981,14 +975,12 @@ radeon_scanout_do_update(xf86CrtcPtr xf8
 
 	ValidateGC(pDraw, gc);
 	(*gc->ops->CopyArea)(&src_pix->drawable, pDraw, gc,
-			     xf86_crtc->x + extents->x1, xf86_crtc->y + extents->y1,
-			     extents->x2 - extents->x1, extents->y2 - extents->y1,
-			     extents->x1, extents->y1);
+			     xf86_crtc->x + extents.x1, xf86_crtc->y + extents.y1,
+			     extents.x2 - extents.x1, extents.y2 - extents.y1,
+			     extents.x1, extents.y1);
 	FreeScratchGC(gc);
     }
 
-    radeon_cs_flush_indirect(scrn);
-
     info->accel_state->force = force;
 
     return TRUE;
@@ -999,7 +991,7 @@ radeon_scanout_update_abort(xf86CrtcPtr 
 {
     drmmode_crtc_private_ptr drmmode_crtc = event_data;
 
-    drmmode_crtc->scanout_update_pending = FALSE;
+    drmmode_crtc->scanout_update_pending = 0;
 }
 
 static void
@@ -1015,8 +1007,10 @@ radeon_scanout_update_handler(xf86CrtcPt
 	drmmode_crtc->dpms_mode == DPMSModeOn) {
 	if (radeon_scanout_do_update(crtc, drmmode_crtc->scanout_id,
 				     screen->GetWindowPixmap(screen->root),
-				     &region->extents))
+				     region->extents)) {
+	    radeon_cs_flush_indirect(crtc->scrn);
 	    RegionEmpty(region);
+	}
     }
 
     radeon_scanout_update_abort(crtc, event_data);
@@ -1074,7 +1068,7 @@ radeon_scanout_update(xf86CrtcPtr xf86_c
 	return;
     }
 
-    drmmode_crtc->scanout_update_pending = TRUE;
+    drmmode_crtc->scanout_update_pending = drm_queue_seq;
 }
 
 static void
@@ -1096,8 +1090,10 @@ radeon_scanout_flip(ScreenPtr pScreen, R
     scanout_id = drmmode_crtc->scanout_id ^ 1;
     if (!radeon_scanout_do_update(xf86_crtc, scanout_id,
 				  pScreen->GetWindowPixmap(pScreen->root),
-				  &region->extents))
+				  region->extents))
 	return;
+
+    radeon_cs_flush_indirect(scrn);
     RegionEmpty(region);
 
     drm_queue_seq = radeon_drm_queue_alloc(xf86_crtc,
@@ -1139,7 +1135,7 @@ radeon_scanout_flip(ScreenPtr pScreen, R
     }
 
     drmmode_crtc->scanout_id = scanout_id;
-    drmmode_crtc->scanout_update_pending = TRUE;
+    drmmode_crtc->scanout_update_pending = drm_queue_seq;
 }
 
 static void RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
@@ -1162,6 +1158,9 @@ static void RADEONBlockHandler_KMS(BLOCK
 	    xf86CrtcPtr crtc = xf86_config->crtc[c];
 	    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
+	    if (drmmode_crtc->rotate.pixmap)
+		continue;
+
 	    if (drmmode_crtc->tear_free)
 		radeon_scanout_flip(pScreen, info, crtc);
 	    else if (drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap)
@@ -1681,8 +1680,7 @@ void RADEONWindowExposures_oneshot(Windo
     pScreen->WindowExposures(pWin, pRegion);
 #endif
 
-    radeon_cs_flush_indirect(pScrn);
-    radeon_bo_wait(info->front_bo);
+    radeon_finish(pScrn, info->front_buffer);
     drmmode_set_desired_modes(pScrn, &info->drmmode, TRUE);
 }
 
@@ -1762,7 +1760,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn
     info->dri2.available = FALSE;
     info->dri2.enabled = FALSE;
     info->dri2.pKernelDRMVersion = drmGetVersion(pRADEONEnt->fd);
-    if (info->dri2.pKernelDRMVersion == NULL) {
+    if (!info->dri2.pKernelDRMVersion) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		   "RADEONDRIGetVersion failed to get the DRM version\n");
 	return FALSE;
@@ -1782,7 +1780,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn
 	return FALSE;
     }
 
-    radeon_drm_queue_init();
+    radeon_drm_queue_init(pScrn);
 
     info->allowColorTiling2D = FALSE;
 
@@ -1917,7 +1915,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn
 	    xf86OutputPtr output = xf86_config->output[i];
 
 	    /* XXX: double check crtc mode */
-	    if ((output->probed_modes != NULL) && (output->crtc == NULL))
+	    if (output->probed_modes && !output->crtc)
 		output->crtc = xf86_config->crtc[0];
 	}
     }
@@ -1980,7 +1978,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn
 	if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE;
     }
 
-    if (pScrn->modes == NULL
+    if (!pScrn->modes
 #ifdef XSERVER_PLATFORM_BUS
         && !pScrn->is_gpu
 #endif
@@ -2017,12 +2015,8 @@ static Bool RADEONCursorInit_KMS(ScreenP
 	    return FALSE;
 	}
 
-	if (PointPriv->spriteFuncs->SetCursor != drmmode_sprite_set_cursor) {
-	    info->SetCursor = PointPriv->spriteFuncs->SetCursor;
-	    info->MoveCursor = PointPriv->spriteFuncs->MoveCursor;
-	    PointPriv->spriteFuncs->SetCursor = drmmode_sprite_set_cursor;
-	    PointPriv->spriteFuncs->MoveCursor = drmmode_sprite_move_cursor;
-	}
+	info->SpriteFuncs = PointPriv->spriteFuncs;
+	PointPriv->spriteFuncs = &drmmode_sprite_funcs;
     }
 
     if (xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE))
@@ -2095,7 +2089,7 @@ static Bool RADEONSaveScreen_KMS(ScreenP
     unblank = xf86IsUnblank(mode);
     if (unblank) SetTimeSinceLastInputEvent();
 
-    if ((pScrn != NULL) && pScrn->vtSema) {
+    if (pScrn && pScrn->vtSema) {
 	if (unblank)
 	    RADEONUnblank(pScrn);
 	else
@@ -2186,10 +2180,8 @@ static Bool RADEONCloseScreen_KMS(Screen
 	miPointerScreenPtr PointPriv =
 	    dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
 
-	if (PointPriv->spriteFuncs->SetCursor == drmmode_sprite_set_cursor) {
-	    PointPriv->spriteFuncs->SetCursor = info->SetCursor;
-	    PointPriv->spriteFuncs->MoveCursor = info->MoveCursor;
-	}
+	if (PointPriv->spriteFuncs == &drmmode_sprite_funcs)
+	    PointPriv->spriteFuncs = info->SpriteFuncs;
     }
 
     pScreen->BlockHandler = info->BlockHandler;
@@ -2234,7 +2226,16 @@ Bool RADEONScreenInit_KMS(ScreenPtr pScr
     if (info->r600_shadow_fb == FALSE)
         info->directRenderingEnabled = radeon_dri2_screen_init(pScreen);
 
-    info->surf_man = radeon_surface_manager_new(pRADEONEnt->fd);
+    if (info->ChipFamily >= CHIP_FAMILY_R600) {
+	info->surf_man = radeon_surface_manager_new(pRADEONEnt->fd);
+
+	if (!info->surf_man) {
+	    xf86DrvMsg(pScreen->myNum, X_ERROR,
+		       "Failed to initialize surface manager\n");
+	    return FALSE;
+	}
+    }
+
     if (!info->bufmgr)
         info->bufmgr = radeon_bo_manager_gem_ctor(pRADEONEnt->fd);
     if (!info->bufmgr) {
@@ -2267,13 +2268,17 @@ Bool RADEONScreenInit_KMS(ScreenPtr pScr
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "radeon_setup_kernel_mem failed\n");
 	return FALSE;
     }
-    front_ptr = info->front_bo->ptr;
+
+    if (!(info->front_buffer->flags & RADEON_BO_FLAGS_GBM))
+	front_ptr = info->front_buffer->bo.radeon->ptr;
+    else
+	front_ptr = NULL;
 
     if (info->r600_shadow_fb) {
 	info->fb_shadow = calloc(1,
 				 pScrn->displayWidth * pScrn->virtualY *
 				 ((pScrn->bitsPerPixel + 7) >> 3));
-	if (info->fb_shadow == NULL) {
+	if (!info->fb_shadow) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                        "Failed to allocate shadow framebuffer\n");
 	    return FALSE;
@@ -2476,15 +2481,17 @@ Bool RADEONEnterVT_KMS(ScrnInfoPtr pScrn
     if (info->r600_shadow_fb) {
 	int base_align = drmmode_get_base_align(pScrn, info->pixel_bytes, 0);
 	struct radeon_bo *front_bo = radeon_bo_open(info->bufmgr, 0,
-						    info->front_bo->size,
+						    pScrn->displayWidth *
+						    info->pixel_bytes *
+						    pScrn->virtualY,
 						    base_align,
 						    RADEON_GEM_DOMAIN_VRAM, 0);
 
 	if (front_bo) {
 	    if (radeon_bo_map(front_bo, 1) == 0) {
 		memset(front_bo->ptr, 0, front_bo->size);
-		radeon_bo_unref(info->front_bo);
-		info->front_bo = front_bo;
+		radeon_bo_unref(info->front_buffer->bo.radeon);
+		info->front_buffer->bo.radeon = front_bo;
 	    } else {
 		radeon_bo_unref(front_bo);
 		front_bo = NULL;
@@ -2582,8 +2589,7 @@ void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn
 		    radeon_pixmap_get_fb(black_scanout.pixmap);
 
 		radeon_pixmap_clear(black_scanout.pixmap);
-		radeon_cs_flush_indirect(pScrn);
-		radeon_bo_wait(black_scanout.bo);
+		radeon_finish(pScrn, black_scanout.bo);
 
 		for (i = 0; i < xf86_config->num_crtc; i++) {
 		    crtc = xf86_config->crtc[i];
@@ -2632,7 +2638,8 @@ void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn
 
 	pixmap_unref_fb(pScreen->GetScreenPixmap(pScreen), None, pRADEONEnt);
     } else {
-	memset(info->front_bo->ptr, 0, info->front_bo->size);
+	memset(info->front_buffer->bo.radeon->ptr, 0,
+	       pScrn->displayWidth * info->pixel_bytes * pScrn->virtualY);
     }
 
     TimerSet(NULL, 0, 1000, cleanup_black_fb, pScreen);
@@ -2670,98 +2677,21 @@ static Bool radeon_setup_kernel_mem(Scre
     RADEONInfoPtr info = RADEONPTR(pScrn);
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int cpp = info->pixel_bytes;
-    uint32_t screen_size;
-    int pitch, base_align;
+    int pitch;
     uint32_t tiling_flags = 0;
-    struct radeon_surface surface;
 
-    if (info->accel_state->exa != NULL) {
+    if (info->accel_state->exa) {
 	xf86DrvMsg(pScreen->myNum, X_ERROR, "Memory map already initialized\n");
 	return FALSE;
     }
     if (!info->use_glamor && info->r600_shadow_fb == FALSE) {
         info->accel_state->exa = exaDriverAlloc();
-        if (info->accel_state->exa == NULL) {
+        if (!info->accel_state->exa) {
 	    xf86DrvMsg(pScreen->myNum, X_ERROR, "exaDriverAlloc failed\n");
 	    return FALSE;
 	}
     }
 
-    if (info->allowColorTiling && !info->shadow_primary) {
-	if (info->ChipFamily >= CHIP_FAMILY_R600) {
-		if (info->allowColorTiling2D) {
-			tiling_flags |= RADEON_TILING_MACRO;
-		} else {
-			tiling_flags |= RADEON_TILING_MICRO;
-		}
-	} else
-	    tiling_flags |= RADEON_TILING_MACRO;
-    }
-    pitch = RADEON_ALIGN(pScrn->virtualX, drmmode_get_pitch_align(pScrn, cpp, tiling_flags)) * cpp;
-    screen_size = RADEON_ALIGN(pScrn->virtualY, drmmode_get_height_align(pScrn, tiling_flags)) * pitch;
-    base_align = drmmode_get_base_align(pScrn, cpp, tiling_flags);
-	if (info->ChipFamily >= CHIP_FAMILY_R600) {
-		if(!info->surf_man) {
-			xf86DrvMsg(pScreen->myNum, X_ERROR,
-				   "failed to initialise surface manager\n");
-			return FALSE;
-		}
-		memset(&surface, 0, sizeof(struct radeon_surface));
-		surface.npix_x = pScrn->virtualX;
-		surface.npix_y = pScrn->virtualY;
-		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)) {
-			xf86DrvMsg(pScreen->myNum, X_ERROR,
-				   "radeon_surface_best failed\n");
-			return FALSE;
-		}
-		if (radeon_surface_init(info->surf_man, &surface)) {
-			xf86DrvMsg(pScreen->myNum, X_ERROR,
-				   "radeon_surface_init failed\n");
-			return FALSE;
-		}
-		pitch = surface.level[0].pitch_bytes;
-		screen_size = surface.bo_size;
-		base_align = surface.bo_alignment;
-		tiling_flags = 0;
-		switch (surface.level[0].mode) {
-		case RADEON_SURF_MODE_2D:
-			tiling_flags |= RADEON_TILING_MACRO;
-			tiling_flags |= surface.bankw << RADEON_TILING_EG_BANKW_SHIFT;
-			tiling_flags |= surface.bankh << RADEON_TILING_EG_BANKH_SHIFT;
-			tiling_flags |= surface.mtilea << RADEON_TILING_EG_MACRO_TILE_ASPECT_SHIFT;
-			if (surface.tile_split)
-				tiling_flags |= eg_tile_split(surface.tile_split)
-						<< RADEON_TILING_EG_TILE_SPLIT_SHIFT;
-			break;
-		case RADEON_SURF_MODE_1D:
-			tiling_flags |= RADEON_TILING_MICRO;
-			break;
-		default:
-			break;
-		}
-		info->front_surface = surface;
-	}
     {
 	int cursor_size;
 	int c;
@@ -2770,7 +2700,7 @@ static Bool radeon_setup_kernel_mem(Scre
 	cursor_size = RADEON_ALIGN(cursor_size, RADEON_GPU_PAGE_SIZE);
 	for (c = 0; c < xf86_config->num_crtc; c++) {
 	    /* cursor objects */
-            if (info->cursor_bo[c] == NULL) {
+            if (!info->cursor_bo[c]) {
                 info->cursor_bo[c] = radeon_bo_open(info->bufmgr, 0,
                                                     cursor_size, 0,
                                                     RADEON_GEM_DOMAIN_VRAM, 0);
@@ -2788,41 +2718,56 @@ static Bool radeon_setup_kernel_mem(Scre
         }
     }
 
-    screen_size = RADEON_ALIGN(screen_size, RADEON_GPU_PAGE_SIZE);
+    if (!info->front_buffer) {
+	int usage = CREATE_PIXMAP_USAGE_BACKING_PIXMAP;
+
+	if (info->allowColorTiling && !info->shadow_primary) {
+	    if (info->ChipFamily < CHIP_FAMILY_R600 || info->allowColorTiling2D)
+		usage |= RADEON_CREATE_PIXMAP_TILING_MACRO;
+	    else
+		usage |= RADEON_CREATE_PIXMAP_TILING_MICRO;
+	}
+
+        info->front_buffer = radeon_alloc_pixmap_bo(pScrn, pScrn->virtualX,
+						    pScrn->virtualY,
+						    pScrn->depth,
+						    usage,
+						    pScrn->bitsPerPixel,
+						    &pitch,
+						    &info->front_surface,
+						    &tiling_flags);
 
-    if (info->front_bo == NULL) {
-        info->front_bo = radeon_bo_open(info->bufmgr, 0, screen_size,
-                                        base_align,
-                                        info->shadow_primary ?
-                                        RADEON_GEM_DOMAIN_GTT :
-                                        RADEON_GEM_DOMAIN_VRAM,
-                                        tiling_flags ? RADEON_GEM_NO_CPU_ACCESS : 0);
         if (info->r600_shadow_fb == TRUE) {
-            if (radeon_bo_map(info->front_bo, 1)) {
+            if (radeon_bo_map(info->front_buffer->bo.radeon, 1)) {
                 ErrorF("Failed to map cursor buffer memory\n");
             }
         }
+
+	if (!info->use_glamor) {
 #if X_BYTE_ORDER == X_BIG_ENDIAN
-	switch (cpp) {
-	case 4:
-	    tiling_flags |= RADEON_TILING_SWAP_32BIT;
-	    break;
-	case 2:
-	    tiling_flags |= RADEON_TILING_SWAP_16BIT;
-	    break;
-	}
-	if (info->ChipFamily < CHIP_FAMILY_R600 &&
-	    info->r600_shadow_fb && tiling_flags)
-	    tiling_flags |= RADEON_TILING_SURFACE;
+	    switch (cpp) {
+	    case 4:
+		tiling_flags |= RADEON_TILING_SWAP_32BIT;
+		break;
+	    case 2:
+		tiling_flags |= RADEON_TILING_SWAP_16BIT;
+		break;
+	    }
+	    if (info->ChipFamily < CHIP_FAMILY_R600 &&
+		info->r600_shadow_fb && tiling_flags)
+		tiling_flags |= RADEON_TILING_SURFACE;
 #endif
-	if (tiling_flags)
-            radeon_bo_set_tiling(info->front_bo, tiling_flags, pitch);
-    }
+	    if (tiling_flags)
+		radeon_bo_set_tiling(info->front_buffer->bo.radeon, tiling_flags, pitch);
+	}
 
-    pScrn->displayWidth = pitch / cpp;
+	pScrn->displayWidth = pitch / cpp;
+    }
 
-    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Front buffer size: %dK\n", info->front_bo->size/1024);
-    radeon_kms_update_vram_limit(pScrn, screen_size);
+    pitch = pScrn->displayWidth * cpp;
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Front buffer size: %dK\n",
+	       pitch * pScrn->virtualY / 1024);
+    radeon_kms_update_vram_limit(pScrn, pitch * pScrn->virtualY);
     return TRUE;
 }
 
@@ -2834,9 +2779,8 @@ void radeon_kms_update_vram_limit(ScrnIn
     int c;
 
     for (c = 0; c < xf86_config->num_crtc; c++) {
-	if (info->cursor_bo[c] != NULL) {
+	if (info->cursor_bo[c])
 	    new_fb_size += (64 * 4 * 64);
-	}
     }
 
     remain_size_bytes = info->vram_size - new_fb_size;

Index: xsrc/external/mit/xf86-video-ati-kms/include/config.h
diff -u xsrc/external/mit/xf86-video-ati-kms/include/config.h:1.6 xsrc/external/mit/xf86-video-ati-kms/include/config.h:1.7
--- xsrc/external/mit/xf86-video-ati-kms/include/config.h:1.6	Sun Mar 11 19:44:00 2018
+++ xsrc/external/mit/xf86-video-ati-kms/include/config.h	Sun Dec 30 07:34:43 2018
@@ -86,7 +86,7 @@
 #define PACKAGE_NAME "xf86-video-ati"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "xf86-video-ati 18.0.0"
+#define PACKAGE_STRING "xf86-video-ati 18.1.0"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "xf86-video-ati"
@@ -95,13 +95,13 @@
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "18.0.0"
+#define PACKAGE_VERSION "18.1.0"
 
 /* Major version of this package */
 #define PACKAGE_VERSION_MAJOR 18
 
 /* Minor version of this package */
-#define PACKAGE_VERSION_MINOR 0
+#define PACKAGE_VERSION_MINOR 1
 
 /* Patch version of this package */
 #define PACKAGE_VERSION_PATCHLEVEL 0
@@ -116,7 +116,7 @@
 #define USE_SYS_ENDIAN_H 1
 
 /* Version number of package */
-#define VERSION "18.0.0"
+#define VERSION "18.1.0"
 
 /* Enable large inode numbers on Mac OS X 10.5.  */
 #ifndef _DARWIN_USE_64_BIT_INODE

Reply via email to