2022-05-10 20:37:33

by Stefan Binding

[permalink] [raw]
Subject: [PATCH v1 0/3] ALSA: hda/cs8409: Add support for Odin Laptop Variants

Add support for new Odin Laptop Variants into CS8409 HDA Driver.

Since these laptops require Speaker Playback Switch, support must be added into
CS8409 HDA driver. Since CS8409 does not have amplifier parameters for the NID
associated with the speaker, the HDA driver does not add the switch
automatically, so the driver needs to add this support manually.

Stefan Binding (3):
ALSA: hda/cs8409: Support new Odin Variants
ALSA: hda/cs8409: Add Speaker Playback Switch for Cyborg
ALSA: hda/cs8409: Add Speaker Playback Switch for Warlock

sound/pci/hda/patch_cs8409-tables.c | 19 +++++++
sound/pci/hda/patch_cs8409.c | 85 ++++++++++++++++++++++++-----
sound/pci/hda/patch_cs8409.h | 5 ++
3 files changed, 95 insertions(+), 14 deletions(-)

--
2.25.1



2022-05-10 20:59:00

by Stefan Binding

[permalink] [raw]
Subject: [PATCH v1 1/3] ALSA: hda/cs8409: Support new Odin Variants

Odin Variants have the internal mic connected
directly to the CPU rather than codec.

Signed-off-by: Stefan Binding <[email protected]>
---
sound/pci/hda/patch_cs8409-tables.c | 19 +++++++++++++++++++
sound/pci/hda/patch_cs8409.c | 11 ++++++++---
sound/pci/hda/patch_cs8409.h | 1 +
3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/sound/pci/hda/patch_cs8409-tables.c b/sound/pci/hda/patch_cs8409-tables.c
index 0d11b24a1317..4f4cc8215917 100644
--- a/sound/pci/hda/patch_cs8409-tables.c
+++ b/sound/pci/hda/patch_cs8409-tables.c
@@ -76,6 +76,13 @@ const struct hda_pintbl cs8409_cs42l42_pincfgs[] = {
{} /* terminator */
};

+const struct hda_pintbl cs8409_cs42l42_pincfgs_no_dmic[] = {
+ { CS8409_PIN_ASP1_TRANSMITTER_A, 0x042120f0 }, /* ASP-1-TX */
+ { CS8409_PIN_ASP1_RECEIVER_A, 0x04a12050 }, /* ASP-1-RX */
+ { CS8409_PIN_ASP2_TRANSMITTER_A, 0x901000f0 }, /* ASP-2-TX */
+ {} /* terminator */
+};
+
/* Vendor specific HW configuration for CS42L42 */
static const struct cs8409_i2c_param cs42l42_init_reg_seq[] = {
{ CS42L42_I2C_TIMEOUT, 0xB0 },
@@ -518,6 +525,11 @@ const struct snd_pci_quirk cs8409_fixup_tbl[] = {
SND_PCI_QUIRK(0x1028, 0x0B95, "Warlock MLK Dual Mic", CS8409_WARLOCK_MLK_DUAL_MIC),
SND_PCI_QUIRK(0x1028, 0x0B96, "Warlock MLK", CS8409_WARLOCK_MLK),
SND_PCI_QUIRK(0x1028, 0x0B97, "Warlock MLK Dual Mic", CS8409_WARLOCK_MLK_DUAL_MIC),
+ SND_PCI_QUIRK(0x1028, 0x0BA5, "Odin", CS8409_ODIN),
+ SND_PCI_QUIRK(0x1028, 0x0BA6, "Odin", CS8409_ODIN),
+ SND_PCI_QUIRK(0x1028, 0x0BA8, "Odin", CS8409_ODIN),
+ SND_PCI_QUIRK(0x1028, 0x0BAA, "Odin", CS8409_ODIN),
+ SND_PCI_QUIRK(0x1028, 0x0BAE, "Odin", CS8409_ODIN),
SND_PCI_QUIRK(0x1028, 0x0BB2, "Warlock MLK", CS8409_WARLOCK_MLK),
SND_PCI_QUIRK(0x1028, 0x0BB3, "Warlock MLK", CS8409_WARLOCK_MLK),
SND_PCI_QUIRK(0x1028, 0x0BB4, "Warlock MLK", CS8409_WARLOCK_MLK),
@@ -545,6 +557,7 @@ const struct hda_model_fixup cs8409_models[] = {
{ .id = CS8409_WARLOCK_MLK_DUAL_MIC, .name = "warlock mlk dual mic" },
{ .id = CS8409_CYBORG, .name = "cyborg" },
{ .id = CS8409_DOLPHIN, .name = "dolphin" },
+ { .id = CS8409_ODIN, .name = "odin" },
{}
};

@@ -593,4 +606,10 @@ const struct hda_fixup cs8409_fixups[] = {
.type = HDA_FIXUP_FUNC,
.v.func = dolphin_fixups,
},
+ [CS8409_ODIN] = {
+ .type = HDA_FIXUP_PINS,
+ .v.pins = cs8409_cs42l42_pincfgs_no_dmic,
+ .chained = true,
+ .chain_id = CS8409_FIXUPS,
+ },
};
diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c
index c3a8b04c71d8..c4d21569cc7d 100644
--- a/sound/pci/hda/patch_cs8409.c
+++ b/sound/pci/hda/patch_cs8409.c
@@ -1027,6 +1027,9 @@ static void cs8409_cs42l42_hw_init(struct hda_codec *codec)
/* DMIC1_MO=00b, DMIC1/2_SR=1 */
cs8409_vendor_coef_set(codec, CS8409_DMIC_CFG, 0x0003);
break;
+ case CS8409_ODIN:
+ /* ASP1/2_xxx_EN=1, ASP1/2_MCLK_EN=0, DMIC1_SCL_EN=0 */
+ cs8409_vendor_coef_set(codec, CS8409_PAD_CFG_SLW_RATE_CTRL, 0xfc00);
default:
break;
}
@@ -1116,6 +1119,7 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,

