* [PATCH v2 1/3] ASoC: qcom: audioreach: Commonize setting channel mappings
@ 2023-11-30 18:07 Krzysztof Kozlowski
2023-11-30 18:07 ` [PATCH v2 2/3] ASoC: qcom: audioreach: drop duplicate channel defines Krzysztof Kozlowski
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-11-30 18:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-sound,
linux-kernel
Cc: Krzysztof Kozlowski
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: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
Changes in v2:
1. New patch
---
sound/soc/qcom/qdsp6/audioreach.c | 35 ++++++++++++++-----------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
index 5974c7929dd3..3db5ff367a29 100644
--- a/sound/soc/qcom/qdsp6/audioreach.c
+++ b/sound/soc/qcom/qdsp6/audioreach.c
@@ -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);
+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,
struct audioreach_container *cont)
{
@@ -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->num_channels = mcfg->num_channels;
- if (mcfg->num_channels == 1) {
- mp3_cfg->channel_mapping[0] = PCM_CHANNEL_L;
- } else if (mcfg->num_channels == 2) {
- mp3_cfg->channel_mapping[0] = PCM_CHANNEL_L;
- mp3_cfg->channel_mapping[1] = PCM_CHANNEL_R;
- }
+ audioreach_set_channel_mapping(mp3_cfg->channel_mapping,
+ mcfg->num_channels);
break;
case SND_AUDIOCODEC_AAC:
media_fmt_hdr->data_format = DATA_FORMAT_RAW_COMPRESSED;
@@ -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->bits_per_sample = mcfg->bit_width;
- if (num_channels == 1) {
- media_cfg->channel_mapping[0] = PCM_CHANNEL_L;
- } else if (num_channels == 2) {
- media_cfg->channel_mapping[0] = PCM_CHANNEL_L;
- media_cfg->channel_mapping[1] = PCM_CHANNEL_R;
-
- }
+ audioreach_set_channel_mapping(media_cfg->channel_mapping,
+ num_channels);
rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
@@ -1153,12 +1154,8 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph,
cfg->endianness = PCM_LITTLE_ENDIAN;
cfg->num_channels = mcfg->num_channels;
- if (mcfg->num_channels == 1)
- cfg->channel_mapping[0] = PCM_CHANNEL_L;
- else if (num_channels == 2) {
- cfg->channel_mapping[0] = PCM_CHANNEL_L;
- cfg->channel_mapping[1] = PCM_CHANNEL_R;
- }
+ audioreach_set_channel_mapping(cfg->channel_mapping,
+ num_channels);
} else {
rc = audioreach_set_compr_media_format(header, p, mcfg);
if (rc) {
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] ASoC: qcom: audioreach: drop duplicate channel defines
2023-11-30 18:07 [PATCH v2 1/3] ASoC: qcom: audioreach: Commonize setting channel mappings Krzysztof Kozlowski
@ 2023-11-30 18:07 ` Krzysztof Kozlowski
2023-11-30 18:07 ` [PATCH v2 3/3] ASoC: qcom: audioreach: Add 4 channel support Krzysztof Kozlowski
2023-12-11 16:20 ` [PATCH v2 1/3] ASoC: qcom: audioreach: Commonize setting channel mappings Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-11-30 18:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-sound,
linux-kernel
Cc: Krzysztof Kozlowski
q6apm.h header already defines channel mapping values, so drop
duplicated devices from audioreach.h.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
Changes in v2:
1. New patch
---
sound/soc/qcom/qdsp6/audioreach.c | 12 ++++++------
sound/soc/qcom/qdsp6/audioreach.h | 2 --
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
index 3db5ff367a29..5c7113d46b6f 100644
--- a/sound/soc/qcom/qdsp6/audioreach.c
+++ b/sound/soc/qcom/qdsp6/audioreach.c
@@ -270,10 +270,10 @@ 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;
+ ch_map[0] = PCM_CHANNEL_FL;
} else if (num_channels == 2) {
- ch_map[0] = PCM_CHANNEL_L;
- ch_map[1] = PCM_CHANNEL_R;
+ ch_map[0] = PCM_CHANNEL_FL;
+ ch_map[1] = PCM_CHANNEL_FR;
}
}
@@ -839,10 +839,10 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
media_format->num_channels = cfg->num_channels;
if (num_channels == 1) {
- media_format->channel_mapping[0] = PCM_CHANNEL_L;
+ media_format->channel_mapping[0] = PCM_CHANNEL_FL;
} else if (num_channels == 2) {
- media_format->channel_mapping[0] = PCM_CHANNEL_L;
- media_format->channel_mapping[1] = PCM_CHANNEL_R;
+ media_format->channel_mapping[0] = PCM_CHANNEL_FL;
+ media_format->channel_mapping[1] = PCM_CHANNEL_FR;
}
rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h
index e38111ffd7b9..2c82917b7162 100644
--- a/sound/soc/qcom/qdsp6/audioreach.h
+++ b/sound/soc/qcom/qdsp6/audioreach.h
@@ -158,8 +158,6 @@ struct param_id_enc_bitrate_param {
#define MEDIA_FMT_ID_PCM 0x09001000
#define MEDIA_FMT_ID_MP3 0x09001009
-#define PCM_CHANNEL_L 1
-#define PCM_CHANNEL_R 2
#define SAMPLE_RATE_48K 48000
#define BIT_WIDTH_16 16
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] ASoC: qcom: audioreach: Add 4 channel support
2023-11-30 18:07 [PATCH v2 1/3] ASoC: qcom: audioreach: Commonize setting channel mappings Krzysztof Kozlowski
2023-11-30 18:07 ` [PATCH v2 2/3] ASoC: qcom: audioreach: drop duplicate channel defines Krzysztof Kozlowski
@ 2023-11-30 18:07 ` Krzysztof Kozlowski
2023-12-11 16:20 ` [PATCH v2 1/3] ASoC: qcom: audioreach: Commonize setting channel mappings Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-11-30 18:07 UTC (permalink / raw)
To: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-sound,
linux-kernel
Cc: Krzysztof Kozlowski
Add support four channel streams. Map channel 3 and 4 to left/right
surround ("quad(side)" from ffmpeg standard channel list) to match what
is in qdsp6/q6dsp-common.c driver.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
Changes in v2:
1. Rebase to avoid duplicate code.
v1:
https://lore.kernel.org/alsa-devel/20231020084919.18628-1-krzysztof.kozlowski@linaro.org/
quad(side):
https://trac.ffmpeg.org/wiki/AudioChannelManipulation#Listchannelnamesandstandardchannellayouts
---
sound/soc/qcom/qdsp6/audioreach.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
index 5c7113d46b6f..5291deac0a0b 100644
--- a/sound/soc/qcom/qdsp6/audioreach.c
+++ b/sound/soc/qcom/qdsp6/audioreach.c
@@ -274,6 +274,11 @@ static void audioreach_set_channel_mapping(u8 *ch_map, int num_channels)
} else if (num_channels == 2) {
ch_map[0] = PCM_CHANNEL_FL;
ch_map[1] = PCM_CHANNEL_FR;
+ } else if (num_channels == 4) {
+ ch_map[0] = PCM_CHANNEL_FL;
+ ch_map[1] = PCM_CHANNEL_FR;
+ ch_map[2] = PCM_CHANNEL_LS;
+ ch_map[3] = PCM_CHANNEL_RS;
}
}
@@ -843,6 +848,11 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
} else if (num_channels == 2) {
media_format->channel_mapping[0] = PCM_CHANNEL_FL;
media_format->channel_mapping[1] = PCM_CHANNEL_FR;
+ } else if (num_channels == 4) {
+ media_format->channel_mapping[0] = PCM_CHANNEL_FL;
+ media_format->channel_mapping[1] = PCM_CHANNEL_FR;
+ media_format->channel_mapping[2] = PCM_CHANNEL_LS;
+ media_format->channel_mapping[3] = PCM_CHANNEL_RS;
}
rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
@@ -1063,7 +1073,7 @@ static int audioreach_pcm_set_media_format(struct q6apm_graph *graph,
int rc, payload_size;
struct gpr_pkt *pkt;
- if (num_channels > 2) {
+ if (num_channels > 4) {
dev_err(graph->dev, "Error: Invalid channels (%d)!\n", num_channels);
return -EINVAL;
}
@@ -1117,7 +1127,7 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph,
struct gpr_pkt *pkt;
void *p;
- if (num_channels > 2) {
+ if (num_channels > 4) {
dev_err(graph->dev, "Error: Invalid channels (%d)!\n", num_channels);
return -EINVAL;
}
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/3] ASoC: qcom: audioreach: Commonize setting channel mappings
2023-11-30 18:07 [PATCH v2 1/3] ASoC: qcom: audioreach: Commonize setting channel mappings Krzysztof Kozlowski
2023-11-30 18:07 ` [PATCH v2 2/3] ASoC: qcom: audioreach: drop duplicate channel defines Krzysztof Kozlowski
2023-11-30 18:07 ` [PATCH v2 3/3] ASoC: qcom: audioreach: Add 4 channel support Krzysztof Kozlowski
@ 2023-12-11 16:20 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-12-11 16:20 UTC (permalink / raw)
To: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-sound,
linux-kernel, Krzysztof Kozlowski
On Thu, 30 Nov 2023 19:07:56 +0100, Krzysztof Kozlowski wrote:
> 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).
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/3] ASoC: qcom: audioreach: Commonize setting channel mappings
commit: ef14f40a3613ddd43a8dd736b5df6f865dcbb817
[2/3] ASoC: qcom: audioreach: drop duplicate channel defines
commit: bcd684eae5aefc0688fcf43fd555155dd57f27c9
[3/3] ASoC: qcom: audioreach: Add 4 channel support
commit: 3c5fcb20e07e3681a645fc3a8d890478ca320825
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-12-11 16:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30 18:07 [PATCH v2 1/3] ASoC: qcom: audioreach: Commonize setting channel mappings Krzysztof Kozlowski
2023-11-30 18:07 ` [PATCH v2 2/3] ASoC: qcom: audioreach: drop duplicate channel defines Krzysztof Kozlowski
2023-11-30 18:07 ` [PATCH v2 3/3] ASoC: qcom: audioreach: Add 4 channel support Krzysztof Kozlowski
2023-12-11 16:20 ` [PATCH v2 1/3] ASoC: qcom: audioreach: Commonize setting channel mappings Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®