Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/sound/soc_sdw_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ int asoc_sdw_cs_amp_init(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_links,
struct asoc_sdw_codec_info *info,
bool playback);
int asoc_sdw_cs_spk_feedback_rtd_init(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_dai *dai);

/* MAXIM codec support */
int asoc_sdw_maxim_init(struct snd_soc_card *card,
Expand Down
8 changes: 7 additions & 1 deletion sound/soc/codecs/cs35l56.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,12 @@ static struct snd_soc_dai_driver cs35l56_dai[] = {
.rates = CS35L56_RATES,
.formats = CS35L56_RX_FORMATS,
},
.symmetric_rate = 1,
.ops = &cs35l56_sdw_dai_ops,
},
{
.name = "cs35l56-sdw1c",
.id = 2,
.capture = {
.stream_name = "SDW1 Capture",
.channels_min = 1,
Expand All @@ -655,7 +661,7 @@ static struct snd_soc_dai_driver cs35l56_dai[] = {
},
.symmetric_rate = 1,
.ops = &cs35l56_sdw_dai_ops,
}
},
};

static int cs35l56_write_cal(struct cs35l56_private *cs35l56)
Expand Down
76 changes: 68 additions & 8 deletions sound/soc/intel/common/soc-acpi-intel-mtl-match.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,66 @@ static const struct snd_soc_acpi_adr_device cs42l43_0_adr[] = {
}
};

static const struct snd_soc_acpi_endpoint cs35l56_l_fb_endpoints[] = {
{ /* Speaker Playback Endpoint */
.num = 0,
.aggregated = 1,
.group_position = 0,
.group_id = 1,
},
{ /* Feedback Capture Endpoint */
.num = 1,
.aggregated = 1,
.group_position = 0,
.group_id = 2,
},
};

static const struct snd_soc_acpi_endpoint cs35l56_r_fb_endpoints[] = {
{ /* Speaker Playback Endpoint */
.num = 0,
.aggregated = 1,
.group_position = 1,
.group_id = 1,
},
{ /* Feedback Capture Endpoint */
.num = 1,
.aggregated = 1,
.group_position = 1,
.group_id = 2,
},
};

static const struct snd_soc_acpi_endpoint cs35l56_2_fb_endpoints[] = {
{ /* Speaker Playback Endpoint */
.num = 0,
.aggregated = 1,
.group_position = 2,
.group_id = 1,
},
{ /* Feedback Capture Endpoint */
.num = 1,
.aggregated = 1,
.group_position = 2,
.group_id = 2,
},
};

static const struct snd_soc_acpi_endpoint cs35l56_3_fb_endpoints[] = {
{ /* Speaker Playback Endpoint */
.num = 0,
.aggregated = 1,
.group_position = 3,
.group_id = 1,
},
{ /* Feedback Capture Endpoint */
.num = 1,
.aggregated = 1,
.group_position = 3,
.group_id = 2,
},
};

static const struct snd_soc_acpi_adr_device cs35l56_1_adr[] = {
{
.adr = 0x00013701FA355601ull,
Expand Down Expand Up @@ -474,14 +534,14 @@ static const struct snd_soc_acpi_adr_device cs35l56_2_adr[] = {
static const struct snd_soc_acpi_adr_device cs35l56_2_r_adr[] = {
{
.adr = 0x00023201FA355601ull,
.num_endpoints = 1,
.endpoints = &spk_r_endpoint,
.num_endpoints = ARRAY_SIZE(cs35l56_r_fb_endpoints),
.endpoints = cs35l56_r_fb_endpoints,
.name_prefix = "AMP3"
},
{
.adr = 0x00023301FA355601ull,
.num_endpoints = 1,
.endpoints = &spk_3_endpoint,
.num_endpoints = ARRAY_SIZE(cs35l56_3_fb_endpoints),
.endpoints = cs35l56_3_fb_endpoints,
.name_prefix = "AMP4"
}

Expand All @@ -490,14 +550,14 @@ static const struct snd_soc_acpi_adr_device cs35l56_2_r_adr[] = {
static const struct snd_soc_acpi_adr_device cs35l56_3_l_adr[] = {
{
.adr = 0x00033001fa355601ull,
.num_endpoints = 1,
.endpoints = &spk_l_endpoint,
.num_endpoints = ARRAY_SIZE(cs35l56_l_fb_endpoints),
.endpoints = cs35l56_l_fb_endpoints,
.name_prefix = "AMP1"
},
{
.adr = 0x00033101fa355601ull,
.num_endpoints = 1,
.endpoints = &spk_2_endpoint,
.num_endpoints = ARRAY_SIZE(cs35l56_2_fb_endpoints),
.endpoints = cs35l56_2_fb_endpoints,
.name_prefix = "AMP2"
}
};
Expand Down
46 changes: 46 additions & 0 deletions sound/soc/sdw_utils/soc_sdw_cs_amp.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <sound/soc_sdw_utils.h>

#define CODEC_NAME_SIZE 8
#define CS_AMP_CHANNELS_PER_AMP 4

int asoc_sdw_cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
{
Expand Down Expand Up @@ -48,6 +49,51 @@ int asoc_sdw_cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai
}
EXPORT_SYMBOL_NS(asoc_sdw_cs_spk_rtd_init, SND_SOC_SDW_UTILS);

int asoc_sdw_cs_spk_feedback_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
{
const struct snd_soc_dai_link *dai_link = rtd->dai_link;
const struct snd_soc_dai_link_ch_map *ch_map;
const struct snd_soc_dai_link_component *codec_dlc;
struct snd_soc_dai *codec_dai;
u8 ch_slot[8] = {};
unsigned int amps_per_bus, ch_per_amp, mask;
int i, ret;

WARN_ON(dai_link->num_cpus > ARRAY_SIZE(ch_slot));

/*
* CS35L56 has 4 TX channels. When the capture is aggregated the
* same bus slots will be allocated to all the amps on a bus. Only
* one amp on that bus can be transmitting in each slot so divide
* the available 4 slots between all the amps on a bus.
*/
amps_per_bus = dai_link->num_codecs / dai_link->num_cpus;
if ((amps_per_bus == 0) || (amps_per_bus > CS_AMP_CHANNELS_PER_AMP)) {
dev_err(rtd->card->dev, "Illegal num_codecs:%u / num_cpus:%u\n",
dai_link->num_codecs, dai_link->num_cpus);
return -EINVAL;
}

ch_per_amp = CS_AMP_CHANNELS_PER_AMP / amps_per_bus;

for_each_rtd_ch_maps(rtd, i, ch_map) {
codec_dlc = snd_soc_link_to_codec(rtd->dai_link, i);
codec_dai = snd_soc_find_dai(codec_dlc);
mask = GENMASK(ch_per_amp - 1, 0) << ch_slot[ch_map->cpu];

ret = snd_soc_dai_set_tdm_slot(codec_dai, 0, mask, 4, 32);
if (ret < 0) {
dev_err(rtd->card->dev, "Failed to set TDM slot:%d\n", ret);
return ret;
}

ch_slot[ch_map->cpu] += ch_per_amp;
}

return 0;
}
EXPORT_SYMBOL_NS(asoc_sdw_cs_spk_feedback_rtd_init, SND_SOC_SDW_UTILS);

int asoc_sdw_cs_amp_init(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_links,
struct asoc_sdw_codec_info *info,
Expand Down
13 changes: 10 additions & 3 deletions sound/soc/sdw_utils/soc_sdw_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,19 +488,26 @@ struct asoc_sdw_codec_info codec_info_list[] = {
.part_id = 0x3556,
.dais = {
{
.direction = {true, true},
.direction = {true, false},
.dai_name = "cs35l56-sdw1",
.dai_type = SOC_SDW_DAI_TYPE_AMP,
.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_AMP_IN_DAI_ID},
.dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
.init = asoc_sdw_cs_amp_init,
.rtd_init = asoc_sdw_cs_spk_rtd_init,
.controls = generic_spk_controls,
.num_controls = ARRAY_SIZE(generic_spk_controls),
.widgets = generic_spk_widgets,
.num_widgets = ARRAY_SIZE(generic_spk_widgets),
},
{
.direction = {false, true},
.dai_name = "cs35l56-sdw1c",
.dai_type = SOC_SDW_DAI_TYPE_AMP,
.dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_AMP_IN_DAI_ID},
.rtd_init = asoc_sdw_cs_spk_feedback_rtd_init,
},
},
.dai_num = 1,
.dai_num = 2,
},
{
.part_id = 0x4242,
Expand Down
Loading