Re: [PATCH v24 11/34] ASoC: usb: Fetch ASoC card and pcm device information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 8/1/24 03:17, Wesley Cheng wrote:
> USB SND needs to know how the USB offload path is being routed.  This would
> allow for applications to open the corresponding sound card and pcm device
> when it wants to take the audio offload path.  This callback should return
> the mapped indexes based on the USB SND device information.
> 
> Signed-off-by: Wesley Cheng <quic_wcheng@xxxxxxxxxxx>
> ---
>  include/sound/soc-usb.h | 16 ++++++++++++++++
>  sound/soc/soc-usb.c     | 28 ++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h
> index d6b576f971ae..a167e3de0a78 100644
> --- a/include/sound/soc-usb.h
> +++ b/include/sound/soc-usb.h
> @@ -8,6 +8,11 @@
>  
>  #include <sound/soc.h>
>  
> +enum snd_soc_usb_kctl {
> +	SND_SOC_USB_KCTL_CARD_ROUTE,
> +	SND_SOC_USB_KCTL_PCM_ROUTE,
> +};
> +
>  /**
>   * struct snd_soc_usb_device
>   * @card_idx - sound card index associated with USB device
> @@ -32,6 +37,7 @@ struct snd_soc_usb_device {
>   * @component - reference to ASoC component
>   * @num_supported_streams - number of supported concurrent sessions
>   * @connection_status_cb - callback to notify connection events
> + * @get_offload_dev - callback to fetch mapped ASoC device
>   * @priv_data - driver data
>   **/
>  struct snd_soc_usb {
> @@ -40,6 +46,8 @@ struct snd_soc_usb {
>  	unsigned int num_supported_streams;
>  	int (*connection_status_cb)(struct snd_soc_usb *usb,
>  			struct snd_soc_usb_device *sdev, bool connected);
> +	int (*get_offload_dev)(struct snd_soc_component *component,
> +				int card, int pcm, enum snd_soc_usb_kctl route);
>  	void *priv_data;
>  };
>  
> @@ -51,6 +59,8 @@ void *snd_soc_usb_find_priv_data(struct device *dev);
>  int snd_soc_usb_setup_offload_jack(struct snd_soc_component *component,
>  					struct snd_soc_jack *jack);
>  int snd_soc_usb_disable_offload_jack(struct snd_soc_component *component);
> +int soc_usb_get_offload_device(struct device *dev, int card, int pcm,
> +				enum snd_soc_usb_kctl route);
>  
>  struct snd_soc_usb *snd_soc_usb_allocate_port(struct snd_soc_component *component,
>  					      int num_streams, void *data);
> @@ -86,6 +96,12 @@ static inline int snd_soc_usb_disable_offload_jack(struct snd_soc_component *com
>  	return -ENODEV;
>  }
>  
> +static int soc_usb_get_offload_device(struct device *dev, int card, int pcm,
> +					enum snd_soc_usb_kctl route)
> +{
> +	return -ENODEV;
> +}
> +
>  static inline struct snd_soc_usb *snd_soc_usb_allocate_port(
>  					      struct snd_soc_component *component,
>  					      int num_streams, void *data)
> diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c
> index fe2a75a28af4..3c217ac67c57 100644
> --- a/sound/soc/soc-usb.c
> +++ b/sound/soc/soc-usb.c
> @@ -117,6 +117,34 @@ int snd_soc_usb_disable_offload_jack(struct snd_soc_component *component)
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_usb_disable_offload_jack);
>  
> +/**
> + * soc_usb_get_offload_device - Set active USB offload path

get or set?

> + * @dev - USB device to get offload status
> + * @card - USB card index
> + * @pcm - USB PCM device index
> + *> + * Fetch the current status for the USB SND card and PCM device
indexes
> + * specified.

the function returns an integer, how does this return the 'mapped indices"?

> + */
> +int soc_usb_get_offload_device(struct device *dev, int card, int pcm,
> +				enum snd_soc_usb_kctl route)

missing route in kernel doc.

> +{
> +	struct snd_soc_usb *ctx;
> +	int ret;
> +
> +	ctx = snd_soc_find_usb_ctx(dev);
> +	if (!ctx)
> +		return -ENODEV;
> +
> +	mutex_lock(&ctx_mutex);
> +	if (ctx && ctx->get_offload_dev)
> +		ret = ctx->get_offload_dev(ctx->component, card, pcm, route);
> +	mutex_unlock(&ctx_mutex);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(soc_usb_get_offload_device);
> +
>  /**
>   * snd_soc_usb_find_priv_data() - Retrieve private data stored
>   * @dev: device reference





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux