comp: run default params handler if not defined by target comp

Actions perfomed by the default handler are required to keep
the component device state consistent (e.g. dev->frames are
initialized). While the current comp_params() silently skips
the component if params are not defined.

New simple components will not be required to define a handler
if no extra steps are needed.

It is also an opportunity to reduce the code of existing components
Note that most of the extra steps are moved to prepare() in many
implementations already (like volume), others may follow and remove
their params() handlers once reduced to a single call to the default
handler (like mux recently did).

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
This commit is contained in:
Marcin Maka 2020-04-01 15:40:28 +02:00 committed by Tomasz Lauda
parent 3808dfec67
commit 8a7875d5e4
3 changed files with 25 additions and 4 deletions

View File

@ -263,6 +263,10 @@ struct comp_ops {
* Sets component audio stream parameters.
* @param dev Component device.
* @param params Audio (PCM) stream parameters to be set.
*
* Infrastructure calls comp_verify_params() if this handler is not
* defined, therefore it should be left NULL if no extra steps are
* required.
*/
int (*params)(struct comp_dev *dev,
struct sof_ipc_stream_params *params);

View File

@ -85,10 +85,18 @@ static inline int comp_params(struct comp_dev *dev,
{
int ret = 0;
if (dev->drv->ops.params)
ret = (dev->is_shared && !cpu_is_me(dev->comp.core)) ?
comp_params_remote(dev, params) :
dev->drv->ops.params(dev, params);
if (dev->is_shared && !cpu_is_me(dev->comp.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");
}
}
comp_shared_commit(dev);

View File

@ -118,3 +118,12 @@ void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
(void)data;
(void)high_priority;
}
int comp_verify_params(struct comp_dev *dev, uint32_t flag,
struct sof_ipc_stream_params *params)
{
(void)dev;
(void)flag;
(void)params;
return 0;
}