[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-nouveau: Changes to 'debian-experimental'



 ChangeLog             |   89 +++++++++++++++++++++++++++++
 configure.ac          |    2 
 debian/changelog      |    4 -
 src/drmmode_display.c |    4 +
 src/nouveau_dri2.c    |  150 ++++++++++++++++++++++++++++++++++++++------------
 src/nouveau_exa.c     |   45 +++++++++++++++
 src/nouveau_local.h   |    1 
 src/nv50_exa.c        |    3 -
 src/nv_driver.c       |  127 +++++++++++++++++++++++++++++++++++++++++-
 src/nv_include.h      |    6 +-
 src/nv_proto.h        |    1 
 src/nv_type.h         |    6 +-
 src/nvc0_accel.c      |   59 ++++++++++++++++++-
 src/nvc0_accel.h      |    1 
 src/nvc0_exa.c        |    3 -
 src/nvc0_xv.c         |    4 -
 16 files changed, 450 insertions(+), 55 deletions(-)

New commits:
commit 6be7f6c22567141e1b09cefd2740a0cb11228f12
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Wed Sep 12 15:12:15 2012 +0200

    New upstream release.

diff --git a/ChangeLog b/ChangeLog
index 54ad2a3..be9cb72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,92 @@
+commit 20f3830ddf868c0d1a46c18fa381585c076bfb8d
+Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
+Date:   Wed Sep 12 13:42:43 2012 +0200
+
+    bump version to 1.0.2
+
+commit 239f39977ebb64c9d545c6f3c905de3c0ad840d0
+Author: Dave Airlie <airlied@redhat.com>
+Date:   Thu Jul 19 13:46:44 2012 +1000
+
+    nouveau: enable provider/capabilities
+    
+    this adds the provider object for nouveau and enables the capabilities
+    on it.
+    
+    Signed-off-by: Dave Airlie <airlied@redhat.com>
+
+commit 28abba276e36fd0176f416996d44297ddf13f5cd
+Author: Dave Airlie <airlied@redhat.com>
+Date:   Thu Jul 19 13:46:12 2012 +1000
+
+    nouveau/dri2: add support for DRI2 offload
+    
+    This adds the nouveau interfaces for DRI2 offload, this allows nouveau
+    to act as an offload slave.
+    
+    Signed-off-by: Dave Airlie <airlied@redhat.com>
+
+commit b0be0ac86bae871c9f1724c40298d50d7f2b08e4
+Author: Dave Airlie <airlied@redhat.com>
+Date:   Thu Jul 19 13:45:32 2012 +1000
+
+    nouveau: add pixmap tracking/updating support.
+    
+    This should allow nouveau to act as an output master for driving output
+    slaves.
+    
+    Signed-off-by: Dave Airlie <airlied@redhat.com>
+
+commit baf485b1d304d741073f058d524ca698af3c15cd
+Author: Dave Airlie <airlied@redhat.com>
+Date:   Thu Jul 19 13:42:13 2012 +1000
+
+    nouveau/exa: add support for shared pixmaps.
+    
+    This adds the pixmap export/import hooks, along with code for nv50/nvc0
+    to validate shared buffers in GTT space.
+    
+    Signed-off-by: Dave Airlie <airlied@redhat.com>
+
+commit 2f48b8f462a03cb92db9e9a7ae1957eb27473965
+Author: Dave Airlie <airlied@redhat.com>
+Date:   Thu Jul 19 13:40:23 2012 +1000
+
+    nouveau: add platform bus support
+    
+    This adds the ability to load nouveau via the new platform apis.
+    
+    Signed-off-by: Dave Airlie <airlied@redhat.com>
+
+commit 3aa9a296f508089a247f92b829036ca6a55b7b42
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Wed Aug 15 13:26:51 2012 -0400
+
+    Remove vbe and int10 includes
+    
+    This driver has never used int10 or vbe, presumably these were just
+    copypasta from nv.
+    
+    Signed-off-by: Adam Jackson <ajax@redhat.com>
+
+commit 9b9be11e99930136a591059db1bf4ceaca8806e7
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Thu Jul 19 18:22:44 2012 -0400
+
+    Implement ->driverFunc
+    
+    Copied from fbdev, makes it so we can run without iopl.
+    
+    Signed-off-by: Adam Jackson <ajax@redhat.com>
+
+commit 6629066b87142cdd1d9e881b61ef55c97aedf949
+Author: Ben Skeggs <bskeggs@redhat.com>
+Date:   Fri Aug 3 17:05:33 2012 +1000
+
+    nvc0/nve0: support sync-to-vblank if kernel is new enough
+    
+    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
+
 commit d1bc38b6673c54af61196056c489383fba8dced8
 Author: Ben Skeggs <bskeggs@redhat.com>
 Date:   Fri Jul 6 16:23:50 2012 +1000
diff --git a/debian/changelog b/debian/changelog
index 92692f3..7e8404c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,7 +1,7 @@
-xserver-xorg-video-nouveau (1:1.0.1-4) UNRELEASED; urgency=low
+xserver-xorg-video-nouveau (1:1.0.2-1) UNRELEASED; urgency=low
 
   [ Maarten Lankhorst ]
-  * Rebuild for x server 1.13rc1
+  * New upstream release.
   * Drop 02-drm-nouveau-newabi.patch and require libdrm 2.4.34
 
  -- Maarten Lankhorst <maarten.lankhorst@canonical.com>  Mon, 16 Jul 2012 15:22:19 +0200

commit 20f3830ddf868c0d1a46c18fa381585c076bfb8d
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Wed Sep 12 13:42:43 2012 +0200

    bump version to 1.0.2

diff --git a/configure.ac b/configure.ac
index af126fb..4861608 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-nouveau],
-        [1.0.1],
+        [1.0.2],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-video-nouveau])
 

commit 239f39977ebb64c9d545c6f3c905de3c0ad840d0
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu Jul 19 13:46:44 2012 +1000

    nouveau: enable provider/capabilities
    
    this adds the provider object for nouveau and enables the capabilities
    on it.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 62838fa..803785d 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1199,6 +1199,10 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp)
 	for (i = 0; i < drmmode->mode_res->count_connectors; i++)
 		drmmode_output_init(pScrn, drmmode, i);
 
+#ifdef NOUVEAU_PIXMAP_SHARING
+	xf86ProviderSetup(pScrn, NULL, "nouveau");
+#endif
+
 	xf86InitialConfiguration(pScrn, TRUE);
 
 	return TRUE;
diff --git a/src/nv_driver.c b/src/nv_driver.c
index a02cef3..271f641 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -643,6 +643,25 @@ NVDRIGetVersion(ScrnInfoPtr pScrn)
 	return TRUE;
 }
 
+static void
+nouveau_setup_capabilities(ScrnInfoPtr pScrn)
+{
+#ifdef NOUVEAU_PIXMAP_SHARING
+	NVPtr pNv = NVPTR(pScrn);
+	uint64_t value;
+	int ret;
+
+	pScrn->capabilities = 0;
+	ret = drmGetCap(pNv->dev->fd, DRM_CAP_PRIME, &value);
+	if (ret == 0) {
+		if (value & DRM_PRIME_CAP_EXPORT)
+			pScrn->capabilities |= RR_Capability_SourceOutput;
+		if (value & DRM_PRIME_CAP_IMPORT)
+			pScrn->capabilities |= RR_Capability_SourceOffload;
+	}
+#endif
+}
+
 static Bool
 NVPreInitDRM(ScrnInfoPtr pScrn)
 {
@@ -751,6 +770,8 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
 		NVPreInitFail("\n");
 	dev = pNv->dev;
 
+	nouveau_setup_capabilities(pScrn);
+
 	pScrn->chipset = malloc(sizeof(char) * 25);
 	sprintf(pScrn->chipset, "NVIDIA NV%02x", dev->chipset);
 	xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Chipset: \"%s\"\n", pScrn->chipset);

commit 28abba276e36fd0176f416996d44297ddf13f5cd
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu Jul 19 13:46:12 2012 +1000

    nouveau/dri2: add support for DRI2 offload
    
    This adds the nouveau interfaces for DRI2 offload, this allows nouveau
    to act as an offload slave.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/nouveau_dri2.c b/src/nouveau_dri2.c
index 62333b1..71cff26 100644
--- a/src/nouveau_dri2.c
+++ b/src/nouveau_dri2.c
@@ -21,34 +21,40 @@ nouveau_dri2_buffer(DRI2BufferPtr buf)
 	return (struct nouveau_dri2_buffer *)buf;
 }
 
+static PixmapPtr get_drawable_pixmap(DrawablePtr drawable)
+{
+	if (drawable->type == DRAWABLE_PIXMAP)
+		return (PixmapPtr)drawable;
+	else
+		return (*drawable->pScreen->GetWindowPixmap)((WindowPtr)drawable);
+}
+
 DRI2BufferPtr
