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

Diff of /Xorgautoconfig/Xorgautoconfig.c

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

Revision 1.14 Revision 1.15
30#include <sys/mman.h> 30#include <sys/mman.h>
31#include <netinet/in.h> 31#include <netinet/in.h>
32#include <linux/fb.h> 32#include <linux/fb.h>
33#include <byteswap.h> 33#include <byteswap.h>
34#include <dirent.h> 34#include <dirent.h>
35#include <sys/utsname.h>
35 36
36#include "ddcprobe/common.h" 37#include "ddcprobe/common.h"
37#include "ddcprobe/vesamode.h" 38#include "ddcprobe/vesamode.h"
38#include "Xorgtext.h" 39#include "Xorgtext.h"
39 40
78 char videobuf[MAX_VIDEO_LEN]; /* Video Card Device section */ 79 char videobuf[MAX_VIDEO_LEN]; /* Video Card Device section */
79 int videolen = MAX_VIDEO_LEN - 1; /* How many chars we have left */ 80 int videolen = MAX_VIDEO_LEN - 1; /* How many chars we have left */
80 char dri = FALSE; /* DRI on or off */ 81 char dri = FALSE; /* DRI on or off */
81 char dump = FALSE; /* Dump debugging info? */ 82 char dump = FALSE; /* Dump debugging info? */
82 char quiet = FALSE; /* Be quiet */ 83 char quiet = FALSE; /* Be quiet */
84 struct utsname kern; /* Get the kernel version */
85 char kern_new = FALSE;
86 char kern_ver [3];
87
88 uname(&kern);
89 if(strlen(kern.release) > 6) {
90 strncpy(kern_ver, (const char *)(&kern.release) + 4, 2);
91 kern_ver[2] = (char) NULL;
92
93 if(atoi(kern_ver) >= 12)
94 kern_new = TRUE;
95 }
83 96
84 if (!(fd = open(name, O_RDONLY))) 97 if (!(fd = open(name, O_RDONLY)))
85 rc = 2; /* Failure */ 98 rc = 2; /* Failure */
86 99
87 if (!rc && ioctl(fd, FBIOGET_FSCREENINFO, &fix)) 100 if (!rc && ioctl(fd, FBIOGET_FSCREENINFO, &fix))
119 quiet = TRUE; 132 quiet = TRUE;
120 else if (!strncmp(argv[args], "--keymap=", 9)) { 133 else if (!strncmp(argv[args], "--keymap=", 9)) {
121 strncpy(keyboard_layout, argv[args] + 9 , 29); 134 strncpy(keyboard_layout, argv[args] + 9 , 29);
122 strcat(keyboard_layout, "\"\n"); 135 strcat(keyboard_layout, "\"\n");
123 } 136 }
137 else if (!strcmp(argv[args], "--version")) {
138 printf("Xorgautoconfig v" XAC_VER "\n");
139 exit(0);
140 }
124 else if (!strcmp(argv[args], "--list-keymaps")) { 141 else if (!strcmp(argv[args], "--list-keymaps")) {
125 printf("%s", keymap_list); 142 printf("%s", keymap_list);
126 exit(0); 143 exit(0);
127 } else { 144 } else {
128 usage(); 145 usage();
220 /* Work out the card specifics to figure out if we need DRI, etc. */ 237 /* Work out the card specifics to figure out if we need DRI, etc. */
221 depth = 16; 238 depth = 16;
222 memset(videobuf, 0, MAX_VIDEO_LEN); 239 memset(videobuf, 0, MAX_VIDEO_LEN);
223 if (nv) { 240 if (nv) {
224 if (!strncmp(macid, "PowerMac4,2", 11) || !strncmp(macid, "PowerMac4,5", 11)) 241 if (!strncmp(macid, "PowerMac4,2", 11) || !strncmp(macid, "PowerMac4,5", 11))
225 fprintf(f, " Option \"FlatPanel\"\n"); 242 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Option \"FlatPanel\"\n");
226 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_nv); 243 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_nv);
227 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"nv\"\n"); 244 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"nv\"\n");
228 dri = FALSE; 245 dri = FALSE;
229 } else if((fbdev) || (bus == 0 && dev == 0 && func == 0)) { 246 } else if((fbdev) || (bus == 0 && dev == 0 && func == 0)) {
230 if (!fbdev) { 247 if (!fbdev) {
283 dri = FALSE; /* Can this be enabled? */ 300 dri = FALSE; /* Can this be enabled? */
284 break; 301 break;
285 /* ATI Rage 128 Family */ 302 /* ATI Rage 128 Family */
286 case 32: 303 case 32:
287 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_r128); 304 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_r128);
305 if(kern_new)
306 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "\tOption\t\"UseFBDev\"\t\"False\"\n");
307 else
308 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "\tOption\t\"UseFBDev\"\t\"True\"\n");
288 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"r128\"\n"); 309 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"r128\"\n");
289 dri = TRUE; 310 dri = TRUE;
290 break; 311 break;
291 /* ATI Radeon */ 312 /* ATI Radeon */
292 /* FIXME what are the values for radeon > 9200? */
293 case 38: 313 case 38:
294 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_radeon); 314 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_radeon);
295 if(!strncmp(macid + 5, "Pegasos", 7)) 315 if(!strncmp(macid + 5, "Pegasos", 7))
296 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", "\tOption\t\"BusType\"\t\"PCI\"\n"); 316 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", "\tOption\t\"BusType\"\t\"PCI\"\n");
317 if(kern_new)
318 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "\tOption\t\"UseFBDev\"\t\"False\"\n");
319 else
320 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "\tOption\t\"UseFBDev\"\t\"True\"\n");
297 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"radeon\"\n"); 321 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"radeon\"\n");
298 dri = TRUE; 322 dri = TRUE;
299 break; 323 break;
300 default: 324 default:
301 if (!strncmp(fix.id, "ATI Radeon", 10)) { 325 if (!strncmp(fix.id, "ATI Radeon", 10)) {
302 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_radeon); 326 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_radeon);
303 if(!strncmp(macid + 5, "Pegasos", 7)) 327 if(!strncmp(macid + 5, "Pegasos", 7))
304 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", "\tOption\t\"BusType\"\t\"PCI\"\n"); 328 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", "\tOption\t\"BusType\"\t\"PCI\"\n");
329 if(kern_new)
330 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "\tOption\t\"UseFBDev\"\t\"False\"\n");
331 else
332 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "\tOption\t\"UseFBDev\"\t\"True\"\n");
305 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"radeon\"\n"); 333 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"radeon\"\n");
306 dri = TRUE; 334 dri = TRUE;
307 } else if (!strncmp(fix.id, "Rage128", 7)) { 335 } else if (!strncmp(fix.id, "Rage128", 7)) {
308 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_r128); 336 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_r128);
337 if(kern_new)
338 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "\tOption\t\"UseFBDev\"\t\"False\"\n");
339 else
340 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "\tOption\t\"UseFBDev\"\t\"True\"\n");
309 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"r128\"\n"); 341 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"r128\"\n");
310 dri = TRUE; 342 dri = TRUE;
311 } else if (!strncmp(fix.id, "Rage Mobility M3", 16)) { 343 } else if (!strncmp(fix.id, "Rage Mobility M3", 16)) {
312 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_r128); 344 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "%s", driver_r128);
345 if(kern_new)
346 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "\tOption\t\"UseFBDev\"\t\"False\"\n");
347 else
348 videolen -= snprintf(videobuf + strlen(videobuf), videolen, "\tOption\t\"UseFBDev\"\t\"True\"\n");
313 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"r128\"\n"); 349 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"r128\"\n");
314 dri = TRUE; 350 dri = TRUE;
315 } else { 351 } else {
316 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " #Option \"ShadowFB\" \"true\"\n"); 352 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " #Option \"ShadowFB\" \"true\"\n");
317 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"fbdev\"\n"); 353 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " Driver\t\"fbdev\"\n");
346 } 382 }
347 383
348 /* Check the permissions for writing */ 384 /* Check the permissions for writing */
349 if (!(f = fopen("/etc/X11/xorg.conf", "w"))) { 385 if (!(f = fopen("/etc/X11/xorg.conf", "w"))) {
350 fprintf(stderr, "Can't write to /etc/X11/xorg.conf. Exiting.\n"); 386 fprintf(stderr, "Can't write to /etc/X11/xorg.conf. Exiting.\n");
351 return -1;; 387 return -1;
352 } 388 }
353 389
354 /*** BEGIN xorg.conf ***/ 390 /*** BEGIN xorg.conf ***/
355 fprintf(f, "%s", header); 391 fprintf(f, "%s", header);
356 392

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.20