diff mbox series

[v9,28/34] ASoC: qcom: qdsp6: Add support to track available USB PCM devices

Message ID 20231017200109.11407-29-quic_wcheng@quicinc.com
State New
Headers show
Series Introduce QC USB SND audio offloading support | expand

Commit Message

Wesley Cheng Oct. 17, 2023, 8:01 p.m. UTC
The USB backend should know about which sound resources are being shared
between the ASoC and USB SND paths.  This can be utilized to properly
select and maintain the offloading devices.

Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
---
 sound/soc/qcom/qdsp6/q6usb.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Pierre-Louis Bossart Oct. 17, 2023, 10:43 p.m. UTC | #1
On 10/17/23 15:01, Wesley Cheng wrote:
> The USB backend should know about which sound resources are being shared
> between the ASoC and USB SND paths.  This can be utilized to properly
> select and maintain the offloading devices.
> 
> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
> ---
>  sound/soc/qcom/qdsp6/q6usb.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/sound/soc/qcom/qdsp6/q6usb.c b/sound/soc/qcom/qdsp6/q6usb.c
> index 329a7d4a3c01..d697cbe7f184 100644
> --- a/sound/soc/qcom/qdsp6/q6usb.c
> +++ b/sound/soc/qcom/qdsp6/q6usb.c
> @@ -25,10 +25,18 @@
>  
>  #define SID_MASK	0xF
>  
> +struct q6usb_status {
> +	unsigned int num_pcm;

how would one know which ones are capture and which ones are playback?

This really looks like a playback-only assumption, despite earlier
mentions of capture supported.

> +	unsigned int chip_index;
> +	unsigned int pcm_index;
> +};
> +
>  struct q6usb_port_data {
>  	struct q6afe_usb_cfg usb_cfg;
>  	struct snd_soc_usb *usb;
>  	struct q6usb_offload priv;
> +	unsigned long available_card_slot;
> +	struct q6usb_status status[SNDRV_CARDS];
>  	int active_idx;
>  };
>  
> @@ -110,6 +118,14 @@ static int q6usb_alsa_connection_cb(struct snd_soc_usb *usb,
>  	if (connected) {
>  		/* We only track the latest USB headset plugged in */
>  		data->active_idx = sdev->card_idx;
> +
> +		set_bit(sdev->card_idx, &data->available_card_slot);
> +		data->status[sdev->card_idx].num_pcm = sdev->num_playback;

there you go...

> +		data->status[sdev->card_idx].chip_index = sdev->chip_idx;
> +	} else {
> +		clear_bit(sdev->card_idx, &data->available_card_slot);
> +		data->status[sdev->card_idx].num_pcm = 0;
> +		data->status[sdev->card_idx].chip_index = 0;
>  	}
>  
>  	return 0;
Wesley Cheng Oct. 19, 2023, 1 a.m. UTC | #2
Hi Pierre,

On 10/17/2023 3:43 PM, Pierre-Louis Bossart wrote:
> 
> 
> On 10/17/23 15:01, Wesley Cheng wrote:
>> The USB backend should know about which sound resources are being shared
>> between the ASoC and USB SND paths.  This can be utilized to properly
>> select and maintain the offloading devices.
>>
>> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
>> ---
>>   sound/soc/qcom/qdsp6/q6usb.c | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/sound/soc/qcom/qdsp6/q6usb.c b/sound/soc/qcom/qdsp6/q6usb.c
>> index 329a7d4a3c01..d697cbe7f184 100644
>> --- a/sound/soc/qcom/qdsp6/q6usb.c
>> +++ b/sound/soc/qcom/qdsp6/q6usb.c
>> @@ -25,10 +25,18 @@
>>   
>>   #define SID_MASK	0xF
>>   
>> +struct q6usb_status {
>> +	unsigned int num_pcm;
> 
> how would one know which ones are capture and which ones are playback?
> 
> This really looks like a playback-only assumption, despite earlier
> mentions of capture supported.
> 

Yes, playback only, which is the reasoning for only having one parameter 
here.  I will rename it though to be clearer.

Thanks
Wesley Cheng

>> +	unsigned int chip_index;
>> +	unsigned int pcm_index;
>> +};
>> +
>>   struct q6usb_port_data {
>>   	struct q6afe_usb_cfg usb_cfg;
>>   	struct snd_soc_usb *usb;
>>   	struct q6usb_offload priv;
>> +	unsigned long available_card_slot;
>> +	struct q6usb_status status[SNDRV_CARDS];
>>   	int active_idx;
>>   };
>>   
>> @@ -110,6 +118,14 @@ static int q6usb_alsa_connection_cb(struct snd_soc_usb *usb,
>>   	if (connected) {
>>   		/* We only track the latest USB headset plugged in */
>>   		data->active_idx = sdev->card_idx;
>> +
>> +		set_bit(sdev->card_idx, &data->available_card_slot);
>> +		data->status[sdev->card_idx].num_pcm = sdev->num_playback;
> 
> there you go...
> 
>> +		data->status[sdev->card_idx].chip_index = sdev->chip_idx;
>> +	} else {
>> +		clear_bit(sdev->card_idx, &data->available_card_slot);
>> +		data->status[sdev->card_idx].num_pcm = 0;
>> +		data->status[sdev->card_idx].chip_index = 0;
>>   	}
>>   
>>   	return 0;
diff mbox series

Patch

diff --git a/sound/soc/qcom/qdsp6/q6usb.c b/sound/soc/qcom/qdsp6/q6usb.c
index 329a7d4a3c01..d697cbe7f184 100644
--- a/sound/soc/qcom/qdsp6/q6usb.c
+++ b/sound/soc/qcom/qdsp6/q6usb.c
@@ -25,10 +25,18 @@ 
 
 #define SID_MASK	0xF
 
+struct q6usb_status {
+	unsigned int num_pcm;
+	unsigned int chip_index;
+	unsigned int pcm_index;
+};
+
 struct q6usb_port_data {
 	struct q6afe_usb_cfg usb_cfg;
 	struct snd_soc_usb *usb;
 	struct q6usb_offload priv;
+	unsigned long available_card_slot;
+	struct q6usb_status status[SNDRV_CARDS];
 	int active_idx;
 };
 
@@ -110,6 +118,14 @@  static int q6usb_alsa_connection_cb(struct snd_soc_usb *usb,
 	if (connected) {
 		/* We only track the latest USB headset plugged in */
 		data->active_idx = sdev->card_idx;
+
+		set_bit(sdev->card_idx, &data->available_card_slot);
+		data->status[sdev->card_idx].num_pcm = sdev->num_playback;
+		data->status[sdev->card_idx].chip_index = sdev->chip_idx;
+	} else {
+		clear_bit(sdev->card_idx, &data->available_card_slot);
+		data->status[sdev->card_idx].num_pcm = 0;
+		data->status[sdev->card_idx].chip_index = 0;
 	}
 
 	return 0;