summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-06-27 13:48:34 +0100
committerDave Airlie <airlied@redhat.com>2012-09-19 13:17:21 +1000
commit72829f53389b8d9c27ee2d088ce59436372374fa (patch)
tree39b7a2c50e839e9eeb2710831b5e1c4fb54cf78c
parent127847d4b6f929294cf8868beae9d1412515777a (diff)
xf86: initial GPU screens for all
-rw-r--r--hw/xfree86/common/Makefile.am2
-rw-r--r--hw/xfree86/common/xf86Bus.c37
-rw-r--r--hw/xfree86/common/xf86Cursor.c3
-rw-r--r--hw/xfree86/common/xf86Helper.c9
-rw-r--r--hw/xfree86/common/xf86Imped.c209
-rw-r--r--hw/xfree86/common/xf86Init.c13
-rw-r--r--hw/xfree86/common/xf86Priv.h2
-rw-r--r--hw/xfree86/common/xf86platformBus.c4
8 files changed, 268 insertions, 11 deletions
diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index f8fcde956..5fa8e833d 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -47,7 +47,7 @@ libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \
xf86VidMode.c xf86fbman.c xf86cmap.c \
xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
xf86Mode.c xorgHelper.c xf86Extensions.h \
- xf86Extensions.c xf86vmode.c \
+ xf86Extensions.c xf86vmode.c xf86Imped.c\
$(XVSOURCES) $(BUSSOURCES) $(RANDRSOURCES)
nodist_libcommon_la_SOURCES = xf86DefModeSet.c xf86Build.h
libcommon_la_LIBADD = $(top_builddir)/config/libconfig.la
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 40f492194..fc173f300 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -115,7 +115,7 @@ Bool
xf86BusConfig(void)
{
screenLayoutPtr layout;
- int i, j;
+ int i, j, k;
/* Enable full I/O access */
if (xorgHWAccess)
@@ -142,7 +142,7 @@ xf86BusConfig(void)
}
/* If nothing was detected, return now */
- if (xf86NumScreens == 0) {
+ if (xf86NumScreens == 0 && xf86NumGPUScreens == 0) {
xf86Msg(X_ERROR, "No devices detected.\n");
return FALSE;
}
@@ -191,12 +191,41 @@ xf86BusConfig(void)
}
}
+ for (i = 0; i < xf86NumGPUScreens; i++) {
+ for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
+ layout++) {
+ Bool found = FALSE;
+
+ for (j = 0; j < xf86GPUScreens[i]->numEntities; j++) {
+ GDevPtr dev = xf86GetDevFromEntity(xf86GPUScreens[i]->entityList[j],
+ xf86GPUScreens[i]->entityInstanceList[j]);
+ if (dev == layout->screen->device) {
+ /* A match has been found */
+ xf86GPUScreens[i]->confScreen = layout->screen;
+ found = TRUE;
+ break;
+ }
+ if (found)
+ break;
+ }
+ if (found)
+ break;
+ }
+ if (layout->screen == NULL) {
+ /* No match found */
+ xf86Msg(X_ERROR,
+ "GPU Screen %d deleted because no matching config section.\n", i);
+ xf86DeleteScreen(xf86GPUScreens[i--]);
+ }
+ }
+
+#if 0
/* bind GPU conf screen to protocol screen 0 */
for (i = 0; i < xf86NumGPUScreens; i++)
xf86GPUScreens[i]->confScreen = xf86Screens[0]->confScreen;
-
+#endif
/* If no screens left, return now. */
- if (xf86NumScreens == 0) {
+ if (xf86NumScreens == 0 && xf86NumGPUScreens == 0) {
xf86Msg(X_ERROR,
"Device(s) detected, but none match those in the config file.\n");
return FALSE;
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 65a9e8264..6be0ff60a 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -92,6 +92,9 @@ void
xf86InitViewport(ScrnInfoPtr pScr)
{
+ if (!pScr->modes)
+ return;
+
pScr->PointerMoved = xf86PointerMoved;
/*
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index f681a8577..c9db05669 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -198,10 +198,11 @@ xf86AllocateScreen(DriverPtr drv, int flags)
*/
pScrn->drv = drv;
- drv->refCount++;
- pScrn->module = DuplicateModule(drv->module, NULL);
-
- pScrn->DriverFunc = drv->driverFunc;
+ if (drv) {
+ drv->refCount++;
+ pScrn->module = DuplicateModule(drv->module, NULL);
+ pScrn->DriverFunc = drv->driverFunc;
+ }
return pScrn;
}
diff --git a/hw/xfree86/common/xf86Imped.c b/hw/xfree86/common/xf86Imped.c
new file mode 100644
index 000000000..bb27504fe
--- /dev/null
+++ b/hw/xfree86/common/xf86Imped.c
@@ -0,0 +1,209 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "servermd.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+
+#include "xf86.h"
+#include "mipointer.h"
+#include "micmap.h"
+#include "impedance.h"
+#include "xf86Priv.h"
+#include "xf86Crtc.h"
+
+Bool (*drv_dri2_hook)(ScreenPtr);
+
+static void xf86FixupRGBOrdering(ScrnInfoPtr scrn, ScreenPtr screen)
+{
+ VisualPtr visual;
+ visual = screen->visuals + screen->numVisuals;
+ while (--visual >= screen->visuals) {
+ if ((visual->class | DynamicClass) == DirectColor) {
+ visual->offsetRed = scrn->offset.red;
+ visual->offsetGreen = scrn->offset.green;
+ visual->offsetBlue = scrn->offset.blue;
+ visual->redMask = scrn->mask.red;
+ visual->greenMask = scrn->mask.green;
+ visual->blueMask = scrn->mask.blue;
+ }
+ }
+}
+
+static Bool impedSaveScreen(ScreenPtr pScreen, int mode)
+{
+ return TRUE;
+}
+
+static Bool
+impedHelperScreenInit(ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ int width = 0, height = 0;
+ int i;
+ Bool allow_slave = FALSE;
+ ScrnInfoPtr master = NULL;
+
+ if (!impedSetupScreen(pScreen))
+ return FALSE;
+
+retry:
+ for (i = 0; i < xf86NumGPUScreens; i++) {
+ if (xf86GPUScreens[i]->confScreen->screennum != pScreen->myNum)
+ continue;
+
+ if (allow_slave) {
+ if (!(xf86GPUScreens[i]->roles & RR_Role_Slave_Output))
+ continue;
+ }
+ else if (!(xf86GPUScreens[i]->roles & RR_Role_Master))
+ continue;
+
+ if (xf86GPUScreens[i]->numEntities != 1)
+ continue;
+
+ if (!xf86IsEntityPrimary(xf86GPUScreens[i]->entityList[0]))
+ continue;
+
+ master = xf86GPUScreens[i];
+
+ if (xf86GPUScreens[i]->virtualX > width)
+ width = xf86GPUScreens[i]->virtualX;
+
+ if (xf86GPUScreens[i]->virtualY > height)
+ height = xf86GPUScreens[i]->virtualY;
+ ErrorF("attaching %s as primary master\n", xf86GPUScreens[i]->driverName);
+ AttachGPU(pScreen, xf86GPUScreens[i]->pScreen);
+ xf86SetCurrentRole(xf86GPUScreens[i], RR_Role_Master);
+ break;
+ }
+
+ if (!master && !allow_slave) {
+ allow_slave = TRUE;
+ goto retry;
+ }
+ if (!master) {
+ ErrorF("cannot find master device\n");
+ return FALSE;
+ }
+
+ for (i = 0; i < xf86NumGPUScreens; i++) {
+ if (xf86GPUScreens[i]->confScreen->screennum != pScreen->myNum)
+ continue;
+
+ if (xf86GPUScreens[i]->current_role)
+ continue;
+
+ if (xf86GPUScreens[i]->roles & RR_Role_Slave_Offload) {
+ ErrorF("want to attach %s as offload slave\n", xf86GPUScreens[i]->driverName);
+ AttachOffloadGPU(master->pScreen, xf86GPUScreens[i]->pScreen);
+ xf86SetCurrentRole(xf86GPUScreens[i], RR_Role_Slave_Offload);
+ }
+ }
+
+ for (i = 0; i < xf86NumGPUScreens; i++) {
+ if (xf86GPUScreens[i]->confScreen->screennum != pScreen->myNum)
+ continue;
+
+ if (xf86GPUScreens[i]->current_role)
+ continue;
+ ErrorF("want tot attach %s to unbound list\n", xf86GPUScreens[i]->driverName);
+ AttachUnboundGPU(pScreen, xf86GPUScreens[i]->pScreen);
+ }
+
+ if (!impedFinishScreenInit(pScreen, NULL, width, height,
+ 75, 75,
+ master->displayWidth, master->bitsPerPixel))
+ return FALSE;
+
+ // xf86FixupRGBOrdering(master, pScreen);
+ if (!impedPictureInit(pScreen, 0, 0))
+ return FALSE;
+
+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+ if (!miCreateDefColormap (pScreen)) {
+ return FALSE;
+ }
+
+ /* do dri2 init */
+ if (xf86LoaderCheckSymbol("DRI2Connect") && drv_dri2_hook)
+ drv_dri2_hook(pScreen);
+
+ pScreen->SaveScreen = impedSaveScreen;
+ xf86DisableRandR(); /* disable old randr extension */
+
+ /* need to create a dumb randr 12 to handle protocol stuff */
+ // impedRandR12Init(pScreen);
+ return TRUE;
+}
+
+static void impedPointerMoved(ScrnInfoPtr pScrn, int x, int y)
+{
+}
+
+static void
+impedLeaveVT(ScrnInfoPtr pScrn)
+{
+
+}
+
+static Bool
+impedEnterVT(ScrnInfoPtr pScrn)
+{
+ return TRUE;
+}
+
+void xf86ImpedAddProtoScreens(int screennum)
+{
+ ScrnInfoPtr pScrn;
+ Pix24Flags screenpix24;
+ ScrnInfoPtr first = NULL;
+ int i;
+
+ pScrn = xf86AllocateScreen(NULL, 0);
+ pScrn->ScreenInit = impedHelperScreenInit;
+ pScrn->PointerMoved = impedPointerMoved;
+ pScrn->LeaveVT = impedLeaveVT;
+ pScrn->EnterVT = impedEnterVT;
+ screenpix24 = Pix24DontCare;
+ for (i = 0; i < xf86NumGPUScreens; i++) {
+ if (xf86GPUScreens[i]->confScreen->screennum != screennum)
+ continue;
+
+ if (!first) {
+ first = xf86GPUScreens[i];
+ if (first->pixmap24 != Pix24DontCare)
+ screenpix24 = first->pixmap24;
+ continue;
+ }
+ /* sort out inconsistencies */
+ if (first->imageByteOrder != xf86GPUScreens[i]->imageByteOrder)
+ FatalError("Inconsistent display imageByteOrder. Exiting\n");
+
+ if (first->bitmapScanlinePad != xf86GPUScreens[i]->bitmapScanlinePad)
+ FatalError("Inconsistent display bitmapScanlinePad. Exiting\n");
+
+ if (first->bitmapScanlineUnit != xf86GPUScreens[i]->bitmapScanlineUnit)
+ FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n");
+
+ if (first->bitmapBitOrder != xf86GPUScreens[i]->bitmapBitOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+
+ if (xf86GPUScreens[i]->pixmap24 != Pix24DontCare) {
+ if (screenpix24 == Pix24DontCare)
+ screenpix24 = xf86GPUScreens[i]->pixmap24;
+ else if (screenpix24 != xf86GPUScreens[i]->pixmap24)
+ FatalError("Inconsistent depth 24 pixmap format. Exiting\n");
+ }
+ }
+ pScrn->imageByteOrder = first->imageByteOrder;
+ pScrn->bitmapScanlinePad = first->bitmapScanlinePad;
+ pScrn->bitmapScanlineUnit = first->bitmapScanlineUnit;
+ pScrn->bitmapBitOrder = first->bitmapBitOrder;
+ pScrn->pixmap24 = first->pixmap24;
+
+}
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index e4a6b8613..4581e43c5 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -612,7 +612,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
* If no screens left, return now.
*/
- if (xf86NumScreens == 0) {
+ if (xf86NumScreens == 0 && xf86NumGPUScreens == 0) {
xf86Msg(X_ERROR,
"Screen(s) found, but none have a usable configuration.\n");
return;
@@ -636,6 +636,17 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
* At this stage we know how many screens there are.
*/
+ if (xf86NumGPUScreens > 0) {
+ int total_proto_screens = -1;
+ for (i = 0; i < xf86NumGPUScreens; i++) {
+ if (xf86GPUScreens[i]->confScreen->screennum > total_proto_screens)
+ total_proto_screens = xf86GPUScreens[i]->confScreen->screennum;
+ }
+ total_proto_screens++;
+ for (i = 0; i < total_proto_screens; i++)
+ xf86ImpedAddProtoScreens(i);
+ }
+
for (i = 0; i < xf86NumScreens; i++)
xf86InitViewport(xf86Screens[i]);
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index c9f2e7eb8..79bcc858f 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -167,6 +167,8 @@ xf86CallDriverProbe(struct _DriverRec *drv, Bool detect_only);
extern _X_EXPORT Bool
xf86PrivsElevated(void);
+extern _X_EXPORT void
+xf86ImpedAddProtoScreens(int screennum);
#endif /* _NO_XF86_PROTOTYPES */
#endif /* _XF86PRIV_H */
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 24eaf8f9b..353dc589c 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -372,7 +372,9 @@ xf86platformProbeDev(DriverPtr drvp)
if (j == xf86_num_platform_devices)
continue;
- foundScreen = probeSingleDevice(&xf86_platform_devices[j], drvp, devList[i], 0);
+ foundScreen = probeSingleDevice(&xf86_platform_devices[j], drvp, devList[i], PLATFORM_PROBE_GPU_SCREEN);
+ if (!foundScreen)
+ foundScreen = probeSingleDevice(&xf86_platform_devices[j], drvp, devList[i], 0);
if (!foundScreen)
continue;
}