xf86-video-modesetting: Branch 'restart' - 5 commits - src/driver.c src/drmmode_display.h

Dave Airlie airlied at kemper.freedesktop.org
Thu Sep 29 04:35:11 PDT 2011


 src/driver.c          |  253 ++++++++++++++++++--------------------------------
 src/drmmode_display.h |   54 ++--------
 2 files changed, 110 insertions(+), 197 deletions(-)

New commits:
commit 7307ff4dd1a6cbfa1e4311ec2c6efc26eb81a434
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Sep 29 12:34:27 2011 +0100

    drop loading dri2

diff --git a/src/driver.c b/src/driver.c
index dee9cff..0aaafd1 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -462,10 +462,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 	return FALSE;
     }
 
-#ifdef DRI2
-    xf86LoadSubModule(pScrn, "dri2");
-#endif
-
     return TRUE;
     fail:
     return FALSE;
commit 0ca055f7b19e60df8ba4aa44522e06e06c1222f1
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Sep 29 12:34:17 2011 +0100

    update authors/copyright

diff --git a/src/driver.c b/src/driver.c
index 9bb1cb4..dee9cff 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -1,5 +1,6 @@
 /*
  * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2011 Dave Airlie
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,7 +24,8 @@
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  *
- * Author: Alan Hourihane <alanh at tungstengraphics.com>
+ * Original Author: Alan Hourihane <alanh at tungstengraphics.com>
+ * Rewrite: Dave Airlie <airlied at redhat.com> 
  *
  */
 
commit ac7b8e43842858b8787b1f7ede4d547eece77e5e
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Sep 29 12:30:46 2011 +0100

    gut some more unneeded code

diff --git a/src/driver.c b/src/driver.c
index be781bc..9bb1cb4 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -638,24 +638,6 @@ static void
 LeaveVT(int scrnIndex, int flags)
 {
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-    modesettingPtr ms = modesettingPTR(pScrn);
-    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
-    int o;
-
-    for (o = 0; o < config->num_crtc; o++) {
-	xf86CrtcPtr crtc = config->crtc[o];
-
-	//	cursor_destroy(crtc);
-
-	if (crtc->rotatedPixmap || crtc->rotatedData) {
-	    crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap,
-					crtc->rotatedData);
-	    crtc->rotatedPixmap = NULL;
-	    crtc->rotatedData = NULL;
-	}
-    }
-
-    drmModeRmFB(ms->fd, ms->fb_id);
 
     pScrn->vtSema = FALSE;
 }
commit ffb6bb4deb827c369faadd77495d7cae4acc2a42
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Sep 29 12:28:59 2011 +0100

    modesetting: rewrite probing based on fbdev.
    
    This isn't perfect, it should really do more with bus id matching
    and finding the write drm device using sysfs if it can. but it removes
    lots of hardcoding of pci ids.

diff --git a/src/driver.c b/src/driver.c
index 47ffb07..be781bc 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -31,6 +31,7 @@
 #include "config.h"
 #endif
 
+#include <fcntl.h>
 #include "xf86.h"
 #include "xf86_OSproc.h"
 #include "compiler.h"
@@ -68,18 +69,19 @@ static Bool ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
 		       char **argv);
 static Bool PreInit(ScrnInfoPtr pScrn, int flags);
 
-#if XSERVER_LIBPCIACCESS
-static Bool
-pci_probe(DriverPtr driver,
-	  int entity_num, struct pci_device *device, intptr_t match_data);
-#else
 static Bool Probe(DriverPtr drv, int flags);
-#endif
+static Bool ms_pci_probe(DriverPtr driver,
+			 int entity_num, struct pci_device *device,
+			 intptr_t match_data);
 
