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