2018-10-08 19:42:49

by Connor McAdams

[permalink] [raw]
Subject: [PATCH 0/4] 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(-)

--
2.7.4



2018-10-08 19:42:56

by Connor McAdams

[permalink] [raw]
Subject: [PATCH 4/4] ALSA: hda/ca0132 - Fix input effect controls for desktop cards

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

Signed-off-by: Connor McAdams <[email protected]>
---
sound/pci/hda/patch_ca0132.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 693b063..1a13cea 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -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;
--
2.7.4


2018-10-08 19:43:00

by Connor McAdams

[permalink] [raw]
Subject: [PATCH 3/4] ALSA: hda/ca0132 - Add error checking in ca0132_build_controls()

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

Signed-off-by: Connor McAdams <[email protected]>
---
sound/pci/hda/patch_ca0132.c | 47 +++++++++++++++++++++++++++++++++-----------
1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 07d50d6..693b063 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -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
--
2.7.4


2018-10-08 19:43:42

by Connor McAdams

[permalink] [raw]
Subject: [PATCH 2/4] ALSA: hda/ca0132 - Clean up patch_ca0132()

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

Signed-off-by: Connor McAdams <[email protected]>
---
sound/pci/hda/patch_ca0132.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 12a3581..07d50d6 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -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;
--
2.7.4


2018-10-08 19:44:04

by Connor McAdams

[permalink] [raw]
Subject: [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.

Signed-off-by: Connor McAdams <[email protected]>
---
sound/pci/hda/patch_ca0132.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index b098504..12a3581 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -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;

--
2.7.4


2018-10-09 14:18:11

by Takashi Sakamoto

[permalink] [raw]
Subject: Re: [PATCH 0/4] Various cleanup + Mic Fix

On 2018年10月09日 04:39, Connor McAdams wrote:
> 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(-)

Reviewed-by: Takashi Sakamoto <[email protected]>


Thanks

Takashi Sakamoto

2018-10-09 14:22:30

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH 0/4] Various cleanup + Mic Fix

On Mon, 08 Oct 2018 21:39:56 +0200,
Connor McAdams wrote:
>
> 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

Now applied all four patches. Thanks.


Takashi