mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ASoC: qcom: audioreach: Add 4 channel support
@ 2023-10-20  8:49 Krzysztof Kozlowski
  2023-10-23  8:42 ` Srinivas Kandagatla
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-10-20  8:49 UTC (permalink / raw)
  To: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, 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>

---

quad(side):
https://trac.ffmpeg.org/wiki/AudioChannelManipulation#Listchannelnamesandstandardchannellayouts
---
 sound/soc/qcom/qdsp6/audioreach.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
index 5974c7929dd3..4dd2a2e261c9 100644
--- a/sound/soc/qcom/qdsp6/audioreach.c
+++ b/sound/soc/qcom/qdsp6/audioreach.c
@@ -833,6 +833,11 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
 	} else if (num_channels == 2) {
 		media_format->channel_mapping[0] = PCM_CHANNEL_L;
 		media_format->channel_mapping[1] = PCM_CHANNEL_R;
+	} 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);
@@ -869,6 +874,11 @@ static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr,
 		} else if (mcfg->num_channels == 2) {
 			mp3_cfg->channel_mapping[0] =  PCM_CHANNEL_L;
 			mp3_cfg->channel_mapping[1] =  PCM_CHANNEL_R;
+		} else if (mcfg->num_channels == 4) {
+			mp3_cfg->channel_mapping[0] =  PCM_CHANNEL_FL;
+			mp3_cfg->channel_mapping[1] =  PCM_CHANNEL_FR;
+			mp3_cfg->channel_mapping[2] =  PCM_CHANNEL_LS;
+			mp3_cfg->channel_mapping[3] =  PCM_CHANNEL_RS;
 		}
 		break;
 	case SND_AUDIOCODEC_AAC:
@@ -1057,7 +1067,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;
 	}
@@ -1094,7 +1104,11 @@ static int audioreach_pcm_set_media_format(struct q6apm_graph *graph,
 	} else if (num_channels == 2) {
 		media_cfg->channel_mapping[0] = PCM_CHANNEL_L;
 		media_cfg->channel_mapping[1] = PCM_CHANNEL_R;
-
+	} else if (num_channels == 4) {
+		media_cfg->channel_mapping[0] = PCM_CHANNEL_FL;
+		media_cfg->channel_mapping[1] = PCM_CHANNEL_FR;
+		media_cfg->channel_mapping[2] = PCM_CHANNEL_LS;
+		media_cfg->channel_mapping[3] = PCM_CHANNEL_RS;
 	}
 
 	rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
@@ -1116,7 +1130,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;
 	}
@@ -1158,6 +1172,11 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph,
 		else if (num_channels == 2) {
 			cfg->channel_mapping[0] =  PCM_CHANNEL_L;
 			cfg->channel_mapping[1] =  PCM_CHANNEL_R;
+		} else if (num_channels == 4) {
+			cfg->channel_mapping[0] =  PCM_CHANNEL_FL;
+			cfg->channel_mapping[1] =  PCM_CHANNEL_FR;
+			cfg->channel_mapping[2] =  PCM_CHANNEL_LS;
+			cfg->channel_mapping[3] =  PCM_CHANNEL_RS;
 		}
 	} else {
 		rc = audioreach_set_compr_media_format(header, p, mcfg);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: qcom: audioreach: Add 4 channel support
  2023-10-20  8:49 [PATCH] ASoC: qcom: audioreach: Add 4 channel support Krzysztof Kozlowski
@ 2023-10-23  8:42 ` Srinivas Kandagatla
  2023-11-30 12:17   ` Krzysztof Kozlowski
  0 siblings, 1 reply; 4+ messages in thread
From: Srinivas Kandagatla @ 2023-10-23  8:42 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Banajit Goswami, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel

Thanks for the patch,

On 20/10/2023 09:49, Krzysztof Kozlowski wrote:
> 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>
> 

> ---
> 
> quad(side):
> https://trac.ffmpeg.org/wiki/AudioChannelManipulation#Listchannelnamesandstandardchannellayouts
> ---
>   sound/soc/qcom/qdsp6/audioreach.c | 25 ++++++++++++++++++++++---
>   1 file changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
> index 5974c7929dd3..4dd2a2e261c9 100644
> --- a/sound/soc/qcom/qdsp6/audioreach.c
> +++ b/sound/soc/qcom/qdsp6/audioreach.c
> @@ -833,6 +833,11 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
>   	} else if (num_channels == 2) {
>   		media_format->channel_mapping[0] = PCM_CHANNEL_L;
>   		media_format->channel_mapping[1] = PCM_CHANNEL_R;
> +	} 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;


These are fine, but duplicated from q6dsp_map_channels(), Please 
consider using q6dsp_map_channels().

Also when you do that pl get rid of PCM_CHANNEL_L and PCM_CHANNEL_R 
defines in audioreach.h


thanks,
--srini

>   	}
>   
>   	rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
> @@ -869,6 +874,11 @@ static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr,
>   		} else if (mcfg->num_channels == 2) {
>   			mp3_cfg->channel_mapping[0] =  PCM_CHANNEL_L;
>   			mp3_cfg->channel_mapping[1] =  PCM_CHANNEL_R;
> +		} else if (mcfg->num_channels == 4) {
> +			mp3_cfg->channel_mapping[0] =  PCM_CHANNEL_FL;
> +			mp3_cfg->channel_mapping[1] =  PCM_CHANNEL_FR;
> +			mp3_cfg->channel_mapping[2] =  PCM_CHANNEL_LS;
> +			mp3_cfg->channel_mapping[3] =  PCM_CHANNEL_RS;
>   		}
>   		break;
>   	case SND_AUDIOCODEC_AAC:
> @@ -1057,7 +1067,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;
>   	}
> @@ -1094,7 +1104,11 @@ static int audioreach_pcm_set_media_format(struct q6apm_graph *graph,
>   	} else if (num_channels == 2) {
>   		media_cfg->channel_mapping[0] = PCM_CHANNEL_L;
>   		media_cfg->channel_mapping[1] = PCM_CHANNEL_R;
> -
> +	} else if (num_channels == 4) {
> +		media_cfg->channel_mapping[0] = PCM_CHANNEL_FL;
> +		media_cfg->channel_mapping[1] = PCM_CHANNEL_FR;
> +		media_cfg->channel_mapping[2] = PCM_CHANNEL_LS;
> +		media_cfg->channel_mapping[3] = PCM_CHANNEL_RS;
>   	}
>   
>   	rc = q6apm_send_cmd_sync(graph->apm, pkt, 0);
> @@ -1116,7 +1130,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;
>   	}
> @@ -1158,6 +1172,11 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph,
>   		else if (num_channels == 2) {
>   			cfg->channel_mapping[0] =  PCM_CHANNEL_L;
>   			cfg->channel_mapping[1] =  PCM_CHANNEL_R;
> +		} else if (num_channels == 4) {
> +			cfg->channel_mapping[0] =  PCM_CHANNEL_FL;
> +			cfg->channel_mapping[1] =  PCM_CHANNEL_FR;
> +			cfg->channel_mapping[2] =  PCM_CHANNEL_LS;
> +			cfg->channel_mapping[3] =  PCM_CHANNEL_RS;
>   		}
>   	} else {
>   		rc = audioreach_set_compr_media_format(header, p, mcfg);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: qcom: audioreach: Add 4 channel support
  2023-10-23  8:42 ` Srinivas Kandagatla
