File Index
Files and directories
Sign in
FILE

soc-usb.h

File preview with syntax highlighting.

linux-6.19.14/include/sound/soc-usb.h C
  1/* SPDX-License-Identifier: GPL-2.0
  2 *
  3 * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.
  4 */
  5
  6#ifndef __LINUX_SND_SOC_USB_H
  7#define __LINUX_SND_SOC_USB_H
  8
  9#include <sound/soc.h>
 10
 11enum snd_soc_usb_kctl {
 12	SND_SOC_USB_KCTL_CARD_ROUTE,
 13	SND_SOC_USB_KCTL_PCM_ROUTE,
 14};
 15
 16/**
 17 * struct snd_soc_usb_device - SoC USB representation of a USB sound device
 18 * @card_idx: sound card index associated with USB device
 19 * @chip_idx: USB sound chip array index
 20 * @cpcm_idx: capture PCM index array associated with USB device
 21 * @ppcm_idx: playback PCM index array associated with USB device
 22 * @num_capture: number of capture streams
 23 * @num_playback: number of playback streams
 24 * @list: list head for SoC USB devices
 25 **/
 26struct snd_soc_usb_device {
 27	int card_idx;
 28	int chip_idx;
 29
 30	/* PCM index arrays */
 31	unsigned int *cpcm_idx; /* TODO: capture path is not tested yet */
 32	unsigned int *ppcm_idx;
 33	int num_capture; /* TODO: capture path is not tested yet */
 34	int num_playback;
 35
 36	struct list_head list;
 37};
 38
 39/**
 40 * struct snd_soc_usb - representation of a SoC USB backend entity
 41 * @list: list head for SND SOC struct list
 42 * @component: reference to ASoC component
 43 * @connection_status_cb: callback to notify connection events
 44 * @update_offload_route_info: callback to fetch mapped ASoC card and pcm
 45 *			       device pair.  This is unrelated to the concept
 46 *			       of DAPM route.  The "route" argument carries
 47 *			       an array used for a kcontrol output for either
 48 *			       the card or pcm index.  "path" determines the
 49 *			       which entry to look for. (ie mapped card or pcm)
 50 * @priv_data: driver data
 51 **/
 52struct snd_soc_usb {
 53	struct list_head list;
 54	struct snd_soc_component *component;
 55	int (*connection_status_cb)(struct snd_soc_usb *usb,
 56				    struct snd_soc_usb_device *sdev,
 57				    bool connected);
 58	int (*update_offload_route_info)(struct snd_soc_component *component,
 59					 int card, int pcm, int direction,
 60					 enum snd_soc_usb_kctl path,
 61					 long *route);
 62	void *priv_data;
 63};
 64
 65#if IS_ENABLED(CONFIG_SND_SOC_USB)
 66int snd_soc_usb_find_supported_format(int card_idx,
 67				      struct snd_pcm_hw_params *params,
 68				      int direction);
 69
 70int snd_soc_usb_connect(struct device *usbdev, struct snd_soc_usb_device *sdev);
 71int snd_soc_usb_disconnect(struct device *usbdev, struct snd_soc_usb_device *sdev);
 72void *snd_soc_usb_find_priv_data(struct device *usbdev);
 73
 74int snd_soc_usb_setup_offload_jack(struct snd_soc_component *component,
 75				   struct snd_soc_jack *jack);
 76int snd_soc_usb_update_offload_route(struct device *dev, int card, int pcm,
 77				     int direction, enum snd_soc_usb_kctl path,
 78				     long *route);
 79
 80struct snd_soc_usb *snd_soc_usb_allocate_port(struct snd_soc_component *component,
 81					      void *data);
 82void snd_soc_usb_free_port(struct snd_soc_usb *usb);
 83void snd_soc_usb_add_port(struct snd_soc_usb *usb);
 84void snd_soc_usb_remove_port(struct snd_soc_usb *usb);
 85#else
 86static inline int
 87snd_soc_usb_find_supported_format(int card_idx, struct snd_pcm_hw_params *params,
 88				  int direction)
 89{
 90	return -EINVAL;
 91}
 92
 93static inline int snd_soc_usb_connect(struct device *usbdev,
 94				      struct snd_soc_usb_device *sdev)
 95{
 96	return -ENODEV;
 97}
 98
 99static inline int snd_soc_usb_disconnect(struct device *usbdev,
100					 struct snd_soc_usb_device *sdev)
101{
102	return -EINVAL;
103}
104
105static inline void *snd_soc_usb_find_priv_data(struct device *usbdev)
106{
107	return NULL;
108}
109
110static inline int snd_soc_usb_setup_offload_jack(struct snd_soc_component *component,
111						 struct snd_soc_jack *jack)
112{
113	return 0;
114}
115
116static int snd_soc_usb_update_offload_route(struct device *dev, int card, int pcm,
117					    int direction, enum snd_soc_usb_kctl path,
118					    long *route)
119{
120	return -ENODEV;
121}
122
123static inline struct snd_soc_usb *
124snd_soc_usb_allocate_port(struct snd_soc_component *component, void *data)
125{
126	return ERR_PTR(-ENOMEM);
127}
128
129static inline void snd_soc_usb_free_port(struct snd_soc_usb *usb)
130{ }
131
132static inline void snd_soc_usb_add_port(struct snd_soc_usb *usb)
133{ }
134
135static inline void snd_soc_usb_remove_port(struct snd_soc_usb *usb)
136{ }
137#endif /* IS_ENABLED(CONFIG_SND_SOC_USB) */
138#endif /*__LINUX_SND_SOC_USB_H */
~/ Read-only file preview.