xf86-video-ati: Branch 'master' - 8 commits

Michel Dänzer daenzer at kemper.freedesktop.org
Wed Nov 11 18:28:07 PST 2015


 src/drmmode_display.c |   57 ++++++++++++++++++++++++++++----------------------
 src/radeon_dri2.c     |   20 +++++------------
 src/radeon_video.c    |   56 +++++++++++++++++++++----------------------------
 3 files changed, 63 insertions(+), 70 deletions(-)

New commits:
commit 98291869ac4a542a0b478920586407ff9d2c8ef0
Author: Tom St Denis <tom.stdenis at amd.com>
Date:   Wed Nov 11 16:01:41 2015 +0900

    Clean up radeon_dri2_create_buffer2()
    
    Remove the depth_pixmap variable from the function and clear
    out any dead/odd behaviour that results.
    
    Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
    (ported from amdgpu commit 6000aef4e2f0a121b94023484406fb6f04688f74)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 466d700..d30bbd0 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -181,7 +181,7 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
     RADEONInfoPtr info = RADEONPTR(pScrn);
     BufferPtr buffers;
     struct dri2_buffer_priv *privates;
-    PixmapPtr pixmap, depth_pixmap;
+    PixmapPtr pixmap;
     int flags;
     unsigned front_width;
     uint32_t tiling = 0;
@@ -209,10 +209,9 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
 	cpp = drawable->bitsPerPixel / 8;
     }
 
-    pixmap = pScreen->GetScreenPixmap(pScreen);
-    front_width = pixmap->drawable.width;
+    front_width = pScreen->GetScreenPixmap(pScreen)->drawable.width;
 
-    pixmap = depth_pixmap = NULL;
+    pixmap = NULL;
 
     if (attachment == DRI2BufferFrontLeft) {
 	uint32_t handle;
@@ -227,9 +226,6 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
 	    pixmap = NULL;
 	} else
 	    pixmap->refcnt++;
-    } else if (attachment == DRI2BufferStencil && depth_pixmap) {
-        pixmap = depth_pixmap;
-        pixmap->refcnt++;
     }
 
     if (!pixmap && (is_glamor_pixmap || attachment != DRI2BufferFrontLeft)) {
@@ -314,10 +310,6 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
     if (buffers == NULL)
         goto error;
 
-    if (attachment == DRI2BufferDepth) {
-        depth_pixmap = pixmap;
-    }
-
     if (pixmap) {
 	if (!info->use_glamor) {
 	    info->exa_force_create = TRUE;
commit c6fc7e309a8a922f94a1f5f3e8bfb9058cff7ad1
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Nov 11 15:59:06 2015 +0900

    Properly handle drmModeAddFB failure in drmmode_crtc_scanout_allocate
    
    We were printing an error message, but not propagating the failure. That
    would probably lead to trouble down the road.
    
    (ported from amdgpu commit 21e72fb2418b5cc7fc849a9cf951186e209036b0)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 22b84da..17e5231 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -555,8 +555,12 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 			   pScrn->bitsPerPixel, rotate_pitch,
 			   scanout->bo->handle,
 			   &scanout->fb_id);
-	if (ret)
+	if (ret) {
 		ErrorF("failed to add scanout fb\n");
+		radeon_bo_unref(scanout->bo);
+		scanout->bo = NULL;
+		return NULL;
+	}
 
 	scanout->width = width;
 	scanout->height = height;
commit 4e4f4d53da0539ef9feb8766230a6e9927ae005b
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Nov 11 15:57:21 2015 +0900

    Eliminate redundant data parameter from drmmode_crtc_scanout_create
    
    drmmode_crtc_scanout_create just needs to call
    drmmode_crtc_scanout_allocate when scanout->bo is NULL.
    
    This makes it clearer to the reader / compiler that
    drmmode_crtc_scanout_create doesn't dereference scanout->bo when it's
    NULL.
    
    (ported from amdgpu commit 8da1d0c870e1081d77925807d6e3bbc61a23f54f)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 4397c51..22b84da 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -565,7 +565,7 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 
 static PixmapPtr
 drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
-			    void *data, int width, int height)
+			    int width, int height)
 {
 	ScrnInfoPtr pScrn = crtc->scrn;
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
@@ -579,8 +579,10 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
 		drmmode_crtc_scanout_destroy(drmmode, scanout);
 	}
 
