diff options
author | Keith Packard <keithp@keithp.com> | 2001-09-05 07:12:43 +0000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2001-09-05 07:12:43 +0000 |
commit | 216090d1aedb23c691a75da25b14d8543b932e1c (patch) | |
tree | 3e7f781b63a47a83208880560d8af24db402671e /hw/kdrive/vesa | |
parent | f856b952ec7251d6e95f0b93d62fb026d07b0ebc (diff) |
kdrive: Add primitive ct65550 server. Update kdrive/vesa code to support
DPMS using VESA bios routines. Include support for Toshiba SMM DPMS as
well
Diffstat (limited to 'hw/kdrive/vesa')
-rw-r--r-- | hw/kdrive/vesa/vbe.c | 47 | ||||
-rw-r--r-- | hw/kdrive/vesa/vbe.h | 4 | ||||
-rw-r--r-- | hw/kdrive/vesa/vesa.c | 96 | ||||
-rw-r--r-- | hw/kdrive/vesa/vesa.h | 6 | ||||
-rw-r--r-- | hw/kdrive/vesa/vesainit.c | 4 | ||||
-rw-r--r-- | hw/kdrive/vesa/vga.c | 5 | ||||
-rw-r--r-- | hw/kdrive/vesa/vga.h | 4 |
7 files changed, 150 insertions, 16 deletions
diff --git a/hw/kdrive/vesa/vbe.c b/hw/kdrive/vesa/vbe.c index cb6d0d3a3..e0cdd0775 100644 --- a/hw/kdrive/vesa/vbe.c +++ b/hw/kdrive/vesa/vbe.c @@ -19,7 +19,7 @@ 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. */ -/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vbe.c,v 1.7 2000/11/19 20:51:12 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vbe.c,v 1.9 2001/05/29 04:54:12 keithp Exp $ */ #include "vesa.h" @@ -251,7 +251,7 @@ VbeGetMode(Vm86InfoPtr vi, int *mode) } void * -VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size) +VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size, CARD32 *ret_phys) { U8 *fb; VbeInfoBlock vib; @@ -270,6 +270,7 @@ VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size) size = 1024 * 64L * vib.TotalMemory; *ret_size = size; + *ret_phys = vmib.PhysBasePtr; before = vmib.PhysBasePtr % pagesize; after = pagesize - ((vmib.PhysBasePtr + size) % pagesize); @@ -501,6 +502,48 @@ windowB: return ((U8*)&(LM(vi, MAKE_POINTER(vbe->vmib.WinBSegment, 0)))) + offset - vbe->windowB_offset; } +static const int VbeDPMSModes[4] = { + 0x00, /* KD_DPMS_NORMAL */ + 0x01, /* KD_DPMS_STANDBY */ + 0x02, /* KD_DPMS_SUSPEND */ + 0x04, /* KD_DPMS_POWERDOWN */ +}; + +Bool +VbeDPMS(Vm86InfoPtr vi, VbeInfoBlock *vib, int mode) +{ + int code; + + /* + * Check which modes are supported + */ + vi->vms.regs.eax = 0x4f10; + vi->vms.regs.ebx = 0x0000; + vi->vms.regs.es = 0; + vi->vms.regs.edi = 0; + code = VbeDoInterrupt10 (vi); + if (code < 0) + { + ErrorF ("No DPMS Support\n"); + return FALSE; + } + /* Skip this stage if it's not supported */ + if (((vi->vms.regs.ebx >> 4) & VbeDPMSModes[mode]) != VbeDPMSModes[mode]) + return FALSE; + + /* Select this mode */ + vi->vms.regs.eax = 0x4f10; + vi->vms.regs.ebx = (VbeDPMSModes[mode] << 8) | 0x01; + code = VbeDoInterrupt10 (vi); + if (code < 0) + { + ErrorF ("DPMS failed %d\n", code); + return FALSE; + } + + return TRUE; +} + int VbeReportVib(Vm86InfoPtr vi, VbeInfoBlock *vib) { diff --git a/hw/kdrive/vesa/vbe.h b/hw/kdrive/vesa/vbe.h index bf347fc6b..6e74cc3b5 100644 --- a/hw/kdrive/vesa/vbe.h +++ b/hw/kdrive/vesa/vbe.h @@ -19,7 +19,7 @@ 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. */ -/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vbe.h,v 1.5 2000/10/20 00:19:50 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vbe.h,v 1.6 2001/05/29 04:54:12 keithp Exp $ */ #ifndef _VBE_H #define _VBE_H @@ -134,7 +134,7 @@ int VbeGetMode(Vm86InfoPtr vi, int *mode); void * -VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *size); +VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *size, CARD32 *phys); void VbeUnmapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, void *fb); diff --git a/hw/kdrive/vesa/vesa.c b/hw/kdrive/vesa/vesa.c index ab8ea41e5..960de6795 100644 --- a/hw/kdrive/vesa/vesa.c +++ b/hw/kdrive/vesa/vesa.c @@ -19,7 +19,7 @@ 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. */ -/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.15 2001/07/20 19:35:30 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.c,v 1.16 2001/07/24 19:06:04 keithp Exp $ */ #include "vesa.h" #ifdef RANDR @@ -33,6 +33,7 @@ Bool vesa_shadow = FALSE; Bool vesa_linear_fb = TRUE; Bool vesa_restore = FALSE; Bool vesa_verbose = FALSE; +Bool vesa_force_text = FALSE; #define VesaPriv(scr) ((VesaScreenPrivPtr) (scr)->driver) @@ -959,11 +960,13 @@ vesaMapFramebuffer (KdScreenInfo *screen) if (pscr->mode.vbe) pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo, pscr->mode.mode, - &pscr->fb_size); + &pscr->fb_size, + &pscr->fb_phys); else pscr->fb = VgaMapFramebuffer (priv->vi, pscr->mode.mode, - &pscr->fb_size); + &pscr->fb_size, + &pscr->fb_phys); if (!pscr->fb) return FALSE; break; @@ -1451,11 +1454,13 @@ vesaEnable(ScreenPtr pScreen) if (pscr->mode.vbe) pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo, pscr->mode.mode, - &pscr->fb_size); + &pscr->fb_size, + &pscr->fb_phys); else pscr->fb = VgaMapFramebuffer (priv->vi, pscr->mode.mode, - &pscr->fb_size); + &pscr->fb_size, + &pscr->fb_phys); if (!pscr->fb) return FALSE; screen->fb[0].frameBuffer = (CARD8 *)(pscr->fb); @@ -1501,6 +1506,77 @@ vesaEnable(ScreenPtr pScreen) return TRUE; } +#ifndef TOSHIBA_SMM + +# ifdef linux +# define TOSHIBA_SMM 1 +# endif + +# ifndef TOSHIBA_SMM +# define TOSHIBA_SMM 0 +# endif + +#endif + +#if TOSHIBA_SMM +/* + * Toshiba laptops use a special interface to operate the backlight + */ +#include <sys/ioctl.h> +#define TOSH_PROC "/proc/toshiba" +#define TOSH_DEVICE "/dev/toshiba" +#define TOSH_SMM _IOWR('t', 0x90, 24) + +typedef struct { + unsigned int eax; + unsigned int ebx __attribute__ ((packed)); + unsigned int ecx __attribute__ ((packed)); + unsigned int edx __attribute__ ((packed)); + unsigned int esi __attribute__ ((packed)); + unsigned int edi __attribute__ ((packed)); +} SMMRegisters; + +#define HCI_BACKLIGHT 0x0002 +#define HCI_DISABLE 0x0000 +#define HCI_ENABLE 0x0001 +#define HCI_GET 0xfe00, +#define HCI_SET 0xff00 + +Bool +toshibaDPMS (ScreenPtr pScreen, int mode) +{ + SMMRegisters regs; + static int fd; + + if (!fd) + fd = open (TOSH_DEVICE, 2); + if (fd < 0) + return FALSE; + regs.eax = HCI_SET; + regs.ebx = HCI_BACKLIGHT; + regs.ecx = mode ? HCI_DISABLE : HCI_ENABLE; + if (ioctl (fd, TOSH_SMM, ®s) < 0) + return FALSE; + return TRUE; +} +#endif /* TOSHIBA_SMM */ + +Bool +vesaDPMS (ScreenPtr pScreen, int mode) +{ + KdScreenPriv(pScreen); + VesaCardPrivPtr priv = pScreenPriv->card->driver; + VesaScreenPrivPtr pscr = pScreenPriv->screen->driver; + +#if TOSHIBA_SMM + if (toshibaDPMS (pScreen, mode)) + return TRUE; +#endif + if (pscr->mode.vbe) + return VbeDPMS (priv->vi, priv->vbeInfo, mode); + return FALSE; +} + void vesaDisable(ScreenPtr pScreen) { @@ -1569,6 +1645,13 @@ vesaRestore(KdCardInfo *card) VesaCardPrivPtr priv = card->driver; int n; + if (vesa_force_text) + { + if (vesa_verbose) + ErrorF ("Forcing switch back to mode 3 text\n"); + priv->old_vbe_mode = -1; + priv->old_vga_mode = 3; + } for (n = 0; n < priv->nmode; n++) if (priv->modes[n].vbe && priv->modes[n].mode == (priv->old_vbe_mode&0x3fff)) break; @@ -1774,6 +1857,9 @@ vesaProcessArgument (int argc, char **argv, int i) } else if(!strcmp(argv[i], "-verbose")) { vesa_verbose = TRUE; return 1; + } else if(!strcmp(argv[i], "-force-text")) { + vesa_force_text = TRUE; + return 1; } return 0; diff --git a/hw/kdrive/vesa/vesa.h b/hw/kdrive/vesa/vesa.h index b84d58d2b..fc8f7fa19 100644 --- a/hw/kdrive/vesa/vesa.h +++ b/hw/kdrive/vesa/vesa.h @@ -19,7 +19,7 @@ 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. */ -/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.h,v 1.10 2001/06/04 09:45:42 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesa.h,v 1.11 2001/07/20 19:35:30 keithp Exp $ */ #ifndef _VESA_H_ #define _VESA_H_ @@ -101,6 +101,7 @@ typedef struct _VesaScreenPriv { int layerKind; void *fb; int fb_size; + CARD32 fb_phys; LayerPtr pLayer; } VesaScreenPrivRec, *VesaScreenPrivPtr; @@ -137,6 +138,9 @@ vesaFinishInitScreen(ScreenPtr pScreen); Bool vesaEnable(ScreenPtr pScreen); +Bool +vesaDPMS (ScreenPtr pScreen, int mode); + void vesaDisable(ScreenPtr pScreen); diff --git a/hw/kdrive/vesa/vesainit.c b/hw/kdrive/vesa/vesainit.c index 3019e4f12..a409fc4fb 100644 --- a/hw/kdrive/vesa/vesainit.c +++ b/hw/kdrive/vesa/vesainit.c @@ -19,7 +19,7 @@ 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. */ -/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesainit.c,v 1.5 2000/12/08 21:40:29 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vesainit.c,v 1.6 2001/06/04 09:45:42 keithp Exp $ */ #include "vesa.h" @@ -29,7 +29,7 @@ const KdCardFuncs vesaFuncs = { vesaInitScreen, /* initScreen */ vesaPreserve, /* preserve */ vesaEnable, /* enable */ - 0, /* dpms */ + vesaDPMS, /* dpms */ vesaDisable, /* disable */ vesaRestore, /* restore */ vesaScreenFini, /* scrfini */ diff --git a/hw/kdrive/vesa/vga.c b/hw/kdrive/vesa/vga.c index 24b23e885..a87b70a2d 100644 --- a/hw/kdrive/vesa/vga.c +++ b/hw/kdrive/vesa/vga.c @@ -1,5 +1,5 @@ /* - * $XFree86$ + * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vga.c,v 1.1 2000/10/20 00:19:51 keithp Exp $ * * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * @@ -225,12 +225,13 @@ VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size) } void * -VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size) +VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size, CARD32 *ret_phys) { if (VGA_FB(vmode) == 0xa0000) *size = 0x10000; else *size = 0x4000; + *ret_phys = VGA_FB(vmode); return &LM(vi,VGA_FB(vmode)); } diff --git a/hw/kdrive/vesa/vga.h b/hw/kdrive/vesa/vga.h index 0637c2177..873c1ee95 100644 --- a/hw/kdrive/vesa/vga.h +++ b/hw/kdrive/vesa/vga.h @@ -1,5 +1,5 @@ /* - * $XFree86$ + * $XFree86: xc/programs/Xserver/hw/kdrive/vesa/vga.h,v 1.1 2000/10/20 00:19:51 keithp Exp $ * * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * @@ -53,7 +53,7 @@ void * VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size); void * -VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size); +VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size, CARD32 *phys); void VgaUnmapFramebuffer (Vm86InfoPtr vi); |