sound/soc/codecs/cs-amp-lib-test.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/cs-amp-lib-test.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/cs-amp-lib-test.c- Extension
.c- Size
- 108125 bytes
- Lines
- 2620
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
kunit/resource.hkunit/test.hkunit/test-bug.hkunit/static_stub.hlinux/device/faux.hlinux/firmware/cirrus/cs_dsp.hlinux/firmware/cirrus/wmfw.hlinux/gpio/driver.hlinux/list.hlinux/module.hlinux/overflow.hlinux/pci_ids.hlinux/random.hsound/cs-amp-lib.h
Detected Declarations
struct cs_amp_lib_test_privstruct cs_amp_lib_test_ctl_write_entrystruct cs_amp_lib_test_paramfunction cs_amp_lib_test_init_dummy_cal_blobfunction cs_amp_lib_test_get_target_uidfunction cs_amp_lib_test_get_efi_variable_noheadfunction cs_amp_lib_test_cal_data_too_short_testfunction cs_amp_lib_test_get_efi_variable_bad_countfunction cs_amp_lib_test_cal_count_too_big_testfunction cs_amp_lib_test_get_efi_variable_nonefunction cs_amp_lib_test_no_cal_data_testfunction cs_amp_lib_test_get_efi_variablefunction cs_amp_lib_test_get_efi_variable_all_zerosfunction cs_amp_lib_test_get_hp_cal_efi_variablefunction cs_amp_lib_test_get_hp_efi_calfunction cs_amp_lib_test_get_efi_cal_by_uid_testfunction cs_amp_lib_test_get_efi_cal_by_index_unchecked_testfunction cs_amp_lib_test_get_efi_cal_by_index_checked_testfunction cs_amp_lib_test_get_efi_cal_by_index_uid_mismatch_testfunction cs_amp_lib_test_get_efi_cal_by_index_fallback_testfunction cs_amp_lib_test_get_efi_cal_uid_not_found_noindex_testfunction cs_amp_lib_test_get_efi_cal_uid_not_found_index_not_found_testfunction cs_amp_lib_test_get_efi_cal_no_uid_index_not_found_testfunction cs_amp_lib_test_get_efi_cal_no_uid_no_index_testfunction cs_amp_lib_test_get_efi_cal_zero_not_matched_testfunction cs_amp_lib_test_get_efi_cal_empty_entry_testfunction cs_amp_lib_test_write_cal_coefffunction cs_amp_lib_test_write_cal_data_testfunction cs_amp_lib_test_read_cal_coefffunction cs_amp_lib_test_read_cal_data_testfunction cs_amp_lib_test_write_ambient_testfunction cs_amp_lib_test_set_efi_variablefunction cs_amp_lib_test_set_efi_variable_deniedfunction cs_amp_lib_test_create_new_cal_efifunction cs_amp_lib_test_create_new_cal_efi_indexedfunction cs_amp_lib_test_create_new_cal_efi_indexed_no_maxfunction cs_amp_lib_test_grow_append_cal_efifunction cs_amp_lib_test_grow_append_cal_efi_indexedfunction cs_amp_lib_test_cal_efi_all_zeros_add_firstfunction cs_amp_lib_test_cal_efi_all_zeros_add_first_no_shrinkfunction cs_amp_lib_test_cal_efi_all_zeros_add_first_indexedfunction cs_amp_lib_test_cal_efi_all_zeros_add_first_indexed_no_shrinkfunction cs_amp_lib_test_grow_append_cal_efi_indexed_no_maxfunction cs_amp_lib_test_grow_cal_efi_replace_indexedfunction cs_amp_lib_test_grow_cal_efi_replace_by_uidfunction cs_amp_lib_test_cal_efi_replace_by_uidfunction cs_amp_lib_test_cal_efi_replace_by_indexfunction cs_amp_lib_test_cal_efi_deduplicate
Annotated Snippet
struct cs_amp_lib_test_priv {
struct faux_device *amp_dev;
struct cirrus_amp_efi_data *cal_blob;
struct list_head ctl_write_list;
u32 efi_attr;
};
struct cs_amp_lib_test_ctl_write_entry {
struct list_head list;
unsigned int value;
char name[16];
};
struct cs_amp_lib_test_param {
int num_amps;
int amp_index;
char *vendor_sysid;
char *expected_sysid;
};
static struct cirrus_amp_efi_data *cs_amp_lib_test_cal_blob_dup(struct kunit *test)
{
struct cs_amp_lib_test_priv *priv = test->priv;
struct cirrus_amp_efi_data *temp;
KUNIT_ASSERT_EQ(test, struct_size(priv->cal_blob, data, priv->cal_blob->count),
priv->cal_blob->size);
temp = kunit_kmalloc(test, priv->cal_blob->size, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, temp);
memcpy(temp, priv->cal_blob, priv->cal_blob->size);
return temp;
}
static void cs_amp_lib_test_init_dummy_cal_blob(struct kunit *test, int num_amps)
{
struct cs_amp_lib_test_priv *priv = test->priv;
unsigned int blob_size;
int i;
blob_size = struct_size(priv->cal_blob, data, num_amps);
priv->cal_blob = kunit_kzalloc(test, blob_size, GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, priv->cal_blob);
priv->cal_blob->size = blob_size;
priv->cal_blob->count = num_amps;
get_random_bytes(priv->cal_blob->data, flex_array_size(priv->cal_blob, data, num_amps));
/* Ensure all timestamps are non-zero to mark the entry valid. */
for (i = 0; i < num_amps; i++)
priv->cal_blob->data[i].calTime[0] |= 1;
/*
* Ensure that all UIDs are non-zero and unique.
* Make both words non-zero and not equal values, so that
* tests can verify that both words were checked or changed.
*/
for (i = 0; i < num_amps; i++) {
*(u8 *)&priv->cal_blob->data[i].calTarget[0] = i + 1;
*(u8 *)&priv->cal_blob->data[i].calTarget[1] = i;
}
}
static u64 cs_amp_lib_test_get_target_uid(struct kunit *test)
{
struct cs_amp_lib_test_priv *priv = test->priv;
const struct cs_amp_lib_test_param *param = test->param_value;
u64 uid;
uid = priv->cal_blob->data[param->amp_index].calTarget[1];
uid <<= 32;
uid |= priv->cal_blob->data[param->amp_index].calTarget[0];
return uid;
}
/* Redirected get_efi_variable to simulate that the file is too short */
static efi_status_t cs_amp_lib_test_get_efi_variable_nohead(efi_char16_t *name,
efi_guid_t *guid,
u32 *returned_attr,
unsigned long *size,
void *buf)
{
if (!buf) {
*size = offsetof(struct cirrus_amp_efi_data, data) - 1;
return EFI_BUFFER_TOO_SMALL;
}
Annotation
- Immediate include surface: `kunit/resource.h`, `kunit/test.h`, `kunit/test-bug.h`, `kunit/static_stub.h`, `linux/device/faux.h`, `linux/firmware/cirrus/cs_dsp.h`, `linux/firmware/cirrus/wmfw.h`, `linux/gpio/driver.h`.
- Detected declarations: `struct cs_amp_lib_test_priv`, `struct cs_amp_lib_test_ctl_write_entry`, `struct cs_amp_lib_test_param`, `function cs_amp_lib_test_init_dummy_cal_blob`, `function cs_amp_lib_test_get_target_uid`, `function cs_amp_lib_test_get_efi_variable_nohead`, `function cs_amp_lib_test_cal_data_too_short_test`, `function cs_amp_lib_test_get_efi_variable_bad_count`, `function cs_amp_lib_test_cal_count_too_big_test`, `function cs_amp_lib_test_get_efi_variable_none`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source 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.