Beispiel #1
0
static XF86ConfDisplayPtr
xf86parseDisplaySubSection (void)
{
	int token;
	parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec)

	ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1;
	ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1;
	ptr->disp_frameX0 = ptr->disp_frameY0 = -1;
	while ((token = xf86getToken (DisplayTab)) != ENDSUBSECTION)
	{
		switch (token)
		{
		case COMMENT:
			ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str);
			break;
		case VIEWPORT:
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (VIEWPORT_MSG, NULL);
			ptr->disp_frameX0 = val.num;
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (VIEWPORT_MSG, NULL);
			ptr->disp_frameY0 = val.num;
			break;
		case VIRTUAL:
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (VIRTUAL_MSG, NULL);
			ptr->disp_virtualX = val.num;
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (VIRTUAL_MSG, NULL);
			ptr->disp_virtualY = val.num;
			break;
		case DEPTH:
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (NUMBER_MSG, "Display");
			ptr->disp_depth = val.num;
			break;
		case BPP:
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (NUMBER_MSG, "Display");
			ptr->disp_bpp = val.num;
			break;
		case VISUAL:
			if (xf86getSubToken (&(ptr->disp_comment)) != STRING)
				Error (QUOTE_MSG, "Display");
			ptr->disp_visual = val.str;
			break;
		case WEIGHT:
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (WEIGHT_MSG, NULL);
			ptr->disp_weight.red = val.num;
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (WEIGHT_MSG, NULL);
			ptr->disp_weight.green = val.num;
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (WEIGHT_MSG, NULL);
			ptr->disp_weight.blue = val.num;
			break;
		case BLACK_TOK:
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (BLACK_MSG, NULL);
			ptr->disp_black.red = val.num;
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (BLACK_MSG, NULL);
			ptr->disp_black.green = val.num;
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (BLACK_MSG, NULL);
			ptr->disp_black.blue = val.num;
			break;
		case WHITE_TOK:
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (WHITE_MSG, NULL);
			ptr->disp_white.red = val.num;
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (WHITE_MSG, NULL);
			ptr->disp_white.green = val.num;
			if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
				Error (WHITE_MSG, NULL);
			ptr->disp_white.blue = val.num;
			break;
		case MODES:
			{
				XF86ModePtr mptr;

				while ((token = xf86getSubTokenWithTab (&(ptr->disp_comment), DisplayTab)) == STRING)
				{
					mptr = calloc (1, sizeof (XF86ModeRec));
					mptr->mode_name = val.str;
					mptr->list.next = NULL;
					ptr->disp_mode_lst = (XF86ModePtr)
						xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr);
				}
				xf86unGetToken (token);
			}
			break;
		case OPTION:
			ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst);
			break;
			
		case EOF_TOKEN:
			Error (UNEXPECTED_EOF_MSG, NULL);
			break;
		default:
			Error (INVALID_KEYWORD_MSG, xf86tokenString ());
			break;
		}
	}

#ifdef DEBUG
	printf ("Display subsection parsed\n");
#endif

	return ptr;
}
Beispiel #2
0
static XF86ConfDevicePtr
configureDeviceSection (int screennum)
{
    char identifier[16];
    OptionInfoPtr p;
    int i = 0;
    parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)

    /* Move device info to parser structure */
    sprintf(identifier, "Card%d", screennum);
    ptr->dev_identifier = strdup(identifier);
    ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
    ptr->dev_busid = DevToConfig[screennum].GDev.busID;
    ptr->dev_driver = DevToConfig[screennum].GDev.driver;
    ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac;
    for (i = 0;  (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS);  i++)
        ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
    ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
    ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
    ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase;
    ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
    ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
    ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
    for (i = 0;  (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks);  i++)
        ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i];
    ptr->dev_clocks = i;
    ptr->dev_chipid = DevToConfig[screennum].GDev.chipID;
    ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev;
    ptr->dev_irq = DevToConfig[screennum].GDev.irq;

    /* Make sure older drivers don't segv */
    if (DevToConfig[screennum].GDev.options) {
    	/* Fill in the available driver options for people to use */
	const char *descrip =
	    "        ### Available Driver options are:-\n"
	    "        ### Values: <i>: integer, <f>: float, "
			"<bool>: \"True\"/\"False\",\n"
	    "        ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n"
	    "        ### <percent>: \"<f>%\"\n"
	    "        ### [arg]: arg optional\n";
	ptr->dev_comment = strdup(descrip);
	if (ptr->dev_comment) {
    	    for (p = DevToConfig[screennum].GDev.options;
		 p->name != NULL; p++) {
		char *p_e;
		const char *prefix = "        #Option     ";
		const char *middle = " \t# ";
		const char *suffix = "\n";
		const char *opttype = optionTypeToString(p->type);
		char *optname;
		int len = strlen(ptr->dev_comment) + strlen(prefix) +
			  strlen(middle) + strlen(suffix) + 1;
		
		optname = malloc(strlen(p->name) + 2 + 1);
		if (!optname)
		    break;
		sprintf(optname, "\"%s\"", p->name);

		len += max(20, strlen(optname));
		len += strlen(opttype);

		ptr->dev_comment = realloc(ptr->dev_comment, len);
		if (!ptr->dev_comment)
		    break;
		p_e = ptr->dev_comment + strlen(ptr->dev_comment);
		sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
			opttype, suffix);
		free(optname);
	    }
    	}
    }

    return ptr;
}
Beispiel #3
0
XF86ConfDevicePtr
xf86parseDeviceSection(void)
{
    int i;
    int has_ident = FALSE;
    int token;

    parsePrologue(XF86ConfDevicePtr, XF86ConfDeviceRec)

        /* Zero is a valid value for these */
        ptr->dev_chipid = -1;
    ptr->dev_chiprev = -1;
    ptr->dev_irq = -1;
    while ((token = xf86getToken(DeviceTab)) != ENDSECTION) {
        switch (token) {
        case COMMENT:
            ptr->dev_comment = xf86addComment(ptr->dev_comment, xf86_lex_val.str);
            break;
        case IDENTIFIER:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Identifier");
            if (has_ident == TRUE)
                Error(MULTIPLE_MSG, "Identifier");
            ptr->dev_identifier = xf86_lex_val.str;
            has_ident = TRUE;
            break;
        case VENDOR:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Vendor");
            ptr->dev_vendor = xf86_lex_val.str;
            break;
        case BOARD:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Board");
            ptr->dev_board = xf86_lex_val.str;
            break;
        case CHIPSET:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Chipset");
            ptr->dev_chipset = xf86_lex_val.str;
            break;
        case CARD:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Card");
            ptr->dev_card = xf86_lex_val.str;
            break;
        case DRIVER:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Driver");
            ptr->dev_driver = xf86_lex_val.str;
            break;
        case RAMDAC:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "Ramdac");
            ptr->dev_ramdac = xf86_lex_val.str;
            break;
        case DACSPEED:
            for (i = 0; i < CONF_MAXDACSPEEDS; i++)
                ptr->dev_dacSpeeds[i] = 0;
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER) {
                Error(DACSPEED_MSG, CONF_MAXDACSPEEDS);
            }
            else {
                ptr->dev_dacSpeeds[0] = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
                for (i = 1; i < CONF_MAXDACSPEEDS; i++) {
                    if (xf86getSubToken(&(ptr->dev_comment)) == NUMBER)
                        ptr->dev_dacSpeeds[i] = (int)
                            (xf86_lex_val.realnum * 1000.0 + 0.5);
                    else {
                        xf86unGetToken(token);
                        break;
                    }
                }
            }
            break;
        case VIDEORAM:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "VideoRam");
            ptr->dev_videoram = xf86_lex_val.num;
            break;
        case BIOSBASE:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "BIOSBase");
            ptr->dev_bios_base = xf86_lex_val.num;
            break;
        case MEMBASE:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "MemBase");
            ptr->dev_mem_base = xf86_lex_val.num;
            break;
        case IOBASE:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "IOBase");
            ptr->dev_io_base = xf86_lex_val.num;
            break;
        case CLOCKCHIP:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "ClockChip");
            ptr->dev_clockchip = xf86_lex_val.str;
            break;
        case CHIPID:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "ChipID");
            ptr->dev_chipid = xf86_lex_val.num;
            break;
        case CHIPREV:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "ChipRev");
            ptr->dev_chiprev = xf86_lex_val.num;
            break;

        case CLOCKS:
            token = xf86getSubToken(&(ptr->dev_comment));
            for (i = ptr->dev_clocks;
                 token == NUMBER && i < CONF_MAXCLOCKS; i++) {
                ptr->dev_clock[i] = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
                token = xf86getSubToken(&(ptr->dev_comment));
            }
            ptr->dev_clocks = i;
            xf86unGetToken(token);
            break;
        case MATCHSEAT:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "MatchSeat");
            ptr->match_seat = xf86_lex_val.str;
            break;
        case OPTION:
            ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
            break;
        case BUSID:
            if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                Error(QUOTE_MSG, "BusID");
            ptr->dev_busid = xf86_lex_val.str;
            break;
        case IRQ:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(QUOTE_MSG, "IRQ");
            ptr->dev_irq = xf86_lex_val.num;
            break;
        case SCREEN:
            if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
                Error(NUMBER_MSG, "Screen");
            ptr->dev_screen = xf86_lex_val.num;
            break;
        case EOF_TOKEN:
            Error(UNEXPECTED_EOF_MSG);
            break;
        default:
            Error(INVALID_KEYWORD_MSG, xf86tokenString());
            break;
        }
    }

    if (!has_ident)
        Error(NO_IDENT_MSG);

#ifdef DEBUG
    printf("Device section parsed\n");
#endif

    return ptr;
}