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

Contents of /Xorgautoconfig/Xorgautoconfig.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (hide annotations) (download) (as text)
Sun Jun 26 03:37:42 2005 UTC (9 years, 2 months ago) by josejx
Branch: MAIN
Changes since 1.14: +39 -3 lines
File MIME type: text/x-csrc
Fixed nvidia segfaults and other more minor errors. New version.

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

  ViewVC Help
Powered by ViewVC 1.1.20