List Info

Thread: do not attach adb legacy devices on recent macppc laptops




do not attach adb legacy devices on recent macppc laptops
user name
2006-05-27 13:36:28
Recent Apple laptops (no, not the intel-based ones) have
their on-board
keyboard and trackpad reporting itself both an adb and an
usb device;
this is probably for compatibility with old macos
applications and
whatnot.

Because of this, OpenBSD will attach keyboard and mouse
drivers to both
adb and usb instances, and the adb driver will basically
never get any
input. This works, but this can be confusing to the user
(especially
when trying to change the keyboard layout).

The following diff tries to decide, at adb probing time,
whether we are
running on one of those machines or not; and if we think
there will be
usb devices later, we do not bother probing for adb devices
(yet we
still need to initialize the adb code as it is used for
other things).

I would like this diff tested on as many macppc machines as
possible.
Please report your results (either good or "I don't
see my keyboard at
all anymore" or "my keyboard is now
unresponsive") directly to me, with
a complete dmesg.

Thanks!

Miod

(apply in sys/arch/macppc/dev)
Index: adb.c
============================================================
=======
RCS file: /cvs/src/sys/arch/macppc/dev/adb.c,v
retrieving revision 1.19
diff -u -p -r1.19 adb.c
--- adb.c	2006/03/07 20:00:18	1.19
+++ adb.c	2006/05/27 13:19:10
 -1635,6
+1635,7  adbattach(struct device *parent, struct 
 	struct adb_attach_args aa_args;
 	int totaladbs;
 	int adbindex, adbaddr;
+	u_int kid_ex;
 
 	ca->ca_reg[0] += ca->ca_baseaddr;
 
 -1643,22
+1644,45  adbattach(struct device *parent, struct 
 
 	if (strcmp(ca->ca_name, "via-cuda") == 0)
 		adbHardware = ADB_HW_CUDA;
-	else if (strcmp(ca->ca_name, "via-pmu") ==
0) {
+	else /* if (strcmp(ca->ca_name, "via-pmu")
== 0) */
 		adbHardware = ADB_HW_PMU;
 
-		/*
-		 * Bus reset can take a long time if no adb devices are
-		 * connected, e.g. on a Mac Mini; so check for an adb
-		 * child in the OF tree to speed up pm_adb_op().
-		 */
-		adbempty = 1;
-		for (node = OF_child(ca->ca_node); node; node =
OF_peer(node)) {
+	printf(" irq %d: %s", ca->ca_intr[0],
ca->ca_name);
+
+	/*
+	 * Bus reset can take a long time if no adb devices are
+	 * connected, e.g. on a Mac Mini; so check for an adb
+	 * child in the OF tree to speed up pm_adb_op().
+	 */
+	adbempty = 1;
+	for (node = OF_child(ca->ca_node); node; node =
OF_peer(node)) {
+		if (OF_getprop(node, "name", name, sizeof
name) <= 0)
+			continue;
+		if (strcmp(name, "adb") == 0) {
+			adbempty = 0;
+			break;
+		}
+	}
+
+	/*
+	 * If there are adb devices, check whether they will also
appear
+	 * as usb devices later on the OF device tree walk; if so,
we
+	 * will not try and attach children.
+	 * From empirical evidence systems where the adb devices
are shadowed
+	 * by usb devices have a nonzero
``keyboard-id-extension'' property
+	 * for the adb/keyboard node.
+	 */
+	kid_ex = 0;
+	if (node != NULL) {
+		for (node = OF_child(node); node; node = OF_peer(node)) {
+			/* XXX prefer "device_type" property? */
 			if (OF_getprop(node, "name", name, sizeof
name) <= 0)
 				continue;
-			if (strcmp(name, "adb") == 0) {
-				adbempty = 0;
+			if (strcmp(name, "keyboard") != 0)
+				continue;
+			if (OF_getprop(node,
"keyboard-id-extension", &kid_ex,
+			    sizeof kid_ex) <= 0)
 				break;
-			}
 		}
 	}
 
 -1676,30
+1700,37  adbattach(struct device *parent, struct 
 	if (adb_debug)
 		printf("adb: done with adb_reinit\n");
 #endif
-	totaladbs = count_adbs();
 
-	printf(" irq %d: %s, %d target%s\n",
ca->ca_intr[0], ca->ca_name,
-	    totaladbs, (totaladbs == 1) ? "" :
"s");
+	if (kid_ex == 0) {
+		totaladbs = count_adbs();
 
-	/* for each ADB device */
-	for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
-		/* Get the ADB information */
-		adbaddr = get_ind_adb_info(&adbdata, adbindex);
+		printf(", %d target%s\n",
+		    totaladbs, (totaladbs == 1) ? "" :
"s");
 
-		aa_args.origaddr = adbdata.origADBAddr;
-		aa_args.adbaddr = adbaddr;
-		aa_args.handler_id = adbdata.devType;
+		/* for each ADB device */
+		for (adbindex = 1; adbindex <= totaladbs; adbindex++)
{
+			/* Get the ADB information */
+			adbaddr = get_ind_adb_info(&adbdata, adbindex);
+
+			aa_args.origaddr = adbdata.origADBAddr;
+			aa_args.adbaddr = adbaddr;
+			aa_args.handler_id = adbdata.devType;
 
-		(void)config_found(self, &aa_args, adbprint);
+			(void)config_found(self, &aa_args, adbprint);
+		}
+	} else {
+		printf(", shadowed\n");
 	}
 
 #if NAPM > 0
 	/* Magic for signalling the apm driver to match. */
-	aa_args.origaddr = ADBADDR_APM;
-	aa_args.adbaddr = ADBADDR_APM;
-	aa_args.handler_id = ADBADDR_APM;
+	if (adbHardware == ADB_HW_PMU) {
+		aa_args.origaddr = ADBADDR_APM;
+		aa_args.adbaddr = ADBADDR_APM;
+		aa_args.handler_id = ADBADDR_APM;
 
-	(void)config_found(self, &aa_args, NULL);
+		(void)config_found(self, &aa_args, NULL);
+	}
 #endif
 
 	if (adbHardware == ADB_HW_CUDA)

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )