sound/soc/codecs/cs-amp-lib.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/cs-amp-lib.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/cs-amp-lib.c- Extension
.c- Size
- 25401 bytes
- Lines
- 865
- Domain
- Driver Families
- Bucket
- sound/soc
- 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.
- 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
asm/byteorder.hkunit/static_stub.hlinux/debugfs.hlinux/dev_printk.hlinux/efi.hlinux/firmware/cirrus/cs_dsp.hlinux/math64.hlinux/module.hlinux/mutex.hlinux/overflow.hlinux/pci_ids.hlinux/slab.hlinux/timekeeping.hlinux/types.hsound/cs-amp-lib.h
Detected Declarations
struct cs_amp_spkid_efifunction cs_amp_time_now_in_windows_timefunction cs_amp_write_cal_coefffunction cs_amp_read_cal_coefffunction scoped_guardfunction _cs_amp_write_cal_coeffsfunction _cs_amp_read_cal_coeffsfunction cs_amp_write_cal_coeffsfunction cs_amp_read_cal_coeffsfunction cs_amp_write_ambient_tempfunction cs_amp_get_efi_variablefunction cs_amp_set_efi_variablefunction cs_amp_convert_efi_statusfunction cs_amp_set_cal_efi_bufferfunction _cs_amp_get_efi_calibration_datafunction _cs_amp_set_efi_calibration_datafunction cs_amp_get_efi_calibration_datafunction cs_amp_set_efi_calibration_datafunction cs_amp_get_efi_byte_spkidfunction cs_amp_get_vendor_spkidfunction ERR_PTR
Annotated Snippet
struct cs_amp_spkid_efi {
efi_char16_t *name;
efi_guid_t *guid;
u8 values[2];
};
static int cs_amp_get_efi_byte_spkid(struct device *dev, const struct cs_amp_spkid_efi *info)
{
efi_status_t status;
unsigned long size;
u8 spkid;
int i, ret;
size = sizeof(spkid);
status = cs_amp_get_efi_variable(info->name, info->guid, NULL, &size, &spkid);
ret = cs_amp_convert_efi_status(status);
if (ret < 0)
return ret;
if (size == 0)
return -ENOENT;
for (i = 0; i < ARRAY_SIZE(info->values); i++) {
if (info->values[i] == spkid)
return i;
}
dev_err(dev, "EFI speaker ID bad value %#x\n", spkid);
return -EINVAL;
}
static const struct cs_amp_spkid_efi cs_amp_spkid_byte_types[] = {
{
.name = LENOVO_SPEAKER_ID_EFI_NAME,
.guid = &LENOVO_SPEAKER_ID_EFI_GUID,
.values = { 0xd0, 0xd1 },
},
{
.name = HP_SPEAKER_ID_EFI_NAME,
.guid = &HP_SPEAKER_ID_EFI_GUID,
.values = { 0x30, 0x31 },
},
};
/**
* cs_amp_get_vendor_spkid - get a speaker ID from vendor-specific storage
* @dev: pointer to struct device
*
* Known vendor-specific methods of speaker ID are checked and if one is
* found its speaker ID value is returned.
*
* Return: >=0 is a valid speaker ID. -ENOENT if a vendor-specific method
* was not found. -EACCES if the vendor-specific storage could not
* be read. Other error values indicate that the data from the
* vendor-specific storage was found but could not be understood.
*/
int cs_amp_get_vendor_spkid(struct device *dev)
{
int i, ret;
KUNIT_STATIC_STUB_REDIRECT(cs_amp_get_vendor_spkid, dev);
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE) &&
!IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
return -ENOENT;
for (i = 0; i < ARRAY_SIZE(cs_amp_spkid_byte_types); i++) {
ret = cs_amp_get_efi_byte_spkid(dev, &cs_amp_spkid_byte_types[i]);
if (ret != -ENOENT)
return ret;
}
return -ENOENT;
}
EXPORT_SYMBOL_NS_GPL(cs_amp_get_vendor_spkid, "SND_SOC_CS_AMP_LIB");
static const char *cs_amp_devm_get_dell_ssidex(struct device *dev,
int ssid_vendor, int ssid_device)
{
unsigned int hex_prefix;
char audio_id[4];
char delim;
char *p;
int ret;
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE) &&
!IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
return ERR_PTR(-ENOENT);
Annotation
- Immediate include surface: `asm/byteorder.h`, `kunit/static_stub.h`, `linux/debugfs.h`, `linux/dev_printk.h`, `linux/efi.h`, `linux/firmware/cirrus/cs_dsp.h`, `linux/math64.h`, `linux/module.h`.
- Detected declarations: `struct cs_amp_spkid_efi`, `function cs_amp_time_now_in_windows_time`, `function cs_amp_write_cal_coeff`, `function cs_amp_read_cal_coeff`, `function scoped_guard`, `function _cs_amp_write_cal_coeffs`, `function _cs_amp_read_cal_coeffs`, `function cs_amp_write_cal_coeffs`, `function cs_amp_read_cal_coeffs`, `function cs_amp_write_ambient_temp`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration implementation candidate.
- 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.