xf86-video-intel: 3 commits - src/sna/sna_display.c src/sna/sna.h

Chris Wilson ickle at kemper.freedesktop.org
Fri Mar 28 03:01:53 PDT 2014


 src/sna/sna.h         |    5 -
 src/sna/sna_display.c |  129 ++++++++++++++++++++++++++------------------------
 2 files changed, 69 insertions(+), 65 deletions(-)

New commits:
commit 5c0623b5f36cd1a1a2e3280ab2bea35a7899281b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Mar 28 09:53:49 2014 +0000

    sna: Only transform the temporary cursor coordinates
    
    As we need to recompute them for each CRTC, we need to reset the
    computation each time or else we screw up the coordinates and hide
    the cursors at random.
    
    Breakage from commit 25ca8f136cef9e1bdf06967bf8e78c87b54ffce2
    Author: Chris Wilson <chris at chris-wilson.co.uk>
    Date:   Thu Mar 27 14:15:30 2014 +0000
    
        sna: Support variable sized cursors
    
    Reported-by: Jan Alexander Steffens <jan.steffens at gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76724
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index ff29cab..8d271fd 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -3038,37 +3038,33 @@ rotate_coord(Rotation rotation, int width, int height,
 }
 
 static void
-rotate_coord_back(Rotation rotation, int width, int height,
-		  int x_dst, int y_dst,
-		  int *x_src, int *y_src)
+rotate_coord_back(Rotation rotation, int w, int h, int *x, int *y)
 {
 	int t;
 
 	if (rotation & RR_Reflect_X)
-		x_dst = width - x_dst - 1;
+		*x = w - *x - 1;
 	if (rotation & RR_Reflect_Y)
-		y_dst = height - y_dst - 1;
+		*y = h - *y - 1;
 
 	switch (rotation & 0xf) {
 	case RR_Rotate_0:
 		break;
 	case RR_Rotate_90:
-		t = x_dst;
-		x_dst = y_dst;
-		y_dst = width - t - 1;
+		t = *x;
+		*x = *y;
+		*y = w - t - 1;
 		break;
 	case RR_Rotate_180:
-		x_dst = width - x_dst - 1;
-		y_dst = height - y_dst - 1;
+		*x = w - *x - 1;
+		*y = h - *y - 1;
 		break;
 	case RR_Rotate_270:
-		t = x_dst;
-		x_dst = height - y_dst - 1;
-		y_dst = t;
+		t = *x;
+		*x = h - *y - 1;
+		*y = t;
 		break;
 	}
-	*x_src = x_dst;
-	*y_src = y_dst;
 }
 
 static struct sna_cursor *__sna_create_cursor(struct sna *sna, unsigned size)
@@ -3379,33 +3375,26 @@ sna_set_cursor_position(ScrnInfoPtr scrn, int x, int y)
 			int xhot = sna->cursor.ref->bits->xhot;
 			int yhot = sna->cursor.ref->bits->yhot;
 			struct pict_f_vector v;
-			int dx, dy;
 
 			v.v[0] = (x + xhot) + 0.5;
 			v.v[1] = (y + yhot) + 0.5;
 			v.v[2] = 1;
 			pixman_f_transform_point(&crtc->f_framebuffer_to_crtc, &v);
 
+			rotate_coord_back(crtc->rotation, cursor->size, cursor->size, &xhot, &yhot);
+
 			/* cursor will have 0.5 added to it already so floor is sufficent */
-			x = floor(v.v[0]);
-			y = floor(v.v[1]);
-
-			rotate_coord_back(crtc->rotation, cursor->size, cursor->size,
-					  xhot, yhot,
-					  &dx, &dy);
-			x -= dx;
-			y -= dy;
+			arg.x = floor(v.v[0]) - xhot;
+			arg.y = floor(v.v[1]) - yhot;
 		} else {
-			x -= crtc->x;
-			y -= crtc->y;
+			arg.x = x - crtc->x;
+			arg.y = y - crtc->y;
 		}
 
-		if (x < crtc->mode.HDisplay && x > -cursor->size &&
-		    y < crtc->mode.VDisplay && y > -cursor->size) {
+		if (arg.x < crtc->mode.HDisplay && arg.x > -cursor->size &&
+		    arg.y < crtc->mode.VDisplay && arg.y > -cursor->size) {
 			arg.flags = DRM_MODE_CURSOR_MOVE;
 			arg.handle = cursor->handle;
-			arg.x = x;
-			arg.y = y;
 
 			if (sna_crtc->cursor != arg.handle) {
 				arg.flags |= DRM_MODE_CURSOR_BO;
@@ -3423,7 +3412,7 @@ disable:
 		}
 
 		__DBG(("%s: CRTC:%d (%d, %d), handle=%d\n",
-		       __FUNCTION__, sna_crtc->id, x, y, arg.handle));
+		       __FUNCTION__, sna_crtc->id, arg.x, arg.y, arg.handle));
 
 		if (arg.flags &&
 		    drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_CURSOR, &arg) == 0)
