All of lore.kernel.org
 help / color / mirror / Atom feed
* snd-aoa: headphone detection fix
@ 2006-06-27 10:00 Paul Collins
  2006-06-27 12:41 ` Takashi Iwai
  2006-06-27 17:43 ` Johannes Berg
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Collins @ 2006-06-27 10:00 UTC (permalink / raw)
  To: johannes; +Cc: alsa-devel

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.

Signed-off-by: Paul Collins <paul@ondioline.org>

diff --git a/sound/aoa/core/snd-aoa-gpio-feature.c b/sound/aoa/core/snd-aoa-gpio-feature.c
index 2c6eb77..fa0606e 100644
--- a/sound/aoa/core/snd-aoa-gpio-feature.c
+++ b/sound/aoa/core/snd-aoa-gpio-feature.c
@@ -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;

-- 
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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: snd-aoa: headphone detection fix
  2006-06-27 10:00 snd-aoa: headphone detection fix Paul Collins
@ 2006-06-27 12:41 ` Takashi Iwai
  2006-06-27 17:43 ` Johannes Berg
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2006-06-27 12:41 UTC (permalink / raw)
  To: Paul Collins; +Cc: johannes, alsa-devel

At Tue, 27 Jun 2006 20:00:40 +1000,
Paul Collins wrote:
> 
> 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.
> 
> Signed-off-by: Paul Collins <paul@ondioline.org>
> 
> diff --git a/sound/aoa/core/snd-aoa-gpio-feature.c b/sound/aoa/core/snd-aoa-gpio-feature.c
> index 2c6eb77..fa0606e 100644
> --- a/sound/aoa/core/snd-aoa-gpio-feature.c
> +++ b/sound/aoa/core/snd-aoa-gpio-feature.c
> @@ -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) {

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: snd-aoa: headphone detection fix
  2006-06-27 10:00 snd-aoa: headphone detection fix Paul Collins
  2006-06-27 12:41 ` Takashi Iwai
@ 2006-06-27 17:43 ` Johannes Berg
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2006-06-27 17:43 UTC (permalink / raw)
  To: Paul Collins; +Cc: alsa-devel


[-- Attachment #1.1: Type: text/plain, Size: 544 bytes --]

Hi,

> 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

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 793 bytes --]

[-- Attachment #2: Type: text/plain, Size: 299 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 161 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-06-27 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-27 10:00 snd-aoa: headphone detection fix Paul Collins
2006-06-27 12:41 ` Takashi Iwai
2006-06-27 17:43 ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.