-nouveau_dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment,
+nouveau_dri2_create_buffer2(ScreenPtr pScreen, DrawablePtr pDraw, unsigned int attachment,
 			   unsigned int format)
 {
-	ScreenPtr pScreen = pDraw->pScreen;
 	NVPtr pNv = NVPTR(xf86ScreenToScrn(pScreen));
 	struct nouveau_dri2_buffer *nvbuf;
 	struct nouveau_pixmap *nvpix;
-	PixmapPtr ppix;
+	PixmapPtr ppix = NULL;
 
 	nvbuf = calloc(1, sizeof(*nvbuf));
 	if (!nvbuf)
 		return NULL;
 
 	if (attachment == DRI2BufferFrontLeft) {
-		if (pDraw->type == DRAWABLE_PIXMAP) {
-			ppix = (PixmapPtr)pDraw;
-		} else {
-			WindowPtr pwin = (WindowPtr)pDraw;
-			ppix = pScreen->GetWindowPixmap(pwin);
+		ppix = get_drawable_pixmap(pDraw);
+		if (pScreen != ppix->drawable.pScreen)
+			ppix = NULL;
 
+		if (pDraw->type == DRAWABLE_WINDOW) {
 #if DRI2INFOREC_VERSION >= 6
 			/* Set initial swap limit on drawable. */
 			DRI2SwapLimit(pDraw, pNv->swap_limit);
 #endif
 		}
-
-		ppix->refcnt++;
+		if (ppix)
+			ppix->refcnt++;
 	} else {
 		int bpp;
 		unsigned int usage_hint = NOUVEAU_CREATE_PIXMAP_TILED;
@@ -67,31 +73,43 @@ nouveau_dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment,
 					     usage_hint);
 	}
 
-	pNv->exa_force_cp = TRUE;
-	exaMoveInPixmap(ppix);
-	pNv->exa_force_cp = FALSE;
+	if (ppix) {
+		pNv->exa_force_cp = TRUE;
+		exaMoveInPixmap(ppix);
+		pNv->exa_force_cp = FALSE;
+
+		nvbuf->base.pitch = ppix->devKind;
+		nvbuf->base.cpp = ppix->drawable.bitsPerPixel / 8;
+	}
 
 	nvbuf->base.attachment = attachment;
-	nvbuf->base.pitch = ppix->devKind;
-	nvbuf->base.cpp = ppix->drawable.bitsPerPixel / 8;
 	nvbuf->base.driverPrivate = nvbuf;
 	nvbuf->base.format = format;
 	nvbuf->base.flags = 0;
 	nvbuf->ppix = ppix;
 
-	nvpix = nouveau_pixmap(ppix);
-	if (!nvpix || !nvpix->bo ||
-	    nouveau_bo_name_get(nvpix->bo, &nvbuf->base.name)) {
-		pScreen->DestroyPixmap(nvbuf->ppix);
-		free(nvbuf);
-		return NULL;
+	if (ppix) {
+		nvpix = nouveau_pixmap(ppix);
+		if (!nvpix || !nvpix->bo ||
+		    nouveau_bo_name_get(nvpix->bo, &nvbuf->base.name)) {
+			pScreen->DestroyPixmap(nvbuf->ppix);
+			free(nvbuf);
+			return NULL;
+		}
 	}
-
 	return &nvbuf->base;
 }
 
+DRI2BufferPtr
+nouveau_dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment,
+			   unsigned int format)
+{
+	return nouveau_dri2_create_buffer2(pDraw->pScreen, pDraw,
+					   attachment, format);
+}
+
 void
-nouveau_dri2_destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buf)
+nouveau_dri2_destroy_buffer2(ScreenPtr pScreen, DrawablePtr pDraw, DRI2BufferPtr buf)
 {
 	struct nouveau_dri2_buffer *nvbuf;
 
@@ -99,38 +117,82 @@ nouveau_dri2_destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buf)
 	if (!nvbuf)
 		return;
 
-	pDraw->pScreen->DestroyPixmap(nvbuf->ppix);
+	if (nvbuf->ppix)
+	    pScreen->DestroyPixmap(nvbuf->ppix);
 	free(nvbuf);
 }
 
 void
-nouveau_dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
+nouveau_dri2_destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buf)
+{
+	nouveau_dri2_destroy_buffer2(pDraw->pScreen, pDraw, buf);
+}
+
+void
+nouveau_dri2_copy_region2(ScreenPtr pScreen, DrawablePtr pDraw, RegionPtr pRegion,
 			 DRI2BufferPtr pDstBuffer, DRI2BufferPtr pSrcBuffer)
 {
 	struct nouveau_dri2_buffer *src = nouveau_dri2_buffer(pSrcBuffer);
 	struct nouveau_dri2_buffer *dst = nouveau_dri2_buffer(pDstBuffer);
-	PixmapPtr pspix = src->ppix, pdpix = dst->ppix;
-	ScreenPtr pScreen = pDraw->pScreen;
 	RegionPtr pCopyClip;
 	GCPtr pGC;
-
+	DrawablePtr src_draw, dst_draw;
+	Bool translate = FALSE;
+	int off_x = 0, off_y = 0;
+
+	src_draw = &src->ppix->drawable;
+	dst_draw = &dst->ppix->drawable;
+#if 0
+	ErrorF("attachments src %d, dst %d, drawable %p %p pDraw %p\n",
+	       src->base.attachment, dst->base.attachment,
+	       src_draw, dst_draw, pDraw);
+#endif
 	if (src->base.attachment == DRI2BufferFrontLeft)
-		pspix = (PixmapPtr)pDraw;
-	if (dst->base.attachment == DRI2BufferFrontLeft)
-		pdpix = (PixmapPtr)pDraw;
+		src_draw = pDraw;
+	if (dst->base.attachment == DRI2BufferFrontLeft) {
+#ifdef NOUVEAU_PIXMAP_SHARING
+		if (pDraw->pScreen != pScreen) {
+			dst_draw = DRI2UpdatePrime(pDraw, pDstBuffer);
+			if (!dst_draw)
+				return;
+		} 
+		else
+#endif
+			dst_draw = pDraw;
+	}
+
+	if (dst_draw != pDraw)
+		translate = TRUE;
+
+	if (translate && pDraw->type == DRAWABLE_WINDOW) {
+		WindowPtr pWin = (WindowPtr)pDraw;
+		off_x = pWin->origin.x;
+		off_y = pWin->origin.y;
+	}
 
 	pGC = GetScratchGC(pDraw->depth, pScreen);
 	pCopyClip = REGION_CREATE(pScreen, NULL, 0);
 	REGION_COPY(pScreen, pCopyClip, pRegion);
-	pGC->funcs->ChangeClip(pGC, CT_REGION, pCopyClip, 0);
-	ValidateGC(&pdpix->drawable, pGC);
 
-	pGC->ops->CopyArea(&pspix->drawable, &pdpix->drawable, pGC, 0, 0,
-			   pDraw->width, pDraw->height, 0, 0);
+	if (translate) {
+		REGION_TRANSLATE(pScreen, pCopyClip, off_x, off_y);
+	}
+	pGC->funcs->ChangeClip(pGC, CT_REGION, pCopyClip, 0);
+	ValidateGC(dst_draw, pGC);
+	pGC->ops->CopyArea(src_draw, dst_draw, pGC, 0, 0,
+			   pDraw->width, pDraw->height, off_x, off_y);
 
 	FreeScratchGC(pGC);
 }
 
