sound/core/ump.c
Source file repositories/reference/linux-study-clean/sound/core/ump.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/ump.c- Extension
.c- Size
- 40131 bytes
- Lines
- 1394
- Domain
- Driver Families
- Bucket
- sound/core
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/list.hlinux/slab.hlinux/module.hlinux/export.hlinux/mm.hsound/core.hsound/rawmidi.hsound/ump.hsound/ump_convert.h
Detected Declarations
function process_legacy_outputfunction process_legacy_inputfunction safe_append_stringfunction snd_ump_endpoint_freefunction snd_rawmidi_set_opsfunction snd_ump_dev_seq_freefunction snd_ump_dev_registerfunction snd_ump_dev_unregisterfunction snd_ump_get_blockfunction list_for_each_entryfunction snd_ump_rawmidi_openfunction snd_ump_rawmidi_closefunction snd_ump_rawmidi_triggerfunction snd_ump_rawmidi_drainfunction snd_ump_receive_ump_valfunction snd_ump_receivefunction snd_ump_transmitfunction snd_ump_block_newfunction snd_ump_ioctl_blockfunction snd_ump_ioctlfunction snd_ump_proc_readfunction list_for_each_entryfunction snd_ump_update_group_attrsfunction list_for_each_entryfunction ump_request_openfunction ump_request_closefunction ump_req_msgfunction ump_append_stringfunction choose_default_protocolfunction seq_notify_ep_changefunction ump_handle_ep_info_msgfunction ump_handle_device_info_msgfunction ump_set_rawmidi_namefunction ump_handle_ep_name_msgfunction ump_handle_product_id_msgfunction seq_notify_protocolfunction snd_ump_switch_protocolfunction ump_handle_stream_cfg_msgfunction fill_fb_infofunction is_fb_info_updatedfunction seq_notify_fb_changefunction ump_handle_fb_info_msgfunction ump_handle_fb_name_msgfunction create_block_from_fb_infofunction ump_handle_stream_msgfunction snd_ump_parse_endpointfunction snd_ump_legacy_openfunction snd_ump_legacy_close
Annotated Snippet
if (p->info.block_id > blk) {
list_add_tail(&fb->list, &p->list);
goto added;
}
}
list_add_tail(&fb->list, &ump->block_list);
added:
ump_dbg(ump, "Created a UMP Block #%d (%s)\n", blk, fb->info.name);
*blk_ret = fb;
return 0;
}
EXPORT_SYMBOL_GPL(snd_ump_block_new);
static int snd_ump_ioctl_block(struct snd_ump_endpoint *ump,
struct snd_ump_block_info __user *argp)
{
struct snd_ump_block *fb;
unsigned char id;
if (get_user(id, &argp->block_id))
return -EFAULT;
fb = snd_ump_get_block(ump, id);
if (!fb)
return -ENOENT;
if (copy_to_user(argp, &fb->info, sizeof(fb->info)))
return -EFAULT;
return 0;
}
/*
* Handle UMP-specific ioctls; called from snd_rawmidi_ioctl()
*/
static long snd_ump_ioctl(struct snd_rawmidi *rmidi, unsigned int cmd,
void __user *argp)
{
struct snd_ump_endpoint *ump = rawmidi_to_ump(rmidi);
switch (cmd) {
case SNDRV_UMP_IOCTL_ENDPOINT_INFO:
if (copy_to_user(argp, &ump->info, sizeof(ump->info)))
return -EFAULT;
return 0;
case SNDRV_UMP_IOCTL_BLOCK_INFO:
return snd_ump_ioctl_block(ump, argp);
default:
ump_dbg(ump, "rawmidi: unknown command = 0x%x\n", cmd);
return -ENOTTY;
}
}
static const char *ump_direction_string(int dir)
{
switch (dir) {
case SNDRV_UMP_DIR_INPUT:
return "input";
case SNDRV_UMP_DIR_OUTPUT:
return "output";
case SNDRV_UMP_DIR_BIDIRECTION:
return "bidirection";
default:
return "unknown";
}
}
static const char *ump_ui_hint_string(int dir)
{
switch (dir) {
case SNDRV_UMP_BLOCK_UI_HINT_RECEIVER:
return "receiver";
case SNDRV_UMP_BLOCK_UI_HINT_SENDER:
return "sender";
case SNDRV_UMP_BLOCK_UI_HINT_BOTH:
return "both";
default:
return "unknown";
}
}
/* Additional proc file output */
static void snd_ump_proc_read(struct snd_info_entry *entry,
struct snd_info_buffer *buffer)
{
struct snd_rawmidi *rmidi = entry->private_data;
struct snd_ump_endpoint *ump = rawmidi_to_ump(rmidi);
struct snd_ump_block *fb;
snd_iprintf(buffer, "EP Name: %s\n", ump->info.name);
snd_iprintf(buffer, "EP Product ID: %s\n", ump->info.product_id);
snd_iprintf(buffer, "UMP Version: 0x%04x\n", ump->info.version);
Annotation
- Immediate include surface: `linux/list.h`, `linux/slab.h`, `linux/module.h`, `linux/export.h`, `linux/mm.h`, `sound/core.h`, `sound/rawmidi.h`, `sound/ump.h`.
- Detected declarations: `function process_legacy_output`, `function process_legacy_input`, `function safe_append_string`, `function snd_ump_endpoint_free`, `function snd_rawmidi_set_ops`, `function snd_ump_dev_seq_free`, `function snd_ump_dev_register`, `function snd_ump_dev_unregister`, `function snd_ump_get_block`, `function list_for_each_entry`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.