@ 2023-11-30 12:17   ` Krzysztof Kozlowski
  2023-11-30 12:24     ` Srinivas Kandagatla
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-11-30 12:17 UTC (permalink / raw)
  To: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel

On 23/10/2023 10:42, Srinivas Kandagatla wrote:
> Thanks for the patch,
> 
> On 20/10/2023 09:49, Krzysztof Kozlowski wrote:
>> 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>
>>
> 
>> ---
>>
>> quad(side):
>> https://trac.ffmpeg.org/wiki/AudioChannelManipulation#Listchannelnamesandstandardchannellayouts
>> ---
>>   sound/soc/qcom/qdsp6/audioreach.c | 25 ++++++++++++++++++++++---
>>   1 file changed, 22 insertions(+), 3 deletions(-)
>>
>> diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
>> index 5974c7929dd3..4dd2a2e261c9 100644
>> --- a/sound/soc/qcom/qdsp6/audioreach.c
>> +++ b/sound/soc/qcom/qdsp6/audioreach.c
>> @@ -833,6 +833,11 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
>>   	} else if (num_channels == 2) {
>>   		media_format->channel_mapping[0] = PCM_CHANNEL_L;
>>   		media_format->channel_mapping[1] = PCM_CHANNEL_R;
>> +	} 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;
> 
> 
> These are fine, but duplicated from q6dsp_map_channels(), Please 
> consider using q6dsp_map_channels().
> 
> Also when you do that pl get rid of PCM_CHANNEL_L and PCM_CHANNEL_R 
> defines in audioreach.h

The code is not exactly equivalent, e.g. for one channel L (=1) -> FC
(=3). I assume that's okay for you.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: qcom: audioreach: Add 4 channel support
  2023-11-30 12:17   ` Krzysztof Kozlowski
@ 2023-11-30 12:24     ` Srinivas Kandagatla
  0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2023-11-30 12:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Banajit Goswami, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel



On 30/11/2023 12:17, Krzysztof Kozlowski wrote:
> On 23/10/2023 10:42, Srinivas Kandagatla wrote:
>> Thanks for the patch,
>>
>> On 20/10/2023 09:49, Krzysztof Kozlowski wrote:
>>> 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>
>>>
>>
>>> ---
>>>
>>> quad(side):
>>> https://trac.ffmpeg.org/wiki/AudioChannelManipulation#Listchannelnamesandstandardchannellayouts
>>> ---
>>>    sound/soc/qcom/qdsp6/audioreach.c | 25 ++++++++++++++++++++++---
>>>    1 file changed, 22 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
>>> index 5974c7929dd3..4dd2a2e261c9 100644
>>> --- a/sound/soc/qcom/qdsp6/audioreach.c
>>> +++ b/sound/soc/qcom/qdsp6/audioreach.c
>>> @@ -833,6 +833,11 @@ static int audioreach_mfc_set_media_format(struct q6apm_graph *graph,
>>>    	} else if (num_channels == 2) {
>>>    		media_format->channel_mapping[0] = PCM_CHANNEL_L;
>>>    		media_format->channel_mapping[1] = PCM_CHANNEL_R;
>>> +	} 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;
>>
>>
>> These are fine, but duplicated from q6dsp_map_channels(), Please
>> consider using q6dsp_map_channels().
>>
>> Also when you do that pl get rid of PCM_CHANNEL_L and PCM_CHANNEL_R
>> defines in audioreach.h
> 
> The code is not exactly equivalent, e.g. for one channel L (=1) -> FC
> (=3). I assume that's okay for you.
> 
Yep, that is okay for me.

--srini
> Best regards,
> Krzysztof
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-30 12:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-20  8:49 [PATCH] ASoC: qcom: audioreach: Add 4 channel support Krzysztof Kozlowski
2023-10-23  8:42 ` Srinivas Kandagatla
2023-11-30 12:17   ` Krzysztof Kozlowski
2023-11-30 12:24     ` Srinivas Kandagatla

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®