Skip to contentSkip to conversation

snd-aoa: headphone detection fix

PATCH Paul Collins 3 participants 3 messages Jun 27, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Johannes,

I took a look at tumbler.c and after it requests the headphone or lineout detection IRQ it sets a bit in the associated GPIO register. I added some code to snd-aoa to do something similar and now I get interrupts both on plug and unplug. Three each time, in fact. (I don't remember if this used to happen with snd-powermac.)

I also set the same bit in the linein-detect register on the assumption that it is handled in the same way. I have only been able to test headphone detection here on my PowerBook5,4 though.

sound/aoa/core/snd-aoa-gpio-feature.c +12 -0
index 2c6eb77..fa0606e 100644
@@ -289,6 +289,7 @@ static int ftr_set_notify(struct gpio_ru
 	struct gpio_notification *notif;
 	notify_func_t old;
 	int irq;
+	int gpio = -1;
 	char *name;
 	int err = -EBUSY;
 
@@ -297,16 +298,19 @@ static int ftr_set_notify(struct gpio_ru
 		notif = &rt->headphone_notify;
 		name = "headphone-detect";
 		irq = headphone_detect_irq;
+		gpio = headphone_detect_gpio;
 		break;
 	case AOA_NOTIFY_LINE_IN:
 		notif = &rt->line_in_notify;
 		name = "linein-detect";
 		irq = linein_detect_irq;
+		gpio = linein_detect_gpio;
 		break;
 	case AOA_NOTIFY_LINE_OUT:
 		notif = &rt->line_out_notify;
 		name = "lineout-detect";
 		irq = lineout_detect_irq;
+		gpio = lineout_detect_gpio;
 		break;
 	default:
 		return -EINVAL;
@@ -337,6 +341,14 @@ static int ftr_set_notify(struct gpio_ru
 		err = request_irq(irq, ftr_handle_notify_irq, 0, name, notif);
 		if (err)
 			goto out_unlock;
+
+		/* Activate status interrupts. */
+		if (gpio > -1) {
+			int v;
+			v = pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio, 0);
+			v |= 0x80;
+			pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, gpio, v);
+		}
 	}
 
 	notif->notify = notify;
Signature · 9 lines
Paul Collins
Melbourne, Australia

Dag vijandelijk luchtschip de huismeester is dood

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
#1 lore raw

At Tue, 27 Jun 2006 20:00:40 +1000,

Quoted 48 lines · Paul Collins

Hi Johannes,

I took a look at tumbler.c and after it requests the headphone or lineout detection IRQ it sets a bit in the associated GPIO register. I added some code to snd-aoa to do something similar and now I get interrupts both on plug and unplug. Three each time, in fact. (I don't remember if this used to happen with snd-powermac.)

I also set the same bit in the linein-detect register on the assumption that it is handled in the same way. I have only been able to test headphone detection here on my PowerBook5,4 though.

sound/aoa/core/snd-aoa-gpio-feature.c +4 -0
index 2c6eb77..fa0606e 100644
@@ -289,6 +289,7 @@ static int ftr_set_notify(struct gpio_ru
 	struct gpio_notification *notif;
 	notify_func_t old;
 	int irq;
+	int gpio = -1;
 	char *name;
 	int err = -EBUSY;
 
@@ -297,16 +298,19 @@ static int ftr_set_notify(struct gpio_ru
 		notif = &rt->headphone_notify;
 		name = "headphone-detect";
 		irq = headphone_detect_irq;
+		gpio = headphone_detect_gpio;
 		break;
 	case AOA_NOTIFY_LINE_IN:
 		notif = &rt->line_in_notify;
 		name = "linein-detect";
 		irq = linein_detect_irq;
+		gpio = linein_detect_gpio;
 		break;
 	case AOA_NOTIFY_LINE_OUT:
 		notif = &rt->line_out_notify;
 		name = "lineout-detect";
 		irq = lineout_detect_irq;
+		gpio = lineout_detect_gpio;
 		break;
 	default:
 		return -EINVAL;

sound/aoa/core/snd-aoa-gpio-feature.c static int ftr_set_notify(struct gpio_ru · line 346

Quoted 6 lines
sound/aoa/core/snd-aoa-gpio-feature.c +3 -0
@@ -337,6 +341,14 @@ static int ftr_set_notify(struct gpio_ru
 		err = request_irq(irq, ftr_handle_notify_irq, 0, name, notif);
 		if (err)
 			goto out_unlock;
+
+		/* Activate status interrupts. */
+		if (gpio > -1) {

Do you need this check here? All three cases are covered, so gpio = -1 shouldn't happen...

Takashi

Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

maintainer
#2 lore raw
In reply to Paul Collins

Hi,

Quoted 5 lines

I took a look at tumbler.c and after it requests the headphone or lineout detection IRQ it sets a bit in the associated GPIO register. I added some code to snd-aoa to do something similar and now I get interrupts both on plug and unplug. Three each time, in fact. (I don't remember if this used to happen with snd-powermac.)

Nice detective work :) Unfortunately my mail server had crashed or you'd have gotten a patch for this already, but I'm fairly sure that mine is correct too. Would you try please?

johannes

Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel