All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][1/2] hda: enable unsolicited responses
@ 2005-07-01 15:48 Matt
  2005-07-01 15:55 ` [PATCH][2/2] hda: add sigmatel hp detect support Matt
  0 siblings, 1 reply; 3+ messages in thread
From: Matt @ 2005-07-01 15:48 UTC (permalink / raw)
  To: tiwai, alsa-devel

Patch enables unsolicited responses on the HDA controller. Without
the UREN bit set, the controller will not place unsolicited responses
in a RIRB.

Signed-off-by: Matt <matt@embeddedalley.com>

Index: alsa-kernel/pci/hda/hda_intel.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/hda/hda_intel.c,v
retrieving revision 1.12
diff -u -r1.12 hda_intel.c
--- alsa-kernel/pci/hda/hda_intel.c	13 Jun 2005 13:16:39 -0000	1.12
+++ alsa-kernel/pci/hda/hda_intel.c	1 Jul 2005 14:34:10 -0000
@@ -178,6 +178,9 @@
 #define ICH6_INT_CTRL_EN	0x40000000	/* controller interrupt enable bit */
 #define ICH6_INT_GLOBAL_EN	0x80000000	/* global interrupt enable bit */
 
+/* GCTL unsolicited response enable bit */
+#define ICH6_GCTL_UREN		(1<<8)
+
 /* GCTL reset bit */
 #define ICH6_GCTL_RESET		(1<<0)
 
@@ -562,6 +565,9 @@
 		return -EBUSY;
 	}
 
+	/* Accept unsolicited responses */
+	azx_writel(chip, GCTL, azx_readl(chip, GCTL) | ICH6_GCTL_UREN);
+
 	/* detect codecs */
 	if (! chip->codec_mask) {
 		chip->codec_mask = azx_readw(chip, STATESTS);


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

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

* [PATCH][2/2] hda: add sigmatel hp detect support
  2005-07-01 15:48 [PATCH][1/2] hda: enable unsolicited responses Matt
@ 2005-07-01 15:55 ` Matt
  2005-07-04 16:52   ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Matt @ 2005-07-01 15:55 UTC (permalink / raw)
  To: tiwai, alsa-devel

Adds support for detecting hp insertion/removal and enable/disable of
lineouts based on unsolicited events.

Signed-off-by: Matt <matt@embeddedalley.com>

Index: alsa-kernel/pci/hda/hda_codec.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/hda/hda_codec.h,v
retrieving revision 1.9
diff -u -r1.9 hda_codec.h
--- alsa-kernel/pci/hda/hda_codec.h	10 Jun 2005 18:58:24 -0000	1.9
+++ alsa-kernel/pci/hda/hda_codec.h	1 Jul 2005 15:38:08 -0000
@@ -262,6 +262,9 @@
 #define AC_PINCTL_OUT_EN		(1<<6)
 #define AC_PINCTL_HP_EN			(1<<7)
 
+/* Unsolicited response - 8bit */
+#define AC_USRSP_EN			(1<<7)
+
 /* configuration default - 32bit */
 #define AC_DEFCFG_SEQUENCE		(0xf<<0)
 #define AC_DEFCFG_DEF_ASSOC		(0xf<<4)
Index: alsa-kernel/pci/hda/patch_sigmatel.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/hda/patch_sigmatel.c,v
retrieving revision 1.5
diff -u -r1.5 patch_sigmatel.c
--- alsa-kernel/pci/hda/patch_sigmatel.c	30 Jun 2005 09:54:33 -0000	1.5
+++ alsa-kernel/pci/hda/patch_sigmatel.c	1 Jul 2005 15:38:11 -0000
@@ -36,6 +36,10 @@
 
 #undef STAC_TEST
 
+#define NUM_CONTROL_ALLOC	32
+#define STAC_HP_EVENT		0x37
+#define STAC_UNSOL_ENABLE 	(AC_USRSP_EN | STAC_HP_EVENT)
+
 struct sigmatel_spec {
 	snd_kcontrol_new_t *mixers[4];
 	unsigned int num_mixers;
@@ -507,8 +511,6 @@
 	return 0;
 }
 
