summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/wm_adsp.c
diff options
context:
space:
mode:
authorSimon Trimmer <simont@opensource.cirrus.com>2021-09-13 17:00:56 +0100
committerMark Brown <broonie@kernel.org>2021-09-27 13:00:41 +0100
commit2dd044641ec3672433b9fe3ec47b236621757aa8 (patch)
tree6020339d9bbd11ef638824da3733cbd083762092 /sound/soc/codecs/wm_adsp.c
parente146820215910d889ab16d6c2484fd51a6bb8f1f (diff)
downloadlwn-2dd044641ec3672433b9fe3ec47b236621757aa8.tar.gz
lwn-2dd044641ec3672433b9fe3ec47b236621757aa8.zip
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>
Diffstat (limited to 'sound/soc/codecs/wm_adsp.c')
-rw-r--r--sound/soc/codecs/wm_adsp.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 092df446ff2f..6c5d55b3b311 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -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");