-	if (!data)
-		data = drmmode_crtc_scanout_allocate(crtc, scanout, width, height);
+	if (!scanout->bo) {
+		if (!drmmode_crtc_scanout_allocate(crtc, scanout, width, height))
+			return NULL;
+	}
 
 	rotate_pitch = RADEON_ALIGN(width, drmmode_get_pitch_align(pScrn, drmmode->cpp, 0))
 		* drmmode->cpp;
@@ -713,7 +715,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 			for (i = 0; i < (info->tear_free ? 2 : 1); i++) {
 				drmmode_crtc_scanout_create(crtc,
 							    &drmmode_crtc->scanout[i],
-							    NULL, mode->HDisplay,
+							    mode->HDisplay,
 							    mode->VDisplay);
 
 				if (drmmode_crtc->scanout[i].pixmap) {
@@ -887,8 +889,11 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-	return drmmode_crtc_scanout_create(crtc, &drmmode_crtc->rotate, data,
-					   width, height);
+	/* Xorg passes in the return value of drmmode_crtc_shadow_allocate
+	 * for data, but that's redundant for drmmode_crtc_scanout_create.
+	 */
+	return drmmode_crtc_scanout_create(crtc, &drmmode_crtc->rotate, width,
+					   height);
 }
 
 static void
commit 421a7e797bdd58d83e81af7a6512cc715a3df514
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Nov 11 15:51:58 2015 +0900

    Don't advertise rotation support without hardware acceleration v2
    
    Rotation currently doesn't work without acceleration (doesn't actually
    rotate with Option "NoAccel", crashes with Option "AccelMethod" "none"
    or when glamor fails to initialize) and would probably be too slow
    anyway.
    
    v2: Also remove now dead code checking for ShadowFB from
        drmmode_crtc_scanout_allocate().
    
    (ported from amdgpu commit dc40582d5ff94d812cbc08f95cf14b80cd0f410d)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 561b55e..4397c51 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -522,7 +522,6 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 			      int width, int height)
 {
 	ScrnInfoPtr pScrn = crtc->scrn;
-	RADEONInfoPtr info = RADEONPTR(pScrn);
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 	int aligned_height;
@@ -531,13 +530,6 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 	unsigned long rotate_pitch;
 	int base_align;
 
-	/* rotation requires acceleration */
-	if (info->r600_shadow_fb) {
-		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-			   "Rotation requires acceleration!\n");
-		return NULL;
-	}
-
 	if (scanout->bo) {
 		if (scanout->width == width && scanout->height == height)
 			return scanout->bo->ptr;
@@ -983,7 +975,7 @@ drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 }
 #endif
 
