• Alper Nebi Yasak's avatar
    ASoC: amd: acp: Add kcontrols and widgets per-codec in common code · 919a4a94
    Alper Nebi Yasak authored
    Commit 7ac3404c ("ASoC: amd: acp: Map missing jack kcontrols") adds
    card kcontrols and DAPM widgets corresponding to jacks for Headphone and
    Headset Mic. But these were already being added in acp-legacy-mach.c and
    acp-sof-mach.c, so this causes a probe error:
    
      sof_mach rt5682s-hs-rt1019: control 2:0:0:Headphone Jack Switch:0 is already present
      sof_mach rt5682s-hs-rt1019: ASoC: Failed to add Headphone Jack Switch: -16
      sof_mach rt5682s-hs-rt1019: devm_snd_soc_register_card(sof-rt5682s-hs-rt1019) failed: -16
      sof_mach: probe of rt5682s-hs-rt1019 failed with error -16
    
    Removing the new duplicates from the common code might be enough to fix
    the issue. But some of the codecs use different kcontrols and widgets.
    NAU8821 alone has an "Int Mic". MAX98360A has a single "Spk", while
    RT1019 has "Left Spk" and "Right Spk" (and two codec instances with name
    prefixes).
    
    Since there are per-codec differences, add the kcontrols and widgets
    in the common code as each dai-link is being initialized, instead of in
    the two machine drivers' probe().
    
    Also, MAX98388 has Left and Right instances, but uses a single "SPK"
    widget. That seems weird, so normalize it to use two widgets (one per
    each instance like RT1019) while we're adding controls.
    
    Fixes: 7ac3404c ("ASoC: amd: acp: Map missing jack kcontrols")
    Signed-off-by: default avatarAlper Nebi Yasak <alpernebiyasak@gmail.com>
    Link: https://lore.kernel.org/r/20230818080314.32991-1-alpernebiyasak@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
    919a4a94
acp-mach-common.c 46.8 KB