sound/hda/core/regmap.c
Source file repositories/reference/linux-study-clean/sound/hda/core/regmap.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/core/regmap.c- Extension
.c- Size
- 15241 bytes
- Lines
- 589
- Domain
- Driver Families
- Bucket
- sound/hda
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/device.hlinux/regmap.hlinux/export.hlinux/pm.hsound/core.hsound/hdaudio.hsound/hda_regmap.hlocal.h
Detected Declarations
function codec_pm_lockfunction codec_pm_unlockfunction hda_volatile_regfunction hda_writeable_regfunction snd_array_for_eachfunction hda_readable_regfunction is_stereo_amp_verbfunction hda_reg_read_stereo_ampfunction hda_reg_write_stereo_ampfunction hda_reg_read_coeffunction hda_reg_write_coeffunction hda_reg_readfunction hda_reg_writefunction snd_hdac_regmap_initfunction snd_hdac_regmap_exitfunction snd_hdac_regmap_add_vendor_verbfunction reg_raw_writefunction snd_hdac_regmap_write_rawfunction reg_raw_readfunction __snd_hdac_regmap_read_rawfunction snd_hdac_regmap_read_rawfunction snd_hdac_regmap_read_raw_uncachedfunction reg_raw_updatefunction snd_hdac_regmap_update_rawfunction reg_raw_update_oncefunction snd_hdac_regmap_update_raw_oncefunction snd_hdac_regmap_syncexport snd_hdac_regmap_initexport snd_hdac_regmap_exitexport snd_hdac_regmap_add_vendor_verbexport snd_hdac_regmap_write_rawexport snd_hdac_regmap_read_rawexport snd_hdac_regmap_update_rawexport snd_hdac_regmap_update_raw_onceexport snd_hdac_regmap_sync
Annotated Snippet
if (reg & AC_AMP_GET_OUTPUT) {
verb |= AC_AMP_SET_OUTPUT >> 8;
} else {
verb |= AC_AMP_SET_INPUT >> 8;
verb |= reg & 0xf;
}
break;
}
switch (verb) {
case AC_VERB_SET_DIGI_CONVERT_1:
bytes = 2;
break;
case AC_VERB_SET_CONFIG_DEFAULT_BYTES_0:
bytes = 4;
break;
default:
bytes = 1;
break;
}
for (i = 0; i < bytes; i++) {
reg &= ~0xfffff;
reg |= (verb + i) << 8 | ((val >> (8 * i)) & 0xff);
err = snd_hdac_exec_verb(codec, reg, 0, NULL);
if (err < 0)
goto out;
}
out:
codec_pm_unlock(codec, pm_lock);
return err;
}
static const struct regmap_config hda_regmap_cfg = {
.name = "hdaudio",
.reg_bits = 32,
.val_bits = 32,
.max_register = 0xfffffff,
.writeable_reg = hda_writeable_reg,
.readable_reg = hda_readable_reg,
.volatile_reg = hda_volatile_reg,
.cache_type = REGCACHE_MAPLE,
.reg_read = hda_reg_read,
.reg_write = hda_reg_write,
.use_single_read = true,
.use_single_write = true,
.disable_locking = true,
};
/**
* snd_hdac_regmap_init - Initialize regmap for HDA register accesses
* @codec: the codec object
*
* Returns zero for success or a negative error code.
*/
int snd_hdac_regmap_init(struct hdac_device *codec)
{
struct regmap *regmap;
regmap = regmap_init(&codec->dev, NULL, codec, &hda_regmap_cfg);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
codec->regmap = regmap;
snd_array_init(&codec->vendor_verbs, sizeof(unsigned int), 8);
return 0;
}
EXPORT_SYMBOL_GPL(snd_hdac_regmap_init);
/**
* snd_hdac_regmap_exit - Release the regmap from HDA codec
* @codec: the codec object
*/
void snd_hdac_regmap_exit(struct hdac_device *codec)
{
if (codec->regmap) {
regmap_exit(codec->regmap);
codec->regmap = NULL;
snd_array_free(&codec->vendor_verbs);
}
}
EXPORT_SYMBOL_GPL(snd_hdac_regmap_exit);
/**
* snd_hdac_regmap_add_vendor_verb - add a vendor-specific verb to regmap
* @codec: the codec object
* @verb: verb to allow accessing via regmap
*
* Returns zero for success or a negative error code.
*/
Annotation
- Immediate include surface: `linux/slab.h`, `linux/device.h`, `linux/regmap.h`, `linux/export.h`, `linux/pm.h`, `sound/core.h`, `sound/hdaudio.h`, `sound/hda_regmap.h`.
- Detected declarations: `function codec_pm_lock`, `function codec_pm_unlock`, `function hda_volatile_reg`, `function hda_writeable_reg`, `function snd_array_for_each`, `function hda_readable_reg`, `function is_stereo_amp_verb`, `function hda_reg_read_stereo_amp`, `function hda_reg_write_stereo_amp`, `function hda_reg_read_coef`.
- Atlas domain: Driver Families / sound/hda.
- Implementation status: integration implementation candidate.
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.