Skip to contentSkip to conversation

Use generic parser for HD-audio codec drivers

RFC PATCH In review Takashi Iwai 2 participants 11 messages Jan 8, 2013 – Jan 10, 2013 Sound

lore
Share & tools
lore
#0 lore raw

cover Use generic parser for HD-audio codec drivers

Hi,

this is the next series of patches to convert various codec drivers to use the new generic parser code. Most of changes are obvious, but some places it gets tricky.

As mentioned in another mail, the patches are found in sound-unstable git tree test/hda-migrate branch
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-unstable.git

Takashi

#1 lore raw

PATCH 1/8 ALSA: hda - Use generic parser for Cirrus codec driver

This time, the target is Cirrus codec. Its parser is a subset of generic parser, so we can migrate fully with it now.

The only tricky part is the handling of SPDIF automute. Cirrus driver sets the SPDIF out plug over the headphone. As a workaround, set spec->gen.master_mute for toggling the headphone (and other) mute.

---
 sound/pci/hda/Kconfig        |    1 +
 sound/pci/hda/patch_cirrus.c | 1323 ++++--------------------------------------
 2 files changed, 117 insertions(+), 1207 deletions(-)
sound/pci/hda/Kconfig +1 -0
index ebec1b7..93404d7 100644
@@ -150,6 +150,7 @@ config SND_HDA_CODEC_CIRRUS
 	bool "Build Cirrus Logic codec support"
 	depends on SND_HDA_INTEL
 	default y
+	select SND_HDA_GENERIC
 	help
 	  Say Y here to include Cirrus Logic codec support in
 	  snd-hda-intel driver, such as CS4206.
sound/pci/hda/patch_cirrus.c +116 -1207

1,549 lines not on this page · raw message

Signature · 1 line
1.8.0.1
#2 lore raw

PATCH 2/8 ALSA: hda - Use generic codec parser for C-Media codecs

In reply to Takashi Iwai

Replace the old parser code for C-Media auto-parser with the latest generic parser. For compatibility reason, the static bindings are still left, but they could be cleaned up in future.

---
 sound/pci/hda/Kconfig        |   1 +
 sound/pci/hda/patch_cmedia.c | 164 ++++++++++++-------------------------------
 2 files changed, 47 insertions(+), 118 deletions(-)
sound/pci/hda/Kconfig +1 -0
index 93404d7..d3d7287 100644
@@ -201,6 +201,7 @@ config SND_HDA_CODEC_CA0132
 config SND_HDA_CODEC_CMEDIA
 	bool "Build C-Media HD-audio codec support"
 	default y
+	select SND_HDA_GENERIC
 	help
 	  Say Y here to include C-Media HD-audio codec support in
 	  snd-hda-intel driver, such as CMI9880.
sound/pci/hda/patch_cmedia.c +46 -118

206 lines not on this page · raw message

Signature · 1 line
1.8.0.1
#3 lore raw

PATCH 3/8 ALSA: hda - Remove superfluous kconfig depends

In reply to Takashi Iwai
---
 sound/pci/hda/Kconfig | 3 ---
 1 file changed, 3 deletions(-)
sound/pci/hda/Kconfig +0 -3
index d3d7287..b901494 100644
@@ -148,7 +148,6 @@ config SND_HDA_CODEC_HDMI
 
 config SND_HDA_CODEC_CIRRUS
 	bool "Build Cirrus Logic codec support"
-	depends on SND_HDA_INTEL
 	default y
 	select SND_HDA_GENERIC
 	help
@@ -174,7 +173,6 @@ config SND_HDA_CODEC_CONEXANT
 
 config SND_HDA_CODEC_CA0110
 	bool "Build Creative CA0110-IBG codec support"
-	depends on SND_HDA_INTEL
 	default y
 	help
 	  Say Y here to include Creative CA0110-IBG codec support in
@@ -187,7 +185,6 @@ config SND_HDA_CODEC_CA0110
 
 config SND_HDA_CODEC_CA0132
 	bool "Build Creative CA0132 codec support"
-	depends on SND_HDA_INTEL
 	default y
 	help
 	  Say Y here to include Creative CA0132 codec support in
Signature · 1 line
1.8.0.1
#4 lore raw

PATCH 4/8 ALSA: hda - Use generic parser for CA0110 codec

In reply to Takashi Iwai

CA0110 codec is a fairly straightforward hardware implementation, and we can use the generic parser almost as is.
Just set spec->multi_cap_vol flag to follow the current behavior.

---
 sound/pci/hda/Kconfig        |   1 +
 sound/pci/hda/patch_ca0110.c | 488 ++-----------------------------------------
 2 files changed, 16 insertions(+), 473 deletions(-)
sound/pci/hda/Kconfig +1 -0
index b901494..07025a9 100644
@@ -174,6 +174,7 @@ config SND_HDA_CODEC_CONEXANT
 config SND_HDA_CODEC_CA0110
 	bool "Build Creative CA0110-IBG codec support"
 	default y
+	select SND_HDA_GENERIC
 	help
 	  Say Y here to include Creative CA0110-IBG codec support in
 	  snd-hda-intel driver, found on some Creative X-Fi cards.
sound/pci/hda/patch_ca0110.c +15 -473

525 lines not on this page · raw message

Signature · 1 line
1.8.0.1
#5 lore raw

PATCH 5/8 ALSA: hda - Use generic parser in Conexant codec driver

In reply to Takashi Iwai

... and drop most of own parser code.

It doesn't replace any present static quirks, though.

---
 sound/pci/hda/Kconfig          |    1 +
 sound/pci/hda/patch_conexant.c | 1318 ++--------------------------------------
 2 files changed, 62 insertions(+), 1257 deletions(-)
sound/pci/hda/Kconfig +1 -0
index 07025a9..206f678 100644
@@ -162,6 +162,7 @@ config SND_HDA_CODEC_CIRRUS
 config SND_HDA_CODEC_CONEXANT
 	bool "Build Conexant HD-audio codec support"
 	default y
+	select SND_HDA_GENERIC
 	help
 	  Say Y here to include Conexant HD-audio codec support in
 	  snd-hda-intel driver, such as CX20549.
sound/pci/hda/patch_conexant.c +61 -1257

1,479 lines not on this page · raw message

Signature · 1 line
1.8.0.1
#6 lore raw

PATCH 6/8 ALSA: hda - Rearrange for dropping static quirk codes in Coexant driver

In reply to Takashi Iwai

Just shuffle the codes and add ifdefs for testing to drop the static quirk codes from patch_conexant.c.

By commenting out ENABLE_CXT_STATIC_QUIRKS define at the beginning of the file, you can disable the whole static codes.

---
 sound/pci/hda/patch_conexant.c | 100 +++++++++++++++++++++++------------------
 1 file changed, 57 insertions(+), 43 deletions(-)
sound/pci/hda/patch_conexant.c +57 -43
index f27125b..47b3d5b 100644
@@ -35,6 +35,8 @@
 #include "hda_jack.h"
 #include "hda_generic.h"
 
+#define ENABLE_CXT_STATIC_QUIRKS
+
 #define CXT_PIN_DIR_IN              0x00
 #define CXT_PIN_DIR_OUT             0x01
 #define CXT_PIN_DIR_INOUT           0x02
@@ -57,6 +59,13 @@
 struct conexant_spec {
 	struct hda_gen_spec gen;
 
+	unsigned int beep_amp;
+
+	/* extra EAPD pins */
+	unsigned int num_eapds;
+	hda_nid_t eapds[4];
+
+#ifdef ENABLE_CXT_STATIC_QUIRKS
 	const struct snd_kcontrol_new *mixers[5];
 	int num_mixers;
 	hda_nid_t vmaster_nid;
@@ -125,14 +134,48 @@ struct conexant_spec {
 	unsigned int dc_enable;
 	unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */
 	unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */
+#endif /* ENABLE_CXT_STATIC_QUIRKS */
+};
 
-	unsigned int beep_amp;
 
-	/* extra EAPD pins */
-	unsigned int num_eapds;
-	hda_nid_t eapds[4];
+#ifdef CONFIG_SND_HDA_INPUT_BEEP
+#define set_beep_amp(spec, nid, idx, dir) \
+	((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
+/* additional beep mixers; the actual parameters are overwritten at build */
+static const struct snd_kcontrol_new cxt_beep_mixer[] = {
+	HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
+	HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT),
+	{ } /* end */
 };
 
+/* create beep controls if needed */
+static int add_beep_ctls(struct hda_codec *codec)
+{
+	struct conexant_spec *spec = codec->spec;
+	int err;
+
+	if (spec->beep_amp) {
+		const struct snd_kcontrol_new *knew;
+		for (knew = cxt_beep_mixer; knew->name; knew++) {
+			struct snd_kcontrol *kctl;
+			kctl = snd_ctl_new1(knew, codec);
+			if (!kctl)
+				return -ENOMEM;
+			kctl->private_value = spec->beep_amp;
+			err = snd_hda_ctl_add(codec, 0, kctl);
+			if (err < 0)
+				return err;
+		}
+	}
+	return 0;
+}
+#else
+#define set_beep_amp(spec, nid, idx, dir) /* NOP */
+#define add_beep_ctls(codec)	0
+#endif
+
+
+#ifdef ENABLE_CXT_STATIC_QUIRKS
 static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
 				      struct hda_codec *codec,
 				      struct snd_pcm_substream *substream)
@@ -423,38 +466,6 @@ static const struct snd_kcontrol_new cxt_capture_mixers[] = {
 	{}
 };
 
-#ifdef CONFIG_SND_HDA_INPUT_BEEP
-/* additional beep mixers; the actual parameters are overwritten at build */
-static const struct snd_kcontrol_new cxt_beep_mixer[] = {
-	HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
-	HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT),
-	{ } /* end */
-};
-/* create beep controls if needed */
-static int add_beep_ctls(struct hda_codec *codec)
-{
-	struct conexant_spec *spec = codec->spec;
-	int err;
-
-	if (spec->beep_amp) {
-		const struct snd_kcontrol_new *knew;
-		for (knew = cxt_beep_mixer; knew->name; knew++) {
-			struct snd_kcontrol *kctl;
-			kctl = snd_ctl_new1(knew, codec);
-			if (!kctl)
-				return -ENOMEM;
-			kctl->private_value = spec->beep_amp;
-			err = snd_hda_ctl_add(codec, 0, kctl);
-			if (err < 0)
-				return err;
-		}
-	}
-	return 0;
-}
-#else
-#define add_beep_ctls(codec)	0
-#endif
-
 static const char * const slave_pfxs[] = {
 	"Headphone", "Speaker", "Bass Speaker", "Front", "Surround", "CLFE",
 	NULL
@@ -543,13 +554,6 @@ static const struct hda_codec_ops conexant_patch_ops = {
 	.reboot_notify = snd_hda_shutup_pins,
 };
 
-#ifdef CONFIG_SND_HDA_INPUT_BEEP
-#define set_beep_amp(spec, nid, idx, dir) \
-	((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
-#else
-#define set_beep_amp(spec, nid, idx, dir) /* NOP */
-#endif
-
 static int patch_conexant_auto(struct hda_codec *codec);
 /*
  * EAPD control
@@ -3112,6 +3116,9 @@ static int patch_cxt5066(struct hda_codec *codec)
 	return 0;
 }
 
+#endif /* ENABLE_CXT_STATIC_QUIRKS */
+
+
 /*
  * Automatic parser for CX20641 & co
  */
@@ -3408,6 +3415,13 @@ static int patch_conexant_auto(struct hda_codec *codec)
 	return err;
 }
 
+#ifndef ENABLE_CXT_STATIC_QUIRKS
+#define patch_cxt5045	patch_conexant_auto
+#define patch_cxt5047	patch_conexant_auto
+#define patch_cxt5051	patch_conexant_auto
+#define patch_cxt5066	patch_conexant_auto
+#endif
+
 /*
  */
 
Signature · 1 line
1.8.0.1
#7 lore raw

PATCH 7/8 ALSA: hda - Add generic parser support to Analog Device codec driver

In reply to Takashi Iwai

This patch adds the support for the generic auto-parser to AD codec driver. For AD1988, the old code is replaced simply with the new generic parser. For other codecs, new model "auto" is added and directed to use the generic parser.

No fixup codes have been implemented yet as of now. Eventually we'd replace each static quirk with the generic parser + fixup.

---
 sound/pci/hda/Kconfig        |   1 +
 sound/pci/hda/patch_analog.c | 915 ++++++++++++++-----------------------------
 2 files changed, 292 insertions(+), 624 deletions(-)
sound/pci/hda/Kconfig +1 -0
index 206f678..4962441 100644
@@ -99,6 +99,7 @@ config SND_HDA_CODEC_REALTEK
 config SND_HDA_CODEC_ANALOG
 	bool "Build Analog Device HD-audio codec support"
 	default y
+	select SND_HDA_GENERIC
 	help
 	  Say Y here to include Analog Device HD-audio codec support in
 	  snd-hda-intel driver, such as AD1986A.
sound/pci/hda/patch_analog.c +291 -624

1,260 lines not on this page · raw message

Signature · 1 line
1.8.0.1
#8 lore raw

Re: [PATCH 7/8] ALSA: hda - Add generic parser support to Analog Device codec driver

Quoted 8 lines

This patch adds the support for the generic auto-parser to AD codec driver. For AD1988, the old code is replaced simply with the new generic parser. For other codecs, new model "auto" is added and directed to use the generic parser.

No fixup codes have been implemented yet as of now. Eventually we'd replace each static quirk with the generic parser + fixup

Do the dac allocation of generic of parser really fit for adi codec since DAC0 of most ad198x codecs is for port-A headphone while the first DAC of realtek is for front line out ?

Quoted 1 line

-static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int

idx)

Quoted 5 lines
sound/pci/hda/patch_analog.c +0 -5
-{
-       static const hda_nid_t idx_to_dac[8] = {
-               /* A     B     C     D     E     F     G     H */
-               0x03, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a
-       };
#9 lore raw

Re: [PATCH 7/8] ALSA: hda - Add generic parser support to Analog Device codec driver

At Thu, 10 Jan 2013 14:48:06 +0800,

Quoted 8 lines · Raymond Yau

[1 <text/plain; UTF-8 (7bit)>]

Quoted 6 lines

This patch adds the support for the generic auto-parser to AD codec driver. For AD1988, the old code is replaced simply with the new generic parser. For other codecs, new model "auto" is added and directed to use the generic parser.

Quoted 6 lines
Quoted 2 lines

No fixup codes have been implemented yet as of now. Eventually we'd replace each static quirk with the generic parser + fixup

Do the dac allocation of generic of parser really fit for adi codec since DAC0 of most ad198x codecs is for port-A headphone while the first DAC of realtek is for front line out ?

Yes, the DAC order doesn't matter. The new codec parser tries to parse the full paths.

Takashi

#10 lore raw

PATCH 8/8 ALSA: hda - Use generic parser for VIA codec driver

In reply to Takashi Iwai

Yet another step forward. As all features for VIA codecs have been implemented in the generic driver, we can move on to migrate the VIA codec parser, too.

---
 sound/pci/hda/Kconfig     |    1 +
 sound/pci/hda/patch_via.c | 2784 +++++----------------------------------------
 2 files changed, 293 insertions(+), 2492 deletions(-)
sound/pci/hda/Kconfig +1 -0
index 4962441..4004d40 100644
@@ -124,6 +124,7 @@ config SND_HDA_CODEC_SIGMATEL
 config SND_HDA_CODEC_VIA
 	bool "Build VIA HD-audio codec support"
 	default y
+	select SND_HDA_GENERIC
 	help
 	  Say Y here to include VIA HD-audio codec support in
 	  snd-hda-intel driver, such as VT1708.
sound/pci/hda/patch_via.c +292 -2492

2,993 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.8.0.1

Part of the diff is not shown here. View the raw message.