Lines Matching +full:usb +full:- +full:dai +full:- +full:link
2 ASoC USB support
7 In order to leverage the existing USB sound device support in ALSA, the
8 ASoC USB APIs are introduced to allow the subsystems to exchange
11 One potential use case would be to support USB audio offloading, which is
12 an implementation that allows for an alternate power-optimized path in the audio
13 subsystem to handle the transfer of audio data over the USB bus. This would
20 USB | ASoC
27 | |DAI LNK | |DAI LNK |
32 | |SoC-USB | |
34 |USB SND |<--->|USBSND |<------------>|________| |
35 |(card.c)| |offld |<---------- |
40 |USB SND (endpoint.c) | | | | ^
43 | | | |->|audio DSP |
45 |XHCI HCD |<- |
49 SoC USB driver
52 ----------
55 - ``list``: list head for SND SoC struct list
56 - ``component``: reference to ASoC component
57 - ``connection_status_cb``: callback to notify connection events
58 - ``update_offload_route_info``: callback to fetch selected USB sound card/PCM
60 - ``priv_data``: driver data
63 device, or a USB device (udev->dev). This is created by the ASoC BE DAI
64 link, and the USB sound entity will be able to pass information to the
65 ASoC BE DAI link using this structure.
69 - ``card_idx``: sound card index associated with USB sound device
70 - ``chip_idx``: USB sound chip array index
71 - ``cpcm_idx``: capture pcm device indexes associated with the USB sound device
72 - ``ppcm_idx``: playback pcm device indexes associated with the USB sound device
73 - ``num_playback``: number of playback streams
74 - ``num_capture``: number of capture streams
75 - ``list``: list head for the USB sound device list
77 The struct snd_soc_usb_device is created by the USB sound offload driver.
79 determine the possible offloading paths for this USB audio device.
82 ---------
83 .. code-block:: rst
89 - ``card_idx``: the index into the USB sound chip array.
90 - ``params``: Requested PCM parameters from the USB DPCM BE DAI link
91 - ``direction``: capture or playback
94 being requested by the external DSP is supported by the USB device.
96 Returns 0 on success, and -EOPNOTSUPP on failure.
98 .. code-block:: rst
103 - ``usbdev``: the usb device that was discovered
104 - ``sdev``: capabilities of the device
106 **snd_soc_usb_connect()** notifies the ASoC USB DCPM BE DAI link of a USB
107 audio device detection. This can be utilized in the BE DAI
108 driver to keep track of available USB audio devices. This is intended
109 to be called by the USB offload driver residing in USB SND.
113 .. code-block:: rst
118 - ``usbdev``: the usb device that was removed
119 - ``sdev``: capabilities to free
121 **snd_soc_usb_disconnect()** notifies the ASoC USB DCPM BE DAI link of a USB
122 audio device removal. This is intended to be called by the USB offload
123 driver that resides in USB SND.
125 .. code-block:: rst
130 - ``usbdev``: the usb device to reference to find private data
132 **snd_soc_usb_find_priv_data()** fetches the private data saved to the SoC USB
137 .. code-block:: rst
143 - ``component``: ASoC component to add the jack
144 - ``jack``: jack component to populate
148 designs that support USB audio offloading. Additionally, this will enable the
153 .. code-block:: rst
160 - ``dev``: USB device to look up offload path mapping
161 - ``card``: USB sound card index
162 - ``pcm``: USB sound PCM device index
163 - ``direction``: direction to fetch offload routing information
164 - ``path``: kcontrol selector - pcm device or card index
165 - ``route``: mapping of sound card and pcm indexes for the offload path. This is
170 **snd_soc_usb_update_offload_route()** calls a registered callback to the USB BE DAI
171 link to fetch the information about the mapped ASoC devices for executing USB audio
177 .. code-block:: rst
183 - ``component``: DPCM BE DAI link component
184 - ``data``: private data
186 **snd_soc_usb_allocate_port()** allocates a SoC USB device and populates standard
191 .. code-block:: rst
193 void snd_soc_usb_free_port(struct snd_soc_usb *usb);
196 - ``usb``: SoC USB device to free
198 **snd_soc_usb_free_port()** frees a SoC USB device.
200 .. code-block:: rst
202 void snd_soc_usb_add_port(struct snd_soc_usb *usb);
205 - ``usb``: SoC USB device to add
207 **snd_soc_usb_add_port()** add an allocated SoC USB device to the SOC USB framework.
210 .. code-block:: rst
212 void snd_soc_usb_remove_port(struct snd_soc_usb *usb);
215 - ``usb``: SoC USB device to remove
217 **snd_soc_usb_remove_port()** removes a SoC USB device from the SoC USB framework.
218 After removing a device, any SOC USB operations would not be able to reference the
221 How to Register to SoC USB
222 --------------------------
223 The ASoC DPCM USB BE DAI link is the entity responsible for allocating and
224 registering the SoC USB device on the component bind. Likewise, it will
228 .. code-block:: rst
233 data->usb = snd_soc_usb_allocate_port(component, 1, &data->priv);
234 if (!data->usb)
235 return -ENOMEM;
237 usb->connection_status_cb = q6usb_alsa_connection_cb;
239 ret = snd_soc_usb_add_port(usb);
241 dev_err(component->dev, "failed to add usb port\n");
250 snd_soc_usb_remove_port(data->usb);
251 snd_soc_usb_free_port(data->usb);
257 .name = "q6usb-dai-component",
262 BE DAI links can pass along vendor specific information as part of the
263 call to allocate the SoC USB device. This will allow any BE DAI link
264 parameters or settings to be accessed by the USB offload driver that
265 resides in USB SND.
267 USB Audio Device Connection Flow
268 --------------------------------
269 USB devices can be hotplugged into the USB ports at any point in time.
270 The BE DAI link should be aware of the current state of the physical USB
271 port, i.e. if there are any USB devices with audio interface(s) connected.
272 connection_status_cb() can be used to notify the BE DAI link of any change.
274 This is called whenever there is a USB SND interface bind or remove event,
277 .. code-block:: rst
289 snd_soc_usb_disconnect(usb_get_usb_backend(chip->dev), dev->sdev);
295 not guaranteed, USB SND exposes snd_usb_rediscover_devices() to resend the
296 connect events for any identified USB audio interfaces. Consider the
300 | --> USB audio streams allocated and saved to usb_chip[]
301 | --> Propagate connect event to USB offload driver in USB SND
302 | --> **snd_soc_usb_connect()** exits as USB BE DAI link is not ready
304 BE DAI link component probe
305 | --> DAI link is probed and SoC USB port is allocated
306 | --> The USB audio device connect event is missed
309 is executed when the SoC USB device is registered. Now, when the BE DAI
310 link component probe occurs, the following highlights the sequence:
312 BE DAI link component probe
313 | --> DAI link is probed and SoC USB port is allocated
314 | --> SoC USB device added, and **snd_usb_rediscover_devices()** runs
317 | --> Traverses through usb_chip[] and for non-NULL entries issue
320 In the case where the USB offload driver is unbound, while USB SND is ready,
325 | --> USB audio streams allocated and saved to usb_chip[]
326 | --> Propagate connect event to USB offload driver in USB SND
327 | --> USB offload driver **NOT** ready!
329 BE DAI link component probe
330 | --> DAI link is probed and SoC USB port is allocated
331 | --> No USB connect event due to missing USB offload driver
333 USB offload driver probe
334 | --> **qc_usb_audio_offload_init()**
335 | --> Calls **snd_usb_rediscover_devices()** to notify of devices
337 USB Offload Related Kcontrols
340 -------
342 devices to enable USB audio offloading. SoC USB exposes the get_offload_dev()
347 --------------
355 0 [SM8250MTPWCD938]: sm8250 - SM8250-MTP-WCD9380-WSA8810-VA-D
356 SM8250-MTP-WCD9380-WSA8810-VA-DMIC
357 1 [Seri ]: USB-Audio - Plantronics Blackwire 3225 Seri
359 3225 Seri at usb-xhci-hcd.1.auto-1.1,
361 2 [C320M ]: USB-Audio - Plantronics C320-M
362 Plantronics Plantronics C320-M at usb-xhci-hcd.1.auto-1.2, full speed
368 card 0: SM8250MTPWCD938 [SM8250-MTP-WCD9380-WSA8810-VA-D], device 0: MultiMedia1 (*) []
371 card 0: SM8250MTPWCD938 [SM8250-MTP-WCD9380-WSA8810-VA-D], device 1: MultiMedia2 (*) []
374 card 1: Seri [Plantronics Blackwire 3225 Seri], device 0: USB Audio [USB Audio]
377 card 2: C320M [Plantronics C320-M], device 0: USB Audio [USB Audio]
381 **USB Sound Card** - card#1:
385 USB Offload Playback Card Route PCM#0 -1 (range -1->32)
386 USB Offload Playback PCM Route PCM#0 -1 (range -1->255)
388 **USB Sound Card** - card#2:
392 USB Offload Playback Card Route PCM#0 0 (range -1->32)
393 USB Offload Playback PCM Route PCM#0 1 (range -1->255)
396 (card#0) and two USB sound devices connected (card#1 and card#2). When reading
397 the available kcontrols for each USB audio device, the following kcontrols lists
398 the mapped offload card and pcm device indexes for the specific USB device:
400 ``USB Offload Playback Card Route PCM#*``
402 ``USB Offload Playback PCM Route PCM#*``
404 The kcontrol is indexed, because a USB audio device could potentially have
407 - ``USB Offload Playback Card Route PCM#`` **(R)**: Returns the ASoC platform sound
409 that there is an available offload path for the USB SND device through card#0.
410 If **"-1"** is seen, then no offload path is available for the USB SND device.
411 This kcontrol exists for each USB audio device that exists in the system, and
415 - ``USB Offload Playback PCM Route PCM#`` **(R)**: Returns the ASoC platform sound
417 signifies that there is an available offload path for the USB SND device through
418 PCM device#0. If **"-1"** is seen, then no offload path is available for the USB\
419 SND device. This kcontrol exists for each USB audio device that exists in the
423 USB Offload Playback Route Kcontrol
424 -----------------------------------
426 selection, the SoC USB layer exposes the following:
428 .. code-block:: rst
436 These are specific for the **USB Offload Playback Card Route PCM#** and **USB
439 When users issue get calls to the kcontrol, the registered SoC USB callbacks will
440 execute the registered function calls to the DPCM BE DAI link.
444 .. code-block:: rst
449 usb = snd_soc_usb_allocate_port(component, 1, &data->priv);
450 if (IS_ERR(usb))
451 return -ENOMEM;
453 usb->connection_status_cb = q6usb_alsa_connection_cb;
454 usb->update_offload_route_info = q6usb_get_offload_dev;
456 ret = snd_soc_usb_add_port(usb);
459 Existing USB Sound Kcontrol
460 ---------------------------
461 With the introduction of USB offload support, the above USB offload kcontrol
462 will be added to the pre existing list of kcontrols identified by the USB sound
464 modify characteristics pertaining to the USB audio device.
470 0 INT 2 Capture Channel Map 0, 0 (range 0->36)
471 1 INT 2 Playback Channel Map 0, 0 (range 0->36)
473 3 INT 1 Headset Capture Volume 10 (range 0->13)
475 5 INT 1 Sidetone Playback Volume 4096 (range 0->8192)
477 7 INT 2 Headset Playback Volume 20, 20 (range 0->24)
478 8 INT 1 USB Offload Playback Card Route PCM#0 0 (range -1->32)
479 9 INT 1 USB Offload Playback PCM Route PCM#0 1 (range -1->255)
481 Since USB audio device controls are handled over the USB control endpoint, use the
482 existing mechanisms present in the USB mixer to set parameters, such as volume.