From patchwork Wed Jul 5 15:43:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Code Kipper X-Patchwork-Id: 9826755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CE22E60317 for ; Wed, 5 Jul 2017 15:44:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC60E28560 for ; Wed, 5 Jul 2017 15:44:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0BFE2856D; Wed, 5 Jul 2017 15:44:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFDCD28560 for ; Wed, 5 Jul 2017 15:44:26 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E5D1B266FEB; Wed, 5 Jul 2017 17:43:37 +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 D6493266EB6; Wed, 5 Jul 2017 17:43:33 +0200 (CEST) Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by alsa0.perex.cz (Postfix) with ESMTP id 04104266EB6 for ; Wed, 5 Jul 2017 17:43:29 +0200 (CEST) Received: by mail-lf0-f66.google.com with SMTP id f28so21294418lfi.3 for ; Wed, 05 Jul 2017 08:43:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TGtjDx8uOIJloWuBvo56+jAyeG4BYKk2SgCcS/tcNIw=; b=NyDqW1wjLEtITt2G8xVFxsdL+AJkne6leD7Q2NMhBQ9jSC+zonIMsx5Qo3yWwUWeKY g8MnveaZRInVZPjZPcXd3d1cXN680qGq4VFhJYNZC3Noq5ipXsHkEFUswWkS6KYupC5W ItznC7Oq08kmFifqU0LQxX5h+nHpsglpQnC2dOpiL9OLR4lv2cbILVPFeWf86WEyCybt huU9odnTEkzbkOOhCSIggCwg3xSj05FpF6GBPijm6TdktMmG5ejNHV3q3c0iWgtwc1WC XzVDBodqNC3bW7HvyZMC0LyZ+nzyix54Xy1o9GZ+VnfewAoBSeMwQ4iPYYmsnvCarOvE tJPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TGtjDx8uOIJloWuBvo56+jAyeG4BYKk2SgCcS/tcNIw=; b=aGZqCSrbnGAWdfXHz0EyEA+z3MaC5NWoy8P9EZ41yxbH8PfG9GyR2S7UJ/Hx4TPuur 5yJHK48yopiK4CkkzSE1Ers1KG/cb8GQ1QJ/07xQu1RXuVWevK6i22wlON7M+1aJwGov Q8qeKhGapHOWkteExu0dfudEWuoXFUd97QNjk8ts+Z5Fe5hbjV4XjR/Kr+hAGghG4mln A9Mw5bnI8BZwpWGs8WfNLwxz3gRyfUIk0O2fGAtSgMRIG7+2TrmWBwMTAWErSyKQTEPL nopmBx9HpXQE/VbpxW6+M/SIiu60LkgKfH/9e8KShTZRAbVJOsuukY8yaFwsGbZaHHto UBMQ== X-Gm-Message-State: AKS2vOwUeGDBvZrd+uiD/sVqWD+Du7TXrXTdGzDbiJdG0S0DqSJ3QzHh dbxyK8oW2RIPXWOr X-Received: by 10.46.82.23 with SMTP id g23mr12345669ljb.32.1499269409278; Wed, 05 Jul 2017 08:43:29 -0700 (PDT) Received: from localhost.localdomain (c80-217-9-219.bredband.comhem.se. [80.217.9.219]) by smtp.gmail.com with ESMTPSA id v1sm4602221lja.18.2017.07.05.08.43.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jul 2017 08:43:28 -0700 (PDT) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com Date: Wed, 5 Jul 2017 17:43:23 +0200 Message-Id: <20170705154324.14565-3-codekipper@gmail.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170705154324.14565-1-codekipper@gmail.com> References: <20170705154324.14565-1-codekipper@gmail.com> Cc: alsa-devel@alsa-project.org, Marcus Cooper , lgirdwood@gmail.com, linux-kernel@vger.kernel.org, be17068@iperbole.bo.it, linux-sunxi@googlegroups.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH 2/3] ASoC: sun4i-i2s: Get startup to call set_fmt 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 X-Virus-Scanned: ClamAV using ClamSMTP From: Marcus Cooper The set_fmt function pointer is called during probing and this is whilst the block is disabled. It is over writing the default register values with the same settings so isn't noticed. This wasn't a problem with the older SoCs but with the desire to reuse as much functionlity as possible for the newer devices then set_fmt needs to be called whilst the block is enabled. Signed-off-by: Marcus Cooper --- sound/soc/sunxi/sun4i-i2s.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 38ab0144f897..bb7affd53002 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -351,6 +351,15 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) SUN4I_I2S_FIFO_CTRL_RX_MODE_MASK, SUN4I_I2S_FIFO_CTRL_TX_MODE(1) | SUN4I_I2S_FIFO_CTRL_RX_MODE(1)); + + /* Enable the first two channels */ + regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_SEL_REG, + SUN4I_I2S_TX_CHAN_SEL(2)); + + /* Map them to the two first samples coming in */ + regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG, + SUN4I_I2S_TX_CHAN_MAP(0, 0) | SUN4I_I2S_TX_CHAN_MAP(1, 1)); + return 0; } @@ -457,6 +466,9 @@ static int sun4i_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct device *dev = rtd->card->dev; + int ret = 0; /* Enable the whole hardware block */ regmap_write(i2s->regmap, SUN4I_I2S_CTRL_REG, @@ -467,13 +479,11 @@ static int sun4i_i2s_startup(struct snd_pcm_substream *substream, SUN4I_I2S_CTRL_SDO_EN_MASK, SUN4I_I2S_CTRL_SDO_EN(0)); - /* Enable the first two channels */ - regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_SEL_REG, - SUN4I_I2S_TX_CHAN_SEL(2)); - - /* Map them to the two first samples coming in */ - regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG, - SUN4I_I2S_TX_CHAN_MAP(0, 0) | SUN4I_I2S_TX_CHAN_MAP(1, 1)); + ret = snd_soc_dai_set_fmt(rtd->cpu_dai, rtd->dai_link->dai_fmt); + if (ret < 0) { + dev_err(dev, "can't set cpu_dai set fmt: %d\n", ret); + return ret; + } return clk_prepare_enable(i2s->mod_clk); }