From patchwork Thu Jul 19 16:57:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 142363 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1961573ljj; Thu, 19 Jul 2018 09:57:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcL1XLLXTQWytJATyS5UBQSLqwoApBVrCneOSpG4iYsPacC4mxA/CDp+RNWZhMHRjHh3lNd X-Received: by 2002:adf:ffc7:: with SMTP id x7-v6mr8342266wrs.137.1532019475718; Thu, 19 Jul 2018 09:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532019475; cv=none; d=google.com; s=arc-20160816; b=jlXxTCVNocmHocqw1QNGAWdFU9sX6cUA7ST05IiPfJKCMLqfySZkFEdr3TUgfPWtsX JupmBll1Syl260IENyWn7FNJLmIHbsqkraX8xVNljDc1cHOQ0tRMmtMwyQ8PD3gphClf iw1SlEvJ9N8o37KzlZfWjcn1Qrg1tGPPKDQhqTR+NnEA6slh+wahQuibG//qFprSSwcN vCRgdep+z24miDOH2/hg3yzCsR/kAW39u1KjARhp5o22GdU8OZHhWCSAiyGr90K1PEFi cjL1Ue5e381xAgtWkeK9CIBdH4V0kWdBzOOJP97haX60IdGN0ee+o0Z2O864jF36eexg QriA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=0wzj8+5OKrJViJaMTBi86Np+TZbL8ccsuJMQupIClng=; b=rQ4W2tUI8aJUpUvovCQp0WGyuBqFPlrYUdayzRa3k2jPtccYI5O6KBBA4fadkSlt/6 Ei+1UmDwYwxE3Z3uu81Hbtd9wMp2t97SiYvTR11useRtD7LoWbkDWYWwh0Q+D0+gOWVb WPnJ8JaW+kUtFxbYJ14fruHh9OES9QDDK8CczPNOetXutC6+8iTbLQcaVyq8XXJLRXzE QZeUQ7mKA1DR/nKqCAlJy3E2oW1i9XAfZ8YaH/vzqOQ7+5PEx5XODw0LseqHKZLQ+Sek XgtOwI0dNyqgnd5f5Vb1tlq6dJYiDIwWz8uJUeugEkcmey0AuPTAgPwlOjpvpV45BF/e fHZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=uZl4MafD; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id x8-v6si5085457wrt.296.2018.07.19.09.57.55; Thu, 19 Jul 2018 09:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=uZl4MafD; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id DC6F0267791; Thu, 19 Jul 2018 18:57:23 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4D71E267777; Thu, 19 Jul 2018 18:57:20 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id 8877F26776A for ; Thu, 19 Jul 2018 18:57:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=Szkh65SvPQ64T23emw6eV0FzYQWHa9/LrUPgV4c0ahE=; b=uZl4MafD67Rz mS7my4Dc5cswp1wlPRZsXPw0VSZrLh378vXa+lWOXzbJeTxn2AOMc33SCqLji3RwluLj5DpVEACrX BMNzn4w/+p2jfEBw1gdXGtbKBITlyEil2SaleZhUQ4FmidQ19PqeiMTuZ9FyLY2xOO4psEQPOg2+m JcYfY=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fgCEt-0007JK-9t; Thu, 19 Jul 2018 16:57:15 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fgCEs-0005Tv-S2; Thu, 19 Jul 2018 17:57:14 +0100 From: Mark Brown To: Richard Fitzgerald In-Reply-To: <20180719105039.28312-5-ckeepax@opensource.cirrus.com> Message-Id: Date: Thu, 19 Jul 2018 17:57:14 +0100 Cc: alsa-devel@alsa-project.org, Charles Keepax , patches@opensource.cirrus.com, lgirdwood@gmail.com, stuarth@opensource.cirrus.com, rf@opensource.cirrus.com, broonie@kernel.org Subject: [alsa-devel] Applied "ASoC: wm_adsp: Parse HOST_BUFFER controls" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: wm_adsp: Parse HOST_BUFFER controls has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From d52ed4b0bc73c1c7816f5b7a36229a95acfc76c8 Mon Sep 17 00:00:00 2001 From: Richard Fitzgerald Date: Thu, 19 Jul 2018 11:50:39 +0100 Subject: [PATCH] ASoC: wm_adsp: Parse HOST_BUFFER controls Currently the compressed streams in DSP firmwares are identified essentially by looking at a fixed location inside the firmware. This is fragile and also limits things to a single compressed stream. Here a new form of firmware parameter is added, the HOST_BUFFER which identifies a compressed stream from meta-data in the firmware file. This is more robust and allows for the possiblity of using multiple streams per core in the future. Currently the implementation is still limited to a single stream and will use the first HOST_BUFFER parameter encountered. If there aren't any HOST_BUFFER parameters it will fall back to the legacy way of finding the host buffer. Signed-off-by: Richard Fitzgerald Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm_adsp.c | 66 +++++++++++++++++++++++++++++++++++++- sound/soc/codecs/wmfw.h | 1 + 2 files changed, 66 insertions(+), 1 deletion(-) -- 2.18.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index aeb1b8c27670..e39b0e0b04df 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -1607,6 +1607,15 @@ static int wm_adsp_parse_coeff(struct wm_adsp *dsp, if (ret) return -EINVAL; break; + case WMFW_CTL_TYPE_HOST_BUFFER: + ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, + WMFW_CTL_FLAG_SYS | + WMFW_CTL_FLAG_VOLATILE | + WMFW_CTL_FLAG_READABLE, + 0); + if (ret) + return -EINVAL; + break; default: adsp_err(dsp, "Unknown control type: %d\n", coeff_blk.ctl_type); @@ -3200,7 +3209,7 @@ static inline int wm_adsp_buffer_write(struct wm_adsp_compr_buf *buf, buf->host_buf_ptr + field_offset, data); } -static int wm_adsp_buffer_locate(struct wm_adsp_compr_buf *buf) +static int wm_adsp_legacy_host_buf_addr(struct wm_adsp_compr_buf *buf) { struct wm_adsp_alg_region *alg_region; struct wm_adsp *dsp = buf->dsp; @@ -3239,6 +3248,61 @@ static int wm_adsp_buffer_locate(struct wm_adsp_compr_buf *buf) return 0; } +static struct wm_coeff_ctl * +wm_adsp_find_host_buffer_ctrl(struct wm_adsp_compr_buf *buf) +{ + struct wm_adsp *dsp = buf->dsp; + struct wm_coeff_ctl *ctl; + + list_for_each_entry(ctl, &dsp->ctl_list, list) { + if (ctl->type != WMFW_CTL_TYPE_HOST_BUFFER) + continue; + + if (!ctl->enabled) + continue; + + return ctl; + } + + return NULL; +} + +static int wm_adsp_buffer_locate(struct wm_adsp_compr_buf *buf) +{ + struct wm_adsp *dsp = buf->dsp; + struct wm_coeff_ctl *ctl; + unsigned int reg; + u32 val; + int i, ret; + + ctl = wm_adsp_find_host_buffer_ctrl(buf); + if (!ctl) + return wm_adsp_legacy_host_buf_addr(buf); + + ret = wm_coeff_base_reg(ctl, ®); + if (ret) + return ret; + + for (i = 0; i < 5; ++i) { + ret = regmap_raw_read(dsp->regmap, reg, &val, sizeof(val)); + if (ret < 0) + return ret; + + if (val) + break; + + usleep_range(1000, 2000); + } + + if (!val) + return -EIO; + + buf->host_buf_ptr = be32_to_cpu(val); + adsp_dbg(dsp, "host_buf_ptr=%x\n", buf->host_buf_ptr); + + return 0; +} + static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf) { const struct wm_adsp_fw_caps *caps = wm_adsp_fw[buf->dsp->fw].caps; diff --git a/sound/soc/codecs/wmfw.h b/sound/soc/codecs/wmfw.h index ec78b9da020f..0c3f50acb8b1 100644 --- a/sound/soc/codecs/wmfw.h +++ b/sound/soc/codecs/wmfw.h @@ -29,6 +29,7 @@ /* Non-ALSA coefficient types start at 0x1000 */ #define WMFW_CTL_TYPE_ACKED 0x1000 /* acked control */ #define WMFW_CTL_TYPE_HOSTEVENT 0x1001 /* event control */ +#define WMFW_CTL_TYPE_HOST_BUFFER 0x1002 /* host buffer pointer */ struct wmfw_header { char magic[4];