Audio: Module adapter: Pass entire cdata to clients for all controls

This patch unifies all the control types (bytes, enum, switch).
Previously for binary control the fragment pointed to
cdata->data[0].data while for other control types the cdata
was passed via fragment. If fragment always points to cdata
the module adapter client can reliably check the control type
from cdata->cmd and handle other than binary control types.

Since the client components with binary control pass the
data to comp_data_blob_set() in data_blob.c the restore of
pointer fragment to cdata->data[0].data can be done there.

A check for SOF_CTRL_CMD_BINARY is added to comp_data_blob_set()
and comp_data_blob_get_cmd() to avoid wrong usage of controls.

With IPC4 in comp_data_blob_set() the use of
struct sof_ipc_ctrl_data pointer step is not done but the
fragment is treated as raw data payload without the header.
The generic support for other than binary control will be
solved later for IPC4.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
Seppo Ingalsuo 2023-03-29 13:35:04 +03:00 committed by Liam Girdwood
parent 975dc84e1e
commit 7d0a0c673f
2 changed files with 22 additions and 5 deletions

View File

@ -164,13 +164,26 @@ int comp_init_data_blob(struct comp_data_blob_handler *blob_handler,
int comp_data_blob_set(struct comp_data_blob_handler *blob_handler,
enum module_cfg_fragment_position pos, uint32_t data_offset_size,
const uint8_t *fragment, size_t fragment_size)
const uint8_t *fragment_in, size_t fragment_size)
{
#if CONFIG_IPC_MAJOR_3
struct sof_ipc_ctrl_data *cdata = (struct sof_ipc_ctrl_data *)fragment_in;
const uint8_t *fragment = (const uint8_t *)cdata->data[0].data;
#elif CONFIG_IPC_MAJOR_4
const uint8_t *fragment = fragment_in;
#endif
int ret;
if (!blob_handler)
return -EINVAL;
#if CONFIG_IPC_MAJOR_3
if (cdata->cmd != SOF_CTRL_CMD_BINARY) {
comp_err(blob_handler->dev, "comp_data_blob_set_cmd(), illegal control command");
return -EINVAL;
}
#endif
comp_dbg(blob_handler->dev, "comp_data_blob_set_cmd() pos = %d, fragment size = %d",
pos, fragment_size);
@ -556,6 +569,11 @@ int comp_data_blob_get_cmd(struct comp_data_blob_handler *blob_handler,
assert(blob_handler);
if (cdata->cmd != SOF_CTRL_CMD_BINARY) {
comp_err(blob_handler->dev, "comp_data_blob_set_cmd(), illegal control command");
return -EINVAL;
}
comp_dbg(blob_handler->dev, "comp_data_blob_get_cmd() msg_index = %d, num_elems = %d, remaining = %d ",
cdata->msg_index, cdata->num_elems,
cdata->elems_remaining);

View File

@ -942,12 +942,11 @@ static int module_adapter_get_set_params(struct comp_dev *dev, struct sof_ipc_ct
*/
if (set && md->ops->set_configuration)
return md->ops->set_configuration(mod, cdata->data[0].type, pos, data_offset_size,
(const uint8_t *)cdata->data[0].data,
cdata->num_elems, NULL, 0);
(const uint8_t *)cdata, cdata->num_elems,
NULL, 0);
else if (!set && md->ops->get_configuration)
return md->ops->get_configuration(mod, pos, &data_offset_size,
(uint8_t *)cdata->data[0].data,
cdata->num_elems);
(uint8_t *)cdata, cdata->num_elems);
comp_warn(dev, "module_adapter_get_set_params(): no configuration op set for %d",
dev_comp_id(dev));