]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: tegra: Support CPCAP by machine driver
authorSvyatoslav Ryhel <clamor95@gmail.com>
Mon, 23 Feb 2026 06:50:48 +0000 (08:50 +0200)
committerMark Brown <broonie@kernel.org>
Sun, 1 Mar 2026 23:48:29 +0000 (23:48 +0000)
Add CPCAP codec support to the Tegra ASoC machine driver. This codec is
found in Motorola T20 devices like Atrix 4G and Droid X2.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Link: https://patch.msgid.link/20260223065051.13070-3-clamor95@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/tegra/Kconfig
sound/soc/tegra/tegra_asoc_machine.c

index 9dbd589879fb8182de0c559f374167b58a0a6c01..dd58525b70790696e4db4ef927c81e2ca22a9efd 100644 (file)
@@ -294,6 +294,15 @@ config SND_SOC_TEGRA_SGTL5000
          boards using the SGTL5000 codec, such as Apalis T30, Apalis TK1 or
          Colibri T30.
 
+config SND_SOC_TEGRA_CPCAP
+       tristate "SoC Audio support for Tegra boards using a CPCAP codec"
+       depends on I2C && GPIOLIB && MFD_CPCAP
+       select SND_SOC_TEGRA_MACHINE_DRV
+       select SND_SOC_CPCAP
+       help
+         Say Y or M here if you want to add support for SoC audio on Tegra
+         boards using the CPCAP codec, such as Motorola Atrix 4G or Droid X2.
+
 endif
 
 endmenu
index d48463ac16fc2ae85094a8509c5fe01db59535a7..10834f9c342236b83081d5535f940087cdc62b52 100644 (file)
@@ -287,6 +287,25 @@ static unsigned int tegra_machine_mclk_rate_6mhz(unsigned int srate)
        return mclk;
 }
 
+static unsigned int tegra_machine_mclk_rate_cpcap(unsigned int srate)
+{
+       unsigned int mclk;
+
+       switch (srate) {
+       case 11025:
+       case 22050:
+       case 44100:
+       case 88200:
+               mclk = 26000000;
+               break;
+       default:
+               mclk = 256 * srate;
+               break;
+       }
+
+       return mclk;
+}
+
 static int tegra_machine_hw_params(struct snd_pcm_substream *substream,
                                   struct snd_pcm_hw_params *params)
 {
@@ -985,6 +1004,38 @@ static const struct tegra_asoc_data tegra_rt5631_data = {
        .add_hp_jack = true,
 };
 
+/* CPCAP machine */
+
+SND_SOC_DAILINK_DEFS(cpcap_hifi,
+       DAILINK_COMP_ARRAY(COMP_EMPTY()),
+       DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "cpcap-hifi")),
+       DAILINK_COMP_ARRAY(COMP_EMPTY()));
+
+static struct snd_soc_dai_link tegra_cpcap_dai = {
+       .name = "CPCAP",
+       .stream_name = "CPCAP PCM",
+       .init = tegra_asoc_machine_init,
+       .dai_fmt = SND_SOC_DAIFMT_I2S |
+                  SND_SOC_DAIFMT_NB_NF |
+                  SND_SOC_DAIFMT_CBP_CFP,
+       SND_SOC_DAILINK_REG(cpcap_hifi),
+};
+
+static struct snd_soc_card snd_soc_tegra_cpcap = {
+       .components = "codec:cpcap",
+       .dai_link = &tegra_cpcap_dai,
+       .num_links = 1,
+       .fully_routed = true,
+};
+
+static const struct tegra_asoc_data tegra_cpcap_data = {
+       .mclk_rate = tegra_machine_mclk_rate_cpcap,
+       .card = &snd_soc_tegra_cpcap,
+       .add_common_dapm_widgets = true,
+       .add_common_controls = true,
+       .add_common_snd_ops = true,
+};
+
 static const struct of_device_id tegra_machine_of_match[] = {
        { .compatible = "nvidia,tegra-audio-trimslice", .data = &tegra_trimslice_data },
        { .compatible = "nvidia,tegra-audio-max98090", .data = &tegra_max98090_data },
@@ -997,6 +1048,7 @@ static const struct of_device_id tegra_machine_of_match[] = {
        { .compatible = "nvidia,tegra-audio-rt5640", .data = &tegra_rt5640_data },
        { .compatible = "nvidia,tegra-audio-alc5632", .data = &tegra_rt5632_data },
        { .compatible = "nvidia,tegra-audio-rt5631", .data = &tegra_rt5631_data },
+       { .compatible = "nvidia,tegra-audio-cpcap", .data = &tegra_cpcap_data },
        {},
 };
 MODULE_DEVICE_TABLE(of, tegra_machine_of_match);