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

Contents of /Xorgautoconfig/Xorgautoconfig.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (hide annotations) (download) (as text)
Thu May 18 00:03:21 2006 UTC (8 years, 2 months ago) by josejx
Branch: MAIN
Changes since 1.19: +1 -21 lines
File MIME type: text/x-csrc
Modular X fixes, 0.2.4 release.

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

  ViewVC Help
Powered by ViewVC 1.1.20