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

Contents of /Xorgautoconfig/Xorgautoconfig.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (hide annotations) (download) (as text)
Wed Jul 20 20:11:10 2005 UTC (9 years, 3 months ago) by josejx
Branch: MAIN
Changes since 1.16: +1 -1 lines
File MIME type: text/x-csrc
Fixed usage of the wrong memory address.

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

  ViewVC Help
Powered by ViewVC 1.1.20