-static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
+static xf86CrtcFuncsRec drmmode_crtc_funcs = {
     .dpms = drmmode_crtc_dpms,
     .set_mode_major = drmmode_set_mode_major,
     .set_cursor_colors = drmmode_set_cursor_colors,
@@ -2066,6 +2058,7 @@ drm_wakeup_handler(pointer data, int err, pointer p)
 Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
 {
 	RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+	RADEONInfoPtr info = RADEONPTR(pScrn);
 	int i, num_dvi = 0, num_hdmi = 0;
 	drmModeResPtr mode_res;
 	unsigned int crtcs_needed = 0;
@@ -2086,8 +2079,16 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
 	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
 		       "%d crtcs needed for screen.\n", crtcs_needed);
 
+	if (info->r600_shadow_fb) {
+		/* Rotation requires hardware acceleration */
+		drmmode_crtc_funcs.shadow_allocate = NULL;
+		drmmode_crtc_funcs.shadow_create = NULL;
+		drmmode_crtc_funcs.shadow_destroy = NULL;
+	}
+
 	drmmode->count_crtcs = mode_res->count_crtcs;
 	xf86CrtcSetSizeRange(pScrn, 320, 200, mode_res->max_width, mode_res->max_height);
+
 	for (i = 0; i < mode_res->count_crtcs; i++)
 		if (!xf86IsEntityShared(pScrn->entityList[0]) ||
 		    (crtcs_needed && !(pRADEONEnt->assigned_crtcs & (1 << i))))
commit 875ad48e7b5cdb7beefbf18dddcbee3ed22b5446
Author: Tom St Denis <tom.stdenis at amd.com>
Date:   Wed Nov 11 15:51:19 2015 +0900

    Simplify drmmode_set_mode_major() and avoid leaking memory.
    
    The function would leak the memory allocated for output_ids.  This
    patch addresses that as well as simplifies the logic somewhat.
    
    Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
    (ported from amdgpu commit 460560502a1bdf26d06f3c30df46fa9f28ffb9e5)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 3a3f407..561b55e 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -626,7 +626,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 	int saved_x, saved_y;
 	Rotation saved_rotation;
 	DisplayModeRec saved_mode;
-	uint32_t *output_ids;
+	uint32_t *output_ids = NULL;
 	int output_count = 0;
 	Bool ret = TRUE;
 	int i;
@@ -672,15 +672,13 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		crtc->y = y;
 		crtc->rotation = rotation;
 		crtc->transformPresent = FALSE;
-	}
 
-	output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
-	if (!output_ids) {
-		ret = FALSE;
-		goto done;
-	}
+		output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
+		if (!output_ids) {
+			ret = FALSE;
+			goto done;
+		}
 
