summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-07-21 01:53:45 +0100
committerThomas White <taw@bitwiz.org.uk>2009-07-21 01:53:45 +0100
commit72a3fcc25d026941c0a202cbc6364326b979c767 (patch)
tree6ac64c700a095ea1975f513cec907dd63983df1b
parent6bd6ca43176dccac91fd5ddffeb0da81f0bcd6f6 (diff)
Makefile and initialisation stuff
-rw-r--r--src/Makefile.am3
-rw-r--r--src/glamo-driver.c4
-rw-r--r--src/glamo-kms-driver.c217
-rw-r--r--src/glamo-kms-driver.h3
-rw-r--r--src/glamo.h3
5 files changed, 224 insertions, 6 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d229347..f69adb1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,4 +35,5 @@ glamo_drv_la_SOURCES = \
glamo-draw.c \
glamo-display.c \
glamo-output.c \
- glamo-engine.c
+ glamo-engine.c \
+ glamo-kms-driver.c
diff --git a/src/glamo-driver.c b/src/glamo-driver.c
index 9debf57..a8541f3 100644
--- a/src/glamo-driver.c
+++ b/src/glamo-driver.c
@@ -37,6 +37,7 @@
#include "glamo.h"
#include "glamo-regs.h"
+#include "glamo-kms.driver.h"
#include <fcntl.h>
#include <unistd.h>
@@ -301,6 +302,7 @@ GlamoProbe(DriverPtr drv, int flags)
foundScreen = TRUE;
+ /* Plug in KMS functions instead of the conventional ones */
pScrn->driverVersion = GLAMO_VERSION;
pScrn->driverName = GLAMO_DRIVER_NAME;
pScrn->name = GLAMO_NAME;
@@ -316,6 +318,8 @@ GlamoProbe(DriverPtr drv, int flags)
} else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Not using KMS");
+
if (!xf86LoadDrvSubModule(drv, "fbdevhw"))
return FALSE;
diff --git a/src/glamo-kms-driver.c b/src/glamo-kms-driver.c
index 5102f4b..5bd58e5 100644
--- a/src/glamo-kms-driver.c
+++ b/src/glamo-kms-driver.c
@@ -18,34 +18,241 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
+ *
+ * The KMS parts of this driver are based on xf86-video-modesetting, to
+ * which the following notice applies:
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ *
*/
+
+#include <sys/types.h>
+#include <dirent.h>
+
+#include "xf86.h"
+
+
+static int modesettingEntityIndex = -1;
+
+
+/* Return TRUE if KMS can be used */
+Bool GlamoKernelModesettingAvailable()
+{
+ DIR *dir;
+ struct dirent *ent;
+
+ dir = opendir("/sys/bus/platform/devices/glamo-fb.0/");
+ if ( !dir ) return FALSE;
+
+ do {
+
+ ent = readdir(dir);
+
+ if ( strncmp(ent->d_name, "drm:controlD", 12) == 0 ) {
+ closedir(dir);
+ return TRUE;
+ }
+
+ } while ( ent )
+
+ closedir(dir);
+ return FALSE;
+}
+
+
Bool GlamoKMSPreInit(ScrnInfoPtr pScrn, int flags)
{
+ xf86CrtcConfigPtr xf86_config;
+ GlamoPtr pGlamo;
+ MessageType from = X_PROBED;
+ rgb defaultWeight = { 0, 0, 0 };
+ EntityInfoPtr pEnt;
+ EntPtr glamoEnt = NULL;
+ char *BusID;
+ int i;
+ char *s;
+ int num_pipe;
+ int max_width, max_height;
+
+ if ( pScrn->numEntities != 1 ) return FALSE;
+
+ pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+
+ /* Can't do this yet */
+ if ( flags & PROBE_DETECT ) {
+ ConfiguredMonitor = NULL;
+ return TRUE;
+ }
+
+ /* Allocate driverPrivate */
+ if ( !GlamoGetRec(pScrn) ) return FALSE;
+ pGlamo = GlamoPTR(pScrn);
+ pGlamo->SaveGeneration = -1;
+ pGlamo->pEnt = pEnt;
+
+ pScrn->displayWidth = 640; /* default it */
+
+ /* Allocate an entity private if necessary */
+ if ( xf86IsEntityShared(pScrn->entityList[0]) ) {
+ msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
+ modesettingEntityIndex)->ptr;
+ pGlamo->entityPrivate = msEnt;
+ } else {
+ pGlamo->entityPrivate = NULL;
+ }
+
+ if ( xf86RegisterResources(ms->pEnt->index, NULL, ResNone) ) {
+ return FALSE;
+ }
+
+ if ( xf86IsEntityShared(pScrn->entityList[0]) ) {
+ if ( xf86IsPrimInitDone(pScrn->entityList[0]) ) {
+ /* do something */
+ } else {
+ xf86SetPrimInitDone(pScrn->entityList[0]);
+ }
+ }
+
+ pGlamo->drm_fd = drmOpen(NULL, "platform:glamo-fb");
+
+ if ( ms->fd < 0 ) return FALSE;
+
+ pScrn->racMemFlags = RAC_FB | RAC_COLORMAP;
+ pScrn->monitor = pScrn->confScreen->monitor;
+ pScrn->progClock = TRUE;
+ pScrn->rgbBits = 8;
+
+ if ( !xf86SetDepthBpp (pScrn, 0, 0, 0
+ PreferConvert24to32
+ | SupportConvert24to32
+ | Support32bppFb))
+ return FALSE;
+
+ if ( pScrn->depth != 16 ) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by the driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ xf86PrintDepthBpp(pScrn);
+
+ if ( !xf86SetWeight(pScrn, defaultWeight, defaultWeight) ) return FALSE;
+ if ( !xf86SetDefaultVisual(pScrn, -1) ) return FALSE;
+
+ /* Process the options */
+ xf86CollectOptions(pScrn, NULL);
+ if ( !(ms->Options = xalloc(sizeof(Options))) ) return FALSE;
+ memcpy(ms->Options, Options, sizeof(Options));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);
+
+ /* Allocate an xf86CrtcConfig */
+ xf86CrtcConfigInit(pScrn, &crtc_config_funcs);
+ xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+
+ max_width = 8192;
+ max_height = 8192;
+ xf86CrtcSetSizeRange(pScrn, 320, 200, max_width, max_height);
+
+ if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) {
+ ms->SWCursor = TRUE;
+ }
+
+ SaveHWState(pScrn);
+
+ crtc_init(pScrn);
+ output_init(pScrn);
+
+ if (!xf86InitialConfiguration(pScrn, TRUE)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n");
+ RestoreHWState(pScrn);
+ return FALSE;
+ }
+
+ RestoreHWState(pScrn);
+
+ /*
+ * If the driver can do gamma correction, it should call xf86SetGamma() here.
+ */
+ {
+ Gamma zeros = { 0.0, 0.0, 0.0 };
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ if (pScrn->modes == NULL) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
+ return FALSE;
+ }
+
+ pScrn->currentMode = pScrn->modes;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ /* Load the required sub modules */
+ if (!xf86LoadSubModule(pScrn, "fb")) return FALSE;
+ xf86LoaderReqSymLists(fbSymbols, NULL);
+ xf86LoadSubModule(pScrn, "exa");
+ xf86LoadSubModule(pScrn, "dri2");
+
+ return TRUE;
}
+
Bool GlamoKMSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
char **argv)
{
}
-Bool SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+
+Bool GlamoSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
{
}
-void AdjustFrame(int scrnIndex, int x, int y, int flags)
+
+void GlamoAdjustFrame(int scrnIndex, int x, int y, int flags)
{
}
-Bool EnterVT(int scrnIndex, int flags)
+
+Bool GlamoEnterVT(int scrnIndex, int flags)
{
}
-void LeaveVT(int scrnIndex, int flags)
+
+void GlamoLeaveVT(int scrnIndex, int flags)
{
}
-ModeStatus ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+
+ModeStatus GlamoValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
int flags)
{
}
diff --git a/src/glamo-kms-driver.h b/src/glamo-kms-driver.h
index 84069a3..d68c2df 100644
--- a/src/glamo-kms-driver.h
+++ b/src/glamo-kms-driver.h
@@ -20,6 +20,9 @@
*
*/
+#include "xf86.h"
+
+extern Bool GlamoKernelModesettingAvailable();
extern Bool GlamoKMSPreInit(ScrnInfoPtr pScrn, int flags);
extern Bool GlamoKMSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
char **argv);
diff --git a/src/glamo.h b/src/glamo.h
index 6abf84a..90f60c7 100644
--- a/src/glamo.h
+++ b/src/glamo.h
@@ -135,6 +135,9 @@ typedef struct {
/* Use hardware acceleration */
Bool accel;
+ int drm_fd;
+ unsigned int SaveGeneration;
+
uint16_t *colormap;
} GlamoRec, *GlamoPtr;