Subject: ANNOUNCE: awk script for generating Xconfig timings

From: [email-masked] (Richard Brown)
Date: 16 Jul 1994 05:03:46 GMT

> [email-masked] (Paul Quinn) writes:
>>
>>I just downloaded the xserver for the #9GXE64 from ftp.cdrom.com.  Does
>>anyone have an Xconfig for this card.  I have a Sony 1730 monitor.

Since people keep asking for Xconfig files, i thought i'd post this
handy awk script for generating timings. If you know the specs of your
monitor, you can specify them and give the script resolution and dot
clock frequency.

If you have set the maximum scan frequencies correctly, then everything
should be OK, but just in case, as always, don't blame me if you fry
your monitor:  know what you are doing.

However, this works well for me, and it's easier than using a
calculator.  It writes output suitable for direct inclusion in Xconfig
so you can do:

   % awk -f xconfig.awk HR=1024 VR=768 DCF=110 < /dev/null >> Xconfig

and it includes the refresh rate and horizontal scan frequency.

Save this as xconfig.awk:
----------------------x snip x--------------------------------------
#
# xconfig.awk - awk script for calculating Xconfig parameters for
# XFree86, given the monitor specs and dot clock frequencies.
# The default values are for the Viewsonic 15.
#
# Example Usage:
#    awk -f xconfig.awk HR=1024 VR=768 DCF=110 < /dev/null (or ^D input)
#
# The variable names and meanings are given below.
#
# Author: Richard Brown [email-masked]
#

BEGIN{

   # Sensible defaults if not specified:

   HR = 1024			# Horizontal Resolution
   VR =  768			# Vertical   Resolution
   DCF = 110.0			# Dot Clock Frequency (MHz)

   HFrontMIN = 0.50		# Horizontal Front Porch Minimum (us)
   HsyncMIN  = 1.20		# Horizontal Sync Pulse Width Minimum (us)
   HBackMIN  = 1.25		# Horizontal Back Porch Minimum (us)
   HBlankMIN = 4.00		# Horizontal Blank Period Minimum (us)
   HSFMAX    = 64.0		# Max Horizontal Scan Frequency (kHz)

   VFrontMIN =   0.0		# Vertical Front Porch Minimum
   VsyncMIN  =  45.0		# Vertical Sync Pulse Width Minimum
   VBackMIN  = 500.0		# Vertical Back Porch Minimum
   VBlankMIN = 600.0		# Vertical Blank Period Minimum
   VSFMAX    =  90.0		# Max Vertical Scan Frequency (Hz)

   verbose = 0

}

END{

   # Horizontal Scan Lines:

   Hfront = HFrontMIN * DCF + HR
   if( Hfront%8 ) Hfront = 8 * (1 + int(Hfront/8) )
   # if( (Hfront - HR) < HFrontMIN * DCF ) Hfront += 8

   Hsync = HsyncMIN * DCF + Hfront
   if( Hsync%8 ) Hsync = 8 * (1 + int(Hsync/8) )

   Hblank = HBlankMIN * DCF
   HFL = HR + Hblank
   if( HFL%8 ) HFL = 8 * (1 + int(HFL/8) )

   # Vertical:

   Vtick = HFL / DCF	# us
   Vfront = VR + VfrontMIN / Vtick
   Vsync = Vfront + VsyncMIN / Vtick
   Vback = VBackMIN / Vtick
   Vblank = VBlankMIN / Vtick
   VFL = Vsync + Vback
   if( VFL < VR + Vblank ) VFL = VR + Vblank

   RR = 1000000 * DCF / (HFL * VFL)
   HSF = 1000 * DCF / HFL

   # Done: generate some output:

   if( verbose ) {
      printf "\n# Horizontal:\n"
      printf "# Front Porch = %.2f us, Sync = %.2f, Back Porch = %.2f, ",
             (Hfront - HR) / DCF, (Hsync - Hfront) / DCF, (HFL - Hsync) / DCF
      printf "Blank = %.2f\n\n", (HFL - HR) / DCF
   }

   printf "# Refresh Rate: %.2f Hz, Horizontal Sync Frequency: %.2f kHz\n",
	  RR, HSF

   printf " \"%dx%d\"\t%.2f\t%d %d %d %d   %d %d %d %d\n", HR, VR, DCF, HR,
	   Hfront, Hsync, HFL, VR, Vfront, Vsync, VFL

   if( HSF > HSFMAX )
      printf("\nWarning: the Horizontal sync frequency may be too high for the monitor!\n")
   if( RR > VSFMAX )
      printf("\nWarning: this refresh rate may be too high for the monitor!\n")
}

----------------------x snip x--------------------------------------

rab
-- 
------------------------------------------------------------------------
Richard Brown                     | E-mail: [email-masked]
School of Physics                 | Phone : +61 3 344 5081
University of Melbourne           | Fax   : +61 3 347 4783
Parkville Victoria AUSTRALIA 3052 | Telex : AA35185