*BSD News Article 6052


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel!munnari.oz.au!sgiblab!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!destroyer!uunet!mcsun!sunic!sics.se!jonas
From: jonas@sisu.se (Jonas Lagerblad)
Subject: Re: help: Xconfig for Xfree86
Message-ID: <1992Oct5.135455.17767@sics.se>
Sender: news@sics.se
Organization: Swedish Institute of Systems Development
References: <1992Oct5.025342.22047@umr.edu>
Date: Mon, 5 Oct 1992 13:54:55 GMT
Lines: 125

In article <1992Oct5.025342.22047@umr.edu> jlu@cs.umr.edu ( Eric Jui-Lin Lu ) writes:
>Greetings *,
>
>I have asked for help last Friday.  Since I got no response so far,
>I think I better asking for help again.  I have problem to start up
>X in 386bsd 0.1.  I believe it's caused by Xconfig.  I have followed
....
>
>What I have in my Xconfig:
>
>vga256
>chipset "et4000"
>virtual 1152 900
>viewport 0 0
>[NOTE: I don't have clocks setting since I don't know how to do it.]
>Modes "800x600" "640x480"
>
>VGA card: VGA MENTOR (based on Tseng's ET4000 Turbo MegaVGA Chip and BIOS)
>          a little tin can shows 50.000 MHz
>          (I assumed it's 50MHz)
This is probably not correct (it is 50Mhz) this oscillator isn't the clock
used to generate the Video signal. The simplest method to get the clocks
supported by your et4000 chip is to run xinit, and save the output to a file.
for example:

    % xinit >& File
    ... (kill X or something)
    % cat File
    X386 Version 1.2E 1.0.2a  / X Window System
    (protocol Version 11, revision 0, vendor release 5000)
    VGA256: et4000 (mem: 1024k numclocks: 16)
    VGA256:   clocks: 25 28 33 37 40 45 51 66  0 57 65 73 80 90 102 131
    VGA256: SpeedUp mode selected (Flags=0x1f)

And here you get the clocks available in your card on the clocks line.
>Monitor:  NEC 2A  (max. 800x600)
>          Horizontal frequencies: 31.5 and 35 (or 35.2?) KHz.
>          Vertical   frequencies: 56, 60, and 70 Hz.
>
>Help me!  Somebody.......
Here is a simple program to generate mode lines, which I wrote, feel
free to use it at your own risk (send any bug fixes and improvements
to me (jonas@sisu.se), support for interlaced mode needed).

Regards 
Jonas Lagerblad
------------- xconf.c -----------------
/*
 * Xconf.c: Simple program to generate mode lines for Xfree86.
 *
 * compile: cc -o xconf xconf.c
 *
 * Usage: xconf Xres Yres (e.g xconf 1024 768)
 *
 * Customize the variables below to suit your VGA card and monitor.
 */
/* Copyright 1992, Jonas Lagerblad (jonas@sisu.se) */

/* Clock frequencies supported by VGA card (MHz) */
int vga_rates[] = {25, 28, 33, 37, 40, 45, 51, 65, 57, 73, 80, 90, 102, 131, 0};
/* horizontal frequences supported by your Monitor (Hz) */
int mon_rates[] = {31500, 35500, 48000, 64000, 0};

/* Vertical frequency limits for monitor (Hz) */
int MIN_VFREQ	= 50;
int MAX_VFREQ	= 120;

/* Vertical and horizontal sync times (s) */
double VSYNC	 = 0.000300;
double SYNC	 = 0.0000038;

main(argc,argv)
char ** argv;
{
    double freq, tmp, sec_per_line, vfreq;
    register int dots_per_line, dots_per_sync, lines_per_hsync, lines, diff, j, i, xres, yres, ydiff;

    if (argc != 3) {
	printf("usage: %s xres yres\n", argv[0]);
	exit(1);
    }
    
    xres = atoi(argv[1]);
    yres = atoi(argv[2]);
    if (!xres || !yres) {
	printf("Zero resolution not supported\n");
	exit(1);
    }

    printf("\"%dx%d\"\n", xres, yres);

    for (j=0; mon_rates[j]; j++) {
	printf("# With monitor rate %d\n", mon_rates[j]);
	for (i=0; vga_rates[i]; i++) {
	    freq = vga_rates[i] * 1000000.;
	    dots_per_line = (double)freq / (double) mon_rates[j];
	    dots_per_line >>= 3;
	    dots_per_line <<= 3;
	    sec_per_line = dots_per_line / freq;
	    /* dots per sync is frequency * sync time rounded up 
	     * to be divisible by 8 */
	    dots_per_sync = (double) freq * SYNC + (double) 7;
	    dots_per_sync >>= 3;
	    dots_per_sync <<= 3;
	    lines_per_hsync = 0.99 + VSYNC / sec_per_line;
	    lines = (double) yres * 1.05;
	    ydiff = (lines - yres - lines_per_hsync) / 2;
	    vfreq =  1./(sec_per_line*lines);
	    if( (diff = dots_per_line - dots_per_sync - xres)  > 0 && ydiff > 0 &&
		vfreq >= MIN_VFREQ && vfreq <= MAX_VFREQ) {
		diff /= 2;
		printf("\t%3d\t%4d %4d %4d %4d", vga_rates[i], xres, xres+diff,
		       xres+diff+dots_per_sync, dots_per_line);
		printf("\t%4d %4d %4d %4d\t# Vfreq %.1f Hz\n", yres, yres+ydiff,
		       yres+ydiff+lines_per_hsync, lines, vfreq);
	    }
	}
    }
}
------------------ end xconf.c -------------------
-- 
Jonas Lagerblad
Phone Office: +46-31-830250 Home: +46-31-205955 Car: +46-10-2846031
FAX:	+46-31-831047
email:	jonas@sisu.se