Skip to content

Commit a34547b

Browse files
clamor-sbroonie
authored andcommitted
ASoC: tegra: Support CPCAP by machine driver
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>
1 parent d6b634c commit a34547b

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

sound/soc/tegra/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ config SND_SOC_TEGRA_SGTL5000
294294
boards using the SGTL5000 codec, such as Apalis T30, Apalis TK1 or
295295
Colibri T30.
296296

297+
config SND_SOC_TEGRA_CPCAP
298+
tristate "SoC Audio support for Tegra boards using a CPCAP codec"
299+
depends on I2C && GPIOLIB && MFD_CPCAP
300+
select SND_SOC_TEGRA_MACHINE_DRV
301+
select SND_SOC_CPCAP
302+
help
303+
Say Y or M here if you want to add support for SoC audio on Tegra
304+
boards using the CPCAP codec, such as Motorola Atrix 4G or Droid X2.
305+
297306
endif
298307

299308
endmenu

sound/soc/tegra/tegra_asoc_machine.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,25 @@ static unsigned int tegra_machine_mclk_rate_6mhz(unsigned int srate)
287287
return mclk;
288288
}
289289

290+
static unsigned int tegra_machine_mclk_rate_cpcap(unsigned int srate)
291+
{
292+
unsigned int mclk;
293+
294+
switch (srate) {
295+
case 11025:
296+
case 22050:
297+
case 44100:
298+
case 88200:
299+
mclk = 26000000;
300+
break;
301+
default:
302+
mclk = 256 * srate;
303+
break;
304+
}
305+
306+
return mclk;
307+
}
308+
290309
static int tegra_machine_hw_params(struct snd_pcm_substream *substream,
291310
struct snd_pcm_hw_params *params)
292311
{
@@ -985,6 +1004,38 @@ static const struct tegra_asoc_data tegra_rt5631_data = {
9851004
.add_hp_jack = true,
9861005
};
9871006

1007+
/* CPCAP machine */
1008+
1009+
SND_SOC_DAILINK_DEFS(cpcap_hifi,
1010+
DAILINK_COMP_ARRAY(COMP_EMPTY()),
1011+
DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "cpcap-hifi")),
1012+
DAILINK_COMP_ARRAY(COMP_EMPTY()));
1013+
1014+
static struct snd_soc_dai_link tegra_cpcap_dai = {
1015+
.name = "CPCAP",
1016+
.stream_name = "CPCAP PCM",
1017+
.init = tegra_asoc_machine_init,
1018+
.dai_fmt = SND_SOC_DAIFMT_I2S |
1019+
SND_SOC_DAIFMT_NB_NF |
1020+
SND_SOC_DAIFMT_CBP_CFP,
1021+
SND_SOC_DAILINK_REG(cpcap_hifi),
1022+
};
1023+
1024+
static struct snd_soc_card snd_soc_tegra_cpcap = {
1025+
.components = "codec:cpcap",
1026+
.dai_link = &tegra_cpcap_dai,
1027+
.num_links = 1,
1028+
.fully_routed = true,
1029+
};
1030+
1031+
static const struct tegra_asoc_data tegra_cpcap_data = {
1032+
.mclk_rate = tegra_machine_mclk_rate_cpcap,
1033+
.card = &snd_soc_tegra_cpcap,
1034+
.add_common_dapm_widgets = true,
1035+
.add_common_controls = true,
1036+
.add_common_snd_ops = true,
1037+
};
1038+
9881039
static const struct of_device_id tegra_machine_of_match[] = {
9891040
{ .compatible = "nvidia,tegra-audio-trimslice", .data = &tegra_trimslice_data },
9901041
{ .compatible = "nvidia,tegra-audio-max98090", .data = &tegra_max98090_data },
@@ -997,6 +1048,7 @@ static const struct of_device_id tegra_machine_of_match[] = {
9971048
{ .compatible = "nvidia,tegra-audio-rt5640", .data = &tegra_rt5640_data },
9981049
{ .compatible = "nvidia,tegra-audio-alc5632", .data = &tegra_rt5632_data },
9991050
{ .compatible = "nvidia,tegra-audio-rt5631", .data = &tegra_rt5631_data },
1051+
{ .compatible = "nvidia,tegra-audio-cpcap", .data = &tegra_cpcap_data },
10001052
{},
10011053
};
10021054
MODULE_DEVICE_TABLE(of, tegra_machine_of_match);

0 commit comments

Comments
 (0)