firmware: cs_dsp: Add pre_run callback

The code already has a post_run callback, add a matching pre_run
callback to the client_ops that is called before execution is started.
This callback provides a convenient place for the client code to
set DSP controls or hardware that requires configuration before
the DSP core actually starts execution. Note that placing this callback
before cs_dsp_coeff_sync_controls is important to ensure that any
control values are then correctly synced out to the chip.

Co-authored-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20211117132300.1290-4-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Charles Keepax 2021-11-17 13:22:54 +00:00 committed by Mark Brown
parent 2925748ead
commit 14055b5a3a
No known key found for this signature in database
GPG key ID: 24D68B725D5487D0
2 changed files with 9 additions and 1 deletions

View file

@ -2627,6 +2627,12 @@ int cs_dsp_run(struct cs_dsp *dsp)
goto err; goto err;
} }
if (dsp->client_ops->pre_run) {
ret = dsp->client_ops->pre_run(dsp);
if (ret)
goto err;
}
/* Sync set controls */ /* Sync set controls */
ret = cs_dsp_coeff_sync_controls(dsp); ret = cs_dsp_coeff_sync_controls(dsp);
if (ret != 0) if (ret != 0)

View file

@ -187,7 +187,8 @@ struct cs_dsp {
* struct cs_dsp_client_ops - client callbacks * struct cs_dsp_client_ops - client callbacks
* @control_add: Called under the pwr_lock when a control is created * @control_add: Called under the pwr_lock when a control is created
* @control_remove: Called under the pwr_lock when a control is destroyed * @control_remove: Called under the pwr_lock when a control is destroyed
* @post_run: Called under the pwr_lock by cs_dsp_run() * @pre_run: Called under the pwr_lock by cs_dsp_run() before the core is started
* @post_run: Called under the pwr_lock by cs_dsp_run() after the core is started
* @post_stop: Called under the pwr_lock by cs_dsp_stop() * @post_stop: Called under the pwr_lock by cs_dsp_stop()
* @watchdog_expired: Called when a watchdog expiry is detected * @watchdog_expired: Called when a watchdog expiry is detected
* *
@ -197,6 +198,7 @@ struct cs_dsp {
struct cs_dsp_client_ops { struct cs_dsp_client_ops {
int (*control_add)(struct cs_dsp_coeff_ctl *ctl); int (*control_add)(struct cs_dsp_coeff_ctl *ctl);
void (*control_remove)(struct cs_dsp_coeff_ctl *ctl); void (*control_remove)(struct cs_dsp_coeff_ctl *ctl);
int (*pre_run)(struct cs_dsp *dsp);
int (*post_run)(struct cs_dsp *dsp); int (*post_run)(struct cs_dsp *dsp);
void (*post_stop)(struct cs_dsp *dsp); void (*post_stop)(struct cs_dsp *dsp);
void (*watchdog_expired)(struct cs_dsp *dsp); void (*watchdog_expired)(struct cs_dsp *dsp);