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"
68 static xf86ConfigSymTabRec MonitorTab
[] =
70 {ENDSECTION
, "endsection"},
71 {IDENTIFIER
, "identifier"},
72 {VENDOR
, "vendorname"},
74 {USEMODES
, "usemodes"},
75 {MODELINE
, "modeline"},
76 {DISPLAYSIZE
, "displaysize"},
77 {HORIZSYNC
, "horizsync"},
78 {VERTREFRESH
, "vertrefresh"},
85 static xf86ConfigSymTabRec ModesTab
[] =
87 {ENDSECTION
, "endsection"},
88 {IDENTIFIER
, "identifier"},
89 {MODELINE
, "modeline"},
94 static xf86ConfigSymTabRec TimingTab
[] =
96 {TT_INTERLACE
, "interlace"},
97 {TT_PHSYNC
, "+hsync"},
98 {TT_NHSYNC
, "-hsync"},
99 {TT_PVSYNC
, "+vsync"},
100 {TT_NVSYNC
, "-vsync"},
101 {TT_CSYNC
, "composite"},
102 {TT_PCSYNC
, "+csync"},
103 {TT_NCSYNC
, "-csync"},
104 {TT_DBLSCAN
, "doublescan"},
108 {TT_CUSTOM
, "CUSTOM"},
112 static xf86ConfigSymTabRec ModeTab
[] =
114 {DOTCLOCK
, "dotclock"},
115 {HTIMINGS
, "htimings"},
116 {VTIMINGS
, "vtimings"},
121 {ENDMODE
, "endmode"},
125 #define CLEANUP xf86freeModeLineList
128 xf86freeModeLineList (XF86ConfModeLinePtr ptr
)
130 XF86ConfModeLinePtr prev
;
133 TestFree (ptr
->ml_identifier
);
134 TestFree (ptr
->ml_comment
);
136 ptr
= ptr
->list
.next
;
141 static XF86ConfModeLinePtr
142 xf86parseModeLine (void)
145 parsePrologue (XF86ConfModeLinePtr
, XF86ConfModeLineRec
)
148 if (xf86getSubToken (&(ptr
->ml_comment
)) != STRING
)
149 Error ("ModeLine identifier expected", NULL
);
150 ptr
->ml_identifier
= val
.str
;
153 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
154 Error ("ModeLine dotclock expected", NULL
);
155 ptr
->ml_clock
= (int) (val
.realnum
* 1000.0 + 0.5);
158 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
159 Error ("ModeLine Hdisplay expected", NULL
);
160 ptr
->ml_hdisplay
= val
.num
;
163 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
164 Error ("ModeLine HSyncStart expected", NULL
);
165 ptr
->ml_hsyncstart
= val
.num
;
168 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
169 Error ("ModeLine HSyncEnd expected", NULL
);
170 ptr
->ml_hsyncend
= val
.num
;
173 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
174 Error ("ModeLine HTotal expected", NULL
);
175 ptr
->ml_htotal
= val
.num
;
178 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
179 Error ("ModeLine Vdisplay expected", NULL
);
180 ptr
->ml_vdisplay
= val
.num
;
183 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
184 Error ("ModeLine VSyncStart expected", NULL
);
185 ptr
->ml_vsyncstart
= val
.num
;
188 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
189 Error ("ModeLine VSyncEnd expected", NULL
);
190 ptr
->ml_vsyncend
= val
.num
;
193 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
194 Error ("ModeLine VTotal expected", NULL
);
195 ptr
->ml_vtotal
= val
.num
;
197 token
= xf86getSubTokenWithTab (&(ptr
->ml_comment
), TimingTab
);
198 while ((token
== TT_INTERLACE
) || (token
== TT_PHSYNC
) ||
199 (token
== TT_NHSYNC
) || (token
== TT_PVSYNC
) ||
200 (token
== TT_NVSYNC
) || (token
== TT_CSYNC
) ||
201 (token
== TT_PCSYNC
) || (token
== TT_NCSYNC
) ||
202 (token
== TT_DBLSCAN
) || (token
== TT_HSKEW
) ||
203 (token
== TT_VSCAN
) || (token
== TT_BCAST
))
209 ptr
->ml_flags
|= XF86CONF_INTERLACE
;
212 ptr
->ml_flags
|= XF86CONF_PHSYNC
;
215 ptr
->ml_flags
|= XF86CONF_NHSYNC
;
218 ptr
->ml_flags
|= XF86CONF_PVSYNC
;
221 ptr
->ml_flags
|= XF86CONF_NVSYNC
;
224 ptr
->ml_flags
|= XF86CONF_CSYNC
;
227 ptr
->ml_flags
|= XF86CONF_PCSYNC
;
230 ptr
->ml_flags
|= XF86CONF_NCSYNC
;
233 ptr
->ml_flags
|= XF86CONF_DBLSCAN
;
236 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
237 Error (NUMBER_MSG
, "Hskew");
238 ptr
->ml_hskew
= val
.num
;
239 ptr
->ml_flags
|= XF86CONF_HSKEW
;
242 ptr
->ml_flags
|= XF86CONF_BCAST
;
245 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
246 Error (NUMBER_MSG
, "Vscan");
247 ptr
->ml_vscan
= val
.num
;
248 ptr
->ml_flags
|= XF86CONF_VSCAN
;
251 ptr
->ml_flags
|= XF86CONF_CUSTOM
;
254 Error (UNEXPECTED_EOF_MSG
, NULL
);
257 Error (INVALID_KEYWORD_MSG
, xf86tokenString ());
260 token
= xf86getSubTokenWithTab (&(ptr
->ml_comment
), TimingTab
);
262 xf86unGetToken (token
);
265 printf ("ModeLine parsed\n");
270 static XF86ConfModeLinePtr
271 xf86parseVerboseMode (void)
274 int had_dotclock
= 0, had_htimings
= 0, had_vtimings
= 0;
275 parsePrologue (XF86ConfModeLinePtr
, XF86ConfModeLineRec
)
277 if (xf86getSubToken (&(ptr
->ml_comment
)) != STRING
)
278 Error ("Mode name expected", NULL
);
279 ptr
->ml_identifier
= val
.str
;
280 while ((token
= xf86getToken (ModeTab
)) != ENDMODE
)
285 ptr
->ml_comment
= xf86addComment(ptr
->ml_comment
, val
.str
);
288 if ((token
= xf86getSubToken (&(ptr
->ml_comment
))) != NUMBER
)
289 Error (NUMBER_MSG
, "DotClock");
290 ptr
->ml_clock
= (int) (val
.realnum
* 1000.0 + 0.5);
294 if (xf86getSubToken (&(ptr
->ml_comment
)) == NUMBER
)
295 ptr
->ml_hdisplay
= val
.num
;
297 Error ("Horizontal display expected", NULL
);
299 if (xf86getSubToken (&(ptr
->ml_comment
)) == NUMBER
)
300 ptr
->ml_hsyncstart
= val
.num
;
302 Error ("Horizontal sync start expected", NULL
);
304 if (xf86getSubToken (&(ptr
->ml_comment
)) == NUMBER
)
305 ptr
->ml_hsyncend
= val
.num
;
307 Error ("Horizontal sync end expected", NULL
);
309 if (xf86getSubToken (&(ptr
->ml_comment
)) == NUMBER
)
310 ptr
->ml_htotal
= val
.num
;
312 Error ("Horizontal total expected", NULL
);
316 if (xf86getSubToken (&(ptr
->ml_comment
)) == NUMBER
)
317 ptr
->ml_vdisplay
= val
.num
;
319 Error ("Vertical display expected", NULL
);
321 if (xf86getSubToken (&(ptr
->ml_comment
)) == NUMBER
)
322 ptr
->ml_vsyncstart
= val
.num
;
324 Error ("Vertical sync start expected", NULL
);
326 if (xf86getSubToken (&(ptr
->ml_comment
)) == NUMBER
)
327 ptr
->ml_vsyncend
= val
.num
;
329 Error ("Vertical sync end expected", NULL
);
331 if (xf86getSubToken (&(ptr
->ml_comment
)) == NUMBER
)
332 ptr
->ml_vtotal
= val
.num
;
334 Error ("Vertical total expected", NULL
);
338 token
= xf86getSubToken (&(ptr
->ml_comment
));
340 Error (QUOTE_MSG
, "Flags");
341 while (token
== STRING
)
343 token2
= xf86getStringToken (TimingTab
);
347 ptr
->ml_flags
|= XF86CONF_INTERLACE
;
350 ptr
->ml_flags
|= XF86CONF_PHSYNC
;
353 ptr
->ml_flags
|= XF86CONF_NHSYNC
;
356 ptr
->ml_flags
|= XF86CONF_PVSYNC
;
359 ptr
->ml_flags
|= XF86CONF_NVSYNC
;
362 ptr
->ml_flags
|= XF86CONF_CSYNC
;
365 ptr
->ml_flags
|= XF86CONF_PCSYNC
;
368 ptr
->ml_flags
|= XF86CONF_NCSYNC
;
371 ptr
->ml_flags
|= XF86CONF_DBLSCAN
;
374 ptr
->ml_flags
|= XF86CONF_CUSTOM
;
377 Error (UNEXPECTED_EOF_MSG
, NULL
);
380 Error ("Unknown flag string", NULL
);
383 token
= xf86getSubToken (&(ptr
->ml_comment
));
385 xf86unGetToken (token
);
388 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
389 Error ("Horizontal skew expected", NULL
);
390 ptr
->ml_flags
|= XF86CONF_HSKEW
;
391 ptr
->ml_hskew
= val
.num
;
394 if (xf86getSubToken (&(ptr
->ml_comment
)) != NUMBER
)
395 Error ("Vertical scan count expected", NULL
);
396 ptr
->ml_flags
|= XF86CONF_VSCAN
;
397 ptr
->ml_vscan
= val
.num
;
400 Error (UNEXPECTED_EOF_MSG
, NULL
);
403 Error ("Unexepcted token in verbose \"Mode\" entry\n", NULL
);
407 Error ("the dotclock is missing", NULL
);
409 Error ("the horizontal timings are missing", NULL
);
411 Error ("the vertical timings are missing", NULL
);
414 printf ("Verbose Mode parsed\n");
421 #define CLEANUP xf86freeMonitorList
424 xf86parseMonitorSection (void)
426 int has_ident
= FALSE
;
428 parsePrologue (XF86ConfMonitorPtr
, XF86ConfMonitorRec
)
430 while ((token
= xf86getToken (MonitorTab
)) != ENDSECTION
)
435 ptr
->mon_comment
= xf86addComment(ptr
->mon_comment
, val
.str
);
438 if (xf86getSubToken (&(ptr
->mon_comment
)) != STRING
)
439 Error (QUOTE_MSG
, "Identifier");
440 if (has_ident
== TRUE
)
441 Error (MULTIPLE_MSG
, "Identifier");
442 ptr
->mon_identifier
= val
.str
;
446 if (xf86getSubToken (&(ptr
->mon_comment
)) != STRING
)
447 Error (QUOTE_MSG
, "Vendor");
448 ptr
->mon_vendor
= val
.str
;
451 if (xf86getSubToken (&(ptr
->mon_comment
)) != STRING
)
452 Error (QUOTE_MSG
, "ModelName");
453 ptr
->mon_modelname
= val
.str
;
456 HANDLE_LIST (mon_modeline_lst
, xf86parseVerboseMode
,
457 XF86ConfModeLinePtr
);
460 HANDLE_LIST (mon_modeline_lst
, xf86parseModeLine
,
461 XF86ConfModeLinePtr
);
464 if (xf86getSubToken (&(ptr
->mon_comment
)) != NUMBER
)
465 Error (DISPLAYSIZE_MSG
, NULL
);
466 ptr
->mon_width
= val
.realnum
;
467 if (xf86getSubToken (&(ptr
->mon_comment
)) != NUMBER
)
468 Error (DISPLAYSIZE_MSG
, NULL
);
469 ptr
->mon_height
= val
.realnum
;
473 if (xf86getSubToken (&(ptr
->mon_comment
)) != NUMBER
)
474 Error (HORIZSYNC_MSG
, NULL
);
476 if (ptr
->mon_n_hsync
>= CONF_MAX_HSYNC
)
477 Error ("Sorry. Too many horizontal sync intervals.", NULL
);
478 ptr
->mon_hsync
[ptr
->mon_n_hsync
].lo
= val
.realnum
;
479 switch (token
= xf86getSubToken (&(ptr
->mon_comment
)))
482 ptr
->mon_hsync
[ptr
->mon_n_hsync
].hi
=
483 ptr
->mon_hsync
[ptr
->mon_n_hsync
].lo
;
486 if (xf86getSubToken (&(ptr
->mon_comment
)) != NUMBER
||
487 (float)val
.realnum
< ptr
->mon_hsync
[ptr
->mon_n_hsync
].lo
)
488 Error (HORIZSYNC_MSG
, NULL
);
489 ptr
->mon_hsync
[ptr
->mon_n_hsync
].hi
= val
.realnum
;
490 if ((token
= xf86getSubToken (&(ptr
->mon_comment
))) == COMMA
)
495 /* We cannot currently know if a '\n' was found,
496 * or this is a real error
498 ptr
->mon_hsync
[ptr
->mon_n_hsync
].hi
=
499 ptr
->mon_hsync
[ptr
->mon_n_hsync
].lo
;
504 } while ((token
= xf86getSubToken (&(ptr
->mon_comment
))) == NUMBER
);
506 xf86unGetToken (token
);
510 if (xf86getSubToken (&(ptr
->mon_comment
)) != NUMBER
)
511 Error (VERTREFRESH_MSG
, NULL
);
513 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].lo
= val
.realnum
;
514 switch (token
= xf86getSubToken (&(ptr
->mon_comment
)))
517 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].hi
=
518 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].lo
;
521 if (xf86getSubToken (&(ptr
->mon_comment
)) != NUMBER
||
522 (float)val
.realnum
< ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].lo
)
523 Error (VERTREFRESH_MSG
, NULL
);
524 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].hi
= val
.realnum
;
525 if ((token
= xf86getSubToken (&(ptr
->mon_comment
))) == COMMA
)
527 ptr
->mon_n_vrefresh
++;
530 /* We cannot currently know if a '\n' was found,
531 * or this is a real error
533 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].hi
=
534 ptr
->mon_vrefresh
[ptr
->mon_n_vrefresh
].lo
;
535 ptr
->mon_n_vrefresh
++;
538 if (ptr
->mon_n_vrefresh
>= CONF_MAX_VREFRESH
)
539 Error ("Sorry. Too many vertical refresh intervals.", NULL
);
540 ptr
->mon_n_vrefresh
++;
541 } while ((token
= xf86getSubToken (&(ptr
->mon_comment
))) == NUMBER
);
543 xf86unGetToken (token
);
547 if( xf86getSubToken (&(ptr
->mon_comment
)) != NUMBER
)
549 Error (INVALID_GAMMA_MSG
, NULL
);
553 ptr
->mon_gamma_red
= ptr
->mon_gamma_green
=
554 ptr
->mon_gamma_blue
= val
.realnum
;
555 if( xf86getSubToken (&(ptr
->mon_comment
)) == NUMBER
)
557 ptr
->mon_gamma_green
= val
.realnum
;
558 if( xf86getSubToken (&(ptr
->mon_comment
)) == NUMBER
)
560 ptr
->mon_gamma_blue
= val
.realnum
;
564 Error (INVALID_GAMMA_MSG
, NULL
);
568 xf86unGetToken (token
);
572 ptr
->mon_option_lst
= xf86parseOption(ptr
->mon_option_lst
);
576 XF86ConfModesLinkPtr mptr
;
578 if ((token
= xf86getSubToken (&(ptr
->mon_comment
))) != STRING
)
579 Error (QUOTE_MSG
, "UseModes");
581 /* add to the end of the list of modes sections
583 mptr
= xf86confcalloc (1, sizeof (XF86ConfModesLinkRec
));
584 mptr
->list
.next
= NULL
;
585 mptr
->ml_modes_str
= val
.str
;
586 mptr
->ml_modes
= NULL
;
587 ptr
->mon_modes_sect_lst
= (XF86ConfModesLinkPtr
)
588 xf86addListItem((GenericListPtr
)ptr
->mon_modes_sect_lst
,
589 (GenericListPtr
)mptr
);
593 Error (UNEXPECTED_EOF_MSG
, NULL
);
596 xf86parseError (INVALID_KEYWORD_MSG
, xf86tokenString ());
604 Error (NO_IDENT_MSG
, NULL
);
607 printf ("Monitor section parsed\n");
613 #define CLEANUP xf86freeModesList
616 xf86parseModesSection (void)
618 int has_ident
= FALSE
;
620 parsePrologue (XF86ConfModesPtr
, XF86ConfModesRec
)
622 while ((token
= xf86getToken (ModesTab
)) != ENDSECTION
)
627 ptr
->modes_comment
= xf86addComment(ptr
->modes_comment
, val
.str
);
630 if (xf86getSubToken (&(ptr
->modes_comment
)) != STRING
)
631 Error (QUOTE_MSG
, "Identifier");
632 if (has_ident
== TRUE
)
633 Error (MULTIPLE_MSG
, "Identifier");
634 ptr
->modes_identifier
= val
.str
;
638 HANDLE_LIST (mon_modeline_lst
, xf86parseVerboseMode
,
639 XF86ConfModeLinePtr
);
642 HANDLE_LIST (mon_modeline_lst
, xf86parseModeLine
,
643 XF86ConfModeLinePtr
);
646 xf86parseError (INVALID_KEYWORD_MSG
, xf86tokenString ());
654 Error (NO_IDENT_MSG
, NULL
);
657 printf ("Modes section parsed\n");
665 xf86printMonitorSection (FILE * cf
, XF86ConfMonitorPtr ptr
)
668 XF86ConfModeLinePtr mlptr
;
669 XF86ConfModesLinkPtr mptr
;
673 mptr
= ptr
->mon_modes_sect_lst
;
674 fprintf (cf
, "Section \"Monitor\"\n");
675 if (ptr
->mon_comment
)
676 fprintf (cf
, "%s", ptr
->mon_comment
);
677 if (ptr
->mon_identifier
)
678 fprintf (cf
, "\tIdentifier \"%s\"\n", ptr
->mon_identifier
);
680 fprintf (cf
, "\tVendorName \"%s\"\n", ptr
->mon_vendor
);
681 if (ptr
->mon_modelname
)
682 fprintf (cf
, "\tModelName \"%s\"\n", ptr
->mon_modelname
);
684 fprintf (cf
, "\tUseModes \"%s\"\n", mptr
->ml_modes_str
);
685 mptr
= mptr
->list
.next
;
688 fprintf (cf
, "\tDisplaySize %d\t%d\n",
691 if ( ptr
->mon_n_hsync
|| ptr
->mon_n_vrefresh
)
692 fprintf(cf
," ### Comment all HorizSync and VertRefresh values to use DDC:\n");
693 for (i
= 0; i
< ptr
->mon_n_hsync
; i
++)
695 fprintf (cf
, "\tHorizSync %2.1f - %2.1f\n",
696 ptr
->mon_hsync
[i
].lo
,
697 ptr
->mon_hsync
[i
].hi
);
699 for (i
= 0; i
< ptr
->mon_n_vrefresh
; i
++)
701 fprintf (cf
, "\tVertRefresh %2.1f - %2.1f\n",
702 ptr
->mon_vrefresh
[i
].lo
,
703 ptr
->mon_vrefresh
[i
].hi
);
705 if (ptr
->mon_gamma_red
) {
706 if (ptr
->mon_gamma_red
== ptr
->mon_gamma_green
707 && ptr
->mon_gamma_red
== ptr
->mon_gamma_blue
)
709 fprintf (cf
, "\tGamma %.4g\n",
712 fprintf (cf
, "\tGamma %.4g %.4g %.4g\n",
714 ptr
->mon_gamma_green
,
715 ptr
->mon_gamma_blue
);
718 for (mlptr
= ptr
->mon_modeline_lst
; mlptr
; mlptr
= mlptr
->list
.next
)
720 fprintf (cf
, "\tModeLine \"%s\" %2.1f ",
721 mlptr
->ml_identifier
, mlptr
->ml_clock
/ 1000.0);
722 fprintf (cf
, "%d %d %d %d %d %d %d %d",
723 mlptr
->ml_hdisplay
, mlptr
->ml_hsyncstart
,
724 mlptr
->ml_hsyncend
, mlptr
->ml_htotal
,
725 mlptr
->ml_vdisplay
, mlptr
->ml_vsyncstart
,
726 mlptr
->ml_vsyncend
, mlptr
->ml_vtotal
);
727 if (mlptr
->ml_flags
& XF86CONF_PHSYNC
)
728 fprintf (cf
, " +hsync");
729 if (mlptr
->ml_flags
& XF86CONF_NHSYNC
)
730 fprintf (cf
, " -hsync");
731 if (mlptr
->ml_flags
& XF86CONF_PVSYNC
)
732 fprintf (cf
, " +vsync");
733 if (mlptr
->ml_flags
& XF86CONF_NVSYNC
)
734 fprintf (cf
, " -vsync");
735 if (mlptr
->ml_flags
& XF86CONF_INTERLACE
)
736 fprintf (cf
, " interlace");
737 if (mlptr
->ml_flags
& XF86CONF_CSYNC
)
738 fprintf (cf
, " composite");
739 if (mlptr
->ml_flags
& XF86CONF_PCSYNC
)
740 fprintf (cf
, " +csync");
741 if (mlptr
->ml_flags
& XF86CONF_NCSYNC
)
742 fprintf (cf
, " -csync");
743 if (mlptr
->ml_flags
& XF86CONF_DBLSCAN
)
744 fprintf (cf
, " doublescan");
745 if (mlptr
->ml_flags
& XF86CONF_HSKEW
)
746 fprintf (cf
, " hskew %d", mlptr
->ml_hskew
);
747 if (mlptr
->ml_flags
& XF86CONF_BCAST
)
748 fprintf (cf
, " bcast");
751 xf86printOptionList(cf
, ptr
->mon_option_lst
, 1);
752 fprintf (cf
, "EndSection\n\n");
753 ptr
= ptr
->list
.next
;
758 xf86printModesSection (FILE * cf
, XF86ConfModesPtr ptr
)
760 XF86ConfModeLinePtr mlptr
;
764 fprintf (cf
, "Section \"Modes\"\n");
765 if (ptr
->modes_comment
)
766 fprintf (cf
, "%s", ptr
->modes_comment
);
767 if (ptr
->modes_identifier
)
768 fprintf (cf
, "\tIdentifier \"%s\"\n", ptr
->modes_identifier
);
769 for (mlptr
= ptr
->mon_modeline_lst
; mlptr
; mlptr
= mlptr
->list
.next
)
771 fprintf (cf
, "\tModeLine \"%s\" %2.1f ",
772 mlptr
->ml_identifier
, mlptr
->ml_clock
/ 1000.0);
773 fprintf (cf
, "%d %d %d %d %d %d %d %d",
774 mlptr
->ml_hdisplay
, mlptr
->ml_hsyncstart
,
775 mlptr
->ml_hsyncend
, mlptr
->ml_htotal
,
776 mlptr
->ml_vdisplay
, mlptr
->ml_vsyncstart
,
777 mlptr
->ml_vsyncend
, mlptr
->ml_vtotal
);
778 if (mlptr
->ml_flags
& XF86CONF_PHSYNC
)
779 fprintf (cf
, " +hsync");
780 if (mlptr
->ml_flags
& XF86CONF_NHSYNC
)
781 fprintf (cf
, " -hsync");
782 if (mlptr
->ml_flags
& XF86CONF_PVSYNC
)
783 fprintf (cf
, " +vsync");
784 if (mlptr
->ml_flags
& XF86CONF_NVSYNC
)
785 fprintf (cf
, " -vsync");
786 if (mlptr
->ml_flags
& XF86CONF_INTERLACE
)
787 fprintf (cf
, " interlace");
788 if (mlptr
->ml_flags
& XF86CONF_CSYNC
)
789 fprintf (cf
, " composite");
790 if (mlptr
->ml_flags
& XF86CONF_PCSYNC
)
791 fprintf (cf
, " +csync");
792 if (mlptr
->ml_flags
& XF86CONF_NCSYNC
)
793 fprintf (cf
, " -csync");
794 if (mlptr
->ml_flags
& XF86CONF_DBLSCAN
)
795 fprintf (cf
, " doublescan");
796 if (mlptr
->ml_flags
& XF86CONF_HSKEW
)
797 fprintf (cf
, " hskew %d", mlptr
->ml_hskew
);
798 if (mlptr
->ml_flags
& XF86CONF_VSCAN
)
799 fprintf (cf
, " vscan %d", mlptr
->ml_vscan
);
800 if (mlptr
->ml_flags
& XF86CONF_BCAST
)
801 fprintf (cf
, " bcast");
802 if (mlptr
->ml_comment
)
803 fprintf (cf
, "%s", mlptr
->ml_comment
);
807 fprintf (cf
, "EndSection\n\n");
808 ptr
= ptr
->list
.next
;
813 xf86freeMonitorList (XF86ConfMonitorPtr ptr
)
815 XF86ConfMonitorPtr prev
;
819 TestFree (ptr
->mon_identifier
);
820 TestFree (ptr
->mon_vendor
);
821 TestFree (ptr
->mon_modelname
);
822 TestFree (ptr
->mon_comment
);
823 xf86optionListFree (ptr
->mon_option_lst
);
824 xf86freeModeLineList (ptr
->mon_modeline_lst
);
826 ptr
= ptr
->list
.next
;
832 xf86freeModesList (XF86ConfModesPtr ptr
)
834 XF86ConfModesPtr prev
;
838 TestFree (ptr
->modes_identifier
);
839 TestFree (ptr
->modes_comment
);
840 xf86freeModeLineList (ptr
->mon_modeline_lst
);
842 ptr
= ptr
->list
.next
;
848 xf86findMonitor (const char *ident
, XF86ConfMonitorPtr p
)
852 if (xf86nameCompare (ident
, p
->mon_identifier
) == 0)
861 xf86findModes (const char *ident
, XF86ConfModesPtr p
)
865 if (xf86nameCompare (ident
, p
->modes_identifier
) == 0)
874 xf86findModeLine (const char *ident
, XF86ConfModeLinePtr p
)
878 if (xf86nameCompare (ident
, p
->ml_identifier
) == 0)
887 xf86validateMonitor (XF86ConfigPtr p
, XF86ConfScreenPtr screen
)
889 XF86ConfMonitorPtr monitor
= screen
->scrn_monitor
;
890 XF86ConfModesLinkPtr modeslnk
= monitor
->mon_modes_sect_lst
;
891 XF86ConfModesPtr modes
;
894 modes
= xf86findModes (modeslnk
->ml_modes_str
, p
->conf_modes_lst
);
897 xf86validationError (UNDEFINED_MODES_MSG
,
898 modeslnk
->ml_modes_str
,
899 screen
->scrn_identifier
);
902 modeslnk
->ml_modes
= modes
;
903 modeslnk
= modeslnk
->list
.next
;