sound/soc/qcom/qdsp6/q6usb.c
Source file repositories/reference/linux-study-clean/sound/soc/qcom/qdsp6/q6usb.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/qcom/qdsp6/q6usb.c- Extension
.c- Size
- 10558 bytes
- Lines
- 423
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/auxiliary_bus.hlinux/device.hlinux/dma-mapping.hlinux/dma-map-ops.hlinux/err.hlinux/init.hlinux/iommu.hlinux/module.hlinux/platform_device.hlinux/slab.hsound/asound.hsound/jack.hsound/pcm.hsound/pcm_params.hsound/q6usboffload.hsound/soc.hsound/soc-usb.hdt-bindings/sound/qcom,q6afe.hq6afe.hq6dsp-lpass-ports.h
Detected Declarations
struct q6usb_port_datafunction q6usb_hw_paramsfunction q6usb_audio_ports_of_xlate_dai_namefunction q6usb_get_pcm_id_from_widgetfunction for_each_card_rtdsfunction q6usb_usb_mixer_enabledfunction q6usb_get_pcm_idfunction q6usb_update_offload_routefunction q6usb_alsa_connection_cbfunction q6usb_component_disable_jackfunction q6usb_component_enable_jackfunction q6usb_component_set_jackfunction q6usb_dai_aux_releasefunction q6usb_component_probefunction q6usb_component_removefunction q6usb_dai_dev_probe
Annotated Snippet
struct q6usb_port_data {
struct auxiliary_device uauxdev;
struct q6afe_usb_cfg usb_cfg;
struct snd_soc_usb *usb;
struct snd_soc_jack *hs_jack;
struct q6usb_offload priv;
/* Protects against operations between SOC USB and ASoC */
struct mutex mutex;
struct list_head devices;
};
static const struct snd_soc_dapm_widget q6usb_dai_widgets[] = {
SND_SOC_DAPM_HP("USB_RX_BE", NULL),
};
static const struct snd_soc_dapm_route q6usb_dapm_routes[] = {
{"USB Playback", NULL, "USB_RX_BE"},
};
static int q6usb_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct q6usb_port_data *data = dev_get_drvdata(dai->dev);
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
int direction = substream->stream;
struct q6afe_port *q6usb_afe;
struct snd_soc_usb_device *sdev;
int ret = -EINVAL;
mutex_lock(&data->mutex);
/* No active chip index */
if (list_empty(&data->devices))
goto out;
sdev = list_last_entry(&data->devices, struct snd_soc_usb_device, list);
ret = snd_soc_usb_find_supported_format(sdev->chip_idx, params, direction);
if (ret < 0)
goto out;
q6usb_afe = q6afe_port_get_from_id(cpu_dai->dev, USB_RX);
if (IS_ERR(q6usb_afe)) {
ret = PTR_ERR(q6usb_afe);
goto out;
}
/* Notify audio DSP about the devices being offloaded */
ret = afe_port_send_usb_dev_param(q6usb_afe, sdev->card_idx,
sdev->ppcm_idx[sdev->num_playback - 1]);
out:
mutex_unlock(&data->mutex);
return ret;
}
static const struct snd_soc_dai_ops q6usb_ops = {
.hw_params = q6usb_hw_params,
};
static struct snd_soc_dai_driver q6usb_be_dais[] = {
{
.playback = {
.stream_name = "USB BE RX",
.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
SNDRV_PCM_RATE_192000,
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE |
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE |
SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_U24_BE,
.channels_min = 1,
.channels_max = 2,
.rate_max = 192000,
.rate_min = 8000,
},
.id = USB_RX,
.name = "USB_RX_BE",
.ops = &q6usb_ops,
},
};
static int q6usb_audio_ports_of_xlate_dai_name(struct snd_soc_component *component,
const struct of_phandle_args *args,
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/dma-map-ops.h`, `linux/err.h`, `linux/init.h`, `linux/iommu.h`, `linux/module.h`.
- Detected declarations: `struct q6usb_port_data`, `function q6usb_hw_params`, `function q6usb_audio_ports_of_xlate_dai_name`, `function q6usb_get_pcm_id_from_widget`, `function for_each_card_rtds`, `function q6usb_usb_mixer_enabled`, `function q6usb_get_pcm_id`, `function q6usb_update_offload_route`, `function q6usb_alsa_connection_cb`, `function q6usb_component_disable_jack`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.