sound/usb/caiaq/audio.c
Source file repositories/reference/linux-study-clean/sound/usb/caiaq/audio.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/caiaq/audio.c- Extension
.c- Size
- 21966 bytes
- Lines
- 864
- Domain
- Driver Families
- Bucket
- sound/usb
- 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.
- 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/device.hlinux/spinlock.hlinux/slab.hlinux/init.hlinux/usb.hsound/core.hsound/pcm.hdevice.haudio.h
Detected Declarations
function activate_substreamfunction deactivate_substreamfunction all_substreams_zerofunction stream_startfunction stream_stopfunction snd_usb_caiaq_substream_openfunction snd_usb_caiaq_substream_closefunction all_substreams_zerofunction snd_usb_caiaq_pcm_hw_freefunction snd_usb_caiaq_pcm_preparefunction snd_usb_caiaq_pcm_triggerfunction snd_usb_caiaq_pcm_pointerfunction check_for_elapsed_periodsfunction read_in_urb_mode0function read_in_urb_mode2function read_in_urb_mode3function read_in_urbfunction fill_out_urb_mode_0function fill_out_urb_mode_3function fill_out_urbfunction read_completedfunction write_completedfunction free_urbsfunction snd_usb_caiaq_audio_initfunction snd_usb_caiaq_audio_disconnectfunction snd_usb_caiaq_audio_free
Annotated Snippet
if (ret) {
dev_err(dev, "unable to trigger read #%d! (ret %d)\n",
i, ret);
cdev->streaming = 0;
return -EPIPE;
}
}
return 0;
}
static void stream_stop(struct snd_usb_caiaqdev *cdev)
{
int i;
struct device *dev = caiaqdev_to_dev(cdev);
dev_dbg(dev, "%s(%p)\n", __func__, cdev);
if (!cdev->streaming)
return;
cdev->streaming = 0;
for (i = 0; i < N_URBS; i++) {
usb_kill_urb(cdev->data_urbs_in[i]);
if (test_bit(i, &cdev->outurb_active_mask))
usb_kill_urb(cdev->data_urbs_out[i]);
}
cdev->outurb_active_mask = 0;
}
static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream)
{
struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream);
struct device *dev = caiaqdev_to_dev(cdev);
dev_dbg(dev, "%s(%p)\n", __func__, substream);
substream->runtime->hw = cdev->pcm_info;
snd_pcm_limit_hw_rates(substream->runtime);
return 0;
}
static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)
{
struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream);
struct device *dev = caiaqdev_to_dev(cdev);
dev_dbg(dev, "%s(%p)\n", __func__, substream);
if (all_substreams_zero(cdev->sub_playback) &&
all_substreams_zero(cdev->sub_capture)) {
/* when the last client has stopped streaming,
* all sample rates are allowed again */
stream_stop(cdev);
cdev->pcm_info.rates = cdev->samplerates;
}
return 0;
}
static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub)
{
struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub);
deactivate_substream(cdev, sub);
return 0;
}
static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
{
int bytes_per_sample, bpp, ret;
int index = substream->number;
struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
struct device *dev = caiaqdev_to_dev(cdev);
dev_dbg(dev, "%s(%p)\n", __func__, substream);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
int out_pos;
switch (cdev->spec.data_alignment) {
case 0:
case 2:
out_pos = BYTES_PER_SAMPLE + 1;
break;
case 3:
default:
out_pos = 0;
break;
Annotation
- Immediate include surface: `linux/device.h`, `linux/spinlock.h`, `linux/slab.h`, `linux/init.h`, `linux/usb.h`, `sound/core.h`, `sound/pcm.h`, `device.h`.
- Detected declarations: `function activate_substream`, `function deactivate_substream`, `function all_substreams_zero`, `function stream_start`, `function stream_stop`, `function snd_usb_caiaq_substream_open`, `function snd_usb_caiaq_substream_close`, `function all_substreams_zero`, `function snd_usb_caiaq_pcm_hw_free`, `function snd_usb_caiaq_pcm_prepare`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: source implementation candidate.
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.