summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2009-02-25 00:52:05 +0100
committerLars-Peter Clausen <lars@metafoo.de>2009-02-25 00:52:05 +0100
commit99b38c284e91efc45f9bc4c087e462abe98ae0a4 (patch)
tree69f93ee0ecdd650a5c1e4c3ae6b3738fd1dc34ca /src
parent703acea131caf72e71f04a0ad40f540fe236be89 (diff)
Make the path to the sysfs state file for the jbt6k47 display driver
configurable. It can either be set at configure time with --with-jbt6k47-state-path=PATH. Or at runtime in the xorg.conf device section. The option name is StatePath.
Diffstat (limited to 'src')
-rw-r--r--src/glamo-driver.c44
-rw-r--r--src/glamo-output.c20
-rw-r--r--src/glamo.h7
3 files changed, 60 insertions, 11 deletions
diff --git a/src/glamo-driver.c b/src/glamo-driver.c
index 2c8735f..babf57d 100644
--- a/src/glamo-driver.c
+++ b/src/glamo-driver.c
@@ -128,11 +128,17 @@ typedef enum {
OPTION_SHADOW_FB,
OPTION_DEVICE,
OPTION_DEBUG,
+#ifdef JBT6K74_SET_STATE
+ OPTION_JBT6K74_STATE_PATH
+#endif
} GlamoOpts;
static const OptionInfoRec GlamoOptions[] = {
{ OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_DEBUG, "debug", OPTV_BOOLEAN, {0}, FALSE },
+#ifdef JBT6K74_SET_STATE
+ { OPTION_JBT6K74_STATE_PATH, "StatePath", OPTV_STRING, {0}, FALSE },
+#endif
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
@@ -483,6 +489,13 @@ GlamoPreInit(ScrnInfoPtr pScrn, int flags)
debug = xf86ReturnOptValBool(pGlamo->Options, OPTION_DEBUG, FALSE);
+#ifdef JBT6K74_SET_STATE
+ pGlamo->jbt6k74_state_path = xf86GetOptValString(pGlamo->Options,
+ OPTION_JBT6K74_STATE_PATH);
+ if (pGlamo->jbt6k74_state_path == NULL)
+ pGlamo->jbt6k74_state_path = JBT6K74_STATE_PATH;
+#endif
+
/* First approximation, may be refined in ScreenInit */
pScrn->displayWidth = pScrn->virtualX;
@@ -724,6 +737,19 @@ static void
GlamoSaveHW(ScrnInfoPtr pScrn) {
GlamoPtr pGlamo = GlamoPTR(pScrn);
volatile char *mmio = pGlamo->reg_base;
+#if JBT6K74_SET_STATE
+ int fd;
+
+ fd = open(pGlamo->jbt6k74_state_path, O_RDONLY);
+ if (fd != -1) {
+ read(fd, pGlamo->saved_jbt6k74_state, 14);
+ close(fd);
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Couldn't open \"%s\" to save display resolution: %s\n",
+ pGlamo->jbt6k74_state_path, strerror(errno));
+ }
+#endif
pGlamo->saved_clock_2d = MMIO_IN16(mmio, GLAMO_REG_CLOCK_2D);
pGlamo->saved_clock_isp = MMIO_IN16(mmio, GLAMO_REG_CLOCK_ISP);
@@ -736,13 +762,15 @@ GlamoSaveHW(ScrnInfoPtr pScrn) {
"Framebuffer ioctl FBIOGET_FSCREENINFO failed: %s",
strerror(errno));
}
-
}
static void
GlamoRestoreHW(ScrnInfoPtr pScrn) {
GlamoPtr pGlamo = GlamoPTR(pScrn);
volatile char *mmio = pGlamo->reg_base;
+#ifdef JBT6K74_SET_STATE
+ int fd;
+#endif
if (ioctl(pGlamo->fb_fd, FBIOPUT_VSCREENINFO, (void*)(&pGlamo->fb_saved_var)) == -1) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -755,6 +783,18 @@ GlamoRestoreHW(ScrnInfoPtr pScrn) {
MMIO_OUT16(mmio, GLAMO_REG_CLOCK_GEN5_1, pGlamo->saved_clock_gen5_1);
MMIO_OUT16(mmio, GLAMO_REG_CLOCK_GEN5_2, pGlamo->saved_clock_gen5_2);
MMIO_OUT16(mmio, GLAMO_REG_HOSTBUS(2), pGlamo->saved_hostbus_2);
+
+#ifdef JBT6K74_SET_STATE
+ fd = open(pGlamo->jbt6k74_state_path, O_WRONLY);
+ if (fd != -1) {
+ write(fd, pGlamo->saved_jbt6k74_state, 14);
+ close(fd);
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Couldn't open \"%s\" to restore display resolution: %s\n",
+ pGlamo->jbt6k74_state_path, strerror(errno));
+ }
+#endif
}
static Bool
@@ -773,7 +813,6 @@ GlamoEnterVT(int scrnIndex, int flags) {
return TRUE;
}
-
static void
GlamoLeaveVT(int scrnIndex, int flags) {
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
@@ -784,3 +823,4 @@ GlamoLeaveVT(int scrnIndex, int flags) {
GlamoRestoreHW(pScrn);
}
+
diff --git a/src/glamo-output.c b/src/glamo-output.c
index 57ce7c2..60ea902 100644
--- a/src/glamo-output.c
+++ b/src/glamo-output.c
@@ -39,9 +39,10 @@
#include "glamo.h"
-static const char *display_state_switch_path = "/sys/bus/spi/devices/spi2.0/state";
-static const char *display_state_vga = "normal";
-static const char *display_state_qvga = "qvga-normal";
+#ifdef JBT6K74_SET_STATE
+static const char jbt6k74_state_vga[] = "normal";
+static const char jbt6k74_state_qvga[] = "qvga-normal";
+#endif
typedef struct _GlamoOutput {
DisplayModePtr modes;
@@ -241,18 +242,21 @@ GlamoOutputModeSet(xf86OutputPtr output, DisplayModePtr mode,
static void
GlamoOutputCommit(xf86OutputPtr output) {
- int fd = open(display_state_switch_path, O_WRONLY);
+#ifdef JBT6K74_SET_STATE
+ GlamoPtr pGlamo = GlamoPTR(output->scrn);
+ int fd = open(pGlamo->jbt6k74_state_path, O_WRONLY);
if (fd != -1) {
if(output->crtc->mode.HDisplay == 240 && output->crtc->mode.VDisplay == 320)
- write(fd, display_state_qvga, strlen(display_state_qvga));
+ write(fd, jbt6k74_state_qvga, sizeof(jbt6k74_state_qvga));
else
- write(fd, display_state_vga, strlen(display_state_vga));
+ write(fd, jbt6k74_state_vga, sizeof(jbt6k74_state_vga));
close(fd);
} else {
xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
- "Couldn't open %s to change display resolution: %s\n",
- display_state_switch_path, strerror(errno));
+ "Couldn't open \"%s\" to change display resolution: %s\n",
+ pGlamo->jbt6k74_state_path, strerror(errno));
}
+#endif
}
static void GlamoOutputDestroy(xf86OutputPtr output) {
diff --git a/src/glamo.h b/src/glamo.h
index 84cba3d..2cb3da0 100644
--- a/src/glamo.h
+++ b/src/glamo.h
@@ -125,7 +125,12 @@ typedef struct {
short saved_clock_gen5_2;
short saved_hostbus_2;
- /* Use hardware acceleration */
+#ifdef JBT6K74_SET_STATE
+ char *jbt6k74_state_path;
+ char saved_jbt6k74_state[14];
+#endif
+
+/* Use hardware acceleration */
Bool accel;
} GlamoRec, *GlamoPtr;