From patchwork Tue May 22 10:59:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 136532 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1460588lji; Tue, 22 May 2018 03:59:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrFDJQ8+VbxO1qKY2KTEvr9Ncrp8+aJF0g7EDACnBg6aFxjaJ6zaqerxFaVE/hjLWc6YhQL X-Received: by 2002:adf:8212:: with SMTP id 18-v6mr17926084wrb.144.1526986773723; Tue, 22 May 2018 03:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526986773; cv=none; d=google.com; s=arc-20160816; b=GLRMFDp6BA/wIxHTQuRbNJowq/BX/juwmlSYFAHccEBYmdFZzylAQLeTn6e7fG+Bzv 3w3kfBpgj/Nv+Jkf/KFrbJcSY9THwR7c69wOoI3B3RxQyed/kwCHTNfpjTOVYPGfIsmV jIviqZjMzh39NrkGZ0Qx1MxYDDSS+6nyntVzilerZVBaS4j30rT2l9ysBLErvi3ma014 BB86y7cUNa78cMIolgmjTlPyc7HOhMeuutrgr4J4QZi0TW3i7IKIBJKWlg9wRme9iP4W lS3Q9iSDQvO4fzkGjbwGP6/YbQFic92WGHafOjlv8sbfiiXM11lNLrhVkHjPt0FZCfw2 AZOA== 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=T0bVo+OLQWnY/5IdnNA0eUHAFWE8CR5xBMuYdWOsOEo=; b=eYTJl7T2J+OQhf5IsJUZm0fio225Nw1qT68BWlN/AXjYOqS9qSX/4mko0EY4MLdqwp 5HSinxjRyC4GrSoA7Bfu17DS2ZJs7iXq1hCUBm0F0dNB5OEFt3TCx+n7+85ynXoh8Avb 2AWiFnNRiTOHlh2E0IquJYERniqs7+J4L35UBdBbiSQ2Jb50Emgc9RkqW59soUjrephy ywXLydxUvayDexSZfApvzW5BAwwbtNgkAhUow98dbN+7X9iPYPhyBVDMQ1XUqSy+3th+ 77Fl2ghc9duvrvts76QyNBszihwTFobcSbCPJnsUlL7ZyWBrgJlT8x9vPn1Jr3RPveMZ OfhA== 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=cXtBABPk; 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 b36-v6si13602498wra.300.2018.05.22.03.59.33; Tue, 22 May 2018 03:59:33 -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=cXtBABPk; 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 75E01267660; Tue, 22 May 2018 12:59:32 +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 9B7F6267668; Tue, 22 May 2018 12:59:30 +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 A523026765F for ; Tue, 22 May 2018 12:59:28 +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=s0N3Jbzz/WE5F7ZpsEJKUpSV+4n1M4bYuFhuiDXDN5o=; b=cXtBABPko0PL OXv4aHImpOVJGRbuGUAYlyHLBFhRVnCD7PmYlJMi7hiHHhN6KftKsMuOYCRgVVp4Lt2VbJsu1q8bO OSN1T1fr+MklsHaA6j5KNGgdjRkkv8M3h1qcw9rHKDY2oy8SSsDeIW/gLT4h86m42KcWqMCvL8NYh IFKCI=; 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 1fL50n-0001xZ-TI; Tue, 22 May 2018 10:59:25 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fL50n-0000Ui-GH; Tue, 22 May 2018 11:59:25 +0100 From: Mark Brown To: Daniel Mack In-Reply-To: <20180521215017.29095-1-daniel@zonque.org> Message-Id: Date: Tue, 22 May 2018 11:59:25 +0100 Cc: alsa-devel@alsa-project.org, broonie@kernel.org, robert.jarzmik@free.fr, lars@metafoo.de, haojian.zhuang@gmail.com Subject: [alsa-devel] Applied "ASoC: pxa-ssp: allow more flexible setup order" 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: pxa-ssp: allow more flexible setup order 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 737e370a57e4e83ead04166e89a8b53eee9734b0 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 21 May 2018 23:50:16 +0200 Subject: [PATCH] ASoC: pxa-ssp: allow more flexible setup order The pxa-ssp driver currently assumes that .set_fmt() is called before .set_clkdiv(), .set_pll() etc. Commit a8bd0ee558714 ("ASoC: raumfeld: Use static DAI format setup") broke support for Raumfeld hardware (and possible other PXA based ones) because it effectively changed the order of these calls. Also, as the call to .set_fmt() is now done at probe time, the port clock is not yet enabled. To fix this, strip all hardware register access code from the .set_fmt() callback and memorize the desired value, so we can use it from the .hw_params() callback. Also make the .set_fmt() callback less destructive by reading all registers that it writes to in the beginning and only masking out the bits that it possibly fiddles with. Signed-off-by: Daniel Mack Signed-off-by: Mark Brown --- sound/soc/pxa/pxa-ssp.c | 82 +++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 20 deletions(-) -- 2.17.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 0291c7cb64eb..ffddcf117eb8 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -43,7 +43,8 @@ struct ssp_priv { struct ssp_device *ssp; unsigned int sysclk; - int dai_fmt; + unsigned int dai_fmt; + unsigned int configured_dai_fmt; #ifdef CONFIG_PM uint32_t cr0; uint32_t cr1; @@ -433,36 +434,72 @@ static int pxa_ssp_set_dai_tristate(struct snd_soc_dai *cpu_dai, return 0; } +static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, + unsigned int fmt) +{ + struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + case SND_SOC_DAIFMT_CBM_CFS: + case SND_SOC_DAIFMT_CBS_CFS: + break; + default: + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_NF: + case SND_SOC_DAIFMT_NB_IF: + case SND_SOC_DAIFMT_IB_IF: + case SND_SOC_DAIFMT_IB_NF: + break; + default: + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + case SND_SOC_DAIFMT_DSP_A: + case SND_SOC_DAIFMT_DSP_B: + break; + + default: + return -EINVAL; + } + + /* Settings will be applied in hw_params() */ + priv->dai_fmt = fmt; + + return 0; +} + /* * Set up the SSP DAI format. * The SSP Port must be inactive before calling this function as the * physical interface format is changed. */ -static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, - unsigned int fmt) +static int pxa_ssp_configure_dai_fmt(struct ssp_priv *priv) { - struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; u32 sscr0, sscr1, sspsp, scfr; /* check if we need to change anything at all */ - if (priv->dai_fmt == fmt) + if (priv->configured_dai_fmt == priv->dai_fmt) return 0; - /* we can only change the settings if the port is not in use */ - if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) { - dev_err(&ssp->pdev->dev, - "can't change hardware dai format: stream is in use"); - return -EINVAL; - } - /* reset port settings */ sscr0 = pxa_ssp_read_reg(ssp, SSCR0) & - ~(SSCR0_ECS | SSCR0_NCS | SSCR0_MOD | SSCR0_ACS); - sscr1 = SSCR1_RxTresh(8) | SSCR1_TxTresh(7); - sspsp = 0; + ~(SSCR0_PSP | SSCR0_MOD); + sscr1 = pxa_ssp_read_reg(ssp, SSCR1) & + ~(SSCR1_SCLKDIR | SSCR1_SFRMDIR | SSCR1_SCFR | + SSCR1_RWOT | SSCR1_TRAIL | SSCR1_TFT | SSCR1_RFT); + sspsp = pxa_ssp_read_reg(ssp, SSPSP) & + ~(SSPSP_SFRMP | SSPSP_SCMODE(3)); - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + sscr1 |= SSCR1_RxTresh(8) | SSCR1_TxTresh(7); + + switch (priv->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: sscr1 |= SSCR1_SCLKDIR | SSCR1_SFRMDIR | SSCR1_SCFR; break; @@ -475,7 +512,7 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, return -EINVAL; } - switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + switch (priv->dai_fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF: sspsp |= SSPSP_SFRMP; break; @@ -491,7 +528,7 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, return -EINVAL; } - switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + switch (priv->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: sscr0 |= SSCR0_PSP; sscr1 |= SSCR1_RWOT | SSCR1_TRAIL; @@ -513,7 +550,7 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, pxa_ssp_write_reg(ssp, SSCR1, sscr1); pxa_ssp_write_reg(ssp, SSPSP, sspsp); - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + switch (priv->dai_fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFS: scfr = pxa_ssp_read_reg(ssp, SSCR1) | SSCR1_SCFR; @@ -530,7 +567,7 @@ static int pxa_ssp_set_dai_fmt(struct snd_soc_dai *cpu_dai, * we have to defer some things until hw_params() where we * know parameters like the sample size. */ - priv->dai_fmt = fmt; + priv->configured_dai_fmt = priv->dai_fmt; return 0; } @@ -551,6 +588,7 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream, int width = snd_pcm_format_physical_width(params_format(params)); int ttsa = pxa_ssp_read_reg(ssp, SSTSA) & 0xf; struct snd_dmaengine_dai_dma_data *dma_data; + int ret; dma_data = snd_soc_dai_get_dma_data(cpu_dai, substream); @@ -566,6 +604,10 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream, if (pxa_ssp_read_reg(ssp, SSCR0) & SSCR0_SSE) return 0; + ret = pxa_ssp_configure_dai_fmt(priv); + if (ret < 0) + return ret; + /* clear selected SSP bits */ sscr0 = pxa_ssp_read_reg(ssp, SSCR0) & ~(SSCR0_DSS | SSCR0_EDSS);