-#define NUM_CONTROL_ALLOC	32
-
 enum {
 	STAC_CTL_WIDGET_VOL,
 	STAC_CTL_WIDGET_MUTE,
@@ -617,10 +619,18 @@
 	hda_nid_t pin = cfg->hp_pin;
 	hda_nid_t nid;
 	int i, err;
+	unsigned int wid_caps;
 
 	if (! pin)
 		return 0;
 
+	wid_caps = snd_hda_param_read(codec, pin, AC_PAR_AUDIO_WIDGET_CAP);
+	if (wid_caps & AC_WCAP_UNSOL_CAP)
+		/* Enable unsolicited responses on the HP widget */
+		snd_hda_codec_write(codec, pin, 0,
+				AC_VERB_SET_UNSOLICITED_ENABLE,
+				STAC_UNSOL_ENABLE);
+
 	nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
 	for (i = 0; i < cfg->line_outs; i++) {
 		if (! spec->multiout.dac_nids[i])
@@ -828,6 +838,53 @@
 	kfree(spec);
 }
 
+static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
+				unsigned int flag)
+{
+	unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
+			0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
+	snd_hda_codec_write(codec, nid, 0,
+			AC_VERB_SET_PIN_WIDGET_CONTROL,
+			pin_ctl | flag);
+}
+
+static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
+				  unsigned int flag)
+{
+	unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
+			0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
+	snd_hda_codec_write(codec, nid, 0,
+			AC_VERB_SET_PIN_WIDGET_CONTROL,
+			pin_ctl & ~flag);
+}
+
+static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
+{
+	struct sigmatel_spec *spec = codec->spec;
+	struct auto_pin_cfg *cfg = &spec->autocfg;
+	int i, presence;
+
+	if ((res >> 26) != STAC_HP_EVENT)
+		return;
+
+	presence = snd_hda_codec_read(codec, cfg->hp_pin, 0,
+			AC_VERB_GET_PIN_SENSE, 0x00) >> 31;
+
+	if (presence) {
+		/* disable lineouts, enable hp */
+		for (i = 0; i < cfg->line_outs; i++)
+			stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
+						AC_PINCTL_OUT_EN);
+		stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
+	} else {
+		/* enable lineouts, disable hp */
+		for (i = 0; i < cfg->line_outs; i++)
+			stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
+						AC_PINCTL_OUT_EN);
+		stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
+	}
+} 
+
 #ifdef CONFIG_PM
 static int stac92xx_resume(struct hda_codec *codec)
 {
@@ -851,6 +908,7 @@
 	.build_pcms = stac92xx_build_pcms,
 	.init = stac92xx_init,
 	.free = stac92xx_free,
+	.unsol_event = stac92xx_unsol_event,
 #ifdef CONFIG_PM
 	.resume = stac92xx_resume,
 #endif


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

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

* Re: [PATCH][2/2] hda: add sigmatel hp detect support
  2005-07-01 15:55 ` [PATCH][2/2] hda: add sigmatel hp detect support Matt
@ 2005-07-04 16:52   ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2005-07-04 16:52 UTC (permalink / raw)
  To: Matt; +Cc: alsa-devel

At Fri, 1 Jul 2005 08:55:31 -0700,
Matt wrote:
> 
> Adds support for detecting hp insertion/removal and enable/disable of
> lineouts based on unsolicited events.
> 
> Signed-off-by: Matt <matt@embeddedalley.com>

Thanks!  Both are applied to CVS now.


Takashi


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

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

end of thread, other threads:[~2005-07-04 16:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-01 15:48 [PATCH][1/2] hda: enable unsolicited responses Matt
2005-07-01 15:55 ` [PATCH][2/2] hda: add sigmatel hp detect support Matt
2005-07-04 16:52   ` Takashi Iwai

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.