commit 80792a3f490578735065d9f67ca6ebac00b5bb75
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Mar 28 09:43:34 2014 +0000

    sna: Our cursors are always square.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index 5253475..a2b5e83 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -106,8 +106,6 @@ void LogF(const char *f, ...);
 #include "sna_render.h"
 #include "fb/fb.h"
 
-#define SNA_CURSOR_X			64
-#define SNA_CURSOR_Y			SNA_CURSOR_X
 struct sna_cursor;
 
 struct sna_client {
@@ -296,8 +294,7 @@ struct sna {
 		int last_x;
 		int last_y;
 
-		unsigned short max_width;
-		unsigned short max_height;
+		unsigned max_size;
 	} cursor;
 
 	struct sna_dri {
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 5c2781c..ff29cab 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -3126,7 +3126,7 @@ static struct sna_cursor *__sna_get_cursor(struct sna *sna, xf86CrtcPtr crtc)
 	i = MAX(sna->cursor.ref->bits->width, sna->cursor.ref->bits->height);
 	for (size = 64; size < i; size <<= 1)
 		;
-	assert(size <= sna->cursor.max_width && size <= sna->cursor.max_height);
+	assert(size <= sna->cursor.max_size);
 
 	rotation = crtc->transform_in_use ? crtc->rotation : RR_Rotate_0;
 	for (cursor = sna->cursor.cursors; cursor; cursor = cursor->next) {
@@ -3462,8 +3462,8 @@ sna_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
 	       cursor->bits->argb!=NULL,
 	       sna->cursor.serial));
 
-	return (cursor->bits->width <= sna->cursor.max_width &&
-		cursor->bits->height <= sna->cursor.max_height);
+	return (cursor->bits->width <= sna->cursor.max_size &&
+		cursor->bits->height <= sna->cursor.max_size);
 }
 
 static void
@@ -3478,22 +3478,21 @@ sna_cursor_pre_init(struct sna *sna)
 #define DRM_CAP_CURSOR_WIDTH	8
 #define DRM_CAP_CURSOR_HEIGHT	9
 
-	sna->cursor.max_width = SNA_CURSOR_X;
-	sna->cursor.max_height = SNA_CURSOR_Y;
+	sna->cursor.max_size = 64;
 
 	cap.name = DRM_CAP_CURSOR_WIDTH;
 	if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_GET_CAP, &cap) == 0)
-		sna->cursor.max_width = cap.value;
+		sna->cursor.max_size = cap.value;
 
+#if HAS_DEBUG_FULL
 	cap.name = DRM_CAP_CURSOR_HEIGHT;
 	if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_GET_CAP, &cap) == 0)
-		sna->cursor.max_height = cap.value;
+		assert(sna->cursor.max_size == cap.value);
+#endif
 
 	xf86DrvMsg(sna->scrn->scrnIndex, X_PROBED,
 		   "Using a maximum size of %dx%d for hardware cursors\n",
-		   sna->cursor.max_width,
-		   sna->cursor.max_height);
-	assert(sna->cursor.max_width == sna->cursor.max_height);
+		   sna->cursor.max_size, sna->cursor.max_size);
 }
 
 bool
