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

Diff of /Xorgautoconfig/Xorgautoconfig.c

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

Revision 1.10 Revision 1.11
76 DIR *testdir; /* Test if path is a directory */ 76 DIR *testdir; /* Test if path is a directory */
77 char path[256]; /* Font Path */ 77 char path[256]; /* Font Path */
78 char videobuf[MAX_VIDEO_LEN]; /* Video Card Device section */ 78 char videobuf[MAX_VIDEO_LEN]; /* Video Card Device section */
79 int videolen = MAX_VIDEO_LEN - 1; /* How many chars we have left */ 79 int videolen = MAX_VIDEO_LEN - 1; /* How many chars we have left */
80 char dri = FALSE; /* DRI on or off */ 80 char dri = FALSE; /* DRI on or off */
81 char dump = FALSE; /* Dump debugging info? */
82 char quiet = FALSE; /* Be quiet */
81 83
82 if (!(fd = open(name, O_RDONLY))) 84 if (!(fd = open(name, O_RDONLY)))
83 rc = 2; /* Failure */ 85 rc = 2; /* Failure */
84 86
85 if (!rc && ioctl(fd, FBIOGET_FSCREENINFO, &fix)) 87 if (!rc && ioctl(fd, FBIOGET_FSCREENINFO, &fix))
87 89
88 if (!rc && ioctl(fd, FBIOGET_VSCREENINFO, &var)) 90 if (!rc && ioctl(fd, FBIOGET_VSCREENINFO, &var))
89 rc = 2; /* Failure */ 91 rc = 2; /* Failure */
90 92
91 close(fd); 93 close(fd);
94
95 if (rc) {
96 fprintf(stderr, "Can't access %s. Exiting.\n", name);
97 return -1;
98 }
92 99
93 /* 640x480 framebuffer typically implies a CRT, so lets bump */ 100 /* 640x480 framebuffer typically implies a CRT, so lets bump */
94 /* the resolution up to 800x600 to be a bit more sane */ 101 /* the resolution up to 800x600 to be a bit more sane */
95 if (var.xres == 640 && var.yres == 480) { 102 if (var.xres == 640 && var.yres == 480) {
96 var.xres = 800; 103 var.xres = 800;
97 var.yres = 600; 104 var.yres = 600;
98 }
99
100 if (rc) {
101 fprintf(stderr, "Can't access %s. Exiting.\n", name);
102 return -1;
103 } 105 }
104 106
105 if (argc > 1) { 107 if (argc > 1) {
106 int args; 108 int args;
107 for(args = 1; args<argc; args++) { 109 for(args = 1; args<argc; args++) {
108 if (!strcmp(argv[args], "--fbdepth")) 110 if (!strcmp(argv[args], "--fbdepth"))
109 fbdepth = 1; 111 fbdepth = 1;
110 else if (!strcmp(argv[args], "--fbdev")) 112 else if (!strcmp(argv[args], "--fbdev"))
111 fbdev = 1; 113 fbdev = 1;
114 else if (!strcmp(argv[args], "--dump"))
115 dump = TRUE;
112 else if (!strcmp(argv[args], "--safe")) 116 else if (!strcmp(argv[args], "--safe"))
113 fbdev = fbdepth = 1; 117 fbdev = fbdepth = 1;
118 else if (!strcmp(argv[args], "--quiet"))
119 quiet = TRUE;
114 else if (!strncmp(argv[args], "--keymap=", 9)) { 120 else if (!strncmp(argv[args], "--keymap=", 9)) {
115 strncpy(keyboard_layout, argv[args] + 9 , 29); 121 strncpy(keyboard_layout, argv[args] + 9 , 29);
116 strcat(keyboard_layout, "\"\n"); 122 strcat(keyboard_layout, "\"\n");
117 } 123 }
118 else if (!strcmp(argv[args], "--list-keymaps")) { 124 else if (!strcmp(argv[args], "--list-keymaps")) {
319 break; 325 break;
320 } 326 }
321 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " BusID \"PCI:%d:%d:%d\"\n", bus, dev, func); 327 videolen -= snprintf(videobuf + strlen(videobuf), videolen, " BusID \"PCI:%d:%d:%d\"\n", bus, dev, func);
322 } 328 }
323 329
330 if(dump) {
331 printf("Dumping Debugging Information:\n");
332 printf("\tMachine ID:\t%s\n", macid);
333 if(edid_info == NULL)
334 printf("\tNo EDID Information present\n");
335 else
336 printf("\tEDID Tag:\t%s\n", eisaid);
337 printf("\tH-Min: %i H-Max: %i V-Min: %i V-Max: %i\n", sync.h_min, sync.h_max, sync.v_min, sync.v_max);
338 printf("\tCard Dump:\n");
339 printf("\t\tFramebuffer Id:\t\t%s\n", fix.id);
340 printf("\t\tFramebuffer Type:\t%i\n", fix.accel);
341 printf("\t\tFramebuffer Depth:\t%i\n", depth);
342 return 0;
343 }
344
324 /* Let's be nice and backup an existing xorg.conf */ 345 /* Let's be nice and backup an existing xorg.conf */
325 if ((f = fopen("/etc/X11/xorg.conf", "r"))) { 346 if ((f = fopen("/etc/X11/xorg.conf", "r"))) {
326 system("mv /etc/X11/xorg.conf /etc/X11/xorg.conf.autobak"); 347 system("mv /etc/X11/xorg.conf /etc/X11/xorg.conf.autobak");
348 if(!quiet)
327 printf("The current xorg.conf has been copied into /etc/X11/xorg.conf.autobak\n"); 349 printf("The current xorg.conf has been copied into /etc/X11/xorg.conf.autobak\n");
328 } 350 }
329 351
330 /* Check the permissions for writing */ 352 /* Check the permissions for writing */
331 if (!(f = fopen("/etc/X11/xorg.conf", "w"))) { 353 if (!(f = fopen("/etc/X11/xorg.conf", "w"))) {
488 fprintf(f, "%s", dri_section); 510 fprintf(f, "%s", dri_section);
489 /*** END Xorg.conf ***/ 511 /*** END Xorg.conf ***/
490 512
491 fclose(f); 513 fclose(f);
492 514
515 if(!quiet) {
493 fprintf(stdout, "Wrote /etc/X11/xorg.conf\n"); 516 fprintf(stdout, "Wrote /etc/X11/xorg.conf\n");
494 fprintf(stdout, "Please check the configuration file for additional options\n"); 517 fprintf(stdout, "Please check the configuration file for additional options\n");
518 }
495 519
496 return 0; 520 return 0;
497} 521}

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20