From 558d477a4776bc4dfd1c3972372933f0820d4574 Mon Sep 17 00:00:00 2001 From: Niklas Hallqvist Date: Thu, 18 Sep 1997 22:03:46 +0000 Subject: Match with current kernel; from NetBSD --- usr.sbin/grfconfig/Makefile | 10 +- usr.sbin/grfconfig/grfconfig.8 | 142 ++++++++++---- usr.sbin/grfconfig/grfconfig.c | 406 +++++++++++++++++++++++++++++++---------- 3 files changed, 424 insertions(+), 134 deletions(-) diff --git a/usr.sbin/grfconfig/Makefile b/usr.sbin/grfconfig/Makefile index 34432f857a5..fe708a517f1 100644 --- a/usr.sbin/grfconfig/Makefile +++ b/usr.sbin/grfconfig/Makefile @@ -1,7 +1,11 @@ -# $NetBSD: Makefile,v 1.1 1995/10/09 03:43:22 chopps Exp $ +# $OpenBSD: Makefile,v 1.2 1997/09/18 22:03:44 niklas Exp $ +# $NetBSD: Makefile,v 1.3 1997/07/29 18:03:34 veego Exp $ + +.if ${MACHINE} == "amiga" +PROG= grfconfig +CFLAGS+= -I${.CURDIR}/../../sys/arch -D${MACHINE} +.endif -PROG= grfconfig MAN= grfconfig.8 -CFLAGS+=-I${.CURDIR}/../../sys/arch -D${MACHINE} .include diff --git a/usr.sbin/grfconfig/grfconfig.8 b/usr.sbin/grfconfig/grfconfig.8 index 36f2cf12b34..08f2cfea7f9 100644 --- a/usr.sbin/grfconfig/grfconfig.8 +++ b/usr.sbin/grfconfig/grfconfig.8 @@ -1,8 +1,12 @@ -.\" $NetBSD: grfconfig.8,v 1.3 1995/12/27 07:59:00 chopps Exp $ +.\" $OpenBSD: grfconfig.8,v 1.3 1997/09/18 22:03:45 niklas Exp $ +.\" $NetBSD: grfconfig.8,v 1.4 1997/07/29 17:40:47 veego Exp $ .\" -.\" Copyright (c) 1994 Ezra Story +.\" Copyright (c) 1997 The NetBSD Foundation, Inc. .\" All rights reserved. .\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Ezra Story and Bernd Ernesti. +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -13,37 +17,39 @@ .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: -.\" This product includes software developed by Ezra Story. -.\" 3. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation nor the names of its +.\" contributors may be used to endorse or promote products derived +.\" from this software without specific prior written permission. .\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE +.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. .\" .Dd October 7, 1994 .Dt GRFCONFIG 8 amiga -.Os +.Os OpenBSD .Sh NAME .Nm grfconfig .Nd alter grf device screen mode definitions at run time .Sh SYNOPSIS -.Nm grfconfig +.Nm .Op Fl r .Ar device .Op Ar file .Sh DESCRIPTION -.Nm Grfconfig +.Nm is used to change or view the screen mode definition list contained -in a grf device. You may also alter the console screen definition as well +in a grf device. You may alter the console screen definition as well as the definitions for the graphic screen. The console will automatically reinitialize itself to the new screen mode. .Pp @@ -58,18 +64,18 @@ The grf device to manipulate. This argument is required. .It Ar file The file which contains the mode definitions. If this argument is not specified, -.Nm grfconfig +.Nm will print out of a list of the modes currently loaded into the grf device. .Pp .Sh MODE DEFINITION FILE The mode definitions are taken from a file which has lines of the format: .Pp -num clk wid hi dep hbs hss hse hbe ht vbs vss vse vbe vt +num clk wid hi dep hbs hss hse ht vbs vss vse vt flags .Pp .Bl -tag -width indent .It Ar num -The mode number for 'c' for the console mode. +The mode number or 'c' for the console mode. .It Ar clk The pixel clock in Hz. .It Ar wid @@ -78,17 +84,38 @@ The screen mode's width. The screen mode's height. .It Ar dep The bitdepth of the mode. -.It Ar hbs hss hse hbe ht -The horizonatal timing parameters for the mode in pixel values. All the +.It Ar hbs hss hse ht +The horizontal timing parameters for the mode in pixel values. All the values are relative to the end of the horizontal blank (beginning of the displayed area). -.It Ar vbs vss vse vbe vt +.It Ar vbs vss vse vt The vertical timing paramters for the mode in line values. All the values are relative to the end of vertical blank (beginning of the displayed -area). If vbs is half the width, the grf device will interlace the -display. -If the vbs is twice the width, the grf device will scan double the display. -This is provided the grf device supports those two modes of operation. +area). +.It Ar flags +By default every mode uses negative horizontal and vertical sync pulses, +it is non-interlaced and does not use scandoubling. +.Pp +.Bl -tag -width sync-on-green -offset indent +.It default +Use the default flags: -hsync -vsync +.It doublescan +Doublescan mode +.It interlace +Interlace mode +.It +hsync +Positive horizontal sync pulses +.It -hsync +Negative horizontal sync pulses +.It +vsync +Positive vertical sync pulses +.It -vsync +Negative vertical sync pulses +.It sync-on-green +Composite sync on green +.Pp +.El +.Pp .El .Pp .nf @@ -126,10 +153,53 @@ This is provided the grf device supports those two modes of operation. vbe - +.Sh HISTORY +The +.Nm +command first appeared in +.Nx 1.0 +.Pp +The mode definition file changed two times. +.Pp +In +.Nx 1.0 +all horizontal values were videoclock cycle values instead of pixel values: +.Pp + num clk wid hi dep hbs hss hse hbe ht vbs vss vse vbe vt +.br + 1 31000000 640 480 8 80 86 96 102 104 480 489 492 517 520 + 2 31000000 640 480 8 80 86 96 102 104 240 244 246 258 260 + 3 31000000 640 480 8 80 86 96 102 104 960 978 984 1034 1040 +.Pp +In +.Nx 1.1 +and +.Nx 1.2 : +.Pp + num clk wid hi dep hbs hss hse hbe ht vbs vss vse vbe vt +.br + 1 31000000 640 480 8 640 688 768 816 832 480 489 492 517 520 + 2 31000000 640 480 8 640 688 768 816 832 240 244 246 258 260 + 3 31000000 640 480 8 640 688 768 816 832 960 978 984 1034 1040 +.Pp +the vertical values were used to select the interlace or doublescan mode. +All vertical values were half the width for the interlace mode and twice +the width for the doublescan mode. +.Pp +Beginning with +.Nx 1.3 : +.Pp + num clk wid hi dep hbs hss hse ht vbs vss vse vt flags +.br + 1 31000000 640 480 8 640 688 768 832 480 489 492 520 default + 2 31000000 640 480 8 640 688 768 832 480 489 492 520 interlace + 3 31000000 640 480 8 640 688 768 832 480 489 492 520 doublescan + 4 31000000 640 480 8 640 688 768 832 480 489 492 520 +hsync +vsync +.Pp +hbe and vbe are computed in the grf drivers. +.Pp .Sh BUGS -Some grf devices only understand horizontal cycle values instead of -horizontal pixel values. Add -the option -.Nm -o -to make grfconfig interpret values from the grf device as cycle values. +.Nm +can not set the modes for /dev/grf1, /dev/grf2 and /dev/grf4 +and it will not work for /dev/grf0. + diff --git a/usr.sbin/grfconfig/grfconfig.c b/usr.sbin/grfconfig/grfconfig.c index e40059b1ad4..a3babd2b2ad 100644 --- a/usr.sbin/grfconfig/grfconfig.c +++ b/usr.sbin/grfconfig/grfconfig.c @@ -1,9 +1,13 @@ -/* $NetBSD: grfconfig.c,v 1.4 1996/05/19 09:02:44 veego Exp $ */ +/* $OpenBSD: grfconfig.c,v 1.4 1997/09/18 22:03:45 niklas Exp $ */ +/* $NetBSD: grfconfig.c,v 1.6 1997/07/29 23:41:12 veego Exp $ */ -/* - * Copyright (c) 1995 Ezra Story +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Ezra Story and Bernd Ernesti. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -14,58 +18,93 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Ezra Story. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ + +#include + +#ifndef lint +static char rcsid[] = "$OpenBSD: grfconfig.c,v 1.4 1997/09/18 22:03:45 niklas Exp $"; +#endif /* not lint */ + +#include +#include +#include +#include #include #include #include -#include -#include +#include #include extern char *optarg; extern int optind; +int main __P((int, char **)); +static void print_rawdata __P((struct grfvideo_mode *, int)); + +static struct grf_flag { + u_short grf_flag_number; + char *grf_flag_name; +} grf_flags[] = { + {GRF_FLAGS_DBLSCAN, "doublescan"}, + {GRF_FLAGS_LACE, "interlace"}, + {GRF_FLAGS_PHSYNC, "+hsync"}, + {GRF_FLAGS_NHSYNC, "-hsync"}, + {GRF_FLAGS_PVSYNC, "+vsync"}, + {GRF_FLAGS_NVSYNC, "-vsync"}, + {GRF_FLAGS_SYNC_ON_GREEN, "sync-on-green"}, + {0, 0} +}; + /* - * Dynamic mode loader for NetBSD/Amiga grf devices. + * Dynamic mode loader for OpenBSD/Amiga grf devices. */ int main(ac, av) int ac; char **av; { - int c, y, grffd; - char rawdata = 0; - char oldmode = 1; - char *grfdevice = 0; - char *modefile = 0; - char buf[102]; - char ystr[20]; - FILE *fp; - struct grfvideo_mode gv[1]; - - while ((c = getopt(ac, av, "ro")) != -1) { + struct grfvideo_mode gv[1]; + struct grf_flag *grf_flagp; + FILE *fp; + int c, y, grffd; + int i, lineno = 0; + int uplim, lowlim; + char rawdata = 0, testmode = 0; + char *grfdevice = 0; + char *modefile = 0; + char buf[_POSIX2_LINE_MAX], obuf[_POSIX2_LINE_MAX]; + char *cps[31]; + char *p; + char *errortext; + + + while ((c = getopt(ac, av, "rt")) != -1) { switch (c) { case 'r': /* raw output */ rawdata = 1; break; - case 'o': - oldmode = 8; - break; + case 't': /* test the modefile without setting it */ + testmode = 1; + break; default: printf("grfconfig [-r] device [file]\n"); return (1); @@ -93,49 +132,199 @@ main(ac, av) if (modefile) { if (!(fp = fopen(modefile, "r"))) { - printf("grfconfig: Cannot open mode definition file.\n"); + printf("grfconfig: Cannot open mode definition " + "file.\n"); return (1); } - while (fgets(buf, 300, fp)) { - if (buf[0] == '#') + while (fgets(buf, sizeof(buf), fp)) { + /* + * check for end-of-section, comments, strip off trailing + * spaces and newline character. + */ + for (p = buf; isspace(*p); ++p) + continue; + if (*p == '\0' || *p == '#') continue; + for (p = strchr(buf, '\0'); isspace(*--p);) + continue; + *++p = '\0'; - /* num clk wid hi dep hbs hss hse hbe ht vbs vss vse - * vbe vt */ - - c = sscanf(buf, "%9s %d %hd %hd %hd %hd %hd %hd " - "%hd %hd %hd %hd %hd %hd %hd", - ystr, - &gv->pixel_clock, - &gv->disp_width, - &gv->disp_height, - &gv->depth, - &gv->hblank_start, - &gv->hsync_start, - &gv->hsync_stop, - &gv->hblank_stop, - &gv->htotal, - &gv->vblank_start, - &gv->vsync_start, - &gv->vsync_stop, - &gv->vblank_stop, - &gv->vtotal); - if (c == 15) { - if (y = atoi(ystr)) - gv->mode_num = y; - else - if (ystr[0] == 'c') { - gv->mode_num = 255; - gv->depth = 4; - } + sprintf(obuf, "%s", buf); + lineno = lineno + 1; + + for (i = 0, *cps = strtok(buf, " \b\t\r\n"); + cps[i] != NULL && i < 30; i++) + cps[i + 1] = strtok(NULL, " \b\t\r\n"); + cps[i] = NULL; + + if (cps[13] == NULL) { + printf("grfconfig: too few values in mode " + "definition file:\n %s\n", obuf); + return (1); + } + + gv->pixel_clock = atoi(cps[1]); + gv->disp_width = atoi(cps[2]); + gv->disp_height = atoi(cps[3]); + gv->depth = atoi(cps[4]); + gv->hblank_start = atoi(cps[5]); + gv->hsync_start = atoi(cps[6]); + gv->hsync_stop = atoi(cps[7]); + gv->htotal = atoi(cps[8]); + gv->vblank_start = atoi(cps[9]); + gv->vsync_start = atoi(cps[10]); + gv->vsync_stop = atoi(cps[11]); + gv->vtotal = atoi(cps[12]); + + if ((y = atoi(cps[0]))) + gv->mode_num = y; + else + if (strncasecmp("c", cps[0], 1) == 0) { + gv->mode_num = 255; + gv->depth = 4; + } else { + printf("grfconfig: Illegal mode " + "number: %s\n", cps[0]); + return (1); + } + + if ((gv->pixel_clock == 0) || + (gv->disp_width == 0) || + (gv->disp_height == 0) || + (gv->depth == 0) || + (gv->hblank_start == 0) || + (gv->hsync_start == 0) || + (gv->hsync_stop == 0) || + (gv->htotal == 0) || + (gv->vblank_start == 0) || + (gv->vsync_start == 0) || + (gv->vsync_stop == 0) || + (gv->vtotal == 0)) { + printf("grfconfig: Illegal value in " + "mode #%d:\n %s\n", gv->mode_num, obuf); + return (1); + } + + if (strstr(obuf, "default") != NULL) { + gv->disp_flags = GRF_FLAGS_DEFAULT; + } else { + gv->disp_flags = GRF_FLAGS_DEFAULT; + for (grf_flagp = grf_flags; + grf_flagp->grf_flag_number; grf_flagp++) { + if (strstr(obuf, grf_flagp->grf_flag_name) != NULL) { + gv->disp_flags |= grf_flagp->grf_flag_number; + } + } + if (gv->disp_flags == GRF_FLAGS_DEFAULT) { + printf("grfconfig: Your are using an " + "mode file with an obsolete " + "format.\n See the manpage of " + "grfconfig for more information " + "about the new mode definition " + "file.\n"); + return (1); + } + } + + /* + * Check for impossible gv->disp_flags: + * doublescan and interlace, + * +hsync and -hsync + * +vsync and -vsync. + */ + errortext = NULL; + if ((gv->disp_flags & GRF_FLAGS_DBLSCAN) && + (gv->disp_flags & GRF_FLAGS_LACE)) + errortext = "Interlace and Doublescan"; + if ((gv->disp_flags & GRF_FLAGS_PHSYNC) && + (gv->disp_flags & GRF_FLAGS_NHSYNC)) + errortext = "+hsync and -hsync"; + if ((gv->disp_flags & GRF_FLAGS_PVSYNC) && + (gv->disp_flags & GRF_FLAGS_NVSYNC)) + errortext = "+vsync and -vsync"; + + if (errortext != NULL) { + printf("grfconfig: Illegal flags in " + "mode #%d: %s are both defined!\n", + gv->mode_num, errortext); + return (1); + } + + /* Check for old horizontal cycle values */ + if ((gv->htotal < (gv->disp_width / 4))) { + gv->hblank_start *= 8; + gv->hsync_start *= 8; + gv->hsync_stop *= 8; + gv->htotal *= 8; + printf("grfconfig: Old and no longer " + "supported horizontal videoclock cycle " + "values.\n Wrong mode line:\n %s\n " + "This could be a possible good mode " + "line:\n ", obuf); + printf("%d ", gv->mode_num); + print_rawdata(gv, 0); + printf(" See the manpage of grfconfig for " + "more information about the new mode " + "definition file.\n"); + return (1); + } + + /* Check for old interlace or doublescan modes */ + uplim = gv->disp_height + (gv->disp_height / 4); + lowlim = gv->disp_height - (gv->disp_height / 4); + if (((gv->vtotal * 2) > lowlim) && + ((gv->vtotal * 2) < uplim)) { + gv->vblank_start *= 2; + gv->vsync_start *= 2; + gv->vsync_stop *= 2; + gv->vtotal *= 2; + gv->disp_flags &= ~GRF_FLAGS_DBLSCAN; + gv->disp_flags |= GRF_FLAGS_LACE; + printf("grfconfig: Old and no longer " + "supported vertical values for " + "interlace modes.\n Wrong mode " + "line:\n %s\n This could be a " + "possible good mode line:\n ", obuf); + printf("%d ", gv->mode_num); + print_rawdata(gv, 0); + printf(" See the manpage of grfconfig for " + "more information about the new mode " + "definition file.\n"); + return (1); + } else if (((gv->vtotal / 2) > lowlim) && + ((gv->vtotal / 2) < uplim)) { + gv->vblank_start /= 2; + gv->vsync_start /= 2; + gv->vsync_stop /= 2; + gv->vtotal /= 2; + gv->disp_flags &= ~GRF_FLAGS_LACE; + gv->disp_flags |= GRF_FLAGS_DBLSCAN; + printf("grfconfig: Old and no longer " + "supported vertical values for " + "doublescan modes.\n Wrong mode " + "line:\n %s\n This could be a " + "possible good mode line:\n ", obuf); + printf("%d ", gv->mode_num); + print_rawdata(gv, 0); + printf(" See the manpage of grfconfig for " + "more information about the new mode " + "definition file.\n"); + return (1); + } + + if (testmode == 1) { + if (lineno == 1) + printf("num clk wid hi dep hbs " + "hss hse ht vbs vss vse vt " + "flags\n"); + printf("%d ", gv->mode_num); + print_rawdata(gv, 1); + } else { gv->mode_descr[0] = 0; if (ioctl(grffd, GRFIOCSETMON, (char *) gv) < 0) printf("grfconfig: bad monitor " "definition for mode #%d.\n", gv->mode_num); - } else { - printf("grfconfig: bad line in mode " - "definition file.\n"); } } fclose(fp); @@ -151,23 +340,7 @@ main(ac, av) printf("c "); else printf("%d ", c); - printf("%d %d %d %d %d %d %d " - "%d %d %d %d %d %d %d\n", - gv->pixel_clock, - gv->disp_width, - gv->disp_height, - gv->depth, - gv->hblank_start, - gv->hsync_start, - gv->hsync_stop, - gv->hblank_stop, - gv->htotal, - gv->vblank_start, - gv->vsync_start, - gv->vsync_stop, - gv->vblank_stop, - gv->vtotal - ); + print_rawdata(gv, 0); continue; } if (c == 255) @@ -186,21 +359,64 @@ main(ac, av) gv->disp_width / 8, gv->disp_height / gv->depth); - printf("\t%d.%dkHz @ %dHz %s\n", - gv->pixel_clock / (gv->htotal * 1000 * oldmode), - (gv->pixel_clock / (gv->htotal * 100 * oldmode)) + printf("\t%ld.%ldkHz @ %ldHz", + gv->pixel_clock / (gv->htotal * 1000), + (gv->pixel_clock / (gv->htotal * 100)) % 10, - gv->pixel_clock / (gv->htotal * gv->vtotal * - oldmode), - gv->vblank_start + 100 < gv->disp_height ? - "I" : - (gv->vblank_start - 100) > gv->disp_height ? - "SD" : - "NI" - ); + gv->pixel_clock / (gv->htotal * gv->vtotal)); + printf(" flags:"); + + if (gv->disp_flags == GRF_FLAGS_DEFAULT) { + printf(" default"); + } else { + for (grf_flagp = grf_flags; + grf_flagp->grf_flag_number; grf_flagp++) { + if (gv->disp_flags & grf_flagp->grf_flag_number) { + printf(" %s", grf_flagp->grf_flag_name); + } + } + } + printf("\n"); } } close(grffd); return (0); } + +static void +print_rawdata(gv, rawflags) + struct grfvideo_mode *gv; + int rawflags; +{ + struct grf_flag *grf_flagp; + + printf("%ld %d %d %d %d %d %d %d %d %d %d %d", + gv->pixel_clock, + gv->disp_width, + gv->disp_height, + gv->depth, + gv->hblank_start, + gv->hsync_start, + gv->hsync_stop, + gv->htotal, + gv->vblank_start, + gv->vsync_start, + gv->vsync_stop, + gv->vtotal); + if (rawflags) { + printf(" 0x%.2x", gv->disp_flags); + } else { + if (gv->disp_flags == GRF_FLAGS_DEFAULT) { + printf(" default"); + } else { + for (grf_flagp = grf_flags; + grf_flagp->grf_flag_number; grf_flagp++) { + if (gv->disp_flags & grf_flagp->grf_flag_number) { + printf(" %s", grf_flagp->grf_flag_name); + } + } + } + } + printf("\n"); +} -- cgit v1.2.3