From patchwork Wed Jan 24 14:10:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Code Kipper X-Patchwork-Id: 10182635 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 6E669602B7 for ; Wed, 24 Jan 2018 14:21:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6087A28732 for ; Wed, 24 Jan 2018 14:21:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 555D2288E6; Wed, 24 Jan 2018 14:21:59 +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 B504328732 for ; Wed, 24 Jan 2018 14:21:58 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B430B26750E; Wed, 24 Jan 2018 15:11:11 +0100 (CET) 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 9F794267505; Wed, 24 Jan 2018 15:11:08 +0100 (CET) Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by alsa0.perex.cz (Postfix) with ESMTP id 6F7BE2671F2 for ; Wed, 24 Jan 2018 15:11:05 +0100 (CET) Received: by mail-lf0-f65.google.com with SMTP id t79so5429349lfe.3 for ; Wed, 24 Jan 2018 06:11:05 -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=Z4mbiv/WjUogfRi1khRBXb/8Vp5w+eaGW1TtX+JuIcA=; b=oQrgxBBv65ey9wqeRzjgzr99U/tv4iqnlWFFe9Mz5RhQKcMU80mdBhiZgaOMtRQgYz LOYIJ2P0FXtDY2tRNE3WswE3S7n50WlGikwTTcOh679fSCqSrhdfrxlB1uBI0sOWvnd6 5fE2OBLjC5lcTLjvXueA2amzPwHfKvUjI2ddjAAOtPP+GvJQ5QmIiukDdyA163zI5W8z ed/fPaGh6XFPQwo6hNfY9FJFng6kaeOBRxL4JIoY4YjoNuuq9tM8JHGkMN3VmpUqZIG4 JA6mdyfDuhiKdCPk34Kyk0Nid6NT/zu2FFLGZG3QbRvW3dpIBD+/ZC3vACNBf/+7ylYD DaRA== 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=Z4mbiv/WjUogfRi1khRBXb/8Vp5w+eaGW1TtX+JuIcA=; b=Jqe3A78OyAer7hEYxQgh6LlJwZWq5wlEvgOK44+x2mg9KEpK9/OsyHSMMVaDSQ7pLf Faw/snh6NnYTyttKgHQNm7WfkVSCivpk7aeXfcrlVB3L8WpeF/rgk6EbpcL4wDrtx+PR zHjx7ciTDy1LBLQXySHkCLfzGqa9AKnEGt1AL2Ysj0F3dsB3NQP4A6Dm/qm8bCi8QcBE kkYp/SJpiCzuUBRoS+vNTLYQg3VyLIjfNcgrFmStxXbZYAhliL8G6SyXj3GgA+D+teE3 9erpecjFcDcPJeaMEseNqKRDOKjWR+KYEbZFa0pB3YPVpI7X2quRVjPZGY2u2ts2Cc+M tDRw== X-Gm-Message-State: AKwxytcJwKmdWVwVRFHE5IQBWvWOG+NV2sQ7LwI3/u3lPd49QQDwaP7A 0V4HlDlVEq740gzni7UjVn0= X-Google-Smtp-Source: AH8x2266KSb6H+Zy3RZgUp/mIBVjQscR89UWGtRUN9E4u+4W00JxQmUcc8nVyo/Vf9jpxqQR72qn7w== X-Received: by 10.46.33.18 with SMTP id h18mr3524784ljh.18.1516803064796; Wed, 24 Jan 2018 06:11:04 -0800 (PST) Received: from localhost.localdomain (c80-217-9-219.bredband.comhem.se. [80.217.9.219]) by smtp.gmail.com with ESMTPSA id r84sm579227lff.72.2018.01.24.06.11.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jan 2018 06:11:04 -0800 (PST) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com Date: Wed, 24 Jan 2018 15:10:59 +0100 Message-Id: <20180124141101.12867-2-codekipper@gmail.com> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180124141101.12867-1-codekipper@gmail.com> References: <20180124141101.12867-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 1/3] ASoC: sun4i-i2s: Add set_tdm_slot functionality 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 Some codecs require a different amount of a bit clocks per frame than what is calculated by the sample width. Use the tdm slot bindings to provide this mechanism. Signed-off-by: Marcus Cooper --- sound/soc/sunxi/sun4i-i2s.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index dca1143c1150..d7a9141514cf 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -96,6 +96,7 @@ #define SUN8I_I2S_CTRL_BCLK_OUT BIT(18) #define SUN8I_I2S_CTRL_LRCK_OUT BIT(17) +#define SUN8I_I2S_FMT0_LRCK_MAX_PERIOD (GENMASK(17, 8) >> 8) #define SUN8I_I2S_FMT0_LRCK_PERIOD_MASK GENMASK(17, 8) #define SUN8I_I2S_FMT0_LRCK_PERIOD(period) ((period - 1) << 8) @@ -193,6 +194,9 @@ struct sun4i_i2s { struct regmap_field *field_rxchansel; const struct sun4i_i2s_quirks *variant; + + unsigned int tdm_slots; + unsigned int slot_width; }; struct sun4i_i2s_clk_div { @@ -344,7 +348,7 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai, if (i2s->variant->has_fmt_set_lrck_period) regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG, SUN8I_I2S_FMT0_LRCK_PERIOD_MASK, - SUN8I_I2S_FMT0_LRCK_PERIOD(32)); + SUN8I_I2S_FMT0_LRCK_PERIOD(word_size)); return 0; } @@ -418,7 +422,8 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, sr + i2s->variant->fmt_offset); return sun4i_i2s_set_clk_rate(dai, params_rate(params), - params_width(params)); + i2s->tdm_slots ? + i2s->slot_width : params_width(params)); } static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) @@ -691,6 +696,19 @@ static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, return 0; } +static int sun4i_i2s_set_dai_tdm_slot(struct snd_soc_dai *dai, + unsigned int tx_mask, unsigned int rx_mask, + int slots, int width) +{ + struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); + + i2s->tdm_slots = slots; + + i2s->slot_width = width; + + return 0; +} + static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = { .hw_params = sun4i_i2s_hw_params, .set_fmt = sun4i_i2s_set_fmt, @@ -698,6 +716,7 @@ static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = { .shutdown = sun4i_i2s_shutdown, .startup = sun4i_i2s_startup, .trigger = sun4i_i2s_trigger, + .set_tdm_slot = sun4i_i2s_set_dai_tdm_slot, }; static int sun4i_i2s_dai_probe(struct snd_soc_dai *dai)