+void
+nouveau_dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
+			 DRI2BufferPtr pDstBuffer, DRI2BufferPtr pSrcBuffer)
+{
+    return nouveau_dri2_copy_region2(pDraw->pScreen, pDraw, pRegion,
+				     pDstBuffer, pSrcBuffer);
+}
+
 struct nouveau_dri2_vblank_state {
 	enum {
 		SWAP,
@@ -169,7 +231,9 @@ update_front(DrawablePtr draw, DRI2BufferPtr front)
 		return FALSE;
 	}
 
-	(*draw->pScreen->DestroyPixmap)(nvbuf->ppix);
+	if (nvbuf->ppix)
+		(*draw->pScreen->DestroyPixmap)(nvbuf->ppix);
+
 	front->pitch = pixmap->devKind;
 	front->cpp = pixmap->drawable.bitsPerPixel / 8;
 	nvbuf->ppix = pixmap;
@@ -689,6 +753,17 @@ nouveau_dri2_init(ScreenPtr pScreen)
 	dri2.SwapLimitValidate = nouveau_dri2_swap_limit_validate;
 #endif
 
+#if DRI2INFOREC_VERSION >= 7
+	dri2.version = 7;
+	dri2.GetParam = NULL;
+#endif
+
+#if DRI2INFOREC_VERSION >= 9
+	dri2.version = 9;
+	dri2.CreateBuffer2 = nouveau_dri2_create_buffer2;
+	dri2.DestroyBuffer2 = nouveau_dri2_destroy_buffer2;
+	dri2.CopyRegion2 = nouveau_dri2_copy_region2;
+#endif
 	return DRI2ScreenInit(pScreen, &dri2);
 }
 

commit b0be0ac86bae871c9f1724c40298d50d7f2b08e4
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu Jul 19 13:45:32 2012 +1000

    nouveau: add pixmap tracking/updating support.
    
    This should allow nouveau to act as an output master for driving output
    slaves.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/nv_driver.c b/src/nv_driver.c
index 6988b55..a02cef3 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -428,6 +428,39 @@ NVFlushCallback(CallbackListPtr *list, pointer user_data, pointer call_data)
 		nouveau_pushbuf_kick(pNv->pushbuf, pNv->pushbuf->channel);
 }
 
+#ifdef NOUVEAU_PIXMAP_SHARING
+static void
+redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty)
+{
+	RegionRec pixregion;
+
+	PixmapRegionInit(&pixregion, dirty->slave_dst->master_pixmap);
+
+	PixmapSyncDirtyHelper(dirty, &pixregion);
+
+	DamageRegionAppend(&dirty->slave_dst->drawable, &pixregion);
+	RegionUninit(&pixregion);
+}
+
+static void
+nouveau_dirty_update(ScreenPtr screen)
+{
+	RegionPtr region;
+	PixmapDirtyUpdatePtr ent;
+
+	if (xorg_list_is_empty(&screen->pixmap_dirty_list))
+		return;
+
+	xorg_list_for_each_entry(ent, &screen->pixmap_dirty_list, ent) {
+		region = DamageRegion(ent->damage);
+		if (RegionNotEmpty(region)) {
+			redisplay_dirty(screen, ent);
+			DamageEmpty(ent->damage);
+		}
+	}
+}
+#endif
+
 static void 
 NVBlockHandler (BLOCKHANDLER_ARGS_DECL)
 {
@@ -439,6 +472,10 @@ NVBlockHandler (BLOCKHANDLER_ARGS_DECL)
 	(*pScreen->BlockHandler) (BLOCKHANDLER_ARGS);
 	pScreen->BlockHandler = NVBlockHandler;
 
+#ifdef NOUVEAU_PIXMAP_SHARING
+	nouveau_dirty_update(pScreen);
+#endif
+
 	if (pScrn->vtSema && !pNv->NoAccel)
 		nouveau_pushbuf_kick(pNv->pushbuf, pNv->pushbuf->channel);
 
@@ -1278,6 +1315,11 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL)
 	pNv->CreateScreenResources = pScreen->CreateScreenResources;
 	pScreen->CreateScreenResources = NVCreateScreenResources;
 