@@ -3501,15 +3500,15 @@ sna_cursors_init(ScreenPtr screen, struct sna *sna)
 {
 	xf86CursorInfoPtr cursor_info;
 
-	if ((sna->cursor.max_width | sna->cursor.max_height) == 0)
+	if (sna->cursor.max_size == 0)
 		return false;
 
 	cursor_info = xf86CreateCursorInfoRec();
 	if (cursor_info == NULL)
 		return false;
 
-	cursor_info->MaxWidth = sna->cursor.max_width;
-	cursor_info->MaxHeight = sna->cursor.max_height;
+	cursor_info->MaxWidth = sna->cursor.max_size;
+	cursor_info->MaxHeight = sna->cursor.max_size;
 	cursor_info->Flags = (HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
 			      HARDWARE_CURSOR_UPDATE_UNHIDDEN |
 			      HARDWARE_CURSOR_ARGB);
commit 35b03b3fe6213eb3e08f05efe3428bd6bc5421d2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Mar 28 09:14:59 2014 +0000

    sna: Virtual CRTCs are last, so break loops early
    
    We know that all the virtual CRTCs are at the end of the CRTC array, so
    when we see the first one, we can stop the processing of real CRTCs.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index b850a09..5c2781c 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -1006,7 +1006,7 @@ static void update_flush_interval(struct sna *sna)
 		xf86CrtcPtr crtc = config->crtc[i];
 
 		if (to_sna_crtc(crtc) == NULL)
-			continue;
+			break;
 
 		if (!crtc->enabled) {
 			DBG(("%s: CRTC:%d (pipe %d) disabled\n",
@@ -1093,7 +1093,7 @@ void sna_copy_fbcon(struct sna *sna)
 		struct drm_mode_crtc mode;
 
 		if (!crtc)
-			continue;
+			break;
 
 		VG_CLEAR(mode);
 		mode.crtc_id = crtc->id;
@@ -1533,6 +1533,8 @@ sna_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 	if (mode->HDisplay == 0 || mode->VDisplay == 0)
 		return FALSE;
 
+	assert(sna_crtc);
+
 	xf86DrvMsg(crtc->scrn->scrnIndex, X_INFO,
 		   "switch to mode %dx%d@%.1f on %s using pipe %d, position (%d, %d), rotation %s, reflection %s\n",
 		   mode->HDisplay, mode->VDisplay, xf86ModeVRefresh(mode),
@@ -1600,6 +1602,8 @@ sna_crtc_dpms(xf86CrtcPtr crtc, int mode)
 	if (priv->dpms_mode == mode)
 		return;
 
+	assert(priv);
+
 	if (mode == DPMSModeOn) {
 		if (priv->bo == NULL &&
 		    !sna_crtc_set_mode_major(crtc,
@@ -1630,7 +1634,8 @@ void sna_mode_adjust_frame(struct sna *sna, int x, int y)
 
 		crtc->x = x;
 		crtc->y = y;
-		if (!sna_crtc_set_mode_major(crtc, &crtc->mode,
+		if (to_sna_crtc(crtc) &&
+		    !sna_crtc_set_mode_major(crtc, &crtc->mode,
 					     crtc->rotation, x, y)) {
 			crtc->x = saved_x;
 			crtc->y = saved_y;
@@ -1642,6 +1647,7 @@ static void
 sna_crtc_gamma_set(xf86CrtcPtr crtc,
 		       CARD16 *red, CARD16 *green, CARD16 *blue, int size)
 {
+	assert(to_sna_crtc(crtc));
 	drmModeCrtcSetGamma(to_sna(crtc->scrn)->kgem.fd,
 			    to_sna_crtc(crtc)->id,
 			    size, red, green, blue);
@@ -1663,6 +1669,7 @@ sna_crtc_destroy(xf86CrtcPtr crtc)
 static Bool
 sna_crtc_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr pixmap)
 {
+	assert(to_sna_crtc(crtc));
 	DBG(("%s: CRTC:%d, pipe=%d setting scanout pixmap=%ld\n",
 	     __FUNCTION__,to_sna_crtc(crtc)->id, to_sna_crtc(crtc)->pipe,
 	     pixmap ? pixmap->drawable.serialNumber : 0));
@@ -2093,6 +2100,7 @@ sna_output_get_modes(xf86OutputPtr output)
 		struct drm_mode_crtc mode;
 
 		VG_CLEAR(mode);
+		assert(to_sna_crtc(output->crtc));
 		mode.crtc_id = to_sna_crtc(output->crtc)->id;
 
 		if (drmIoctl(to_sna(output->scrn)->kgem.fd, DRM_IOCTL_MODE_GETCRTC, &mode) == 0) {
@@ -2935,7 +2943,7 @@ sna_mode_resize(ScrnInfoPtr scrn, int width, int height)
 
 		crtc = to_sna_crtc(config->crtc[i]);
 		if (crtc == NULL)
-			continue;
+			break;
 
 		sna_crtc_disable_shadow(sna, crtc);
 	}
@@ -2961,7 +2969,10 @@ sna_mode_resize(ScrnInfoPtr scrn, int width, int height)
 	for (i = 0; i < config->num_crtc; i++) {
 		xf86CrtcPtr crtc = config->crtc[i];
 
-		if (!crtc->enabled || to_sna_crtc(crtc) == NULL)
+		if (to_sna_crtc(crtc) == NULL)
+			break;
+
+		if (!crtc->enabled)
 			continue;
 
 		if (!sna_crtc_set_mode_major(crtc,
@@ -3232,7 +3243,7 @@ sna_show_cursors(ScrnInfoPtr scrn)
 		struct sna_cursor *cursor;
 
 		if (!sna_crtc)
-			continue;
+			break;
 
 		if (!crtc->enabled)
 			continue;
@@ -3299,7 +3310,7 @@ sna_hide_cursors(ScrnInfoPtr scrn)
 		struct drm_mode_cursor arg;
 
 		if (!sna_crtc)
-			continue;
+			break;
 
 		if (!crtc->enabled)
 			continue;
@@ -3350,7 +3361,7 @@ sna_set_cursor_position(ScrnInfoPtr scrn, int x, int y)
 		struct drm_mode_cursor arg;
 
 		if (!sna_crtc)
-			continue;
+			break;
 
 		VG_CLEAR(arg);
 		arg.flags = 0;
@@ -3730,6 +3741,8 @@ static void crtc_init_gamma(xf86CrtcPtr crtc)
 		struct drm_mode_crtc_lut lut;
 		bool gamma_set = false;
 
+		assert(sna_crtc);
+
 		lut.crtc_id = sna_crtc->id;
 		lut.gamma_size = 256;
 		lut.red = (uintptr_t)(gamma);
@@ -3828,7 +3841,7 @@ static bool sna_probe_initial_configuration(struct sna *sna)
 		struct drm_mode_crtc mode;
 
 		if (sna_crtc == NULL)
-			continue;
+			break;
 
 		crtc->enabled = FALSE;
 		crtc->desiredMode.status = MODE_NOMODE;
@@ -3877,8 +3890,10 @@ static bool sna_probe_initial_configuration(struct sna *sna)
 		for (j = 0; j < config->num_crtc; j++) {
 			xf86CrtcPtr crtc = config->crtc[j];
 
-			if (to_sna_crtc(crtc) == NULL ||
-			    to_sna_crtc(crtc)->id != crtc_id)
+			if (to_sna_crtc(crtc) == NULL)
+				break;
+
+			if (to_sna_crtc(crtc)->id != crtc_id)
 				continue;
 
 			if (crtc->desiredMode.status == MODE_OK) {
@@ -4069,7 +4084,7 @@ sna_mode_close(struct sna *sna)
 
 		crtc = to_sna_crtc(config->crtc[i]);
 		if (crtc == NULL)
-			continue;
+			break;
 
 		sna_crtc_disable_shadow(sna, crtc);
 	}
@@ -4137,7 +4152,7 @@ sna_covering_crtc(struct sna *sna, const BoxRec *box, xf86CrtcPtr desired)
 		int coverage;
 
 		if (to_sna_crtc(crtc) == NULL)
-			continue;
+			break;
 
 		/* If the CRTC is off, treat it as not covering */
 		if (to_sna_crtc(crtc)->bo == NULL) {
@@ -4538,7 +4553,7 @@ void sna_mode_update(struct sna *sna)
 		uint32_t expected;
 
 		if (sna_crtc == NULL)
-			continue;
+			break;
 
 #if XF86_CRTC_VERSION >= 3
 		assert(sna_crtc->bo == NULL || crtc->active);
@@ -4592,7 +4607,7 @@ void sna_mode_reset(struct sna *sna)
 	for (i = 0; i < config->num_crtc; i++) {
 		struct sna_crtc *sna_crtc = to_sna_crtc(config->crtc[i]);
 		if (sna_crtc == NULL)
-			continue;
+			break;
 
 		sna_crtc->dpms_mode = -1;
 
@@ -4825,6 +4840,7 @@ sna_crtc_redisplay(xf86CrtcPtr crtc, RegionPtr region)
 	struct sna_pixmap *priv = sna_pixmap(sna->front);
 	int16_t tx, ty;
 
+	assert(sna_crtc);
 	DBG(("%s: crtc %d [pipe=%d], damage (%d, %d), (%d, %d) x %ld\n",
 	     __FUNCTION__, sna_crtc->id, sna_crtc->pipe,
 	     region->extents.x1, region->extents.y1,
@@ -4941,7 +4957,10 @@ void sna_mode_redisplay(struct sna *sna)
 			struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
 			RegionRec damage;
 
-			if (sna_crtc == NULL || !sna_crtc->shadow)
+			if (sna_crtc == NULL)
+				break;
+
+			if (!sna_crtc->shadow)
 				continue;
 
 			assert(crtc->enabled);
@@ -4988,7 +5007,7 @@ void sna_mode_redisplay(struct sna *sna)
 		RegionRec damage;
 
 		if (sna_crtc == NULL)
-			continue;
+			break;
 
 		DBG(("%s: crtc[%d] shadow? %d, transformed? %d\n",
 		     __FUNCTION__, i,


More information about the xorg-commit mailing list