From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8097 invoked from network); 28 Feb 2022 22:32:37 -0000 Received: from 4ess.inri.net (216.126.196.42) by inbox.vuxu.org with ESMTPUTF8; 28 Feb 2022 22:32:37 -0000 Received: from balrog.mythic-beasts.com ([46.235.227.24]) by 4ess; Mon Feb 28 17:24:49 -0500 2022 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=quintile.net; s=mythic-beasts-k1; h=To:Date:Subject:From; bh=+UEyCQdMJ+QmD6KTU3H+yOnIaG9ulUD6iSI7bIy6reE=; b=WQrrD2Yu2TShr+cJ79PdbbfeEK JLOjauU9LVrCB0v4rTvaMm61wI6/yecr+bGwDQD2QZow0/WbZ6DHW2ZPIDKsGQSIM/kcpxu2LbP4a oXvi4+kLGK4y1NE6RuZ2foStMZ62Afgk5kFg9oewljcjgmT5CiT5sAqXUJF6sQTIHcoC9l4QfZ8HP cDKp9W1cY0TkdHB+URXIjvdRKG3wItna7l+WFHqHg8lR1ydzZQj3+xg3akMMMLP+xMDo4sVVP5lzv kNhfV43R8WGgGnhnvGgQBZtC1uNSCGuXSxDENj61DwkUBkrooJ+BM2DGqkHdId9k+bfV64Mqn+wCN e/947GEg==; Received: from [81.187.198.132] (port=56988 helo=smtpclient.apple) by balrog.mythic-beasts.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1nOoAL-00012Y-SU for 9front@9front.org; Mon, 28 Feb 2022 22:06:53 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Steve Simon Mime-Version: 1.0 (1.0) Date: Mon, 28 Feb 2022 22:06:48 +0000 Message-Id: <4996D1CF-0CF6-4ED6-BD9D-22BDEDF1B922@quintile.net> References: <20220228212052.16195-1-mforney@mforney.org> In-Reply-To: <20220228212052.16195-1-mforney@mforney.org> To: 9front@9front.org X-Mailer: iPhone Mail (19D52) X-BlackCat-Spam-Score: 4 List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: abstract stateless realtime-java generator Subject: Re: [9front] [PATCH] aux/vga: return modes according to EDID timing priority order Reply-To: 9front@9front.org Precedence: bulk kudos for this work. > On 28 Feb 2022, at 9:29 pm, Michael Forney wrote: >=20 > =EF=BB=BF > EDID 1.3 section 5 gives a table describing the priority order of > timing information. Use this ordering when constructing the EDID > mode list. >=20 > Since aux/vga selects the first mode in the modelist that matches > the given size, it will now select the mode of that size with the > highest preference. Or, if you set vgasize=3Dauto (or some other > string without an 'x'), aux/vga will select the Preferred Detailed > Timing. >=20 > This should make it unnecessary to modify vgadb in many cases. > --- > sys/src/cmd/aux/vga/edid.c | 133 ++++++++++++++++++++----------------- > 1 file changed, 73 insertions(+), 60 deletions(-) >=20 > diff --git a/sys/src/cmd/aux/vga/edid.c b/sys/src/cmd/aux/vga/edid.c > index d475678fe..09a0acbbc 100644 > --- a/sys/src/cmd/aux/vga/edid.c > +++ b/sys/src/cmd/aux/vga/edid.c > @@ -6,8 +6,8 @@ > #include "pci.h" > #include "vga.h" >=20 > -static Modelist* > -addmode(Modelist *l, Mode m) > +static void > +addmode(Modelist **l, Mode m) > { > Modelist *ll; > int rr; > @@ -15,17 +15,15 @@ addmode(Modelist *l, Mode m) > rr =3D (m.frequency+m.ht*m.vt/2)/(m.ht*m.vt); > snprint(m.name, sizeof m.name, "%dx%d@%dHz", m.x, m.y, rr); >=20 > - for(ll =3D l; ll !=3D nil; ll =3D ll->next){ > - if(strcmp(ll->name, m.name) =3D=3D 0){ > - ll->Mode =3D m; > - return l; > - } > + for(ll =3D *l; ll !=3D nil; ll =3D *l){ > + if(strcmp(ll->name, m.name) =3D=3D 0) > + return; > + l =3D &ll->next; > } >=20 > ll =3D alloc(sizeof(Modelist)); > ll->Mode =3D m; > - ll->next =3D l; > - return ll; > + *l =3D ll; > } >=20 > /* > @@ -282,70 +280,85 @@ parseedid128(void *v) >=20 > assert(p =3D=3D (uchar*)v+8+10+2+5+10); > /* > - * Established timings: a bitmask of 19 preset timings. > + * Timing information priority order (EDID 1.3 section 5) > + * 1. Preferred Timing Mode (first detailed timing block) > + * 2. Other Detailed Timing Mode, in order listed > + * 3. Standard Timings, in order listed > + * 4. Established Timings > */ > - estab =3D (p[0]<<16) | (p[1]<<8) | p[2]; > - p +=3D 3; >=20 > - for(i=3D0, m=3D1<<23; i>=3D1) > - if(estab & m) > - if(vesalookup(&mode, estabtime[i]) =3D=3D 0) > - e->modelist =3D addmode(e->modelist, mode); > + /* > + * Detailed Timings > + */ > + p =3D (uchar*)v+8+10+2+5+10+3+16; > + for(i=3D0; i<4; i++, p+=3D18) > + if(p[0] || p[1]) /* detailed timing block: p[0] or p[1] !=3D 0= */ > + if(decodedtb(&mode, p) =3D=3D 0) > + addmode(&e->modelist, mode); > + assert(p =3D=3D (uchar*)v+8+10+2+5+10+3+16+72); >=20 > - assert(p =3D=3D (uchar*)v+8+10+2+5+10+3); > /* > * Standard Timing Identifications: eight 2-byte selectors > * of more standard timings. > */ > - > + p =3D (uchar*)v+8+10+2+5+10+3; > for(i=3D0; i<8; i++, p+=3D2) > if(decodesti(&mode, p+2*i) =3D=3D 0) > - e->modelist =3D addmode(e->modelist, mode); > - > + addmode(&e->modelist, mode); > assert(p =3D=3D (uchar*)v+8+10+2+5+10+3+16); > - /* > - * Detailed Timings > - */ > - for(i=3D0; i<4; i++, p+=3D18) { > - if(p[0] || p[1]) { /* detailed timing block: p[0] or p[1] !=3D= 0 */ > - if(decodedtb(&mode, p) =3D=3D 0) > - e->modelist =3D addmode(e->modelist, mode); > - } else if(p[2]=3D=3D0) { /* monitor descriptor block */ > - switch(p[3]) { > - case 0xFF: /* monitor serial number (13-byte ascii, 0A ter= minated) */ > - if(q =3D memchr(p+5, 0x0A, 13)) > - *q =3D '\0'; > - memset(e->serialstr, 0, sizeof(e->serialstr)); > - strncpy(e->serialstr, (char*)p+5, 13); > - break; > - case 0xFE: /* ascii string (13-byte ascii, 0A terminated) *= / > - break; > - case 0xFD: /* monitor range limits */ > - e->rrmin =3D p[5]; > - e->rrmax =3D p[6]; > - e->hrmin =3D p[7]*1000; > - e->hrmax =3D p[8]*1000; > - if(p[9] !=3D 0xFF) > - e->pclkmax =3D p[9]*10*1000000; > - break; > - case 0xFC: /* monitor name (13-byte ascii, 0A terminated) *= / > - if(q =3D memchr(p+5, 0x0A, 13)) > - *q =3D '\0'; > - memset(e->name, 0, sizeof(e->name)); > - strncpy(e->name, (char*)p+5, 13); > - break; > - case 0xFB: /* extra color point data */ > - break; > - case 0xFA: /* extra standard timing identifications */ > - for(i=3D0; i<6; i++) > - if(decodesti(&mode, p+5+2*i) =3D=3D 0) > - e->modelist =3D addmode(e->modelist, mode); > - break; > - } > + > + p =3D (uchar*)v+8+10+2+5+10+3+16; > + for(i=3D0; i<4; i++, p+=3D18){ > + if(p[0] || p[1]) > + continue; > + /* monitor descriptor block */ > + switch(p[3]) { > + case 0xFF: /* monitor serial number (13-byte ascii, 0A termina= ted) */ > + if(q =3D memchr(p+5, 0x0A, 13)) > + *q =3D '\0'; > + memset(e->serialstr, 0, sizeof(e->serialstr)); > + strncpy(e->serialstr, (char*)p+5, 13); > + break; > + case 0xFE: /* ascii string (13-byte ascii, 0A terminated) */ > + break; > + case 0xFD: /* monitor range limits */ > + e->rrmin =3D p[5]; > + e->rrmax =3D p[6]; > + e->hrmin =3D p[7]*1000; > + e->hrmax =3D p[8]*1000; > + if(p[9] !=3D 0xFF) > + e->pclkmax =3D p[9]*10*1000000; > + break; > + case 0xFC: /* monitor name (13-byte ascii, 0A terminated) */ > + if(q =3D memchr(p+5, 0x0A, 13)) > + *q =3D '\0'; > + memset(e->name, 0, sizeof(e->name)); > + strncpy(e->name, (char*)p+5, 13); > + break; > + case 0xFB: /* extra color point data */ > + break; > + case 0xFA: /* extra standard timing identifications */ > + for(i=3D0; i<6; i++) > + if(decodesti(&mode, p+5+2*i) =3D=3D 0) > + addmode(&e->modelist, mode); > + break; > } > } > - > assert(p =3D=3D (uchar*)v+8+10+2+5+10+3+16+72); > + > + /* > + * Established timings: a bitmask of 19 preset timings. > + */ > + p =3D (uchar*)v+8+10+2+5+10; > + estab =3D (p[0]<<16) | (p[1]<<8) | p[2]; > + p +=3D 3; > + > + for(i=3D0, m=3D1<<23; i>=3D1) > + if(estab & m) > + if(vesalookup(&mode, estabtime[i]) =3D=3D 0) > + addmode(&e->modelist, mode); > + assert(p =3D=3D (uchar*)v+8+10+2+5+10+3); > + > return e; > } >=20 > --=20 > 2.34.1 >=20