xf86Parser.h revision f7df2e56
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 72typedef 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 85typedef 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 94typedef 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 117typedef 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 135typedef struct { 136 GenericListRec list; 137 const char *vp_identifier; 138 XF86OptionPtr vp_option_lst; 139 char *vp_comment; 140} XF86ConfVideoPortRec, *XF86ConfVideoPortPtr; 141 142typedef 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 158typedef struct { 159 float hi, lo; 160} parser_range; 161 162typedef struct { 163 int red, green, blue; 164} parser_rgb; 165 166typedef struct { 167 GenericListRec list; 168 const char *modes_identifier; 169 XF86ConfModeLinePtr mon_modeline_lst; 170 char *modes_comment; 171} XF86ConfModesRec, *XF86ConfModesPtr; 172 173typedef struct { 174 GenericListRec list; 175 const char *ml_modes_str; 176 XF86ConfModesPtr ml_modes; 177} XF86ConfModesLinkRec, *XF86ConfModesLinkPtr; 178 179typedef 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 202typedef 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_bios_base; 215 unsigned long dev_mem_base; 216 unsigned long dev_io_base; 217 const char *dev_clockchip; 218 int dev_clocks; 219 int dev_clock[CONF_MAXCLOCKS]; 220 int dev_chipid; 221 int dev_chiprev; 222 int dev_irq; 223 int dev_screen; 224 XF86OptionPtr dev_option_lst; 225 char *dev_comment; 226 char *match_seat; 227} XF86ConfDeviceRec, *XF86ConfDevicePtr; 228 229typedef struct { 230 GenericListRec list; 231 const char *mode_name; 232} XF86ModeRec, *XF86ModePtr; 233 234typedef struct { 235 GenericListRec list; 236 int disp_frameX0; 237 int disp_frameY0; 238 int disp_virtualX; 239 int disp_virtualY; 240 int disp_depth; 241 int disp_bpp; 242 const char *disp_visual; 243 parser_rgb disp_weight; 244 parser_rgb disp_black; 245 parser_rgb disp_white; 246 XF86ModePtr disp_mode_lst; 247 XF86OptionPtr disp_option_lst; 248 char *disp_comment; 249} XF86ConfDisplayRec, *XF86ConfDisplayPtr; 250 251typedef struct { 252 XF86OptionPtr flg_option_lst; 253 char *flg_comment; 254} XF86ConfFlagsRec, *XF86ConfFlagsPtr; 255 256typedef struct { 257 GenericListRec list; 258 const char *al_adaptor_str; 259 XF86ConfVideoAdaptorPtr al_adaptor; 260} XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr; 261 262#define CONF_MAXGPUDEVICES 4 263typedef struct { 264 GenericListRec list; 265 const char *scrn_identifier; 266 const char *scrn_obso_driver; 267 int scrn_defaultdepth; 268 int scrn_defaultbpp; 269 int scrn_defaultfbbpp; 270 const char *scrn_monitor_str; 271 XF86ConfMonitorPtr scrn_monitor; 272 const char *scrn_device_str; 273 XF86ConfDevicePtr scrn_device; 274 XF86ConfAdaptorLinkPtr scrn_adaptor_lst; 275 XF86ConfDisplayPtr scrn_display_lst; 276 XF86OptionPtr scrn_option_lst; 277 char *scrn_comment; 278 int scrn_virtualX, scrn_virtualY; 279 char *match_seat; 280 281 int num_gpu_devices; 282 const char *scrn_gpu_device_str[CONF_MAXGPUDEVICES]; 283 XF86ConfDevicePtr scrn_gpu_devices[CONF_MAXGPUDEVICES]; 284} XF86ConfScreenRec, *XF86ConfScreenPtr; 285 286typedef struct { 287 GenericListRec list; 288 char *inp_identifier; 289 char *inp_driver; 290 XF86OptionPtr inp_option_lst; 291 char *inp_comment; 292} XF86ConfInputRec, *XF86ConfInputPtr; 293 294typedef struct { 295 GenericListRec list; 296 XF86ConfInputPtr iref_inputdev; 297 char *iref_inputdev_str; 298 XF86OptionPtr iref_option_lst; 299} XF86ConfInputrefRec, *XF86ConfInputrefPtr; 300 301typedef struct { 302 Bool set; 303 Bool val; 304} xf86TriState; 305 306typedef struct { 307 struct xorg_list entry; 308 char **values; 309} xf86MatchGroup; 310 311typedef 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_touchpad; 329 xf86TriState is_touchscreen; 330 XF86OptionPtr option_lst; 331 char *comment; 332} XF86ConfInputClassRec, *XF86ConfInputClassPtr; 333 334typedef struct { 335 GenericListRec list; 336 char *identifier; 337 char *driver; 338 struct xorg_list match_driver; 339 char *comment; 340} XF86ConfOutputClassRec, *XF86ConfOutputClassPtr; 341 342/* Values for adj_where */ 343#define CONF_ADJ_OBSOLETE -1 344#define CONF_ADJ_ABSOLUTE 0 345#define CONF_ADJ_RIGHTOF 1 346#define CONF_ADJ_LEFTOF 2 347#define CONF_ADJ_ABOVE 3 348#define CONF_ADJ_BELOW 4 349#define CONF_ADJ_RELATIVE 5 350 351typedef struct { 352 GenericListRec list; 353 int adj_scrnum; 354 XF86ConfScreenPtr adj_screen; 355 const char *adj_screen_str; 356 XF86ConfScreenPtr adj_top; 357 const char *adj_top_str; 358 XF86ConfScreenPtr adj_bottom; 359 const char *adj_bottom_str; 360 XF86ConfScreenPtr adj_left; 361 const char *adj_left_str; 362 XF86ConfScreenPtr adj_right; 363 const char *adj_right_str; 364 int adj_where; 365 int adj_x; 366 int adj_y; 367 const char *adj_refscreen; 368} XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr; 369 370typedef struct { 371 GenericListRec list; 372 const char *inactive_device_str; 373 XF86ConfDevicePtr inactive_device; 374} XF86ConfInactiveRec, *XF86ConfInactivePtr; 375 376typedef struct { 377 GenericListRec list; 378 const char *lay_identifier; 379 XF86ConfAdjacencyPtr lay_adjacency_lst; 380 XF86ConfInactivePtr lay_inactive_lst; 381 XF86ConfInputrefPtr lay_input_lst; 382 XF86OptionPtr lay_option_lst; 383 char *match_seat; 384 char *lay_comment; 385} XF86ConfLayoutRec, *XF86ConfLayoutPtr; 386 387typedef struct { 388 GenericListRec list; 389 const char *vs_name; 390 const char *vs_identifier; 391 XF86OptionPtr vs_option_lst; 392 char *vs_comment; 393} XF86ConfVendSubRec, *XF86ConfVendSubPtr; 394 395typedef struct { 396 GenericListRec list; 397 const char *vnd_identifier; 398 XF86OptionPtr vnd_option_lst; 399 XF86ConfVendSubPtr vnd_sub_lst; 400 char *vnd_comment; 401} XF86ConfVendorRec, *XF86ConfVendorPtr; 402 403typedef struct { 404 const char *dri_group_name; 405 int dri_group; 406 int dri_mode; 407 char *dri_comment; 408} XF86ConfDRIRec, *XF86ConfDRIPtr; 409 410typedef struct { 411 XF86OptionPtr ext_option_lst; 412 char *extensions_comment; 413} XF86ConfExtensionsRec, *XF86ConfExtensionsPtr; 414 415typedef struct { 416 XF86ConfFilesPtr conf_files; 417 XF86ConfModulePtr conf_modules; 418 XF86ConfFlagsPtr conf_flags; 419 XF86ConfVideoAdaptorPtr conf_videoadaptor_lst; 420 XF86ConfModesPtr conf_modes_lst; 421 XF86ConfMonitorPtr conf_monitor_lst; 422 XF86ConfDevicePtr conf_device_lst; 423 XF86ConfScreenPtr conf_screen_lst; 424 XF86ConfInputPtr conf_input_lst; 425 XF86ConfInputClassPtr conf_inputclass_lst; 426 XF86ConfOutputClassPtr conf_outputclass_lst; 427 XF86ConfLayoutPtr conf_layout_lst; 428 XF86ConfVendorPtr conf_vendor_lst; 429 XF86ConfDRIPtr conf_dri; 430 XF86ConfExtensionsPtr conf_extensions; 431 char *conf_comment; 432} XF86ConfigRec, *XF86ConfigPtr; 433 434typedef struct { 435 int token; /* id of the token */ 436 const char *name; /* pointer to the LOWERCASED name */ 437} xf86ConfigSymTabRec, *xf86ConfigSymTabPtr; 438 439/* 440 * prototypes for public functions 441 */ 442extern void xf86initConfigFiles(void); 443extern char *xf86openConfigFile(const char *path, const char *cmdline, 444 const char *projroot); 445extern char *xf86openConfigDirFiles(const char *path, const char *cmdline, 446 const char *projroot); 447extern void xf86setBuiltinConfig(const char *config[]); 448extern XF86ConfigPtr xf86readConfigFile(void); 449extern void xf86closeConfigFile(void); 450extern void xf86freeConfig(XF86ConfigPtr p); 451extern int xf86writeConfigFile(const char *, XF86ConfigPtr); 452extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident, 453 XF86ConfDevicePtr p); 454extern _X_EXPORT XF86ConfDevicePtr xf86findDeviceByDriver(const char *driver, 455 XF86ConfDevicePtr p); 456extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name, 457 XF86ConfLayoutPtr list); 458extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident, 459 XF86ConfMonitorPtr p); 460extern _X_EXPORT XF86ConfModesPtr xf86findModes(const char *ident, 461 XF86ConfModesPtr p); 462extern _X_EXPORT XF86ConfModeLinePtr xf86findModeLine(const char *ident, 463 XF86ConfModeLinePtr p); 464extern _X_EXPORT XF86ConfScreenPtr xf86findScreen(const char *ident, 465 XF86ConfScreenPtr p); 466extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident, 467 XF86ConfInputPtr p); 468extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver, 469 XF86ConfInputPtr p); 470extern _X_EXPORT XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident, 471 XF86ConfVideoAdaptorPtr 472 p); 473extern int xf86layoutAddInputDevices(XF86ConfigPtr config, 474 XF86ConfLayoutPtr layout); 475 476extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head, 477 GenericListPtr c_new); 478extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, 479 GenericListPtr list_2); 480 481extern _X_EXPORT int xf86pathIsAbsolute(const char *path); 482extern _X_EXPORT int xf86pathIsSafe(const char *path); 483extern _X_EXPORT char *xf86addComment(char *cur, const char *add); 484extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str); 485 486#endif /* _xf86Parser_h_ */ 487