/* Set HSBIAS_SENSE_EN and Full Scale volume for some variants. */
switch (codec->fixup_id) {
+ case CS8409_ODIN:
case CS8409_WARLOCK_MLK:
case CS8409_WARLOCK_MLK_DUAL_MIC:
spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x0020;
@@ -1136,9 +1140,10 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
/* add hooks */
spec->gen.pcm_playback_hook = cs42l42_playback_pcm_hook;
spec->gen.pcm_capture_hook = cs42l42_capture_pcm_hook;
- /* Set initial DMIC volume to -26 dB */
- snd_hda_codec_amp_init_stereo(codec, CS8409_CS42L42_DMIC_ADC_PIN_NID,
- HDA_INPUT, 0, 0xff, 0x19);
+ if (codec->fixup_id != CS8409_ODIN)
+ /* Set initial DMIC volume to -26 dB */
+ snd_hda_codec_amp_init_stereo(codec, CS8409_CS42L42_DMIC_ADC_PIN_NID,
+ HDA_INPUT, 0, 0xff, 0x19);
snd_hda_gen_add_kctl(&spec->gen, "Headphone Playback Volume",
&cs42l42_dac_volume_mixer);
snd_hda_gen_add_kctl(&spec->gen, "Mic Capture Volume",
diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h
index ebf473a3f109..9852dc4234b4 100644
--- a/sound/pci/hda/patch_cs8409.h
+++ b/sound/pci/hda/patch_cs8409.h
@@ -267,6 +267,7 @@ enum {
CS8409_FIXUPS,
CS8409_DOLPHIN,
CS8409_DOLPHIN_FIXUPS,
+ CS8409_ODIN,
};

enum {
--
2.25.1


2022-05-11 07:08:46

by Stefan Binding

[permalink] [raw]
Subject: [PATCH v1 3/3] ALSA: hda/cs8409: Add Speaker Playback Switch for Warlock

Add support for a Speaker Playback Switch, which disables
the Amp connected to cs8409. The Switch is not added
automatically because cs8409 does not have an output amp
for the speaker NID.

Note: This switch uses a different GPIO to Cyborg/Odin variants

Signed-off-by: Stefan Binding <[email protected]>
---
sound/pci/hda/patch_cs8409.c | 2 ++
sound/pci/hda/patch_cs8409.h | 1 +
2 files changed, 3 insertions(+)

diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c
index f682769667e3..95b33a983e9e 100644
--- a/sound/pci/hda/patch_cs8409.c
+++ b/sound/pci/hda/patch_cs8409.c
@@ -1167,10 +1167,12 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
case CS8409_WARLOCK_MLK:
case CS8409_WARLOCK_MLK_DUAL_MIC:
spec->scodecs[CS8409_CODEC0]->full_scale_vol = CS42L42_FULL_SCALE_VOL_0DB;
+ spec->speaker_pdn_gpio = CS8409_WARLOCK_SPEAKER_PDN;
break;
default:
spec->scodecs[CS8409_CODEC0]->full_scale_vol =
CS42L42_FULL_SCALE_VOL_MINUS6DB;
+ spec->speaker_pdn_gpio = CS8409_WARLOCK_SPEAKER_PDN;
break;
}

diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h
index 630a7a2de51f..260388a6256c 100644
--- a/sound/pci/hda/patch_cs8409.h
+++ b/sound/pci/hda/patch_cs8409.h
@@ -239,6 +239,7 @@ enum cs8409_coefficient_index_registers {
#define CS8409_CS42L42_RESET GENMASK(5, 5) /* CS8409_GPIO5 */
#define CS8409_CS42L42_INT GENMASK(4, 4) /* CS8409_GPIO4 */
#define CS8409_CYBORG_SPEAKER_PDN GENMASK(2, 2) /* CS8409_GPIO2 */
+#define CS8409_WARLOCK_SPEAKER_PDN GENMASK(1, 1) /* CS8409_GPIO1 */
#define CS8409_CS42L42_HP_PIN_NID CS8409_PIN_ASP1_TRANSMITTER_A
#define CS8409_CS42L42_SPK_PIN_NID CS8409_PIN_ASP2_TRANSMITTER_A
#define CS8409_CS42L42_AMIC_PIN_NID CS8409_PIN_ASP1_RECEIVER_A
--
2.25.1


2022-05-11 09:49:24

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 1/3] ALSA: hda/cs8409: Support new Odin Variants

Hi Stefan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on v5.18-rc6 next-20220510]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/intel-lab-lkp/linux/commits/Stefan-Binding/ALSA-hda-cs8409-Add-support-for-Odin-Laptop-Variants/20220511-001936
base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: i386-randconfig-c001-20220509 (https://download.01.org/0day-ci/archive/20220511/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 18dd123c56754edf62c7042dcf23185c3727610f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/e834cdf9c71c45212904ba82b5b7e49d45810deb
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Stefan-Binding/ALSA-hda-cs8409-Add-support-for-Odin-Laptop-Variants/20220511-001936
git checkout e834cdf9c71c45212904ba82b5b7e49d45810deb
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash sound/pci/hda/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

>> sound/pci/hda/patch_cs8409.c:1033:2: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
default:
^
sound/pci/hda/patch_cs8409.c:1033:2: note: insert 'break;' to avoid fall-through
default:
^
break;
1 warning generated.


vim +1033 sound/pci/hda/patch_cs8409.c

8c70461bbb83cf Lucas Tanure 2021-08-11 996
8c70461bbb83cf Lucas Tanure 2021-08-11 997 /* Vendor specific HW configuration
8c70461bbb83cf Lucas Tanure 2021-08-11 998 * PLL, ASP, I2C, SPI, GPIOs, DMIC etc...
8c70461bbb83cf Lucas Tanure 2021-08-11 999 */
8c70461bbb83cf Lucas Tanure 2021-08-11 1000 static void cs8409_cs42l42_hw_init(struct hda_codec *codec)
8c70461bbb83cf Lucas Tanure 2021-08-11 1001 {
8c70461bbb83cf Lucas Tanure 2021-08-11 1002 const struct cs8409_cir_param *seq = cs8409_cs42l42_hw_cfg;
8c70461bbb83cf Lucas Tanure 2021-08-11 1003 const struct cs8409_cir_param *seq_bullseye = cs8409_cs42l42_bullseye_atn;
8c70461bbb83cf Lucas Tanure 2021-08-11 1004 struct cs8409_spec *spec = codec->spec;
24f7ac3d3b6b70 Lucas Tanure 2021-08-11 1005 struct sub_codec *cs42l42 = spec->scodecs[CS8409_CODEC0];
8c70461bbb83cf Lucas Tanure 2021-08-11 1006
8c70461bbb83cf Lucas Tanure 2021-08-11 1007 if (spec->gpio_mask) {
ccff0064a7ce8e Stefan Binding 2021-08-11 1008 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_MASK,
ccff0064a7ce8e Stefan Binding 2021-08-11 1009 spec->gpio_mask);
ccff0064a7ce8e Stefan Binding 2021-08-11 1010 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DIRECTION,
ccff0064a7ce8e Stefan Binding 2021-08-11 1011 spec->gpio_dir);
ccff0064a7ce8e Stefan Binding 2021-08-11 1012 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA,
ccff0064a7ce8e Stefan Binding 2021-08-11 1013 spec->gpio_data);
8c70461bbb83cf Lucas Tanure 2021-08-11 1014 }
8c70461bbb83cf Lucas Tanure 2021-08-11 1015
8c70461bbb83cf Lucas Tanure 2021-08-11 1016 for (; seq->nid; seq++)
8c70461bbb83cf Lucas Tanure 2021-08-11 1017 cs8409_vendor_coef_set(codec, seq->cir, seq->coeff);
8c70461bbb83cf Lucas Tanure 2021-08-11 1018
24f7ac3d3b6b70 Lucas Tanure 2021-08-11 1019 if (codec->fixup_id == CS8409_BULLSEYE) {
8c70461bbb83cf Lucas Tanure 2021-08-11 1020 for (; seq_bullseye->nid; seq_bullseye++)
8c70461bbb83cf Lucas Tanure 2021-08-11 1021 cs8409_vendor_coef_set(codec, seq_bullseye->cir, seq_bullseye->coeff);
24f7ac3d3b6b70 Lucas Tanure 2021-08-11 1022 }
8c70461bbb83cf Lucas Tanure 2021-08-11 1023
6581a045d54c6a Stefan Binding 2022-03-28 1024 switch (codec->fixup_id) {
6581a045d54c6a Stefan Binding 2022-03-28 1025 case CS8409_CYBORG:
6581a045d54c6a Stefan Binding 2022-03-28 1026 case CS8409_WARLOCK_MLK_DUAL_MIC:
8c70461bbb83cf Lucas Tanure 2021-08-11 1027 /* DMIC1_MO=00b, DMIC1/2_SR=1 */
8a7724535bacbb Stefan Binding 2022-03-28 1028 cs8409_vendor_coef_set(codec, CS8409_DMIC_CFG, 0x0003);
6581a045d54c6a Stefan Binding 2022-03-28 1029 break;
e834cdf9c71c45 Stefan Binding 2022-05-10 1030 case CS8409_ODIN:
e834cdf9c71c45 Stefan Binding 2022-05-10 1031 /* ASP1/2_xxx_EN=1, ASP1/2_MCLK_EN=0, DMIC1_SCL_EN=0 */
e834cdf9c71c45 Stefan Binding 2022-05-10 1032 cs8409_vendor_coef_set(codec, CS8409_PAD_CFG_SLW_RATE_CTRL, 0xfc00);
6581a045d54c6a Stefan Binding 2022-03-28 @1033 default:
6581a045d54c6a Stefan Binding 2022-03-28 1034 break;
6581a045d54c6a Stefan Binding 2022-03-28 1035 }
8c70461bbb83cf Lucas Tanure 2021-08-11 1036
24f7ac3d3b6b70 Lucas Tanure 2021-08-11 1037 cs42l42_resume(cs42l42);
8c70461bbb83cf Lucas Tanure 2021-08-11 1038
8c70461bbb83cf Lucas Tanure 2021-08-11 1039 /* Enable Unsolicited Response */
8c70461bbb83cf Lucas Tanure 2021-08-11 1040 cs8409_enable_ur(codec, 1);
8c70461bbb83cf Lucas Tanure 2021-08-11 1041 }
8c70461bbb83cf Lucas Tanure 2021-08-11 1042

--
0-DAY CI Kernel Test Service
https://01.org/lkp