-	if (mode) {
 		ScreenPtr pScreen = pScrn->pScreen;
 
 		for (i = 0; i < xf86_config->num_output; i++) {
@@ -792,6 +790,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		xf86_reload_cursors(pScrn->pScreen);
 
 done:
+	free(output_ids);
 	if (!ret) {
 		crtc->x = saved_x;
 		crtc->y = saved_y;
commit 789d7d6a04cca6b36fb088a074027807ccb8dd61
Author: Tom St Denis <tom.stdenis at amd.com>
Date:   Wed Nov 11 15:48:51 2015 +0900

    Clean up allocation in RADEONInitVideo()
    
    The allocation of the adapters should use the correct sizeof (even if
    allocating an array of pointers).
    
    Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
    (ported from amdgpu commit db3bb2061b9ac16b0922d9afae99874820356a04)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/radeon_video.c b/src/radeon_video.c
index 7abc2f6..48b06e2 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -145,7 +145,7 @@ void RADEONInitVideo(ScreenPtr pScreen)
 	    return;
 
     num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors);
-    newAdaptors = malloc((num_adaptors + 2) * sizeof(XF86VideoAdaptorPtr *));
+    newAdaptors = malloc((num_adaptors + 2) * sizeof(*newAdaptors));
     if (newAdaptors == NULL)
 	return;
 
commit d88fa0dd5d37604de8efb05853738cfaca6a3166
Author: Tom St Denis <tom.stdenis at amd.com>
Date:   Wed Nov 11 15:46:50 2015 +0900

    Simplify pick best crtc to fold two loops into one
    
    This patch folds the two for loops from radeon_pick_best_crtc() into
    one to reduce the LOC and make the routine easier to read.
    
    Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
    (ported from amdgpu commit 3055724aef76a624718f26d5f0f9e9d567ffbcfb)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/radeon_video.c b/src/radeon_video.c
index 9b714e9..7abc2f6 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -79,7 +79,7 @@ radeon_pick_best_crtc(ScrnInfoPtr pScrn, Bool consider_disabled,
 		      int x1, int x2, int y1, int y2)
 {
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-    int			coverage, best_coverage, c;
+    int			coverage, best_coverage, c, cd;
     BoxRec		box, crtc_box, cover_box;
     RROutputPtr         primary_output = NULL;
     xf86CrtcPtr         best_crtc = NULL, primary_crtc = NULL;
@@ -103,38 +103,30 @@ radeon_pick_best_crtc(ScrnInfoPtr pScrn, Bool consider_disabled,
     if (primary_output && primary_output->crtc)
 	primary_crtc = primary_output->crtc->devPrivate;
 
-    /* first consider only enabled CRTCs */
-    for (c = 0; c < xf86_config->num_crtc; c++) {
-	xf86CrtcPtr crtc = xf86_config->crtc[c];
-
-	if (!radeon_crtc_is_enabled(crtc))
-	    continue;
-
-	radeon_crtc_box(crtc, &crtc_box);
-	radeon_box_intersect(&cover_box, &crtc_box, &box);
-	coverage = radeon_box_area(&cover_box);
-	if (coverage > best_coverage ||
-	    (coverage == best_coverage && crtc == primary_crtc)) {
-	    best_crtc = crtc;
-	    best_coverage = coverage;
-	}
-    }
-    if (best_crtc || !consider_disabled)
-	return best_crtc;
-
-    /* if we found nothing, repeat the search including disabled CRTCs */
-    for (c = 0; c < xf86_config->num_crtc; c++) {
-	xf86CrtcPtr crtc = xf86_config->crtc[c];
-
-	radeon_crtc_box(crtc, &crtc_box);
-	radeon_box_intersect(&cover_box, &crtc_box, &box);
-	coverage = radeon_box_area(&cover_box);
-	if (coverage > best_coverage ||
-	    (coverage == best_coverage && crtc == primary_crtc)) {
-	    best_crtc = crtc;
-	    best_coverage = coverage;
+    /* first consider only enabled CRTCs
+     * then on second pass consider disabled ones
+     */
+    for (cd = 0; cd < (consider_disabled ? 2 : 1); cd++) {
+	for (c = 0; c < xf86_config->num_crtc; c++) {
+	    xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+	    if (!cd && !radeon_crtc_is_enabled(crtc))
+		continue;
+
+	    radeon_crtc_box(crtc, &crtc_box);
+	    radeon_box_intersect(&cover_box, &crtc_box, &box);
+	    coverage = radeon_box_area(&cover_box);
+	    if (coverage > best_coverage ||
+		(coverage == best_coverage &&
+		 crtc == primary_crtc)) {
+		best_crtc = crtc;
+		best_coverage = coverage;
+	    }
 	}
+	if (best_crtc)
+	    break;
     }
+
     return best_crtc;
 }
 
commit dbbcd75b3c80aba77673904d46bca97779fd8a8d
Author: Tom St Denis <tom.stdenis at amd.com>
Date:   Wed Nov 11 12:54:54 2015 +0900

    dri2: Avoid calculation with undefined msc value
    
    If the get_msc() call fails for any reason we should avoid updating the
    vblank counter delta with undefined data.
    
    Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com> (minor fixups)
    (ported from amdgpu commit 8823c3d4c6db70cff7699b31088f2d92db8faaf4)
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index b29d88b..466d700 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -641,9 +641,9 @@ xf86CrtcPtr radeon_dri2_drawable_crtc(DrawablePtr pDraw, Bool consider_disabled)
 	if (priv->crtc && priv->crtc != crtc) {
 	    CARD64 ust, mscold, mscnew;
 
-	    radeon_dri2_get_crtc_msc(priv->crtc, &ust, &mscold);
-	    radeon_dri2_get_crtc_msc(crtc, &ust, &mscnew);
-	    priv->vblank_delta += mscold - mscnew;
+	    if (radeon_dri2_get_crtc_msc(priv->crtc, &ust, &mscold) &&
+		radeon_dri2_get_crtc_msc(crtc, &ust, &mscnew))
+		priv->vblank_delta += mscold - mscnew;
 	}
 
 	priv->crtc = crtc;


More information about the xorg-commit mailing list