From patchwork Sun Dec 3 20:41:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Khoruzhick X-Patchwork-Id: 10089409 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 5AC5C602C8 for ; Sun, 3 Dec 2017 20:48:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6694828DF7 for ; Sun, 3 Dec 2017 20:48:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50B0A28D9D; Sun, 3 Dec 2017 20:48:41 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CE05E28D9D for ; Sun, 3 Dec 2017 20:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QsiWhFM9sYAcZUB/vRj2b7YY31iNFsCohTOUT1b1/SA=; b=hzUPDw6/vuh3Vq1URYpInn3wpX /adnBueVyzR9Kzn9TTCHfaIbLzQcy1u712XzCA/De8Zuo0sR++YkdJ2USIKXz4wHBywgnX8IDtEDq aTvuXp3juCNakUn2NJ40ypAH7QX1JpVr12fqwXfKr5RM91PdkLGTUnwBkHgGbv3ZToxaKyZgh0Dd8 aeVmoE9ao6YX5PYC3o4WjQGhMVfIpjq4AWDy3hce1+GQlE/czHEOKNCPAYWuj3SRzYQZxlDWPKedU mv25wZ+y/Gl9zIkcWHQEaZ3fZRTYUs9r9IUnTHPM9dRCG7mx94mAGtD4HyKTf0w2DyJ7vBg8CtYs3 3os61p3Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eLbBn-0003Nd-48; Sun, 03 Dec 2017 20:48:39 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLb5k-00070E-BQ for linux-arm-kernel@lists.infradead.org; Sun, 03 Dec 2017 20:42:26 +0000 Received: by mail-pf0-x241.google.com with SMTP id u25so6986749pfg.5 for ; Sun, 03 Dec 2017 12:42:03 -0800 (PST) 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=VeB7Z13eJEg09JZvRovOc/s+VT7VJMEQTogYDfcHf1c=; b=AgF/lOkejT8yadVLAf1nr3FmSG3Ro9r7dhInLNYAWkX8PVlV8aU+yFLWDbGLEOIB16 WUY/Q723ZA/m6uoB77JB25FLiNoSbeYzkqZTWt79jBePi5ybnU/XrhQ7QOjDTTdzrAlv pjfXq2c3n43UCibsFcm4/nwnRJnxBze+3l0nipuoADzjm90Zvh/4hgGYeT1cCaAx37AI jjP8CPF/uCoae3RnCIonYx8RUIIM+BhdXCCiAV20mj0E2E8DD+TNNifZVuZAAm33to1D a3Zejo09ZbnFgevacAIocp2RQJEhBDUpWlkr0Vp3UGwBe/s1tcqvIex89XmnHEKaxGpv Fn+Q== 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=VeB7Z13eJEg09JZvRovOc/s+VT7VJMEQTogYDfcHf1c=; b=psSrDdbtaP49EcWFBmAqZ7tFq+JOJ1lTkSuAqP+cOY62Ou8xdHWsKFK2oZ2a72kHP0 KRkIppy559ja8IsVsNVhRZBppjeDrtBe42zHYJ/+SrjvLtNfaoU+zmTgJfKfJnfiJ5yZ 6kp/iEI+b2qIQf3wg/XYLrL0HoLN6aFR9z1gV3xNGjTOKpO3OTL+D+fjBtg7NwYOo7jK 5XrieJ6MyLiZ6Ay4RmDPh9Q0b9i+TfaLS4J4+/o+MrYb4LGv9OFysvq5/Zn/dA3e9lI7 kDiXwxiKrnW4TMtaNDO7OnBRIVsQ8b3zRzxr5TOsXYZKTTTO8JU/7mst24eh3BsqoBDM CLrw== X-Gm-Message-State: AJaThX6PywmaVkexZz4ZJm0E5FV3i8YRc2+feXK+wq3tfJQ85MweRaiz wg/X8RpCkKJyuAb5s8K+57M= X-Google-Smtp-Source: AGs4zMbvgDsyNqWxb5LqsQUqUI2LaLj91HTGxMBSyHA4d8YXNCE2QMWzXByOzyCsL/0vUjzwTeAvfQ== X-Received: by 10.99.113.1 with SMTP id m1mr11621369pgc.397.1512333722833; Sun, 03 Dec 2017 12:42:02 -0800 (PST) Received: from anarsoul-thinkpad.lan (216-71-193-140.dyn.novuscom.net. [216.71.193.140]) by smtp.gmail.com with ESMTPSA id z25sm19264929pfe.121.2017.12.03.12.42.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Dec 2017 12:42:02 -0800 (PST) From: Vasily Khoruzhick To: Liam Girdwood , Mark Brown , Maxime Ripard , Chen-Yu Tsai , Marcus Cooper , =?UTF-8?q?Myl=C3=A8ne=20Josserand?= , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/9] ASoC: sun4i-i2s: Add quirk to handle fixed WSS Date: Sun, 3 Dec 2017 12:41:49 -0800 Message-Id: <20171203204157.20829-2-anarsoul@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171203204157.20829-1-anarsoul@gmail.com> References: <20171203204157.20829-1-anarsoul@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171203_124224_415783_CA9BF7BF X-CRM114-Status: GOOD ( 12.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasily Khoruzhick MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP I2S for audio codec on sun50i-A64 always uses fixed word select size value, no matter what is sample width. Add quirk to support that. Signed-off-by: Vasily Khoruzhick --- sound/soc/sunxi/sun4i-i2s.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 04f92583a969..54c16eb64713 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -132,6 +132,8 @@ * @mclk_offset: Value by which mclkdiv needs to be adjusted. * @bclk_offset: Value by which bclkdiv needs to be adjusted. * @fmt_offset: Value by which wss and sr needs to be adjusted. + * @fixed_wss: Hardcoded 'word select size' value needs to be used + * @wss_value: Value to be used as WSS if fixed_wss is set * @field_clkdiv_mclk_en: regmap field to enable mclk output. * @field_fmt_wss: regmap field to set word select size. * @field_fmt_sr: regmap field to set sample resolution. @@ -150,11 +152,13 @@ struct sun4i_i2s_quirks { bool has_chcfg; bool has_chsel_tx_chen; bool has_chsel_offset; + bool fixed_wss; unsigned int reg_offset_txdata; /* TX FIFO */ const struct regmap_config *sun4i_i2s_regmap; unsigned int mclk_offset; unsigned int bclk_offset; unsigned int fmt_offset; + unsigned int wss_value; /* Register fields for i2s */ struct reg_field field_clkdiv_mclk_en; @@ -345,7 +349,7 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); - int sr, wss, channels; + int sr, wss, channels, pwidth; u32 width; channels = params_channels(params); @@ -386,7 +390,8 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, } i2s->playback_dma_data.addr_width = width; - switch (params_width(params)) { + pwidth = params_width(params); + switch (pwidth) { case 16: sr = 0; wss = 0; @@ -396,13 +401,30 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } + if (i2s->variant->fixed_wss) { + wss = i2s->variant->wss_value; + switch (wss) { + case 0: + pwidth = 16; + break; + case 1: + pwidth = 20; + break; + case 2: + pwidth = 24; + break; + case 3: + pwidth = 32; + break; + } + } + regmap_field_write(i2s->field_fmt_wss, wss + i2s->variant->fmt_offset); regmap_field_write(i2s->field_fmt_sr, sr + i2s->variant->fmt_offset); - return sun4i_i2s_set_clk_rate(i2s, params_rate(params), - params_width(params)); + return sun4i_i2s_set_clk_rate(i2s, params_rate(params), pwidth); } static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)