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

Diff of /Xorgautoconfig/Xorgautoconfig.c

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

Revision 1.5 Revision 1.6
70 unsigned char *mem; 70 unsigned char *mem;
71 char *macid; 71 char *macid;
72 char *eisaid; 72 char *eisaid;
73 char keyboard_layout[32]; 73 char keyboard_layout[32];
74 memset(keyboard_layout, 0, 32); 74 memset(keyboard_layout, 0, 32);
75 DIR *testdir; 75
76 char path[256]; 76 DIR *testdir; /* Test if path is a directory */
77 char path[256]; /* Font Path */
78 char videobuf[MAX_VIDEO_LEN]; /* Video Card Device section */
79 int videolen = MAX_VIDEO_LEN - 1; /* How many chars we have left */
80 char dri = FALSE; /* DRI on or off */
77 81
78 if (!(fd = open(name, O_RDONLY))) 82 if (!(fd = open(name, O_RDONLY)))
79 rc = 2; /* Failure */ 83 rc = 2; /* Failure */
80 84
81 if (!rc && ioctl(fd, FBIOGET_FSCREENINFO, &fix)) 85 if (!rc && ioctl(fd, FBIOGET_FSCREENINFO, &fix))
205 if (!strncmp(fix.id, "OFfb", 4)) 209 if (!strncmp(fix.id, "OFfb", 4))
206 offb = 1; 210 offb = 1;
207 } 211 }
208 212
209 findVideoDevice(); /* For BusID */ 213 findVideoDevice(); /* For BusID */
214
215 /* Work out the card specifics to figure out if we need DRI, etc. */
216 depth = 16;
217 if (nv) {
218 if (!strncmp(macid, "PowerMac4,2", 11) || !strncmp(macid, "PowerMac4,5", 11))
219 fprintf(f, " Option \"FlatPanel\"\n");
220 videolen -= snprintf(videobuf, videolen, "%s", driver_nv);
221 videolen -= snprintf(videobuf, videolen, " Driver\t\"nv\"\n");
222 dri = FALSE;
223 } else if((fbdev) || (bus == 0 && dev == 0 && func == 0)) {
224 if (!fbdev) {
225 videolen -= snprintf(videobuf, videolen, " # We couldn't determine the BusID of your ");
226 videolen -= snprintf(videobuf, videolen, "video card. So we will use\n# the fbdev driver\n");
227 }
228 videolen -= snprintf(videobuf, videolen, " #Option \"ShadowFB\" \"true\"\n");
229 videolen -= snprintf(videobuf, videolen, " #Option \"fbdev\" \"%s\"\n", name);
230 videolen -= snprintf(videobuf, videolen, " Driver\t\"fbdev\"\n");
231 videolen -= snprintf(videobuf, videolen, " #BusID \"0:0:0\"\n");
232 depth = 15;
233 dri = FALSE;
234 } else {
235 /* Try and guess what video card is behind /dev/fb0 */
236 switch(fix.accel) {
237 /* ATI Mach64 Family cards */
238 case 6:
239 case 8:
240 case 9:
241 case 10:
242 videolen -= snprintf(videobuf, videolen, "%s", driver_on_opts);
243 videolen -= snprintf(videobuf, videolen, " Driver\t\"ati\"\n");
244 dri = FALSE; /* Can this be enabled? */
245 break;
246 /* IMS Twin Turbo */
247 case 14:
248 videolen -= snprintf(videobuf, videolen, "%s", driver_off_opts);
249 videolen -= snprintf(videobuf, videolen, " Driver\t\"imstt\"\n");
250 dri = FALSE; /* Can this be enabled? */
251 break;
252 /* Matrox Family */
253 case 16:
254 case 17:
255 case 18:
256 case 20:
257 case 21:
258 case 26:
259 videolen -= snprintf(videobuf, videolen, "%s", driver_off_opts);
260 videolen -= snprintf(videobuf, videolen, " Driver\t\"mga\"\n");
261 dri = FALSE; /* Can this be enabled? */
262 break;
263 /* Chips&Technology 6555x */
264 /* Is this still broken?
265 case 30:
266 videolen -= snprintf(videobuf, videolen, "%s", driver_off_opts);
267 videolen -= snprintf(videobuf, videolen, " Driver\t\"chips\"\n");
268 dri = FALSE;
269 break;
270 */
271 /* VooDoo 3 / Banshee */
272 case 31:
273 videolen -= snprintf(videobuf, videolen, "%s", driver_off_opts);
274 videolen -= snprintf(videobuf, videolen, " Driver\t\"tdfx\"\n");
275 dri = FALSE; /* Can this be enabled? */
276 break;
277 /* ATI Rage 128 Family */
278 case 32:
279 videolen -= snprintf(videobuf, videolen, "%s", driver_r128);
280 videolen -= snprintf(videobuf, videolen, " Driver\t\"r128\"\n");
281 dri = TRUE;
282 break;
283 /* ATI Radeon */
284 /* FIXME what are the values for radeon > 9200? */
285 case 38:
286 videolen -= snprintf(videobuf, videolen, "%s", driver_radeon);
287 if(!strncmp(macid + 5, "Pegasos", 7))
288 videolen -= snprintf(videobuf, videolen, "%s", "\tOption\t\"BusType\"\t\"PCI\"");
289 videolen -= snprintf(videobuf, videolen, " Driver\t\"radeon\"\n");
290 dri = TRUE;
291 break;
292 default:
293 /* FIXME still broken? */
294 /* radeon seems to be broken on VE (aka 7000) */
295 if ((!strncmp(fix.id, "ATI Radeon", 10)) &&
296 (strncmp(fix.id, "ATI Radeon VE", 13))) {
297 videolen -= snprintf(videobuf, videolen, "%s", driver_radeon);
298 if(!strncmp(macid + 5, "Pegasos", 7))
299 videolen -= snprintf(videobuf, videolen, "%s", "\tOption\t\"BusType\"\t\"PCI\"");
300 videolen -= snprintf(videobuf, videolen, " Driver\t\"radeon\"\n");
301 dri = TRUE;
302 } else if (!strncmp(fix.id, "Rage128", 7)) {
303 videolen -= snprintf(videobuf, videolen, "%s", driver_r128);
304 videolen -= snprintf(videobuf, videolen, " Driver\t\"r128\"\n");
305 dri = TRUE;
306 } else if (!strncmp(fix.id, "Rage Mobility M3", 16)) {
307 videolen -= snprintf(videobuf, videolen, "%s", driver_r128);
308 videolen -= snprintf(videobuf, videolen, " Driver\t\"r128\"\n");
309 dri = TRUE;
310 } else {
311 videolen -= snprintf(videobuf, videolen, " #Option \"ShadowFB\" \"true\"\n");
312 videolen -= snprintf(videobuf, videolen, " Driver\t\"fbdev\"\n");
313 dri = FALSE;
314 depth = 15;
315 }
316 break;
317 }
318 videolen -= snprintf(videobuf, videolen, " BusID \"PCI:%d:%d:%d\"\n", bus, dev, func);
319 }
210 320
211 /* Let's be nice and backup an existing xorg.conf */ 321 /* Let's be nice and backup an existing xorg.conf */
212 if ((f = fopen("/etc/X11/xorg.conf", "r"))) { 322 if ((f = fopen("/etc/X11/xorg.conf", "r"))) {
213 system("mv /etc/X11/xorg.conf /etc/X11/xorg.conf.autobak"); 323 system("mv /etc/X11/xorg.conf /etc/X11/xorg.conf.autobak");
214 printf("The current xorg.conf has been copied into /etc/X11/xorg.conf.autobak\n"); 324 printf("The current xorg.conf has been copied into /etc/X11/xorg.conf.autobak\n");
255 fprintf(f, "%s", fontpath_gentoo); 365 fprintf(f, "%s", fontpath_gentoo);
256 } 366 }
257 fprintf(f, "EndSection\n\n"); 367 fprintf(f, "EndSection\n\n");
258 368
259 /* modules section */ 369 /* modules section */
370 fprintf(f, "%s", modules_section_start);
371 if(!dri) fprintf(f, "%s", "#");
260 fprintf(f, "%s", modules_section); 372 fprintf(f, "%s", modules_section_end);
261 373
262 /* extensions section */ 374 /* extensions section */
263 fprintf(f, "%s", extensions_section); 375 fprintf(f, "%s", extensions_section);
264 376
265 /* serverflags section */ 377 /* serverflags section */
267 379
268 /* input dev section */ 380 /* input dev section */
269 fprintf(f, "%s", inputdev_section); 381 fprintf(f, "%s", inputdev_section);
270 382
271 /* keyboard */ 383 /* keyboard */
272
273 if(0 == keyboard_layout[0]) 384 if(0 == keyboard_layout[0])
274 strcpy(keyboard_layout, "us\"\n"); 385 strcpy(keyboard_layout, "us\"\n");
275 fprintf(f, "%s", keyboard_linux_start); 386 fprintf(f, "%s", keyboard_linux_start);
276 fprintf(f, "%s", keyboard_layout); 387 fprintf(f, "%s", keyboard_layout);
277 fprintf(f, "%s", keyboard_linux_end); 388 fprintf(f, "%s", keyboard_linux_end);
333 fprintf(f, " Composite"); 444 fprintf(f, " Composite");
334 if (var.sync & FB_SYNC_BROADCAST) 445 if (var.sync & FB_SYNC_BROADCAST)
335 fprintf(f, " bcast"); 446 fprintf(f, " bcast");
336 } 447 }
337 fprintf(f, "%s", device_start); 448 fprintf(f, "%s", device_start);
338 depth = 16;
339
340 /* See if we know where the card is, if not... */
341 if (nv) {
342 if (!strncmp(macid, "PowerMac4,2", 11) || !strncmp(macid, "PowerMac4,5", 11))
343 fprintf(f, " Option \"FlatPanel\"\n");
344 fprintf(f, "%s", driver_nv); 449 fprintf(f, "%s", videobuf);
345 fprintf(f, " Driver\t\"nv\"\n");
346 } else if((fbdev) || (bus == 0 && dev == 0 && func == 0)) {
347 if (!fbdev) {
348 fprintf(f, " # We couldn't determine the BusID of your ");
349 fprintf(f, "video card. So we will use\n# the fbdev driver\n");
350 }
351 fprintf(f, " #Option \"ShadowFB\" \"true\"\n");
352 fprintf(f, " #Option \"fbdev\" \"%s\"\n", name);
353 fprintf(f, " Driver\t\"fbdev\"\n");
354 fprintf(f, " #BusID \"0:0:0\"\n");
355 depth = 15;
356 } else {
357 /* Try and guess what video card is behind /dev/fb0 */
358 switch(fix.accel) {
359 /* ATI Mach64 Family cards */
360 case 6:
361 case 8:
362 case 9:
363 case 10:
364 fprintf(f, "%s", driver_on_opts);
365 fprintf(f, " Driver\t\"ati\"\n");
366 break;
367 /* IMS Twin Turbo */
368 case 14:
369 fprintf(f, "%s", driver_off_opts);
370 fprintf(f, " Driver\t\"imstt\"\n");
371 break;
372 /* Matrox Family */
373 case 16:
374 case 17:
375 case 18:
376 case 20:
377 case 21:
378 case 26:
379 fprintf(f, "%s", driver_off_opts);
380 fprintf(f, " Driver\t\"mga\"\n");
381 break;
382 /* Chips&Technology 6555x */
383 /* Apparently this is broken...
384 case 30:
385 fprintf(f, "%s", driver_off_opts);
386 fprintf(f, " Driver\t\"chips\"\n");
387 break;
388 */
389 /* VooDoo 3 / Banshee */
390 case 31:
391 fprintf(f, "%s", driver_off_opts);
392 fprintf(f, " Driver\t\"tdfx\"\n");
393 break;
394 /* ATI Rage 128 Family */
395 case 32:
396 fprintf(f, "%s", driver_r128);
397 fprintf(f, " Driver\t\"r128\"\n");
398 break;
399 /* ATI Radeon */
400 case 38:
401 fprintf(f, "%s", driver_radeon);
402 fprintf(f, " Driver\t\"radeon\"\n");
403 break;
404 default:
405 /* FIXME still broken? */
406 /* radeon seems to be broken on VE (aka 7000) */
407 if ((!strncmp(fix.id, "ATI Radeon", 10)) &&
408 (strncmp(fix.id, "ATI Radeon VE", 13))) {
409 fprintf(f, "%s", driver_radeon);
410 fprintf(f, " Driver\t\"radeon\"\n");
411 } else if (!strncmp(fix.id, "Rage128", 7)) {
412 fprintf(f, "%s", driver_r128);
413 fprintf(f, " Driver\t\"r128\"\n");
414 } else if (!strncmp(fix.id, "Rage Mobility M3", 16)) {
415 fprintf(f, "%s", driver_r128);
416 fprintf(f, " Driver\t\"r128\"\n");
417 } else {
418 fprintf(f, " #Option \"ShadowFB\"");
419 fprintf(f, " \"true\"\n");
420 fprintf(f, " Driver\t\"fbdev\"\n");
421 depth = 15;
422 }
423 break;
424 }
425 fprintf(f, " BusID \"PCI:%d:%d:%d\"\n", bus, dev, func);
426 }
427 fprintf(f, "%s", screen_section); 450 fprintf(f, "%s", screen_section);
428 fprintf(f, "%d\n", depth); 451 fprintf(f, "%d\n", depth);
429 if(fbdepth && depth != var.bits_per_pixel) 452 if(fbdepth && depth != var.bits_per_pixel)
430 fprintf(f," DefaultFbBpp %d\n", var.bits_per_pixel); 453 fprintf(f," DefaultFbBpp %d\n", var.bits_per_pixel);
431 454

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.20