[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: xviddetect for sparc (was: Re: autodectection of modules at boot time)



Randolph Chung wrote:
> Thanks Eric!
> 
> I'm working with Branden on a X install/config script. Hopefully I'll have
> something ready by the end of today or tomorrow.

After looking at what the kernel does to find the names of framebuffers on
sparc, I modified the script to look in the whole OpenPROM tree: in effect,
some cards are installed at the top (like Creator ones), others under the obio
subtree (CG14) or the sbus or iommu/sbus.
It is therefore more simple to look everywhere for a device_type file that
contains the keyword 'display'.
I also reworked the video ids database for sparc based on the ids I discovered
in kernel sources.

I hope this patch is working better than my old one.
Regards.

-- 
 Eric Delaunay                 | "La guerre justifie l'existence des militaires.
 delaunay@lix.polytechnique.fr | En les supprimant." Henri Jeanson (1900-1970)
diff -uNr xviddetect-0.2.orig/video.ids xviddetect-0.2/video.ids
--- xviddetect-0.2.orig/video.ids	Sat Aug 21 22:36:27 1999
+++ xviddetect-0.2/video.ids	Sun Oct 24 23:11:00 1999
@@ -117,3 +117,16 @@
 s3v|all|53338c01|S3 Inc.|ViRGE/MX
 s3v|all|53338c02|S3 Inc.|ViRGE/MX+
 s3v|all|53338c03|S3 Inc.|ViRGE/MX+MV
+xsun-mono|sparc|bwtwo|Sun|BW2 Monochrome Sun framebuffer
+xsun|sparc|cgtwo|Sun|CG2 8-bit framebuffer
+xsun|sparc|cgthree|Sun|CG3 8-bit framebuffer
+xsun|sparc|cgRDI|Sun|CG3 8-bit framebuffer
+xsun|sparc|cgfour|Sun|CG4 8-bit framebuffer
+xsun|sparc|cgthree+|Sun|CG6 8-bit framebuffer (GX, GX+, TurboGX, TurboGX+)
+xsun|sparc|cgsix|Sun|CG6 8-bit framebuffer (GX, GX+, TurboGX, TurboGX+)
+xsun|sparc|tcx|Sun|TCX framebuffer in 8-bit color mode
+xsun24|sparc|tcx|Sun|TCX framebuffer in 24-bit color mode
+xsun24|sparc|cgeight|Sun|CG8 24-bit framebuffer
+xsun24|sparc|cgfourteen|Sun|CG14 24-bit framebuffer
+xsun24|sparc|SUNW,ffb|Sun|Creator/Creator3D 24-bit framebuffer
+xsun24|sparc|SUNW,afb|Sun|Creator/Creator3D 24-bit framebuffer
diff -uNr xviddetect-0.2.orig/xviddetect xviddetect-0.2/xviddetect
--- xviddetect-0.2.orig/xviddetect	Tue Aug 31 06:11:25 1999
+++ xviddetect-0.2/xviddetect	Sun Oct 24 23:13:00 1999
@@ -15,6 +15,7 @@
 
 sub GetArch {
   my $arch = `uname -m`;
+  chop $arch;
   
   $arch = 'i386' if ($arch =~ /^i\d86/);
   return $arch;
@@ -65,6 +66,9 @@
   return;
   
 oldpci:
+  # no report of error on sparc (could be an sbus machine)
+  return if ($arch eq "sparc");
+
   print "Cannot open $pcidevice. You probably have an old kernel. Support\n";
   print "for the old Linux PCI interface should be coming soon\n\n";
   exit 0;
@@ -94,6 +98,53 @@
   close F;
 }
 
+# Read the SPARC SBus configuration to fill the device list with detected
+# display devices.
+sub SBUSlookup {
+  my $dir=shift;
+  my $dev;
+  # Process through all subdirs to find entries with device_type=display.
+  # Reports such entries in @devices.
+  # Note: to know whether a dir entry is a device subdir, we cannot use -d $_.
+  # It simply doesn't work with openpromfs :(  One alternative is to looking
+  # for an '@' in the name (device@x,y)
+  if (opendir(D, $dir)) {
+    my @contents = grep { s:(.*@):$dir/\1: } readdir(D);
+    closedir D;
+    foreach $dev (@contents) {
+      # Each device subdir may contains 2 files named device_type & name. The
+      # former is telling the type of device (eg. 'display' for a graphic card)
+      # and the latter gives his name ('cgthree', ...).
+      if (open(G, "<$dev/device_type")) {
+	my $id = <G>;
+	chop $id;
+	close G;
+	# a display device is refered as such in the device_type file
+	if ($id eq "'display'") {
+	  if (open(G, "<$dev/name")) {
+	    # get the name of the device (remove surrounding quotes)
+	    $id = <G>;
+	    chop $id;
+	    $id =~ s/'//g;
+	    # register this device in the database
+	    push @devices, $id;
+	  }
+	}
+      }
+      &SBUSlookup($dev);
+    }
+  }
+}
+
+sub ReadSBUS {
+  my $dir;
+  my $dev;
+  # first check for openpromfs
+  -f "/proc/openprom/.node" || die "This system is lacking openpromfs support.";
+  # then parse the tree to looking at display type entries
+  SBUSlookup("/proc/openprom");
+}
+
 sub Help {
   print <<EOF;
 video.pl [--arch <architecture>] [--help]
@@ -118,6 +169,7 @@
 &ReadVideoIDs;
 &ReadPCIIDs;
 &ReadPCI;
+&ReadSBUS if $arch eq "sparc";
 
 if (!$quiet) {
   print "Your architecture seems to be $arch.\n";

Reply to: