Skip to contentSkip to conversation

Various cleanup + Mic Fix

PATCH In review Connor McAdams 3 participants 7 messages Oct 8, 2018 – Oct 9, 2018 Sound

lore
Share & tools
lore
#0 lore raw

cover Various cleanup + Mic Fix

This patch set fixes the microphone inconsistency issue, which means the microphone now works all the time on all of the cards I've tested (ZxR, Z, AE-5), along with the input effects.

It also includes changes suggested by Takashi Sakamoto, I believe I did what he asked properly, but if I messed it up I'm sure you guys will let me know.

This should finish up most of the ca0132 work, with all inputs and outputs working on the desktop cards.

Connor McAdams (4):
ALSA: hda/ca0132 - Fix microphone inconsistency issues
ALSA: hda/ca0132 - Clean up patch_ca0132()
ALSA: hda/ca0132 - Add error checking in ca0132_build_controls()
ALSA: hda/ca0132 - Fix input effect controls for desktop cards

 sound/pci/hda/patch_ca0132.c | 75 +++++++++++++++++++++++++++++++-------------
 1 file changed, 54 insertions(+), 21 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 ALSA: hda/ca0132 - Fix microphone inconsistency issues

This patch fixes microphone inconsistency issues by adding a delay to each setup_defaults function. Without this, the microphone only works intermittently.

---
 sound/pci/hda/patch_ca0132.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/pci/hda/patch_ca0132.c +6 -0
index b098504..12a3581 100644
@@ -7223,6 +7223,8 @@ static void r3d_setup_defaults(struct hda_codec *codec)
 	int num_fx;
 	int idx, i;
 
+	msleep(100);
+
 	if (spec->dsp_state != DSP_DOWNLOADED)
 		return;
 
@@ -7267,6 +7269,8 @@ static void sbz_setup_defaults(struct hda_codec *codec)
 	int num_fx;
 	int idx, i;
 
+	msleep(100);
+
 	if (spec->dsp_state != DSP_DOWNLOADED)
 		return;
 
@@ -7324,6 +7328,8 @@ static void ae5_setup_defaults(struct hda_codec *codec)
 	int num_fx;
 	int idx, i;
 
+	msleep(100);
+
 	if (spec->dsp_state != DSP_DOWNLOADED)
 		return;
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/4 ALSA: hda/ca0132 - Clean up patch_ca0132()

In reply to Connor McAdams

This patch cleans up the patch_ca0132() function with suggestions from Takashi Sakamoto.

---
 sound/pci/hda/patch_ca0132.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
sound/pci/hda/patch_ca0132.c +9 -5
index 12a3581..07d50d6 100644
@@ -8697,10 +8697,6 @@ static int patch_ca0132(struct hda_codec *codec)
 	codec->spec = spec;
 	spec->codec = codec;
 
-	codec->patch_ops = ca0132_patch_ops;
-	codec->pcm_format_first = 1;
-	codec->no_sticky_stream = 1;
-
 	/* Detect codec quirk */
 	quirk = snd_pci_quirk_lookup(codec->bus->pci, ca0132_quirks);
 	if (quirk)
@@ -8711,6 +8707,15 @@ static int patch_ca0132(struct hda_codec *codec)
 	if (spec->quirk == QUIRK_SBZ)
 		sbz_detect_quirk(codec);
 
+	if (spec->quirk == QUIRK_ZXR_DBPRO)
+		codec->patch_ops = dbpro_patch_ops;
+	else
+		codec->patch_ops = ca0132_patch_ops;
+
+	codec->pcm_format_first = 1;
+	codec->no_sticky_stream = 1;
+
+
 	spec->dsp_state = DSP_DOWNLOAD_INIT;
 	spec->num_mixers = 1;
 
@@ -8725,7 +8730,6 @@ static int patch_ca0132(struct hda_codec *codec)
 		snd_hda_codec_set_name(codec, "Sound Blaster ZxR");
 		break;
 	case QUIRK_ZXR_DBPRO:
-		codec->patch_ops = dbpro_patch_ops;
 		break;
 	case QUIRK_R3D:
 		spec->mixers[0] = desktop_mixer;
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/4 ALSA: hda/ca0132 - Add error checking in ca0132_build_controls()

In reply to Connor McAdams

This patch adds error checking to functions creating controls inside of ca0132_build_controls().

---
 sound/pci/hda/patch_ca0132.c | 47 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 12 deletions(-)
sound/pci/hda/patch_ca0132.c +35 -12
index 07d50d6..693b063 100644
@@ -6365,7 +6365,8 @@ static int ca0132_build_controls(struct hda_codec *codec)
 					    NULL, ca0132_alt_slave_pfxs,
 					    "Playback Switch",
 					    true, &spec->vmaster_mute.sw_kctl);
-
+		if (err < 0)
+			return err;
 	}
 
 	/* Add in and out effects controls.
@@ -6392,8 +6393,14 @@ static int ca0132_build_controls(struct hda_codec *codec)
 	 * prefix, and change PlayEnhancement and CrystalVoice to match.
 	 */
 	if (spec->use_alt_controls) {
-		ca0132_alt_add_svm_enum(codec);
-		add_ca0132_alt_eq_presets(codec);
+		err = ca0132_alt_add_svm_enum(codec);
+		if (err < 0)
+			return err;
+
+		err = add_ca0132_alt_eq_presets(codec);
+		if (err < 0)
+			return err;
+
 		err = add_fx_switch(codec, PLAY_ENHANCEMENT,
 					"Enable OutFX", 0);
 		if (err < 0)
@@ -6430,7 +6437,9 @@ static int ca0132_build_controls(struct hda_codec *codec)
 		if (err < 0)
 			return err;
 	}
-	add_voicefx(codec);
+	err = add_voicefx(codec);
+	if (err < 0)
+		return err;
 
 	/*
 	 * If the codec uses alt_functions, you need the enumerated controls
@@ -6438,23 +6447,37 @@ static int ca0132_build_controls(struct hda_codec *codec)
 	 * setting control.
 	 */
 	if (spec->use_alt_functions) {
-		ca0132_alt_add_output_enum(codec);
-		ca0132_alt_add_mic_boost_enum(codec);
+		err = ca0132_alt_add_output_enum(codec);
+		if (err < 0)
+			return err;
+		err = ca0132_alt_add_mic_boost_enum(codec);
+		if (err < 0)
+			return err;
 		/*
 		 * ZxR only has microphone input, there is no front panel
 		 * header on the card, and aux-in is handled by the DBPro board.
 		 */
-		if (spec->quirk != QUIRK_ZXR)
-			ca0132_alt_add_input_enum(codec);
+		if (spec->quirk != QUIRK_ZXR) {
+			err = ca0132_alt_add_input_enum(codec);
+			if (err < 0)
+				return err;
+		}
 	}
 
 	if (spec->quirk == QUIRK_AE5) {
-		ae5_add_headphone_gain_enum(codec);
-		ae5_add_sound_filter_enum(codec);
+		err = ae5_add_headphone_gain_enum(codec);
+		if (err < 0)
+			return err;
+		err = ae5_add_sound_filter_enum(codec);
+		if (err < 0)
+			return err;
 	}
 
-	if (spec->quirk == QUIRK_ZXR)
-		zxr_add_headphone_gain_switch(codec);
+	if (spec->quirk == QUIRK_ZXR) {
+		err = zxr_add_headphone_gain_switch(codec);
+		if (err < 0)
+			return err;
+	}
 #ifdef ENABLE_TUNING_CONTROLS
 	add_tuning_ctls(codec);
 #endif
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/4 ALSA: hda/ca0132 - Fix input effect controls for desktop cards

In reply to Connor McAdams

This patch removes the echo cancellation control for desktop cards, and makes use of the special 0x47 SCP command for noise reduction.

---
 sound/pci/hda/patch_ca0132.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sound/pci/hda/patch_ca0132.c +4 -4
index 693b063..1a13cea 100644
@@ -4857,7 +4857,7 @@ static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val)
 			val = 0;
 
 		/* If Voice Focus on SBZ, set to two channel. */
-		if ((nid == VOICE_FOCUS) && (spec->quirk == QUIRK_SBZ)
+		if ((nid == VOICE_FOCUS) && (spec->use_pci_mmio)
 				&& (spec->cur_mic_type != REAR_LINE_IN)) {
 			if (spec->effects_switch[CRYSTAL_VOICE -
 						 EFFECT_START_NID]) {
@@ -4876,7 +4876,7 @@ static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val)
 		 * For SBZ noise reduction, there's an extra command
 		 * to module ID 0x47. No clue why.
 		 */
-		if ((nid == NOISE_REDUCTION) && (spec->quirk == QUIRK_SBZ)
+		if ((nid == NOISE_REDUCTION) && (spec->use_pci_mmio)
 				&& (spec->cur_mic_type != REAR_LINE_IN)) {
 			if (spec->effects_switch[CRYSTAL_VOICE -
 						 EFFECT_START_NID]) {
@@ -6374,8 +6374,8 @@ static int ca0132_build_controls(struct hda_codec *codec)
 	 */
 	num_fx = OUT_EFFECTS_COUNT + IN_EFFECTS_COUNT;
 	for (i = 0; i < num_fx; i++) {
-		/* SBZ and R3D break if Echo Cancellation is used. */
-		if (spec->quirk == QUIRK_SBZ || spec->quirk == QUIRK_R3D) {
+		/* Desktop cards break if Echo Cancellation is used. */
+		if (spec->use_pci_mmio) {
 			if (i == (ECHO_CANCELLATION - IN_EFFECT_START_NID +
 						OUT_EFFECTS_COUNT))
 				continue;
Signature · 1 line
2.7.4
Reviewed-by on the v1 series
#5 lore raw
In reply to Connor McAdams
Quoted 11 lines · Connor McAdams

This patch set fixes the microphone inconsistency issue, which means the microphone now works all the time on all of the cards I've tested (ZxR, Z, AE-5), along with the input effects.

It also includes changes suggested by Takashi Sakamoto, I believe I did what he asked properly, but if I messed it up I'm sure you guys will let me know.

This should finish up most of the ca0132 work, with all inputs and outputs working on the desktop cards.

Quoted 8 lines

Connor McAdams (4):
ALSA: hda/ca0132 - Fix microphone inconsistency issues
ALSA: hda/ca0132 - Clean up patch_ca0132()
ALSA: hda/ca0132 - Add error checking in ca0132_build_controls()
ALSA: hda/ca0132 - Fix input effect controls for desktop cards

  sound/pci/hda/patch_ca0132.c | 75 +++++++++++++++++++++++++++++++-------------
  1 file changed, 54 insertions(+), 21 deletions(-)

Thanks

Takashi Sakamoto

#6 lore raw
In reply to Connor McAdams
Quoted 9 lines · Connor McAdams

This patch set fixes the microphone inconsistency issue, which means the microphone now works all the time on all of the cards I've tested (ZxR, Z, AE-5), along with the input effects.

It also includes changes suggested by Takashi Sakamoto, I believe I did what he asked properly, but if I messed it up I'm sure you guys will let me know.

Quoted 8 lines

This should finish up most of the ca0132 work, with all inputs and outputs working on the desktop cards.

Connor McAdams (4):
ALSA: hda/ca0132 - Fix microphone inconsistency issues
ALSA: hda/ca0132 - Clean up patch_ca0132()
ALSA: hda/ca0132 - Add error checking in ca0132_build_controls()
ALSA: hda/ca0132 - Fix input effect controls for desktop cards

Now applied all four patches. Thanks.

Takashi