/[gentoo-src]/Xorgautoconfig/Xorgautoconfig.c
Gentoo

Diff of /Xorgautoconfig/Xorgautoconfig.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.2 Revision 1.3
1/* Xorgautoconfig: versatile xorg.conf creation tool for PowerPC 1/* Xorgautoconfig: versatile xorg.conf creation tool for PowerPC
2 * 2 *
3 * Copyright (C) 2005 Lars Weiler <pylon@gentoo.org> 3 * Copyright (C) 2005 Lars Weiler <pylon@gentoo.org>
4 * Copyright (C) 2005 Joseph Jezak <josejx@gentoo.org>
4 * 5 *
5 * This xorg.conf creation tool is a fork from Xautoconfig-0.23 6 * This xorg.conf creation tool is a fork from Xautoconfig-0.23
6 * (http://ftp.penguinppc.org/projects/xautocfg/) 7 * (http://ftp.penguinppc.org/projects/xautocfg/)
7 * 8 *
8 * The original header-comment contained: 9 * The original header-comment contained:
9 * Copyright (C) 2002-2004 Dan Burcaw <dan@ydl.net> 10 * Copyright (C) 2002-2004 Dan Burcaw <dan@ydl.net>
10 * Copyright (C) 1999-2001 Tom Rini <trini@kernel.crashing.org> 11 * Copyright (C) 1999-2001 Tom Rini <trini@kernel.crashing.org>
11 * 12 *
12 * Thanks for this good start for a X.Org configurator! 13 * Thanks for this good start for an X.Org configurator!
13 * 14 *
14 */ 15 */
15 16
16#define _GNU_SOURCE 17#define _GNU_SOURCE
17#include <stdio.h> 18#include <stdio.h>
67 68
68 const char * name = "/dev/fb0"; 69 const char * name = "/dev/fb0";
69 unsigned char *mem; 70 unsigned char *mem;
70 char *macid; 71 char *macid;
71 char *eisaid; 72 char *eisaid;
72 73 char keyboard_layout[32];
74 memset(keyboard_layout, 0, 32);
75
73 if (!(fd = open(name, O_RDONLY))) 76 if (!(fd = open(name, O_RDONLY)))
74 rc = 2; /* Failure */ 77 rc = 2; /* Failure */
75 78
76 if (!rc && ioctl(fd, FBIOGET_FSCREENINFO, &fix)) 79 if (!rc && ioctl(fd, FBIOGET_FSCREENINFO, &fix))
77 rc = 2; /* Failure */ 80 rc = 2; /* Failure */
91 if (rc) { 94 if (rc) {
92 fprintf(stderr, "Can't access %s. Exiting.\n", name); 95 fprintf(stderr, "Can't access %s. Exiting.\n", name);
93 return -1; 96 return -1;
94 } 97 }
95 98
96 if (argc == 2) 99 if (argc > 1) {
97 { 100 int args;
101 for(args = 1; args<argc; args++) {
98 if (!strcmp(argv[1], "--fbdepth")) 102 if (!strcmp(argv[args], "--fbdepth"))
99 fbdepth = 1; 103 fbdepth = 1;
100 else if (!strcmp(argv[1], "--fbdev")) 104 else if (!strcmp(argv[args], "--fbdev"))
101 fbdev = 1; 105 fbdev = 1;
102 else if (!strcmp(argv[1], "--safe")) 106 else if (!strcmp(argv[args], "--safe"))
103 fbdev = fbdepth = 1; 107 fbdev = fbdepth = 1;
104 else if (!strcmp(argv[1], "--help")) { 108 else if (!strncmp(argv[args], "--keymap=", 9)) {
109 strncpy(keyboard_layout, argv[args] + 9 , 29);
110 strcat(keyboard_layout, "\"\n");
111 } else {
105 usage(); 112 usage();
106 exit(0); 113 exit(0);
107 } else {
108 usage();
109 exit(0);
110 } 114 }
111 } else if (argc > 2) { 115 }
112 usage();
113 exit(0);
114
115 } 116 }
116 117
117 /* Check to see what type of Mac we're on.*/ 118 /* Check to see what type of Mac we're on.*/
118 /* e.g. PowerBook1,1 */ 119 /* e.g. PowerBook1,1 */
119 macid = macMachineType(); 120 macid = macMachineType();
208 209
209 if (!(f = fopen("/etc/X11/xorg.conf", "w"))) { 210 if (!(f = fopen("/etc/X11/xorg.conf", "w"))) {
210 fprintf(stderr, "Can't write to /etc/X11/xorg.conf. Exiting.\n"); 211 fprintf(stderr, "Can't write to /etc/X11/xorg.conf. Exiting.\n");
211 return -1;; 212 return -1;;
212 } 213 }
213
214 214
215 /*** BEGIN xorg.conf ***/ 215 /*** BEGIN xorg.conf ***/
216 fprintf(f, "%s", header); 216 fprintf(f, "%s", header);
217 217
218 /* Set fontpaths */ 218 /* Set fontpaths */
261 261
262 /* input dev section */ 262 /* input dev section */
263 fprintf(f, "%s", inputdev_section); 263 fprintf(f, "%s", inputdev_section);
264 264
265 /* keyboard */ 265 /* keyboard */
266
267 if(0 == keyboard_layout[0])
268 strcpy(keyboard_layout, "us\"\n");
269 fprintf(f, "%s", keyboard_linux_start);
270 fprintf(f, "%s", keyboard_layout);
266 fprintf(f, "%s", keyboard_linux); 271 fprintf(f, "%s", keyboard_linux_end);
267 272
268 /* mouse */ 273 /* mouse */
269 fprintf(f, "%s", mouse_section); 274 fprintf(f, "%s", mouse_section);
270 fprintf(f, "IMPS/2\"\n");
271 fprintf(f, " Option \"Device\" \"/dev/input/mice\"\n");
272 fprintf(f, "EndSection\n\n");
273 275
274 /* monitor section */ 276 /* monitor section */
275 if (!offb) 277 if (!offb)
276 fprintf(f, "%s", monitor_section); 278 fprintf(f, "%s", monitor_section);
277 else 279 else
332 /* See if we know where the card is, if not... */ 334 /* See if we know where the card is, if not... */
333 if (nv) { 335 if (nv) {
334 if (!strncmp(macid, "PowerMac4,2", 11) || !strncmp(macid, "PowerMac4,5", 11)) 336 if (!strncmp(macid, "PowerMac4,2", 11) || !strncmp(macid, "PowerMac4,5", 11))
335 fprintf(f, " Option \"FlatPanel\"\n"); 337 fprintf(f, " Option \"FlatPanel\"\n");
336 fprintf(f, "%s", driver_nv); 338 fprintf(f, "%s", driver_nv);
337 fprintf(f, " Driver\t\t\"nv\"\n"); 339 fprintf(f, " Driver\t\"nv\"\n");
338 } else if((fbdev) || (bus == 0 && dev == 0 && func == 0)) { 340 } else if((fbdev) || (bus == 0 && dev == 0 && func == 0)) {
339 if (!fbdev) { 341 if (!fbdev) {
340 fprintf(f, " # We couldn't determine the BusID of your "); 342 fprintf(f, " # We couldn't determine the BusID of your ");
341 fprintf(f, "video card. So we will use\n# the fbdev driver\n"); 343 fprintf(f, "video card. So we will use\n# the fbdev driver\n");
342 } 344 }
343 fprintf(f, " #Option \"ShadowFB\" \"true\"\n"); 345 fprintf(f, " #Option \"ShadowFB\" \"true\"\n");
344 fprintf(f, " #Option \"fbdev\" \"%s\"\n", name); 346 fprintf(f, " #Option \"fbdev\" \"%s\"\n", name);
345 fprintf(f, " Driver\t\t\"fbdev\"\n"); 347 fprintf(f, " Driver\t\"fbdev\"\n");
346 fprintf(f, " #BusID \"0:0:0\"\n"); 348 fprintf(f, " #BusID \"0:0:0\"\n");
347 depth = 15; 349 depth = 15;
348 } else { 350 } else {
349 /* Try and guess what video card is behind /dev/fb0 */ 351 /* Try and guess what video card is behind /dev/fb0 */
350 switch(fix.accel) { 352 switch(fix.accel) {
352 case 6: 354 case 6:
353 case 8: 355 case 8:
354 case 9: 356 case 9:
355 case 10: 357 case 10:
356 fprintf(f, "%s", driver_on_opts); 358 fprintf(f, "%s", driver_on_opts);
357 fprintf(f, " Driver\t\t\"ati\"\n"); 359 fprintf(f, " Driver\t\"ati\"\n");
358 break; 360 break;
359 /* IMS Twin Turbo */ 361 /* IMS Twin Turbo */
360 case 14: 362 case 14:
361 fprintf(f, "%s", driver_off_opts); 363 fprintf(f, "%s", driver_off_opts);
362 fprintf(f, " Driver\t\t\"imstt\"\n"); 364 fprintf(f, " Driver\t\"imstt\"\n");
363 break; 365 break;
364 /* Matrox Family */ 366 /* Matrox Family */
365 case 16: 367 case 16:
366 case 17: 368 case 17:
367 case 18: 369 case 18:
368 case 20: 370 case 20:
369 case 21: 371 case 21:
370 case 26: 372 case 26:
371 fprintf(f, "%s", driver_off_opts); 373 fprintf(f, "%s", driver_off_opts);
372 fprintf(f, " Driver\t\t\"mga\"\n"); 374 fprintf(f, " Driver\t\"mga\"\n");
373 break; 375 break;
374 /* Chips&Technology 6555x */ 376 /* Chips&Technology 6555x */
375 /* Apparently this is broken... 377 /* Apparently this is broken...
376 case 30: 378 case 30:
377 fprintf(f, "%s", driver_off_opts); 379 fprintf(f, "%s", driver_off_opts);
378 fprintf(f, " Driver\t\t\"chips\"\n"); 380 fprintf(f, " Driver\t\"chips\"\n");
379 break; 381 break;
380 */ 382 */
381 /* VooDoo 3 / Banshee */ 383 /* VooDoo 3 / Banshee */
382 case 31: 384 case 31:
383 fprintf(f, "%s", driver_off_opts); 385 fprintf(f, "%s", driver_off_opts);
384 fprintf(f, " Driver\t\t\"tdfx\"\n"); 386 fprintf(f, " Driver\t\"tdfx\"\n");
385 break; 387 break;
386 /* ATI Rage 128 Family */ 388 /* ATI Rage 128 Family */
387 case 32: 389 case 32:
388 fprintf(f, "%s", driver_r128); 390 fprintf(f, "%s", driver_r128);
389 fprintf(f, " Driver\t\t\"r128\"\n"); 391 fprintf(f, " Driver\t\"r128\"\n");
390 break; 392 break;
391 /* ATI Radeon */ 393 /* ATI Radeon */
392 case 38: 394 case 38:
393 fprintf(f, "%s", driver_radeon); 395 fprintf(f, "%s", driver_radeon);
394 fprintf(f, " Driver\t\t\"radeon\"\n"); 396 fprintf(f, " Driver\t\"radeon\"\n");
395 break; 397 break;
396 default: 398 default:
397 /* FIXME still broken? */ 399 /* FIXME still broken? */
398 /* radeon seems to be broken on VE (aka 7000) */ 400 /* radeon seems to be broken on VE (aka 7000) */
399 if ((!strncmp(fix.id, "ATI Radeon", 10)) && 401 if ((!strncmp(fix.id, "ATI Radeon", 10)) &&
400 (strncmp(fix.id, "ATI Radeon VE", 13))) { 402 (strncmp(fix.id, "ATI Radeon VE", 13))) {
401 fprintf(f, "%s", driver_radeon); 403 fprintf(f, "%s", driver_radeon);
402 fprintf(f, " Driver\t\t\"radeon\"\n"); 404 fprintf(f, " Driver\t\"radeon\"\n");
403 } else if (!strncmp(fix.id, "Rage128", 7)) { 405 } else if (!strncmp(fix.id, "Rage128", 7)) {
404 fprintf(f, "%s", driver_r128); 406 fprintf(f, "%s", driver_r128);
405 fprintf(f, " Driver\t\t\"r128\"\n"); 407 fprintf(f, " Driver\t\"r128\"\n");
406 } else if (!strncmp(fix.id, "Rage Mobility M3", 16)) { 408 } else if (!strncmp(fix.id, "Rage Mobility M3", 16)) {
407 fprintf(f, "%s", driver_r128); 409 fprintf(f, "%s", driver_r128);
408 fprintf(f, " Driver\t\t\"r128\"\n"); 410 fprintf(f, " Driver\t\"r128\"\n");
409 } else { 411 } else {
410 fprintf(f, " #Option \"ShadowFB\""); 412 fprintf(f, " #Option \"ShadowFB\"");
411 fprintf(f, " \"true\"\n"); 413 fprintf(f, " \"true\"\n");
412 fprintf(f, " Driver\t\t\"fbdev\"\n"); 414 fprintf(f, " Driver\t\"fbdev\"\n");
413 depth = 15; 415 depth = 15;
414 } 416 }
415 break; 417 break;
416 } 418 }
417 fprintf(f, " BusID \"PCI:%d:%d:%d\"\n", bus, dev, func); 419 fprintf(f, " BusID \"PCI:%d:%d:%d\"\n", bus, dev, func);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.20