-#if XSERVER_LIBPCIACCESS
-static const struct pci_id_match device_match[] = {
-    {0x8086, 0x0046, 0xffff, 0xffff, 0, 0, 0},
-    {0, 0, 0},
+#ifdef XSERVER_LIBPCIACCESS
+static const struct pci_id_match ms_device_match[] = {
+    {
+	PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
+	0x00030000, 0x00ffffff, 0
+    },
+
+    { 0, 0, 0 },
 };
 #endif
 
@@ -87,38 +89,29 @@ _X_EXPORT DriverRec modesetting = {
     1,
     "modesetting",
     Identify,
-#if XSERVER_LIBPCIACCESS
-    NULL,
-#else
     Probe,
-#endif
     AvailableOptions,
     NULL,
     0,
     NULL,
-#if XSERVER_LIBPCIACCESS
-    device_match,
-    pci_probe
-#endif
+    ms_device_match,
+    ms_pci_probe,
 };
 
 static SymTabRec Chipsets[] = {
-    {0x0046, "Intel Graphics Device"},
+    {0, "kms" },
     {-1, NULL}
 };
 
-static PciChipsets PciDevices[] = {
-    {0x2592, 0x0046, RES_SHARED_VGA},
-    {-1, -1, RES_UNDEFINED}
-};
-
 typedef enum
 {
     OPTION_SW_CURSOR,
+    OPTION_DEVICE_PATH,
 } modesettingOpts;
 
 static const OptionInfoRec Options[] = {
     {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE},
+    {OPTION_DEVICE_PATH, "kmsdev", OPTV_STRING, {0}, FALSE },
     {-1, NULL, OPTV_NONE, {0}, FALSE}
 };
 
@@ -171,6 +164,27 @@ Identify(int flags)
 		      Chipsets);
 }
 
