drivers/firmware/cirrus/test/cs_dsp_test_bin.c
Source file repositories/reference/linux-study-clean/drivers/firmware/cirrus/test/cs_dsp_test_bin.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/cirrus/test/cs_dsp_test_bin.c- Extension
.c- Size
- 112749 bytes
- Lines
- 2871
- 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.
- 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/static_stub.hkunit/test.hlinux/build_bug.hlinux/firmware/cirrus/cs_dsp.hlinux/firmware/cirrus/cs_dsp_test_utils.hlinux/firmware/cirrus/wmfw.hlinux/firmware.hlinux/math.hlinux/random.hlinux/regmap.h../cs_dsp.h
Detected Declarations
struct cs_dsp_test_localstruct bin_test_paramfunction _num_words_to_num_packed_regsfunction bin_patch_one_wordfunction bin_patch_one_multiwordfunction bin_patch_multi_onewordfunction bin_patch_multi_oneword_unorderedfunction bin_patch_multi_oneword_sparse_unorderedfunction bin_patch_one_word_multiple_memsfunction bin_patch_one_word_multiple_algsfunction bin_patch_one_word_multiple_algs_unorderedfunction bin_patch_1_packedfunction bin_patch_1_packed_1_single_trailingfunction bin_patch_1_packed_2_single_trailingfunction bin_patch_1_packed_3_single_trailingfunction bin_patch_1_packed_2_trailingfunction bin_patch_1_packed_3_trailingfunction bin_patch_1_single_leading_1_packedfunction bin_patch_2_single_leading_1_packedfunction bin_patch_2_leading_1_packedfunction bin_patch_3_single_leading_1_packedfunction bin_patch_3_leading_1_packedfunction bin_patch_multi_onepackedfunction bin_patch_multi_onepacked_unorderedfunction bin_patch_multi_onepacked_sparse_unorderedfunction bin_patch_1_packed_multiple_memsfunction bin_patch_1_packed_multiple_algsfunction bin_patch_1_packed_multiple_algs_unorderedfunction bin_patch_mixed_packed_unpacked_randomfunction bin_patch_name_and_infofunction cs_dsp_bin_test_can_emit_message_hookfunction cs_dsp_bin_test_common_initfunction cs_dsp_bin_test_halo_init_commonfunction cs_dsp_bin_test_halo_initfunction cs_dsp_bin_test_halo_wmdr3_initfunction cs_dsp_bin_test_adsp2_32bit_initfunction cs_dsp_bin_test_adsp2_16bit_initfunction x_or_y_or_z_and_offset_param_descfunction x_or_y_or_z_param_descfunction offset_param_descfunction alg_param_descfunction x_or_y_or_z_and_alg_param_desc
Annotated Snippet
struct cs_dsp_test_local {
struct cs_dsp_mock_bin_builder *bin_builder;
struct cs_dsp_mock_wmfw_builder *wmfw_builder;
struct firmware *wmfw;
};
struct bin_test_param {
const char *name;
int mem_type;
unsigned int offset_words;
int alg_idx;
void (*add_patch)(struct cs_dsp_mock_bin_builder *builder,
unsigned int alg_id, unsigned int alg_ver,
int mem_region, unsigned int reg_addr_offset,
const void *payload_data, size_t payload_len_bytes);
};
static const struct cs_dsp_mock_alg_def bin_test_mock_algs[] = {
{
.id = 0xfafa,
.ver = 0x100000,
.xm_size_words = 164,
.ym_size_words = 164,
.zm_size_words = 164,
},
{
.id = 0xfbfb,
.ver = 0x100000,
.xm_size_words = 99,
.ym_size_words = 99,
.zm_size_words = 99,
},
{
.id = 0xc321,
.ver = 0x100000,
.xm_size_words = 120,
.ym_size_words = 120,
.zm_size_words = 120,
},
{
.id = 0xb123,
.ver = 0x100000,
.xm_size_words = 96,
.ym_size_words = 96,
.zm_size_words = 96,
},
};
/*
* Convert number of DSP words to number of packed registers rounded
* down to the nearest register.
* There are 3 registers for every 4 packed words.
*/
static unsigned int _num_words_to_num_packed_regs(unsigned int num_dsp_words)
{
return (num_dsp_words * 3) / 4;
}
/* bin file that patches a single DSP word */
static void bin_patch_one_word(struct kunit *test)
{
struct cs_dsp_test *priv = test->priv;
const struct bin_test_param *param = test->param_value;
unsigned int reg_inc_per_word = cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
u32 reg_val, payload_data;
unsigned int alg_base_words, reg_addr;
struct firmware *fw;
get_random_bytes(&payload_data, sizeof(payload_data));
alg_base_words = cs_dsp_mock_xm_header_get_alg_base_in_words(priv,
bin_test_mock_algs[param->alg_idx].id,
param->mem_type);
param->add_patch(priv->local->bin_builder,
bin_test_mock_algs[param->alg_idx].id,
bin_test_mock_algs[param->alg_idx].ver,
param->mem_type,
param->offset_words * reg_inc_per_word,
&payload_data, sizeof(payload_data));
fw = cs_dsp_mock_bin_get_firmware(priv->local->bin_builder);
KUNIT_ASSERT_EQ(test,
cs_dsp_power_up(priv->dsp, priv->local->wmfw, "mock_wmfw",
fw, "mock_bin", "misc"),
0);
/* Content of registers should match payload_data */
reg_addr = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type) +
((alg_base_words + param->offset_words) * reg_inc_per_word);
Annotation
- Immediate include surface: `kunit/device.h`, `kunit/resource.h`, `kunit/static_stub.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`.
- Detected declarations: `struct cs_dsp_test_local`, `struct bin_test_param`, `function _num_words_to_num_packed_regs`, `function bin_patch_one_word`, `function bin_patch_one_multiword`, `function bin_patch_multi_oneword`, `function bin_patch_multi_oneword_unordered`, `function bin_patch_multi_oneword_sparse_unordered`, `function bin_patch_one_word_multiple_mems`, `function bin_patch_one_word_multiple_algs`.
- Atlas domain: Driver Families / drivers/firmware.
- 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.