+#ifdef NOUVEAU_PIXMAP_SHARING
+	pScreen->StartPixmapTracking = PixmapStartDirtyTracking;
+	pScreen->StopPixmapTracking = PixmapStopDirtyTracking;
+#endif
+
 	if (!xf86CrtcScreenInit(pScreen))
 		return FALSE;
 

commit baf485b1d304d741073f058d524ca698af3c15cd
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu Jul 19 13:42:13 2012 +1000

    nouveau/exa: add support for shared pixmaps.
    
    This adds the pixmap export/import hooks, along with code for nv50/nvc0
    to validate shared buffers in GTT space.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/nouveau_exa.c b/src/nouveau_exa.c
index 9b6b1f3..13d7e1f 100644
--- a/src/nouveau_exa.c
+++ b/src/nouveau_exa.c
@@ -154,6 +154,47 @@ nouveau_exa_destroy_pixmap(ScreenPtr pScreen, void *priv)
 	free(nvpix);
 }
 
+#ifdef NOUVEAU_PIXMAP_SHARING
+static Bool
+nouveau_exa_share_pixmap_backing(PixmapPtr ppix, ScreenPtr slave, void **handle_p)
+{
+	struct nouveau_bo *bo = nouveau_pixmap_bo(ppix);
+	struct nouveau_pixmap *nvpix = nouveau_pixmap(ppix);
+	int ret;
+	int handle;
+
+	ret = nouveau_bo_set_prime(bo, &handle);
+	if (ret != 0) {
+		ErrorF("%s: ret is %d errno is %d\n", __func__, ret, errno);
+		return FALSE;
+	}
+	nvpix->shared = TRUE;
+	*handle_p = (void *)(long)handle;
+	return TRUE;
+}
+
+static Bool
+nouveau_exa_set_shared_pixmap_backing(PixmapPtr ppix, void *handle)
+{
+	ScrnInfoPtr pScrn = xf86ScreenToScrn(ppix->drawable.pScreen);
+	NVPtr pNv = NVPTR(pScrn);
+	struct nouveau_bo *bo = nouveau_pixmap_bo(ppix);
+	struct nouveau_pixmap *nvpix = nouveau_pixmap(ppix);
+	int ret;
+	int ihandle = (int)(long)(handle);
+
+	ret = nouveau_bo_prime_handle_ref(pNv->dev, ihandle, &bo);
+	if (ret) {
+		ErrorF("failed to get BO with handle %d\n", ihandle);
+		return FALSE;
+	}
+	nvpix->bo = bo;
+	nvpix->shared = TRUE;
+	close(ihandle);
+	return TRUE;
+}
+#endif
+
 bool
 nv50_style_tiled_pixmap(PixmapPtr ppix)
 {
@@ -381,6 +422,10 @@ nouveau_exa_init(ScreenPtr pScreen)
 
 	exa->CreatePixmap2 = nouveau_exa_create_pixmap;
 	exa->DestroyPixmap = nouveau_exa_destroy_pixmap;
+#ifdef NOUVEAU_PIXMAP_SHARING
+	exa->SharePixmapBacking = nouveau_exa_share_pixmap_backing;
+	exa->SetSharedPixmapBacking = nouveau_exa_set_shared_pixmap_backing;
+#endif
 
 	if (pNv->Architecture >= NV_ARCH_50) {
 		exa->maxX = 8192;
diff --git a/src/nv50_exa.c b/src/nv50_exa.c
index 2a25e74..d6f38eb 100644
--- a/src/nv50_exa.c
+++ b/src/nv50_exa.c
@@ -94,10 +94,11 @@ NV50EXAAcquireSurface2D(PixmapPtr ppix, int is_src, uint32_t fmt)
 {
 	NV50EXA_LOCALS(ppix);
 	struct nouveau_bo *bo = nouveau_pixmap_bo(ppix);
+	struct nouveau_pixmap *nvpix = nouveau_pixmap(ppix);
 	int mthd = is_src ? NV50_2D_SRC_FORMAT : NV50_2D_DST_FORMAT;
 	uint32_t bo_flags;
 
-	bo_flags  = NOUVEAU_BO_VRAM;
+	bo_flags = nvpix->shared ? NOUVEAU_BO_GART : NOUVEAU_BO_VRAM;
 	bo_flags |= is_src ? NOUVEAU_BO_RD : NOUVEAU_BO_WR;
 
 	if (!nv50_style_tiled_pixmap(ppix)) {
diff --git a/src/nv_type.h b/src/nv_type.h
index 930b7ee..5a99dbd 100644
--- a/src/nv_type.h
+++ b/src/nv_type.h
@@ -15,6 +15,10 @@
 #error "This driver requires a DRI-enabled X server"
 #endif
 
+#if XF86_CRTC_VERSION >= 5
+#define NOUVEAU_PIXMAP_SHARING 1
+#endif
+
 #define NV_ARCH_03  0x03
 #define NV_ARCH_04  0x04
 #define NV_ARCH_10  0x10
@@ -165,6 +169,7 @@ struct nouveau_pixmap {
 	struct nouveau_bo *bo;
 	void *linear;
 	unsigned size;
+	Bool shared;
 };
 
 static inline struct nouveau_pixmap *
diff --git a/src/nvc0_exa.c b/src/nvc0_exa.c
index 6a8f1a1..dc8ba0b 100644
--- a/src/nvc0_exa.c
+++ b/src/nvc0_exa.c
@@ -95,10 +95,11 @@ NVC0EXAAcquireSurface2D(PixmapPtr ppix, int is_src, uint32_t fmt)
 {
 	NVC0EXA_LOCALS(ppix);
 	struct nouveau_bo *bo = nouveau_pixmap_bo(ppix);
+	struct nouveau_pixmap *nvpix = nouveau_pixmap(ppix);
 	int mthd = is_src ? NV50_2D_SRC_FORMAT : NV50_2D_DST_FORMAT;
 	uint32_t bo_flags;
 
-	bo_flags  = NOUVEAU_BO_VRAM;
+	bo_flags = nvpix->shared ? NOUVEAU_BO_GART : NOUVEAU_BO_VRAM;
 	bo_flags |= is_src ? NOUVEAU_BO_RD : NOUVEAU_BO_WR;
 
 	if (!nv50_style_tiled_pixmap(ppix)) {

commit 2f48b8f462a03cb92db9e9a7ae1957eb27473965
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu Jul 19 13:40:23 2012 +1000

    nouveau: add platform bus support
    
    This adds the ability to load nouveau via the new platform apis.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>

diff --git a/src/nv_driver.c b/src/nv_driver.c
index e8725f5..6988b55 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -73,6 +73,39 @@ static Bool NVPciProbe (	DriverPtr 		drv,
 				struct pci_device	*dev,
 				intptr_t		match_data	);
 
+#ifdef XSERVER_PLATFORM_BUS
+static Bool
+NVPlatformProbe(DriverPtr driver,
+            int entity_num, int flags, struct xf86_platform_device *dev, intptr_t dev_match_data)
+{
+	ScrnInfoPtr scrn = NULL;
+	uint32_t scr_flags = 0;
+
+	if (!dev->pdev)
+		return FALSE;
+
+        if (flags & PLATFORM_PROBE_GPU_SCREEN)
+               scr_flags = XF86_ALLOCATE_GPU_SCREEN;
+
+	scrn = xf86AllocateScreen(driver, scr_flags);
+	xf86AddEntityToScreen(scrn, entity_num);
+
+	scrn->driverVersion    = NV_VERSION;
+	scrn->driverName       = NV_DRIVER_NAME;
+	scrn->name             = NV_NAME;
+
+	scrn->Probe            = NULL;
+	scrn->PreInit          = NVPreInit;
+	scrn->ScreenInit       = NVScreenInit;
+	scrn->SwitchMode       = NVSwitchMode;
+	scrn->AdjustFrame      = NVAdjustFrame;
+	scrn->EnterVT          = NVEnterVT;
+	scrn->LeaveVT          = NVLeaveVT;
+	scrn->FreeScreen       = NVFreeScreen;
+	return scrn != NULL;
+}
+#endif
+
 /*
  * This contains the functions needed by the server after loading the
  * driver module.  It must be supplied, and gets added the driver list by
@@ -91,7 +124,10 @@ _X_EXPORT DriverRec NV = {
 	0,
 	NVDriverFunc,
 	nouveau_device_match,
-	NVPciProbe
+	NVPciProbe,
+#ifdef XSERVER_PLATFORM_BUS
+	NVPlatformProbe,
+#endif
 };
 
 struct NvFamily
@@ -654,7 +690,11 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
 
 	/* Get the entity, and make sure it is PCI. */
 	pNv->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
-	if (pNv->pEnt->location.type != BUS_PCI)
+	if (pNv->pEnt->location.type != BUS_PCI
+#ifdef XSERVER_PLATFORM_BUS
+		&& pNv->pEnt->location.type != BUS_PLATFORM
+#endif
+		)
 		return FALSE;
 
 	if (xf86IsEntityShared(pScrn->entityList[0])) {
diff --git a/src/nv_include.h b/src/nv_include.h
index 1e382b2..3984227 100644
--- a/src/nv_include.h
+++ b/src/nv_include.h
@@ -20,6 +20,10 @@
 /* Drivers that need to access the PCI config space directly need this */
 #include "xf86Pci.h"
 
+#ifdef XSERVER_PLATFORM_BUS
+#include "xf86platformBus.h"
+#endif
+
 /* All drivers initialising the SW cursor need this */
 #include "mipointer.h"
 

commit 3aa9a296f508089a247f92b829036ca6a55b7b42
Author: Adam Jackson <ajax@redhat.com>
Date:   Wed Aug 15 13:26:51 2012 -0400

    Remove vbe and int10 includes
    
    This driver has never used int10 or vbe, presumably these were just
    copypasta from nv.
    
    Signed-off-by: Adam Jackson <ajax@redhat.com>

diff --git a/src/nv_driver.c b/src/nv_driver.c
index 4e1e8a1..e8725f5 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -25,7 +25,6 @@
 #include "nv_include.h"
 
 #include "xorg-server.h"
-#include "xf86int10.h"
 #include "xf86drm.h"
 #include "xf86drmMode.h"
 #include "nouveau_drm.h"
diff --git a/src/nv_include.h b/src/nv_include.h
index 8d628c0..1e382b2 100644
--- a/src/nv_include.h
+++ b/src/nv_include.h
@@ -30,8 +30,6 @@
 
 #include "xf86DDC.h"
 
-#include "vbe.h"
-
 #include "xf86RandR12.h"
 
 #include "nv_const.h"
diff --git a/src/nv_type.h b/src/nv_type.h
index e1ea494..930b7ee 100644
--- a/src/nv_type.h
+++ b/src/nv_type.h
@@ -3,7 +3,6 @@
 
 #include "colormapst.h"
 #include "xf86Cursor.h"
-#include "xf86int10.h"
 #include "exa.h"
 #ifdef XF86DRI
 #define _XF86DRI_SERVER_

commit 9b9be11e99930136a591059db1bf4ceaca8806e7
Author: Adam Jackson <ajax@redhat.com>
Date:   Thu Jul 19 18:22:44 2012 -0400

    Implement ->driverFunc
    
    Copied from fbdev, makes it so we can run without iopl.
    
    Signed-off-by: Adam Jackson <ajax@redhat.com>

diff --git a/src/nv_driver.c b/src/nv_driver.c
index beef789..4e1e8a1 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -48,6 +48,8 @@ static Bool    NVSaveScreen(ScreenPtr pScreen, int mode);
 static void    NVCloseDRM(ScrnInfoPtr);
 
 /* Optional functions */
+static Bool    NVDriverFunc(ScrnInfoPtr scrn, xorgDriverFuncOp op,
+			    void *data);
 static Bool    NVSwitchMode(SWITCH_MODE_ARGS_DECL);
 static void    NVAdjustFrame(ADJUST_FRAME_ARGS_DECL);
 static void    NVFreeScreen(FREE_SCREEN_ARGS_DECL);
@@ -88,7 +90,7 @@ _X_EXPORT DriverRec NV = {
 	NVAvailableOptions,
 	NULL,
 	0,
-	NULL,
+	NVDriverFunc,
 	nouveau_device_match,
 	NVPciProbe
 };
@@ -200,6 +202,21 @@ NVIdentify(int flags)
 }
 
 static Bool
+NVDriverFunc(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
+{
+    xorgHWFlags *flag;
+
+    switch (op) {
+	case GET_REQUIRED_HW_INTERFACES:
+	    flag = (CARD32 *)data;
+	    (*flag) = 0;
+	    return TRUE;
+	default:
+	    return FALSE;
+    }
+}
+
+static Bool
 NVPciProbe(DriverPtr drv, int entity_num, struct pci_device *pci_dev,
 	   intptr_t match_data)
 {

commit 6629066b87142cdd1d9e881b61ef55c97aedf949
Author: Ben Skeggs <bskeggs@redhat.com>
Date:   Fri Aug 3 17:05:33 2012 +1000

    nvc0/nve0: support sync-to-vblank if kernel is new enough
    
    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>

diff --git a/src/nouveau_dri2.c b/src/nouveau_dri2.c
index 0b3cc38..62333b1 100644
--- a/src/nouveau_dri2.c
+++ b/src/nouveau_dri2.c
@@ -316,6 +316,9 @@ nouveau_dri2_finish_swap(DrawablePtr draw, unsigned int frame,
 					   NOUVEAU_BO_VRAM | NOUVEAU_BO_RD
 				     }, 1);
 
+		if (pNv->Architecture >= NV_ARCH_C0)
+			NVC0SyncToVBlank(dst_pix, REGION_EXTENTS(0, &reg));
+		else
 		if (pNv->Architecture >= NV_ARCH_50)
 			NV50SyncToVBlank(dst_pix, REGION_EXTENTS(0, &reg));
 		else
diff --git a/src/nouveau_local.h b/src/nouveau_local.h
index b8a4fea..3de69a2 100644
--- a/src/nouveau_local.h
+++ b/src/nouveau_local.h
@@ -250,6 +250,7 @@ BEGIN_1IC0(struct nouveau_pushbuf *push, int subc, int mthd, int size)
 
 #define NV01_SUBC(subc, mthd) SUBC_##subc((NV01_SUBCHAN_##mthd))
 #define NV11_SUBC(subc, mthd) SUBC_##subc((NV11_SUBCHAN_##mthd))
+#define NV84_SUBC(subc, mthd) SUBC_##subc((NV84_SUBCHAN_##mthd))
 
 #define NV04_GRAPH(subc, mthd) SUBC_##subc((NV04_GRAPH_##mthd))
 #define NV50_GRAPH(subc, mthd) SUBC_##subc((NV50_GRAPH_##mthd))
diff --git a/src/nv_proto.h b/src/nv_proto.h
index b546ebd..bcf927d 100644
--- a/src/nv_proto.h
+++ b/src/nv_proto.h
@@ -149,6 +149,7 @@ Bool NVAccelInit2D_NV50(ScrnInfoPtr pScrn);
 Bool NVAccelInitNV50TCL(ScrnInfoPtr pScrn);
 
 /* in nvc0_accel.c */
+void NVC0SyncToVBlank(PixmapPtr ppix, BoxPtr box);
 Bool NVAccelInitM2MF_NVC0(ScrnInfoPtr pScrn);
 Bool NVAccelInitCopy_NVC0(ScrnInfoPtr pScrn);
 Bool NVAccelInitP2MF_NVE0(ScrnInfoPtr pScrn);
diff --git a/src/nvc0_accel.c b/src/nvc0_accel.c
index c5da0cd..406bc59 100644
--- a/src/nvc0_accel.c
+++ b/src/nvc0_accel.c
@@ -25,6 +25,45 @@
 #include "nvc0_shader.h"
 #include "nve0_shader.h"
 
+void
+NVC0SyncToVBlank(PixmapPtr ppix, BoxPtr box)
+{
+	ScrnInfoPtr pScrn = xf86ScreenToScrn(ppix->drawable.pScreen);
+	NVPtr pNv = NVPTR(pScrn);
+	struct nouveau_pushbuf *push = pNv->pushbuf;
+	int crtcs;
+
+	if (!pNv->NvSW || !nouveau_exa_pixmap_is_onscreen(ppix))
+		return;
+
+	crtcs = nv_window_belongs_to_crtc(pScrn, box->x1, box->y1,
+					  box->x2 - box->x1,
+					  box->y2 - box->y1);
+	if (!crtcs)
+		return;
+
+	if (!PUSH_SPACE(push, 32))
+		return;
+
+	BEGIN_NVC0(push, NV01_SUBC(NVSW, OBJECT), 1);
+	PUSH_DATA (push, pNv->NvSW->handle);
+	BEGIN_NVC0(push, NV84_SUBC(NVSW, SEMAPHORE_ADDRESS_HIGH), 4);
+	PUSH_DATA (push, (pNv->scratch->offset + SEMA_OFFSET) >> 32);
+	PUSH_DATA (push, (pNv->scratch->offset + SEMA_OFFSET));
+	PUSH_DATA (push, 0x22222222);
+	PUSH_DATA (push, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG);
+	BEGIN_NVC0(push, SUBC_NVSW(0x0400), 4);
+	PUSH_DATA (push, (pNv->scratch->offset + SEMA_OFFSET) >> 32);
+	PUSH_DATA (push, (pNv->scratch->offset + SEMA_OFFSET));
+	PUSH_DATA (push, 0x11111111);
+	PUSH_DATA (push, ffs(crtcs) - 1);
+	BEGIN_NVC0(push, NV84_SUBC(NVSW, SEMAPHORE_ADDRESS_HIGH), 4);
+	PUSH_DATA (push, (pNv->scratch->offset + SEMA_OFFSET) >> 32);
+	PUSH_DATA (push, (pNv->scratch->offset + SEMA_OFFSET));
+	PUSH_DATA (push, 0x11111111);
+	PUSH_DATA (push, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL);
+}
+
 Bool
 NVAccelInitM2MF_NVC0(ScrnInfoPtr pScrn)
 {
@@ -140,19 +179,29 @@ NVAccelInit3D_NVC0(ScrnInfoPtr pScrn)
 	NVPtr pNv = NVPTR(pScrn);
 	struct nouveau_pushbuf *push = pNv->pushbuf;
 	struct nouveau_bo *bo = pNv->scratch;
-	uint32_t class;
+	uint32_t class, handle;
 	int ret;
 
-	if (pNv->Architecture < NV_ARCH_E0)
-		class = 0x9097;
-	else
-		class = 0xa097;
+	if (pNv->Architecture < NV_ARCH_E0) {
+		class  = 0x9097;
+		handle = 0x001f906e;
+	} else {
+		class  = 0xa097;
+		handle = 0x0000906e;
+	}
 
 	ret = nouveau_object_new(pNv->channel, class, class,
 				 NULL, 0, &pNv->Nv3D);
 	if (ret)


Reply to: