/* Create control pointing to this data */
def.flags = param->flags;
def.mem_type = param->mem_type;
def.offset_dsp_words = param->offs_words;
def.length_bytes = param->len_bytes;
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
/* * Write new data to the control, it should be written to the registers * and cs_dsp_coeff_lock_and_write_ctrl() should return 1 to indicate * that the control content changed.
*/
get_random_bytes(reg_vals, param->len_bytes);
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_write_ctrl(ctl, 0, reg_vals, param->len_bytes),
1);
KUNIT_ASSERT_EQ(test, regmap_raw_read(dsp->regmap, reg, readback, param->len_bytes), 0);
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals, param->len_bytes);
/* Drop expected writes and the regmap cache should be clean */
cs_dsp_mock_xm_header_drop_from_regmap_cache(priv);
cs_dsp_mock_regmap_drop_bytes(priv, reg, param->len_bytes);
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, true));
}
/* * Read from a volatile control while the firmware is running. * This should return the current state of the underlying registers.
*/ staticvoid cs_dsp_ctl_read_volatile_running(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals, *readback;
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
/* Read the control, it should return the current register content */
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl, 0, readback, param->len_bytes),
0);
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals, param->len_bytes);
/* * Change the register content and read the control, it should return * the new register content
*/
get_random_bytes(reg_vals, param->len_bytes);
KUNIT_ASSERT_EQ(test, regmap_raw_write(dsp->regmap, reg, reg_vals, param->len_bytes), 0);
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl, 0, readback, param->len_bytes),
0);
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals, param->len_bytes);
}
/* * Read from a volatile control before the firmware is started. * This should return an error.
*/ staticvoid cs_dsp_ctl_read_volatile_not_started(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals;
/* Create some DSP data to be read into the control cache */
alg_base_words = _get_alg_mem_base_words(test, alg_idx, param->mem_type);
reg = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type);
reg += (alg_base_words + param->offs_words) *
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
regmap_raw_write(dsp->regmap, reg, reg_vals, param->len_bytes);
/* Create control pointing to this data */
def.flags = param->flags | WMFW_CTL_FLAG_VOLATILE;
def.mem_type = param->mem_type;
def.offset_dsp_words = param->offs_words;
def.length_bytes = param->len_bytes;
/* Create some DSP data to be read into the control cache */
alg_base_words = _get_alg_mem_base_words(test, alg_idx, param->mem_type);
reg = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type);
reg += (alg_base_words + param->offs_words) *
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
regmap_raw_write(dsp->regmap, reg, reg_vals, param->len_bytes);
/* Create control pointing to this data */
def.flags = param->flags | WMFW_CTL_FLAG_VOLATILE;
def.mem_type = param->mem_type;
def.offset_dsp_words = param->offs_words;
def.length_bytes = param->len_bytes;
/* Power-down DSP then power-up with a different firmware */
cs_dsp_power_down(dsp);
wmfw = cs_dsp_mock_wmfw_get_firmware(builder2);
KUNIT_ASSERT_EQ(test, cs_dsp_power_up(dsp, wmfw, "mock_fw2", NULL, NULL, "mbc.vss"), 0);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
/* Read the control, it should return an error */
ctl = list_first_entry_or_null(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
KUNIT_ASSERT_NOT_NULL(test, ctl);
KUNIT_EXPECT_LT(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl, 0, reg_vals, param->len_bytes),
0);
}
/* * Write to a volatile control before the firmware is started. * This should return an error.
*/ staticvoid cs_dsp_ctl_write_volatile_not_started(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals;
/* Drop expected writes and the regmap cache should be clean */
cs_dsp_mock_xm_header_drop_from_regmap_cache(priv);
cs_dsp_mock_regmap_drop_bytes(priv, reg, param->len_bytes);
/* Write the control, it should return an error */
ctl = list_first_entry_or_null(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
KUNIT_ASSERT_NOT_NULL(test, ctl);
KUNIT_EXPECT_LT(test,
cs_dsp_coeff_lock_and_write_ctrl(ctl, 0, reg_vals, param->len_bytes),
0);
/* Should not have been any writes to registers */
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, true));
}
/* * Write to a volatile control after the firmware has stopped. * This should return an error.
*/ staticvoid cs_dsp_ctl_write_volatile_stopped(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals;
/* Start and stop the firmware */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
cs_dsp_stop(dsp);
/* Drop expected writes and the regmap cache should be clean */
cs_dsp_mock_xm_header_drop_from_regmap_cache(priv);
cs_dsp_mock_regmap_drop_bytes(priv, reg, param->len_bytes);
/* Write the control, it should return an error */
ctl = list_first_entry_or_null(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
KUNIT_ASSERT_NOT_NULL(test, ctl);
KUNIT_EXPECT_LT(test,
cs_dsp_coeff_lock_and_write_ctrl(ctl, 0, reg_vals, param->len_bytes),
0);
/* Should not have been any writes to registers */
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, true));
}
/* * Write to a volatile control after the DSP has been powered down. * This should return an error.
*/ staticvoid cs_dsp_ctl_write_volatile_stopped_powered_down(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals;
/* Start and stop the firmware then power down */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
cs_dsp_stop(dsp);
cs_dsp_power_down(dsp);
/* Drop expected writes and the regmap cache should be clean */
cs_dsp_mock_xm_header_drop_from_regmap_cache(priv);
cs_dsp_mock_regmap_drop_bytes(priv, reg, param->len_bytes);
/* Write the control, it should return an error */
ctl = list_first_entry_or_null(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
KUNIT_ASSERT_NOT_NULL(test, ctl);
KUNIT_EXPECT_LT(test,
cs_dsp_coeff_lock_and_write_ctrl(ctl, 0, reg_vals, param->len_bytes),
0);
/* Should not have been any writes to registers */
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, true));
}
/* * Write to a volatile control when a different firmware is currently * loaded into the DSP. * Should return an error.
*/ staticvoid cs_dsp_ctl_write_volatile_not_current_loaded_fw(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; struct cs_dsp_mock_wmfw_builder *builder2 = _create_dummy_wmfw(test); int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals;
/* Create some DSP data to be read into the control cache */
alg_base_words = _get_alg_mem_base_words(test, alg_idx, param->mem_type);
reg = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type);
reg += (alg_base_words + param->offs_words) *
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
regmap_raw_write(dsp->regmap, reg, reg_vals, param->len_bytes);
/* Create control pointing to this data */
def.flags = param->flags | WMFW_CTL_FLAG_VOLATILE;
def.mem_type = param->mem_type;
def.offset_dsp_words = param->offs_words;
def.length_bytes = param->len_bytes;
/* Power-down DSP then power-up with a different firmware */
cs_dsp_power_down(dsp);
wmfw = cs_dsp_mock_wmfw_get_firmware(builder2);
KUNIT_ASSERT_EQ(test, cs_dsp_power_up(dsp, wmfw, "mock_fw2", NULL, NULL, "mbc.vss"), 0);
/* Drop expected writes and the regmap cache should be clean */
cs_dsp_mock_xm_header_drop_from_regmap_cache(priv);
cs_dsp_mock_regmap_drop_bytes(priv, reg, param->len_bytes);
/* Write the control, it should return an error */
ctl = list_first_entry_or_null(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
KUNIT_ASSERT_NOT_NULL(test, ctl);
KUNIT_EXPECT_LT(test,
cs_dsp_coeff_lock_and_write_ctrl(ctl, 0, reg_vals, param->len_bytes),
0);
/* Should not have been any writes to registers */
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, true));
}
/* * Write to a volatile control when a different firmware is currently * running. * Should return an error.
*/ staticvoid cs_dsp_ctl_write_volatile_not_current_running_fw(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; struct cs_dsp_mock_wmfw_builder *builder2 = _create_dummy_wmfw(test); int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals;
/* Create some DSP data to be read into the control cache */
alg_base_words = _get_alg_mem_base_words(test, alg_idx, param->mem_type);
reg = cs_dsp_mock_base_addr_for_mem(priv, param->mem_type);
reg += (alg_base_words + param->offs_words) *
cs_dsp_mock_reg_addr_inc_per_unpacked_word(priv);
regmap_raw_write(dsp->regmap, reg, reg_vals, param->len_bytes);
/* Create control pointing to this data */
def.flags = param->flags | WMFW_CTL_FLAG_VOLATILE;
def.mem_type = param->mem_type;
def.offset_dsp_words = param->offs_words;
def.length_bytes = param->len_bytes;
/* Power-down DSP then power-up with a different firmware */
cs_dsp_power_down(dsp);
wmfw = cs_dsp_mock_wmfw_get_firmware(builder2);
KUNIT_ASSERT_EQ(test, cs_dsp_power_up(dsp, wmfw, "mock_fw2", NULL, NULL, "mbc.vss"), 0);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
/* Drop expected writes and the regmap cache should be clean */
cs_dsp_mock_xm_header_drop_from_regmap_cache(priv);
cs_dsp_mock_regmap_drop_bytes(priv, reg, param->len_bytes);
/* Write the control, it should return an error */
ctl = list_first_entry_or_null(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
KUNIT_ASSERT_NOT_NULL(test, ctl);
KUNIT_EXPECT_LT(test,
cs_dsp_coeff_lock_and_write_ctrl(ctl, 0, reg_vals, param->len_bytes),
0);
/* Should not have been any writes to registers */
KUNIT_EXPECT_FALSE(test, cs_dsp_mock_regmap_is_dirty(priv, true));
}
/* * Read from an offset into the control data. Should return only the * portion of data from the offset position.
*/ staticvoid cs_dsp_ctl_read_with_seek(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals, *readback; unsignedint seek_words;
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
/* * Read from an offset into the control cache. Should return only the * portion of data from the offset position. * Same as cs_dsp_ctl_read_with_seek() except the control is cached * and the firmware is not running.
*/ staticvoid cs_dsp_ctl_read_cache_with_seek(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals, *readback; unsignedint seek_words;
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
/* Reads are only allowed to be a multiple of the DSP word length */ for (len_bytes = sizeof(u32); len_bytes < def.length_bytes; len_bytes += sizeof(u32)) {
memset(readback, 0, def.length_bytes);
KUNIT_EXPECT_EQ(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl, 0, readback, len_bytes),
0);
KUNIT_EXPECT_MEMEQ(test, readback, reg_vals, len_bytes);
KUNIT_EXPECT_MEMNEQ(test,
(u8 *)readback + len_bytes,
(u8 *)reg_vals + len_bytes,
def.length_bytes - len_bytes);
}
}
/* * Read less than the full length of data from a cached control. * Should return only the requested number of bytes. * Same as cs_dsp_ctl_read_truncated() except the control is cached * and the firmware is not running.
*/ staticvoid cs_dsp_ctl_read_cache_truncated(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals, *readback; unsignedint len_bytes;
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
/* * Write to an offset into the control cache. Should only change the * portion of data from the offset position. * Same as cs_dsp_ctl_write_with_seek() except the control is cached * and the firmware is not running.
*/ staticvoid cs_dsp_ctl_write_cache_with_seek(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals, *readback, *new_data; unsignedint seek_words;
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
/* Writes are only allowed to be a multiple of the DSP word length */ for (len_bytes = sizeof(u32); len_bytes < def.length_bytes; len_bytes += sizeof(u32)) { /* Reset the register values to the test data */
regmap_raw_write(dsp->regmap, reg, reg_vals, def.length_bytes);
/* * Write less than the full length of data to a cached control. * Should only change the requested number of bytes. * Same as cs_dsp_ctl_write_truncated() except the control is cached * and the firmware is not running.
*/ staticvoid cs_dsp_ctl_write_cache_truncated(struct kunit *test)
{ conststruct cs_dsp_ctl_rw_test_param *param = test->param_value; struct cs_dsp_test *priv = test->priv; struct cs_dsp_test_local *local = priv->local; struct cs_dsp *dsp = priv->dsp; struct cs_dsp_mock_coeff_def def = mock_coeff_template; int alg_idx = _find_alg_entry(test, param->alg_id); unsignedint reg, alg_base_words; struct cs_dsp_coeff_ctl *ctl; struct firmware *wmfw;
u32 *reg_vals, *readback, *new_data; unsignedint len_bytes;
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Start and stop the firmware so the read will come from the cache */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
cs_dsp_stop(dsp);
/* Writes are only allowed to be a multiple of the DSP word length */ for (len_bytes = sizeof(u32); len_bytes < def.length_bytes; len_bytes += sizeof(u32)) { /* Reset the cache to the test data */
KUNIT_EXPECT_GE(test,
cs_dsp_coeff_lock_and_write_ctrl(ctl, 0, reg_vals,
def.length_bytes),
0);
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
if (!(def.flags & WMFW_CTL_FLAG_VOLATILE)) { /* Stop firmware and repeat the read from the cache */
kunit_release_action(test, _cs_dsp_stop_wrapper, dsp);
KUNIT_ASSERT_FALSE(test, dsp->running);
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
if (!(def.flags & WMFW_CTL_FLAG_VOLATILE)) { /* Stop firmware and repeat the read from the cache */
kunit_release_action(test, _cs_dsp_stop_wrapper, dsp);
KUNIT_ASSERT_FALSE(test, dsp->running);
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
/* * Read full control length but at a start offset of 1 so that * offset + length exceeds the length of the control.
*/
KUNIT_EXPECT_LT(test,
cs_dsp_coeff_lock_and_read_ctrl(ctl, 1, reg_vals, def.length_bytes),
0);
if (!(def.flags & WMFW_CTL_FLAG_VOLATILE)) { /* Stop firmware and repeat the read from the cache */
kunit_release_action(test, _cs_dsp_stop_wrapper, dsp);
KUNIT_ASSERT_FALSE(test, dsp->running);
/* Create control pointing to this data */
cs_dsp_mock_wmfw_start_alg_info_block(local->wmfw_builder,
cs_dsp_ctl_rw_test_algs[alg_idx].id, "dummyalg", NULL);
cs_dsp_mock_wmfw_add_coeff_desc(local->wmfw_builder, &def);
cs_dsp_mock_wmfw_end_alg_info_block(local->wmfw_builder);
/* Start the firmware and add an action to stop it during cleanup */
KUNIT_ASSERT_EQ(test, cs_dsp_run(dsp), 0);
KUNIT_ASSERT_EQ(test, kunit_add_action_or_reset(test, _cs_dsp_stop_wrapper, dsp), 0);
/* Drop expected writes and the regmap cache should be clean */
cs_dsp_mock_xm_header_drop_from_regmap_cache(priv);
cs_dsp_mock_regmap_drop_bytes(priv, reg, param->len_bytes);
if (!(def.flags & WMFW_CTL_FLAG_VOLATILE)) { /* Stop firmware and repeat the write to the cache */
kunit_release_action(test, _cs_dsp_stop_wrapper, dsp);
KUNIT_ASSERT_FALSE(test, dsp->running);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.