From: Simon Trimmer <simont@opensource.cirrus.com>
To: <broonie@kernel.org>, <lgirdwood@gmail.com>
Cc: <alsa-devel@alsa-project.org>, <patches@opensource.cirrus.com>,
<linux-kernel@vger.kernel.org>,
Simon Trimmer <simont@opensource.cirrus.com>,
Charles Keepax <ckeepax@opensource.cirrus.com>
Subject: [PATCH 15/16] ASoC: wm_adsp: Separate wm_adsp specifics in cs_dsp_client_ops
Date: Mon, 13 Sep 2021 17:00:56 +0100 [thread overview]
Message-ID: <20210913160057.103842-16-simont@opensource.cirrus.com> (raw)
In-Reply-To: <20210913160057.103842-1-simont@opensource.cirrus.com>
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>
---
sound/soc/codecs/wm_adsp.c | 48 ++++++++++++++++++++++++++++++--------
sound/soc/codecs/wm_adsp.h | 10 ++++++++
2 files changed, 48 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");
diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h
index 5a70b6679fa3..25aaef74654c 100644
--- a/sound/soc/codecs/wm_adsp.h
+++ b/sound/soc/codecs/wm_adsp.h
@@ -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
--
2.33.0
next prev parent reply other threads:[~2021-09-13 16:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 16:00 [PATCH 00/16] add driver to support firmware loading on Cirrus Logic DSPs Simon Trimmer
2021-09-13 16:00 ` [PATCH 01/16] ASoC: wm_adsp: Remove use of snd_ctl_elem_type_t Simon Trimmer
2021-09-13 16:00 ` [PATCH 02/16] ASoC: wm_adsp: Move check for control existence Simon Trimmer
2021-09-13 16:00 ` [PATCH 03/16] ASoC: wm_adsp: Switch to using wm_coeff_read_ctrl for compressed buffers Simon Trimmer
2021-09-13 16:00 ` [PATCH 04/16] ASoC: wm_adsp: Cancel ongoing work when removing controls Simon Trimmer
2021-09-13 16:00 ` [PATCH 05/16] ASoC: wm_adsp: Rename generic DSP support Simon Trimmer
2021-09-13 16:00 ` [PATCH 06/16] ASoC: wm_adsp: Introduce cs_dsp logging macros Simon Trimmer
2021-09-13 16:00 ` [PATCH 07/16] ASoC: wm_adsp: Separate some ASoC and generic functions Simon Trimmer
2021-09-13 16:00 ` [PATCH 08/16] ASoC: wm_adsp: Split DSP power operations into helper functions Simon Trimmer
2021-09-13 16:00 ` [PATCH 09/16] ASoC: wm_adsp: Move sys_config_size to wm_adsp Simon Trimmer
2021-09-13 16:00 ` [PATCH 10/16] ASoC: wm_adsp: Separate generic cs_dsp_coeff_ctl handling Simon Trimmer
2021-09-13 16:00 ` [PATCH 11/16] ASoC: wm_adsp: Move check of dsp->running to better place Simon Trimmer
2021-09-13 16:00 ` [PATCH 12/16] ASoC: wm_adsp: Pass firmware names as parameters when starting DSP core Simon Trimmer
2021-09-13 16:00 ` [PATCH 13/16] ASoC: wm_adsp: move firmware loading to client Simon Trimmer
2021-09-13 16:00 ` [PATCH 14/16] ASoC: wm_adsp: Split out struct cs_dsp from struct wm_adsp Simon Trimmer
2021-09-13 16:00 ` Simon Trimmer [this message]
2021-09-13 16:00 ` [PATCH 16/16] firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs Simon Trimmer
2021-09-27 17:45 ` [PATCH 00/16] " Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210913160057.103842-16-simont@opensource.cirrus.com \
--to=simont@opensource.cirrus.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).