xf86-video-intel: 3 commits - src/i830_batchbuffer.h src/i830_dri.c src/i830_driver.c src/i830_memory.c src/i965_render.c

Carl Worth cworth at kemper.freedesktop.org
Tue May 26 16:12:45 PDT 2009


 src/i830_batchbuffer.h |    9 ++++
 src/i830_dri.c         |   35 +----------------
 src/i830_driver.c      |   97 +++++++++++++++++++++++++++++++++++++++----------
 src/i830_memory.c      |   16 --------
 src/i965_render.c      |   32 +++++++++-------
 5 files changed, 107 insertions(+), 82 deletions(-)

New commits:
commit 8e942b70cb9a784b3f1311affd6fc74c4bcf68bb
Author: Carl Worth <cworth at cworth.org>
Date:   Thu May 21 13:12:52 2009 -0700

    Revert "Rely on BO pixmaps being present in acceleration paths."
    
    This reverts commit 4653a7db622ad54a3182d93c81331765d930db34.
    
    Eric was getting a little too ambitious about our brave, new world.
    We do still want the driver to work with old, non-GEM kernels
    after all.

diff --git a/src/i830_batchbuffer.h b/src/i830_batchbuffer.h
index 0283438..4903b8c 100644
--- a/src/i830_batchbuffer.h
+++ b/src/i830_batchbuffer.h
@@ -102,9 +102,16 @@ intel_batch_emit_reloc_pixmap(I830Ptr pI830, PixmapPtr pPixmap,
 			      uint32_t delta)
 {
     dri_bo *bo = i830_get_pixmap_bo(pPixmap);
+    uint32_t offset;
     assert(pI830->batch_ptr != NULL);
     assert(intel_batch_space(pI830) >= 4);
-    intel_batch_emit_reloc(pI830, bo, read_domains, write_domain, delta);
+    if (bo) {
+	intel_batch_emit_reloc(pI830, bo, read_domains, write_domain, delta);
+	return;
+    }
+    offset = intel_get_pixmap_offset(pPixmap);
+    *(uint32_t *)(pI830->batch_ptr + pI830->batch_used) = offset + delta;
+    pI830->batch_used += 4;
 }
 
 #define OUT_BATCH(dword) intel_batch_emit_dword(pI830, dword)
diff --git a/src/i965_render.c b/src/i965_render.c
index 7583af1..e527f11 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -923,7 +923,6 @@ i965_set_picture_surface_state(dri_bo *ss_bo, int ss_index,
     struct brw_surface_state_padded *ss;
     struct brw_surface_state local_ss;
     dri_bo *pixmap_bo = i830_get_pixmap_bo(pPixmap);
-    uint32_t write_domain, read_domains;
 
     ss = (struct brw_surface_state_padded *)ss_bo->virtual + ss_index;
 
@@ -953,7 +952,10 @@ i965_set_picture_surface_state(dri_bo *ss_bo, int ss_index,
     local_ss.ss0.vert_line_stride_ofs = 0;
     local_ss.ss0.mipmap_layout_mode = 0;
     local_ss.ss0.render_cache_read_mode = 0;
-    local_ss.ss1.base_addr = pixmap_bo->offset;
+    if (pixmap_bo != NULL)
+	local_ss.ss1.base_addr = pixmap_bo->offset;
+    else
+	local_ss.ss1.base_addr = intel_get_pixmap_offset(pPixmap);
 
     local_ss.ss2.mip_count = 0;
     local_ss.ss2.render_target_rotation = 0;
@@ -965,20 +967,22 @@ i965_set_picture_surface_state(dri_bo *ss_bo, int ss_index,
 
     memcpy(ss, &local_ss, sizeof(local_ss));
 
+    if (pixmap_bo != NULL) {
+	uint32_t write_domain, read_domains;
 
-    if (is_dst) {
-	write_domain = I915_GEM_DOMAIN_RENDER;
-	read_domains = I915_GEM_DOMAIN_RENDER;
-    } else {
-	write_domain = 0;
-	read_domains = I915_GEM_DOMAIN_SAMPLER;
+	if (is_dst) {
+	    write_domain = I915_GEM_DOMAIN_RENDER;
+	    read_domains = I915_GEM_DOMAIN_RENDER;
+	} else {
+	    write_domain = 0;
+	    read_domains = I915_GEM_DOMAIN_SAMPLER;
+	}
+	dri_bo_emit_reloc(ss_bo, read_domains, write_domain,
+			  0,
+			  ss_index * sizeof(*ss) +
+			  offsetof(struct brw_surface_state, ss1),
+			  pixmap_bo);
     }
-    drm_intel_bo_emit_reloc(ss_bo,
-			    ss_index * sizeof(*ss) +
-			    offsetof(struct brw_surface_state, ss1),
-			    pixmap_bo,
-			    0,
-			    read_domains, write_domain);
 }
 
 static void
commit 1a039f4371bec455cad43f0fb7b329f2ee09a974
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Apr 27 17:45:02 2009 -0700

    Fold GEM detection into DRM master open.
    
    We don't have anything to do with the DRM unless it's GEM-enabled, unless
    we were to support GEM-but-not-DRI2, which doesn't seem useful.
    
    Compilation fixes by Carl Worth <cworth at cworth.org>

diff --git a/src/i830_driver.c b/src/i830_driver.c
index ef4d575..0b6bb71 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1420,7 +1420,8 @@ i830_open_drm_master(ScrnInfoPtr scrn)
     struct pci_device *dev = i830->PciInfo;
     char *busid;
     drmSetVersion sv;
-    int err;
+    struct drm_i915_getparam gp;
+    int err, has_gem;
 
     /* We wish we had asprintf, but all we get is XNFprintf. */
     busid = XNFprintf("pci:%04x:%02x:%02x.%d",
@@ -1428,6 +1429,7 @@ i830_open_drm_master(ScrnInfoPtr scrn)
 
     i830->drmSubFD = drmOpen("i915", busid);
     if (i830->drmSubFD == -1) {
+	xfree(busid);
 	xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 		   "[drm] Failed to open DRM device for %s\n", busid);
 	return FALSE;
@@ -1449,6 +1451,19 @@ i830_open_drm_master(ScrnInfoPtr scrn)
 	return FALSE;
     }
 
+    has_gem = FALSE;
+    gp.param = I915_PARAM_HAS_GEM;
+    gp.value = &has_gem;
+    (void)drmCommandWriteRead(i830->drmSubFD, DRM_I915_GETPARAM,
+			      &gp, sizeof(gp));
+    if (!has_gem) {
+	xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+		   "[drm] Failed to detect GEM.  Kernel 2.6.28 required.\n");
+	drmClose(i830->drmSubFD);
+	i830->drmSubFD = -1;
+	return FALSE;
+    }
+
     return TRUE;
 }
 
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 99b9fc8..5e07213 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -368,9 +368,7 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
 {
     I830Ptr pI830 = I830PTR(pScrn);
     i830_memory *start, *end;
-    struct drm_i915_getparam gp;
     struct drm_i915_setparam sp;
-    int has_gem;
 
     start = xcalloc(1, sizeof(*start));
     if (start == NULL)
@@ -407,24 +405,12 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
 
     pI830->memory_list = start;
 
-    has_gem = FALSE;
-
-    if (pI830->directRenderingType >= DRI_DRI2)
-    {
-	has_gem = FALSE;
-	gp.param = I915_PARAM_HAS_GEM;
-	gp.value = &has_gem;
-    
-	(void)drmCommandWriteRead(pI830->drmSubFD, DRM_I915_GETPARAM,
-				  &gp, sizeof(gp));
-    }
-
     /* Now that we have our manager set up, initialize the kernel MM if
      * possible, covering almost all of the aperture.  We need libdri interface
      * 5.4 or newer so we can rely on the lock being held after DRIScreenInit,
      * rather than after DRIFinishScreenInit.
      */
-    if (pI830->directRenderingType == DRI_DRI2 && has_gem) {
+    if (pI830->directRenderingType == DRI_DRI2) {
 	int mmsize;
 
 	/* Take over all of the graphics aperture minus enough to for
commit a04a51c9bb6066454e0fda3c7897f97dab436358
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Apr 27 17:29:36 2009 -0700

    Open the DRM and keep the handle throughout server startup to finish.
    
    This will let us configure the server from start to finish with the
    most pertinent information available (KMS vs UMS, DRI2 vs non-DRI).  Also,
    we now close the DRI2 fd at terminate, which we didn't before.
    
    This duplicates some code from DRI1 for getting a master FD like I'd done in
    DRI2, but given that we weren't loading DRI1 ourselves, this is also a
    bogosity cleanup, and avoids allocating the extra DRI1 private.

diff --git a/src/i830_dri.c b/src/i830_dri.c
index 0648249..fc059df 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -329,7 +329,7 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen)
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     I830Ptr pI830 = I830PTR(pScrn);
     DRI2InfoRec info;
-    char *p, buf[64];
+    char *p;
     int i;
     struct stat sbuf;
     dev_t d;
@@ -355,36 +355,7 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen)
     }
 #endif
 
-    sprintf(buf, "pci:%04x:%02x:%02x.%d",
-	    pI830->PciInfo->domain,
-	    pI830->PciInfo->bus,
-	    pI830->PciInfo->dev,
-	    pI830->PciInfo->func);
-
-    /* Use the already opened (master) fd from modesetting */
-    if (pI830->use_drm_mode) {
-	info.fd = pI830->drmSubFD;
-    } else {
-	info.fd = drmOpen("i915", buf);
-	drmSetVersion sv;
-	int err;
-
-	/* Check that what we opened was a master or a master-capable FD,
-	 * by setting the version of the interface we'll use to talk to it.
-	 * (see DRIOpenDRMMaster() in DRI1)
-	 */
-	sv.drm_di_major = 1;
-	sv.drm_di_minor = 1;
-	sv.drm_dd_major = -1;
-	err = drmSetInterfaceVersion(info.fd, &sv);
-	if (err != 0)
-	    return FALSE;
-    }
-
-    if (info.fd < 0) {
-	xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed to open DRM device\n");
-	return FALSE;
-    }
+    info.fd = pI830->drmSubFD;
 
     /* The whole drmOpen thing is a fiasco and we need to find a way
      * back to just using open(2).  For now, however, lets just make
@@ -423,8 +394,6 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen)
 
     info.CopyRegion = I830DRI2CopyRegion;
 
-    pI830->drmSubFD = info.fd;
-
     return DRI2ScreenInit(pScreen, &info);
 }
 
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 854ad0f..ef4d575 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1414,28 +1414,61 @@ I830AccelMethodInit(ScrnInfoPtr pScrn)
 }
 
 static Bool
-I830DrmModeInit(ScrnInfoPtr pScrn)
+i830_open_drm_master(ScrnInfoPtr scrn)
 {
-    I830Ptr pI830 = I830PTR(pScrn);
-    char *bus_id;
-    int ret;
+    I830Ptr i830 = I830PTR(scrn);
+    struct pci_device *dev = i830->PciInfo;
+    char *busid;
+    drmSetVersion sv;
+    int err;
+
+    /* We wish we had asprintf, but all we get is XNFprintf. */
+    busid = XNFprintf("pci:%04x:%02x:%02x.%d",
+		      dev->domain, dev->bus, dev->dev, dev->func);
+
+    i830->drmSubFD = drmOpen("i915", busid);
+    if (i830->drmSubFD == -1) {
+	xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+		   "[drm] Failed to open DRM device for %s\n", busid);
+	return FALSE;
+    }
 
-    pI830->accel = ACCEL_UXA;
+    xfree(busid);
 
-    bus_id = DRICreatePCIBusID(pI830->PciInfo);
+    /* Check that what we opened was a master or a master-capable FD,
+     * by setting the version of the interface we'll use to talk to it.
+     * (see DRIOpenDRMMaster() in DRI1)
+     */
+    sv.drm_di_major = 1;
+    sv.drm_di_minor = 1;
+    sv.drm_dd_major = -1;
+    err = drmSetInterfaceVersion(i830->drmSubFD, &sv);
+    if (err != 0) {
+	drmClose(i830->drmSubFD);
+	i830->drmSubFD = -1;
+	return FALSE;
+    }
 
-    /* Create a bus Id */
-    /* Low level DRM open */
-    ret = DRIOpenDRMMaster(pScrn, SAREA_MAX, bus_id, "i915");
-    xfree(bus_id);
-    if (!ret) {
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "[dri] DRIGetVersion failed to open the DRM\n"
-		       "[dri] Disabling DRI.\n");
-	    return FALSE;
+    return TRUE;
+}
+
+static void
+i830_close_drm_master(ScrnInfoPtr scrn)
+{
+    I830Ptr i830 = I830PTR(scrn);
+    if (i830->drmSubFD > 0) {
+	drmClose(i830->drmSubFD);
+	i830->drmSubFD = -1;
     }
+}
+
+static Bool
+I830DrmModeInit(ScrnInfoPtr pScrn)
+{
+    I830Ptr pI830 = I830PTR(pScrn);
+
+    pI830->accel = ACCEL_UXA;
 
-    pI830->drmSubFD = DRIMasterFD(pScrn);
     if (drmmode_pre_init(pScrn, pI830->drmSubFD, pI830->cpp) == FALSE) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		   "Kernel modesetting setup failed\n");
@@ -1477,11 +1510,17 @@ I830XvInit(ScrnInfoPtr pScrn)
 }
 
 /**
- * This is called per zaphod head (so usually just once) to do initialization
- * before the Screen is created.
+ * This is called before ScreenInit to do any require probing of screen
+ * configuration.
  *
  * This code generally covers probing, module loading, option handling
  * card mapping, and RandR setup.
+ *
+ * Since xf86InitialConfiguration ends up requiring that we set video modes
+ * in order to detect configuration, we end up having to do a lot of driver
+ * setup (talking to the DRM, mapping the device, etc.) in this function.
+ * As a result, we want to set up that server initialization once rather
+ * that doing it per generation.
  */
 static Bool
 I830PreInit(ScrnInfoPtr pScrn, int flags)
@@ -1531,6 +1570,8 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
 
    pI830->PciInfo = xf86GetPciInfoForEntity(pI830->pEnt->index);
 
+   i830_open_drm_master(pScrn);
+
    if (xf86RegisterResources(pI830->pEnt->index, NULL, ResNone)) {
       PreInitCleanup(pScrn);
       return FALSE;
@@ -2839,12 +2880,15 @@ i830AdjustFrame(int scrnIndex, int x, int y, int flags)
 static void
 I830FreeScreen(int scrnIndex, int flags)
 {
-#ifdef INTEL_XVMC
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+#ifdef INTEL_XVMC
     I830Ptr pI830 = I830PTR(pScrn);
     if (pI830 && pI830->XvMCEnabled)
 	intel_xvmc_finish(xf86Screens[scrnIndex]);
 #endif
+
+    i830_close_drm_master(pScrn);
+
    I830FreeRec(xf86Screens[scrnIndex]);
    if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
       vgaHWFreeHWRec(xf86Screens[scrnIndex]);


More information about the xorg-commit mailing list