xf86-video-intel: 4 commits - src/common.h src/i810_driver.c src/i830_dri.c src/i830_uxa.c src/i965_render.c

Eric Anholt anholt at kemper.freedesktop.org
Thu Feb 25 10:43:11 PST 2010


 src/common.h      |   29 +++
 src/i810_driver.c |    2 
 src/i830_dri.c    |  449 ++++++++++++++++++++++++++++--------------------------
 src/i830_uxa.c    |   12 +
 src/i965_render.c |    6 
 5 files changed, 285 insertions(+), 213 deletions(-)

New commits:
commit 529bf185fbcb9f7705b315a5106054ee25c1c77f
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Feb 24 17:54:13 2010 -0800

    In frame event handling, track drawable id instead of drawable pointer.
    
    Windows aren't refcounted, so if the event came in after the window
    was destroyed, we'd dereference garbage and segfault.

diff --git a/src/i830_dri.c b/src/i830_dri.c
index 028f9fd..64aeb76 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -394,7 +394,7 @@ enum DRI2FrameEventType {
 };
 
 typedef struct _DRI2FrameEvent {
-	DrawablePtr pDraw;
+	XID drawable_id;
 	ClientPtr client;
 	enum DRI2FrameEventType type;
 	int frame;
@@ -472,7 +472,7 @@ I830DRI2ScheduleFlip(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
 	if (!flip_info)
 	    return FALSE;
 
-	flip_info->pDraw = draw;
+	flip_info->drawable_id = draw->id;
 	flip_info->client = client;
 	flip_info->type = DRI2_SWAP;
 	flip_info->event_complete = func;
@@ -505,17 +505,29 @@ void I830DRI2FrameEventHandler(unsigned int frame, unsigned int tv_sec,
 			       unsigned int tv_usec, void *event_data)
 {
 	DRI2FrameEventPtr event = event_data;
-	DrawablePtr pDraw = event->pDraw;
-	ScreenPtr screen = pDraw->pScreen;
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
-	intel_screen_private *intel = intel_get_screen_private(scrn);
+	DrawablePtr drawable;
+	ScreenPtr screen;
+	ScrnInfoPtr scrn;
+	intel_screen_private *intel;
+	int status;
+
+	status = dixLookupDrawable(&drawable, event->drawable_id, serverClient,
+				   M_ANY, DixWriteAccess);
+	if (status != Success) {
+		xfree(event);
+		return;
+	}
+
+	screen = drawable->pScreen;
+	scrn = xf86Screens[screen->myNum];
+	intel = intel_get_screen_private(scrn);
 
 	switch (event->type) {
 	case DRI2_FLIP:
 		/* If we can still flip... */
-		if (DRI2CanFlip(pDraw) && !intel->shadow_present &&
+		if (DRI2CanFlip(drawable) && !intel->shadow_present &&
 		    intel->use_pageflipping &&
-		    I830DRI2ScheduleFlip(event->client, pDraw, event->front,
+		    I830DRI2ScheduleFlip(event->client, drawable, event->front,
 					 event->back, event->event_complete,
 					 event->event_data)) {
 			break;
@@ -524,8 +536,8 @@ void I830DRI2FrameEventHandler(unsigned int frame, unsigned int tv_sec,
 	case DRI2_SWAP: {
 		int swap_type;
 
-		if (DRI2CanExchange(pDraw)) {
-			I830DRI2ExchangeBuffers(pDraw,
+		if (DRI2CanExchange(drawable)) {
+			I830DRI2ExchangeBuffers(drawable,
 						event->front, event->back);
 			swap_type = DRI2_EXCHANGE_COMPLETE;
 		} else {
@@ -534,21 +546,21 @@ void I830DRI2FrameEventHandler(unsigned int frame, unsigned int tv_sec,
 
 			box.x1 = 0;
 			box.y1 = 0;
-			box.x2 = pDraw->width;
-			box.y2 = pDraw->height;
+			box.x2 = drawable->width;
+			box.y2 = drawable->height;
 			REGION_INIT(pScreen, &region, &box, 0);
 
-			I830DRI2CopyRegion(pDraw,
+			I830DRI2CopyRegion(drawable,
 					   &region, event->front, event->back);
 			swap_type = DRI2_BLIT_COMPLETE;
 	}
-		DRI2SwapComplete(event->client, pDraw, frame, tv_sec, tv_usec,
+		DRI2SwapComplete(event->client, drawable, frame, tv_sec, tv_usec,
 				 swap_type,
 				 event->event_complete, event->event_data);
 		break;
 	}
 	case DRI2_WAITMSC:
-		DRI2WaitMSCComplete(event->client, pDraw,
+		DRI2WaitMSCComplete(event->client, drawable,
 				    frame, tv_sec, tv_usec);
 		break;
 	default:
@@ -565,14 +577,25 @@ void I830DRI2FlipEventHandler(unsigned int frame, unsigned int tv_sec,
 			      unsigned int tv_usec, void *event_data)
 {
 	DRI2FrameEventPtr flip = event_data;
-	DrawablePtr pDraw = flip->pDraw;
-	ScreenPtr screen = pDraw->pScreen;
-	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	DrawablePtr drawable;
+	ScreenPtr screen;
+	ScrnInfoPtr scrn;
+	int status;
+
+	status = dixLookupDrawable(&drawable, flip->drawable_id, serverClient,
+				     M_ANY, DixWriteAccess);
+	if (status != Success) {
+		xfree(flip);
+		return;
+	}
+
+	screen = drawable->pScreen;
+	scrn = xf86Screens[screen->myNum];
 
 	/* We assume our flips arrive in order, so we don't check the frame */
 	switch (flip->type) {
 	case DRI2_SWAP:
-		DRI2SwapComplete(flip->client, pDraw, frame, tv_sec, tv_usec,
+		DRI2SwapComplete(flip->client, drawable, frame, tv_sec, tv_usec,
 				 DRI2_FLIP_COMPLETE, flip->event_complete,
 				 flip->event_data);
 	break;
@@ -641,7 +664,7 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
 	    return TRUE;
 	}
 
-	swap_info->pDraw = draw;
+	swap_info->drawable_id = draw->id;
 	swap_info->client = client;
 	swap_info->event_complete = func;
 	swap_info->event_data = data;
@@ -817,7 +840,7 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc,
 		return TRUE;
 	}
 
-	wait_info->pDraw = draw;
+	wait_info->drawable_id = draw->id;
 	wait_info->client = client;
 	wait_info->type = DRI2_WAITMSC;
 
commit 633c7033170b0e9b468dbee444b94922f6c30940
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Feb 24 17:40:30 2010 -0800

    Fix up a bunch of inconsistent 4-space indentation in i830_dri.c

diff --git a/src/i830_dri.c b/src/i830_dri.c
index dbf7c66..028f9fd 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -75,8 +75,8 @@ extern XF86ModuleData dri2ModuleData;
 #endif
 
 typedef struct {
-    PixmapPtr pixmap;
-    unsigned int attachment;
+	PixmapPtr pixmap;
+	unsigned int attachment;
 } I830DRI2BufferPrivateRec, *I830DRI2BufferPrivatePtr;
 
 #ifndef USE_DRI2_1_1_0
@@ -388,45 +388,45 @@ I830DRI2CopyRegion(DrawablePtr drawable, RegionPtr pRegion,
 #if DRI2INFOREC_VERSION >= 4
 
 enum DRI2FrameEventType {
-    DRI2_SWAP,
-    DRI2_FLIP,
-    DRI2_WAITMSC,
+	DRI2_SWAP,
+	DRI2_FLIP,
+	DRI2_WAITMSC,
 };
 
 typedef struct _DRI2FrameEvent {
-    DrawablePtr		pDraw;
-    ClientPtr		client;
-    enum DRI2FrameEventType type;
-    int			frame;
-
-    /* for swaps & flips only */
-    DRI2SwapEventPtr	event_complete;
-    void		*event_data;
-    DRI2BufferPtr	front;
-    DRI2BufferPtr	back;
+	DrawablePtr pDraw;
+	ClientPtr client;
+	enum DRI2FrameEventType type;
+	int frame;
+
+	/* for swaps & flips only */
+	DRI2SwapEventPtr event_complete;
+	void *event_data;
+	DRI2BufferPtr front;
+	DRI2BufferPtr back;
 } DRI2FrameEventRec, *DRI2FrameEventPtr;
 
 static int
 I830DRI2DrawablePipe(DrawablePtr pDraw)
 {
-    ScreenPtr pScreen = pDraw->pScreen;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-    BoxRec box, crtcbox;
-    xf86CrtcPtr crtc;
-    int pipe = -1;
+	ScreenPtr pScreen = pDraw->pScreen;
+	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+	BoxRec box, crtcbox;
+	xf86CrtcPtr crtc;
+	int pipe = -1;
 
-    box.x1 = pDraw->x;
-    box.y1 = pDraw->y;
-    box.x2 = box.x1 + pDraw->width;
-    box.y2 = box.y1 + pDraw->height;
+	box.x1 = pDraw->x;
+	box.y1 = pDraw->y;
+	box.x2 = box.x1 + pDraw->width;
+	box.y2 = box.y1 + pDraw->height;
 
-    crtc = i830_covering_crtc(pScrn, &box, NULL, &crtcbox);
+	crtc = i830_covering_crtc(pScrn, &box, NULL, &crtcbox);
 
-    /* Make sure the CRTC is valid and this is the real front buffer */
-    if (crtc != NULL && !crtc->rotatedData)
-	pipe = i830_crtc_to_pipe(crtc);
+	/* Make sure the CRTC is valid and this is the real front buffer */
+	if (crtc != NULL && !crtc->rotatedData)
+		pipe = i830_crtc_to_pipe(crtc);
 
-    return pipe;
+	return pipe;
 }
 
 static void
@@ -504,82 +504,86 @@ I830DRI2ScheduleFlip(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
 void I830DRI2FrameEventHandler(unsigned int frame, unsigned int tv_sec,
 			       unsigned int tv_usec, void *event_data)
 {
-    DRI2FrameEventPtr event = event_data;
-    DrawablePtr pDraw = event->pDraw;
-    ScreenPtr screen = pDraw->pScreen;
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
-    intel_screen_private *intel = intel_get_screen_private(scrn);
-
-    switch (event->type) {
-    case DRI2_FLIP:
-	/* If we can still flip... */
-	if (DRI2CanFlip(pDraw) && !intel->shadow_present &&
-	    intel->use_pageflipping &&
-	    I830DRI2ScheduleFlip(event->client, pDraw, event->front,
-				 event->back, event->event_complete,
-				 event->event_data)) {
-	    break;
-	}
-	/* else fall through to exchange/blit */
-    case DRI2_SWAP: {
-	int swap_type;
-
-	if (DRI2CanExchange(pDraw)) {
-	    I830DRI2ExchangeBuffers(pDraw, event->front, event->back);
-	    swap_type = DRI2_EXCHANGE_COMPLETE;
-	} else {
-	    BoxRec	    box;
-	    RegionRec	    region;
-
-	    box.x1 = 0;
-	    box.y1 = 0;
-	    box.x2 = pDraw->width;
-	    box.y2 = pDraw->height;
-	    REGION_INIT(pScreen, &region, &box, 0);
+	DRI2FrameEventPtr event = event_data;
+	DrawablePtr pDraw = event->pDraw;
+	ScreenPtr screen = pDraw->pScreen;
+	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	intel_screen_private *intel = intel_get_screen_private(scrn);
 
-	    I830DRI2CopyRegion(pDraw, &region, event->front, event->back);
-	    swap_type = DRI2_BLIT_COMPLETE;
+	switch (event->type) {
+	case DRI2_FLIP:
+		/* If we can still flip... */
+		if (DRI2CanFlip(pDraw) && !intel->shadow_present &&
+		    intel->use_pageflipping &&
+		    I830DRI2ScheduleFlip(event->client, pDraw, event->front,
+					 event->back, event->event_complete,
+					 event->event_data)) {
+			break;
+		}
+		/* else fall through to exchange/blit */
+	case DRI2_SWAP: {
+		int swap_type;
+
+		if (DRI2CanExchange(pDraw)) {
+			I830DRI2ExchangeBuffers(pDraw,
+						event->front, event->back);
+			swap_type = DRI2_EXCHANGE_COMPLETE;
+		} else {
+			BoxRec	    box;
+			RegionRec	    region;
+
+			box.x1 = 0;
+			box.y1 = 0;
+			box.x2 = pDraw->width;
+			box.y2 = pDraw->height;
+			REGION_INIT(pScreen, &region, &box, 0);
+
+			I830DRI2CopyRegion(pDraw,
+					   &region, event->front, event->back);
+			swap_type = DRI2_BLIT_COMPLETE;
+	}
+		DRI2SwapComplete(event->client, pDraw, frame, tv_sec, tv_usec,
+				 swap_type,
+				 event->event_complete, event->event_data);
+		break;
+	}
+	case DRI2_WAITMSC:
+		DRI2WaitMSCComplete(event->client, pDraw,
+				    frame, tv_sec, tv_usec);
+		break;
+	default:
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "%s: unknown vblank event received\n", __func__);
+		/* Unknown type */
+		break;
 	}
-	DRI2SwapComplete(event->client, pDraw, frame, tv_sec, tv_usec,
-			 swap_type, event->event_complete, event->event_data);
-	break;
-    }
-    case DRI2_WAITMSC:
-	DRI2WaitMSCComplete(event->client, pDraw, frame, tv_sec, tv_usec);
-	break;
-    default:
-	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-		   "%s: unknown vblank event received\n", __func__);
-	/* Unknown type */
-	break;
-    }
 
-    xfree(event);
+	xfree(event);
 }
 
 void I830DRI2FlipEventHandler(unsigned int frame, unsigned int tv_sec,
 			      unsigned int tv_usec, void *event_data)
 {
-    DRI2FrameEventPtr flip = event_data;
-    DrawablePtr pDraw = flip->pDraw;
-    ScreenPtr screen = pDraw->pScreen;
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
-
-    /* We assume our flips arrive in order, so we don't check the frame */
-    switch (flip->type) {
-    case DRI2_SWAP:
-	DRI2SwapComplete(flip->client, pDraw, frame, tv_sec, tv_usec,
-			 DRI2_FLIP_COMPLETE, flip->event_complete,
-			 flip->event_data);
-	break;
-    default:
-	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-		   "%s: unknown vblank event received\n", __func__);
-	/* Unknown type */
+	DRI2FrameEventPtr flip = event_data;
+	DrawablePtr pDraw = flip->pDraw;
+	ScreenPtr screen = pDraw->pScreen;
+	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+
+	/* We assume our flips arrive in order, so we don't check the frame */
+	switch (flip->type) {
+	case DRI2_SWAP:
+		DRI2SwapComplete(flip->client, pDraw, frame, tv_sec, tv_usec,
+				 DRI2_FLIP_COMPLETE, flip->event_complete,
+				 flip->event_data);
 	break;
-    }
+	default:
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "%s: unknown vblank event received\n", __func__);
+		/* Unknown type */
+		break;
+	}
 
-    xfree(flip);
+	xfree(flip);
 }
 
 /*
@@ -698,22 +702,22 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
 	 * so we queue an event that will satisfy the divisor/remainderequation.
 	 */
 	if ((vbl.reply.sequence % divisor) == remainder) {
-	    BoxRec	    box;
-	    RegionRec	    region;
+		BoxRec box;
+		RegionRec region;
 
-	    box.x1 = 0;
-	    box.y1 = 0;
-	    box.x2 = draw->width;
-	    box.y2 = draw->height;
-	    REGION_INIT(pScreen, &region, &box, 0);
+		box.x1 = 0;
+		box.y1 = 0;
+		box.x2 = draw->width;
+		box.y2 = draw->height;
+		REGION_INIT(pScreen, &region, &box, 0);
 
-	    I830DRI2CopyRegion(draw, &region, front, back);
+		I830DRI2CopyRegion(draw, &region, front, back);
 
-	    DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func,
-			     data);
-	    if (swap_info)
-		xfree(swap_info);
-	    return TRUE;
+		DRI2SwapComplete(client, draw, 0, 0, 0,
+				 DRI2_BLIT_COMPLETE, func, data);
+		if (swap_info)
+			xfree(swap_info);
+		return TRUE;
 	}
 
 	vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT;
@@ -753,35 +757,35 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
 static int
 I830DRI2GetMSC(DrawablePtr draw, CARD64 *ust, CARD64 *msc)
 {
-    ScreenPtr screen = draw->pScreen;
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
-    intel_screen_private *intel = intel_get_screen_private(scrn);
-    drmVBlank vbl;
-    int ret, pipe = I830DRI2DrawablePipe(draw);
-
-    /* Drawable not displayed, make up a value */
-    if (pipe == -1) {
-	*ust = 0;
-	*msc = 0;
-	return TRUE;
-    }
+	ScreenPtr screen = draw->pScreen;
+	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	drmVBlank vbl;
+	int ret, pipe = I830DRI2DrawablePipe(draw);
 
-    vbl.request.type = DRM_VBLANK_RELATIVE;
-    if (pipe > 0)
-	vbl.request.type |= DRM_VBLANK_SECONDARY;
-    vbl.request.sequence = 0;
+	/* Drawable not displayed, make up a value */
+	if (pipe == -1) {
+		*ust = 0;
+		*msc = 0;
+		return TRUE;
+	}
+
+	vbl.request.type = DRM_VBLANK_RELATIVE;
+	if (pipe > 0)
+		vbl.request.type |= DRM_VBLANK_SECONDARY;
+	vbl.request.sequence = 0;
 
-    ret = drmWaitVBlank(intel->drmSubFD, &vbl);
-    if (ret) {
-	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-		   "get vblank counter failed: %s\n", strerror(errno));
-	return FALSE;
-    }
+	ret = drmWaitVBlank(intel->drmSubFD, &vbl);
+	if (ret) {
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "get vblank counter failed: %s\n", strerror(errno));
+		return FALSE;
+	}
 
-    *ust = ((CARD64)vbl.reply.tval_sec * 1000000) + vbl.reply.tval_usec;
-    *msc = vbl.reply.sequence;
+	*ust = ((CARD64)vbl.reply.tval_sec * 1000000) + vbl.reply.tval_usec;
+	*msc = vbl.reply.sequence;
 
-    return TRUE;
+	return TRUE;
 }
 
 /*
@@ -794,93 +798,93 @@ static int
 I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc,
 			CARD64 divisor, CARD64 remainder)
 {
-    ScreenPtr screen = draw->pScreen;
-    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
-    intel_screen_private *intel = intel_get_screen_private(scrn);
-    DRI2FrameEventPtr wait_info;
-    drmVBlank vbl;
-    int ret, pipe = I830DRI2DrawablePipe(draw);
-
-    /* Drawable not visible, return immediately */
-    if (pipe == -1) {
-	DRI2WaitMSCComplete(client, draw, target_msc, 0, 0);
-	return TRUE;
-    }
+	ScreenPtr screen = draw->pScreen;
+	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	DRI2FrameEventPtr wait_info;
+	drmVBlank vbl;
+	int ret, pipe = I830DRI2DrawablePipe(draw);
 
-    wait_info = xcalloc(1, sizeof(DRI2FrameEventRec));
-    if (!wait_info) {
-	DRI2WaitMSCComplete(client, draw, 0, 0, 0);
-	return TRUE;
-    }
-
-    wait_info->pDraw = draw;
-    wait_info->client = client;
-    wait_info->type = DRI2_WAITMSC;
-
-    /* Get current count */
-    vbl.request.type = DRM_VBLANK_RELATIVE;
-    if (pipe > 0)
-	vbl.request.type |= DRM_VBLANK_SECONDARY;
-    vbl.request.sequence = 0;
-    ret = drmWaitVBlank(intel->drmSubFD, &vbl);
-    if (ret) {
-	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-		   "get vblank counter failed: %s\n", strerror(errno));
-	return FALSE;
-    }
-
-    /*
-     * If divisor is zero, we just need to make sure target_msc passes
-     * before waking up the client.
-     */
-    if (divisor == 0) {
+	/* Drawable not visible, return immediately */
+	if (pipe == -1) {
+		DRI2WaitMSCComplete(client, draw, target_msc, 0, 0);
+		return TRUE;
+	}
+
+	wait_info = xcalloc(1, sizeof(DRI2FrameEventRec));
+	if (!wait_info) {
+		DRI2WaitMSCComplete(client, draw, 0, 0, 0);
+		return TRUE;
+	}
+
+	wait_info->pDraw = draw;
+	wait_info->client = client;
+	wait_info->type = DRI2_WAITMSC;
+
+	/* Get current count */
+	vbl.request.type = DRM_VBLANK_RELATIVE;
+	if (pipe > 0)
+		vbl.request.type |= DRM_VBLANK_SECONDARY;
+	vbl.request.sequence = 0;
+	ret = drmWaitVBlank(intel->drmSubFD, &vbl);
+	if (ret) {
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "get vblank counter failed: %s\n", strerror(errno));
+		return FALSE;
+	}
+
+	/*
+	 * If divisor is zero, we just need to make sure target_msc passes
+	 * before waking up the client.
+	 */
+	if (divisor == 0) {
+		vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT;
+		if (pipe > 0)
+			vbl.request.type |= DRM_VBLANK_SECONDARY;
+		vbl.request.sequence = target_msc;
+		vbl.request.signal = (unsigned long)wait_info;
+		ret = drmWaitVBlank(intel->drmSubFD, &vbl);
+		if (ret) {
+			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+				   "get vblank counter failed: %s\n", strerror(errno));
+			return FALSE;
+		}
+
+		wait_info->frame = vbl.reply.sequence;
+		DRI2BlockClient(client, draw);
+		return TRUE;
+	}
+
+	/*
+	 * If we get here, target_msc has already passed or we don't have one,
+	 * so we queue an event that will satisfy the divisor/remainder equation.
+	 */
 	vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT;
 	if (pipe > 0)
-	    vbl.request.type |= DRM_VBLANK_SECONDARY;
-	vbl.request.sequence = target_msc;
+		vbl.request.type |= DRM_VBLANK_SECONDARY;
+
+	/*
+	 * If we have no remainder and the condition isn't satisified, it means
+	 * we've passed the last point where seq % divisor == remainder, so we need
+	 * to wait for the next time that will happen.
+	 */
+	if (((vbl.reply.sequence % divisor) != remainder) && !remainder)
+		vbl.request.sequence += divisor;
+
+	vbl.request.sequence = vbl.reply.sequence - (vbl.reply.sequence % divisor) +
+		remainder;
 	vbl.request.signal = (unsigned long)wait_info;
 	ret = drmWaitVBlank(intel->drmSubFD, &vbl);
 	if (ret) {
-	    xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-		       "get vblank counter failed: %s\n", strerror(errno));
-	    return FALSE;
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "get vblank counter failed: %s\n", strerror(errno));
+		return FALSE;
 	}
 
 	wait_info->frame = vbl.reply.sequence;
 	DRI2BlockClient(client, draw);
+
 	return TRUE;
-    }
-
-    /*
-     * If we get here, target_msc has already passed or we don't have one,
-     * so we queue an event that will satisfy the divisor/remainder equation.
-     */
-    vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT;
-    if (pipe > 0)
-	vbl.request.type |= DRM_VBLANK_SECONDARY;
-
-    /*
-     * If we have no remainder and the condition isn't satisified, it means
-     * we've passed the last point where seq % divisor == remainder, so we need
-     * to wait for the next time that will happen.
-     */
-    if (((vbl.reply.sequence % divisor) != remainder) && !remainder)
-	vbl.request.sequence += divisor;
-
-    vbl.request.sequence = vbl.reply.sequence - (vbl.reply.sequence % divisor) +
-	remainder;
-    vbl.request.signal = (unsigned long)wait_info;
-    ret = drmWaitVBlank(intel->drmSubFD, &vbl);
-    if (ret) {
-	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-		   "get vblank counter failed: %s\n", strerror(errno));
-	return FALSE;
-    }
-
-    wait_info->frame = vbl.reply.sequence;
-    DRI2BlockClient(client, draw);
-
-    return TRUE;
 }
 #endif
 
commit 9291828a569a01ed4a6ef71f530b93f8a54c84aa
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Jan 15 12:51:50 2010 -0800

    Add new mobile Sandybridge PCI IDs.

diff --git a/src/common.h b/src/common.h
index fc51cde..bc5d722 100644
--- a/src/common.h
+++ b/src/common.h
@@ -328,6 +328,8 @@ extern int I810_DEBUG;
 #ifndef PCI_CHIP_SANDYBRIDGE
 #define PCI_CHIP_SANDYBRIDGE		0x0102
 #define PCI_CHIP_SANDYBRIDGE_BRIDGE	0x0100
+#define PCI_CHIP_SANDYBRIDGE_M		0x0106
+#define PCI_CHIP_SANDYBRIDGE_BRIDGE_M	0x0104
 #endif
 
 #define I810_MEMBASE(p,n) (p)->regions[(n)].base_addr
@@ -385,7 +387,8 @@ extern int I810_DEBUG;
 
 #define IS_I915(pI810) (IS_I915G(pI810) || IS_I915GM(pI810) || IS_I945G(pI810) || IS_I945GM(pI810) || IS_G33CLASS(pI810))
 
-#define IS_GEN6(pI810) ((pI810)->PciInfo->device_id == PCI_CHIP_SANDYBRIDGE)
+#define IS_GEN6(pI810) ((pI810)->PciInfo->device_id == PCI_CHIP_SANDYBRIDGE || \
+			(pI810)->PciInfo->device_id == PCI_CHIP_SANDYBRIDGE_M)
 
 #define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810) || IS_I915GM(pI810) || IS_I945GM(pI810) || IS_I965GM(pI810) || IS_GM45(pI810) || IS_IGD(pI810) || IS_IGDNG_M(pI810))
 /* supports Y tiled surfaces (pre-965 Mesa isn't ready yet) */
diff --git a/src/i810_driver.c b/src/i810_driver.c
index ba1ded7..3109834 100644
--- a/src/i810_driver.c
+++ b/src/i810_driver.c
@@ -141,6 +141,7 @@ static const struct pci_id_match intel_device_match[] = {
    INTEL_DEVICE_MATCH (PCI_CHIP_IGDNG_D_G, 0 ),
    INTEL_DEVICE_MATCH (PCI_CHIP_IGDNG_M_G, 0 ),
    INTEL_DEVICE_MATCH (PCI_CHIP_SANDYBRIDGE, 0 ),
+   INTEL_DEVICE_MATCH (PCI_CHIP_SANDYBRIDGE_M, 0 ),
     { 0, 0, 0 },
 };
 
commit 3c71f98b9e5262675e61fafb317d0c35e62a873f
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Oct 22 16:55:02 2009 -0700

    Add initial defines and probing for Sandybridge

diff --git a/src/common.h b/src/common.h
index 3169cdf..fc51cde 100644
--- a/src/common.h
+++ b/src/common.h
@@ -325,6 +325,11 @@ extern int I810_DEBUG;
 #define PCI_CHIP_IGDNG_M_G_BRIDGE	0x0044
 #endif
 
+#ifndef PCI_CHIP_SANDYBRIDGE
+#define PCI_CHIP_SANDYBRIDGE		0x0102
+#define PCI_CHIP_SANDYBRIDGE_BRIDGE	0x0100
+#endif
+
 #define I810_MEMBASE(p,n) (p)->regions[(n)].base_addr
 #define VENDOR_ID(p)      (p)->vendor_id
 #define DEVICE_ID(p)      (p)->device_id
@@ -357,14 +362,31 @@ extern int I810_DEBUG;
 #define IS_IGDNG_D(pI810) (DEVICE_ID(pI810->PciInfo) == PCI_CHIP_IGDNG_D_G)
 #define IS_IGDNG_M(pI810) (DEVICE_ID(pI810->PciInfo) == PCI_CHIP_IGDNG_M_G)
 #define IS_IGDNG(pI810) (IS_IGDNG_D(pI810) || IS_IGDNG_M(pI810))
-#define IS_I965G(pI810) (DEVICE_ID(pI810->PciInfo) == PCI_CHIP_I965_G || DEVICE_ID(pI810->PciInfo) == PCI_CHIP_G35_G || DEVICE_ID(pI810->PciInfo) == PCI_CHIP_I965_Q || DEVICE_ID(pI810->PciInfo) == PCI_CHIP_I946_GZ || DEVICE_ID(pI810->PciInfo) == PCI_CHIP_I965_GM || DEVICE_ID(pI810->PciInfo) == PCI_CHIP_I965_GME || IS_G4X(pI810) || IS_IGDNG(pI810))
+#define IS_I965G(pI810) (DEVICE_ID(pI810->PciInfo) == PCI_CHIP_I965_G || \
+			 DEVICE_ID(pI810->PciInfo) == PCI_CHIP_G35_G || \
+			 DEVICE_ID(pI810->PciInfo) == PCI_CHIP_I965_Q || \
+			 DEVICE_ID(pI810->PciInfo) == PCI_CHIP_I946_GZ || \
+			 DEVICE_ID(pI810->PciInfo) == PCI_CHIP_I965_GM || \
+			 DEVICE_ID(pI810->PciInfo) == PCI_CHIP_I965_GME || \
+			 IS_G4X(pI810) || \
+			 IS_IGDNG(pI810) || \
+			 IS_GEN6(pI810))
 #define IS_G33CLASS(pI810) (DEVICE_ID(pI810->PciInfo) == PCI_CHIP_G33_G ||\
  			    DEVICE_ID(pI810->PciInfo) == PCI_CHIP_Q35_G ||\
 			    DEVICE_ID(pI810->PciInfo) == PCI_CHIP_Q33_G || \
 			    IS_IGD(pI810))
-#define IS_I9XX(pI810) (IS_I915G(pI810) || IS_I915GM(pI810) || IS_I945G(pI810) || IS_I945GM(pI810) || IS_I965G(pI810) || IS_G33CLASS(pI810))
+
+#define IS_I9XX(pI810) (IS_I915G(pI810) ||			\
+			IS_I915GM(pI810) ||			\
+			IS_I945G(pI810) ||			\
+			IS_I945GM(pI810) ||			\
+			IS_I965G(pI810) ||			\
+			IS_G33CLASS(pI810))
+
 #define IS_I915(pI810) (IS_I915G(pI810) || IS_I915GM(pI810) || IS_I945G(pI810) || IS_I945GM(pI810) || IS_G33CLASS(pI810))
 
+#define IS_GEN6(pI810) ((pI810)->PciInfo->device_id == PCI_CHIP_SANDYBRIDGE)
+
 #define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810) || IS_I915GM(pI810) || IS_I945GM(pI810) || IS_I965GM(pI810) || IS_GM45(pI810) || IS_IGD(pI810) || IS_IGDNG_M(pI810))
 /* supports Y tiled surfaces (pre-965 Mesa isn't ready yet) */
 #define SUPPORTS_YTILING(pI810) (IS_I965G(intel))
diff --git a/src/i810_driver.c b/src/i810_driver.c
index 3bec092..ba1ded7 100644
--- a/src/i810_driver.c
+++ b/src/i810_driver.c
@@ -140,6 +140,7 @@ static const struct pci_id_match intel_device_match[] = {
    INTEL_DEVICE_MATCH (PCI_CHIP_B43_G, 0 ),
    INTEL_DEVICE_MATCH (PCI_CHIP_IGDNG_D_G, 0 ),
    INTEL_DEVICE_MATCH (PCI_CHIP_IGDNG_M_G, 0 ),
+   INTEL_DEVICE_MATCH (PCI_CHIP_SANDYBRIDGE, 0 ),
     { 0, 0, 0 },
 };
 
diff --git a/src/i830_uxa.c b/src/i830_uxa.c
index f489f4f..50835db 100644
--- a/src/i830_uxa.c
+++ b/src/i830_uxa.c
@@ -194,6 +194,12 @@ i830_uxa_prepare_solid(PixmapPtr pixmap, int alu, Pixel planemask, Pixel fg)
 		i830_get_pixmap_bo(pixmap),
 	};
 
+	if (IS_GEN6(intel)) {
+		intel_debug_fallback(scrn,
+				     "Sandybridge BLT engine not supported\n");
+		return FALSE;
+	}
+
 	if (!UXA_PM_IS_SOLID(&pixmap->drawable, planemask)) {
 		intel_debug_fallback(scrn, "planemask is not solid\n");
 		return FALSE;
@@ -296,6 +302,12 @@ i830_uxa_prepare_copy(PixmapPtr source, PixmapPtr dest, int xdir,
 		i830_get_pixmap_bo(dest),
 	};
 
+	if (IS_GEN6(intel)) {
+		intel_debug_fallback(scrn,
+				     "Sandybridge BLT engine not supported\n");
+		return FALSE;
+	}
+
 	if (!UXA_PM_IS_SOLID(&source->drawable, planemask)) {
 		intel_debug_fallback(scrn, "planemask is not solid");
 		return FALSE;
diff --git a/src/i965_render.c b/src/i965_render.c
index 7866dd7..3623549 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -236,8 +236,14 @@ i965_check_composite(int op, PicturePtr source_picture, PicturePtr mask_picture,
 		     PicturePtr dest_picture)
 {
 	ScrnInfoPtr scrn = xf86Screens[dest_picture->pDrawable->pScreen->myNum];
+	intel_screen_private *intel = intel_get_screen_private(scrn);
 	uint32_t tmp1;
 
+	if (IS_GEN6(intel)) {
+		intel_debug_fallback(scrn, "Unsupported hardware\n");
+		return FALSE;
+	}
+
 	/* Check for unsupported compositing operations. */
 	if (op >= sizeof(i965_blend_op) / sizeof(i965_blend_op[0])) {
 		intel_debug_fallback(scrn,


More information about the xorg-commit mailing list