sound/core/compress_offload.c
Source file repositories/reference/linux-study-clean/sound/core/compress_offload.c
File Facts
- System
- Linux kernel
- Corpus path
sound/core/compress_offload.c- Extension
.c- Size
- 41094 bytes
- Lines
- 1560
- Domain
- Driver Families
- Bucket
- sound/core
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/file.hlinux/fs.hlinux/list.hlinux/math64.hlinux/mm.hlinux/mutex.hlinux/poll.hlinux/slab.hlinux/sched.hlinux/types.hlinux/uio.hlinux/uaccess.hlinux/dma-buf.hlinux/module.hlinux/compat.hsound/core.hsound/initval.hsound/info.hsound/compress_params.hsound/compress_offload.hsound/compress_driver.h
Detected Declarations
struct snd_compr_filefunction snd_compr_task_free_allfunction snd_compr_freefunction snd_compr_tstamp32_from_64function snd_compr_update_tstampfunction snd_compr_calc_availfunction snd_compr_get_availfunction snd_compr_avail32_from_64function snd_compr_ioctl_availfunction snd_compr_write_datafunction snd_compr_writefunction snd_compr_readfunction snd_compr_mmapfunction snd_compr_get_pollfunction snd_compr_pollfunction snd_compr_get_capsfunction snd_compr_get_codec_capsfunction snd_compr_malloc_pagesfunction snd_compr_free_pagesfunction snd_compr_allocate_bufferfunction snd_compress_check_inputfunction snd_compr_set_paramsfunction snd_compr_get_paramsfunction snd_compr_get_metadatafunction snd_compr_set_metadatafunction snd_compr_tstampfunction snd_compr_pausefunction snd_compr_resumefunction snd_compr_startfunction snd_compr_stopfunction error_delayed_workfunction snd_compr_stop_errorfunction snd_compress_wait_for_drainfunction snd_compr_drainfunction snd_compr_next_trackfunction snd_compr_partial_drainfunction snd_compr_find_taskfunction list_for_each_entryfunction snd_compr_task_freefunction snd_compr_seqno_nextfunction snd_compr_task_newfunction fd_installfunction snd_compr_task_createfunction snd_compr_task_start_preparefunction snd_compr_task_startfunction snd_compr_task_start_ioctlfunction snd_compr_task_stop_onefunction snd_compr_task_free_one
Annotated Snippet
static const struct file_operations snd_compr_file_ops = {
.owner = THIS_MODULE,
.open = snd_compr_open,
.release = snd_compr_free,
.write = snd_compr_write,
.read = snd_compr_read,
.unlocked_ioctl = snd_compr_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = snd_compr_ioctl_compat,
#endif
.mmap = snd_compr_mmap,
.poll = snd_compr_poll,
};
static int snd_compress_dev_register(struct snd_device *device)
{
int ret;
struct snd_compr *compr;
if (snd_BUG_ON(!device || !device->device_data))
return -EBADFD;
compr = device->device_data;
pr_debug("reg device %s, direction %d\n", compr->name,
compr->direction);
/* register compressed device */
ret = snd_register_device(SNDRV_DEVICE_TYPE_COMPRESS,
compr->card, compr->device,
&snd_compr_file_ops, compr, compr->dev);
if (ret < 0) {
pr_err("snd_register_device failed %d\n", ret);
return ret;
}
return ret;
}
static int snd_compress_dev_disconnect(struct snd_device *device)
{
struct snd_compr *compr;
compr = device->device_data;
snd_unregister_device(compr->dev);
return 0;
}
#ifdef CONFIG_SND_VERBOSE_PROCFS
static void snd_compress_proc_info_read(struct snd_info_entry *entry,
struct snd_info_buffer *buffer)
{
struct snd_compr *compr = (struct snd_compr *)entry->private_data;
snd_iprintf(buffer, "card: %d\n", compr->card->number);
snd_iprintf(buffer, "device: %d\n", compr->device);
snd_iprintf(buffer, "stream: %s\n",
compr->direction == SND_COMPRESS_PLAYBACK
? "PLAYBACK" : "CAPTURE");
snd_iprintf(buffer, "id: %s\n", compr->id);
}
static int snd_compress_proc_init(struct snd_compr *compr)
{
struct snd_info_entry *entry;
char name[16];
sprintf(name, "compr%i", compr->device);
entry = snd_info_create_card_entry(compr->card, name,
compr->card->proc_root);
if (!entry)
return -ENOMEM;
entry->mode = S_IFDIR | 0555;
compr->proc_root = entry;
entry = snd_info_create_card_entry(compr->card, "info",
compr->proc_root);
if (entry)
snd_info_set_text_ops(entry, compr,
snd_compress_proc_info_read);
compr->proc_info_entry = entry;
return 0;
}
static void snd_compress_proc_done(struct snd_compr *compr)
{
snd_info_free_entry(compr->proc_info_entry);
compr->proc_info_entry = NULL;
snd_info_free_entry(compr->proc_root);
compr->proc_root = NULL;
}
Annotation
- Immediate include surface: `linux/file.h`, `linux/fs.h`, `linux/list.h`, `linux/math64.h`, `linux/mm.h`, `linux/mutex.h`, `linux/poll.h`, `linux/slab.h`.
- Detected declarations: `struct snd_compr_file`, `function snd_compr_task_free_all`, `function snd_compr_free`, `function snd_compr_tstamp32_from_64`, `function snd_compr_update_tstamp`, `function snd_compr_calc_avail`, `function snd_compr_get_avail`, `function snd_compr_avail32_from_64`, `function snd_compr_ioctl_avail`, `function snd_compr_write_data`.
- Atlas domain: Driver Families / sound/core.
- Implementation status: pattern 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.