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).
55 #ifdef HAVE_XORG_CONFIG_H
56 #include <xorg-config.h>
59 #include "xf86Parser.h"
60 #include "xf86tokens.h"
61 #include "Configint.h"
65 static xf86ConfigSymTabRec MonitorTab
[] = {
66 {ENDSECTION
, "endsection"},
67 {IDENTIFIER
, "identifier"},
68 {VENDOR
, "vendorname"},
70 {USEMODES
, "usemodes"},
71 {MODELINE
, "modeline"},
72 {DISPLAYSIZE
, "displaysize"},
73 {HORIZSYNC
, "horizsync"},
74 {VERTREFRESH
, "vertrefresh"},
81 static xf86ConfigSymTabRec ModesTab
[] = {
82 {ENDSECTION
, "endsection"},
83 {IDENTIFIER
, "identifier"},
84 {MODELINE
, "modeline"},
89 static xf86ConfigSymTabRec TimingTab
[] = {
90 {TT_INTERLACE
, "interlace"},
91 {TT_PHSYNC
, "+hsync"},
92 {TT_NHSYNC
, "-hsync"},
93 {TT_PVSYNC
, "+vsync"},
94 {TT_NVSYNC
, "-vsync"},
95 {TT_CSYNC
, "composite"},
96 {TT_PCSYNC
, "+csync"},
97 {TT_NCSYNC
, "-csync"},
98 {TT_DBLSCAN
, "doublescan"},
105 static xf86ConfigSymTabRec ModeTab
[] = {
106 {DOTCLOCK
, "dotclock"},
107 {HTIMINGS
, "htimings"},
108 {VTIMINGS
, "vtimings"},
113 {ENDMODE
, "endmode"},
117 #define CLEANUP xf86freeModeLineList
120 xf86freeModeLineList(XF86ConfModeLinePtr ptr
)
122 XF86ConfModeLinePtr prev
;
125 TestFree(ptr
->ml_identifier
);
126 TestFree(ptr
->ml_comment
);
128 ptr
= ptr
->list
.next
;
133 static XF86ConfModeLinePtr
134 xf86parseModeLine(void)
138 parsePrologue(XF86ConfModeLinePtr
, XF86ConfModeLineRec
)
141 if (xf86getSubToken(&(ptr
->ml_comment
)) != STRING
)
142 Error("ModeLine identifier expected");
143 ptr
->ml_identifier
= val
.str
;
146 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
147 Error("ModeLine dotclock expected");
148 ptr
->ml_clock
= (int) (val
.realnum
* 1000.0 + 0.5);
151 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
152 Error("ModeLine Hdisplay expected");
153 ptr
->ml_hdisplay
= val
.num
;
156 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
157 Error("ModeLine HSyncStart expected");
158 ptr
->ml_hsyncstart
= val
.num
;
161 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
162 Error("ModeLine HSyncEnd expected");
163 ptr
->ml_hsyncend
= val
.num
;
166 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
167 Error("ModeLine HTotal expected");
168 ptr
->ml_htotal
= val
.num
;
171 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
172 Error("ModeLine Vdisplay expected");
173 ptr
->ml_vdisplay
= val
.num
;
176 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
177 Error("ModeLine VSyncStart expected");
178 ptr
->ml_vsyncstart
= val
.num
;
181 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
182 Error("ModeLine VSyncEnd expected");
183 ptr
->ml_vsyncend
= val
.num
;
186 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
187 Error("ModeLine VTotal expected");
188 ptr
->ml_vtotal
= val
.num
;
190 token
= xf86getSubTokenWithTab(&(ptr
->ml_comment
), TimingTab
);
191 while ((token
== TT_INTERLACE
) || (token
== TT_PHSYNC
) ||
192 (token
== TT_NHSYNC
) || (token
== TT_PVSYNC
) ||
193 (token
== TT_NVSYNC
) || (token
== TT_CSYNC
) ||
194 (token
== TT_PCSYNC
) || (token
== TT_NCSYNC
) ||
195 (token
== TT_DBLSCAN
) || (token
== TT_HSKEW
) ||
196 (token
== TT_VSCAN
) || (token
== TT_BCAST
)) {
200 ptr
->ml_flags
|= XF86CONF_INTERLACE
;
203 ptr
->ml_flags
|= XF86CONF_PHSYNC
;
206 ptr
->ml_flags
|= XF86CONF_NHSYNC
;
209 ptr
->ml_flags
|= XF86CONF_PVSYNC
;
212 ptr
->ml_flags
|= XF86CONF_NVSYNC
;
215 ptr
->ml_flags
|= XF86CONF_CSYNC
;
218 ptr
->ml_flags
|= XF86CONF_PCSYNC
;
221 ptr
->ml_flags
|= XF86CONF_NCSYNC
;
224 ptr
->ml_flags
|= XF86CONF_DBLSCAN
;
227 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
228 Error(NUMBER_MSG
, "Hskew");
229 ptr
->ml_hskew
= val
.num
;
230 ptr
->ml_flags
|= XF86CONF_HSKEW
;
233 ptr
->ml_flags
|= XF86CONF_BCAST
;
236 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
237 Error(NUMBER_MSG
, "Vscan");
238 ptr
->ml_vscan
= val
.num
;
239 ptr
->ml_flags
|= XF86CONF_VSCAN
;
242 Error(UNEXPECTED_EOF_MSG
);
245 Error(INVALID_KEYWORD_MSG
, xf86tokenString());
248 token
= xf86getSubTokenWithTab(&(ptr
->ml_comment
), TimingTab
);
250 xf86unGetToken(token
);
253 printf("ModeLine parsed\n");
258 static XF86ConfModeLinePtr
259 xf86parseVerboseMode(void)
262 int had_dotclock
= 0, had_htimings
= 0, had_vtimings
= 0;
264 parsePrologue(XF86ConfModeLinePtr
, XF86ConfModeLineRec
)
266 if (xf86getSubToken(&(ptr
->ml_comment
)) != STRING
)
267 Error("Mode name expected");
268 ptr
->ml_identifier
= val
.str
;
269 while ((token
= xf86getToken(ModeTab
)) != ENDMODE
) {
272 ptr
->ml_comment
= xf86addComment(ptr
->ml_comment
, val
.str
);
275 if ((token
= xf86getSubToken(&(ptr
->ml_comment
))) != NUMBER
)
276 Error(NUMBER_MSG
, "DotClock");
277 ptr
->ml_clock
= (int) (val
.realnum
* 1000.0 + 0.5);
281 if (xf86getSubToken(&(ptr
->ml_comment
)) == NUMBER
)
282 ptr
->ml_hdisplay
= val
.num
;
284 Error("Horizontal display expected");
286 if (xf86getSubToken(&(ptr
->ml_comment
)) == NUMBER
)
287 ptr
->ml_hsyncstart
= val
.num
;
289 Error("Horizontal sync start expected");
291 if (xf86getSubToken(&(ptr
->ml_comment
)) == NUMBER
)
292 ptr
->ml_hsyncend
= val
.num
;
294 Error("Horizontal sync end expected");
296 if (xf86getSubToken(&(ptr
->ml_comment
)) == NUMBER
)
297 ptr
->ml_htotal
= val
.num
;
299 Error("Horizontal total expected");
303 if (xf86getSubToken(&(ptr
->ml_comment
)) == NUMBER
)
304 ptr
->ml_vdisplay
= val
.num
;
306 Error("Vertical display expected");
308 if (xf86getSubToken(&(ptr
->ml_comment
)) == NUMBER
)
309 ptr
->ml_vsyncstart
= val
.num
;
311 Error("Vertical sync start expected");
313 if (xf86getSubToken(&(ptr
->ml_comment
)) == NUMBER
)
314 ptr
->ml_vsyncend
= val
.num
;
316 Error("Vertical sync end expected");
318 if (xf86getSubToken(&(ptr
->ml_comment
)) == NUMBER
)
319 ptr
->ml_vtotal
= val
.num
;
321 Error("Vertical total expected");
325 token
= xf86getSubToken(&(ptr
->ml_comment
));
327 Error(QUOTE_MSG
, "Flags");
328 while (token
== STRING
) {
329 token2
= xf86getStringToken(TimingTab
);
332 ptr
->ml_flags
|= XF86CONF_INTERLACE
;
335 ptr
->ml_flags
|= XF86CONF_PHSYNC
;
338 ptr
->ml_flags
|= XF86CONF_NHSYNC
;
341 ptr
->ml_flags
|= XF86CONF_PVSYNC
;
344 ptr
->ml_flags
|= XF86CONF_NVSYNC
;
347 ptr
->ml_flags
|= XF86CONF_CSYNC
;
350 ptr
->ml_flags
|= XF86CONF_PCSYNC
;
353 ptr
->ml_flags
|= XF86CONF_NCSYNC
;
356 ptr
->ml_flags
|= XF86CONF_DBLSCAN
;
359 Error(UNEXPECTED_EOF_MSG
);
362 Error("Unknown flag string");
365 token
= xf86getSubToken(&(ptr
->ml_comment
));
367 xf86unGetToken(token
);
370 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
371 Error("Horizontal skew expected");
372 ptr
->ml_flags
|= XF86CONF_HSKEW
;
373 ptr
->ml_hskew
= val
.num
;
376 if (xf86getSubToken(&(ptr
->ml_comment
)) != NUMBER
)
377 Error("Vertical scan count expected");
378 ptr
->ml_flags
|= XF86CONF_VSCAN
;
379 ptr
->ml_vscan
= val
.num
;
382 Error(UNEXPECTED_EOF_MSG
);
385 Error("Unexepcted token in verbose \"Mode\" entry\n");
389 Error("the dotclock is missing");
391 Error("the horizontal timings are missing");
393 Error("the vertical timings are missing");
396 printf("Verbose Mode parsed\n");
403 #define CLEANUP xf86freeMonitorList
406 xf86parseMonitorSection(void)
408 int has_ident
= FALSE
;
411 parsePrologue(XF86ConfMonitorPtr
, XF86ConfMonitorRec
)
413 while ((token
= xf86getToken(MonitorTab
)) != ENDSECTION
) {
416 ptr
->mon_comment
= xf86addComment(ptr
->mon_comment
, val
.str
);
419 if (xf86getSubToken(&(ptr
->mon_comment
)) != STRING
)
420 Error(QUOTE_MSG
, "Identifier");
421 if (has_ident
== TRUE
)
422 Error(MULTIPLE_MSG
, "Identifier");
423 ptr
->mon_identifier
= val
.str
;
427 if (xf86getSubToken(&(ptr
->mon_comment
)) != STRING
)
428 Error(QUOTE_MSG
, "Vendor");
429 ptr
->mon_vendor
= val
.str
;
432 if (xf86getSubToken(&(ptr
->mon_comment
)) != STRING
)
433 Error(QUOTE_MSG
, "ModelName");
434 ptr
->mon_modelname
= val
.str
;
437 HANDLE_LIST(mon_modeline_lst
, xf86parseVerboseMode
,
438 XF86ConfModeLinePtr
);
441 HANDLE_LIST(mon_modeline_lst
, xf86parseModeLine
,
442 XF86ConfModeLinePtr
);
445 if (xf86getSubToken(&(ptr
->mon_comment
)) != NUMBER
)
446 Error(DISPLAYSIZE_MSG
);
447 ptr
->mon_width
= val
.realnum
;
448 if (xf86getSubToken(&(ptr
->mon_comment
)) != NUMBER
)
449 Error(DISPLAYSIZE_MSG
);
450 ptr
->mon_height
= val
.realnum
;
454 if (xf86getSubToken(&(ptr
->mon_comment
)) != NUMBER
)
455 Error(HORIZSYNC_MSG
);
457 if (ptr
->mon_n_hsync
>= CONF_MAX_HSYNC
)
458 Error("Sorry. Too many horizontal sync intervals.");
459 ptr
->mon_hsync
[ptr
->mon_n_hsync
].lo
= val
.realnum
;
460 switch (token
= xf86getSubToken(&(ptr
->mon_comment
))) {
462 ptr
->mon_hsync
[ptr
->mon_n_hsync
].hi
=
463 ptr
->mon_hsync
[ptr
->mon_n_hsync
].lo
;
466 if (xf86getSubToken(&(ptr
->mon_comment
)) != NUMBER
||
467 (float) val
.realnum
<
468 ptr
->mon_hsync
[ptr
->mon_n_hsync
].lo
)
469 Error(HORIZSYNC_MSG
);
470 ptr
->mon_hsync
[ptr
->mon_n_hsync
].hi
= val
.realnum
;
471 if ((token
= xf86getSubToken(&(ptr
->mon_comment
))) == COMMA
)
476 /* We cannot currently know if a '\n' was found,
477 * or this is a real error
479 ptr
->mon_hsync
[ptr
->mon_n_hsync
].hi
=
480 ptr
->mon_hsync
[ptr
->mon_n_hsync
].lo
;
485 } while ((token
= xf86getSubToken(&(ptr
->mon_comment
))) == NUMBER
);
487 xf86unGetToken(token
);
491 if (xf86getSubToken(&(ptr
->mon_comment
)) != NUMBER
)
492 Error(VERTREFRESH_MSG
);
494 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].lo
= val
.realnum
;
495 switch (token
= xf86getSubToken(&(ptr
->mon_comment
))) {
497 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].hi
=
498 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].lo
;
501 if (xf86getSubToken(&(ptr
->mon_comment
)) != NUMBER
||
502 (float) val
.realnum
<
503 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].lo
)
504 Error(VERTREFRESH_MSG
);
505 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].hi
= val
.realnum
;
506 if ((token
= xf86getSubToken(&(ptr
->mon_comment
))) == COMMA
)
508 ptr
->mon_n_vrefresh
++;
511 /* We cannot currently know if a '\n' was found,
512 * or this is a real error
514 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].hi
=
515 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].lo
;
516 ptr
->mon_n_vrefresh
++;
519 if (ptr
->mon_n_vrefresh
>= CONF_MAX_VREFRESH
)
520 Error("Sorry. Too many vertical refresh intervals.");
521 ptr
->mon_n_vrefresh
++;
522 } while ((token
= xf86getSubToken(&(ptr
->mon_comment
))) == NUMBER
);
524 xf86unGetToken(token
);
528 if (xf86getSubToken(&(ptr
->mon_comment
)) != NUMBER
) {
529 Error(INVALID_GAMMA_MSG
);
532 ptr
->mon_gamma_red
= ptr
->mon_gamma_green
=
533 ptr
->mon_gamma_blue
= val
.realnum
;
534 if (xf86getSubToken(&(ptr
->mon_comment
)) == NUMBER
) {
535 ptr
->mon_gamma_green
= val
.realnum
;
536 if (xf86getSubToken(&(ptr
->mon_comment
)) == NUMBER
) {
537 ptr
->mon_gamma_blue
= val
.realnum
;
540 Error(INVALID_GAMMA_MSG
);
544 xf86unGetToken(token
);
548 ptr
->mon_option_lst
= xf86parseOption(ptr
->mon_option_lst
);
552 XF86ConfModesLinkPtr mptr
;
554 if ((token
= xf86getSubToken(&(ptr
->mon_comment
))) != STRING
)
555 Error(QUOTE_MSG
, "UseModes");
557 /* add to the end of the list of modes sections
559 mptr
= calloc(1, sizeof(XF86ConfModesLinkRec
));
560 mptr
->list
.next
= NULL
;
561 mptr
->ml_modes_str
= val
.str
;
562 mptr
->ml_modes
= NULL
;
563 ptr
->mon_modes_sect_lst
= (XF86ConfModesLinkPtr
)
564 xf86addListItem((GenericListPtr
) ptr
->mon_modes_sect_lst
,
565 (GenericListPtr
) mptr
);
569 Error(UNEXPECTED_EOF_MSG
);
572 xf86parseError(INVALID_KEYWORD_MSG
, xf86tokenString());
583 printf("Monitor section parsed\n");
589 #define CLEANUP xf86freeModesList
592 xf86parseModesSection(void)
594 int has_ident
= FALSE
;
597 parsePrologue(XF86ConfModesPtr
, XF86ConfModesRec
)
599 while ((token
= xf86getToken(ModesTab
)) != ENDSECTION
) {
602 ptr
->modes_comment
= xf86addComment(ptr
->modes_comment
, val
.str
);
605 if (xf86getSubToken(&(ptr
->modes_comment
)) != STRING
)
606 Error(QUOTE_MSG
, "Identifier");
607 if (has_ident
== TRUE
)
608 Error(MULTIPLE_MSG
, "Identifier");
609 ptr
->modes_identifier
= val
.str
;
613 HANDLE_LIST(mon_modeline_lst
, xf86parseVerboseMode
,
614 XF86ConfModeLinePtr
);
617 HANDLE_LIST(mon_modeline_lst
, xf86parseModeLine
,
618 XF86ConfModeLinePtr
);
621 xf86parseError(INVALID_KEYWORD_MSG
, xf86tokenString());
632 printf("Modes section parsed\n");
640 xf86printMonitorSection(FILE * cf
, XF86ConfMonitorPtr ptr
)
643 XF86ConfModeLinePtr mlptr
;
644 XF86ConfModesLinkPtr mptr
;
647 mptr
= ptr
->mon_modes_sect_lst
;
648 fprintf(cf
, "Section \"Monitor\"\n");
649 if (ptr
->mon_comment
)
650 fprintf(cf
, "%s", ptr
->mon_comment
);
651 if (ptr
->mon_identifier
)
652 fprintf(cf
, "\tIdentifier \"%s\"\n", ptr
->mon_identifier
);
654 fprintf(cf
, "\tVendorName \"%s\"\n", ptr
->mon_vendor
);
655 if (ptr
->mon_modelname
)
656 fprintf(cf
, "\tModelName \"%s\"\n", ptr
->mon_modelname
);
658 fprintf(cf
, "\tUseModes \"%s\"\n", mptr
->ml_modes_str
);
659 mptr
= mptr
->list
.next
;
662 fprintf(cf
, "\tDisplaySize %d\t%d\n",
663 ptr
->mon_width
, ptr
->mon_height
);
664 for (i
= 0; i
< ptr
->mon_n_hsync
; i
++) {
665 fprintf(cf
, "\tHorizSync %2.1f - %2.1f\n",
666 ptr
->mon_hsync
[i
].lo
, ptr
->mon_hsync
[i
].hi
);
668 for (i
= 0; i
< ptr
->mon_n_vrefresh
; i
++) {
669 fprintf(cf
, "\tVertRefresh %2.1f - %2.1f\n",
670 ptr
->mon_vrefresh
[i
].lo
, ptr
->mon_vrefresh
[i
].hi
);
672 if (ptr
->mon_gamma_red
) {
673 if (ptr
->mon_gamma_red
== ptr
->mon_gamma_green
674 && ptr
->mon_gamma_red
== ptr
->mon_gamma_blue
) {
675 fprintf(cf
, "\tGamma %.4g\n", ptr
->mon_gamma_red
);
678 fprintf(cf
, "\tGamma %.4g %.4g %.4g\n",
680 ptr
->mon_gamma_green
, ptr
->mon_gamma_blue
);
683 for (mlptr
= ptr
->mon_modeline_lst
; mlptr
; mlptr
= mlptr
->list
.next
) {
684 fprintf(cf
, "\tModeLine \"%s\" %2.1f ",
685 mlptr
->ml_identifier
, mlptr
->ml_clock
/ 1000.0);
686 fprintf(cf
, "%d %d %d %d %d %d %d %d",
687 mlptr
->ml_hdisplay
, mlptr
->ml_hsyncstart
,
688 mlptr
->ml_hsyncend
, mlptr
->ml_htotal
,
689 mlptr
->ml_vdisplay
, mlptr
->ml_vsyncstart
,
690 mlptr
->ml_vsyncend
, mlptr
->ml_vtotal
);
691 if (mlptr
->ml_flags
& XF86CONF_PHSYNC
)
692 fprintf(cf
, " +hsync");
693 if (mlptr
->ml_flags
& XF86CONF_NHSYNC
)
694 fprintf(cf
, " -hsync");
695 if (mlptr
->ml_flags
& XF86CONF_PVSYNC
)
696 fprintf(cf
, " +vsync");
697 if (mlptr
->ml_flags
& XF86CONF_NVSYNC
)
698 fprintf(cf
, " -vsync");
699 if (mlptr
->ml_flags
& XF86CONF_INTERLACE
)
700 fprintf(cf
, " interlace");
701 if (mlptr
->ml_flags
& XF86CONF_CSYNC
)
702 fprintf(cf
, " composite");
703 if (mlptr
->ml_flags
& XF86CONF_PCSYNC
)
704 fprintf(cf
, " +csync");
705 if (mlptr
->ml_flags
& XF86CONF_NCSYNC
)
706 fprintf(cf
, " -csync");
707 if (mlptr
->ml_flags
& XF86CONF_DBLSCAN
)
708 fprintf(cf
, " doublescan");
709 if (mlptr
->ml_flags
& XF86CONF_HSKEW
)
710 fprintf(cf
, " hskew %d", mlptr
->ml_hskew
);
711 if (mlptr
->ml_flags
& XF86CONF_BCAST
)
712 fprintf(cf
, " bcast");
715 xf86printOptionList(cf
, ptr
->mon_option_lst
, 1);
716 fprintf(cf
, "EndSection\n\n");
717 ptr
= ptr
->list
.next
;
722 xf86printModesSection(FILE * cf
, XF86ConfModesPtr ptr
)
724 XF86ConfModeLinePtr mlptr
;
727 fprintf(cf
, "Section \"Modes\"\n");
728 if (ptr
->modes_comment
)
729 fprintf(cf
, "%s", ptr
->modes_comment
);
730 if (ptr
->modes_identifier
)
731 fprintf(cf
, "\tIdentifier \"%s\"\n", ptr
->modes_identifier
);
732 for (mlptr
= ptr
->mon_modeline_lst
; mlptr
; mlptr
= mlptr
->list
.next
) {
733 fprintf(cf
, "\tModeLine \"%s\" %2.1f ",
734 mlptr
->ml_identifier
, mlptr
->ml_clock
/ 1000.0);
735 fprintf(cf
, "%d %d %d %d %d %d %d %d",
736 mlptr
->ml_hdisplay
, mlptr
->ml_hsyncstart
,
737 mlptr
->ml_hsyncend
, mlptr
->ml_htotal
,
738 mlptr
->ml_vdisplay
, mlptr
->ml_vsyncstart
,
739 mlptr
->ml_vsyncend
, mlptr
->ml_vtotal
);
740 if (mlptr
->ml_flags
& XF86CONF_PHSYNC
)
741 fprintf(cf
, " +hsync");
742 if (mlptr
->ml_flags
& XF86CONF_NHSYNC
)
743 fprintf(cf
, " -hsync");
744 if (mlptr
->ml_flags
& XF86CONF_PVSYNC
)
745 fprintf(cf
, " +vsync");
746 if (mlptr
->ml_flags
& XF86CONF_NVSYNC
)
747 fprintf(cf
, " -vsync");
748 if (mlptr
->ml_flags
& XF86CONF_INTERLACE
)
749 fprintf(cf
, " interlace");
750 if (mlptr
->ml_flags
& XF86CONF_CSYNC
)
751 fprintf(cf
, " composite");
752 if (mlptr
->ml_flags
& XF86CONF_PCSYNC
)
753 fprintf(cf
, " +csync");
754 if (mlptr
->ml_flags
& XF86CONF_NCSYNC
)
755 fprintf(cf
, " -csync");
756 if (mlptr
->ml_flags
& XF86CONF_DBLSCAN
)
757 fprintf(cf
, " doublescan");
758 if (mlptr
->ml_flags
& XF86CONF_HSKEW
)
759 fprintf(cf
, " hskew %d", mlptr
->ml_hskew
);
760 if (mlptr
->ml_flags
& XF86CONF_VSCAN
)
761 fprintf(cf
, " vscan %d", mlptr
->ml_vscan
);
762 if (mlptr
->ml_flags
& XF86CONF_BCAST
)
763 fprintf(cf
, " bcast");
764 if (mlptr
->ml_comment
)
765 fprintf(cf
, "%s", mlptr
->ml_comment
);
769 fprintf(cf
, "EndSection\n\n");
770 ptr
= ptr
->list
.next
;
775 xf86freeMonitorList(XF86ConfMonitorPtr ptr
)
777 XF86ConfMonitorPtr prev
;
780 TestFree(ptr
->mon_identifier
);
781 TestFree(ptr
->mon_vendor
);
782 TestFree(ptr
->mon_modelname
);
783 TestFree(ptr
->mon_comment
);
784 xf86optionListFree(ptr
->mon_option_lst
);
785 xf86freeModeLineList(ptr
->mon_modeline_lst
);
787 ptr
= ptr
->list
.next
;
793 xf86freeModesList(XF86ConfModesPtr ptr
)
795 XF86ConfModesPtr prev
;
798 TestFree(ptr
->modes_identifier
);
799 TestFree(ptr
->modes_comment
);
800 xf86freeModeLineList(ptr
->mon_modeline_lst
);
802 ptr
= ptr
->list
.next
;
808 xf86findMonitor(const char *ident
, XF86ConfMonitorPtr p
)
811 if (xf86nameCompare(ident
, p
->mon_identifier
) == 0)
820 xf86findModes(const char *ident
, XF86ConfModesPtr p
)
823 if (xf86nameCompare(ident
, p
->modes_identifier
) == 0)
832 xf86findModeLine(const char *ident
, XF86ConfModeLinePtr p
)
835 if (xf86nameCompare(ident
, p
->ml_identifier
) == 0)
844 xf86validateMonitor(XF86ConfigPtr p
, XF86ConfScreenPtr screen
)
846 XF86ConfMonitorPtr monitor
= screen
->scrn_monitor
;
847 XF86ConfModesLinkPtr modeslnk
= monitor
->mon_modes_sect_lst
;
848 XF86ConfModesPtr modes
;
851 modes
= xf86findModes(modeslnk
->ml_modes_str
, p
->conf_modes_lst
);
853 xf86validationError(UNDEFINED_MODES_MSG
,
854 modeslnk
->ml_modes_str
,
855 screen
->scrn_identifier
);
858 modeslnk
->ml_modes
= modes
;
859 modeslnk
= modeslnk
->list
.next
;