summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2010-01-13 11:35:52 -0800
committerKeith Packard <keithp@keithp.com>2010-01-27 13:57:00 -0800
commitf311f2d047120fb816897444d2101465ff5189db (patch)
treef8e9f9fde18eb0f254cd8ee03a02f0fcf4240157
parentf57bc0ede8e018c7e264b917927c42a018cd1d5a (diff)
DRI2: Allow multiple driver names.
Each driver type (e.g. DRI2DriverDRI or DRI2DriverVDPAU) can have a name in the driverNames array in DRI2InfoRec. DRI2Connect returns the name for the driver specified by driverType. Also print names of supported drivers in DRI2ScreenInit. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--hw/xfree86/dri2/dri2.c44
-rw-r--r--hw/xfree86/dri2/dri2.h9
2 files changed, 46 insertions, 7 deletions
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 3db826e91..3d0fa75ec 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -70,7 +70,8 @@ typedef struct _DRI2Drawable {
typedef struct _DRI2Screen *DRI2ScreenPtr;
typedef struct _DRI2Screen {
- const char *driverName;
+ unsigned int numDrivers;
+ const char **driverNames;
const char *deviceName;
int fd;
unsigned int lastSequence;
@@ -772,14 +773,12 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
{
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
- if (ds == NULL)
+ if (ds == NULL || driverType >= ds->numDrivers ||
+ !ds->driverNames[driverType])
return FALSE;
- if (driverType != DRI2DriverDRI)
- return BadValue;
-
*fd = ds->fd;
- *driverName = ds->driverName;
+ *driverName = ds->driverNames[driverType];
*deviceName = ds->deviceName;
return TRUE;
@@ -800,6 +799,11 @@ Bool
DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
{
DRI2ScreenPtr ds;
+ const char* driverTypeNames[] = {
+ "DRI", /* DRI2DriverDRI */
+ "VDPAU", /* DRI2DriverVDPAU */
+ };
+ unsigned int i;
if (info->version < 3)
return FALSE;
@@ -815,7 +819,6 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
return FALSE;
ds->fd = info->fd;
- ds->driverName = info->driverName;
ds->deviceName = info->deviceName;
ds->CreateBuffer = info->CreateBuffer;
@@ -828,9 +831,35 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
ds->GetMSC = info->GetMSC;
}
+ if (info->version == 3 || info->numDrivers == 0) {
+ /* Driver too old: use the old-style driverName field */
+ ds->numDrivers = 1;
+ ds->driverNames = xalloc(sizeof(*ds->driverNames));
+ if (!ds->driverNames) {
+ xfree(ds);
+ return FALSE;
+ }
+ ds->driverNames[0] = info->driverName;
+ } else {
+ ds->numDrivers = info->numDrivers;
+ ds->driverNames = xalloc(info->numDrivers * sizeof(*ds->driverNames));
+ if (!ds->driverNames) {
+ xfree(ds);
+ return FALSE;
+ }
+ memcpy(ds->driverNames, info->driverNames,
+ info->numDrivers * sizeof(*ds->driverNames));
+ }
+
dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
+ for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
+ if (i < ds->numDrivers && ds->driverNames[i]) {
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
+ driverTypeNames[i], ds->driverNames[i]);
+ }
+ }
return TRUE;
}
@@ -840,6 +869,7 @@ DRI2CloseScreen(ScreenPtr pScreen)
{
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+ xfree(ds->driverNames);
xfree(ds);
dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
}
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index dd59297df..1c8626b44 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -164,9 +164,18 @@ typedef struct {
DRI2DestroyBufferProcPtr DestroyBuffer;
DRI2CopyRegionProcPtr CopyRegion;
DRI2WaitProcPtr Wait;
+
+ /* added in version 4 */
+
DRI2ScheduleSwapProcPtr ScheduleSwap;
DRI2GetMSCProcPtr GetMSC;
DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
+
+ /* number of drivers in the driverNames array */
+ unsigned int numDrivers;
+ /* array of driver names, indexed by DRI2Driver* driver types */
+ /* a name of NULL means that driver is not supported */
+ const char * const *driverNames;
} DRI2InfoRec, *DRI2InfoPtr;
extern _X_EXPORT int DRI2EventBase;