r1825 - in trunk: . doc packages packages/udev packages/xorg-udev-rules

alexander at linuxfromscratch.org alexander at linuxfromscratch.org
Sat Mar 24 05:06:14 PDT 2007


Author: alexander
Date: 2007-03-24 06:06:14 -0600 (Sat, 24 Mar 2007)
New Revision: 1825

Added:
   trunk/packages/xorg-udev-rules/
   trunk/packages/xorg-udev-rules/Makefile
   trunk/packages/xorg-udev-rules/extract_pci_ids.c
Removed:
   trunk/packages/udev/detect-video
Modified:
   trunk/Makefile
   trunk/doc/README
   trunk/packages/udev/Makefile
Log:
Added a program that extracts PCI IDs of supported video cards from Xorg
drivers and writes udev rules like this:

# ATI Radeon X850 PRO (R480) (AGP)
ATTR{vendor}=="0x1002", ATTR{device}=="0x4b4b", RUN+="/bin/sed -i s/vesa/ati/ /etc/X11/xorg.conf"

This way, video card autodetection is now fixed.


Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2007-03-24 10:47:05 UTC (rev 1824)
+++ trunk/Makefile	2007-03-24 12:06:14 UTC (rev 1825)
@@ -250,7 +250,7 @@
 	ch-freetype ch-fontconfig \
 	ch-Xorg-base ch-Xorg-util ch-Xorg-proto ch-Xorg-lib ch-libdrm ch-Mesa \
 	ch-xbitmaps ch-Xorg-app ch-xcursor-themes ch-xorg-server \
-	ch-Xorg-font ch-Xorg-driver ch-XML-Parser ch-xkeyboard-config \
+	ch-Xorg-font ch-Xorg-driver ch-xorg-udev-rules ch-XML-Parser ch-xkeyboard-config \
 	ch-synaptics ch-inputattach ch-915resolution ch-fonts-thai \
 	ch-freefont ch-fonts-dejavu ch-fonts-kochi ch-fonts-firefly ch-fonts-baekmuk \
 	ch-libjpeg ch-libtiff ch-openssh ch-glib2 ch-giflib ch-imlib ch-imlib2 \

