Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/audio/component.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,3 +557,62 @@ void audio_stream_copy_to_linear(struct audio_stream *source, int ioffset,
snk += bytes_copied;
}
}

/** See comp_ops::params */
int comp_params(struct comp_dev *dev,
struct sof_ipc_stream_params *params)
{
int ret = 0;

if (dev->is_shared && !cpu_is_me(dev->ipc_config.core)) {
ret = comp_params_remote(dev, params);
} else {
if (dev->drv->ops.params) {
ret = dev->drv->ops.params(dev, params);
} else {
/* not defined, run the default handler */
ret = comp_verify_params(dev, 0, params);
if (ret < 0)
comp_err(dev, "pcm params verification failed");
}
}

return ret;
}

/** See comp_ops::cmd */
int comp_cmd(struct comp_dev *dev, int cmd, void *data,
int max_data_size)
{
struct sof_ipc_ctrl_data *cdata = ASSUME_ALIGNED(data, 4);

if (cmd == COMP_CMD_SET_DATA &&
(cdata->data->magic != SOF_ABI_MAGIC ||
SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, cdata->data->abi))) {
comp_err(dev, "comp_cmd(): invalid version, data->magic = %u, data->abi = %u",
cdata->data->magic, cdata->data->abi);
return -EINVAL;
}

if (dev->drv->ops.cmd)
return dev->drv->ops.cmd(dev, cmd, data, max_data_size);

return -EINVAL;
}

/** See comp_ops::copy */
int comp_copy(struct comp_dev *dev)
{
int ret = 0;

assert(dev->drv->ops.copy);

/* copy only if we are the owner of the component */
if (cpu_is_me(dev->ipc_config.core)) {
perf_cnt_init(&dev->pcd);
ret = dev->drv->ops.copy(dev);
perf_cnt_stamp(&dev->pcd, comp_perf_info, dev);
}

return ret;
}
21 changes: 21 additions & 0 deletions src/include/sof/audio/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,21 @@ static inline int comp_get_state(struct comp_dev *req_dev, struct comp_dev *dev)

struct comp_data_blob_handler;

/**
* Parameter init for component on other core.
* @param dev Component device.
* @param params Parameters to be set.
* @return 0 if succeeded, error code otherwise.
*/
static inline int comp_params_remote(struct comp_dev *dev,
struct sof_ipc_stream_params *params)
{
struct idc_msg msg = { IDC_MSG_PARAMS, IDC_MSG_PARAMS_EXT(dev->ipc_config.id),
dev->ipc_config.core, sizeof(*params), params, };

return idc_send_msg(&msg, IDC_BLOCKING);
}

/**
* Returns data blob. In case when new data blob is available it returns new
* one. Function returns also data blob size in case when size pointer is given.
Expand Down Expand Up @@ -920,6 +935,12 @@ void comp_data_blob_handler_free(struct comp_data_blob_handler *blob_handler);
int comp_verify_params(struct comp_dev *dev, uint32_t flag,
struct sof_ipc_stream_params *params);

int comp_params(struct comp_dev *dev, struct sof_ipc_stream_params *params);

int comp_cmd(struct comp_dev *dev, int cmd, void *data, int max_data_size);

int comp_copy(struct comp_dev *dev);

/** @}*/

#endif /* __SOF_AUDIO_COMPONENT_H__ */
74 changes: 0 additions & 74 deletions src/include/sof/audio/component_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,43 +55,6 @@ static inline void comp_free(struct comp_dev *dev)
dev->drv->ops.free(dev);
}

/**
* Parameter init for component on other core.
* @param dev Component device.
* @param params Parameters to be set.
* @return 0 if succeeded, error code otherwise.
*/
static inline int comp_params_remote(struct comp_dev *dev,
struct sof_ipc_stream_params *params)
{
struct idc_msg msg = { IDC_MSG_PARAMS, IDC_MSG_PARAMS_EXT(dev->ipc_config.id),
dev->ipc_config.core, sizeof(*params), params, };

return idc_send_msg(&msg, IDC_BLOCKING);
}

/** See comp_ops::params */
static inline int comp_params(struct comp_dev *dev,
struct sof_ipc_stream_params *params)
{
int ret = 0;

if (dev->is_shared && !cpu_is_me(dev->ipc_config.core)) {
ret = comp_params_remote(dev, params);
} else {
if (dev->drv->ops.params) {
ret = dev->drv->ops.params(dev, params);
} else {
/* not defined, run the default handler */
ret = comp_verify_params(dev, 0, params);
if (ret < 0)
comp_err(dev, "pcm params verification failed");
}
}

return ret;
}

/** See comp_ops::dai_get_hw_params */
static inline int comp_dai_get_hw_params(struct comp_dev *dev,
struct sof_ipc_stream_params *params,
Expand All @@ -103,26 +66,6 @@ static inline int comp_dai_get_hw_params(struct comp_dev *dev,
return -EINVAL;
}

/** See comp_ops::cmd */
static inline int comp_cmd(struct comp_dev *dev, int cmd, void *data,
int max_data_size)
{
struct sof_ipc_ctrl_data *cdata = ASSUME_ALIGNED(data, 4);

if (cmd == COMP_CMD_SET_DATA &&
(cdata->data->magic != SOF_ABI_MAGIC ||
SOF_ABI_VERSION_INCOMPATIBLE(SOF_ABI_VERSION, cdata->data->abi))) {
comp_err(dev, "comp_cmd(): invalid version, data->magic = %u, data->abi = %u",
cdata->data->magic, cdata->data->abi);
return -EINVAL;
}

if (dev->drv->ops.cmd)
return dev->drv->ops.cmd(dev, cmd, data, max_data_size);

return -EINVAL;
}

/**
* Runs comp_ops::trigger on the core the target component is assigned to.
*/
Expand Down Expand Up @@ -163,23 +106,6 @@ static inline int comp_prepare(struct comp_dev *dev)
return 0;
}

/** See comp_ops::copy */
static inline int comp_copy(struct comp_dev *dev)
{
int ret = 0;

assert(dev->drv->ops.copy);

/* copy only if we are the owner of the component */
if (cpu_is_me(dev->ipc_config.core)) {
perf_cnt_init(&dev->pcd);
ret = dev->drv->ops.copy(dev);
perf_cnt_stamp(&dev->pcd, comp_perf_info, dev);
}

return ret;
}

/** See comp_ops::get_attribute */
static inline int comp_get_attribute(struct comp_dev *dev, uint32_t type,
void *value)
Expand Down