ASoC: qcom: audioreach: Add 4 channel support
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Thu, 30 Nov 2023 18:07:58 +0000 (19:07 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 11 Dec 2023 12:54:10 +0000 (12:54 +0000)
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>
Link: https://msgid.link/r/20231130180758.212172-3-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/qcom/qdsp6/audioreach.c

index 5c7113d46b6f81da3c42c21b455958167544c917..5291deac0a0b39cd511b6af5647a46ed9e9c08a9 100644 (file)
@@ -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;
        }