1 #! /usr/bin/awk -f
2 # $NetBSD: modelines2c.awk,v 1.4 2006/10/26 23:19:50 bjh21 Exp $
3 # $FreeBSD$
4 #
5 # Copyright (c) 2006 Itronix Inc.
6 # All rights reserved.
7 #
8 # Written by Garrett D'Amore for Itronix Inc.
9 #
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
12 # are met:
13 # 1. Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
15 # 2. Redistributions in binary form must reproduce the above copyright
16 # notice, this list of conditions and the following disclaimer in the
17 # documentation and/or other materials provided with the distribution.
18 # 3. The name of Itronix Inc. may not be used to endorse
19 # or promote products derived from this software without specific
20 # prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
23 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
26 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 # ON ANY THEORY OF LIABILITY, WHETHER IN
30 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
33 #
34
35 BEGIN {
36 nmodes = 0;
37 }
38
39 NR == 1 {
40 split($0,v,"$");
41
42 VERSION=v[2];
43
44 printf("/*\t$NetBSD" "$\t*/\n\n");
45 printf("/*\n") ;
46 printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n");
47 printf(" *\n");
48 printf(" * generated from:\n");
49 printf(" *\t%s\n", VERSION);
50 printf(" */\n\n");
51
52 printf("#include <sys/cdefs.h>\n");
53 printf("__KERNEL_RCSID(0, \"$NetBSD" "$\");\n\n");
54
55 printf("#include <dev/videomode/videomode.h>\n\n");
56
57 printf("/*\n");
58 printf(" * These macros help the modelines below fit on one line.\n");
59 printf(" */\n");
60 printf("#define HP VID_PHSYNC\n");
61 printf("#define HN VID_NHSYNC\n");
62 printf("#define VP VID_PVSYNC\n");
63 printf("#define VN VID_NVSYNC\n");
64 printf("#define I VID_INTERLACE\n");
65 printf("#define DS VID_DBLSCAN\n");
66 printf("\n");
67
68 printf("#define M(nm,hr,vr,clk,hs,he,ht,vs,ve,vt,f) \\\n");
69 printf("\t{ clk, hr, hs, he, ht, vr, vs, ve, vt, f, nm } \n\n");
70
71 printf("const struct videomode videomode_list[] = {\n");
72
73 next
74 }
75
76 (/^ModeLine/) {
77 dotclock = $3;
78
79 hdisplay = $4;
80 hsyncstart = $5;
81 hsyncend = $6;
82 htotal = $7;
83
84 vdisplay = $8;
85 vsyncstart = $9;
86 vsyncend = $10;
87 vtotal = $11;
88
89 macro = "MODE";
90 iflag = "";
91 iflags = "";
92 hflags = "HP";
93 vflags = "VP";
94
95 if ($12 ~ "^-")
96 hflags = "HN";
97
98 if ($13 ~ "^-")
99 vflags = "VN";
100
101 ifactor=1.0;
102 if ($14 ~ "[Ii][Nn][Tt][Ee][Rr][Ll][Aa][Cc][Ee]") {
103 iflag = "i";
104 iflags = "|I";
105 ifactor = 2.0;
106 }
107
108 # We truncate the vrefresh figure, but some mode descriptions rely
109 # on rounding, so we can't win here. Adding an additional .1
110 # compensates to some extent.
111
112 hrefresh= (dotclock * 1000000) / htotal;
113 vrefresh= int(((hrefresh * ifactor) / vtotal) + .1);
114
115 modestr = sprintf("%dx%dx%d%s", hdisplay, vdisplay, vrefresh, iflag);
116
117 # printf("/* %dx%d%s refresh %d Hz, hsync %d kHz */\n",
118 # hdisplay, vdisplay, iflag, vrefresh, hrefresh/1000);
119 printf("M(\"%s\",%d,%d,%d,%d,%d,%d,%d,%d,%d,%s),\n",
120 modestr,
121 hdisplay, vdisplay, dotclock * 1000,
122 hsyncstart, hsyncend, htotal,
123 vsyncstart, vsyncend, vtotal, hflags "|" vflags iflags);
124
125 modestr = sprintf("%dx%dx%d%s",
126 hdisplay/2 , vdisplay/2, vrefresh, iflag);
127
128 dmodes[nmodes]=sprintf("M(\"%s\",%d,%d,%d,%d,%d,%d,%d,%d,%d,%s),",
129 modestr,
130 hdisplay/2, vdisplay/2, dotclock * 1000 / 2,
131 hsyncstart/2, hsyncend/2, htotal/2,
132 vsyncstart/2, vsyncend/2, vtotal/2,
133 hflags "|" vflags "|DS" iflags);
134
135 nmodes = nmodes + 1
136
137 }
138
139 END {
140
141 printf("\n/* Derived Double Scan Modes */\n\n");
142
143 for ( i = 0; i < nmodes; i++ )
144 {
145 print dmodes[i];
146 }
147
148 printf("};\n\n");
149 printf("const int videomode_count = %d;\n", nmodes);
150 }
Cache object: 1f220c851f54a2ba2b05a7417f140e05
|