Skip to content

Commit 56e7a93

Browse files
committed
Merge tag 'asoc-fix-v5.14-rc4' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Fixes for v5.14 Quite a lot of fixes here, the biggest set being for the cs42l42 driver which is reasonably old but has seen a sudden uptick in activity. There's also some fixes for correctly referencing PCM buffer addresses and the removal of some driver-local bodges that had been done for the lack of prefix handling in DAPM which were broken by the core handling that as expected.
2 parents 97367c9 + e5ada3f commit 56e7a93

25 files changed

+200
-137
lines changed

MAINTAINERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19992,7 +19992,8 @@ F: Documentation/devicetree/bindings/extcon/wlf,arizona.yaml
1999219992
F: Documentation/devicetree/bindings/mfd/wlf,arizona.yaml
1999319993
F: Documentation/devicetree/bindings/mfd/wm831x.txt
1999419994
F: Documentation/devicetree/bindings/regulator/wlf,arizona.yaml
19995-
F: Documentation/devicetree/bindings/sound/wlf,arizona.yaml
19995+
F: Documentation/devicetree/bindings/sound/wlf,*.yaml
19996+
F: Documentation/devicetree/bindings/sound/wm*
1999619997
F: Documentation/hwmon/wm83??.rst
1999719998
F: arch/arm/mach-s3c/mach-crag6410*
1999819999
F: drivers/clk/clk-wm83*.c

sound/soc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ config SND_SOC_COMPRESS
3636

3737
config SND_SOC_TOPOLOGY
3838
bool
39+
select SND_DYNAMIC_MINORS
3940

4041
config SND_SOC_TOPOLOGY_KUNIT_TEST
4142
tristate "KUnit tests for SoC topology"

sound/soc/amd/acp-da7219-max98357a.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = {
525525
| SND_SOC_DAIFMT_CBM_CFM,
526526
.init = cz_da7219_init,
527527
.dpcm_playback = 1,
528+
.stop_dma_first = 1,
528529
.ops = &cz_da7219_play_ops,
529530
SND_SOC_DAILINK_REG(designware1, dlgs, platform),
530531
},
@@ -534,6 +535,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = {
534535
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
535536
| SND_SOC_DAIFMT_CBM_CFM,
536537
.dpcm_capture = 1,
538+
.stop_dma_first = 1,
537539
.ops = &cz_da7219_cap_ops,
538540
SND_SOC_DAILINK_REG(designware2, dlgs, platform),
539541
},
@@ -543,6 +545,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = {
543545
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
544546
| SND_SOC_DAIFMT_CBM_CFM,
545547
.dpcm_playback = 1,
548+
.stop_dma_first = 1,
546549
.ops = &cz_max_play_ops,
547550
SND_SOC_DAILINK_REG(designware3, mx, platform),
548551
},
@@ -553,6 +556,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = {
553556
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
554557
| SND_SOC_DAIFMT_CBM_CFM,
555558
.dpcm_capture = 1,
559+
.stop_dma_first = 1,
556560
.ops = &cz_dmic0_cap_ops,
557561
SND_SOC_DAILINK_REG(designware3, adau, platform),
558562
},
@@ -563,6 +567,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = {
563567
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
564568
| SND_SOC_DAIFMT_CBM_CFM,
565569
.dpcm_capture = 1,
570+
.stop_dma_first = 1,
566571
.ops = &cz_dmic1_cap_ops,
567572
SND_SOC_DAILINK_REG(designware2, adau, platform),
568573
},

sound/soc/amd/acp-pcm-dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ static int acp_dma_hw_params(struct snd_soc_component *component,
969969

970970
acp_set_sram_bank_state(rtd->acp_mmio, 0, true);
971971
/* Save for runtime private data */
972-
rtd->dma_addr = substream->dma_buffer.addr;
972+
rtd->dma_addr = runtime->dma_addr;
973973
rtd->order = get_order(size);
974974

975975
/* Fill the page table entries in ACP SRAM */

sound/soc/amd/raven/acp3x-pcm-dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static int acp3x_dma_hw_params(struct snd_soc_component *component,
286286
pr_err("pinfo failed\n");
287287
}
288288
size = params_buffer_bytes(params);
289-
rtd->dma_addr = substream->dma_buffer.addr;
289+
rtd->dma_addr = substream->runtime->dma_addr;
290290
rtd->num_pages = (PAGE_ALIGN(size) >> PAGE_SHIFT);
291291
config_acp3x_dma(rtd, substream->stream);
292292
return 0;

sound/soc/amd/renoir/acp3x-pdm-dma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static int acp_pdm_dma_hw_params(struct snd_soc_component *component,
242242
return -EINVAL;
243243
size = params_buffer_bytes(params);
244244
period_bytes = params_period_bytes(params);
245-
rtd->dma_addr = substream->dma_buffer.addr;
245+
rtd->dma_addr = substream->runtime->dma_addr;
246246
rtd->num_pages = (PAGE_ALIGN(size) >> PAGE_SHIFT);
247247
config_acp_dma(rtd, substream->stream);
248248
init_pdm_ring_buffer(MEM_WINDOW_START, size, period_bytes,

sound/soc/amd/renoir/rn-pci-acp3x.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ static const struct dev_pm_ops rn_acp_pm = {
382382
.runtime_resume = snd_rn_acp_resume,
383383
.suspend = snd_rn_acp_suspend,
384384
.resume = snd_rn_acp_resume,
385+
.restore = snd_rn_acp_resume,
386+
.poweroff = snd_rn_acp_suspend,
385387
};
386388

387389
static void snd_rn_acp_remove(struct pci_dev *pci)

sound/soc/codecs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,7 @@ config SND_SOC_WCD934X
15591559
config SND_SOC_WCD938X
15601560
depends on SND_SOC_WCD938X_SDW
15611561
tristate
1562+
depends on SOUNDWIRE || !SOUNDWIRE
15621563

15631564
config SND_SOC_WCD938X_SDW
15641565
tristate "WCD9380/WCD9385 Codec - SDW"

sound/soc/codecs/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,10 @@ obj-$(CONFIG_SND_SOC_WCD_MBHC) += snd-soc-wcd-mbhc.o
583583
obj-$(CONFIG_SND_SOC_WCD9335) += snd-soc-wcd9335.o
584584
obj-$(CONFIG_SND_SOC_WCD934X) += snd-soc-wcd934x.o
585585
obj-$(CONFIG_SND_SOC_WCD938X) += snd-soc-wcd938x.o
586-
obj-$(CONFIG_SND_SOC_WCD938X_SDW) += snd-soc-wcd938x-sdw.o
586+
ifdef CONFIG_SND_SOC_WCD938X_SDW
587+
# avoid link failure by forcing sdw code built-in when needed
588+
obj-$(CONFIG_SND_SOC_WCD938X) += snd-soc-wcd938x-sdw.o
589+
endif
587590
obj-$(CONFIG_SND_SOC_WL1273) += snd-soc-wl1273.o
588591
obj-$(CONFIG_SND_SOC_WM0010) += snd-soc-wm0010.o
589592
obj-$(CONFIG_SND_SOC_WM1250_EV1) += snd-soc-wm1250-ev1.o

sound/soc/codecs/cs42l42.c

Lines changed: 70 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ static const struct regmap_config cs42l42_regmap = {
405405
.use_single_write = true,
406406
};
407407

408-
static DECLARE_TLV_DB_SCALE(adc_tlv, -9600, 100, false);
408+
static DECLARE_TLV_DB_SCALE(adc_tlv, -9700, 100, true);
409409
static DECLARE_TLV_DB_SCALE(mixer_tlv, -6300, 100, true);
410410

411411
static const char * const cs42l42_hpf_freq_text[] = {
@@ -425,34 +425,23 @@ static SOC_ENUM_SINGLE_DECL(cs42l42_wnf3_freq_enum, CS42L42_ADC_WNF_HPF_CTL,
425425
CS42L42_ADC_WNF_CF_SHIFT,
426426
cs42l42_wnf3_freq_text);
427427

428-
static const char * const cs42l42_wnf05_freq_text[] = {
429-
"280Hz", "315Hz", "350Hz", "385Hz",
430-
"420Hz", "455Hz", "490Hz", "525Hz"
431-
};
432-
433-
static SOC_ENUM_SINGLE_DECL(cs42l42_wnf05_freq_enum, CS42L42_ADC_WNF_HPF_CTL,
434-
CS42L42_ADC_WNF_CF_SHIFT,
435-
cs42l42_wnf05_freq_text);
436-
437428
static const struct snd_kcontrol_new cs42l42_snd_controls[] = {
438429
/* ADC Volume and Filter Controls */
439430
SOC_SINGLE("ADC Notch Switch", CS42L42_ADC_CTL,
440-
CS42L42_ADC_NOTCH_DIS_SHIFT, true, false),
431+
CS42L42_ADC_NOTCH_DIS_SHIFT, true, true),
441432
SOC_SINGLE("ADC Weak Force Switch", CS42L42_ADC_CTL,
442433
CS42L42_ADC_FORCE_WEAK_VCM_SHIFT, true, false),
443434
SOC_SINGLE("ADC Invert Switch", CS42L42_ADC_CTL,
444435
CS42L42_ADC_INV_SHIFT, true, false),
445436
SOC_SINGLE("ADC Boost Switch", CS42L42_ADC_CTL,
446437
CS42L42_ADC_DIG_BOOST_SHIFT, true, false),
447-
SOC_SINGLE_SX_TLV("ADC Volume", CS42L42_ADC_VOLUME,
448-
CS42L42_ADC_VOL_SHIFT, 0xA0, 0x6C, adc_tlv),
438+
SOC_SINGLE_S8_TLV("ADC Volume", CS42L42_ADC_VOLUME, -97, 12, adc_tlv),
449439
SOC_SINGLE("ADC WNF Switch", CS42L42_ADC_WNF_HPF_CTL,
450440
CS42L42_ADC_WNF_EN_SHIFT, true, false),
451441
SOC_SINGLE("ADC HPF Switch", CS42L42_ADC_WNF_HPF_CTL,
452442
CS42L42_ADC_HPF_EN_SHIFT, true, false),
453443
SOC_ENUM("HPF Corner Freq", cs42l42_hpf_freq_enum),
454444
SOC_ENUM("WNF 3dB Freq", cs42l42_wnf3_freq_enum),
455-
SOC_ENUM("WNF 05dB Freq", cs42l42_wnf05_freq_enum),
456445

457446
/* DAC Volume and Filter Controls */
458447
SOC_SINGLE("DACA Invert Switch", CS42L42_DAC_CTL1,
@@ -471,8 +460,8 @@ static const struct snd_soc_dapm_widget cs42l42_dapm_widgets[] = {
471460
SND_SOC_DAPM_OUTPUT("HP"),
472461
SND_SOC_DAPM_DAC("DAC", NULL, CS42L42_PWR_CTL1, CS42L42_HP_PDN_SHIFT, 1),
473462
SND_SOC_DAPM_MIXER("MIXER", CS42L42_PWR_CTL1, CS42L42_MIXER_PDN_SHIFT, 1, NULL, 0),
474-
SND_SOC_DAPM_AIF_IN("SDIN1", NULL, 0, CS42L42_ASP_RX_DAI0_EN, CS42L42_ASP_RX0_CH1_SHIFT, 0),
475-
SND_SOC_DAPM_AIF_IN("SDIN2", NULL, 1, CS42L42_ASP_RX_DAI0_EN, CS42L42_ASP_RX0_CH2_SHIFT, 0),
463+
SND_SOC_DAPM_AIF_IN("SDIN1", NULL, 0, SND_SOC_NOPM, 0, 0),
464+
SND_SOC_DAPM_AIF_IN("SDIN2", NULL, 1, SND_SOC_NOPM, 0, 0),
476465

477466
/* Playback Requirements */
478467
SND_SOC_DAPM_SUPPLY("ASP DAI0", CS42L42_PWR_CTL1, CS42L42_ASP_DAI_PDN_SHIFT, 1, NULL, 0),
@@ -630,6 +619,8 @@ static int cs42l42_pll_config(struct snd_soc_component *component)
630619

631620
for (i = 0; i < ARRAY_SIZE(pll_ratio_table); i++) {
632621
if (pll_ratio_table[i].sclk == clk) {
622+
cs42l42->pll_config = i;
623+
633624
/* Configure the internal sample rate */
634625
snd_soc_component_update_bits(component, CS42L42_MCLK_CTL,
635626
CS42L42_INTERNAL_FS_MASK,
@@ -638,14 +629,9 @@ static int cs42l42_pll_config(struct snd_soc_component *component)
638629
(pll_ratio_table[i].mclk_int !=
639630
24000000)) <<
640631
CS42L42_INTERNAL_FS_SHIFT);
641-
/* Set the MCLK src (PLL or SCLK) and the divide
642-
* ratio
643-
*/
632+
644633
snd_soc_component_update_bits(component, CS42L42_MCLK_SRC_SEL,
645-
CS42L42_MCLK_SRC_SEL_MASK |
646634
CS42L42_MCLKDIV_MASK,
647-
(pll_ratio_table[i].mclk_src_sel
648-
<< CS42L42_MCLK_SRC_SEL_SHIFT) |
649635
(pll_ratio_table[i].mclk_div <<
650636
CS42L42_MCLKDIV_SHIFT));
651637
/* Set up the LRCLK */
@@ -681,15 +667,6 @@ static int cs42l42_pll_config(struct snd_soc_component *component)
681667
CS42L42_FSYNC_PULSE_WIDTH_MASK,
682668
CS42L42_FRAC1_VAL(fsync - 1) <<
683669
CS42L42_FSYNC_PULSE_WIDTH_SHIFT);
684-
snd_soc_component_update_bits(component,
685-
CS42L42_ASP_FRM_CFG,
686-
CS42L42_ASP_5050_MASK,
687-
CS42L42_ASP_5050_MASK);
688-
/* Set the frame delay to 1.0 SCLK clocks */
689-
snd_soc_component_update_bits(component, CS42L42_ASP_FRM_CFG,
690-
CS42L42_ASP_FSD_MASK,
691-
CS42L42_ASP_FSD_1_0 <<
692-
CS42L42_ASP_FSD_SHIFT);
693670
/* Set the sample rates (96k or lower) */
694671
snd_soc_component_update_bits(component, CS42L42_FS_RATE_EN,
695672
CS42L42_FS_EN_MASK,
@@ -789,7 +766,18 @@ static int cs42l42_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
789766
/* interface format */
790767
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
791768
case SND_SOC_DAIFMT_I2S:
792-
case SND_SOC_DAIFMT_LEFT_J:
769+
/*
770+
* 5050 mode, frame starts on falling edge of LRCLK,
771+
* frame delayed by 1.0 SCLKs
772+
*/
773+
snd_soc_component_update_bits(component,
774+
CS42L42_ASP_FRM_CFG,
775+
CS42L42_ASP_STP_MASK |
776+
CS42L42_ASP_5050_MASK |
777+
CS42L42_ASP_FSD_MASK,
778+
CS42L42_ASP_5050_MASK |
779+
(CS42L42_ASP_FSD_1_0 <<
780+
CS42L42_ASP_FSD_SHIFT));
793781
break;
794782
default:
795783
return -EINVAL;
@@ -819,6 +807,25 @@ static int cs42l42_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
819807
return 0;
820808
}
821809

810+
static int cs42l42_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
811+
{
812+
struct snd_soc_component *component = dai->component;
813+
struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component);
814+
815+
/*
816+
* Sample rates < 44.1 kHz would produce an out-of-range SCLK with
817+
* a standard I2S frame. If the machine driver sets SCLK it must be
818+
* legal.
819+
*/
820+
if (cs42l42->sclk)
821+
return 0;
822+
823+
/* Machine driver has not set a SCLK, limit bottom end to 44.1 kHz */
824+
return snd_pcm_hw_constraint_minmax(substream->runtime,
825+
SNDRV_PCM_HW_PARAM_RATE,
826+
44100, 192000);
827+
}
828+
822829
static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream,
823830
struct snd_pcm_hw_params *params,
824831
struct snd_soc_dai *dai)
@@ -832,6 +839,10 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream,
832839
cs42l42->srate = params_rate(params);
833840
cs42l42->bclk = snd_soc_params_to_bclk(params);
834841

842+
/* I2S frame always has 2 channels even for mono audio */
843+
if (channels == 1)
844+
cs42l42->bclk *= 2;
845+
835846
switch(substream->stream) {
836847
case SNDRV_PCM_STREAM_CAPTURE:
837848
if (channels == 2) {
@@ -855,6 +866,17 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream,
855866
snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_CH2_AP_RES,
856867
CS42L42_ASP_RX_CH_AP_MASK |
857868
CS42L42_ASP_RX_CH_RES_MASK, val);
869+
870+
/* Channel B comes from the last active channel */
871+
snd_soc_component_update_bits(component, CS42L42_SP_RX_CH_SEL,
872+
CS42L42_SP_RX_CHB_SEL_MASK,
873+
(channels - 1) << CS42L42_SP_RX_CHB_SEL_SHIFT);
874+
875+
/* Both LRCLK slots must be enabled */
876+
snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_EN,
877+
CS42L42_ASP_RX0_CH_EN_MASK,
878+
BIT(CS42L42_ASP_RX0_CH1_SHIFT) |
879+
BIT(CS42L42_ASP_RX0_CH2_SHIFT));
858880
break;
859881
default:
860882
break;
@@ -900,13 +922,21 @@ static int cs42l42_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
900922
*/
901923
regmap_multi_reg_write(cs42l42->regmap, cs42l42_to_osc_seq,
902924
ARRAY_SIZE(cs42l42_to_osc_seq));
925+
926+
/* Must disconnect PLL before stopping it */
927+
snd_soc_component_update_bits(component,
928+
CS42L42_MCLK_SRC_SEL,
929+
CS42L42_MCLK_SRC_SEL_MASK,
930+
0);
931+
usleep_range(100, 200);
932+
903933
snd_soc_component_update_bits(component, CS42L42_PLL_CTL1,
904934
CS42L42_PLL_START_MASK, 0);
905935
}
906936
} else {
907937
if (!cs42l42->stream_use) {
908938
/* SCLK must be running before codec unmute */
909-
if ((cs42l42->bclk < 11289600) && (cs42l42->sclk < 11289600)) {
939+
if (pll_ratio_table[cs42l42->pll_config].mclk_src_sel) {
910940
snd_soc_component_update_bits(component, CS42L42_PLL_CTL1,
911941
CS42L42_PLL_START_MASK, 1);
912942

@@ -927,6 +957,12 @@ static int cs42l42_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
927957
CS42L42_PLL_LOCK_TIMEOUT_US);
928958
if (ret < 0)
929959
dev_warn(component->dev, "PLL failed to lock: %d\n", ret);
960+
961+
/* PLL must be running to drive glitchless switch logic */
962+
snd_soc_component_update_bits(component,
963+
CS42L42_MCLK_SRC_SEL,
964+
CS42L42_MCLK_SRC_SEL_MASK,
965+
CS42L42_MCLK_SRC_SEL_MASK);
930966
}
931967

932968
/* Mark SCLK as present, turn off internal oscillator */
@@ -960,8 +996,8 @@ static int cs42l42_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
960996
SNDRV_PCM_FMTBIT_S24_LE |\
961997
SNDRV_PCM_FMTBIT_S32_LE )
962998

963-
964999
static const struct snd_soc_dai_ops cs42l42_ops = {
1000+
.startup = cs42l42_dai_startup,
9651001
.hw_params = cs42l42_pcm_hw_params,
9661002
.set_fmt = cs42l42_set_dai_fmt,
9671003
.set_sysclk = cs42l42_set_sysclk,

0 commit comments

Comments
 (0)