sound/usb/caiaq/device.c
Source file repositories/reference/linux-study-clean/sound/usb/caiaq/device.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/caiaq/device.c- Extension
.c- Size
- 15109 bytes
- Lines
- 584
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/moduleparam.hlinux/device.hlinux/interrupt.hlinux/module.hlinux/init.hlinux/gfp.hlinux/usb.hsound/initval.hsound/core.hsound/pcm.hdevice.haudio.hmidi.hcontrol.hinput.h
Detected Declarations
function usb_ep1_command_reply_dispatchfunction snd_usb_caiaq_send_commandfunction snd_usb_caiaq_send_command_bankfunction snd_usb_caiaq_set_audio_paramsfunction snd_usb_caiaq_set_auto_msgfunction setup_cardfunction card_freefunction create_cardfunction init_cardfunction usb_urb_ep_type_checkfunction snd_probefunction snd_disconnect
Annotated Snippet
USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) {
if (urb->actual_length > sizeof(cdev->control_state))
urb->actual_length = sizeof(cdev->control_state);
memcpy(cdev->control_state, buf + 1, urb->actual_length);
wake_up(&cdev->ep1_wait_queue);
break;
}
#ifdef CONFIG_SND_USB_CAIAQ_INPUT
fallthrough;
case EP1_CMD_READ_ERP:
case EP1_CMD_READ_ANALOG:
snd_usb_caiaq_input_dispatch(cdev, buf, urb->actual_length);
#endif
break;
}
cdev->ep1_in_urb.actual_length = 0;
ret = usb_submit_urb(&cdev->ep1_in_urb, GFP_ATOMIC);
if (ret < 0)
dev_err(dev, "unable to submit urb. OOM!?\n");
}
int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev,
unsigned char command,
const unsigned char *buffer,
int len)
{
int actual_len;
struct usb_device *usb_dev = cdev->chip.dev;
if (!usb_dev)
return -EIO;
if (len > EP1_BUFSIZE - 1)
len = EP1_BUFSIZE - 1;
if (buffer && len > 0)
memcpy(cdev->ep1_out_buf+1, buffer, len);
cdev->ep1_out_buf[0] = command;
return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1),
cdev->ep1_out_buf, len+1, &actual_len, 200);
}
int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev,
unsigned char command,
unsigned char bank,
const unsigned char *buffer,
int len)
{
int actual_len;
struct usb_device *usb_dev = cdev->chip.dev;
if (!usb_dev)
return -EIO;
if (len > EP1_BUFSIZE - 2)
len = EP1_BUFSIZE - 2;
if (buffer && len > 0)
memcpy(cdev->ep1_out_buf+2, buffer, len);
cdev->ep1_out_buf[0] = command;
cdev->ep1_out_buf[1] = bank;
return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1),
cdev->ep1_out_buf, len+2, &actual_len, 200);
}
int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev,
int rate, int depth, int bpp)
{
int ret;
char tmp[5];
struct device *dev = caiaqdev_to_dev(cdev);
switch (rate) {
case 44100: tmp[0] = SAMPLERATE_44100; break;
case 48000: tmp[0] = SAMPLERATE_48000; break;
case 88200: tmp[0] = SAMPLERATE_88200; break;
case 96000: tmp[0] = SAMPLERATE_96000; break;
case 192000: tmp[0] = SAMPLERATE_192000; break;
default: return -EINVAL;
}
switch (depth) {
case 16: tmp[1] = DEPTH_16; break;
case 24: tmp[1] = DEPTH_24; break;
default: return -EINVAL;
}
Annotation
- Immediate include surface: `linux/moduleparam.h`, `linux/device.h`, `linux/interrupt.h`, `linux/module.h`, `linux/init.h`, `linux/gfp.h`, `linux/usb.h`, `sound/initval.h`.
- Detected declarations: `function usb_ep1_command_reply_dispatch`, `function snd_usb_caiaq_send_command`, `function snd_usb_caiaq_send_command_bank`, `function snd_usb_caiaq_set_audio_params`, `function snd_usb_caiaq_set_auto_msg`, `function setup_card`, `function card_free`, `function create_card`, `function init_card`, `function usb_urb_ep_type_check`.
- Atlas domain: Driver Families / sound/usb.
- 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.