Commit ef14f40a authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown

ASoC: qcom: audioreach: Commonize setting channel mappings

Move code assigning channel mapping values to a common helper function.
This simplifies three out of four cases, with the last case using
incompatible type (uint16_t array instead of uint8_t array).
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://msgid.link/r/20231130180758.212172-1-krzysztof.kozlowski@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 5012f9d8
...@@ -267,6 +267,16 @@ void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t token ...@@ -267,6 +267,16 @@ void *audioreach_alloc_apm_cmd_pkt(int pkt_size, uint32_t opcode, uint32_t token
} }
EXPORT_SYMBOL_GPL(audioreach_alloc_apm_cmd_pkt); EXPORT_SYMBOL_GPL(audioreach_alloc_apm_cmd_pkt);
static void audioreach_set_channel_mapping(u8 *ch_map, int num_channels)
{
if (num_channels == 1) {
ch_map[0] = PCM_CHANNEL_L;
} else if (num_channels == 2) {
ch_map[0] = PCM_CHANNEL_L;
ch_map[1] = PCM_CHANNEL_R;
}
}
static void apm_populate_container_config(struct apm_container_obj *cfg, static void apm_populate_container_config(struct apm_container_obj *cfg,
struct audioreach_container *cont) struct audioreach_container *cont)
{ {
...@@ -864,12 +874,8 @@ static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr, ...@@ -864,12 +874,8 @@ static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr,
mp3_cfg->endianness = PCM_LITTLE_ENDIAN; mp3_cfg->endianness = PCM_LITTLE_ENDIAN;
mp3_cfg->num_channels = mcfg->num_channels; mp3_cfg->num_channels = mcfg->num_channels;
if (mcfg->num_channels == 1) { audioreach_set_channel_mapping(mp3_cfg->channel_mapping,
mp3_cfg->channel_mapping[0] = PCM_CHANNEL_L; mcfg->num_channels);
} else if (mcfg->num_channels == 2) {
mp3_cfg->channel_mapping[0] = PCM_CHANNEL_L;
mp3_cfg->channel_mapping[1] = PCM_CHANNEL_R;
}
break; break;
case SND_AUDIOCODEC_AAC: case SND_AUDIOCODEC_AAC:
media_fmt_hdr->data_format = DATA_FORMAT_RAW_COMPRESSED; media_fmt_hdr->data_format = DATA_FORMAT_RAW_COMPRESSED;
...@@ -1089,13 +1095,8 @@ static int audioreach_pcm_set_media_format(struct q6apm_graph *graph, ...@@ -1089,13 +1095,8 @@ static int audioreach_pcm_set_media_format(struct q6apm_graph *graph,
media_cfg->q_factor = mcfg->bit_width - 1; media_cfg->q_factor = mcfg->bit_width - 1;
media_cfg->bits_per_sample = mcfg->bit_width; media_cfg->bits_per_sample = mcfg->bit_width;
if (num_channels == 1) { audioreach_set_channel_mapping(media_cfg->channel_mapping,
media_cfg->channel_mapping[0] = PCM_CHANNEL_L; num_channels);
} else if (num_channels == 2) {
media_cfg->channel_mapping[0] = PCM_CHANNEL_L;
media_cfg->channel_mapping[1] = PCM_CHANNEL_R;
}
rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
...@@ -1153,12 +1154,8 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph, ...@@ -1153,12 +1154,8 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph,
cfg->endianness = PCM_LITTLE_ENDIAN; cfg->endianness = PCM_LITTLE_ENDIAN;
cfg->num_channels = mcfg->num_channels; cfg->num_channels = mcfg->num_channels;
if (mcfg->num_channels == 1) audioreach_set_channel_mapping(cfg->channel_mapping,
cfg->channel_mapping[0] = PCM_CHANNEL_L; num_channels);
else if (num_channels == 2) {
cfg->channel_mapping[0] = PCM_CHANNEL_L;
cfg->channel_mapping[1] = PCM_CHANNEL_R;
}
} else { } else {
rc = audioreach_set_compr_media_format(header, p, mcfg); rc = audioreach_set_compr_media_format(header, p, mcfg);
if (rc) { if (rc) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment