diff options
author | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
commit | 3562e78743202e43aec8727005182a2558117eca (patch) | |
tree | 8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /xorg-server/hw/xfree86/utils/xorgconfig/cards.c | |
download | vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2 vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip |
Checked in the following released items:
xkeyboard-config-1.4.tar.gz
ttf-bitstream-vera-1.10.tar.gz
font-alias-1.0.1.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sony-misc-1.0.0.tar.gz
font-schumacher-misc-1.0.0.tar.gz
font-mutt-misc-1.0.0.tar.gz
font-misc-misc-1.0.0.tar.gz
font-misc-meltho-1.0.0.tar.gz
font-micro-misc-1.0.0.tar.gz
font-jis-misc-1.0.0.tar.gz
font-isas-misc-1.0.0.tar.gz
font-dec-misc-1.0.0.tar.gz
font-daewoo-misc-1.0.0.tar.gz
font-cursor-misc-1.0.0.tar.gz
font-arabic-misc-1.0.0.tar.gz
font-winitzki-cyrillic-1.0.0.tar.gz
font-misc-cyrillic-1.0.0.tar.gz
font-cronyx-cyrillic-1.0.0.tar.gz
font-screen-cyrillic-1.0.1.tar.gz
font-xfree86-type1-1.0.1.tar.gz
font-adobe-utopia-type1-1.0.1.tar.gz
font-ibm-type1-1.0.0.tar.gz
font-bitstream-type1-1.0.0.tar.gz
font-bitstream-speedo-1.0.0.tar.gz
font-bh-ttf-1.0.0.tar.gz
font-bh-type1-1.0.0.tar.gz
font-bitstream-100dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz
font-bh-100dpi-1.0.0.tar.gz
font-adobe-utopia-100dpi-1.0.1.tar.gz
font-adobe-100dpi-1.0.0.tar.gz
font-util-1.0.1.tar.gz
font-bitstream-75dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz
font-adobe-utopia-75dpi-1.0.1.tar.gz
font-bh-75dpi-1.0.0.tar.gz
bdftopcf-1.0.1.tar.gz
font-adobe-75dpi-1.0.0.tar.gz
mkfontscale-1.0.6.tar.gz
openssl-0.9.8k.tar.gz
bigreqsproto-1.0.2.tar.gz
xtrans-1.2.2.tar.gz
resourceproto-1.0.2.tar.gz
inputproto-1.4.4.tar.gz
compositeproto-0.4.tar.gz
damageproto-1.1.0.tar.gz
zlib-1.2.3.tar.gz
xkbcomp-1.0.5.tar.gz
freetype-2.3.9.tar.gz
pthreads-w32-2-8-0-release.tar.gz
pixman-0.12.0.tar.gz
kbproto-1.0.3.tar.gz
evieext-1.0.2.tar.gz
fixesproto-4.0.tar.gz
recordproto-1.13.2.tar.gz
randrproto-1.2.2.tar.gz
scrnsaverproto-1.1.0.tar.gz
renderproto-0.9.3.tar.gz
xcmiscproto-1.1.2.tar.gz
fontsproto-2.0.2.tar.gz
xextproto-7.0.3.tar.gz
xproto-7.0.14.tar.gz
libXdmcp-1.0.2.tar.gz
libxkbfile-1.0.5.tar.gz
libfontenc-1.0.4.tar.gz
libXfont-1.3.4.tar.gz
libX11-1.1.5.tar.gz
libXau-1.0.4.tar.gz
libxcb-1.1.tar.gz
xorg-server-1.5.3.tar.gz
Diffstat (limited to 'xorg-server/hw/xfree86/utils/xorgconfig/cards.c')
-rw-r--r-- | xorg-server/hw/xfree86/utils/xorgconfig/cards.c | 278 |
1 files changed, 278 insertions, 0 deletions
diff --git a/xorg-server/hw/xfree86/utils/xorgconfig/cards.c b/xorg-server/hw/xfree86/utils/xorgconfig/cards.c new file mode 100644 index 000000000..8116f0a03 --- /dev/null +++ b/xorg-server/hw/xfree86/utils/xorgconfig/cards.c @@ -0,0 +1,278 @@ +/* + * Functions to manipulate card database. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "cards.h" + +/* Some vars to make path names in texts more flexible. */ +#ifndef PROJECTROOT +# define PROJECTROOT "/usr" +#endif +#define TREEROOT PROJECTROOT +#define TREEROOTLX TREEROOT "/lib/X11" +#define TREEROOTCFG TREEROOT "/etc/X11" +#ifdef XDOCDIR +# define TREEROOTDOC XDOCDIR +#else +# define TREEROOTDOC TREEROOTLX "/doc" +#endif + +/* + * Database format: + * + * NAME <name of card> + * CHIPSET <chipset description> + * SERVER <server name> + * DRIVER <driver name> + * + * Optional keywords: + * RAMDAC <ramdac identifier> + * CLOCKCHIP <clockchip identifier> + * DACSPEED <dacspeed> + * NOCLOCKPROBE + * UNSUPPORTED + * + * SEE <name of card> refers to another card definition; parameters that + * are already defined are not overridden. + * + * <server name> is one of Mono, VGA16, SVGA, S3, Mach32, Mach8, 8514, + * P9000, AGX, W32. + * + * A useful additional keywords may be CLOCKS. + */ + + + +/* Database vars. */ + +int lastcard; + +Card card[MAX_CARDS]; + + +static int +getnextline(FILE *f, char *l) +{ + if (fgets(l, 128, f) == NULL) + return -1; + return 0; +} + +static void +appendstring(char **destp, char *src) +{ + char *newstr; + newstr = malloc(strlen(*destp) + strlen(src) + 1); + strcpy(newstr, *destp); + strcat(newstr, src); + if (strlen(*destp) > 0) + free(*destp); + *destp = newstr; +} + +int +lookupcard(char *name) { + int i; + for (i = 0; i <= lastcard; i++) + if (strcmp(name, card[i].name) == 0) + return i; + return -1; +} + +static char *s3_comment = +"# Use Option \"nolinear\" if the server doesn't start up correctly\n" +"# (this avoids the linear framebuffer probe). If that fails try\n" +"# option \"nomemaccess\".\n" +"#\n" +"# Refer to " TREEROOTDOC "/README.S3, and the XF86_S3 man page.\n"; + +static char *cirrus_comment = +"# Use Option \"no_bitblt\" if you have graphics problems. If that fails\n" +"# try Option \"noaccel\".\n" +"# Refer to " TREEROOTDOC "/README.cirrus.\n" +"# To allow linear addressing, uncomment the Option line and the\n" +"# address that the card maps the framebuffer to.\n"; + +int parse_database() { + FILE *f; + char buf[128]; + int i, lineno; + char filename[128]; + + strcpy(filename, CARD_DATABASE_FILE); + f = fopen(filename, "r"); + if (f == NULL) + return -1; + + lastcard = -1; + lineno = 0; + + for (;;) { + if (getnextline(f, buf)) + break; + lineno++; + if (buf[0] == '#') + /* Comment. */ + continue; + if (strncmp(buf, "END", 3) == 0) + /* End of database. */ + break; + if (strncmp(buf, "LINE", 4) == 0 && lastcard>=0) { + /* Line of Device comment. */ + /* Append to existing lines. */ + appendstring(&card[lastcard].lines, buf + 5); + continue; + } + /* + * The following keywords require the trailing newline + * to be deleted. + */ + i = strlen(buf); + buf[--i] = '\0'; + + /* remove trailing spaces or tabs */ + for(--i; i>=0 && (buf[i] == ' ' || buf[i] == '\011'); i--) ; + if (i>=0) + buf[i+1] = '\0'; + else + continue; /* skip empty lines */ + + if (strncmp(buf, "NAME", 4) == 0) { + /* New entry. */ + lastcard++; + card[lastcard].name = malloc(strlen(buf + 5) + 1); + strcpy(card[lastcard].name, buf + 5); + card[lastcard].chipset = NULL; + card[lastcard].server = NULL; + card[lastcard].driver = NULL; + card[lastcard].ramdac = NULL; + card[lastcard].clockchip = NULL; + card[lastcard].dacspeed = NULL; + card[lastcard].flags = 0; + card[lastcard].lines = ""; + continue; + } + if (lastcard < 0) /* no NAME line found yet */ + continue; + if (strncmp(buf, "SEE", 3) == 0) { + /* Reference to another entry. */ + int i; + i = lookupcard(buf + 4); + if (i == -1) { + printf("Error in database, invalid reference: %s.\n", + buf + 4); + free(card[lastcard].name); + lastcard--; + continue; + } + if (card[lastcard].chipset == NULL) + card[lastcard].chipset = card[i].chipset; + if (card[lastcard].server == NULL) + card[lastcard].server = card[i].server; + if (card[lastcard].driver == NULL) + card[lastcard].driver = card[i].driver; + if (card[lastcard].ramdac == NULL) + card[lastcard].ramdac = card[i].ramdac; + if (card[lastcard].clockchip == NULL) + card[lastcard].clockchip = card[i].clockchip; + if (card[lastcard].dacspeed == NULL) + card[lastcard].dacspeed = card[i].dacspeed; + card[lastcard].flags |= card[i].flags; + appendstring(&card[lastcard].lines, card[i].lines); + continue; + } + if (strncmp(buf, "CHIPSET", 7) == 0) { + /* Chipset description. */ + card[lastcard].chipset = malloc(strlen(buf + 8) + 1); + strcpy(card[lastcard].chipset, buf + 8); + continue; + } + if (strncmp(buf, "SERVER", 6) == 0) { + /* Server identifier. */ + card[lastcard].server = malloc(strlen(buf + 7) + 1); + strcpy(card[lastcard].server, buf + 7); + continue; + } + if (strncmp(buf, "DRIVER", 6) == 0) { + /* Driver identifier. */ + card[lastcard].driver = malloc(strlen(buf + 7) + 1); + strcpy(card[lastcard].driver, buf + 7); + continue; + } + if (strncmp(buf, "RAMDAC", 6) == 0) { + /* Ramdac indentifier. */ + card[lastcard].ramdac = malloc(strlen(buf + 7) + 1); + strcpy(card[lastcard].ramdac, buf + 7); + continue; + } + if (strncmp(buf, "CLOCKCHIP", 9) == 0) { + /* Clockchip indentifier. */ + card[lastcard].clockchip = malloc(strlen(buf + 10) + 1); + strcpy(card[lastcard].clockchip, buf + 10); + card[lastcard].flags |= NOCLOCKPROBE; + continue; + } + if (strncmp(buf, "DACSPEED", 8) == 0) { + /* Clockchip indentifier. */ + card[lastcard].dacspeed = malloc(strlen(buf + 9) + 1); + strcpy(card[lastcard].dacspeed, buf + 9); + continue; + } + if (strncmp(buf, "NOCLOCKPROBE", 12) == 0) { + card[lastcard].flags |= NOCLOCKPROBE; + continue; + } + if (strncmp(buf, "UNSUPPORTED", 12) == 0) { + card[lastcard].flags |= UNSUPPORTED; + continue; + } + /* test for missing required fields */ + if (card[lastcard].driver == NULL) { + fprintf(stderr, "Warning DRIVER specification missing " + "in Card database entry %s (line %d).\n", + card[lastcard].name, lineno); + keypress(); + card[lastcard].driver = "unknown"; + } + if (card[lastcard].chipset == NULL) { + fprintf(stderr, "Warning CHIPSET specification missing " + "in Card database entry %s (line %d).\n", + card[lastcard].name, lineno); + keypress(); + card[lastcard].chipset = "unknown"; + } + } + + fclose(f); + + /* + * Add general comments. + */ + for (i = 0; i <= lastcard; i++) { + if (card[i].server && strcmp(card[i].server, "S3") == 0) + appendstring(&card[i].lines, s3_comment); + if (card[i].chipset && + strncmp(card[i].chipset, "CL-GD", 5) == 0) + appendstring(&card[i].lines, cirrus_comment); + } + + sort_database(); + + return 0; +} + +static int +compare_card(const void *e1, const void *e2) +{ + return strcmp(((Card *)e1)->name, ((Card *)e2)->name); +} + +void +sort_database() { + /* Each element is a bunch of words, but nothing too bad. */ + qsort(card, lastcard + 1, sizeof(Card), compare_card); +} |