Hi Dave,
The following patches are necessary to make the modesetting driver work on !PCI devices. based on 0.2.0.
Sascha
---------------------------------------------------------------- Sascha Hauer (5): fix if() brackets in Probe function introduce open_hw() function make busID non mandatory Fix non PCI device probing do not bail out on non pci devices
src/driver.c | 76 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 39 insertions(+), 37 deletions(-)
in Probe() the indention shows what's meant but there are no brackets. Add them.
Signed-off-by: Sascha Hauer s.hauer@pengutronix.de --- src/driver.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/driver.c b/src/driver.c index d8bb7b5..2004434 100644 --- a/src/driver.c +++ b/src/driver.c @@ -274,7 +274,7 @@ Probe(DriverPtr drv, int flags) NULL, NULL, NULL, NULL); }
- if (scrn) + if (scrn) { foundScreen = TRUE; scrn->driverVersion = 1; scrn->driverName = "modesetting"; @@ -291,6 +291,7 @@ Probe(DriverPtr drv, int flags)
xf86DrvMsg(scrn->scrnIndex, X_INFO, "using %s\n", dev ? dev : "default device"); + } } }
probe_hw opens the hardware in the order we want it: first try devname, if this is NULL then try the KMSDEVICE environment variable and as a last fallback use "/dev/dri/card0". Instead of implementing the same code again when really opening the device move the code to a open_hw() function and let probe_hw use it.
Signed-off-by: Sascha Hauer s.hauer@pengutronix.de --- src/driver.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/driver.c b/src/driver.c index 2004434..dc90e04 100644 --- a/src/driver.c +++ b/src/driver.c @@ -174,7 +174,7 @@ Identify(int flags) Chipsets); }
-static Bool probe_hw(char *dev) +static int open_hw(char *dev) { int fd; if (dev) @@ -186,13 +186,20 @@ static Bool probe_hw(char *dev) fd = open(dev,O_RDWR, 0); } } - if (fd == -1) { + if (fd == -1) xf86DrvMsg(-1, X_ERROR,"open %s: %s\n", dev, strerror(errno)); - return FALSE; - } - close(fd); - return TRUE;
+ return fd; +} + +static Bool probe_hw(char *dev) +{ + int fd = open_hw(dev); + if (fd != -1) { + close(fd); + return TRUE; + } + return FALSE; }
static const OptionInfoRec *
Currently the driver only probes a device when it has a busID. The busID is optional so don't depend on it.
Signed-off-by: Sascha Hauer s.hauer@pengutronix.de --- src/driver.c | 46 ++++++++++++++++++++++------------------------ 1 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/src/driver.c b/src/driver.c index dc90e04..a9422a5 100644 --- a/src/driver.c +++ b/src/driver.c @@ -273,32 +273,30 @@ Probe(DriverPtr drv, int flags) for (i = 0; i < numDevSections; i++) {
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); - } + if (probe_hw(dev)) { + int entity; + entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE); + scrn = xf86ConfigFbEntity(scrn, 0, entity, + NULL, NULL, NULL, NULL); + }
- if (scrn) { - foundScreen = TRUE; - 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, + if (scrn) { + foundScreen = TRUE; + 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"); - } } }
When no devicename is found in the option then the driver probes by PciInfo no matter if it's valid or not. Instead of doing this use PciInfo only when it's valid and fall back to the devicename otherwise. With devicename probing use open_hw() to fall back on the KMSDEVICE environment variable or to the default device.
Signed-off-by: Sascha Hauer s.hauer@pengutronix.de --- src/driver.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/driver.c b/src/driver.c index a9422a5..c7532d3 100644 --- a/src/driver.c +++ b/src/driver.c @@ -416,8 +416,6 @@ PreInit(ScrnInfoPtr pScrn, int flags) if (ms->pEnt->location.type != BUS_PCI) return FALSE;
- ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index); - /* Allocate an entity private if necessary */ if (xf86IsEntityShared(pScrn->entityList[0])) { msEnt = xf86GetEntityPrivate(pScrn->entityList[0], @@ -463,8 +461,8 @@ PreInit(ScrnInfoPtr pScrn, int flags) memcpy(ms->Options, Options, sizeof(Options)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);
- devicename = xf86GetOptValString(ms->Options, OPTION_DEVICE_PATH); - if (!devicename) { + ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index); + if (ms->PciInfo) { BusID = malloc(64); sprintf(BusID, "PCI:%d:%d:%d", #if XSERVER_LIBPCIACCESS @@ -479,7 +477,8 @@ PreInit(ScrnInfoPtr pScrn, int flags)
ms->fd = drmOpen(NULL, BusID); } else { - ms->fd = open(devicename, O_RDWR, 0); + devicename = xf86GetOptValString(ms->Options, OPTION_DEVICE_PATH); + ms->fd = open_hw(devicename); } if (ms->fd < 0) return FALSE;
To make the driver work on nin PCI devices we shouldn't bail out in this case.
Signed-off-by: Sascha Hauer s.hauer@pengutronix.de --- src/driver.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/src/driver.c b/src/driver.c index c7532d3..87431ff 100644 --- a/src/driver.c +++ b/src/driver.c @@ -413,9 +413,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
pScrn->displayWidth = 640; /* default it */
- if (ms->pEnt->location.type != BUS_PCI) - return FALSE; - /* Allocate an entity private if necessary */ if (xf86IsEntityShared(pScrn->entityList[0])) { msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
dri-devel@lists.freedesktop.org