ASoC: wm_adsp: Separate wm_adsp specifics in cs_dsp_client_ops
This is preparation for moving the generic DSP support out of ASoC. The event callbacks let the client add custom handling of events. Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20210913160057.103842-16-simont@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
e146820215
commit
2dd044641e
@ -318,6 +318,9 @@ static const struct cs_dsp_ops cs_dsp_adsp1_ops;
|
||||
static const struct cs_dsp_ops cs_dsp_adsp2_ops[];
|
||||
static const struct cs_dsp_ops cs_dsp_halo_ops;
|
||||
|
||||
static const struct cs_dsp_client_ops wm_adsp1_client_ops;
|
||||
static const struct cs_dsp_client_ops wm_adsp2_client_ops;
|
||||
|
||||
struct cs_dsp_buf {
|
||||
struct list_head list;
|
||||
void *buf;
|
||||
@ -1548,9 +1551,11 @@ static int cs_dsp_create_control(struct cs_dsp *dsp,
|
||||
|
||||
list_add(&ctl->list, &dsp->ctl_list);
|
||||
|
||||
ret = wm_adsp_control_add(ctl);
|
||||
if (ret)
|
||||
goto err_list_del;
|
||||
if (dsp->client_ops->control_add) {
|
||||
ret = dsp->client_ops->control_add(ctl);
|
||||
if (ret)
|
||||
goto err_list_del;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -2865,6 +2870,8 @@ int wm_adsp1_init(struct wm_adsp *dsp)
|
||||
{
|
||||
int ret;
|
||||
|
||||
dsp->cs_dsp.client_ops = &wm_adsp1_client_ops;
|
||||
|
||||
ret = cs_dsp_adsp1_init(&dsp->cs_dsp);
|
||||
if (ret)
|
||||
return ret;
|
||||
@ -3436,9 +3443,11 @@ static int cs_dsp_run(struct cs_dsp *dsp)
|
||||
|
||||
dsp->running = true;
|
||||
|
||||
ret = wm_adsp_event_post_run(dsp);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
if (dsp->client_ops->post_run) {
|
||||
ret = dsp->client_ops->post_run(dsp);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
mutex_unlock(&dsp->pwr_lock);
|
||||
|
||||
@ -3475,7 +3484,8 @@ static void cs_dsp_stop(struct cs_dsp *dsp)
|
||||
if (dsp->ops->disable_core)
|
||||
dsp->ops->disable_core(dsp);
|
||||
|
||||
wm_adsp_event_post_stop(dsp);
|
||||
if (dsp->client_ops->post_stop)
|
||||
dsp->client_ops->post_stop(dsp);
|
||||
|
||||
mutex_unlock(&dsp->pwr_lock);
|
||||
|
||||
@ -3585,6 +3595,7 @@ int wm_adsp2_init(struct wm_adsp *dsp)
|
||||
INIT_WORK(&dsp->boot_work, wm_adsp_boot_work);
|
||||
|
||||
dsp->sys_config_size = sizeof(struct wm_adsp_system_config_xm_hdr);
|
||||
dsp->cs_dsp.client_ops = &wm_adsp2_client_ops;
|
||||
|
||||
ret = cs_dsp_adsp2_init(&dsp->cs_dsp);
|
||||
if (ret)
|
||||
@ -3608,6 +3619,7 @@ int wm_halo_init(struct wm_adsp *dsp)
|
||||
INIT_WORK(&dsp->boot_work, wm_adsp_boot_work);
|
||||
|
||||
dsp->sys_config_size = sizeof(struct wm_halo_system_config_xm_hdr);
|
||||
dsp->cs_dsp.client_ops = &wm_adsp2_client_ops;
|
||||
|
||||
ret = cs_dsp_halo_init(&dsp->cs_dsp);
|
||||
if (ret)
|
||||
@ -3624,7 +3636,8 @@ static void cs_dsp_remove(struct cs_dsp *dsp)
|
||||
while (!list_empty(&dsp->ctl_list)) {
|
||||
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
|
||||
|
||||
wm_adsp_control_remove(ctl);
|
||||
if (dsp->client_ops->control_remove)
|
||||
dsp->client_ops->control_remove(ctl);
|
||||
|
||||
list_del(&ctl->list);
|
||||
cs_dsp_free_ctl_blk(ctl);
|
||||
@ -4573,7 +4586,8 @@ static void cs_dsp_adsp2_bus_error(struct cs_dsp *dsp)
|
||||
if (val & ADSP2_WDT_TIMEOUT_STS_MASK) {
|
||||
cs_dsp_err(dsp, "watchdog timeout error\n");
|
||||
dsp->ops->stop_watchdog(dsp);
|
||||
wm_adsp_fatal_error(dsp);
|
||||
if (dsp->client_ops->watchdog_expired)
|
||||
dsp->client_ops->watchdog_expired(dsp);
|
||||
}
|
||||
|
||||
if (val & (ADSP2_ADDR_ERR_MASK | ADSP2_REGION_LOCK_ERR_MASK)) {
|
||||
@ -4697,7 +4711,8 @@ static void cs_dsp_halo_wdt_expire(struct cs_dsp *dsp)
|
||||
cs_dsp_warn(dsp, "WDT Expiry Fault\n");
|
||||
|
||||
dsp->ops->stop_watchdog(dsp);
|
||||
wm_adsp_fatal_error(dsp);
|
||||
if (dsp->client_ops->watchdog_expired)
|
||||
dsp->client_ops->watchdog_expired(dsp);
|
||||
|
||||
mutex_unlock(&dsp->pwr_lock);
|
||||
}
|
||||
@ -4718,6 +4733,11 @@ static const struct cs_dsp_ops cs_dsp_adsp1_ops = {
|
||||
.region_to_reg = cs_dsp_region_to_reg,
|
||||
};
|
||||
|
||||
static const struct cs_dsp_client_ops wm_adsp1_client_ops = {
|
||||
.control_add = wm_adsp_control_add,
|
||||
.control_remove = wm_adsp_control_remove,
|
||||
};
|
||||
|
||||
static const struct cs_dsp_ops cs_dsp_adsp2_ops[] = {
|
||||
{
|
||||
.parse_sizes = cs_dsp_adsp2_parse_sizes,
|
||||
@ -4791,4 +4811,12 @@ static const struct cs_dsp_ops cs_dsp_halo_ops = {
|
||||
.stop_core = cs_dsp_halo_stop_core,
|
||||
};
|
||||
|
||||
static const struct cs_dsp_client_ops wm_adsp2_client_ops = {
|
||||
.control_add = wm_adsp_control_add,
|
||||
.control_remove = wm_adsp_control_remove,
|
||||
.post_run = wm_adsp_event_post_run,
|
||||
.post_stop = wm_adsp_event_post_stop,
|
||||
.watchdog_expired = wm_adsp_fatal_error,
|
||||
};
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
@ -52,6 +52,7 @@ struct cs_dsp_alg_region {
|
||||
struct wm_adsp_compr;
|
||||
struct wm_adsp_compr_buf;
|
||||
struct cs_dsp_ops;
|
||||
struct cs_dsp_client_ops;
|
||||
|
||||
struct cs_dsp_coeff_ctl {
|
||||
const char *fw_name;
|
||||
@ -81,6 +82,7 @@ struct cs_dsp {
|
||||
struct regmap *regmap;
|
||||
|
||||
const struct cs_dsp_ops *ops;
|
||||
const struct cs_dsp_client_ops *client_ops;
|
||||
|
||||
unsigned int base;
|
||||
unsigned int base_sysinfo;
|
||||
@ -237,4 +239,12 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type,
|
||||
int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type,
|
||||
unsigned int alg, void *buf, size_t len);
|
||||
|
||||
struct cs_dsp_client_ops {
|
||||
int (*control_add)(struct cs_dsp_coeff_ctl *ctl);
|
||||
void (*control_remove)(struct cs_dsp_coeff_ctl *ctl);
|
||||
int (*post_run)(struct cs_dsp *dsp);
|
||||
void (*post_stop)(struct cs_dsp *dsp);
|
||||
void (*watchdog_expired)(struct cs_dsp *dsp);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user