+static Bool probe_hw(char *dev)
+{
+    int fd;
+    if (dev)
+	fd = open(dev, O_RDWR, 0);
+    else {
+	dev = getenv("KMSDEVICE");
+	if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) {
+	    dev = "/dev/dri/card0";
+	    fd = open(dev,O_RDWR, 0);
+	}
+    }
+    if (fd == -1) {
+	xf86DrvMsg(-1, X_ERROR,"open %s: %s\n", dev, strerror(errno));
+	return FALSE;
+    }
+    close(fd);
+    return TRUE;
+
+}
+
 static const OptionInfoRec *
 AvailableOptions(int chipid, int busid)
 {
@@ -179,25 +193,26 @@ AvailableOptions(int chipid, int busid)
 
 #if XSERVER_LIBPCIACCESS
 static Bool
-pci_probe(DriverPtr driver,
-	  int entity_num, struct pci_device *device, intptr_t match_data)
+ms_pci_probe(DriverPtr driver,
+	     int entity_num, struct pci_device *dev, intptr_t match_data)
 {
     ScrnInfoPtr scrn = NULL;
     EntityInfoPtr entity;
     DevUnion *private;
 
-    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, PciDevices,
+    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, NULL,
 			       NULL, NULL, NULL, NULL, NULL);
-    if (scrn != NULL) {
-	scrn->driverVersion = 1;
-	scrn->driverName = "modesetting";
-	scrn->name = "modesetting";
-	scrn->Probe = NULL;
-
-	entity = xf86GetEntityInfo(entity_num);
-
-	switch (device->device_id) {
-	case 0x0046:
+    if (scrn) {
+	char *devpath;
+	GDevPtr devSection = xf86GetDevFromEntity(scrn->entityList[0],
+						  scrn->entityInstanceList[0]);
+
+	devpath = xf86FindOptionValue(devSection->options, "kmsdev");
+	if (probe_hw(devpath)) {
+	    scrn->driverVersion = 1;
+	    scrn->driverName = "modesetting";
+	    scrn->name = "modeset";
+	    scrn->Probe = NULL;
 	    scrn->PreInit = PreInit;
 	    scrn->ScreenInit = ScreenInit;
 	    scrn->SwitchMode = SwitchMode;
@@ -206,12 +221,19 @@ pci_probe(DriverPtr driver,
 	    scrn->LeaveVT = LeaveVT;
 	    scrn->FreeScreen = FreeScreen;
 	    scrn->ValidMode = ValidMode;
-	    break;
-	}
+
+	    xf86DrvMsg(scrn->scrnIndex, X_CONFIG,
+		       "claimed PCI slot %d@%d:%d:%d\n", 
+		       dev->bus, dev->domain, dev->dev, dev->func);
+	    xf86DrvMsg(scrn->scrnIndex, X_INFO,
+		       "using %s\n", devpath ? devpath : "default device");
+	} else
+	    scrn = NULL;
     }
     return scrn != NULL;
 }
-#else
+#endif
+
 static Bool
 Probe(DriverPtr drv, int flags)
 {
@@ -220,9 +242,13 @@ Probe(DriverPtr drv, int flags)
     DevUnion *pPriv;
     GDevPtr *devSections;
     Bool foundScreen = FALSE;
-    pciVideoPtr *VideoInfo;
-    pciVideoPtr *ppPci;
     int numDevs;
+    char *dev;
+    ScrnInfoPtr scrn;
+
+    /* For now, just bail out for PROBE_DETECT. */
+    if (flags & PROBE_DETECT)
+	return FALSE;
 
     /*
      * Find the config file Device sections that match this
@@ -232,110 +258,41 @@ Probe(DriverPtr drv, int flags)
 	return FALSE;
     }
 
-    /*
-     * This probing is just checking the PCI data the server already
-     * collected.
-     */
-    if (!(VideoInfo = xf86GetPciVideoInfo()))
-	return FALSE;
+    for (i = 0; i < numDevSections; i++) {
 
-#if 0
-    numUsed = 0;
-    for (ppPci = VideoInfo; ppPci != NULL && *ppPci != NULL; ppPci++) {
-	for (numDevs = 0; numDevs < numDevSections; numDevs++) {
-	    if (devSections[numDevs]->busID && *devSections[numDevs]->busID) {
-		if (xf86ComparePciBusString
-		    (devSections[numDevs]->busID, (*ppPci)->bus,
-		     (*ppPci)->device, (*ppPci)->func)) {
-		    /* Claim slot */
-		    if (xf86CheckPciSlot((*ppPci)->bus, (*ppPci)->device,
-					 (*ppPci)->func)) {
-			usedChips[numUsed++] =
-			    xf86ClaimPciSlot((*ppPci)->bus, (*ppPci)->device,
-					     (*ppPci)->func, drv,
-					     (*ppPci)->chipType, NULL, TRUE);
-			ErrorF("CLAIMED %d %d %d\n", (*ppPci)->bus,
-			       (*ppPci)->device, (*ppPci)->func);
-		    }
-		}
+	dev = xf86FindOptionValue(devSections[i]->options,"kmsdev");
+	if (devSections[i]->busID) {
+	    if (probe_hw(dev)) {
+		int entity;
+		entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE);
+		scrn = xf86ConfigFbEntity(scrn, 0, entity,
+					   NULL, NULL, NULL, NULL);
 	    }
-	}
-    }
-#else
-    /* Look for Intel i8xx devices. */
-    numUsed = xf86MatchPciInstances("modesetting", PCI_VENDOR_INTEL,
-				    Chipsets, PciDevices,
-				    devSections, numDevSections,
-				    drv, &usedChips);
-#endif
 
-    if (flags & PROBE_DETECT) {
-	if (numUsed > 0)
-	    foundScreen = TRUE;
-    } else {
-	for (i = 0; i < numUsed; i++) {
-	    ScrnInfoPtr pScrn = NULL;
-
-	    /* Allocate new ScrnInfoRec and claim the slot */
-	    if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
-					     PciDevices, NULL, NULL, NULL,
-					     NULL, NULL))) {
-		EntityInfoPtr pEnt;
-
-		pEnt = xf86GetEntityInfo(usedChips[i]);
-
-		pScrn->driverVersion = 1;
-		pScrn->driverName = "modesetting";
-		pScrn->name = "modesetting";
-		pScrn->Probe = Probe;
+	    if (scrn)
 		foundScreen = TRUE;
-		{
-		    /* Allocate an entity private if necessary */
-		    if (modesettingEntityIndex < 0)
-			modesettingEntityIndex =
-			    xf86AllocateEntityPrivateIndex();
-
-		    pPriv = xf86GetEntityPrivate(pScrn->entityList[0],
-						 modesettingEntityIndex);
-		    if (!pPriv->ptr) {
-			pPriv->ptr = xnfcalloc(sizeof(EntRec), 1);
-			msEnt = pPriv->ptr;
-			msEnt->lastInstance = -1;
-		    } else {
-			msEnt = pPriv->ptr;
-		    }
-
-		    /*
-		     * Set the entity instance for this instance of the driver.
-		     * For dual head per card, instance 0 is the "master"
-		     * instance, driving the primary head, and instance 1 is
-		     * the "slave".
-		     */
-		    msEnt->lastInstance++;
-		    xf86SetEntityInstanceForScreen(pScrn,
-						   pScrn->entityList[0],
-						   msEnt->lastInstance);
-		    pScrn->PreInit = PreInit;
-		    pScrn->ScreenInit = ScreenInit;
-		    pScrn->SwitchMode = SwitchMode;
-		    pScrn->AdjustFrame = AdjustFrame;
-		    pScrn->EnterVT = EnterVT;
-		    pScrn->LeaveVT = LeaveVT;
-		    pScrn->FreeScreen = FreeScreen;
-		    pScrn->ValidMode = ValidMode;
-		    break;
-		}
-	    } else
-		ErrorF("FAILED PSCRN\n");
+		scrn->driverVersion = 1;
+		scrn->driverName = "modesetting";
+		scrn->name = "modesetting";
+		scrn->Probe = Probe;
+		scrn->PreInit = PreInit;
+		scrn->ScreenInit = ScreenInit;
+		scrn->SwitchMode = SwitchMode;
+		scrn->AdjustFrame = AdjustFrame;
+		scrn->EnterVT = EnterVT;
+		scrn->LeaveVT = LeaveVT;
+		scrn->FreeScreen = FreeScreen;
+		scrn->ValidMode = ValidMode;
+
+		xf86DrvMsg(scrn->scrnIndex, X_INFO,
+			   "using %s\n", dev ? dev : "default device");
 	}
     }
 
-    free(usedChips);
     free(devSections);
 
     return foundScreen;
 }
-#endif
 
 static Bool
 GetRec(ScrnInfoPtr pScrn)
commit ec9374e4210ab36a07209e27a79922545eafd5e2
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Sep 29 11:52:51 2011 +0100

    cleanup some the drmmode_display header file

diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 2d72505..845207a 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -33,49 +33,33 @@
 #endif
 
 struct dumb_bo {
-  uint32_t handle;
-  uint32_t size;
-  void *ptr;
-  int map_count;
-  uint32_t pitch;
+    uint32_t handle;
+    uint32_t size;
+    void *ptr;
+    int map_count;
+    uint32_t pitch;
 };
 
 typedef struct {
-  int fd;
-  unsigned fb_id;
-  drmModeResPtr mode_res;
-  drmModeFBPtr mode_fb;
-  int cpp;
-  ScrnInfoPtr scrn;
+    int fd;
+    unsigned fb_id;
+    drmModeResPtr mode_res;
+    drmModeFBPtr mode_fb;
+    int cpp;
+    ScrnInfoPtr scrn;
 #ifdef HAVE_UDEV
-  struct udev_monitor *uevent_monitor;
-  InputHandlerProc uevent_handler;
+    struct udev_monitor *uevent_monitor;
+    InputHandlerProc uevent_handler;
 #endif
-  drmEventContext event_context;
-  struct dumb_bo *front_bo;
+    drmEventContext event_context;
+    struct dumb_bo *front_bo;
 } drmmode_rec, *drmmode_ptr;
 
 typedef struct {
-  drmmode_ptr drmmode;
-  unsigned old_fb_id;
-  int flip_count;
-  void *event_data;
-  unsigned int fe_frame;
-  unsigned int fe_tv_sec;
-  unsigned int fe_tv_usec;
-} drmmode_flipdata_rec, *drmmode_flipdata_ptr;
-
-typedef struct {
-  drmmode_flipdata_ptr flipdata;
-  Bool dispatch_me;
-} drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr;
-
-typedef struct {
     drmmode_ptr drmmode;
     drmModeCrtcPtr mode_crtc;
     int hw_id;
     struct dumb_bo *cursor_bo;
-  //    struct radeon_bo *rotate_bo;
     unsigned rotate_fb_id;
     uint16_t lut_r[256], lut_g[256], lut_b[256];
 } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
@@ -103,21 +87,13 @@ typedef struct {
 
 
 extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
-//extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr);
-//extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo);
 void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y, int flags);
 extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
-extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
 
 extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
 extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
 
-extern int drmmode_get_height_align(ScrnInfoPtr scrn, uint32_t tiling);
-extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
-extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
-
-//Bool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *data, int ref_crtc_hw_id);
 Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 void *drmmode_map_front_bo(drmmode_ptr drmmode);
 Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);


More information about the xorg-commit mailing list