3
* Copyright (c) 1997 Metro Link Incorporated
5
* Permission is hereby granted, free of charge, to any person obtaining a
6
* copy of this software and associated documentation files (the "Software"),
7
* to deal in the Software without restriction, including without limitation
8
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
* and/or sell copies of the Software, and to permit persons to whom the
10
* Software is furnished to do so, subject to the following conditions:
12
* The above copyright notice and this permission notice shall be included in
13
* all copies or substantial portions of the Software.
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
20
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
* Except as contained in this notice, the name of the Metro Link shall not be
24
* used in advertising or otherwise to promote the sale, use or other dealings
25
* in this Software without prior written authorization from Metro Link.
29
* Copyright (c) 1997-2003 by The XFree86 Project, Inc.
31
* Permission is hereby granted, free of charge, to any person obtaining a
32
* copy of this software and associated documentation files (the "Software"),
33
* to deal in the Software without restriction, including without limitation
34
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
35
* and/or sell copies of the Software, and to permit persons to whom the
36
* Software is furnished to do so, subject to the following conditions:
38
* The above copyright notice and this permission notice shall be included in
39
* all copies or substantial portions of the Software.
41
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
44
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
45
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
46
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
47
* OTHER DEALINGS IN THE SOFTWARE.
49
* Except as contained in this notice, the name of the copyright holder(s)
50
* and author(s) shall not be used in advertising or otherwise to promote
51
* the sale, use or other dealings in this Software without prior written
52
* authorization from the copyright holder(s) and author(s).
56
/* View/edit this file with tab stops set to 4 */
58
#ifdef HAVE_XORG_CONFIG_H
59
#include <xorg-config.h>
62
#include "xf86Parser.h"
63
#include "xf86tokens.h"
64
#include "Configint.h"
69
xf86ConfigSymTabRec DeviceTab[] =
71
{ENDSECTION, "endsection"},
72
{IDENTIFIER, "identifier"},
73
{VENDOR, "vendorname"},
77
{DACSPEED, "dacspeed"},
80
{VIDEORAM, "videoram"},
81
{BIOSBASE, "biosbase"},
84
{CLOCKCHIP, "clockchip"},
90
{TEXTCLOCKFRQ, "textclockfreq"},
96
#define CLEANUP xf86freeDeviceList
99
xf86parseDeviceSection (void)
102
int has_ident = FALSE;
104
parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
106
/* Zero is a valid value for these */
107
ptr->dev_chipid = -1;
108
ptr->dev_chiprev = -1;
110
while ((token = xf86getToken (DeviceTab)) != ENDSECTION)
115
ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str);
118
if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
119
Error (QUOTE_MSG, "Identifier");
120
if (has_ident == TRUE)
121
Error (MULTIPLE_MSG, "Identifier");
122
ptr->dev_identifier = val.str;
126
if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
127
Error (QUOTE_MSG, "Vendor");
128
ptr->dev_vendor = val.str;
131
if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
132
Error (QUOTE_MSG, "Board");
133
ptr->dev_board = val.str;
136
if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
137
Error (QUOTE_MSG, "Chipset");
138
ptr->dev_chipset = val.str;
141
if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
142
Error (QUOTE_MSG, "Card");
143
ptr->dev_card = val.str;
146
if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
147
Error (QUOTE_MSG, "Driver");
148
ptr->dev_driver = val.str;
151
if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
152
Error (QUOTE_MSG, "Ramdac");
153
ptr->dev_ramdac = val.str;
156
for (i = 0; i < CONF_MAXDACSPEEDS; i++)
157
ptr->dev_dacSpeeds[i] = 0;
158
if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
160
Error (DACSPEED_MSG, CONF_MAXDACSPEEDS);
164
ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5);
165
for (i = 1; i < CONF_MAXDACSPEEDS; i++)
167
if (xf86getSubToken (&(ptr->dev_comment)) == NUMBER)
168
ptr->dev_dacSpeeds[i] = (int)
169
(val.realnum * 1000.0 + 0.5);
172
xf86unGetToken (token);
179
if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
180
Error (NUMBER_MSG, "VideoRam");
181
ptr->dev_videoram = val.num;
184
if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
185
Error (NUMBER_MSG, "BIOSBase");
186
ptr->dev_bios_base = val.num;
189
if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
190
Error (NUMBER_MSG, "MemBase");
191
ptr->dev_mem_base = val.num;
194
if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
195
Error (NUMBER_MSG, "IOBase");
196
ptr->dev_io_base = val.num;
199
if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
200
Error (QUOTE_MSG, "ClockChip");
201
ptr->dev_clockchip = val.str;
204
if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
205
Error (NUMBER_MSG, "ChipID");
206
ptr->dev_chipid = val.num;
209
if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
210
Error (NUMBER_MSG, "ChipRev");
211
ptr->dev_chiprev = val.num;
215
token = xf86getSubToken(&(ptr->dev_comment));
216
for( i = ptr->dev_clocks;
217
token == NUMBER && i < CONF_MAXCLOCKS; i++ ) {
218
ptr->dev_clock[i] = (int)(val.realnum * 1000.0 + 0.5);
219
token = xf86getSubToken(&(ptr->dev_comment));
222
xf86unGetToken (token);
225
if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER)
226
Error (NUMBER_MSG, "TextClockFreq");
227
ptr->dev_textclockfreq = (int)(val.realnum * 1000.0 + 0.5);
230
ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
233
if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
234
Error (QUOTE_MSG, "BusID");
235
ptr->dev_busid = val.str;
238
if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
239
Error (QUOTE_MSG, "IRQ");
240
ptr->dev_irq = val.num;
243
if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
244
Error (NUMBER_MSG, "Screen");
245
ptr->dev_screen = val.num;
248
Error (UNEXPECTED_EOF_MSG, NULL);
251
Error (INVALID_KEYWORD_MSG, xf86tokenString ());
257
Error (NO_IDENT_MSG, NULL);
260
printf ("Device section parsed\n");
269
xf86printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr)
275
fprintf (cf, "Section \"Device\"\n");
276
if (ptr->dev_comment)
277
fprintf (cf, "%s", ptr->dev_comment);
278
if (ptr->dev_identifier)
279
fprintf (cf, "\tIdentifier \"%s\"\n", ptr->dev_identifier);
281
fprintf (cf, "\tDriver \"%s\"\n", ptr->dev_driver);
283
fprintf (cf, "\tVendorName \"%s\"\n", ptr->dev_vendor);
285
fprintf (cf, "\tBoardName \"%s\"\n", ptr->dev_board);
286
if (ptr->dev_chipset)
287
fprintf (cf, "\tChipSet \"%s\"\n", ptr->dev_chipset);
289
fprintf (cf, "\tCard \"%s\"\n", ptr->dev_card);
291
fprintf (cf, "\tRamDac \"%s\"\n", ptr->dev_ramdac);
292
if (ptr->dev_dacSpeeds[0] > 0 ) {
293
fprintf (cf, "\tDacSpeed ");
294
for (i = 0; i < CONF_MAXDACSPEEDS
295
&& ptr->dev_dacSpeeds[i] > 0; i++ )
296
fprintf (cf, "%g ", (double) (ptr->dev_dacSpeeds[i])/ 1000.0 );
299
if (ptr->dev_videoram)
300
fprintf (cf, "\tVideoRam %d\n", ptr->dev_videoram);
301
if (ptr->dev_bios_base)
302
fprintf (cf, "\tBiosBase 0x%lx\n", ptr->dev_bios_base);
303
if (ptr->dev_mem_base)
304
fprintf (cf, "\tMemBase 0x%lx\n", ptr->dev_mem_base);
305
if (ptr->dev_io_base)
306
fprintf (cf, "\tIOBase 0x%lx\n", ptr->dev_io_base);
307
if (ptr->dev_clockchip)
308
fprintf (cf, "\tClockChip \"%s\"\n", ptr->dev_clockchip);
309
if (ptr->dev_chipid != -1)
310
fprintf (cf, "\tChipId 0x%x\n", ptr->dev_chipid);
311
if (ptr->dev_chiprev != -1)
312
fprintf (cf, "\tChipRev 0x%x\n", ptr->dev_chiprev);
314
xf86printOptionList(cf, ptr->dev_option_lst, 1);
315
if (ptr->dev_clocks > 0 ) {
316
fprintf (cf, "\tClocks ");
317
for (i = 0; i < ptr->dev_clocks; i++ )
318
fprintf (cf, "%.1f ", (double)ptr->dev_clock[i] / 1000.0 );
321
if (ptr->dev_textclockfreq) {
322
fprintf (cf, "\tTextClockFreq %.1f\n",
323
(double)ptr->dev_textclockfreq / 1000.0);
326
fprintf (cf, "\tBusID \"%s\"\n", ptr->dev_busid);
327
if (ptr->dev_screen > 0)
328
fprintf (cf, "\tScreen %d\n", ptr->dev_screen);
329
if (ptr->dev_irq >= 0)
330
fprintf (cf, "\tIRQ %d\n", ptr->dev_irq);
331
fprintf (cf, "EndSection\n\n");
332
ptr = ptr->list.next;
337
xf86freeDeviceList (XF86ConfDevicePtr ptr)
339
XF86ConfDevicePtr prev;
343
TestFree (ptr->dev_identifier);
344
TestFree (ptr->dev_vendor);
345
TestFree (ptr->dev_board);
346
TestFree (ptr->dev_chipset);
347
TestFree (ptr->dev_card);
348
TestFree (ptr->dev_driver);
349
TestFree (ptr->dev_ramdac);
350
TestFree (ptr->dev_clockchip);
351
TestFree (ptr->dev_comment);
352
xf86optionListFree (ptr->dev_option_lst);
355
ptr = ptr->list.next;
361
xf86findDevice (const char *ident, XF86ConfDevicePtr p)
365
if (xf86nameCompare (ident, p->dev_identifier) == 0)