Received: by 10.223.176.46 with SMTP id f43csp801562wra; Wed, 24 Jan 2018 06:12:59 -0800 (PST) X-Google-Smtp-Source: AH8x227DqdbdXE0s/5UPyUJQfGpphpD2jOR5hIwXtZWfFf3h9l/ojsFkKVOJDDZ9YDv20OGq2AE+ X-Received: by 10.99.126.86 with SMTP id o22mr11087655pgn.364.1516803178994; Wed, 24 Jan 2018 06:12:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516803178; cv=none; d=google.com; s=arc-20160816; b=ldeDuQCRYYq4wAza+Y9NCqKz+chkhgoRMwVhrEbkxo+xMOtUALdTGnS/Zt/6MTsu1G 40BC+gWAGfgpIZNoLM4+6VScf5zY0Z6FJEbNjBUfDz4lk5m8QYjJciNUv6OQNvJ+ZtGN 9yBgdF1CzT5SIuWab+6/Hec6RCRoNfI4ODkb3fIzO1EQhBclDaS80fDwsLF++Egqec7P yVH82Tp+X8bFEgXvwFZDz9m/aznNYJSdY53WSqXpc/gCi3jrFm6dfoV8ZDw0Kl574EuA 24+xfIX6GSGbQAv0tRwzBHo1F4fRRZiGR1P+VhGDg3S/mWfzqd63mkJvthfnVgBMi4ga Ge9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Z4mbiv/WjUogfRi1khRBXb/8Vp5w+eaGW1TtX+JuIcA=; b=j2Fa6PEYvK2C2lBe1/aOET921qX2KQ8pISgULdUi0wVvO5+IFbfy3qa+iXonUSnxHp nOlK0xxGOO45ndW7iVliA9EgeT57PS4k0Sfimk0/fJtzEaP0X+Lucmj5ZHmjsQhE85hD 4f+gBf5RCBqKY29SwZZ/MNFUiA/UgsWfdf9hh24VhDaxQVL/m4dvuMozvuC8qISKzjpQ ZmZgpLHguygkvsTr7sMdFMkMwNYDHF5pfXU9NLnZIe594q83zSylsDZOY4bwdUDxEIx2 ARYcXFyB9L4Uh5coLIXeeMqdGTtvqMtGbheGOsPEE8vnHwmXc7X8xRX51U536JqAWqqc NRpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oQrgxBBv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si254677pla.607.2018.01.24.06.12.45; Wed, 24 Jan 2018 06:12:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oQrgxBBv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934027AbeAXOLJ (ORCPT + 99 others); Wed, 24 Jan 2018 09:11:09 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:40463 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934001AbeAXOLG (ORCPT ); Wed, 24 Jan 2018 09:11:06 -0500 Received: by mail-lf0-f65.google.com with SMTP id h92so5411167lfi.7 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=pgX+Gf0RKdlLsaIp3OD/3396ntd7dB99rftp7G/7Lgpd1ZD2INX0LF/4H8+tpLFawg GU3+XCYESf7xMH6I2wVsppEW9Kh2BJT/qUNoegazFN4PLBw4wpOFh9THm++P+scVdLod DTtjylsi30oucmh8jRyc++FkwzhOQ6A+eIP57Ay2q0UTe9XTQMRj4A2uiYx3ERM81x+t qVfULdTws0DoyRhfV7zYfMo0byrrow2oA6jKBk1qBLOzVrm6FqkObbmJP0puUTC+8U3I Cnn/0PUYbO9aUnMv29CNSPeHvNims7TZBZU4kk5LhARbLmB76Gjz4gzr+WPZ1vSHC930 Fd5w== X-Gm-Message-State: AKwxytci9VQMKH/tOTxa4M8YZJrOXLdLKcmKO4QKVKl2h62baC5c2zKr EWlMCEWxlnPhUkn4OYYKcl0= 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 Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, lgirdwood@gmail.com, broonie@kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, be17068@iperbole.bo.it, Marcus Cooper Subject: [PATCH 1/3] ASoC: sun4i-i2s: Add set_tdm_slot functionality 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.16.0