summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorftrvxmtrx <devnull@localhost>2014-12-26 17:01:58 +0100
committerftrvxmtrx <devnull@localhost>2014-12-26 17:01:58 +0100
commit0d5b33a9e821ab0c3230bd25596b6567f2b28cd6 (patch)
treed3d87fc9131670e7625016f742561299114e6c4b
parent04ec990b670c761866da5bb0ab344da3407e78ca (diff)
downloadplan9front-0d5b33a9e821ab0c3230bd25596b6567f2b28cd6.tar.xz
aux/vga: scaling modes for VESA
-rw-r--r--sys/man/8/vga14
-rw-r--r--sys/src/cmd/aux/vga/main.c13
-rw-r--r--sys/src/cmd/aux/vga/vesa.c53
-rw-r--r--sys/src/cmd/aux/vga/vga.h1
4 files changed, 69 insertions, 12 deletions
diff --git a/sys/man/8/vga b/sys/man/8/vga
index 686c142e5..0ac6e7550 100644
--- a/sys/man/8/vga
+++ b/sys/man/8/vga
@@ -15,6 +15,10 @@ vga \- configure a VGA card
.I monitor
]
[
+.B -s
+.I scaling
+]
+[
.B -x
.I file
]
@@ -81,6 +85,16 @@ is usually set by including it in the
.B plan9.ini
file read by the PC boot program.
.TP
+.B -s
+set scaling mode to either
+.I off
+to disable completely (image will be centered),
+.I full
+to stretch to full screen
+or
+.I aspect
+to stretch while preserving aspect ratio.
+.TP
.B -p
print the current or expected register values at appropriate points depending on
other options.
diff --git a/sys/src/cmd/aux/vga/main.c b/sys/src/cmd/aux/vga/main.c
index a42e8e648..9b4de02b0 100644
--- a/sys/src/cmd/aux/vga/main.c
+++ b/sys/src/cmd/aux/vga/main.c
@@ -149,7 +149,7 @@ chanstr[32+1] = {
static void
usage(void)
{
- fprint(2, "usage: aux/vga [ -BcdilpvV ] [ -b bios-id ] [ -m monitor ] [ -x db ] [ mode [ virtualsize ] ]\n");
+ fprint(2, "usage: aux/vga [ -BcdilpvV ] [ -b bios-id ] [ -m monitor ] [-s scaling] [ -x db ] [ mode [ virtualsize ] ]\n");
exits("usage");
}
@@ -157,7 +157,7 @@ void
main(int argc, char** argv)
{
char *bios, buf[256], sizeb[256], *p, *vsize, *psize;
- char *type, *vtype;
+ char *type, *vtype, *scaling;
int virtual, len;
Ctlr *ctlr;
Vga *vga;
@@ -169,6 +169,7 @@ main(int argc, char** argv)
if((type = getenv("monitor")) == 0)
type = "vga";
psize = vsize = "640x480x8";
+ scaling = nil;
ARGBEGIN{
default:
@@ -204,6 +205,9 @@ main(int argc, char** argv)
*/
rflag++;
break;
+ case 's':
+ scaling = EARGF(usage());
+ break;
case 'v':
vflag = 1;
break;
@@ -467,6 +471,11 @@ main(int argc, char** argv)
}
}
+ if(scaling != nil){
+ if(vga->vesa)
+ vesa.scaling(vga, vga->vesa, scaling);
+ }
+
trace("main->exits\n");
exits(0);
}
diff --git a/sys/src/cmd/aux/vga/vesa.c b/sys/src/cmd/aux/vga/vesa.c
index 1375b2813..f561ac22b 100644
--- a/sys/src/cmd/aux/vga/vesa.c
+++ b/sys/src/cmd/aux/vga/vesa.c
@@ -105,6 +105,8 @@ void vesaddc(void);
int vbeddcedid(Vbe *vbe, Edid *e);
void printedid(Edid*);
void fixbios(Vbe*);
+uchar* vbesetup(Vbe*, Ureg*, int);
+int vbecall(Vbe*, Ureg*);
int
dbvesa(Vga* vga)
@@ -192,7 +194,7 @@ havemode:
*m = *vesamodes[i];
break;
}
- if(edid){
+ if(edid != nil){
for(l = edid->modelist; l; l = l->next){
if(l->x != vm.dx || l->y != vm.dy)
continue;
@@ -272,7 +274,7 @@ dump(Vga*, Ctlr*)
char did[0x200];
uchar *p, *ep;
- if(!vbe){
+ if(vbe == nil){
Bprint(&stdout, "no vesa bios\n");
return;
}
@@ -280,7 +282,7 @@ dump(Vga*, Ctlr*)
memset(did, 0, sizeof did);
vbeprintinfo(vbe);
p = vbemodes(vbe);
- if(p){
+ if(p != nil){
for(ep=p+1024; (p[0]!=0xFF || p[1]!=0xFF) && p<ep; p+=2){
vbeprintmodeinfo(vbe, WORD(p), "");
if(WORD(p) < nelem(did))
@@ -290,17 +292,48 @@ dump(Vga*, Ctlr*)
for(i=0x100; i<0x1FF; i++)
if(!did[i])
vbeprintmodeinfo(vbe, i, " (unoffered)");
- if(edid)
+ if(edid != nil)
printedid(edid);
}
+static void
+scaling(Vga*, Ctlr* ctlr, char* scaling)
+{
+ Ureg u;
+ int mode;
+
+ if(vbe == nil)
+ error("no vesa bios\n");
+
+ if(strcmp(scaling, "off") == 0)
+ mode = 1;
+ else if(strcmp(scaling, "aspect") == 0)
+ mode = 3;
+ else if(strcmp(scaling, "full") == 0)
+ mode = 0;
+ else{
+ ctlr->flag |= Ferror;
+ fprint(2, "vbescaling: unknown mode %s\n", scaling);
+ return;
+ }
+
+ vbesetup(vbe, &u, 0x4F14);
+ u.bx = 0x102;
+ u.cx = mode;
+ if(vbecall(vbe, &u) < 0){
+ ctlr->flag |= Ferror;
+ fprint(2, "vbescaling: %r\n");
+ }
+}
+
Ctlr vesa = {
- "vesa", /* name */
- snarf, /* snarf */
- options, /* options */
- 0, /* init */
- load, /* load */
- dump, /* dump */
+ "vesa",
+ snarf,
+ options,
+ nil,
+ load,
+ dump,
+ scaling,
};
Ctlr softhwgc = {
diff --git a/sys/src/cmd/aux/vga/vga.h b/sys/src/cmd/aux/vga/vga.h
index b6b6a9d20..33fdb61ca 100644
--- a/sys/src/cmd/aux/vga/vga.h
+++ b/sys/src/cmd/aux/vga/vga.h
@@ -49,6 +49,7 @@ typedef struct Ctlr {
void (*init)(Vga*, Ctlr*);
void (*load)(Vga*, Ctlr*);
void (*dump)(Vga*, Ctlr*);
+ void (*scaling)(Vga*, Ctlr*, char*);
char* type;
ulong flag;