Modified: trunk/doc/README
===================================================================
--- trunk/doc/README	2007-03-24 10:47:05 UTC (rev 1824)
+++ trunk/doc/README	2007-03-24 12:06:14 UTC (rev 1825)
@@ -83,11 +83,6 @@
 process may fail if you have more than one video card, if your video card
 doesn't support 24-bit color depth, or if your monitor is not Plug-n-Play
 compatible (in other words, doesn't tell its characteristics to Xorg via DDC).
-Also, in the following cases, the autodetection process is known to suggest
-a non-working driver even for 2D graphics:
-
-    * ATI Radeon X1000 or higher (needs the "vesa" driver)
-
 In such cases, you have to edit the /etc/X11/xorg.conf file manually, using
 vim, joe or nano.
 
@@ -119,6 +114,8 @@
 Section "Monitor"
 	Identifier	"Generic Monitor"
 	Option		"DPMS"
+	# Option	"NoDDC" # for broken monitors that
+				# report max dot clock = 0 MHz
 	HorizSync	30-92   # because gtf said "hsync: 91.38 kHz"
 	VertRefresh	56-86   # because a 85 Hz mode has been requested
 	# the Modeline may also be pasted here

Modified: trunk/packages/udev/Makefile
===================================================================
--- trunk/packages/udev/Makefile	2007-03-24 10:47:05 UTC (rev 1824)
+++ trunk/packages/udev/Makefile	2007-03-24 12:06:14 UTC (rev 1825)
@@ -41,8 +41,7 @@
 	cd $(CONFDIR) ; make install install-doc install-extra-doc
 	rm /etc/udev/rules.d/81-cdrom.rules
 	echo 'ACTION=="add", SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", IMPORT{program}="cdrom_id --export $tempnode", GROUP="cdrom"' >/etc/udev/rules.d/61-cdrom.rules
-	echo 'ACTION=="add", BUS=="pci", ATTR{class}=="0x030000", RUN+="detect-video"' >/etc/udev/rules.d/30-video.rules
-	install -m755 ../detect-video ../dhcp-helper /lib/udev
+	install -m755 ../dhcp-helper /lib/udev
 	install -m644 ../76-network.rules /etc/udev/rules.d/
 	install -m644 -D docs/writing_udev_rules/index.html \
 	 /usr/share/doc/$(DIR)/index.html

Deleted: trunk/packages/udev/detect-video
===================================================================
--- trunk/packages/udev/detect-video	2007-03-24 10:47:05 UTC (rev 1824)
+++ trunk/packages/udev/detect-video	2007-03-24 12:06:14 UTC (rev 1825)
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-SUB_VENDOR_ID=${PCI_SUBSYS_ID%:*}
-SUB_DEVICE_ID=${PCI_SUBSYS_ID#*:}
-
-VENDOR_ID=${PCI_ID%:*}
-DEVICE_ID=${PCI_ID#*:}
-
-X_DRIVER=`/usr/bin/getconfig.pl -b "0x$SUB_DEVICE_ID" -c 0x0300 \
-	-d "0x$DEVICE_ID" -s "0x$SUB_VENDOR_ID" -v "0x$VENDOR_ID" 2>/dev/null`
-if [ -n "$X_DRIVER" ] ; then
-	echo "Using \"$X_DRIVER\" as a video driver" >/dev/console
-	sed -i -e "s/vesa/$X_DRIVER/" /etc/X11/xorg.conf
-fi

Added: trunk/packages/xorg-udev-rules/Makefile
===================================================================
--- trunk/packages/xorg-udev-rules/Makefile	                        (rev 0)
+++ trunk/packages/xorg-udev-rules/Makefile	2007-03-24 12:06:14 UTC (rev 1825)
@@ -0,0 +1,33 @@
+# xorg udev rules Makefile
+
+NM= xorg-udev-rules
+
+# Targets
+
+chroot:
+	chroot "$(MP)" $(chenv-blfs) \
+	'cd $(ROOT) && make ch-$(NM) $(chbash-post-bash)'
+
+stage2: Makefile extract_pci_ids.c
+	make -f Makefile compile-$@ >$(NM).log 2>&1
+	make clean >>$(NM).log 2>&1
+	touch $@	
+
+compile-stage2:
+	nm -D /usr/bin/Xorg | egrep ' (B|D) ' | cut -d ' ' -f 3 | grep -v __ >symbols
+	for a in `cat symbols` ; do echo "char $$a[4096];" ; done >symbols.c
+	gcc -rdynamic -o extract_pci_ids extract_pci_ids.c symbols.c -ldl
+	echo '# Automatically generated rules, do not edit' >30-video.rules
+	echo 'SUBSYSTEM!="pci", GOTO="end_video"' >>30-video.rules
+	echo 'ATTR{class}!="0x030000", GOTO="end_video"' >>30-video.rules
+	echo '' >>30-video.rules
+	for a in /usr/lib/xorg/modules/drivers/*_drv.so ; do \
+	    echo $$a ; \
+	    ./extract_pci_ids $$a >>30-video.rules ; done
+	echo 'LABEL="end_video"' >>30-video.rules
+	install -m644 30-video.rules /etc/udev/rules.d
+
+clean:
+	rm -f extract_pci_ids symbols symbols.c 30-video.rules
+
+.PHONY: clean chroot compile-stage2

Added: trunk/packages/xorg-udev-rules/extract_pci_ids.c
===================================================================
--- trunk/packages/xorg-udev-rules/extract_pci_ids.c	                        (rev 0)
+++ trunk/packages/xorg-udev-rules/extract_pci_ids.c	2007-03-24 12:06:14 UTC (rev 1825)
@@ -0,0 +1,188 @@
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <xorg/xf86str.h>
+
+char driver_name[128];
+
+DriverPtr GetDriverRec(char *drvname, void *handle)
+{
+	char mdsym[128];
+	XF86ModuleData * md;
+	DriverRec *result;
+	sprintf(mdsym, "%sModuleData", drvname);
+	md = dlsym(handle, mdsym);
+	md->setup(&result, NULL, NULL, NULL);
+	return result;
+}
+
+void WriteUdevRule(const char *comment, int vendor, int device)
+{
+	if ((vendor == 0) || (vendor == 0xff) || (vendor == 0xffff))
+		return;
+	if ((device == 0) || (device == 0xffff))
+		return;
+	printf("# %s\n"
+		"ATTR{vendor}==\"0x%04x\", "
+		"ATTR{device}==\"0x%04x\", "
+		"RUN+=\"/bin/sed -i s/vesa/%s/ /etc/X11/xorg.conf\"\n\n",
+		comment, vendor, device, driver_name);
+}
+
+int main(int argc, char *argv[])
+{
+	void *handle;
+	char driver[128];
+	char drvname[128];
+	char *pos;
+	DriverPtr drv;
+
+	strcpy(driver, argv[1]);
+	strcpy(drvname, argv[1]);
+	pos = strstr(drvname, "_drv.so");
+	if (!pos) {
+		/* This file is not a driver */
+		return 0;
+	}
+	*pos = 0;
+	pos = strrchr(drvname, '/');
+	if (pos)
+		strcpy(driver_name, pos + 1);
+	else
+		/* dlopen would fail anyway */
+		return 0;
+
+	/* radeon and r128 should not be used directly,
+	   and sisusb is too different */
+	if (!strcmp(driver_name, "radeon"))
+		return 0;
+	if (!strcmp(driver_name, "r128"))
+		return 0;
+	if (!strcmp(driver_name, "sisusb"))
+		return 0;
+
+	handle = dlopen(driver, RTLD_LAZY);
+	if (!handle) {
+		/* this driver is not interesting anyway */
+		return 0;
+	}
+	drv = GetDriverRec(driver_name, handle);
+	if (!strcmp(driver_name, "nv")) {
+		drv->Identify(1);
+	} else if (!strcmp(driver_name, "ati")) {
+		Bool (*Probe)(struct _DriverRec *drv, int flags);
+		Probe = dlsym(handle, "R128Probe");
+		Probe(drv, 1);
+		Probe = dlsym(handle, "RADEONProbe");
+		Probe(drv, 1);
+	} else {
+		drv->Probe(drv, 1);
+	}
+	dlclose(handle);
+	return 0;
+}
+
+/* Stubs that are called by Xorg drivers from Probe and Identify functions */
+unsigned char byte_reversed[256];
+
+pointer XNFalloc(unsigned long amount)
+{
+	return malloc(amount);
+}
+
+unsigned short StandardMinorOpcode(void * client)
+{
+	return 1;
+}
+
+void xf86ErrorFVerb()
+{
+}
+
+void xf86AddDriver(DriverPtr drv, void * module, int unknown)
+{
+	DriverPtr *dest = module;
+	*dest = drv;
+}
+
+int xf86MatchDevice()
+{
+	return 1;
+}
+
+void * xf86GetPciVideoInfo()
+{
+	static void* dummy = NULL;
+	return &dummy;
+}
+
+void *xf86GetPciConfigInfo(void)
+{
+	static void* dummy = NULL;
+	return &dummy;
+}
+
+void LoaderRefSymLists(const char ** dummy, ...)
+{
+}
+
+void xf86LoaderRefSymLists(const char ** dummy, ...)
+{
+}
+
+void xf86MsgVerb(MessageType type, int verb, const char *format, ...)
+{
+}
+
+void Xfree(void * ptr)
+{
+}
+
+int xf86MatchPciInstances(const char *driverName, int vendorID,
+                      SymTabPtr chipsets, PciChipsets *PCIchipsets,
+                      GDevPtr *devList, int numDevs, DriverPtr drvp,
+                      int **foundEntities)
+{
+	const char *comment;
+	while (PCIchipsets->PCIid != -1) {
+		SymTabPtr chips = chipsets;
+		while (chips->token != -1) {
+			if (chips->token == PCIchipsets->numChipset)
+				comment = chips->name;
+			chips++;
+		}
+		if (!vendorID)
+			vendorID = PCIchipsets->PCIid >> 16;
+		WriteUdevRule(comment, vendorID, PCIchipsets->PCIid & 0xffff);
+		PCIchipsets++;
+	}
+	return 0;
+}
+
+void xf86PrintChipsets(const char *drvname, const char *drvmsg,
+                       SymTabPtr chips)
+{
+	while(chips->token != -1) {
+		WriteUdevRule(chips->name,
+		    chips->token >> 16, chips->token & 0xffff);
+		chips++;
+	}
+}
+
+int xf86MatchIsaInstances(const char *driverName, SymTabPtr chipsets,
+                          IsaChipsets *ISAchipsets, DriverPtr drvp,
+                          FindIsaDevProc FindIsaDevice, GDevPtr *devList,
+                          int numDevs, int **foundEntities)
+{
+	return 0;
+}
+
+pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name)
+{
+	return NULL;
+}
+
+Bool xf86ServerIsOnlyDetecting(void)
+{
+	return TRUE;
+}




More information about the livecd mailing list