sound/isa/sb/sb16_csp.c
Source file repositories/reference/linux-study-clean/sound/isa/sb/sb16_csp.c
File Facts
- System
- Linux kernel
- Corpus path
sound/isa/sb/sb16_csp.c- Extension
.c- Size
- 31964 bytes
- Lines
- 1158
- Domain
- Driver Families
- Bucket
- sound/isa
- 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/delay.hlinux/init.hlinux/slab.hlinux/module.hlinux/string_choices.hsound/core.hsound/control.hsound/info.hsound/sb16_csp.hsound/initval.h
Detected Declarations
struct riff_headerstruct desc_headerfunction snd_sb_csp_newfunction snd_sb_csp_freefunction snd_sb_csp_openfunction snd_sb_csp_ioctlfunction snd_sb_csp_releasefunction snd_sb_csp_usefunction snd_sb_csp_unusefunction snd_sb_csp_riff_loadfunction snd_sb_csp_unloadfunction command_seqfunction set_codec_parameterfunction set_registerfunction read_registerfunction set_mode_registerfunction csp_detectfunction get_versionfunction snd_sb_csp_check_versionfunction CSPfunction scoped_guardfunction snd_sb_csp_load_userfunction snd_sb_csp_firmware_loadfunction runfunction snd_sb_csp_startfunction scoped_guardfunction snd_sb_csp_stopfunction scoped_guardfunction snd_sb_csp_pausefunction scoped_guardfunction snd_sb_csp_restartfunction scoped_guardfunction snd_sb_qsound_switch_getfunction snd_sb_qsound_switch_putfunction snd_sb_qsound_space_infofunction snd_sb_qsound_space_getfunction snd_sb_qsound_space_putfunction snd_sb_qsound_buildfunction snd_sb_qsound_destroyfunction snd_sb_csp_qsound_transferfunction init_proc_entryfunction info_readexport snd_sb_csp_new
Annotated Snippet
struct riff_header {
__le32 name;
__le32 len;
};
struct desc_header {
struct riff_header info;
__le16 func_nr;
__le16 VOC_type;
__le16 flags_play_rec;
__le16 flags_16bit_8bit;
__le16 flags_stereo_mono;
__le16 flags_rates;
};
/*
* prototypes
*/
static void snd_sb_csp_free(struct snd_hwdep *hw);
static int snd_sb_csp_open(struct snd_hwdep * hw, struct file *file);
static int snd_sb_csp_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg);
static int snd_sb_csp_release(struct snd_hwdep * hw, struct file *file);
static int csp_detect(struct snd_sb *chip, int *version);
static int set_codec_parameter(struct snd_sb *chip, unsigned char par, unsigned char val);
static int set_register(struct snd_sb *chip, unsigned char reg, unsigned char val);
static int read_register(struct snd_sb *chip, unsigned char reg);
static int set_mode_register(struct snd_sb *chip, unsigned char mode);
static int get_version(struct snd_sb *chip);
static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
struct snd_sb_csp_microcode __user * code);
static int snd_sb_csp_unload(struct snd_sb_csp * p);
static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags);
static int snd_sb_csp_autoload(struct snd_sb_csp * p, snd_pcm_format_t pcm_sfmt, int play_rec_mode);
static int snd_sb_csp_check_version(struct snd_sb_csp * p);
static int snd_sb_csp_use(struct snd_sb_csp * p);
static int snd_sb_csp_unuse(struct snd_sb_csp * p);
static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channels);
static int snd_sb_csp_stop(struct snd_sb_csp * p);
static int snd_sb_csp_pause(struct snd_sb_csp * p);
static int snd_sb_csp_restart(struct snd_sb_csp * p);
static int snd_sb_qsound_build(struct snd_sb_csp * p);
static void snd_sb_qsound_destroy(struct snd_sb_csp * p);
static int snd_sb_csp_qsound_transfer(struct snd_sb_csp * p);
static int init_proc_entry(struct snd_sb_csp * p, int device);
static void info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer);
/*
* Detect CSP chip and create a new instance
*/
int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep)
{
struct snd_sb_csp *p;
int version;
int err;
struct snd_hwdep *hw;
if (rhwdep)
*rhwdep = NULL;
if (csp_detect(chip, &version))
return -ENODEV;
err = snd_hwdep_new(chip->card, "SB16-CSP", device, &hw);
if (err < 0)
return err;
p = kzalloc_obj(*p);
if (!p) {
snd_device_free(chip->card, hw);
return -ENOMEM;
}
p->chip = chip;
p->version = version;
/* CSP operators */
p->ops.csp_use = snd_sb_csp_use;
p->ops.csp_unuse = snd_sb_csp_unuse;
p->ops.csp_autoload = snd_sb_csp_autoload;
p->ops.csp_start = snd_sb_csp_start;
p->ops.csp_stop = snd_sb_csp_stop;
p->ops.csp_qsound_transfer = snd_sb_csp_qsound_transfer;
mutex_init(&p->access_mutex);
sprintf(hw->name, "CSP v%d.%d", (version >> 4), (version & 0x0f));
hw->iface = SNDRV_HWDEP_IFACE_SB16CSP;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/init.h`, `linux/slab.h`, `linux/module.h`, `linux/string_choices.h`, `sound/core.h`, `sound/control.h`, `sound/info.h`.
- Detected declarations: `struct riff_header`, `struct desc_header`, `function snd_sb_csp_new`, `function snd_sb_csp_free`, `function snd_sb_csp_open`, `function snd_sb_csp_ioctl`, `function snd_sb_csp_release`, `function snd_sb_csp_use`, `function snd_sb_csp_unuse`, `function snd_sb_csp_riff_load`.
- Atlas domain: Driver Families / sound/isa.
- 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.