From patchwork Mon Sep 13 16:00:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Trimmer X-Patchwork-Id: 509858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78F9FC433EF for ; Mon, 13 Sep 2021 16:06:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F423A604D1 for ; Mon, 13 Sep 2021 16:06:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F423A604D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8C83F174A; Mon, 13 Sep 2021 18:05:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8C83F174A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631549194; bh=V+Npz1uCx2tlCjKR+HAPvsBkWcaLWFpbE2/ACpOW2qA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=deDZ2hy9nZXV76FGTHlqmjk+54ihkgPRab1nnWHIzGarPj0+fsdKmNazK2Kn+w8RV oycxHyYp86vL63tj8ByaLh3Ga4UCgZ0pmm6W3wyC7yUiSS9xaWj10Pz/uUnB47zJff 2HQdiSAkebec7L/k8wgxT6HSOSr2+QbGWLjsKjEc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 235F8F8053A; Mon, 13 Sep 2021 18:02:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 097F8F804EB; Mon, 13 Sep 2021 18:01:57 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 25002F804E7 for ; Mon, 13 Sep 2021 18:01:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 25002F804E7 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="mdOEbmYz" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18DFp9LG002377; Mon, 13 Sep 2021 11:01:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=OBZHpz2FkLV0JvQS3xJVOcECRKMDHTFlFOYDPsWZUU4=; b=mdOEbmYzyfkP3Fd8ksKCixyl5K5XnlLIjSVUNxH5t8Yto/mJXsBKJA3KWJbVHjL7lJar YBO2RRJSrUoDN/HRPNPw/DpiiLbLKSAw9c22LBl1YTKyx+viHYCdKRQ2R2WOwG7OjNm1 Mncjf0l7C5lcb9gJ3ETbDUVIjP7uF7iqekR68UOBaPB8dVlECJpfPtNhvyJBshE5yu8n EtEHyNhK0pfaQ398LcOycNoUSm1FfV2XBCNcX6+njWhP73stsEByfBsqQFWiaXEtZ0ZA +z5nE1gfKKSXmIAscHjGhNM9/PeBTn7EUp1rwtbBE/7VcAKbFvA8BL/Kxy3kPhkjbopN 3g== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 3b29n3r0ag-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 13 Sep 2021 11:01:30 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Mon, 13 Sep 2021 17:01:22 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.12 via Frontend Transport; Mon, 13 Sep 2021 17:01:22 +0100 Received: from simont-vb.lan?044ad.cirrus.com (unknown [198.90.238.152]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 6EE752A9; Mon, 13 Sep 2021 16:01:22 +0000 (UTC) From: Simon Trimmer To: , 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 Message-ID: <20210913160057.103842-16-simont@opensource.cirrus.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913160057.103842-1-simont@opensource.cirrus.com> References: <20210913160057.103842-1-simont@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: rdan-NIuf_rbuZIU9WuBmeKmoo2emyZS X-Proofpoint-ORIG-GUID: rdan-NIuf_rbuZIU9WuBmeKmoo2emyZS X-Proofpoint-Spam-Reason: safe Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org, Simon Trimmer , linux-kernel@vger.kernel.org, Charles Keepax X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 Signed-off-by: Charles Keepax --- 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