1117N/A/*
1117N/A *
1117N/A * Copyright (c) 1997 Metro Link Incorporated
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining a
1117N/A * copy of this software and associated documentation files (the "Software"),
1117N/A * to deal in the Software without restriction, including without limitation
1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1117N/A * and/or sell copies of the Software, and to permit persons to whom the
1117N/A * Software is furnished to do so, subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice shall be included in
1117N/A * all copies or substantial portions of the Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1117N/A * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1117N/A * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
1117N/A * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1117N/A * SOFTWARE.
1117N/A *
1117N/A * Except as contained in this notice, the name of the Metro Link shall not be
1117N/A * used in advertising or otherwise to promote the sale, use or other dealings
1117N/A * in this Software without prior written authorization from Metro Link.
1117N/A *
1117N/A */
1117N/A/*
1117N/A * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining a
1117N/A * copy of this software and associated documentation files (the "Software"),
1117N/A * to deal in the Software without restriction, including without limitation
1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1117N/A * and/or sell copies of the Software, and to permit persons to whom the
1117N/A * Software is furnished to do so, subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice shall be included in
1117N/A * all copies or substantial portions of the Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1117N/A * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1117N/A * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1117N/A * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1117N/A * OTHER DEALINGS IN THE SOFTWARE.
1117N/A *
1117N/A * Except as contained in this notice, the name of the copyright holder(s)
1117N/A * and author(s) shall not be used in advertising or otherwise to promote
1117N/A * the sale, use or other dealings in this Software without prior written
1117N/A * authorization from the copyright holder(s) and author(s).
1117N/A */
1117N/A
1117N/A/* View/edit this file with tab stops set to 4 */
1117N/A
1117N/A#ifdef HAVE_XORG_CONFIG_H
1117N/A#include <xorg-config.h>
1117N/A#endif
1117N/A
1117N/A#include "xf86Parser.h"
1117N/A#include "xf86tokens.h"
1117N/A#include "Configint.h"
1117N/A#include "fields.h" /* Config file output line fields */
1117N/A
1117N/A#if defined(SMI_FBCONFIG)
1117N/A#include "fbc_line_er.h" /* External Representation of config lines */
1117N/A#endif
1117N/A
1117N/Aextern LexRec val;
1117N/A
1117N/Astatic xf86ConfigSymTabRec DisplayTab[] =
1117N/A{
1117N/A {ENDSUBSECTION, "endsubsection"},
1117N/A {MODES, "modes"},
1117N/A {VIEWPORT, "viewport"},
1117N/A {VIRTUAL, "virtual"},
1117N/A {VISUAL, "visual"},
1117N/A {BLACK_TOK, "black"},
1117N/A {WHITE_TOK, "white"},
1117N/A {MONITOR, "monitor"},
1117N/A {DEPTH, "depth"},
1117N/A {BPP, "fbbpp"},
1117N/A {WEIGHT, "weight"},
1117N/A {OPTION, "option"},
1117N/A {-1, ""},
1117N/A};
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86parseScrnMonitor()
1117N/A *
1117N/A * Parse the Monitor entry line of a Screen section. Return a
1117N/A * pointer to the diagnostic message text in the event of an error.
1117N/A */
1117N/Astatic
1117N/Achar *
1117N/Axf86parseScrnMonitor(
1117N/A XF86ConfScreenPtr ptr) /* Ptr to Screen section structure */
1117N/A{
1117N/A XF86ConfScrnMonitorEntryRec mon_entry; /* Temp Monitor entry element */
1117N/A XF86ConfScrnMonitorEntryPtr mon_ptr; /* Ptr to Monitor list element */
1117N/A int token; /* Monitor entry token ID */
1117N/A
1117N/A /*
1117N/A * Look for the optional monitor number token
1117N/A */
1117N/A mon_entry.scrn_monitor_num_seen = FALSE;
1117N/A mon_entry.scrn_monitor_num = 0;
1117N/A token = xf86getSubToken(&(ptr->scrn_comment));
1117N/A if (token == NUMBER) {
1117N/A mon_entry.scrn_monitor_num_seen = TRUE;
1117N/A mon_entry.scrn_monitor_num = val.num;
1117N/A token = xf86getSubToken(&(ptr->scrn_comment));
1117N/A }
1117N/A
1117N/A /*
1117N/A * Look for the monitor name string token
1117N/A */
1117N/A if (token != STRING) {
1117N/A /* Monitor entry syntax error */
1117N/A return (MONITOR_SYNTAX_MSG);
1117N/A }
1117N/A mon_entry.scrn_monitor_name = val.str;
1117N/A
1117N/A /*
1117N/A * Don't allow:
1117N/A * * Monitor numbers to be omitted when there are muliple
1117N/A * Monitor entries
1117N/A * * Duplicate Monitor numbers
1117N/A * * Duplicate Monitor names
1117N/A */
1117N/A for (mon_ptr = ptr->scrn_monitor_lst;
1117N/A mon_ptr != NULL;
1117N/A mon_ptr = (XF86ConfScrnMonitorEntryPtr)mon_ptr->list.next) {
1117N/A
1117N/A if (!mon_entry.scrn_monitor_num_seen ||
1117N/A !mon_ptr->scrn_monitor_num_seen) {
1117N/A /* Missing monitor number */
1117N/A return (MONITOR_NUM_REQUIRED_MSG);
1117N/A }
1117N/A if (mon_entry.scrn_monitor_num ==
1117N/A mon_ptr->scrn_monitor_num) {
1117N/A /* Duplicate monitor number */
1117N/A return (MONITOR_DUP_NUM_MSG);
1117N/A }
1117N/A if (xf86nameCompare(mon_entry.scrn_monitor_name,
1117N/A mon_ptr->scrn_monitor_name) == 0) {
1117N/A /* Duplicate monitor name */
1117N/A return (MONITOR_DUP_NAME_MSG);
1117N/A }
1117N/A }
1117N/A
1117N/A /*
1117N/A * Append the new Monitor entry element to the list
1117N/A */
1117N/A mon_ptr = xf86confcalloc(1, sizeof (XF86ConfScrnMonitorEntryRec));
1117N/A if (mon_ptr == NULL) {
1117N/A /* Insufficient memory */
1117N/A return (NO_MEMORY_MSG);
1117N/A }
1117N/A mon_ptr->list.next = NULL;
1117N/A mon_ptr->scrn_monitor_num_seen = mon_entry.scrn_monitor_num_seen;
1117N/A mon_ptr->scrn_monitor_num = mon_entry.scrn_monitor_num;
1117N/A mon_ptr->scrn_monitor_name = mon_entry.scrn_monitor_name;
1117N/A mon_ptr->scrn_monitor = NULL;
1117N/A ptr->scrn_monitor_lst = (XF86ConfScrnMonitorEntryPtr)xf86addListItem(
1117N/A (glp)ptr->scrn_monitor_lst,
1117N/A (glp)mon_ptr);
1117N/A
1117N/A /*
1117N/A * Return successfully
1117N/A */
1117N/A return (NULL);
1117N/A
1117N/A}
1117N/A
1117N/A
1117N/A#define CLEANUP xf86freeDisplayList
1117N/A
1117N/AXF86ConfDisplayPtr
1117N/Axf86parseDisplaySubSection (void)
1117N/A{
1117N/A int token;
1117N/A#if defined(SMI_FBCONFIG)
1117N/A void *line_er; /* Ptr to Extnl Rep of config file line */
1117N/A#endif
1117N/A parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec)
1117N/A
1117N/A ptr->disp_monitor_seen = FALSE;
1117N/A
1117N/A ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1;
1117N/A ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1;
1117N/A ptr->disp_frameX0 = ptr->disp_frameY0 = -1;
1117N/A for (;;)
1117N/A {
1117N/A token = xf86getToken(DisplayTab);
1117N/A
1117N/A#if defined(SMI_FBCONFIG)
1117N/A /*
1117N/A * Get a ptr to the External Representation of this config line
1117N/A */
1117N/A line_er = fbc_get_current_line_ER();
1117N/A
1117N/A#endif
1117N/A if (token == ENDSUBSECTION)
1117N/A {
1117N/A break;
1117N/A }
1117N/A switch (token)
1117N/A {
1117N/A case COMMENT:
1117N/A ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str);
1117N/A break;
1117N/A case VIEWPORT:
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (VIEWPORT_MSG, NULL);
1117N/A ptr->disp_frameX0 = val.num;
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (VIEWPORT_MSG, NULL);
1117N/A ptr->disp_frameY0 = val.num;
1117N/A break;
1117N/A case VIRTUAL:
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (VIRTUAL_MSG, NULL);
1117N/A ptr->disp_virtualX = val.num;
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (VIRTUAL_MSG, NULL);
1117N/A ptr->disp_virtualY = val.num;
1117N/A break;
1117N/A case MONITOR:
1117N/A if (ptr->disp_monitor_seen ||
1117N/A (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)) {
1117N/A Error (NUMBER_MSG, "Display");
1117N/A }
1117N/A ptr->disp_monitor_seen = TRUE;
1117N/A ptr->disp_monitor_num = val.num;
1117N/A break;
1117N/A case DEPTH:
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (NUMBER_MSG, "Display");
1117N/A ptr->disp_depth = val.num;
1117N/A break;
1117N/A case BPP:
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (NUMBER_MSG, "Display");
1117N/A ptr->disp_bpp = val.num;
1117N/A break;
1117N/A case VISUAL:
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "Display");
1117N/A ptr->disp_visual = val.str;
1117N/A break;
1117N/A case WEIGHT:
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (WEIGHT_MSG, NULL);
1117N/A ptr->disp_weight.red = val.num;
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (WEIGHT_MSG, NULL);
1117N/A ptr->disp_weight.green = val.num;
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (WEIGHT_MSG, NULL);
1117N/A ptr->disp_weight.blue = val.num;
1117N/A break;
1117N/A case BLACK_TOK:
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (BLACK_MSG, NULL);
1117N/A ptr->disp_black.red = val.num;
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (BLACK_MSG, NULL);
1117N/A ptr->disp_black.green = val.num;
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (BLACK_MSG, NULL);
1117N/A ptr->disp_black.blue = val.num;
1117N/A break;
1117N/A case WHITE_TOK:
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (WHITE_MSG, NULL);
1117N/A ptr->disp_white.red = val.num;
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (WHITE_MSG, NULL);
1117N/A ptr->disp_white.green = val.num;
1117N/A if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
1117N/A Error (WHITE_MSG, NULL);
1117N/A ptr->disp_white.blue = val.num;
1117N/A break;
1117N/A case MODES:
1117N/A {
1117N/A XF86ModePtr mptr;
1117N/A
1117N/A while ((token = xf86getSubTokenWithTab (&(ptr->disp_comment), DisplayTab)) == STRING)
1117N/A {
1117N/A mptr = xf86confcalloc (1, sizeof (XF86ModeRec));
1117N/A mptr->mode_name = val.str;
1117N/A mptr->list.next = NULL;
1117N/A ptr->disp_mode_lst = (XF86ModePtr)
1117N/A xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr);
1117N/A }
1117N/A xf86unGetToken (token);
1117N/A }
1117N/A#if defined(SMI_FBCONFIG)
1117N/A /*
1117N/A * Link Internal & External Representations of the line
1117N/A */
1117N/A ptr->disp_modes_line_er = line_er;
1117N/A fbc_link_line_ER(line_er,
1117N/A (void *)ptr,
1117N/A (xf86_print_fn_t *)&xf86printDisplaySubsectionModes,
1117N/A FBC_INDENT_2);
1117N/A#endif
1117N/A break;
1117N/A case OPTION:
1117N/A ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst);
1117N/A break;
1117N/A
1117N/A case EOF_TOKEN:
1117N/A Error (UNEXPECTED_EOF_MSG, NULL);
1117N/A break;
1117N/A default:
1117N/A Error (INVALID_KEYWORD_MSG, xf86tokenString ());
1117N/A break;
1117N/A }
1117N/A }
1117N/A
1117N/A#if defined(SMI_FBCONFIG)
1117N/A /*
1117N/A * Link Internal & External Representations of the EndSubSection line
1117N/A */
1117N/A ptr->disp_end_line_er = line_er;
1117N/A fbc_link_line_ER(line_er,
1117N/A (void *)ptr,
1117N/A (xf86_print_fn_t *)&xf86printDisplaySubsectionEndSubsection,
1117N/A FBC_INDENT_1);
1117N/A
1117N/A#endif
1117N/A#ifdef DEBUG
1117N/A printf ("Display subsection parsed\n");
1117N/A#endif
1117N/A
1117N/A return ptr;
1117N/A}
1117N/A
1117N/A#undef CLEANUP
1117N/A
1117N/Astatic xf86ConfigSymTabRec ScreenTab[] =
1117N/A{
1117N/A {ENDSECTION, "endsection"},
1117N/A {IDENTIFIER, "identifier"},
1117N/A {OBSDRIVER, "driver"},
1117N/A {MDEVICE, "device"},
1117N/A {MONITOR, "monitor"},
1117N/A {VIDEOADAPTOR, "videoadaptor"},
1117N/A {SCREENNO, "screenno"},
1117N/A {SUBSECTION, "subsection"},
1117N/A {DEFAULTDEPTH, "defaultcolordepth"},
1117N/A {DEFAULTDEPTH, "defaultdepth"},
1117N/A {DEFAULTBPP, "defaultbpp"},
1117N/A {DEFAULTFBBPP, "defaultfbbpp"},
1117N/A {OPTION, "option"},
1117N/A {-1, ""},
1117N/A};
1117N/A
1117N/A#define CLEANUP xf86freeScreenList
1117N/AXF86ConfScreenPtr
1117N/Axf86parseScreenSection (void)
1117N/A{
1117N/A int has_ident = FALSE;
1117N/A int has_driver= FALSE;
1117N/A int token;
1117N/A#if defined(SMI_FBCONFIG)
1117N/A void *line_er; /* Ptr to Extnl Rep of config file line */
1117N/A#endif
1117N/A parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
1117N/A
1117N/A for (;;)
1117N/A {
1117N/A token = xf86getToken(ScreenTab);
1117N/A#if defined(SMI_FBCONFIG)
1117N/A /*
1117N/A * Get a ptr to the External Representation of this config line
1117N/A */
1117N/A line_er = fbc_get_current_line_ER();
1117N/A
1117N/A#endif
1117N/A if (token == ENDSECTION)
1117N/A {
1117N/A break;
1117N/A }
1117N/A switch (token)
1117N/A {
1117N/A case COMMENT:
1117N/A ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str);
1117N/A break;
1117N/A case IDENTIFIER:
1117N/A if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "Identifier");
1117N/A ptr->scrn_identifier = val.str;
1117N/A if (has_ident || has_driver)
1117N/A Error (ONLY_ONE_MSG,"Identifier or Driver");
1117N/A has_ident = TRUE;
1117N/A break;
1117N/A case OBSDRIVER:
1117N/A if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "Driver");
1117N/A ptr->scrn_obso_driver = val.str;
1117N/A if (has_ident || has_driver)
1117N/A Error (ONLY_ONE_MSG,"Identifier or Driver");
1117N/A has_driver = TRUE;
1117N/A break;
1117N/A case DEFAULTDEPTH:
1117N/A if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
1117N/A Error (NUMBER_MSG, "DefaultDepth");
1117N/A ptr->scrn_defaultdepth = val.num;
1117N/A#if defined(SMI_FBCONFIG)
1117N/A /*
1117N/A * Link Internal & External Representations of the line
1117N/A */
1117N/A ptr->scrn_defaultdepth_line_er = line_er;
1117N/A fbc_link_line_ER(line_er,
1117N/A (void *)ptr,
1117N/A (xf86_print_fn_t *)&xf86printScreenSectionDefaultDepth,
1117N/A FBC_INDENT_1);
1117N/A#endif
1117N/A break;
1117N/A case DEFAULTBPP:
1117N/A if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
1117N/A Error (NUMBER_MSG, "DefaultBPP");
1117N/A ptr->scrn_defaultbpp = val.num;
1117N/A break;
1117N/A case DEFAULTFBBPP:
1117N/A if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
1117N/A Error (NUMBER_MSG, "DefaultFbBPP");
1117N/A ptr->scrn_defaultfbbpp = val.num;
1117N/A break;
1117N/A case MDEVICE:
1117N/A if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "Device");
1117N/A if (ptr->scrn_device_str != NULL) {
1117N/A Error (MULTIPLE_MSG, "Device");
1117N/A }
1117N/A ptr->scrn_device_str = val.str;
1117N/A break;
1117N/A case MONITOR:
1117N/A {
1117N/A char *error_msg;
1117N/A error_msg = xf86parseScrnMonitor(ptr);
1117N/A if (error_msg != NULL) {
1117N/A Error (error_msg, NULL);
1117N/A }
1117N/A }
1117N/A break;
1117N/A case VIDEOADAPTOR:
1117N/A {
1117N/A XF86ConfAdaptorLinkPtr aptr;
1117N/A
1117N/A if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "VideoAdaptor");
1117N/A
1117N/A /* Don't allow duplicates */
1117N/A for (aptr = ptr->scrn_adaptor_lst; aptr;
1117N/A aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next)
1117N/A if (xf86nameCompare (val.str, aptr->al_adaptor_str) == 0)
1117N/A break;
1117N/A
1117N/A if (aptr == NULL)
1117N/A {
1117N/A aptr = xf86confcalloc (1, sizeof (XF86ConfAdaptorLinkRec));
1117N/A aptr->list.next = NULL;
1117N/A aptr->al_adaptor_str = val.str;
1117N/A ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr)
1117N/A xf86addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr);
1117N/A }
1117N/A }
1117N/A break;
1117N/A case OPTION:
1117N/A ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst);
1117N/A break;
1117N/A case SUBSECTION:
1117N/A if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "SubSection");
1117N/A {
1117N/A xf86conffree(val.str);
1117N/A HANDLE_LIST (scrn_display_lst, xf86parseDisplaySubSection,
1117N/A XF86ConfDisplayPtr);
1117N/A }
1117N/A break;
1117N/A case EOF_TOKEN:
1117N/A Error (UNEXPECTED_EOF_MSG, NULL);
1117N/A break;
1117N/A default:
1117N/A Error (INVALID_KEYWORD_MSG, xf86tokenString ());
1117N/A break;
1117N/A }
1117N/A }
1117N/A
1117N/A#if defined(SMI_FBCONFIG)
1117N/A /*
1117N/A * Link Internal & External Representations of the EndSection line
1117N/A */
1117N/A ptr->scrn_end_line_er = line_er;
1117N/A fbc_link_line_ER(line_er,
1117N/A (void *)ptr,
1117N/A (xf86_print_fn_t *)&xf86printScreenSectionEndSection,
1117N/A FBC_INDENT_0);
1117N/A
1117N/A#endif
1117N/A if (!has_ident && !has_driver)
1117N/A Error (NO_IDENT_MSG, NULL);
1117N/A
1117N/A#ifdef DEBUG
1117N/A printf ("Screen section parsed\n");
1117N/A#endif
1117N/A
1117N/A return ptr;
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printDisplaySubsectionSubsection()
1117N/A *
1117N/A * Write the Display subsection Subsection line to the configuration
1117N/A * file.
1117N/A */
1117N/Avoid
1117N/Axf86printDisplaySubsectionSubsection(
1117N/A FILE *cf, /* Config file output stream */
1117N/A XF86ConfDisplayPtr dptr, /* Ptr to Display subsection */
1117N/A const char *const whitespace[])
1117N/A{
1117N/A fprintf(cf, "\tSubsection \"Display\"\n");
1117N/A if (dptr->disp_comment != NULL) {
1117N/A fprintf(cf, "%s", dptr->disp_comment);
1117N/A }
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printDisplaySubectionMonitor()
1117N/A *
1117N/A * Write a Display subsection Monitor entry line to the configuration
1117N/A * file.
1117N/A */
1117N/Avoid
1117N/Axf86printDisplaySubsectionMonitor(
1117N/A FILE *cf, /* Config file output stream */
1117N/A XF86ConfDisplayPtr dptr, /* Ptr to Display subsection */
1117N/A const char *const whitespace[])
1117N/A{
1117N/A xf86printFields(cf, whitespace, "Monitor", NULL);
1117N/A fprintf(cf, "%d\n", dptr->disp_monitor_num);
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printDisplaySubsectionModes()
1117N/A *
1117N/A * Write the Modes line of a Display subsection of a Screen section
1117N/A * to the configuration file.
1117N/A */
1117N/Avoid
1117N/Axf86printDisplaySubsectionModes(
1117N/A FILE *cf, /* Config file output stream */
1117N/A XF86ConfDisplayPtr dptr, /* Ptr to Display subsection */
1117N/A const char *const whitespace[])
1117N/A{
1117N/A XF86ModePtr mptr; /* Ptr to Modes name list element */
1117N/A const char *space; /* Ptr to "" or " " separator */
1117N/A
1117N/A xf86printFields(cf, whitespace, "Modes", NULL);
1117N/A space = "";
1117N/A for (mptr = dptr->disp_mode_lst; mptr != NULL; mptr = mptr->list.next)
1117N/A {
1117N/A fprintf(cf, "%s\"%s\"", space, mptr->mode_name);
1117N/A space = " ";
1117N/A }
1117N/A fprintf(cf, "\n");
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printDisplaySubsectionEndSubsection()
1117N/A *
1117N/A * Write the Display subsection EndSubsection line to the
1117N/A * configuration file.
1117N/A */
1117N/Avoid
1117N/Axf86printDisplaySubsectionEndSubsection(
1117N/A FILE *cf, /* Config file output stream */
1117N/A XF86ConfDisplayPtr dptr, /* Ptr to Display subsection */
1117N/A const char *const whitespace[])
1117N/A{
1117N/A//??? xf86printFields(cf, whitespace, "EndSubsection\n", NULL);
1117N/A fprintf (cf, "\tEndSubsection\n");
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printScreenSectionSection()
1117N/A *
1117N/A * Write the Screen section Section line to the configuration file.
1117N/A */
1117N/Avoid
1117N/Axf86printScreenSectionSection(
1117N/A FILE * cf, XF86ConfScreenPtr ptr, const char *const whitespace[])
1117N/A{
1117N/A fprintf (cf, "Section \"Screen\"\n");
1117N/A if (ptr->scrn_comment != NULL) {
1117N/A fprintf(cf, "%s", ptr->scrn_comment);
1117N/A }
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printScreenSectionIdentifier()
1117N/A *
1117N/A * Write the Screen section Identifier line to the configuration
1117N/A * file.
1117N/A */
1117N/Avoid
1117N/Axf86printScreenSectionIdentifier(
1117N/A FILE * cf, XF86ConfScreenPtr ptr, const char *const whitespace[])
1117N/A{
1117N/A/*???*/ xf86printFields(cf, whitespace, "Identifier", NULL);
1117N/A fprintf(cf, "\"%s\"\n", ptr->scrn_identifier);
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printScreenSectionDevice()
1117N/A *
1117N/A * Write the Screen section Device entry line to the configuration
1117N/A * file.
1117N/A */
1117N/Avoid
1117N/Axf86printScreenSectionDevice(
1117N/A FILE * cf, XF86ConfScreenPtr ptr, const char *const whitespace[])
1117N/A{
1117N/A xf86printFields(cf, whitespace, "Device", NULL);
1117N/A fprintf(cf, "\"%s\"\n", ptr->scrn_device_str);
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printScreenSectionMonitor()
1117N/A *
1117N/A * Write a Screen section Monitor entry line to the configuration
1117N/A * file.
1117N/A */
1117N/Avoid
1117N/Axf86printScreenSectionMonitor(
1117N/A FILE * cf, /* Config file output stream */
1117N/A XF86ConfScrnMonitorEntryPtr mon_ptr, /* Ptr to Monitor entry */
1117N/A const char *const whitespace[])
1117N/A{
1117N/A char monitor_field[64]; /* "Monitor[ <num>]" */
1117N/A
1117N/A sprintf(monitor_field,
1117N/A (mon_ptr->scrn_monitor_num_seen) ? "Monitor %d" : "Monitor",
1117N/A mon_ptr->scrn_monitor_num);
1117N/A xf86printFields(cf, whitespace, monitor_field, NULL);
1117N/A fprintf(cf, "\"%s\"\n", mon_ptr->scrn_monitor_name);
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printScreenSectionDefaultDepth()
1117N/A *
1117N/A * Write a Screen section DefaultDepth entry to the configuration
1117N/A * file.
1117N/A */
1117N/Avoid
1117N/Axf86printScreenSectionDefaultDepth(
1117N/A FILE * cf, XF86ConfScreenPtr ptr, const char *const whitespace[])
1117N/A{
1117N/A xf86printFields(cf, whitespace, "DefaultDepth", NULL);
1117N/A fprintf(cf, "%d\n", ptr->scrn_defaultdepth);
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printScreenSectionEndSection()
1117N/A *
1117N/A * Write the Screen section EndSection line to the configuration
1117N/A * file.
1117N/A */
1117N/Avoid
1117N/Axf86printScreenSectionEndSection(
1117N/A FILE * cf, XF86ConfScreenPtr ptr, const char *const whitespace[])
1117N/A{
1117N/A fprintf (cf, "EndSection\n");
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86printScreenSection()
1117N/A *
1117N/A * Write a Screen section to the configuration file.
1117N/A */
1117N/Avoid
1117N/Axf86printScreenSection (FILE * cf, XF86ConfScreenPtr ptr)
1117N/A{
1117N/A XF86ConfAdaptorLinkPtr aptr;
1117N/A XF86ConfDisplayPtr dptr;
1117N/A XF86ConfScrnMonitorEntryPtr mon_ptr; /* Ptr to a Monitor element */
1117N/A
1117N/A while (ptr)
1117N/A {
1117N/A xf86printScreenSectionSection(cf, ptr, xf86whitespace_0);
1117N/A if (ptr->scrn_identifier) {
1117N/A xf86printScreenSectionIdentifier(
1117N/A cf, ptr, xf86whitespace_1);
1117N/A }
1117N/A if (ptr->scrn_obso_driver)
1117N/A fprintf (cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver);
1117N/A if (ptr->scrn_device_str) {
1117N/A xf86printScreenSectionDevice(
1117N/A cf, ptr, xf86whitespace_1);
1117N/A }
1117N/A for (mon_ptr = ptr->scrn_monitor_lst;
1117N/A mon_ptr != NULL;
1117N/A mon_ptr = (XF86ConfScrnMonitorEntryPtr)mon_ptr->list.next) {
1117N/A xf86printScreenSectionMonitor(cf, mon_ptr, xf86whitespace_1);
1117N/A }
1117N/A if (ptr->scrn_defaultdepth)
1117N/A xf86printScreenSectionDefaultDepth(cf, ptr, xf86whitespace_1);
1117N/A if (ptr->scrn_defaultbpp)
1117N/A fprintf (cf, "\tDefaultBPP %d\n",
1117N/A ptr->scrn_defaultbpp);
1117N/A if (ptr->scrn_defaultfbbpp)
1117N/A fprintf (cf, "\tDefaultFbBPP %d\n",
1117N/A ptr->scrn_defaultfbbpp);
1117N/A xf86printOptionList(cf, ptr->scrn_option_lst, xf86whitespace_1);
1117N/A for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = aptr->list.next)
1117N/A {
1117N/A fprintf (cf, "\tVideoAdaptor \"%s\"\n", aptr->al_adaptor_str);
1117N/A }
1117N/A
1117N/A /*
1117N/A * Write each Display subsection to the configuration file
1117N/A */
1117N/A for (dptr = ptr->scrn_display_lst; dptr; dptr = dptr->list.next)
1117N/A {
1117N/A xf86printDisplaySubsectionSubsection(cf, dptr, xf86whitespace_1);
1117N/A if (dptr->disp_monitor_seen) {
1117N/A xf86printDisplaySubsectionMonitor(cf, dptr, xf86whitespace_1);
1117N/A }
1117N/A
1117N/A if (dptr->disp_frameX0 >= 0 || dptr->disp_frameY0 >= 0)
1117N/A {
1117N/A fprintf (cf, "\t\tViewport %d %d\n",
1117N/A dptr->disp_frameX0, dptr->disp_frameY0);
1117N/A }
1117N/A if (dptr->disp_virtualX != 0 || dptr->disp_virtualY != 0)
1117N/A {
1117N/A fprintf (cf, "\t\tVirtual %d %d\n",
1117N/A dptr->disp_virtualX, dptr->disp_virtualY);
1117N/A }
1117N/A if (dptr->disp_depth)
1117N/A {
1117N/A fprintf (cf, "\t\tDepth %d\n", dptr->disp_depth);
1117N/A }
1117N/A if (dptr->disp_bpp)
1117N/A {
1117N/A fprintf (cf, "\t\tFbBPP %d\n", dptr->disp_bpp);
1117N/A }
1117N/A if (dptr->disp_visual)
1117N/A {
1117N/A fprintf (cf, "\t\tVisual \"%s\"\n", dptr->disp_visual);
1117N/A }
1117N/A if (dptr->disp_weight.red != 0)
1117N/A {
1117N/A fprintf (cf, "\t\tWeight %d %d %d\n",
1117N/A dptr->disp_weight.red, dptr->disp_weight.green, dptr->disp_weight.blue);
1117N/A }
1117N/A if (dptr->disp_black.red != -1)
1117N/A {
1117N/A fprintf (cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n",
1117N/A dptr->disp_black.red, dptr->disp_black.green, dptr->disp_black.blue);
1117N/A }
1117N/A if (dptr->disp_white.red != -1)
1117N/A {
1117N/A fprintf (cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n",
1117N/A dptr->disp_white.red, dptr->disp_white.green, dptr->disp_white.blue);
1117N/A }
1117N/A if (dptr->disp_mode_lst != NULL)
1117N/A {
1117N/A xf86printDisplaySubsectionModes(cf, dptr, xf86whitespace_2);
1117N/A }
1117N/A xf86printOptionList(cf, dptr->disp_option_lst, xf86whitespace_2);
1117N/A xf86printDisplaySubsectionEndSubsection(
1117N/A cf, dptr, xf86whitespace_1);
1117N/A }
1117N/A xf86printScreenSectionEndSection(cf, ptr, xf86whitespace_0);
1117N/A fprintf(cf, "\n");
1117N/A ptr = ptr->list.next;
1117N/A }
1117N/A
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86freeScrnMonitorList()
1117N/A *
1117N/A * Free the list of Monitor entries of a Screen section, and the
1117N/A * contents of each entry (i.e. Monitor section name string).
1117N/A *
1117N/A * Note that xf86conffree() (aka free()) accepts NULL pointers.
1117N/A */
1117N/Astatic
1117N/Avoid
1117N/Axf86freeScrnMonitorList(XF86ConfScrnMonitorEntryPtr mon_ptr)
1117N/A{
1117N/A XF86ConfScrnMonitorEntryPtr next_mon_ptr;
1117N/A
1117N/A for ( ; mon_ptr != NULL; mon_ptr = next_mon_ptr) {
1117N/A next_mon_ptr = mon_ptr->list.next;
1117N/A xf86conffree(mon_ptr->scrn_monitor_name);
1117N/A xf86conffree(mon_ptr);
1117N/A }
1117N/A}
1117N/A
1117N/A
1117N/A/*
1117N/A * xf86freeScreenList()
1117N/A *
1117N/A * Free the list of Screen sections, and the contents of each
1117N/A * section.
1117N/A */
1117N/Avoid
1117N/Axf86freeScreenList (XF86ConfScreenPtr ptr)
1117N/A{
1117N/A XF86ConfScreenPtr prev;
1117N/A
1117N/A while (ptr)
1117N/A {
1117N/A TestFree (ptr->scrn_identifier);
1117N/A TestFree (ptr->scrn_device_str);
1117N/A TestFree (ptr->scrn_comment);
1117N/A xf86optionListFree (ptr->scrn_option_lst);
1117N/A xf86freeScrnMonitorList(ptr->scrn_monitor_lst);
1117N/A xf86freeAdaptorLinkList (ptr->scrn_adaptor_lst);
1117N/A xf86freeDisplayList (ptr->scrn_display_lst);
1117N/A prev = ptr;
1117N/A ptr = ptr->list.next;
1117N/A xf86conffree (prev);
1117N/A }
1117N/A}
1117N/A
1117N/Avoid
1117N/Axf86freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr)
1117N/A{
1117N/A XF86ConfAdaptorLinkPtr prev;
1117N/A
1117N/A while (ptr)
1117N/A {
1117N/A TestFree (ptr->al_adaptor_str);
1117N/A prev = ptr;
1117N/A ptr = ptr->list.next;
1117N/A xf86conffree (prev);
1117N/A }
1117N/A}
1117N/A
1117N/Avoid
1117N/Axf86freeDisplayList (XF86ConfDisplayPtr ptr)
1117N/A{
1117N/A XF86ConfDisplayPtr prev;
1117N/A
1117N/A while (ptr)
1117N/A {
1117N/A xf86freeModeList (ptr->disp_mode_lst);
1117N/A xf86optionListFree (ptr->disp_option_lst);
1117N/A prev = ptr;
1117N/A ptr = ptr->list.next;
1117N/A xf86conffree (prev);
1117N/A }
1117N/A}
1117N/A
1117N/Avoid
1117N/Axf86freeModeList (XF86ModePtr ptr)
1117N/A{
1117N/A XF86ModePtr prev;
1117N/A
1117N/A while (ptr)
1117N/A {
1117N/A TestFree (ptr->mode_name);
1117N/A prev = ptr;
1117N/A ptr = ptr->list.next;
1117N/A xf86conffree (prev);
1117N/A }
1117N/A}
1117N/A
1117N/A/*
1117N/A * xf86validateScreen()
1117N/A *
1117N/A * Validate each Screen section and its subordinate sections.
1117N/A */
1117N/Aint
1117N/Axf86validateScreen (XF86ConfigPtr p)
1117N/A{
1117N/A XF86ConfScreenPtr screen = p->conf_screen_lst;
1117N/A XF86ConfScrnMonitorEntryPtr mon_ptr; /* Ptr to a Monitor entry */
1117N/A XF86ConfMonitorPtr monitor; /* Ptr to a Monitor section */
1117N/A XF86ConfDevicePtr device;
1117N/A XF86ConfAdaptorLinkPtr adaptor;
1117N/A
1117N/A#if !defined(SMI_FBCONFIG) /* Missing section will be constructed */
1117N/A if (!screen)
1117N/A {
1117N/A xf86validationError ("At least one Screen section is required.");
1117N/A return (FALSE);
1117N/A }
1117N/A
1117N/A#endif
1117N/A while (screen)
1117N/A {
1117N/A if (screen->scrn_obso_driver && !screen->scrn_identifier)
1117N/A screen->scrn_identifier = screen->scrn_obso_driver;
1117N/A
1117N/A /*
1117N/A * Process each Monitor entry in this Screen section
1117N/A */
1117N/A for (mon_ptr = screen->scrn_monitor_lst;
1117N/A mon_ptr != NULL;
1117N/A mon_ptr = (XF86ConfScrnMonitorEntryPtr)mon_ptr->list.next) {
1117N/A
1117N/A monitor = xf86findMonitor(mon_ptr->scrn_monitor_name,
1117N/A p->conf_monitor_lst);
1117N/A if (monitor == NULL) {
1117N/A xf86validationError(
1117N/A UNDEFINED_MONITOR_MSG,
1117N/A mon_ptr->scrn_monitor_name,
1117N/A screen->scrn_identifier);
1117N/A return (FALSE);
1117N/A }
1117N/A mon_ptr->scrn_monitor = monitor;
1117N/A if (!xf86validateMonitor(
1117N/A p, screen->scrn_identifier, monitor)) {
1117N/A return (FALSE);
1117N/A }
1117N/A }
1117N/A
1117N/A /*
1117N/A * Make sure the specified Device section can be found
1117N/A */
1117N/A if (screen->scrn_device_str == NULL) {
1117N/A xf86validationError(UNDEFINED_DEVICE_MSG,
1117N/A "", screen->scrn_identifier);
1117N/A return (FALSE);
1117N/A }
1117N/A device = xf86findDevice (screen->scrn_device_str, p->conf_device_lst);
1117N/A if (!device)
1117N/A {
1117N/A xf86validationError (UNDEFINED_DEVICE_MSG,
1117N/A screen->scrn_device_str, screen->scrn_identifier);
1117N/A return (FALSE);
1117N/A }
1117N/A screen->scrn_device = device;
1117N/A
1117N/A adaptor = screen->scrn_adaptor_lst;
1117N/A while (adaptor)
1117N/A {
1117N/A adaptor->al_adaptor = xf86findVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst);
1117N/A if (!adaptor->al_adaptor)
1117N/A {
1117N/A xf86validationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier);
1117N/A return (FALSE);
1117N/A }
1117N/A else if (adaptor->al_adaptor->va_fwdref)
1117N/A {
1117N/A xf86validationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str,
1117N/A adaptor->al_adaptor->va_fwdref);
1117N/A return (FALSE);
1117N/A }
1117N/A
1117N/A adaptor->al_adaptor->va_fwdref = xf86configStrdup(screen->scrn_identifier);
1117N/A adaptor = adaptor->list.next;
1117N/A }
1117N/A
1117N/A screen = screen->list.next;
1117N/A }
1117N/A
1117N/A return (TRUE);
1117N/A}
1117N/A
1117N/AXF86ConfScreenPtr
1117N/Axf86findScreen (const char *ident, XF86ConfScreenPtr p)
1117N/A{
1117N/A while (p)
1117N/A {
1117N/A if (xf86nameCompare (ident, p->scrn_identifier) == 0)
1117N/A return (p);
1117N/A
1117N/A p = p->list.next;
1117N/A }
1117N/A return (NULL);
1117N/A}
1117N/A