aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Salveti de Araujo2012-08-22 22:51:15 -0500
committerRob Clark2012-08-23 14:37:58 -0500
commit041314709f1bdfbe1544dab32fdc68e9bd59186b (patch)
treee558ca13dac3027b49c339eee1fad1be9f504e48
parent8c19eee2ebe41e8d6c79ae88edbca1d590f451dc (diff)
downloadxf86-video-omap-041314709f1bdfbe1544dab32fdc68e9bd59186b.tar.gz
xf86-video-omap-041314709f1bdfbe1544dab32fdc68e9bd59186b.tar.xz
xf86-video-omap-041314709f1bdfbe1544dab32fdc68e9bd59186b.zip
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);
54static Bool OMAPEnterVT(VT_FUNC_ARGS_DECL); 54static Bool OMAPEnterVT(VT_FUNC_ARGS_DECL);
55static void OMAPLeaveVT(VT_FUNC_ARGS_DECL); 55static void OMAPLeaveVT(VT_FUNC_ARGS_DECL);
56static void OMAPFreeScreen(FREE_SCREEN_ARGS_DECL); 56static void OMAPFreeScreen(FREE_SCREEN_ARGS_DECL);
57#ifdef XSERVER_PLATFORM_BUS
58static Bool OMAPPlatformProbe(DriverPtr drv, int entity_num, int flags,
59 struct xf86_platform_device *dev, intptr_t match_data);
60#endif
57 61
58 62
59 63
@@ -74,7 +78,10 @@ _X_EXPORT DriverRec OMAP = {
74 NULL, 78 NULL,
75#ifdef XSERVER_LIBPCIACCESS 79#ifdef XSERVER_LIBPCIACCESS
76 NULL, 80 NULL,
77 NULL 81 NULL,
82#endif
83#ifdef XSERVER_PLATFORM_BUS
84 OMAPPlatformProbe,
78#endif 85#endif
79}; 86};
80 87
@@ -259,7 +266,11 @@ OMAPSetup(pointer module, pointer opts, int *errmaj, int *errmin)
259 /* This module should be loaded only once, but check to be sure: */ 266 /* This module should be loaded only once, but check to be sure: */
260 if (!setupDone) { 267 if (!setupDone) {
261 setupDone = TRUE; 268 setupDone = TRUE;
269#ifdef XSERVER_PLATFORM_BUS
270 xf86AddDriver(&OMAP, module, HaveDriverFuncs);
271#else
262 xf86AddDriver(&OMAP, module, 0); 272 xf86AddDriver(&OMAP, module, 0);
273#endif
263 274
264 /* The return value must be non-NULL on success even though there is no 275 /* The return value must be non-NULL on success even though there is no
265 * TearDownProc. 276 * TearDownProc.
@@ -427,6 +438,7 @@ OMAPPreInit(ScrnInfoPtr pScrn, int flags)
427 rgb defaultWeight = { 0, 0, 0 }; 438 rgb defaultWeight = { 0, 0, 0 };
428 rgb defaultMask = { 0, 0, 0 }; 439 rgb defaultMask = { 0, 0, 0 };
429 Gamma defaultGamma = { 0.0, 0.0, 0.0 }; 440 Gamma defaultGamma = { 0.0, 0.0, 0.0 };
441 EntityInfoPtr pEnt;
430 uint64_t value; 442 uint64_t value;
431 int i; 443 int i;
432 444
@@ -449,7 +461,8 @@ OMAPPreInit(ScrnInfoPtr pScrn, int flags)
449 OMAPGetRec(pScrn); 461 OMAPGetRec(pScrn);
450 pOMAP = OMAPPTR(pScrn); 462 pOMAP = OMAPPTR(pScrn);
451 463
452 pOMAP->pEntityInfo = xf86GetEntityInfo(pScrn->entityList[0]); 464 pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
465 pOMAP->pEntityInfo = pEnt;
453 466
454 pScrn->monitor = pScrn->confScreen->monitor; 467 pScrn->monitor = pScrn->confScreen->monitor;
455 468
@@ -492,7 +505,17 @@ OMAPPreInit(ScrnInfoPtr pScrn, int flags)
492 /* Using a programmable clock: */ 505 /* Using a programmable clock: */
493 pScrn->progClock = TRUE; 506 pScrn->progClock = TRUE;
494 507
495 /* Open a connection to the DRM, so we can communicate with the KMS code: */ 508#ifdef XSERVER_PLATFORM_BUS
509 if (pEnt->location.type == BUS_PLATFORM) {
510 char *busid = xf86_get_platform_device_attrib(pEnt->location.id.plat,
511 ODEV_ATTRIB_BUSID);
512 pOMAP->drmFD = drmOpen(NULL, busid);
513 if (pOMAP->drmFD < 0)
514 goto fail;
515 pOMAP->deviceName = drmGetDeviceNameFromFd(pOMAP->drmFD);
516 }
517 else
518#endif
496 if (!OMAPOpenDRMMaster(pScrn, 0)) { 519 if (!OMAPOpenDRMMaster(pScrn, 0)) {
497 goto fail; 520 goto fail;
498 } 521 }
@@ -1059,3 +1082,42 @@ OMAPFreeScreen(FREE_SCREEN_ARGS_DECL)
1059 TRACE_EXIT(); 1082 TRACE_EXIT();
1060} 1083}
1061 1084
1085#ifdef XSERVER_PLATFORM_BUS
1086static Bool
1087OMAPPlatformProbe(DriverPtr drv, int entity_num, int flags,
1088 struct xf86_platform_device *dev, intptr_t match_data)
1089{
1090 ScrnInfoPtr pScrn = NULL;
1091 Bool foundScreen = FALSE;
1092 char *busid = xf86_get_platform_device_attrib(dev, ODEV_ATTRIB_BUSID);
1093 int fd;
1094
1095 fd = drmOpen(NULL, busid);
1096 if (fd != -1) {
1097 pScrn = xf86AllocateScreen(drv, 0);
1098 if (!pScrn) {
1099 EARLY_ERROR_MSG("Cannot allocate a ScrnInfoPtr");
1100 return FALSE;
1101 }
1102
1103 xf86AddEntityToScreen(pScrn, entity_num);
1104 foundScreen = TRUE;
1105
1106 pScrn->driverVersion = OMAP_VERSION;
1107 pScrn->driverName = (char *)OMAP_DRIVER_NAME;
1108 pScrn->name = (char *)OMAP_NAME;
1109 pScrn->Probe = OMAPProbe;
1110 pScrn->PreInit = OMAPPreInit;
1111 pScrn->ScreenInit = OMAPScreenInit;
1112 pScrn->SwitchMode = OMAPSwitchMode;
1113 pScrn->AdjustFrame = OMAPAdjustFrame;
1114 pScrn->EnterVT = OMAPEnterVT;
1115 pScrn->LeaveVT = OMAPLeaveVT;
1116 pScrn->FreeScreen = OMAPFreeScreen;
1117
1118 drmClose(fd);
1119 }
1120
1121 return foundScreen;
1122}
1123#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 @@
56#include "xf86drm.h" 56#include "xf86drm.h"
57#include "drm_fourcc.h" 57#include "drm_fourcc.h"
58#include "dri2.h" 58#include "dri2.h"
59#ifdef XSERVER_PLATFORM_BUS
60#include "xf86platformBus.h"
61#endif
59 62
60#include <omap_drm.h> 63#include <omap_drm.h>
61#include <omap_drmif.h> 64#include <omap_drmif.h>