xf86Parser.h revision 6747b715
1/*
2 *
3 * Copyright (c) 1997  Metro Link Incorporated
4 *
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:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
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
21 * SOFTWARE.
22 *
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.
26 *
27 */
28/*
29 * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
30 *
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:
37 *
38 * The above copyright notice and this permission notice shall be included in
39 * all copies or substantial portions of the Software.
40 *
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.
48 *
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).
53 */
54
55
56/*
57 * This file contains the external interfaces for the XFree86 configuration
58 * file parser.
59 */
60#ifdef HAVE_XORG_CONFIG_H
61#include <xorg-config.h>
62#endif
63
64#ifndef _xf86Parser_h_
65#define _xf86Parser_h_
66
67#include <X11/Xdefs.h>
68#include "xf86Optrec.h"
69#include "list.h"
70
71#define HAVE_PARSER_DECLS
72
73typedef struct
74{
75	char *file_logfile;
76	char *file_modulepath;
77	char *file_fontpath;
78	char *file_comment;
79	char *file_xkbdir;
80}
81XF86ConfFilesRec, *XF86ConfFilesPtr;
82
83/* Values for load_type */
84#define XF86_LOAD_MODULE	0
85#define XF86_LOAD_DRIVER	1
86#define XF86_DISABLE_MODULE	2
87
88typedef struct
89{
90	GenericListRec list;
91	int load_type;
92	char *load_name;
93	XF86OptionPtr load_opt;
94	char *load_comment;
95        int ignore;
96}
97XF86LoadRec, *XF86LoadPtr;
98
99typedef struct
100{
101	XF86LoadPtr mod_load_lst;
102    XF86LoadPtr mod_disable_lst;
103	char *mod_comment;
104}
105XF86ConfModuleRec, *XF86ConfModulePtr;
106
107#define CONF_IMPLICIT_KEYBOARD	"Implicit Core Keyboard"
108
109#define CONF_IMPLICIT_POINTER	"Implicit Core Pointer"
110
111#define XF86CONF_PHSYNC    0x0001
112#define XF86CONF_NHSYNC    0x0002
113#define XF86CONF_PVSYNC    0x0004
114#define XF86CONF_NVSYNC    0x0008
115#define XF86CONF_INTERLACE 0x0010
116#define XF86CONF_DBLSCAN   0x0020
117#define XF86CONF_CSYNC     0x0040
118#define XF86CONF_PCSYNC    0x0080
119#define XF86CONF_NCSYNC    0x0100
120#define XF86CONF_HSKEW     0x0200	/* hskew provided */
121#define XF86CONF_BCAST     0x0400
122#define XF86CONF_CUSTOM    0x0800	/* timing numbers customized by editor */
123#define XF86CONF_VSCAN     0x1000
124
125typedef struct
126{
127	GenericListRec list;
128	char *ml_identifier;
129	int ml_clock;
130	int ml_hdisplay;
131	int ml_hsyncstart;
132	int ml_hsyncend;
133	int ml_htotal;
134	int ml_vdisplay;
135	int ml_vsyncstart;
136	int ml_vsyncend;
137	int ml_vtotal;
138	int ml_vscan;
139	int ml_flags;
140	int ml_hskew;
141	char *ml_comment;
142}
143XF86ConfModeLineRec, *XF86ConfModeLinePtr;
144
145typedef struct
146{
147	GenericListRec list;
148	char *vp_identifier;
149	XF86OptionPtr vp_option_lst;
150	char *vp_comment;
151}
152XF86ConfVideoPortRec, *XF86ConfVideoPortPtr;
153
154typedef struct
155{
156	GenericListRec list;
157	char *va_identifier;
158	char *va_vendor;
159	char *va_board;
160	char *va_busid;
161	char *va_driver;
162	XF86OptionPtr va_option_lst;
163	XF86ConfVideoPortPtr va_port_lst;
164	char *va_fwdref;
165	char *va_comment;
166}
167XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr;
168
169#define CONF_MAX_HSYNC 8
170#define CONF_MAX_VREFRESH 8
171
172typedef struct
173{
174	float hi, lo;
175}
176parser_range;
177
178typedef struct
179{
180	int red, green, blue;
181}
182parser_rgb;
183
184typedef struct
185{
186	GenericListRec list;
187	char *modes_identifier;
188	XF86ConfModeLinePtr mon_modeline_lst;
189	char *modes_comment;
190}
191XF86ConfModesRec, *XF86ConfModesPtr;
192
193typedef struct
194{
195	GenericListRec list;
196	char *ml_modes_str;
197	XF86ConfModesPtr ml_modes;
198}
199XF86ConfModesLinkRec, *XF86ConfModesLinkPtr;
200
201typedef struct
202{
203	GenericListRec list;
204	char *mon_identifier;
205	char *mon_vendor;
206	char *mon_modelname;
207	int mon_width;				/* in mm */
208	int mon_height;				/* in mm */
209	XF86ConfModeLinePtr mon_modeline_lst;
210	int mon_n_hsync;
211	parser_range mon_hsync[CONF_MAX_HSYNC];
212	int mon_n_vrefresh;
213	parser_range mon_vrefresh[CONF_MAX_VREFRESH];
214	float mon_gamma_red;
215	float mon_gamma_green;
216	float mon_gamma_blue;
217	XF86OptionPtr mon_option_lst;
218	XF86ConfModesLinkPtr mon_modes_sect_lst;
219	char *mon_comment;
220}
221XF86ConfMonitorRec, *XF86ConfMonitorPtr;
222
223#define CONF_MAXDACSPEEDS 4
224#define CONF_MAXCLOCKS    128
225
226typedef struct
227{
228	GenericListRec list;
229	char *dev_identifier;
230	char *dev_vendor;
231	char *dev_board;
232	char *dev_chipset;
233	char *dev_busid;
234	char *dev_card;
235	char *dev_driver;
236	char *dev_ramdac;
237	int dev_dacSpeeds[CONF_MAXDACSPEEDS];
238	int dev_videoram;
239	int dev_textclockfreq;
240	unsigned long dev_bios_base;
241	unsigned long dev_mem_base;
242	unsigned long dev_io_base;
243	char *dev_clockchip;
244	int dev_clocks;
245	int dev_clock[CONF_MAXCLOCKS];
246	int dev_chipid;
247	int dev_chiprev;
248	int dev_irq;
249	int dev_screen;
250	XF86OptionPtr dev_option_lst;
251	char *dev_comment;
252}
253XF86ConfDeviceRec, *XF86ConfDevicePtr;
254
255typedef struct
256{
257	GenericListRec list;
258	char *mode_name;
259}
260XF86ModeRec, *XF86ModePtr;
261
262typedef struct
263{
264	GenericListRec list;
265	int disp_frameX0;
266	int disp_frameY0;
267	int disp_virtualX;
268	int disp_virtualY;
269	int disp_depth;
270	int disp_bpp;
271	char *disp_visual;
272	parser_rgb disp_weight;
273	parser_rgb disp_black;
274	parser_rgb disp_white;
275	XF86ModePtr disp_mode_lst;
276	XF86OptionPtr disp_option_lst;
277	char *disp_comment;
278}
279XF86ConfDisplayRec, *XF86ConfDisplayPtr;
280
281typedef struct
282{
283	XF86OptionPtr flg_option_lst;
284	char *flg_comment;
285}
286XF86ConfFlagsRec, *XF86ConfFlagsPtr;
287
288typedef struct
289{
290	GenericListRec list;
291	char *al_adaptor_str;
292	XF86ConfVideoAdaptorPtr al_adaptor;
293}
294XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr;
295
296typedef struct
297{
298	GenericListRec list;
299	char *scrn_identifier;
300	char *scrn_obso_driver;
301	int scrn_defaultdepth;
302	int scrn_defaultbpp;
303	int scrn_defaultfbbpp;
304	char *scrn_monitor_str;
305	XF86ConfMonitorPtr scrn_monitor;
306	char *scrn_device_str;
307	XF86ConfDevicePtr scrn_device;
308	XF86ConfAdaptorLinkPtr scrn_adaptor_lst;
309	XF86ConfDisplayPtr scrn_display_lst;
310	XF86OptionPtr scrn_option_lst;
311	char *scrn_comment;
312	int scrn_virtualX, scrn_virtualY;
313}
314XF86ConfScreenRec, *XF86ConfScreenPtr;
315
316typedef struct
317{
318	GenericListRec list;
319	char *inp_identifier;
320	char *inp_driver;
321	XF86OptionPtr inp_option_lst;
322	char *inp_comment;
323}
324XF86ConfInputRec, *XF86ConfInputPtr;
325
326typedef struct
327{
328	GenericListRec list;
329	XF86ConfInputPtr iref_inputdev;
330	char *iref_inputdev_str;
331	XF86OptionPtr iref_option_lst;
332}
333XF86ConfInputrefRec, *XF86ConfInputrefPtr;
334
335typedef struct
336{
337	Bool set;
338	Bool val;
339}
340xf86TriState;
341
342typedef struct
343{
344	struct list entry;
345	char **values;
346}
347xf86MatchGroup;
348
349typedef struct
350{
351	GenericListRec list;
352	char *identifier;
353	char *driver;
354	struct list match_product;
355	struct list match_vendor;
356	struct list match_device;
357	struct list match_os;
358	struct list match_pnpid;
359	struct list match_usbid;
360	struct list match_driver;
361	struct list match_tag;
362	xf86TriState is_keyboard;
363	xf86TriState is_pointer;
364	xf86TriState is_joystick;
365	xf86TriState is_tablet;
366	xf86TriState is_touchpad;
367	xf86TriState is_touchscreen;
368	XF86OptionPtr option_lst;
369	char *comment;
370}
371XF86ConfInputClassRec, *XF86ConfInputClassPtr;
372
373/* Values for adj_where */
374#define CONF_ADJ_OBSOLETE	-1
375#define CONF_ADJ_ABSOLUTE	0
376#define CONF_ADJ_RIGHTOF	1
377#define CONF_ADJ_LEFTOF		2
378#define CONF_ADJ_ABOVE		3
379#define CONF_ADJ_BELOW		4
380#define CONF_ADJ_RELATIVE	5
381
382typedef struct
383{
384	GenericListRec list;
385	int adj_scrnum;
386	XF86ConfScreenPtr adj_screen;
387	char *adj_screen_str;
388	XF86ConfScreenPtr adj_top;
389	char *adj_top_str;
390	XF86ConfScreenPtr adj_bottom;
391	char *adj_bottom_str;
392	XF86ConfScreenPtr adj_left;
393	char *adj_left_str;
394	XF86ConfScreenPtr adj_right;
395	char *adj_right_str;
396	int adj_where;
397	int adj_x;
398	int adj_y;
399	char *adj_refscreen;
400}
401XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr;
402
403typedef struct
404{
405	GenericListRec list;
406	char *inactive_device_str;
407	XF86ConfDevicePtr inactive_device;
408}
409XF86ConfInactiveRec, *XF86ConfInactivePtr;
410
411typedef struct
412{
413	GenericListRec list;
414	char *lay_identifier;
415	XF86ConfAdjacencyPtr lay_adjacency_lst;
416	XF86ConfInactivePtr lay_inactive_lst;
417	XF86ConfInputrefPtr lay_input_lst;
418	XF86OptionPtr lay_option_lst;
419	char *lay_comment;
420}
421XF86ConfLayoutRec, *XF86ConfLayoutPtr;
422
423typedef struct
424{
425	GenericListRec list;
426	char *vs_name;
427	char *vs_identifier;
428	XF86OptionPtr vs_option_lst;
429	char *vs_comment;
430}
431XF86ConfVendSubRec, *XF86ConfVendSubPtr;
432
433typedef struct
434{
435	GenericListRec list;
436	char *vnd_identifier;
437	XF86OptionPtr vnd_option_lst;
438	XF86ConfVendSubPtr vnd_sub_lst;
439	char *vnd_comment;
440}
441XF86ConfVendorRec, *XF86ConfVendorPtr;
442
443typedef struct
444{
445	GenericListRec list;
446	int buf_count;
447	int buf_size;
448	char *buf_flags;
449	char *buf_comment;
450}
451XF86ConfBuffersRec, *XF86ConfBuffersPtr;
452
453typedef struct
454{
455	char *dri_group_name;
456	int dri_group;
457	int dri_mode;
458	XF86ConfBuffersPtr dri_buffers_lst;
459	char *dri_comment;
460}
461XF86ConfDRIRec, *XF86ConfDRIPtr;
462
463typedef struct
464{
465	XF86OptionPtr ext_option_lst;
466	char *extensions_comment;
467}
468XF86ConfExtensionsRec, *XF86ConfExtensionsPtr;
469
470typedef struct
471{
472	XF86ConfFilesPtr conf_files;
473	XF86ConfModulePtr conf_modules;
474	XF86ConfFlagsPtr conf_flags;
475	XF86ConfVideoAdaptorPtr conf_videoadaptor_lst;
476	XF86ConfModesPtr conf_modes_lst;
477	XF86ConfMonitorPtr conf_monitor_lst;
478	XF86ConfDevicePtr conf_device_lst;
479	XF86ConfScreenPtr conf_screen_lst;
480	XF86ConfInputPtr conf_input_lst;
481	XF86ConfInputClassPtr conf_inputclass_lst;
482	XF86ConfLayoutPtr conf_layout_lst;
483	XF86ConfVendorPtr conf_vendor_lst;
484	XF86ConfDRIPtr conf_dri;
485	XF86ConfExtensionsPtr conf_extensions;
486	char *conf_comment;
487}
488XF86ConfigRec, *XF86ConfigPtr;
489
490typedef struct
491{
492	int token;			/* id of the token */
493	char *name;			/* pointer to the LOWERCASED name */
494}
495xf86ConfigSymTabRec, *xf86ConfigSymTabPtr;
496
497/*
498 * prototypes for public functions
499 */
500extern void xf86initConfigFiles(void);
501extern const char *xf86openConfigFile(const char *path, const char *cmdline,
502				      const char *projroot);
503extern const char *xf86openConfigDirFiles(const char *path, const char *cmdline,
504					  const char *projroot);
505extern void xf86setBuiltinConfig(const char *config[]);
506extern XF86ConfigPtr xf86readConfigFile(void);
507extern void xf86closeConfigFile(void);
508extern void xf86freeConfig(XF86ConfigPtr p);
509extern int xf86writeConfigFile(const char *, XF86ConfigPtr);
510extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p);
511extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list);
512extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p);
513extern _X_EXPORT XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p);
514extern _X_EXPORT XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p);
515extern _X_EXPORT XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p);
516extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p);
517extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p);
518extern _X_EXPORT XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident,
519						XF86ConfVideoAdaptorPtr p);
520extern int xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout);
521
522extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new);
523extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2);
524
525extern _X_EXPORT int xf86pathIsAbsolute(const char *path);
526extern _X_EXPORT int xf86pathIsSafe(const char *path);
527extern _X_EXPORT char *xf86addComment(char *cur, char *add);
528extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str);
529
530#endif /* _xf86Parser_h_ */
531