2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XFree86 vbe module
|
|
|
|
* Copyright 2000 Egbert Eich
|
|
|
|
*
|
|
|
|
* The mode query/save/set/restore functions from the vesa driver
|
|
|
|
* have been moved here.
|
|
|
|
* Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
|
|
|
|
* Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "xf86.h"
|
|
|
|
#include "vbe.h"
|
2010-04-13 13:54:46 -06:00
|
|
|
#include <X11/extensions/dpmsconst.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define VERSION(x) VBE_VERSION_MAJOR(x),VBE_VERSION_MINOR(x)
|
|
|
|
|
|
|
|
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
|
2012-06-10 07:21:05 -06:00
|
|
|
#define B_O16(x) (x)
|
2006-11-26 11:13:41 -07:00
|
|
|
#define B_O32(x) (x)
|
|
|
|
#else
|
|
|
|
#define B_O16(x) ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8))
|
|
|
|
#define B_O32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \
|
|
|
|
| (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24))
|
|
|
|
#endif
|
|
|
|
#define L_ADD(x) (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00)
|
|
|
|
|
|
|
|
#define FARP(p) (((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff))
|
|
|
|
#define R16(v) ((v) & 0xffff)
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static unsigned char *vbeReadEDID(vbeInfoPtr pVbe);
|
2006-11-26 11:13:41 -07:00
|
|
|
static Bool vbeProbeDDC(vbeInfoPtr pVbe);
|
|
|
|
|
|
|
|
static const char vbeVersionString[] = "VBE2";
|
|
|
|
|
|
|
|
vbeInfoPtr
|
|
|
|
VBEInit(xf86Int10InfoPtr pInt, int entityIndex)
|
|
|
|
{
|
|
|
|
return VBEExtendedInit(pInt, entityIndex, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
vbeInfoPtr
|
|
|
|
VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags)
|
|
|
|
{
|
|
|
|
int RealOff;
|
|
|
|
pointer page = NULL;
|
|
|
|
ScrnInfoPtr pScrn = xf86FindScreenForEntity(entityIndex);
|
|
|
|
vbeControllerInfoPtr vbe = NULL;
|
|
|
|
Bool init_int10 = FALSE;
|
|
|
|
vbeInfoPtr vip = NULL;
|
|
|
|
int screen;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pScrn)
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
screen = pScrn->scrnIndex;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pInt) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!xf86LoadSubModule(pScrn, "int10"))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
xf86DrvMsg(screen, X_INFO, "initializing int10\n");
|
|
|
|
pInt = xf86ExtendedInitInt10(entityIndex, Flags);
|
|
|
|
if (!pInt)
|
|
|
|
goto error;
|
|
|
|
init_int10 = TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
page = xf86Int10AllocPages(pInt, 1, &RealOff);
|
|
|
|
if (!page)
|
|
|
|
goto error;
|
|
|
|
vbe = (vbeControllerInfoPtr) page;
|
|
|
|
memcpy(vbe->VbeSignature, vbeVersionString, 4);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pInt->ax = 0x4F00;
|
|
|
|
pInt->es = SEG_ADDR(RealOff);
|
|
|
|
pInt->di = SEG_OFF(RealOff);
|
|
|
|
pInt->num = 0x10;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86ExecX86int10(pInt);
|
|
|
|
|
|
|
|
if ((pInt->ax & 0xff) != 0x4f) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA BIOS not detected\n");
|
|
|
|
goto error;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (pInt->ax & 0xff00) {
|
|
|
|
case 0:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsg(screen, X_INFO, "VESA BIOS detected\n");
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case 0x100:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsg(screen, X_INFO, "VESA BIOS function failed\n");
|
|
|
|
goto error;
|
2006-11-26 11:13:41 -07:00
|
|
|
case 0x200:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsg(screen, X_INFO, "VESA BIOS not supported\n");
|
|
|
|
goto error;
|
2006-11-26 11:13:41 -07:00
|
|
|
case 0x300:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsg(screen, X_INFO, "VESA BIOS not supported in current mode\n");
|
|
|
|
goto error;
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsg(screen, X_INFO, "Invalid\n");
|
|
|
|
goto error;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 4,
|
2012-06-10 07:21:05 -06:00
|
|
|
"VbeVersion is %d, OemStringPtr is 0x%08lx,\n"
|
|
|
|
"\tOemVendorNamePtr is 0x%08lx, OemProductNamePtr is 0x%08lx,\n"
|
|
|
|
"\tOemProductRevPtr is 0x%08lx\n",
|
|
|
|
vbe->VbeVersion, (unsigned long) vbe->OemStringPtr,
|
|
|
|
(unsigned long) vbe->OemVendorNamePtr,
|
|
|
|
(unsigned long) vbe->OemProductNamePtr,
|
|
|
|
(unsigned long) vbe->OemProductRevPtr);
|
|
|
|
|
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE Version %i.%i\n",
|
|
|
|
VERSION(vbe->VbeVersion));
|
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE Total Mem: %i kB\n",
|
|
|
|
vbe->TotalMem * 64);
|
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM: %s\n",
|
|
|
|
(CARD8 *) xf86int10Addr(pInt, L_ADD(vbe->OemStringPtr)));
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (B_O16(vbe->VbeVersion) >= 0x200) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Software Rev: %i.%i\n",
|
|
|
|
VERSION(vbe->OemSoftwareRev));
|
|
|
|
if (vbe->OemVendorNamePtr)
|
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Vendor: %s\n",
|
|
|
|
(CARD8 *) xf86int10Addr(pInt,
|
|
|
|
L_ADD(vbe->
|
|
|
|
OemVendorNamePtr)));
|
|
|
|
if (vbe->OemProductNamePtr)
|
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Product: %s\n",
|
|
|
|
(CARD8 *) xf86int10Addr(pInt,
|
|
|
|
L_ADD(vbe->
|
|
|
|
OemProductNamePtr)));
|
|
|
|
if (vbe->OemProductRevPtr)
|
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE OEM Product Rev: %s\n",
|
|
|
|
(CARD8 *) xf86int10Addr(pInt,
|
|
|
|
L_ADD(vbe->
|
|
|
|
OemProductRevPtr)));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
vip = (vbeInfoPtr) xnfalloc(sizeof(vbeInfoRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
vip->version = B_O16(vbe->VbeVersion);
|
|
|
|
vip->pInt10 = pInt;
|
|
|
|
vip->ddc = DDC_UNCHECKED;
|
|
|
|
vip->memory = page;
|
|
|
|
vip->real_mode_base = RealOff;
|
|
|
|
vip->num_pages = 1;
|
|
|
|
vip->init_int10 = init_int10;
|
|
|
|
|
|
|
|
return vip;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (page)
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86Int10FreePages(pInt, page, 1);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (init_int10)
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86FreeInt10(pInt);
|
2006-11-26 11:13:41 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vbeFree(vbeInfoPtr pVbe)
|
|
|
|
{
|
|
|
|
if (!pVbe)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86Int10FreePages(pVbe->pInt10, pVbe->memory, pVbe->num_pages);
|
2006-11-26 11:13:41 -07:00
|
|
|
/* If we have initalized int10 we ought to free it, too */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pVbe->init_int10)
|
|
|
|
xf86FreeInt10(pVbe->pInt10);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pVbe);
|
2006-11-26 11:13:41 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
vbeProbeDDC(vbeInfoPtr pVbe)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *ddc_level;
|
2013-06-07 11:28:45 -06:00
|
|
|
int screen = pVbe->pInt10->pScrn->scrnIndex;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pVbe->ddc == DDC_NONE)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pVbe->ddc != DDC_UNCHECKED)
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pVbe->pInt10->ax = 0x4F15;
|
|
|
|
pVbe->pInt10->bx = 0;
|
|
|
|
pVbe->pInt10->cx = 0;
|
|
|
|
pVbe->pInt10->es = 0;
|
|
|
|
pVbe->pInt10->di = 0;
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC not supported\n");
|
|
|
|
pVbe->ddc = DDC_NONE;
|
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
switch ((pVbe->pInt10->ax >> 8) & 0xff) {
|
|
|
|
case 0:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsg(screen, X_INFO, "VESA VBE DDC supported\n");
|
|
|
|
switch (pVbe->pInt10->bx & 0x3) {
|
|
|
|
case 0:
|
|
|
|
ddc_level = " none";
|
|
|
|
pVbe->ddc = DDC_NONE;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ddc_level = " 1";
|
|
|
|
pVbe->ddc = DDC_1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ddc_level = " 2";
|
|
|
|
pVbe->ddc = DDC_2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ddc_level = " 1 + 2";
|
|
|
|
pVbe->ddc = DDC_1_2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ddc_level = "";
|
|
|
|
pVbe->ddc = DDC_NONE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC Level%s\n", ddc_level);
|
|
|
|
if (pVbe->pInt10->bx & 0x4) {
|
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC Screen blanked"
|
|
|
|
"for data transfer\n");
|
|
|
|
pVbe->ddc_blank = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pVbe->ddc_blank = FALSE;
|
|
|
|
|
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3,
|
|
|
|
"VESA VBE DDC transfer in appr. %x sec.\n",
|
|
|
|
(pVbe->pInt10->bx >> 8) & 0xff);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef enum {
|
2012-06-10 07:21:05 -06:00
|
|
|
VBEOPT_NOVBE,
|
2006-11-26 11:13:41 -07:00
|
|
|
VBEOPT_NODDC
|
|
|
|
} VBEOpts;
|
|
|
|
|
|
|
|
static const OptionInfoRec VBEOptions[] = {
|
2012-06-10 07:21:05 -06:00
|
|
|
{VBEOPT_NOVBE, "NoVBE", OPTV_BOOLEAN, {0}, FALSE},
|
|
|
|
{VBEOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE},
|
|
|
|
{-1, NULL, OPTV_NONE, {0}, FALSE},
|
2006-11-26 11:13:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned char *
|
|
|
|
vbeReadEDID(vbeInfoPtr pVbe)
|
|
|
|
{
|
|
|
|
int RealOff = pVbe->real_mode_base;
|
|
|
|
pointer page = pVbe->memory;
|
|
|
|
unsigned char *tmp = NULL;
|
|
|
|
Bool novbe = FALSE;
|
|
|
|
Bool noddc = FALSE;
|
2013-06-07 11:28:45 -06:00
|
|
|
ScrnInfoPtr pScrn = pVbe->pInt10->pScrn;
|
|
|
|
int screen = pScrn->scrnIndex;
|
2006-11-26 11:13:41 -07:00
|
|
|
OptionInfoPtr options;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!page)
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
options = xnfalloc(sizeof(VBEOptions));
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) memcpy(options, VBEOptions, sizeof(VBEOptions));
|
2013-06-07 11:28:45 -06:00
|
|
|
xf86ProcessOptions(screen, pScrn->options, options);
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86GetOptValBool(options, VBEOPT_NOVBE, &novbe);
|
|
|
|
xf86GetOptValBool(options, VBEOPT_NODDC, &noddc);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(options);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (novbe || noddc)
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!vbeProbeDDC(pVbe))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
memset(page, 0, sizeof(vbeInfoPtr));
|
|
|
|
strcpy(page, vbeVersionString);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pVbe->pInt10->ax = 0x4F15;
|
|
|
|
pVbe->pInt10->bx = 0x01;
|
|
|
|
pVbe->pInt10->cx = 0;
|
|
|
|
pVbe->pInt10->dx = 0;
|
|
|
|
pVbe->pInt10->es = SEG_ADDR(RealOff);
|
|
|
|
pVbe->pInt10->di = SEG_OFF(RealOff);
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC invalid\n");
|
|
|
|
goto error;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
switch (pVbe->pInt10->ax & 0xff00) {
|
|
|
|
case 0x0:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC read successfully\n");
|
|
|
|
tmp = (unsigned char *) xnfalloc(128);
|
|
|
|
memcpy(tmp, page, 128);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case 0x100:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC read failed\n");
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE DDC unkown failure %i\n",
|
|
|
|
pVbe->pInt10->ax & 0xff00);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
error:
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
xf86MonPtr
|
|
|
|
vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86MonPtr pMonitor;
|
|
|
|
pointer pModule;
|
2006-11-26 11:13:41 -07:00
|
|
|
unsigned char *DDC_data = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (!pVbe)
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pVbe->version < 0x200)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!(pModule = pDDCModule)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pModule =
|
2013-06-07 11:28:45 -06:00
|
|
|
xf86LoadSubModule(pVbe->pInt10->pScrn, "ddc");
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pModule)
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
DDC_data = vbeReadEDID(pVbe);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!DDC_data)
|
|
|
|
return NULL;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
pMonitor = xf86InterpretEDID(pVbe->pInt10->pScrn->scrnIndex, DDC_data);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!pDDCModule)
|
|
|
|
xf86UnloadSubModule(pModule);
|
|
|
|
return pMonitor;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GET_UNALIGNED2(x) \
|
|
|
|
((*(CARD16*)(x)) | (*(((CARD16*)(x) + 1))) << 16)
|
|
|
|
|
|
|
|
VbeInfoBlock *
|
|
|
|
VBEGetVBEInfo(vbeInfoPtr pVbe)
|
|
|
|
{
|
|
|
|
VbeInfoBlock *block = NULL;
|
|
|
|
int i, pStr, pModes;
|
|
|
|
char *str;
|
|
|
|
CARD16 major, *modes;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
memset(pVbe->memory, 0, sizeof(VbeInfoBlock));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AH := 4Fh Super VGA support
|
|
|
|
AL := 00h Return Super VGA information
|
|
|
|
ES:DI := Pointer to buffer
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := status
|
|
|
|
(All other registers are preserved)
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
((char *) pVbe->memory)[0] = 'V';
|
|
|
|
((char *) pVbe->memory)[1] = 'B';
|
|
|
|
((char *) pVbe->memory)[2] = 'E';
|
|
|
|
((char *) pVbe->memory)[3] = '2';
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f00;
|
|
|
|
pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
|
|
|
|
pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
block = calloc(sizeof(VbeInfoBlock), 1);
|
2012-06-10 07:21:05 -06:00
|
|
|
block->VESASignature[0] = ((char *) pVbe->memory)[0];
|
|
|
|
block->VESASignature[1] = ((char *) pVbe->memory)[1];
|
|
|
|
block->VESASignature[2] = ((char *) pVbe->memory)[2];
|
|
|
|
block->VESASignature[3] = ((char *) pVbe->memory)[3];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
block->VESAVersion = *(CARD16 *) (((char *) pVbe->memory) + 4);
|
|
|
|
major = (unsigned) block->VESAVersion >> 8;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 6));
|
2006-11-26 11:13:41 -07:00
|
|
|
str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
|
|
|
|
block->OEMStringPtr = strdup(str);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
block->Capabilities[0] = ((char *) pVbe->memory)[10];
|
|
|
|
block->Capabilities[1] = ((char *) pVbe->memory)[11];
|
|
|
|
block->Capabilities[2] = ((char *) pVbe->memory)[12];
|
|
|
|
block->Capabilities[3] = ((char *) pVbe->memory)[13];
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pModes = GET_UNALIGNED2((((char *) pVbe->memory) + 14));
|
2006-11-26 11:13:41 -07:00
|
|
|
modes = xf86int10Addr(pVbe->pInt10, FARP(pModes));
|
|
|
|
i = 0;
|
|
|
|
while (modes[i] != 0xffff)
|
2012-06-10 07:21:05 -06:00
|
|
|
i++;
|
2011-04-02 10:08:38 -06:00
|
|
|
block->VideoModePtr = malloc(sizeof(CARD16) * (i + 1));
|
2006-11-26 11:13:41 -07:00
|
|
|
memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i);
|
|
|
|
block->VideoModePtr[i] = 0xffff;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
block->TotalMemory = *(CARD16 *) (((char *) pVbe->memory) + 18);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (major < 2)
|
2012-06-10 07:21:05 -06:00
|
|
|
memcpy(&block->OemSoftwareRev, ((char *) pVbe->memory) + 20, 236);
|
2006-11-26 11:13:41 -07:00
|
|
|
else {
|
2012-06-10 07:21:05 -06:00
|
|
|
block->OemSoftwareRev = *(CARD16 *) (((char *) pVbe->memory) + 20);
|
|
|
|
pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 22));
|
|
|
|
str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
|
|
|
|
block->OemVendorNamePtr = strdup(str);
|
|
|
|
pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 26));
|
|
|
|
str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
|
|
|
|
block->OemProductNamePtr = strdup(str);
|
|
|
|
pStr = GET_UNALIGNED2((((char *) pVbe->memory) + 30));
|
|
|
|
str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
|
|
|
|
block->OemProductRevPtr = strdup(str);
|
|
|
|
memcpy(&block->Reserved, ((char *) pVbe->memory) + 34, 222);
|
|
|
|
memcpy(&block->OemData, ((char *) pVbe->memory) + 256, 256);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return block;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
VBEFreeVBEInfo(VbeInfoBlock * block)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
free(block->OEMStringPtr);
|
|
|
|
free(block->VideoModePtr);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (((unsigned) block->VESAVersion >> 8) >= 2) {
|
|
|
|
free(block->OemVendorNamePtr);
|
|
|
|
free(block->OemProductNamePtr);
|
|
|
|
free(block->OemProductRevPtr);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
free(block);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock * block)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AH := 4Fh Super VGA support
|
|
|
|
AL := 02h Set Super VGA video mode
|
|
|
|
BX := Video mode
|
|
|
|
D0-D8 := Mode number
|
|
|
|
D9-D10 := Reserved (must be 0)
|
|
|
|
D11 := 0 Use current default refresh rate
|
|
|
|
:= 1 Use user specified CRTC values for refresh rate
|
|
|
|
D12-13 Reserved for VBE/AF (must be 0)
|
|
|
|
D14 := 0 Use windowed frame buffer model
|
|
|
|
:= 1 Use linear/flat frame buffer model
|
|
|
|
D15 := 0 Clear video memory
|
|
|
|
:= 1 Don't clear video memory
|
|
|
|
ES:DI := Pointer to VbeCRTCInfoBlock structure
|
|
|
|
|
|
|
|
Output: AX = Status
|
|
|
|
(All other registers are preserved)
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f02;
|
|
|
|
pVbe->pInt10->bx = mode;
|
|
|
|
if (block) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pVbe->pInt10->bx |= 1 << 11;
|
|
|
|
memcpy(pVbe->memory, block, sizeof(VbeCRTCInfoBlock));
|
|
|
|
pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
|
|
|
|
pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pVbe->pInt10->bx &= ~(1 << 11);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
return (R16(pVbe->pInt10->ax) == 0x4f);
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
VBEGetVBEMode(vbeInfoPtr pVbe, int *mode)
|
|
|
|
{
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AH := 4Fh Super VGA support
|
|
|
|
AL := 03h Return current video mode
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := Status
|
|
|
|
BX := Current video mode
|
|
|
|
(All other registers are preserved)
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f03;
|
|
|
|
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if (R16(pVbe->pInt10->ax) == 0x4f) {
|
2012-06-10 07:21:05 -06:00
|
|
|
*mode = R16(pVbe->pInt10->bx);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
VbeModeInfoBlock *
|
|
|
|
VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
|
|
|
|
{
|
|
|
|
VbeModeInfoBlock *block = NULL;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
memset(pVbe->memory, 0, sizeof(VbeModeInfoBlock));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AH := 4Fh Super VGA support
|
|
|
|
AL := 01h Return Super VGA mode information
|
|
|
|
CX := Super VGA video mode
|
|
|
|
(mode number must be one of those returned by Function 0)
|
|
|
|
ES:DI := Pointer to buffer
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := status
|
|
|
|
(All other registers are preserved)
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f01;
|
|
|
|
pVbe->pInt10->cx = mode;
|
|
|
|
pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
|
|
|
|
pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
|
|
|
block = malloc(sizeof(VbeModeInfoBlock));
|
|
|
|
if (block)
|
2012-06-10 07:21:05 -06:00
|
|
|
memcpy(block, pVbe->memory, sizeof(*block));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return block;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
VBEFreeModeInfo(VbeModeInfoBlock * block)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
free(block);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function,
|
|
|
|
pointer *memory, int *size, int *real_mode_pages)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AH := 4Fh Super VGA support
|
|
|
|
AL := 04h Save/restore Super VGA video state
|
|
|
|
DL := 00h Return save/restore state buffer size
|
|
|
|
CX := Requested states
|
|
|
|
D0 = Save/restore video hardware state
|
|
|
|
D1 = Save/restore video BIOS data state
|
|
|
|
D2 = Save/restore video DAC state
|
|
|
|
D3 = Save/restore Super VGA state
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX = Status
|
|
|
|
BX = Number of 64-byte blocks to hold the state buffer
|
|
|
|
(All other registers are preserved)
|
|
|
|
|
|
|
|
Input:
|
|
|
|
AH := 4Fh Super VGA support
|
|
|
|
AL := 04h Save/restore Super VGA video state
|
|
|
|
DL := 01h Save Super VGA video state
|
|
|
|
CX := Requested states (see above)
|
|
|
|
ES:BX := Pointer to buffer
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := Status
|
|
|
|
(All other registers are preserved)
|
|
|
|
|
|
|
|
Input:
|
|
|
|
AH := 4Fh Super VGA support
|
|
|
|
AL := 04h Save/restore Super VGA video state
|
|
|
|
DL := 02h Restore Super VGA video state
|
|
|
|
CX := Requested states (see above)
|
|
|
|
ES:BX := Pointer to buffer
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := Status
|
|
|
|
(All other registers are preserved)
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
if ((pVbe->version & 0xff00) > 0x100) {
|
2013-06-07 11:28:45 -06:00
|
|
|
int screen = pVbe->pInt10->pScrn->scrnIndex;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (function == MODE_QUERY || (function == MODE_SAVE && !*memory)) {
|
|
|
|
/* Query amount of memory to save state */
|
|
|
|
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f04;
|
|
|
|
pVbe->pInt10->dx = 0;
|
|
|
|
pVbe->pInt10->cx = 0x000f;
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (function == MODE_SAVE) {
|
|
|
|
int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1;
|
|
|
|
|
|
|
|
if ((*memory = xf86Int10AllocPages(pVbe->pInt10, npages,
|
|
|
|
real_mode_pages)) == NULL) {
|
|
|
|
xf86DrvMsg(screen, X_ERROR,
|
|
|
|
"Cannot allocate memory to save SVGA state.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*size = pVbe->pInt10->bx * 64;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save/Restore Super VGA state */
|
|
|
|
if (function != MODE_QUERY) {
|
|
|
|
|
|
|
|
if (!*memory)
|
|
|
|
return FALSE;
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f04;
|
|
|
|
switch (function) {
|
|
|
|
case MODE_SAVE:
|
|
|
|
pVbe->pInt10->dx = 1;
|
|
|
|
break;
|
|
|
|
case MODE_RESTORE:
|
|
|
|
pVbe->pInt10->dx = 2;
|
|
|
|
break;
|
|
|
|
case MODE_QUERY:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pVbe->pInt10->cx = 0x000f;
|
|
|
|
|
|
|
|
pVbe->pInt10->es = SEG_ADDR(*real_mode_pages);
|
|
|
|
pVbe->pInt10->bx = SEG_OFF(*real_mode_pages);
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
return (R16(pVbe->pInt10->ax) == 0x4f);
|
|
|
|
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window)
|
|
|
|
{
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AH := 4Fh Super VGA support
|
|
|
|
AL := 05h
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
Output:
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f05;
|
|
|
|
pVbe->pInt10->bx = window;
|
|
|
|
pVbe->pInt10->dx = iBank;
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command,
|
2012-06-10 07:21:05 -06:00
|
|
|
int width, int *pixels, int *bytes, int *max)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (command < SCANWID_SET || command > SCANWID_GET_MAX)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AX := 4F06h VBE Set/Get Logical Scan Line Length
|
|
|
|
BL := 00h Set Scan Line Length in Pixels
|
|
|
|
:= 01h Get Scan Line Length
|
|
|
|
:= 02h Set Scan Line Length in Bytes
|
|
|
|
:= 03h Get Maximum Scan Line Length
|
|
|
|
CX := If BL=00h Desired Width in Pixels
|
|
|
|
If BL=02h Desired Width in Bytes
|
|
|
|
(Ignored for Get Functions)
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := VBE Return Status
|
|
|
|
BX := Bytes Per Scan Line
|
|
|
|
CX := Actual Pixels Per Scan Line
|
|
|
|
(truncated to nearest complete pixel)
|
|
|
|
DX := Maximum Number of Scan Lines
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f06;
|
|
|
|
pVbe->pInt10->bx = command;
|
|
|
|
if (command == SCANWID_SET || command == SCANWID_SET_BYTES)
|
2012-06-10 07:21:05 -06:00
|
|
|
pVbe->pInt10->cx = width;
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (command == SCANWID_GET || command == SCANWID_GET_MAX) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pixels)
|
|
|
|
*pixels = R16(pVbe->pInt10->cx);
|
|
|
|
if (bytes)
|
|
|
|
*bytes = R16(pVbe->pInt10->bx);
|
|
|
|
if (max)
|
|
|
|
*max = R16(pVbe->pInt10->dx);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace)
|
|
|
|
{
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f07;
|
|
|
|
pVbe->pInt10->bx = wait_retrace ? 0x80 : 0x00;
|
|
|
|
pVbe->pInt10->cx = x;
|
|
|
|
pVbe->pInt10->dx = y;
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y)
|
|
|
|
{
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f07;
|
|
|
|
pVbe->pInt10->bx = 0x01;
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
*x = pVbe->pInt10->cx;
|
|
|
|
*y = pVbe->pInt10->dx;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits)
|
|
|
|
{
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AX := 4F08h VBE Set/Get Palette Format
|
|
|
|
BL := 00h Set DAC Palette Format
|
|
|
|
:= 01h Get DAC Palette Format
|
|
|
|
BH := Desired bits of color per primary
|
|
|
|
(Set DAC Palette Format only)
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := VBE Return Status
|
|
|
|
BH := Current number of bits of color per primary
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f08;
|
|
|
|
if (!bits)
|
2012-06-10 07:21:05 -06:00
|
|
|
pVbe->pInt10->bx = 0x01;
|
|
|
|
else
|
|
|
|
pVbe->pInt10->bx = (bits & 0x00ff) << 8;
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
2012-06-10 07:21:05 -06:00
|
|
|
return 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return (bits != 0 ? bits : (pVbe->pInt10->bx >> 8) & 0x00ff);
|
|
|
|
}
|
|
|
|
|
|
|
|
CARD32 *
|
|
|
|
VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
|
2012-06-10 07:21:05 -06:00
|
|
|
CARD32 *data, Bool secondary, Bool wait_retrace)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
(16-bit)
|
|
|
|
AX := 4F09h VBE Load/Unload Palette Data
|
|
|
|
BL := 00h Set Palette Data
|
|
|
|
:= 01h Get Palette Data
|
|
|
|
:= 02h Set Secondary Palette Data
|
|
|
|
:= 03h Get Secondary Palette Data
|
|
|
|
:= 80h Set Palette Data during Vertical Retrace
|
|
|
|
CX := Number of palette registers to update (to a maximum of 256)
|
|
|
|
DX := First of the palette registers to update (start)
|
|
|
|
ES:DI := Table of palette values (see below for format)
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := VBE Return Status
|
|
|
|
|
|
|
|
Input:
|
|
|
|
(32-bit)
|
|
|
|
BL := 00h Set Palette Data
|
|
|
|
:= 80h Set Palette Data during Vertical Retrace
|
|
|
|
CX := Number of palette registers to update (to a maximum of 256)
|
|
|
|
DX := First of the palette registers to update (start)
|
|
|
|
ES:EDI := Table of palette values (see below for format)
|
|
|
|
DS := Selector for memory mapped registers
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f09;
|
|
|
|
if (!secondary)
|
2012-06-10 07:21:05 -06:00
|
|
|
pVbe->pInt10->bx = set && wait_retrace ? 0x80 : set ? 0 : 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
pVbe->pInt10->bx = set ? 2 : 3;
|
2006-11-26 11:13:41 -07:00
|
|
|
pVbe->pInt10->cx = num;
|
|
|
|
pVbe->pInt10->dx = first;
|
|
|
|
pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
|
|
|
|
pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
|
|
|
|
if (set)
|
2012-06-10 07:21:05 -06:00
|
|
|
memcpy(pVbe->memory, data, num * sizeof(CARD32));
|
2006-11-26 11:13:41 -07:00
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (set)
|
2012-06-10 07:21:05 -06:00
|
|
|
return data;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
data = malloc(num * sizeof(CARD32));
|
2006-11-26 11:13:41 -07:00
|
|
|
memcpy(data, pVbe->memory, num * sizeof(CARD32));
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return data;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
VBEpmi *
|
|
|
|
VBEGetVBEpmi(vbeInfoPtr pVbe)
|
|
|
|
{
|
|
|
|
VBEpmi *pmi;
|
|
|
|
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AH := 4Fh Super VGA support
|
|
|
|
AL := 0Ah Protected Mode Interface
|
|
|
|
BL := 00h Return Protected Mode Table
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := Status
|
|
|
|
ES := Real Mode Segment of Table
|
|
|
|
DI := Offset of Table
|
|
|
|
CX := Lenght of Table including protected mode code in bytes (for copying purposes)
|
|
|
|
(All other registers are preserved)
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f0a;
|
|
|
|
pVbe->pInt10->bx = 0;
|
|
|
|
pVbe->pInt10->di = 0;
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pmi = malloc(sizeof(VBEpmi));
|
2006-11-26 11:13:41 -07:00
|
|
|
pmi->seg_tbl = R16(pVbe->pInt10->es);
|
|
|
|
pmi->tbl_off = R16(pVbe->pInt10->di);
|
|
|
|
pmi->tbl_len = R16(pVbe->pInt10->cx);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return pmi;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
vbeModeInfoPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock * vbe)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
vbeModeInfoPtr ModeList = NULL;
|
|
|
|
|
|
|
|
int i = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
while (vbe->VideoModePtr[i] != 0xffff) {
|
2012-06-10 07:21:05 -06:00
|
|
|
vbeModeInfoPtr m;
|
|
|
|
VbeModeInfoBlock *mode;
|
|
|
|
int id = vbe->VideoModePtr[i++];
|
|
|
|
int bpp;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((mode = VBEGetModeInfo(pVbe, id)) == NULL)
|
|
|
|
continue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
bpp = mode->BitsPerPixel;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
m = xnfcalloc(sizeof(vbeModeInfoRec), 1);
|
|
|
|
m->width = mode->XResolution;
|
|
|
|
m->height = mode->YResolution;
|
|
|
|
m->bpp = bpp;
|
|
|
|
m->n = id;
|
|
|
|
m->next = ModeList;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
xf86DrvMsgVerb(pVbe->pInt10->pScrn->scrnIndex, X_PROBED, 3,
|
2012-06-10 07:21:05 -06:00
|
|
|
"BIOS reported VESA mode 0x%x: x:%i y:%i bpp:%i\n",
|
|
|
|
m->n, m->width, m->height, m->bpp);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ModeList = m;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VBEFreeModeInfo(mode);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return ModeList;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
unsigned short
|
2006-11-26 11:13:41 -07:00
|
|
|
VBECalcVbeModeIndex(vbeModeInfoPtr m, DisplayModePtr mode, int bpp)
|
|
|
|
{
|
|
|
|
while (m) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (bpp == m->bpp
|
|
|
|
&& mode->HDisplay == m->width && mode->VDisplay == m->height)
|
|
|
|
return m->n;
|
|
|
|
m = m->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr,
|
2012-06-10 07:21:05 -06:00
|
|
|
vbeSaveRestoreFunction function)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
Bool SaveSucc = FALSE;
|
|
|
|
|
|
|
|
if (VBE_VERSION_MAJOR(pVbe->version) > 1
|
2012-06-10 07:21:05 -06:00
|
|
|
&& (function == MODE_SAVE || vbe_sr->pstate)) {
|
|
|
|
if (function == MODE_RESTORE)
|
|
|
|
memcpy(vbe_sr->state, vbe_sr->pstate, vbe_sr->stateSize);
|
|
|
|
ErrorF("VBESaveRestore\n");
|
|
|
|
if ((VBESaveRestore(pVbe, function,
|
|
|
|
(pointer) &vbe_sr->state,
|
|
|
|
&vbe_sr->stateSize, &vbe_sr->statePage))) {
|
|
|
|
if (function == MODE_SAVE) {
|
|
|
|
SaveSucc = TRUE;
|
|
|
|
vbe_sr->stateMode = -1; /* invalidate */
|
|
|
|
/* don't rely on the memory not being touched */
|
|
|
|
if (vbe_sr->pstate == NULL)
|
|
|
|
vbe_sr->pstate = malloc(vbe_sr->stateSize);
|
|
|
|
memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize);
|
|
|
|
}
|
|
|
|
ErrorF("VBESaveRestore done with success\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ErrorF("VBESaveRestore done\n");
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (function == MODE_SAVE && !SaveSucc)
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) VBEGetVBEMode(pVbe, &vbe_sr->stateMode);
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (function == MODE_RESTORE && vbe_sr->stateMode != -1)
|
2012-06-10 07:21:05 -06:00
|
|
|
VBESetVBEMode(pVbe, vbe_sr->stateMode, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock)
|
|
|
|
{
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AX := 4F0Bh VBE Get Pixel Clock
|
|
|
|
BL := 00h Get Pixel Clock
|
|
|
|
ECX := pixel clock in units of Hz
|
|
|
|
DX := mode number
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := VBE Return Status
|
|
|
|
ECX := Closest pixel clock
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f0b;
|
2008-11-02 08:26:08 -07:00
|
|
|
pVbe->pInt10->bx = 0x00;
|
2006-11-26 11:13:41 -07:00
|
|
|
pVbe->pInt10->cx = clock;
|
|
|
|
pVbe->pInt10->dx = mode;
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if (R16(pVbe->pInt10->ax) != 0x4f)
|
2012-06-10 07:21:05 -06:00
|
|
|
return 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return pVbe->pInt10->cx;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
VBEDPMSSet(vbeInfoPtr pVbe, int mode)
|
|
|
|
{
|
|
|
|
/*
|
2012-06-10 07:21:05 -06:00
|
|
|
Input:
|
|
|
|
AX := 4F10h DPMS
|
|
|
|
BL := 01h Set Display Power State
|
|
|
|
BH := requested power state
|
|
|
|
|
|
|
|
Output:
|
|
|
|
AX := VBE Return Status
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
pVbe->pInt10->ax = 0x4f10;
|
|
|
|
pVbe->pInt10->bx = 0x01;
|
|
|
|
switch (mode) {
|
|
|
|
case DPMSModeOn:
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case DPMSModeStandby:
|
2012-06-10 07:21:05 -06:00
|
|
|
pVbe->pInt10->bx |= 0x100;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case DPMSModeSuspend:
|
2012-06-10 07:21:05 -06:00
|
|
|
pVbe->pInt10->bx |= 0x200;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case DPMSModeOff:
|
2012-06-10 07:21:05 -06:00
|
|
|
pVbe->pInt10->bx |= 0x400;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
return (R16(pVbe->pInt10->ax) == 0x4f);
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
void
|
2013-06-07 11:28:45 -06:00
|
|
|
VBEInterpretPanelID(ScrnInfoPtr pScrn, struct vbePanelID *data)
|
2007-11-24 10:55:21 -07:00
|
|
|
{
|
|
|
|
DisplayModePtr mode;
|
|
|
|
const float PANEL_HZ = 60.0;
|
|
|
|
|
|
|
|
if (!data)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "PanelID returned panel resolution %dx%d\n",
|
2012-06-10 07:21:05 -06:00
|
|
|
data->hsize, data->vsize);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
if (pScrn->monitor->nHsync || pScrn->monitor->nVrefresh)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
if (data->hsize < 320 || data->vsize < 240) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "...which I refuse to believe\n");
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
mode = xf86CVTMode(data->hsize, data->vsize, PANEL_HZ, 1, 0);
|
|
|
|
|
|
|
|
pScrn->monitor->nHsync = 1;
|
2011-12-18 09:08:59 -07:00
|
|
|
pScrn->monitor->hsync[0].lo = 29.37;
|
2012-06-10 07:21:05 -06:00
|
|
|
pScrn->monitor->hsync[0].hi = (float) mode->Clock / (float) mode->HTotal;
|
2007-11-24 10:55:21 -07:00
|
|
|
pScrn->monitor->nVrefresh = 1;
|
|
|
|
pScrn->monitor->vrefresh[0].lo = 56.0;
|
|
|
|
pScrn->monitor->vrefresh[0].hi =
|
2012-06-10 07:21:05 -06:00
|
|
|
(float) mode->Clock * 1000.0 / (float) mode->HTotal /
|
|
|
|
(float) mode->VTotal;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2011-12-18 09:08:59 -07:00
|
|
|
if (pScrn->monitor->vrefresh[0].hi < 59.47)
|
2012-06-10 07:21:05 -06:00
|
|
|
pScrn->monitor->vrefresh[0].hi = 59.47;
|
2011-12-18 09:08:59 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(mode);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
struct vbePanelID *
|
|
|
|
VBEReadPanelID(vbeInfoPtr pVbe)
|
|
|
|
{
|
|
|
|
int RealOff = pVbe->real_mode_base;
|
|
|
|
pointer page = pVbe->memory;
|
2009-09-06 13:44:18 -06:00
|
|
|
void *tmp = NULL;
|
2013-06-07 11:28:45 -06:00
|
|
|
int screen = pVbe->pInt10->pScrn->scrnIndex;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
|
|
|
pVbe->pInt10->ax = 0x4F11;
|
|
|
|
pVbe->pInt10->bx = 0x01;
|
|
|
|
pVbe->pInt10->cx = 0;
|
|
|
|
pVbe->pInt10->dx = 0;
|
|
|
|
pVbe->pInt10->es = SEG_ADDR(RealOff);
|
|
|
|
pVbe->pInt10->di = SEG_OFF(RealOff);
|
|
|
|
pVbe->pInt10->num = 0x10;
|
|
|
|
|
|
|
|
xf86ExecX86int10(pVbe->pInt10);
|
|
|
|
|
|
|
|
if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE PanelID invalid\n");
|
|
|
|
goto error;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (pVbe->pInt10->ax & 0xff00) {
|
|
|
|
case 0x0:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3,
|
|
|
|
"VESA VBE PanelID read successfully\n");
|
|
|
|
tmp = xnfalloc(32);
|
|
|
|
memcpy(tmp, page, 32);
|
|
|
|
break;
|
2007-11-24 10:55:21 -07:00
|
|
|
case 0x100:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3, "VESA VBE PanelID read failed\n");
|
|
|
|
break;
|
2007-11-24 10:55:21 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86DrvMsgVerb(screen, X_INFO, 3,
|
|
|
|
"VESA VBE PanelID unknown failure %i\n",
|
|
|
|
pVbe->pInt10->ax & 0xff00);
|
|
|
|
break;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
error:
|
2007-11-24 10:55:21 -07:00
|
|
|
return tmp;
|
|
|
|
}
|