| 1 |
/* Xorgautoconfig: versatile xorg.conf creation tool for PowerPC
|
| 2 |
*
|
| 3 |
* Copyright (C) 2005 Lars Weiler <pylon@gentoo.org>
|
| 4 |
* Copyright (C) 2005 Joseph Jezak <josejx@gentoo.org>
|
| 5 |
*
|
| 6 |
* This xorg.conf creation tool is a fork from Xautoconfig-0.23
|
| 7 |
* (http://ftp.penguinppc.org/projects/xautocfg/)
|
| 8 |
*
|
| 9 |
* The original header-comment contained:
|
| 10 |
* Copyright (C) 2002-2004 Dan Burcaw <dan@ydl.net>
|
| 11 |
* Copyright (C) 1999-2001 Tom Rini <trini@kernel.crashing.org>
|
| 12 |
*
|
| 13 |
* Thanks for this good start for an X.Org configurator!
|
| 14 |
*
|
| 15 |
*/
|
| 16 |
|
| 17 |
#define _GNU_SOURCE
|
| 18 |
#include <stdio.h>
|
| 19 |
#include <stdlib.h>
|
| 20 |
#include <assert.h>
|
| 21 |
#include <ctype.h>
|
| 22 |
#include <signal.h>
|
| 23 |
#include <fcntl.h>
|
| 24 |
#include <string.h>
|
| 25 |
#include <unistd.h>
|
| 26 |
#include <sys/ioctl.h>
|
| 27 |
#include <sys/types.h>
|
| 28 |
#include <sys/stat.h>
|
| 29 |
#include <sys/syscall.h>
|
| 30 |
#include <sys/mman.h>
|
| 31 |
#include <netinet/in.h>
|
| 32 |
#include <linux/fb.h>
|
| 33 |
#include <byteswap.h>
|
| 34 |
#include <dirent.h>
|
| 35 |
|
| 36 |
#include "ddcprobe/common.h"
|
| 37 |
#include "ddcprobe/vesamode.h"
|
| 38 |
#include "Xorgtext.h"
|
| 39 |
|
| 40 |
extern int bus, dev, func;
|
| 41 |
extern void findVideoDevice(void);
|
| 42 |
extern void help();
|
| 43 |
extern void usage();
|
| 44 |
extern char * macMachineType(void);
|
| 45 |
|
| 46 |
struct monitor_sync
|
| 47 |
{
|
| 48 |
int h_min;
|
| 49 |
int h_max;
|
| 50 |
int v_min;
|
| 51 |
int v_max;
|
| 52 |
};
|
| 53 |
|
| 54 |
int main(int argc, char **argv) {
|
| 55 |
FILE * f;
|
| 56 |
int i, depth, fd;
|
| 57 |
int rc = 0, offb = 0, fbdepth = 0, fbdev = 0, nv = 0;
|
| 58 |
unsigned int xsstart, xsend, xtotal = 0;
|
| 59 |
unsigned int ysstart, ysend, ytotal = 0;
|
| 60 |
double drate, vrate, hrate;
|
| 61 |
unsigned int htotal, vtotal;
|
| 62 |
char manufacturer[4];
|
| 63 |
|
| 64 |
struct monitor_sync sync;
|
| 65 |
struct fb_fix_screeninfo fix;
|
| 66 |
struct fb_var_screeninfo var;
|
| 67 |
struct edid1_info *edid_info = NULL;
|
| 68 |
|
| 69 |
const char * name = "/dev/fb0";
|
| 70 |
unsigned char *mem;
|
| 71 |
char *macid;
|
| 72 |
char *eisaid;
|
| 73 |
char keyboard_layout[32];
|
| 74 |
memset(keyboard_layout, 0, 32);
|
| 75 |
|
| 76 |
DIR *testdir; /* Test if path is a directory */
|
| 77 |
char path[256]; /* Font Path */
|
| 78 |
char videobuf[MAX_VIDEO_LEN]; /* Video Card Device section */
|
| 79 |
int videolen = MAX_VIDEO_LEN - 1; /* How many chars we have left */
|
| 80 |
char dri = FALSE; /* DRI on or off */
|
| 81 |
|
| 82 |
if (!(fd = open(name, O_RDONLY)))
|
| 83 |
rc = 2; /* Failure */
|
| 84 |
|
| 85 |
if (!rc && ioctl(fd, FBIOGET_FSCREENINFO, &fix))
|
| 86 |
rc = 2; /* Failure */
|
| 87 |
|
| 88 |
if (!rc && ioctl(fd, FBIOGET_VSCREENINFO, &var))
|
| 89 |
rc = 2; /* Failure */
|
| 90 |
|
| 91 |
close(fd);
|
| 92 |
|
| 93 |
/* 640x480 framebuffer typically implies a CRT, so lets bump */
|
| 94 |
/* the resolution up to 800x600 to be a bit more sane */
|
| 95 |
if (var.xres == 640 && var.yres == 480) {
|
| 96 |
var.xres = 800;
|
| 97 |
var.yres = 600;
|
| 98 |
}
|
| 99 |
|
| 100 |
if (rc) {
|
| 101 |
fprintf(stderr, "Can't access %s. Exiting.\n", name);
|
| 102 |
return -1;
|
| 103 |
}
|
| 104 |
|
| 105 |
if (argc > 1) {
|
| 106 |
int args;
|
| 107 |
for(args = 1; args<argc; args++) {
|
| 108 |
if (!strcmp(argv[args], "--fbdepth"))
|
| 109 |
fbdepth = 1;
|
| 110 |
else if (!strcmp(argv[args], "--fbdev"))
|
| 111 |
fbdev = 1;
|
| 112 |
else if (!strcmp(argv[args], "--safe"))
|
| 113 |
fbdev = fbdepth = 1;
|
| 114 |
else if (!strncmp(argv[args], "--keymap=", 9)) {
|
| 115 |
strncpy(keyboard_layout, argv[args] + 9 , 29);
|
| 116 |
strcat(keyboard_layout, "\"\n");
|
| 117 |
}
|
| 118 |
else if (!strcmp(argv[args], "--list-keymaps")) {
|
| 119 |
printf("%s", keymap_list);
|
| 120 |
exit(0);
|
| 121 |
} else {
|
| 122 |
usage();
|
| 123 |
exit(0);
|
| 124 |
}
|
| 125 |
}
|
| 126 |
}
|
| 127 |
|
| 128 |
/* Check to see what type of Mac we're on.*/
|
| 129 |
/* e.g. PowerBook1,1 */
|
| 130 |
macid = macMachineType();
|
| 131 |
|
| 132 |
sync.h_min = 0;
|
| 133 |
sync.h_max = 0;
|
| 134 |
sync.v_min = 0;
|
| 135 |
sync.v_max = 0;
|
| 136 |
|
| 137 |
/* Check to see if EDID is available */
|
| 138 |
if ( (sizeof(struct edid1_info) == 256) &&
|
| 139 |
(sizeof(struct edid_monitor_descriptor) == 18) &&
|
| 140 |
get_edid_supported())
|
| 141 |
{
|
| 142 |
edid_info = get_edid_info();
|
| 143 |
|
| 144 |
if ( !(edid_info == NULL) &&
|
| 145 |
!(edid_info->version == 0) &&
|
| 146 |
!(edid_info->version == 0xff && edid_info->revision == 0xff) &&
|
| 147 |
!(edid_info->version == 0 && edid_info->revision == 0))
|
| 148 |
{
|
| 149 |
manufacturer[0] = edid_info->manufacturer_name.char1 + 'A' - 1;
|
| 150 |
manufacturer[1] = edid_info->manufacturer_name.char2 + 'A' - 1;
|
| 151 |
manufacturer[2] = edid_info->manufacturer_name.char3 + 'A' - 1;
|
| 152 |
manufacturer[3] = '\0';
|
| 153 |
eisaid = malloc(sizeof(manufacturer) + sizeof(edid_info->product_code));
|
| 154 |
sprintf(eisaid, "%s%04x", manufacturer, edid_info->product_code);
|
| 155 |
|
| 156 |
for (i = 0; i < 4; i++)
|
| 157 |
{
|
| 158 |
struct edid_monitor_descriptor *monitor = NULL;
|
| 159 |
|
| 160 |
monitor = &edid_info->monitor_details.monitor_descriptor[i];
|
| 161 |
|
| 162 |
if (monitor->type == edid_monitor_descriptor_range)
|
| 163 |
{
|
| 164 |
sync.h_min = monitor->data.range_data.horizontal_min;
|
| 165 |
sync.h_max = monitor->data.range_data.horizontal_max;
|
| 166 |
sync.v_min = monitor->data.range_data.vertical_min;
|
| 167 |
sync.v_max = monitor->data.range_data.vertical_max;
|
| 168 |
}
|
| 169 |
}
|
| 170 |
/* On certain Apple LCD panels, set vertical min and max */
|
| 171 |
if ((eisaid) && (!strcmp(eisaid, "APP1592") ||
|
| 172 |
!strcmp(eisaid, "APPf401") ||
|
| 173 |
!strcmp(eisaid, "APP1792") ||
|
| 174 |
!strcmp(eisaid, "APP1992") ||
|
| 175 |
!strcmp(eisaid, "APP1692") ||
|
| 176 |
!strcmp(eisaid, "APP1892")))
|
| 177 |
sync.v_min = 50;
|
| 178 |
sync.v_max = 60;
|
| 179 |
}
|
| 180 |
}
|
| 181 |
|
| 182 |
/* More or less taken from Geert Uytterhoeven's fbset (GPL'ed as well..) */
|
| 183 |
htotal = var.left_margin+var.xres+var.right_margin+var.hsync_len;
|
| 184 |
vtotal = var.upper_margin+var.yres+var.lower_margin+var.vsync_len;
|
| 185 |
drate = (1E12/var.pixclock);
|
| 186 |
hrate = drate/htotal;
|
| 187 |
vrate = hrate/vtotal;
|
| 188 |
xsstart = var.xres+var.right_margin;
|
| 189 |
xsend = xsstart+var.hsync_len;
|
| 190 |
xtotal = xsend+var.left_margin;
|
| 191 |
ysstart = var.yres+var.lower_margin;
|
| 192 |
ysend = ysstart+var.vsync_len;
|
| 193 |
ytotal = ysend+var.upper_margin;
|
| 194 |
if (var.bits_per_pixel == 8)
|
| 195 |
depth = 8;
|
| 196 |
else
|
| 197 |
depth = var.red.length+var.green.length+var.blue.length;
|
| 198 |
|
| 199 |
/* look for nvidia and offb */
|
| 200 |
if (fix.id)
|
| 201 |
{
|
| 202 |
mem = strdup(fix.id);
|
| 203 |
while(((i = strlen(mem)) > 0) && isspace(mem[i - 1])) {
|
| 204 |
mem[i - 1] = '\0';
|
| 205 |
}
|
| 206 |
if (strstr(fix.id, "NVDA") != NULL)
|
| 207 |
nv = 1;
|
| 208 |
|
| 209 |
if (!strncmp(fix.id, "OFfb", 4))
|
| 210 |
offb = 1;
|
| 211 |
}
|
| 212 |
|
| 213 |
findVideoDevice(); /* For BusID */
|
| 214 |
|
| 215 |
/* Work out the card specifics to figure out if we need DRI, etc. */
|
| 216 |
depth = 16;
|
| 217 |
memset(videobuf, 0, MAX_VIDEO_LEN);
|
| 218 |
if (nv) {
|
| 219 |
if (!strncmp(macid, "PowerMac4,2", 11) || !strncmp(macid, "PowerMac4,5", 11))
|
| 220 |
fprintf(f, " Option \"FlatPanel\"\n");
|
| 221 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_nv);
|
| 222 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"nv\"\n");
|
| 223 |
dri = FALSE;
|
| 224 |
} else if((fbdev) || (bus == 0 && dev == 0 && func == 0)) {
|
| 225 |
if (!fbdev) {
|
| 226 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " # We couldn't determine the BusID of your ");
|
| 227 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "video card. So we will use\n# the fbdev driver\n");
|
| 228 |
}
|
| 229 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " #Option \"ShadowFB\" \"true\"\n");
|
| 230 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " #Option \"fbdev\" \"%s\"\n", name);
|
| 231 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"fbdev\"\n");
|
| 232 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " #BusID \"0:0:0\"\n");
|
| 233 |
depth = 15;
|
| 234 |
dri = FALSE;
|
| 235 |
} else {
|
| 236 |
/* Try and guess what video card is behind /dev/fb0 */
|
| 237 |
switch(fix.accel) {
|
| 238 |
/* ATI Mach64 Family cards */
|
| 239 |
case 6:
|
| 240 |
case 8:
|
| 241 |
case 9:
|
| 242 |
case 10:
|
| 243 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_on_opts);
|
| 244 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"ati\"\n");
|
| 245 |
dri = FALSE; /* Can this be enabled? */
|
| 246 |
break;
|
| 247 |
/* IMS Twin Turbo */
|
| 248 |
case 14:
|
| 249 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_off_opts);
|
| 250 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"imstt\"\n");
|
| 251 |
dri = FALSE; /* Can this be enabled? */
|
| 252 |
break;
|
| 253 |
/* Matrox Family */
|
| 254 |
case 16:
|
| 255 |
case 17:
|
| 256 |
case 18:
|
| 257 |
case 20:
|
| 258 |
case 21:
|
| 259 |
case 26:
|
| 260 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_off_opts);
|
| 261 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"mga\"\n");
|
| 262 |
dri = FALSE; /* Can this be enabled? */
|
| 263 |
break;
|
| 264 |
/* Chips&Technology 6555x */
|
| 265 |
/* Is this still broken?
|
| 266 |
case 30:
|
| 267 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_off_opts);
|
| 268 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"chips\"\n");
|
| 269 |
dri = FALSE;
|
| 270 |
break;
|
| 271 |
*/
|
| 272 |
/* VooDoo 3 / Banshee */
|
| 273 |
case 31:
|
| 274 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_off_opts);
|
| 275 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"tdfx\"\n");
|
| 276 |
dri = FALSE; /* Can this be enabled? */
|
| 277 |
break;
|
| 278 |
/* ATI Rage 128 Family */
|
| 279 |
case 32:
|
| 280 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_r128);
|
| 281 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"r128\"\n");
|
| 282 |
dri = TRUE;
|
| 283 |
break;
|
| 284 |
/* ATI Radeon */
|
| 285 |
/* FIXME what are the values for radeon > 9200? */
|
| 286 |
case 38:
|
| 287 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_radeon);
|
| 288 |
if(!strncmp(macid + 5, "Pegasos", 7))
|
| 289 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", "\tOption\t\"BusType\"\t\"PCI\"\n");
|
| 290 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"radeon\"\n");
|
| 291 |
dri = TRUE;
|
| 292 |
break;
|
| 293 |
default:
|
| 294 |
/* FIXME still broken? */
|
| 295 |
/* radeon seems to be broken on VE (aka 7000) */
|
| 296 |
if ((!strncmp(fix.id, "ATI Radeon", 10)) &&
|
| 297 |
(strncmp(fix.id, "ATI Radeon VE", 13))) {
|
| 298 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_radeon);
|
| 299 |
if(!strncmp(macid + 5, "Pegasos", 7))
|
| 300 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", "\tOption\t\"BusType\"\t\"PCI\"\n");
|
| 301 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"radeon\"\n");
|
| 302 |
dri = TRUE;
|
| 303 |
} else if (!strncmp(fix.id, "Rage128", 7)) {
|
| 304 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_r128);
|
| 305 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"r128\"\n");
|
| 306 |
dri = TRUE;
|
| 307 |
} else if (!strncmp(fix.id, "Rage Mobility M3", 16)) {
|
| 308 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_r128);
|
| 309 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"r128\"\n");
|
| 310 |
dri = TRUE;
|
| 311 |
} else {
|
| 312 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " #Option \"ShadowFB\" \"true\"\n");
|
| 313 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"fbdev\"\n");
|
| 314 |
dri = FALSE;
|
| 315 |
depth = 15;
|
| 316 |
}
|
| 317 |
break;
|
| 318 |
}
|
| 319 |
videolen -= snprintf(videobuf + strlen(videobuf), videolen, " BusID \"PCI:%d:%d:%d\"\n", bus, dev, func);
|
| 320 |
}
|
| 321 |
|
| 322 |
/* Let's be nice and backup an existing xorg.conf */
|
| 323 |
if ((f = fopen("/etc/X11/xorg.conf", "r"))) {
|
| 324 |
system("mv /etc/X11/xorg.conf /etc/X11/xorg.conf.autobak");
|
| 325 |
printf("The current xorg.conf has been copied into /etc/X11/xorg.conf.autobak\n");
|
| 326 |
}
|
| 327 |
|
| 328 |
/* Check the permissions for writing */
|
| 329 |
if (!(f = fopen("/etc/X11/xorg.conf", "w"))) {
|
| 330 |
fprintf(stderr, "Can't write to /etc/X11/xorg.conf. Exiting.\n");
|
| 331 |
return -1;;
|
| 332 |
}
|
| 333 |
|
| 334 |
/*** BEGIN xorg.conf ***/
|
| 335 |
fprintf(f, "%s", header);
|
| 336 |
|
| 337 |
/* Set fontpaths */
|
| 338 |
DIR *fontdir = opendir(FONTPATH);
|
| 339 |
struct dirent *fontpath;
|
| 340 |
|
| 341 |
/* Add x fontserver note */
|
| 342 |
fprintf(f, "%s", fontpath_xfs);
|
| 343 |
if(fontdir != NULL) {
|
| 344 |
while ((fontpath = readdir (fontdir))) {
|
| 345 |
if((fontpath->d_name)[0] != '.') {
|
| 346 |
/* Only add directories */
|
| 347 |
strcpy(path, FONTPATH);
|
| 348 |
strcat(path, fontpath->d_name);
|
| 349 |
strcat(path, "/");
|
| 350 |
testdir = opendir(path);
|
| 351 |
if(testdir != NULL) {
|
| 352 |
fprintf(f, "\tFontPath\t\"%s\"\n",
|
| 353 |
path);
|
| 354 |
if(!strncmp(fontpath->d_name,"75dpi",5) ||
|
| 355 |
!strncmp(fontpath->d_name,"100dpi",6)){
|
| 356 |
fprintf(f, "\tFontPath\t\"%s:unscaled\"\n",
|
| 357 |
path);
|
| 358 |
}
|
| 359 |
closedir(testdir);
|
| 360 |
}
|
| 361 |
}
|
| 362 |
}
|
| 363 |
closedir(fontdir);
|
| 364 |
}
|
| 365 |
else {
|
| 366 |
fprintf(f, "%s", fontpath_gentoo);
|
| 367 |
}
|
| 368 |
fprintf(f, "EndSection\n\n");
|
| 369 |
|
| 370 |
/* modules section */
|
| 371 |
fprintf(f, "%s", modules_section_start);
|
| 372 |
if(!dri) fprintf(f, "%s", "#");
|
| 373 |
fprintf(f, "%s", modules_section_end);
|
| 374 |
|
| 375 |
/* extensions section */
|
| 376 |
fprintf(f, "%s", extensions_section);
|
| 377 |
|
| 378 |
/* serverflags section */
|
| 379 |
fprintf(f, "%s", serverflags_section);
|
| 380 |
|
| 381 |
/* input dev section */
|
| 382 |
fprintf(f, "%s", inputdev_section);
|
| 383 |
|
| 384 |
/* keyboard */
|
| 385 |
if(0 == keyboard_layout[0])
|
| 386 |
strcpy(keyboard_layout, "us\"\n");
|
| 387 |
fprintf(f, "%s", keyboard_linux_start);
|
| 388 |
fprintf(f, "%s", keyboard_layout);
|
| 389 |
fprintf(f, "%s", keyboard_linux_end);
|
| 390 |
|
| 391 |
/* mouse */
|
| 392 |
fprintf(f, "%s", mouse_section);
|
| 393 |
|
| 394 |
/* monitor section */
|
| 395 |
if (!offb)
|
| 396 |
fprintf(f, "%s", monitor_section);
|
| 397 |
else
|
| 398 |
fprintf(f, "%s", monitor_section_nomodes);
|
| 399 |
|
| 400 |
/* Use EDID's horizsync / vert refresh first, otherwise try to be sane */
|
| 401 |
if (sync.h_min && sync.h_max && sync.v_min && sync.v_max)
|
| 402 |
{
|
| 403 |
fprintf(f, "\tHorizSync %d-%d\n\tVertRefresh %d-%d\n",
|
| 404 |
sync.h_min, sync.h_max, sync.v_min, sync.v_max);
|
| 405 |
} else if (!strncmp(macid, "PowerMac4,2", 11)) {
|
| 406 |
fprintf(f, "\tHorizSync 28-49 \n\tVertRefresh 50-60\n");
|
| 407 |
} else if (sync.v_min && sync.v_max) {
|
| 408 |
/* Apple Studio/Cinema Display case */
|
| 409 |
fprintf(f, "\tHorizSync 30-130\n\tVertRefresh %d-%d\n",
|
| 410 |
sync.v_min, sync.v_max);
|
| 411 |
} else {
|
| 412 |
if(var.xres <= 640)
|
| 413 |
fprintf(f, " HorizSync 28-33\n VertRefresh 43-72\n");
|
| 414 |
else if(var.xres <= 800)
|
| 415 |
fprintf(f, " HorizSync 28-50\n VertRefresh 43-75\n");
|
| 416 |
else if(var.xres <= 1024)
|
| 417 |
fprintf(f, " HorizSync 30-70\n VertRefresh 50-160\n");
|
| 418 |
else if(var.xres <= 1152)
|
| 419 |
fprintf(f, " HorizSync 30-100\n VertRefresh 50-160\n");
|
| 420 |
else
|
| 421 |
fprintf(f, " HorizSync 30-130\n VertRefresh 50-160\n");
|
| 422 |
}
|
| 423 |
|
| 424 |
if (!offb)
|
| 425 |
{
|
| 426 |
fprintf(f, "%s", modes_section);
|
| 427 |
fprintf(f, " # D: %5.3f MHz, H: %5.3f kHz, V: %5.3f Hz\n", drate/1E6,
|
| 428 |
hrate/1E3, vrate);
|
| 429 |
fprintf(f, " Modeline \"%dx%d\" %5.3f %d %d %d %d %d %d %d %d ",
|
| 430 |
var.xres, var.yres, drate/1E6, var.xres, xsstart, xsend,
|
| 431 |
xtotal, var.yres, ysstart, ysend, ytotal);
|
| 432 |
if (var.vmode & FB_VMODE_INTERLACED)
|
| 433 |
fprintf(f, " Interlace");
|
| 434 |
if (var.vmode & FB_VMODE_DOUBLE)
|
| 435 |
fprintf(f, " DoubleScan");
|
| 436 |
if (var.sync & FB_SYNC_HOR_HIGH_ACT)
|
| 437 |
fprintf(f, " +HSync");
|
| 438 |
else
|
| 439 |
fprintf(f, " -HSync");
|
| 440 |
if (var.sync & FB_SYNC_VERT_HIGH_ACT)
|
| 441 |
fprintf(f, " +VSync");
|
| 442 |
else
|
| 443 |
fprintf(f, " -VSync");
|
| 444 |
if (var.sync & FB_SYNC_COMP_HIGH_ACT)
|
| 445 |
fprintf(f, " Composite");
|
| 446 |
if (var.sync & FB_SYNC_BROADCAST)
|
| 447 |
fprintf(f, " bcast");
|
| 448 |
}
|
| 449 |
fprintf(f, "%s", device_start);
|
| 450 |
fprintf(f, "%s", videobuf);
|
| 451 |
fprintf(f, "%s", screen_section);
|
| 452 |
fprintf(f, "%d\n", depth);
|
| 453 |
if(fbdepth && depth != var.bits_per_pixel)
|
| 454 |
fprintf(f," DefaultFbBpp %d\n", var.bits_per_pixel);
|
| 455 |
|
| 456 |
/* Print this out for 8 / 16 / 24 */
|
| 457 |
for (i = 8;i <= 24;i = i + 8)
|
| 458 |
{
|
| 459 |
fprintf(f, " SubSection \"Display\"\n");
|
| 460 |
fprintf(f, " Depth %d\n", i);
|
| 461 |
|
| 462 |
/* If they've got 32bit use it, otherwise use 24 */
|
| 463 |
if (depth == 24 && depth != var.bits_per_pixel)
|
| 464 |
fprintf(f, " FbBpp %d\n",
|
| 465 |
var.bits_per_pixel);
|
| 466 |
|
| 467 |
fprintf(f, " Modes \"%dx%d\"\n", var.xres,
|
| 468 |
var.yres);
|
| 469 |
fprintf(f, " EndSubSection\n");
|
| 470 |
}
|
| 471 |
|
| 472 |
/* To catch depth = 15, common :( */
|
| 473 |
if(depth == 15) {
|
| 474 |
fprintf(f, " SubSection \"Display\"\n");
|
| 475 |
fprintf(f, " Depth %d\n", depth);
|
| 476 |
|
| 477 |
fprintf(f, " FbBpp %d\n",
|
| 478 |
var.bits_per_pixel);
|
| 479 |
|
| 480 |
fprintf(f, " Modes \"%dx%d\"\n", var.xres,
|
| 481 |
var.yres);
|
| 482 |
fprintf(f, " EndSubSection\n");
|
| 483 |
}
|
| 484 |
|
| 485 |
fprintf(f, "EndSection\n");
|
| 486 |
fprintf(f, "%s", dri_section);
|
| 487 |
/*** END Xorg.conf ***/
|
| 488 |
|
| 489 |
fclose(f);
|
| 490 |
|
| 491 |
fprintf(stdout, "Wrote /etc/X11/xorg.conf\n");
|
| 492 |
fprintf(stdout, "Please check the configuration file for additional options\n");
|
| 493 |
|
| 494 |
return 0;
|
| 495 |
}
|