xserver

xserver with xephyr scale patch
git clone https://git.neptards.moe/u3shit/xserver.git
Log | Files | Refs | README | LICENSE

modeline2c.awk (3447B)


      1 #!/usr/bin/awk -f
      2 #
      3 # Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
      4 # All rights reserved.
      5 #
      6 # Based on Perl script by Dirk Hohndel.
      7 #
      8 # Redistribution and use in source and binary forms, with or without
      9 # modification, are permitted provided that the following conditions
     10 # are met:
     11 #
     12 # 1. Redistributions of source code must retain the above copyright
     13 #    notice, this list of conditions and the following disclaimer.
     14 # 2. Redistributions in binary form must reproduce the above copyright
     15 #    notice, this list of conditions and the following disclaimer in
     16 #    the documentation and/or other materials provided with the
     17 #    distribution.
     18 #
     19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     20 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     22 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
     23 # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     24 # INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
     25 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     26 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     27 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     29 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30 # SUCH DAMAGE.
     31 #
     32 # Usage: modeline2c.awk < modefile > xf86DefModeSet.c
     33 #
     34 
     35 BEGIN {
     36 	flagsdict[""] = "0"
     37 
     38 	flagsdict["+hsync +vsync"] = "V_PHSYNC | V_PVSYNC"
     39 	flagsdict["+hsync -vsync"] = "V_PHSYNC | V_NVSYNC"
     40 	flagsdict["-hsync +vsync"] = "V_NHSYNC | V_PVSYNC"
     41 	flagsdict["-hsync -vsync"] = "V_NHSYNC | V_NVSYNC"
     42 	flagsdict["+hsync +vsync interlace"] = "V_PHSYNC | V_PVSYNC | V_INTERLACE"
     43 	flagsdict["+hsync -vsync interlace"] = "V_PHSYNC | V_NVSYNC | V_INTERLACE"
     44 	flagsdict["-hsync +vsync interlace"] = "V_NHSYNC | V_PVSYNC | V_INTERLACE"
     45 	flagsdict["-hsync -vsync interlace"] = "V_NHSYNC | V_NVSYNC | V_INTERLACE"
     46 
     47 	print "/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at"
     48 	print " * modeline2c.awk */"
     49 	print ""
     50 	print "/*"
     51 	print " * Author: Joerg Sonnenberger <joerg@NetBSD.org>"
     52 	print " * Based on Perl script from Dirk Hohndel <hohndel@XFree86.Org>"
     53 	print " */"
     54 	print ""
     55 	print "#ifdef HAVE_XORG_CONFIG_H"
     56 	print "#include <xorg-config.h>"
     57 	print "#endif"
     58 	print ""
     59 	print "#include \"xf86.h\""
     60 	print "#include \"xf86Config.h\""
     61 	print "#include \"xf86Priv.h\""
     62 	print "#include \"xf86_OSlib.h\""
     63 	print ""
     64 	print "#include \"globals.h\""
     65 	print ""
     66 	print "#define MODEPREFIX NULL, NULL, NULL, MODE_OK, M_T_DEFAULT"
     67 	print "#define MODESUFFIX 0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0"
     68 	print ""
     69 	print "const DisplayModeRec xf86DefaultModes [] = {"
     70 
     71 	modeline = "\t{MODEPREFIX,%d, %d,%d,%d,%d,0, %d,%d,%d,%d,0, %s, MODESUFFIX},\n"
     72 	modeline_data = "^[a-zA-Z]+[ \t]+[^ \t]+[ \t0-9.]+"
     73 }
     74 
     75 /^[mM][oO][dD][eE][lL][iI][nN][eE]/ {
     76 	flags = $0
     77 	gsub(modeline_data, "", flags)
     78 	flags = tolower(flags)
     79 	printf(modeline, $3 * 1000, $4, $5, $6, $7,
     80 	       $8, $9, $10, $11, flagsdict[flags])
     81 	# Half-width double scanned modes
     82 	printf(modeline, $3 * 500, $4/2, $5/2, $6/2, $7/2,
     83 	       $8/2, $9/2, $10/2, $11/2, flagsdict[flags] " | V_DBLSCAN")
     84 }
     85 
     86 /^#/ {
     87 	print "/*" substr($0, 2) " */"
     88 }
     89 
     90 END {
     91 	print "};"
     92 	printf "const int xf86NumDefaultModes = ARRAY_SIZE(xf86DefaultModes);"
     93 }