diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-02-02 02:58:59 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-02-02 02:58:59 +0100 |
commit | 8067368e10330a67550f9e3ee353da858266a6eb (patch) | |
tree | da29460c6810b48ee67b2d330c04a22a3ab35379 /sys/src/cmd/aux/vga/main.c | |
parent | e34fa15921cd76d78e7adc28e471204de036d66a (diff) |
aux/vga: use optional edid information to determine mode when vgadb fails
igfx and vesa can determine monitor timing information from ddc
and store the edid info for connected monitors in vga->edid[].
when monitor type cannot be found in vgadb, we consult the edid
information and make a mode based on the edid info.
this avoids having to maintain a vgadb entry for each monitor.
monitor can be set to "[width]x[height]@[freq]Hz" for a specific
edid setting. when not found, a mode is searched based on the
size.
so the following should work:
aux/vga -m 1366x768@60Hz -l 1366x768x32
aux/vga -m auto -l 1366x768x32
Diffstat (limited to 'sys/src/cmd/aux/vga/main.c')
-rw-r--r-- | sys/src/cmd/aux/vga/main.c | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/sys/src/cmd/aux/vga/main.c b/sys/src/cmd/aux/vga/main.c index a42e8e648..188801e89 100644 --- a/sys/src/cmd/aux/vga/main.c +++ b/sys/src/cmd/aux/vga/main.c @@ -17,6 +17,7 @@ dump(Vga* vga) { Ctlr *ctlr; Attr *attr; + int i; if(vga->mode) dbdumpmode(vga->mode); @@ -37,6 +38,12 @@ dump(Vga* vga) (*ctlr->dump)(vga, ctlr); ctlr->flag |= Fdump; } + + for(i=0; i < nelem(vga->edid); i++){ + if(vga->edid[i]) + printedid(vga->edid[i]); + } + Bprint(&stdout, "\n"); } @@ -135,6 +142,54 @@ linear(Vga* vga) vgactlw("linear", "0"); } +static Mode* +dbedidmode(Vga *vga, char *type, char *size) +{ + char buf[32], *p; + int i, x, y, z; + Modelist *l; + Mode *m; + + z = 32; + x = y = 0; + snprint(buf, sizeof(buf), "%s", size); + if((p = strchr(buf, 'x')) != nil){ + *p++ = 0; + x = atoi(buf); + y = atoi(p); + if((p = strchr(p, 'x')) != nil){ + *p++ = 0; + z = atoi(p); + } + } + + for(i=0; i<nelem(vga->edid); i++){ + if(vga->edid[i] == nil) + continue; + for(l = vga->edid[i]->modelist; l != nil; l = l->next) + if(strcmp(l->name, type) == 0) + goto found; + } + for(i=0; i<nelem(vga->edid); i++){ + if(vga->edid[i] == nil) + continue; + for(l = vga->edid[i]->modelist; l != nil; l = l->next) + if((x == 0 || l->x == x) && (y == 0 || l->y == y)) + goto found; + } + return nil; + +found: + m = alloc(sizeof(Mode)); + *m = *((Mode*)l); + m->z = z; + x = m->x; + y = m->y; + snprint(m->type, sizeof(m->type), "%s", type); + snprint(m->size, sizeof(m->size), "%dx%dx%d", x, y, z); + return m; +} + char* chanstr[32+1] = { [1] "k1", @@ -291,10 +346,13 @@ main(int argc, char** argv) if(vga->vesa){ strcpy(monitordb, "vesa bios"); - vga->mode = dbvesamode(psize); - }else + vga->mode = dbvesamode(vga, psize); + }else { vga->mode = dbmode(monitordb, type, psize); - if(vga->mode == 0) + if(vga->mode == nil) + vga->mode = dbedidmode(vga, type, psize); + } + if(vga->mode == nil) error("main: %s@%s not in %s\n", type, psize, monitordb); if(virtual){ |