sound/synth/emux/soundfont.c
Source file repositories/reference/linux-study-clean/sound/synth/emux/soundfont.c
File Facts
- System
- Linux kernel
- Corpus path
sound/synth/emux/soundfont.c- Extension
.c- Size
- 37705 bytes
- Lines
- 1490
- Domain
- Driver Families
- Bucket
- sound/synth
- 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/uaccess.hlinux/slab.hlinux/export.hsound/core.hsound/soundfont.hsound/seq_oss_legacy.h
Detected Declarations
function snd_soundfont_close_checkfunction snd_soundfont_loadfunction is_special_typefunction open_patchfunction scoped_guardfunction scoped_guardfunction newsffunction is_identical_fontfunction close_patchfunction probe_datafunction set_zone_counterfunction sf_zone_newfunction set_sample_counterfunction sf_sample_newfunction sf_sample_deletefunction load_mapfunction remove_infofunction load_infofunction init_voice_infofunction init_voice_parmfunction set_samplefunction find_samplefunction validate_sample_infofunction load_datafunction snd_sf_linear_to_logfunction freq_to_notefunction calc_rate_offsetfunction calc_gus_envelope_timefunction snd_sf_calc_parm_holdfunction calc_parm_searchfunction snd_sf_calc_parm_attackfunction snd_sf_calc_parm_decayfunction load_guspatchfunction snd_soundfont_load_guspatchfunction rebuild_presetsfunction add_presetfunction delete_presetfunction mappingfunction search_first_zonefunction search_zonesfunction get_indexfunction snd_sf_initfunction snd_sf_clearfunction snd_sf_newfunction snd_sf_freefunction scoped_guardfunction snd_soundfont_remove_samplesfunction snd_soundfont_remove_unlocked
Annotated Snippet
if (!sflist->currsf) {
dev_err(card->dev,
"soundfont: remove_info: patch not opened\n");
rc = -EINVAL;
} else {
int bank, instr;
bank = ((unsigned short)patch.optarg >> 8) & 0xff;
instr = (unsigned short)patch.optarg & 0xff;
if (! remove_info(sflist, sflist->currsf, bank, instr))
rc = -EINVAL;
else
rc = 0;
}
break;
}
return rc;
}
/* check if specified type is special font (GUS or preset-alias) */
static inline int
is_special_type(int type)
{
type &= 0x0f;
return (type == SNDRV_SFNT_PAT_TYPE_GUS ||
type == SNDRV_SFNT_PAT_TYPE_MAP);
}
/* open patch; create sf list */
static int
open_patch(struct snd_sf_list *sflist, const char __user *data,
int count, int client)
{
struct soundfont_open_parm parm;
struct snd_soundfont *sf;
scoped_guard(spinlock_irqsave, &sflist->lock) {
if (sflist->open_client >= 0 || sflist->currsf)
return -EBUSY;
}
if (copy_from_user(&parm, data, sizeof(parm)))
return -EFAULT;
if (is_special_type(parm.type)) {
parm.type |= SNDRV_SFNT_PAT_SHARED;
sf = newsf(sflist, parm.type, NULL);
} else
sf = newsf(sflist, parm.type, parm.name);
if (sf == NULL) {
return -ENOMEM;
}
scoped_guard(spinlock_irqsave, &sflist->lock) {
sflist->open_client = client;
sflist->currsf = sf;
}
return 0;
}
/*
* Allocate a new soundfont structure.
*/
static struct snd_soundfont *
newsf(struct snd_sf_list *sflist, int type, char *name)
{
struct snd_soundfont *sf;
/* check the shared fonts */
if (type & SNDRV_SFNT_PAT_SHARED) {
for (sf = sflist->fonts; sf; sf = sf->next) {
if (is_identical_font(sf, type, name)) {
return sf;
}
}
}
/* not found -- create a new one */
sf = kzalloc_obj(*sf);
if (sf == NULL)
return NULL;
sf->id = sflist->fonts_size;
sflist->fonts_size++;
/* prepend this record */
sf->next = sflist->fonts;
sflist->fonts = sf;
Annotation
- Immediate include surface: `linux/uaccess.h`, `linux/slab.h`, `linux/export.h`, `sound/core.h`, `sound/soundfont.h`, `sound/seq_oss_legacy.h`.
- Detected declarations: `function snd_soundfont_close_check`, `function snd_soundfont_load`, `function is_special_type`, `function open_patch`, `function scoped_guard`, `function scoped_guard`, `function newsf`, `function is_identical_font`, `function close_patch`, `function probe_data`.
- Atlas domain: Driver Families / sound/synth.
- 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.