drivers/firmware/cirrus/test/cs_dsp_test_control_parse.c
Source file repositories/reference/linux-study-clean/drivers/firmware/cirrus/test/cs_dsp_test_control_parse.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/cirrus/test/cs_dsp_test_control_parse.c- Extension
.c- Size
- 68586 bytes
- Lines
- 1844
- Domain
- Driver Families
- Bucket
- drivers/firmware
- 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.
- 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
kunit/device.hkunit/resource.hkunit/test.hlinux/build_bug.hlinux/firmware/cirrus/cs_dsp.hlinux/firmware/cirrus/cs_dsp_test_utils.hlinux/firmware/cirrus/wmfw.hlinux/list.hlinux/mutex.hlinux/regmap.h
Detected Declarations
struct cs_dsp_test_localstruct cs_dsp_ctl_parse_test_paramfunction cs_dsp_ctl_parse_no_coeffsfunction cs_dsp_ctl_parse_v1_namefunction cs_dsp_ctl_parse_empty_v1_namefunction cs_dsp_ctl_parse_max_v1_namefunction cs_dsp_ctl_parse_short_namefunction cs_dsp_ctl_parse_min_short_namefunction cs_dsp_ctl_parse_max_short_namefunction cs_dsp_ctl_parse_with_min_fullnamefunction cs_dsp_ctl_parse_with_max_fullnamefunction cs_dsp_ctl_parse_with_min_descriptionfunction cs_dsp_ctl_parse_with_max_descriptionfunction cs_dsp_ctl_parse_with_max_fullname_and_descriptionfunction cs_dsp_ctl_shortname_alignmentfunction cs_dsp_ctl_fullname_alignmentfunction cs_dsp_ctl_description_alignmentfunction cs_dsp_get_ctl_testfunction cs_dsp_get_ctlfunction cs_dsp_ctl_parse_memory_typefunction cs_dsp_ctl_parse_alg_idfunction offunction cs_dsp_ctl_parse_offsetfunction cs_dsp_ctl_parse_lengthfunction cs_dsp_ctl_parse_ctl_typefunction cs_dsp_ctl_parse_flagsfunction cs_dsp_ctl_illegal_type_flagsfunction cs_dsp_ctl_parse_fw_namefunction cs_dsp_ctl_alg_id_uniquenessfunction cs_dsp_ctl_mem_uniquenessfunction cs_dsp_ctl_fw_uniquenessfunction cs_dsp_ctl_squash_reloaded_controlsfunction cs_dsp_ctl_v2_squash_reloaded_controlsfunction cs_dsp_ctl_v2_compare_lenfunction cs_dsp_ctl_parse_test_common_initfunction cs_dsp_ctl_parse_test_halo_initfunction cs_dsp_ctl_parse_test_adsp2_32bit_initfunction cs_dsp_ctl_parse_test_adsp2_32bit_wmfw1_initfunction cs_dsp_ctl_parse_test_adsp2_32bit_wmfw2_initfunction cs_dsp_ctl_parse_test_adsp2_16bit_initfunction cs_dsp_ctl_parse_test_adsp2_16bit_wmfw1_initfunction cs_dsp_ctl_parse_test_adsp2_16bit_wmfw2_initfunction cs_dsp_ctl_mem_type_descfunction cs_dsp_ctl_alg_id_descfunction cs_dsp_ctl_offset_descfunction cs_dsp_ctl_length_descfunction cs_dsp_ctl_type_flags_descfunction cs_dsp_ctl_flags_desc
Annotated Snippet
struct cs_dsp_test_local {
struct cs_dsp_mock_xm_header *xm_header;
struct cs_dsp_mock_wmfw_builder *wmfw_builder;
int wmfw_version;
};
struct cs_dsp_ctl_parse_test_param {
int mem_type;
int alg_id;
unsigned int offset;
unsigned int length;
u16 ctl_type;
u16 flags;
};
static const struct cs_dsp_mock_alg_def cs_dsp_ctl_parse_test_algs[] = {
{
.id = 0xfafa,
.ver = 0x100000,
.xm_size_words = 164,
.ym_size_words = 164,
.zm_size_words = 164,
},
{
.id = 0xb,
.ver = 0x100001,
.xm_size_words = 8,
.ym_size_words = 8,
.zm_size_words = 8,
},
{
.id = 0x9f1234,
.ver = 0x100500,
.xm_size_words = 16,
.ym_size_words = 16,
.zm_size_words = 16,
},
{
.id = 0xff00ff,
.ver = 0x300113,
.xm_size_words = 16,
.ym_size_words = 16,
.zm_size_words = 16,
},
};
static const struct cs_dsp_mock_coeff_def mock_coeff_template = {
.shortname = "Dummy Coeff",
.type = WMFW_CTL_TYPE_BYTES,
.mem_type = WMFW_ADSP2_YM,
.flags = WMFW_CTL_FLAG_VOLATILE,
.length_bytes = 4,
};
static char *cs_dsp_ctl_alloc_test_string(struct kunit *test, char c, size_t len)
{
char *str;
str = kunit_kmalloc(test, len + 1, GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, str);
memset(str, c, len);
str[len] = '\0';
return str;
}
/* Algorithm info block without controls should load */
static void cs_dsp_ctl_parse_no_coeffs(struct kunit *test)
{
struct cs_dsp_test *priv = test->priv;
struct cs_dsp_test_local *local = priv->local;
struct firmware *wmfw;
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_parse_test_algs[0].id,
"dummyalg", NULL);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
wmfw = cs_dsp_mock_wmfw_get_firmware(priv->local->wmfw_builder);
KUNIT_ASSERT_EQ(test, cs_dsp_power_up(priv->dsp, wmfw, "mock_fw", NULL, NULL, "misc"), 0);
}
/*
* V1 controls do not have names, the name field in the coefficient entry
* should be ignored.
*/
static void cs_dsp_ctl_parse_v1_name(struct kunit *test)
{
struct cs_dsp_test *priv = test->priv;
struct cs_dsp_test_local *local = priv->local;
Annotation
- Immediate include surface: `kunit/device.h`, `kunit/resource.h`, `kunit/test.h`, `linux/build_bug.h`, `linux/firmware/cirrus/cs_dsp.h`, `linux/firmware/cirrus/cs_dsp_test_utils.h`, `linux/firmware/cirrus/wmfw.h`, `linux/list.h`.
- Detected declarations: `struct cs_dsp_test_local`, `struct cs_dsp_ctl_parse_test_param`, `function cs_dsp_ctl_parse_no_coeffs`, `function cs_dsp_ctl_parse_v1_name`, `function cs_dsp_ctl_parse_empty_v1_name`, `function cs_dsp_ctl_parse_max_v1_name`, `function cs_dsp_ctl_parse_short_name`, `function cs_dsp_ctl_parse_min_short_name`, `function cs_dsp_ctl_parse_max_short_name`, `function cs_dsp_ctl_parse_with_min_fullname`.
- Atlas domain: Driver Families / drivers/firmware.
- Implementation status: source 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.