Commit 2dd04464 authored by Simon Trimmer's avatar Simon Trimmer Committed by Mark Brown

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: default avatarSimon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210913160057.103842-16-simont@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e1468202
...@@ -318,6 +318,9 @@ static const struct cs_dsp_ops cs_dsp_adsp1_ops; ...@@ -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_adsp2_ops[];
static const struct cs_dsp_ops cs_dsp_halo_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 cs_dsp_buf {
struct list_head list; struct list_head list;
void *buf; void *buf;
...@@ -1548,9 +1551,11 @@ static int cs_dsp_create_control(struct cs_dsp *dsp, ...@@ -1548,9 +1551,11 @@ static int cs_dsp_create_control(struct cs_dsp *dsp,
list_add(&ctl->list, &dsp->ctl_list); list_add(&ctl->list, &dsp->ctl_list);
ret = wm_adsp_control_add(ctl); if (dsp->client_ops->control_add) {
if (ret) ret = dsp->client_ops->control_add(ctl);
goto err_list_del; if (ret)
goto err_list_del;
}
return 0; return 0;
...@@ -2865,6 +2870,8 @@ int wm_adsp1_init(struct wm_adsp *dsp) ...@@ -2865,6 +2870,8 @@ int wm_adsp1_init(struct wm_adsp *dsp)
{ {
int ret; int ret;
dsp->cs_dsp.client_ops = &wm_adsp1_client_ops;
ret = cs_dsp_adsp1_init(&dsp->cs_dsp); ret = cs_dsp_adsp1_init(&dsp->cs_dsp);
if (ret) if (ret)
return ret; return ret;
...@@ -3436,9 +3443,11 @@ static int cs_dsp_run(struct cs_dsp *dsp) ...@@ -3436,9 +3443,11 @@ static int cs_dsp_run(struct cs_dsp *dsp)
dsp->running = true; dsp->running = true;
ret = wm_adsp_event_post_run(dsp); if (dsp->client_ops->post_run) {
if (ret < 0) ret = dsp->client_ops->post_run(dsp);
goto err; if (ret)
goto err;
}
mutex_unlock(&dsp->pwr_lock); mutex_unlock(&dsp->pwr_lock);
...@@ -3475,7 +3484,8 @@ static void cs_dsp_stop(struct cs_dsp *dsp) ...@@ -3475,7 +3484,8 @@ static void cs_dsp_stop(struct cs_dsp *dsp)
if (dsp->ops->disable_core) if (dsp->ops->disable_core)
dsp->ops->disable_core(dsp); 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); mutex_unlock(&dsp->pwr_lock);
...@@ -3585,6 +3595,7 @@ int wm_adsp2_init(struct wm_adsp *dsp) ...@@ -3585,6 +3595,7 @@ int wm_adsp2_init(struct wm_adsp *dsp)
INIT_WORK(&dsp->boot_work, wm_adsp_boot_work); INIT_WORK(&dsp->boot_work, wm_adsp_boot_work);
dsp->sys_config_size = sizeof(struct wm_adsp_system_config_xm_hdr); 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); ret = cs_dsp_adsp2_init(&dsp->cs_dsp);
if (ret) if (ret)
...@@ -3608,6 +3619,7 @@ int wm_halo_init(struct wm_adsp *dsp) ...@@ -3608,6 +3619,7 @@ int wm_halo_init(struct wm_adsp *dsp)
INIT_WORK(&dsp->boot_work, wm_adsp_boot_work); INIT_WORK(&dsp->boot_work, wm_adsp_boot_work);
dsp->sys_config_size = sizeof(struct wm_halo_system_config_xm_hdr); 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); ret = cs_dsp_halo_init(&dsp->cs_dsp);
if (ret) if (ret)
...@@ -3624,7 +3636,8 @@ static void cs_dsp_remove(struct cs_dsp *dsp) ...@@ -3624,7 +3636,8 @@ static void cs_dsp_remove(struct cs_dsp *dsp)
while (!list_empty(&dsp->ctl_list)) { while (!list_empty(&dsp->ctl_list)) {
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_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); list_del(&ctl->list);
cs_dsp_free_ctl_blk(ctl); cs_dsp_free_ctl_blk(ctl);
...@@ -4573,7 +4586,8 @@ static void cs_dsp_adsp2_bus_error(struct cs_dsp *dsp) ...@@ -4573,7 +4586,8 @@ static void cs_dsp_adsp2_bus_error(struct cs_dsp *dsp)
if (val & ADSP2_WDT_TIMEOUT_STS_MASK) { if (val & ADSP2_WDT_TIMEOUT_STS_MASK) {
cs_dsp_err(dsp, "watchdog timeout error\n"); cs_dsp_err(dsp, "watchdog timeout error\n");
dsp->ops->stop_watchdog(dsp); 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)) { 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) ...@@ -4697,7 +4711,8 @@ static void cs_dsp_halo_wdt_expire(struct cs_dsp *dsp)
cs_dsp_warn(dsp, "WDT Expiry Fault\n"); cs_dsp_warn(dsp, "WDT Expiry Fault\n");
dsp->ops->stop_watchdog(dsp); 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); mutex_unlock(&dsp->pwr_lock);
} }
...@@ -4718,6 +4733,11 @@ static const struct cs_dsp_ops cs_dsp_adsp1_ops = { ...@@ -4718,6 +4733,11 @@ static const struct cs_dsp_ops cs_dsp_adsp1_ops = {
.region_to_reg = cs_dsp_region_to_reg, .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[] = { static const struct cs_dsp_ops cs_dsp_adsp2_ops[] = {
{ {
.parse_sizes = cs_dsp_adsp2_parse_sizes, .parse_sizes = cs_dsp_adsp2_parse_sizes,
...@@ -4791,4 +4811,12 @@ static const struct cs_dsp_ops cs_dsp_halo_ops = { ...@@ -4791,4 +4811,12 @@ static const struct cs_dsp_ops cs_dsp_halo_ops = {
.stop_core = cs_dsp_halo_stop_core, .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"); MODULE_LICENSE("GPL v2");
...@@ -52,6 +52,7 @@ struct cs_dsp_alg_region { ...@@ -52,6 +52,7 @@ struct cs_dsp_alg_region {
struct wm_adsp_compr; struct wm_adsp_compr;
struct wm_adsp_compr_buf; struct wm_adsp_compr_buf;
struct cs_dsp_ops; struct cs_dsp_ops;
struct cs_dsp_client_ops;
struct cs_dsp_coeff_ctl { struct cs_dsp_coeff_ctl {
const char *fw_name; const char *fw_name;
...@@ -81,6 +82,7 @@ struct cs_dsp { ...@@ -81,6 +82,7 @@ struct cs_dsp {
struct regmap *regmap; struct regmap *regmap;
const struct cs_dsp_ops *ops; const struct cs_dsp_ops *ops;
const struct cs_dsp_client_ops *client_ops;
unsigned int base; unsigned int base;
unsigned int base_sysinfo; unsigned int base_sysinfo;
...@@ -237,4 +239,12 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type, ...@@ -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, int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type,
unsigned int alg, void *buf, size_t len); 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 #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment