diff options
author | Jordan Crouse <jordan.crouse@amd.com> | 2008-06-10 12:08:53 -0600 |
---|---|---|
committer | Jordan Crouse <jordan.crouse@amd.com> | 2008-06-10 14:18:54 -0600 |
commit | 2fc546c0d129fe7d3edee6b0cbfd530de33e2209 (patch) | |
tree | a0c61280f087c577b5e9568a8f72bd22ea265ba8 | |
parent | 489546dfd2dd295db63f31e123b0073a6fa330a9 (diff) |
geode: Bring over the DCON detection code from the OLPC tree
-rw-r--r-- | src/geode.h | 1 | ||||
-rw-r--r-- | src/geode_dcon.c | 47 | ||||
-rw-r--r-- | src/lx_driver.c | 36 |
3 files changed, 70 insertions, 14 deletions
diff --git a/src/geode.h b/src/geode.h index 2490315..2c2ce89 100644 --- a/src/geode.h +++ b/src/geode.h @@ -234,6 +234,7 @@ VESARec; #define OUTPUT_CRT 0x02 #define OUTPUT_TV 0x04 #define OUTPUT_VOP 0x08 +#define OUTPUT_DCON 0x10 typedef struct _geodeRec { diff --git a/src/geode_dcon.c b/src/geode_dcon.c index 27cad18..fc887f7 100644 --- a/src/geode_dcon.c +++ b/src/geode_dcon.c @@ -35,11 +35,56 @@ #include "geode.h" #include <unistd.h> +#include <fcntl.h> + +#define DCON_SLEEP_FILE "/sys/devices/platform/dcon/sleep" static Bool dcon_present(void) { - return access("/sys/devices/platform/dcon", F_OK) == 0; + static int _dval = -1; + + if (_dval == -1) + _dval = (access("/sys/devices/platform/dcon", F_OK) == 0); + + return (Bool) _dval; +} + +int +DCONDPMSSet(ScrnInfoPtr pScrni, int mode, int flags) +{ + static int failed = -1; + int fd; + char value[1]; + + if (failed == -1) + failed = !dcon_present(); + + if (failed) + return 0; + + fd = open(DCON_SLEEP_FILE, O_WRONLY); + + if (fd < 0) { + failed = 1; + return 0; + } + + switch (mode) { + case DPMSModeOn: + value[0] = '0'; + break; + case DPMSModeStandby: + case DPMSModeSuspend: + case DPMSModeOff: + value[0] = '1'; + break; + } + + write(fd, value, sizeof(value)); + close(fd); + + return 1; } Bool diff --git a/src/lx_driver.c b/src/lx_driver.c index d44fb94..e8477db 100644 --- a/src/lx_driver.c +++ b/src/lx_driver.c @@ -525,7 +525,7 @@ LXPreInit(ScrnInfoPtr pScrni, int flags) OptionInfoRec *GeodeOptions = &LX_GeodeOptions[0]; rgb defaultWeight = { 0, 0, 0 }; int modecnt; - char *s, *panelgeo = NULL; + char *s; if (pScrni->numEntities != 1) return FALSE; @@ -636,7 +636,7 @@ LXPreInit(ScrnInfoPtr pScrni, int flags) &pGeode->tryHWCursor); if (!xf86GetOptValInteger(GeodeOptions, LX_OPTION_FBSIZE, - (int *) &(pGeode->FBAvail))) + (int *)&(pGeode->FBAvail))) pGeode->FBAvail = 0; /* For compatability - allow SWCursor too */ @@ -666,7 +666,7 @@ LXPreInit(ScrnInfoPtr pScrni, int flags) } xf86GetOptValInteger(GeodeOptions, LX_OPTION_EXA_SCRATCH_BFRSZ, - (int *) &(pGeode->exaBfrSz)); + (int *)&(pGeode->exaBfrSz)); if (pGeode->exaBfrSz <= 0) pGeode->exaBfrSz = 0; @@ -676,23 +676,23 @@ LXPreInit(ScrnInfoPtr pScrni, int flags) pGeode->Output &= ~OUTPUT_PANEL; } - panelgeo = xf86GetOptValString(GeodeOptions, LX_OPTION_PANEL_GEOMETRY); - - /* Get the panel information - if it is specified on the command line, - * then go with that - otherwise try to determine it by probing the - * BIOS - the BIOS may tell us that the panel doesn't exist, so the - * value of the output bitmask may change + /* Panel detection code - + * 1. See if an OLPC DCON is attached - we can make some assumptions + * about the panel if so. + * 2. Use override options specified in the config + * 3. "Autodetect" the panel through VSA */ if (dcon_init(pScrni)) { - pGeode->Output = OUTPUT_PANEL; + pGeode->Output = OUTPUT_PANEL | OUTPUT_DCON; } else if (pGeode->Output & OUTPUT_PANEL) { + char *panelgeo = + xf86GetOptValString(GeodeOptions, LX_OPTION_PANEL_GEOMETRY); + if (panelgeo != NULL) GeodeGetFPGeometry(panelgeo, &pGeode->PanelX, &pGeode->PanelY); else { - Bool ret = lx_get_panel(&pGeode->PanelX, &pGeode->PanelY); - - if (ret == FALSE) + if (!lx_get_panel(&pGeode->PanelX, &pGeode->PanelY)) pGeode->Output &= ~OUTPUT_PANEL; } } @@ -704,6 +704,9 @@ LXPreInit(ScrnInfoPtr pScrni, int flags) xf86DrvMsg(pScrni->scrnIndex, X_INFO, " PANEL: %s\n", pGeode->Output & OUTPUT_PANEL ? "YES" : "NO"); + xf86DrvMsg(pScrni->scrnIndex, X_INFO, " DCON: %s\n", + pGeode->Output & OUTPUT_DCON ? "YES" : "NO"); + xf86DrvMsg(pScrni->scrnIndex, X_INFO, " VGA: %s\n", pGeode->useVGA ? "YES" : "NO"); @@ -1204,9 +1207,16 @@ LXLoadPalette(ScrnInfoPtr pScrni, static void LXDPMSSet(ScrnInfoPtr pScrni, int mode, int flags) { + GeodeRec *pGeode = GEODEPTR(pScrni); + if (!pScrni->vtSema) return; + if (pGeode->Output & OUTPUT_DCON) { + if (DCONDPMSSet(pScrni, mode, flags)) + return; + } + switch (mode) { case DPMSModeOn: lx_enable_dac_power(pScrni, 1); |