14642e01fSmrg#!/usr/bin/awk -f 24642e01fSmrg# 34642e01fSmrg# Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>. 44642e01fSmrg# All rights reserved. 54642e01fSmrg# 64642e01fSmrg# Based on Perl script by Dirk Hohndel. 74642e01fSmrg# 84642e01fSmrg# Redistribution and use in source and binary forms, with or without 94642e01fSmrg# modification, are permitted provided that the following conditions 104642e01fSmrg# are met: 114642e01fSmrg# 124642e01fSmrg# 1. Redistributions of source code must retain the above copyright 134642e01fSmrg# notice, this list of conditions and the following disclaimer. 144642e01fSmrg# 2. Redistributions in binary form must reproduce the above copyright 154642e01fSmrg# notice, this list of conditions and the following disclaimer in 164642e01fSmrg# the documentation and/or other materials provided with the 174642e01fSmrg# distribution. 184642e01fSmrg# 194642e01fSmrg# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 204642e01fSmrg# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 214642e01fSmrg# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 224642e01fSmrg# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 234642e01fSmrg# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 244642e01fSmrg# INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 254642e01fSmrg# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 264642e01fSmrg# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 274642e01fSmrg# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 284642e01fSmrg# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 294642e01fSmrg# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304642e01fSmrg# SUCH DAMAGE. 314642e01fSmrg# 324642e01fSmrg# Usage: modeline2c.awk < modefile > xf86DefModeSet.c 334642e01fSmrg# 344642e01fSmrg 354642e01fSmrgBEGIN { 364642e01fSmrg flagsdict[""] = "0" 374642e01fSmrg 384642e01fSmrg flagsdict["+hsync +vsync"] = "V_PHSYNC | V_PVSYNC" 394642e01fSmrg flagsdict["+hsync -vsync"] = "V_PHSYNC | V_NVSYNC" 404642e01fSmrg flagsdict["-hsync +vsync"] = "V_NHSYNC | V_PVSYNC" 414642e01fSmrg flagsdict["-hsync -vsync"] = "V_NHSYNC | V_NVSYNC" 424642e01fSmrg flagsdict["+hsync +vsync interlace"] = "V_PHSYNC | V_PVSYNC | V_INTERLACE" 434642e01fSmrg flagsdict["+hsync -vsync interlace"] = "V_PHSYNC | V_NVSYNC | V_INTERLACE" 444642e01fSmrg flagsdict["-hsync +vsync interlace"] = "V_NHSYNC | V_PVSYNC | V_INTERLACE" 454642e01fSmrg flagsdict["-hsync -vsync interlace"] = "V_NHSYNC | V_NVSYNC | V_INTERLACE" 464642e01fSmrg 474642e01fSmrg print "/* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT -- LOOK at" 484642e01fSmrg print " * modeline2c.awk */" 494642e01fSmrg print "" 504642e01fSmrg print "/*" 514642e01fSmrg print " * Author: Joerg Sonnenberger <joerg@NetBSD.org>" 524642e01fSmrg print " * Based on Perl script from Dirk Hohndel <hohndel@XFree86.Org>" 534642e01fSmrg print " */" 544642e01fSmrg print "" 554642e01fSmrg print "#ifdef HAVE_XORG_CONFIG_H" 564642e01fSmrg print "#include <xorg-config.h>" 574642e01fSmrg print "#endif" 584642e01fSmrg print "" 594642e01fSmrg print "#include \"xf86.h\"" 604642e01fSmrg print "#include \"xf86Config.h\"" 614642e01fSmrg print "#include \"xf86Priv.h\"" 624642e01fSmrg print "#include \"xf86_OSlib.h\"" 634642e01fSmrg print "" 644642e01fSmrg print "#include \"globals.h\"" 654642e01fSmrg print "" 664642e01fSmrg print "#define MODEPREFIX NULL, NULL, NULL, MODE_OK, M_T_DEFAULT" 674642e01fSmrg 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" 684642e01fSmrg print "" 694642e01fSmrg print "const DisplayModeRec xf86DefaultModes [] = {" 704642e01fSmrg 714642e01fSmrg modeline = "\t{MODEPREFIX,%d, %d,%d,%d,%d,0, %d,%d,%d,%d,0, %s, MODESUFFIX},\n" 724642e01fSmrg modeline_data = "^[a-zA-Z]+[ \t]+[^ \t]+[ \t0-9.]+" 734642e01fSmrg} 744642e01fSmrg 754642e01fSmrg/^[mM][oO][dD][eE][lL][iI][nN][eE]/ { 764642e01fSmrg flags = $0 774642e01fSmrg gsub(modeline_data, "", flags) 784642e01fSmrg flags = tolower(flags) 794642e01fSmrg printf(modeline, $3 * 1000, $4, $5, $6, $7, 804642e01fSmrg $8, $9, $10, $11, flagsdict[flags]) 814642e01fSmrg # Half-width double scanned modes 824642e01fSmrg printf(modeline, $3 * 500, $4/2, $5/2, $6/2, $7/2, 834642e01fSmrg $8/2, $9/2, $10/2, $11/2, flagsdict[flags] " | V_DBLSCAN") 844642e01fSmrg} 854642e01fSmrg 864642e01fSmrg/^#/ { 874642e01fSmrg print "/*" substr($0, 2) " */" 884642e01fSmrg} 894642e01fSmrg 904642e01fSmrgEND { 914642e01fSmrg print "};" 921b5d61b8Smrg printf "const int xf86NumDefaultModes = ARRAY_SIZE(xf86DefaultModes);" 934642e01fSmrg} 94