summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Salveti de Araujo <ricardo.salveti@linaro.org>2012-08-23 00:51:15 -0300
committerRob Clark <rob@ti.com>2012-08-23 14:37:58 -0500
commit041314709f1bdfbe1544dab32fdc68e9bd59186b (patch)
treee558ca13dac3027b49c339eee1fad1be9f504e48
parent8c19eee2ebe41e8d6c79ae88edbca1d590f451dc (diff)
omap: add support for PlatformProbe
Since xorg 1.12.99.901 we now have support for platform devices, which is already responsible for looking over the devices from udev, and setting up the device attributes, entity and platform slot, simplifying the probe method. The old probe function is still valid, and also used in case there's no platform support, so this change only affects users building the driver agains the latest xorg release. Signed-off-by: Ricardo Salveti de Araujo <ricardo.salveti@linaro.org> Signed-off-by: Rob Clark <rob@ti.com>
-rw-r--r--src/omap_driver.c68
-rw-r--r--src/omap_driver.h3
2 files changed, 68 insertions, 3 deletions
diff --git a/src/omap_driver.c b/src/omap_driver.c
index 86862bc..983d24c 100644
--- a/src/omap_driver.c
+++ b/src/omap_driver.c
@@ -54,6 +54,10 @@ static void OMAPAdjustFrame(ADJUST_FRAME_ARGS_DECL);
static Bool OMAPEnterVT(VT_FUNC_ARGS_DECL);
static void OMAPLeaveVT(VT_FUNC_ARGS_DECL);
static void OMAPFreeScreen(FREE_SCREEN_ARGS_DECL);
+#ifdef XSERVER_PLATFORM_BUS
+static Bool OMAPPlatformProbe(DriverPtr drv, int entity_num, int flags,
+ struct xf86_platform_device *dev, intptr_t match_data);
+#endif
@@ -74,7 +78,10 @@ _X_EXPORT DriverRec OMAP = {
NULL,
#ifdef XSERVER_LIBPCIACCESS
NULL,
- NULL
+ NULL,
+#endif
+#ifdef XSERVER_PLATFORM_BUS
+ OMAPPlatformProbe,
#endif
};
@@ -259,7 +266,11 @@ OMAPSetup(pointer module, pointer opts, int *errmaj, int *errmin)
/* This module should be loaded only once, but check to be sure: */
if (!setupDone) {
setupDone = TRUE;
+#ifdef XSERVER_PLATFORM_BUS
+ xf86AddDriver(&OMAP, module, HaveDriverFuncs);
+#else
xf86AddDriver(&OMAP, module, 0);
+#endif
/* The return value must be non-NULL on success even though there is no
* TearDownProc.
@@ -427,6 +438,7 @@ OMAPPreInit(ScrnInfoPtr pScrn, int flags)
rgb defaultWeight = { 0, 0, 0 };
rgb defaultMask = { 0, 0, 0 };
Gamma defaultGamma = { 0.0, 0.0, 0.0 };
+ EntityInfoPtr pEnt;
uint64_t value;
int i;
@@ -449,7 +461,8 @@ OMAPPreInit(ScrnInfoPtr pScrn, int flags)
OMAPGetRec(pScrn);
pOMAP = OMAPPTR(pScrn);
- pOMAP->pEntityInfo = xf86GetEntityInfo(pScrn->entityList[0]);
+ pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+ pOMAP->pEntityInfo = pEnt;
pScrn->monitor = pScrn->confScreen->monitor;
@@ -492,7 +505,17 @@ OMAPPreInit(ScrnInfoPtr pScrn, int flags)
/* Using a programmable clock: */
pScrn->progClock = TRUE;
- /* Open a connection to the DRM, so we can communicate with the KMS code: */
+#ifdef XSERVER_PLATFORM_BUS
+ if (pEnt->location.type == BUS_PLATFORM) {
+ char *busid = xf86_get_platform_device_attrib(pEnt->location.id.plat,
+ ODEV_ATTRIB_BUSID);
+ pOMAP->drmFD = drmOpen(NULL, busid);
+ if (pOMAP->drmFD < 0)
+ goto fail;
+ pOMAP->deviceName = drmGetDeviceNameFromFd(pOMAP->drmFD);
+ }
+ else
+#endif
if (!OMAPOpenDRMMaster(pScrn, 0)) {
goto fail;
}
@@ -1059,3 +1082,42 @@ OMAPFreeScreen(FREE_SCREEN_ARGS_DECL)
TRACE_EXIT();
}
+#ifdef XSERVER_PLATFORM_BUS
+static Bool
+OMAPPlatformProbe(DriverPtr drv, int entity_num, int flags,
+ struct xf86_platform_device *dev, intptr_t match_data)
+{
+ ScrnInfoPtr pScrn = NULL;
+ Bool foundScreen = FALSE;
+ char *busid = xf86_get_platform_device_attrib(dev, ODEV_ATTRIB_BUSID);
+ int fd;
+
+ fd = drmOpen(NULL, busid);
+ if (fd != -1) {
+ pScrn = xf86AllocateScreen(drv, 0);
+ if (!pScrn) {
+ EARLY_ERROR_MSG("Cannot allocate a ScrnInfoPtr");
+ return FALSE;
+ }
+
+ xf86AddEntityToScreen(pScrn, entity_num);
+ foundScreen = TRUE;
+
+ pScrn->driverVersion = OMAP_VERSION;
+ pScrn->driverName = (char *)OMAP_DRIVER_NAME;
+ pScrn->name = (char *)OMAP_NAME;
+ pScrn->Probe = OMAPProbe;
+ pScrn->PreInit = OMAPPreInit;
+ pScrn->ScreenInit = OMAPScreenInit;
+ pScrn->SwitchMode = OMAPSwitchMode;
+ pScrn->AdjustFrame = OMAPAdjustFrame;
+ pScrn->EnterVT = OMAPEnterVT;
+ pScrn->LeaveVT = OMAPLeaveVT;
+ pScrn->FreeScreen = OMAPFreeScreen;
+
+ drmClose(fd);
+ }
+
+ return foundScreen;
+}
+#endif
diff --git a/src/omap_driver.h b/src/omap_driver.h
index aa639fc..7bfedc0 100644
--- a/src/omap_driver.h
+++ b/src/omap_driver.h
@@ -56,6 +56,9 @@
#include "xf86drm.h"
#include "drm_fourcc.h"
#include "dri2.h"
+#ifdef XSERVER_PLATFORM_BUS
+#include "xf86platformBus.h"
+#endif
#include <omap_drm.h>
#include <omap_drmif.h>