Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp392817ybl; Tue, 13 Aug 2019 23:11:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzrcwlpVIWk8KAadZLoLgrt8rbCneomJpspq6tCsCE5B2uDd2TuRI3D6wPeHexI8udkVoW X-Received: by 2002:a65:6281:: with SMTP id f1mr35424380pgv.400.1565763103290; Tue, 13 Aug 2019 23:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565763103; cv=none; d=google.com; s=arc-20160816; b=ZJiwiSdcdJ451WD4MLe2r96GYZYTz7pB8w2t/fDmUmU7qp2bKHREmtRc4y2qRnM/xS XrHquctcN3nKZ80k6JdihcbaiWtbBNdfw1CTXtG1fuwZSiu+K9YW6UkLPWb3Yj2+Nnvq KQIRvglAB7/QNARiL8og3uY2eAqmvpogm6JGOfMQbStXJ0+4p5rCWh6fals7CJtzUHnU kfsfSY1j7La7kJci/E1fAZ1Xz38c3N7uBxdqHqC4sCodwKk/lVAds45HZypeHVb3BMVj y9S6wg3+uUtg8gub3vZHGpiVx54LlO6RamHTXHUcygMsNLxbXlgdry43jOQj1P8PrJhZ 0sqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nIdAGNiLkiiK2Gw0kPcR7I6xu5ZStD9Kxb2ECFc6UjY=; b=mDxnDxt8Y0ncTfjxfRHAzNVJZ/qlu5zqXZvIvKHjqR4U5ZyRN+c1VPQNq73XlAEz/m h4aG+N9P5c649BsVLf+iLPINsC37EFne9PWvqOeCWl2kTFl7az4lCN+PB47j/mv3WyQ1 EyaGq7Nkis9re8rLSKVHLon4mYT76MvkK9n+69tdN772GqsWt1AtwcI2kpAHmMvi4CmC 2GN7dJYUKu8rhkwXsg2a2u2RBkm+GTWf7+ycR0pdQFcQMZ2HG+lNZKbMbZy1qBxl4xZP ASRkfuoWNRJa6tDCtUjYhSQdephF1InwPWFAmuRGfNhdO+SaaQe4IakOfNJMzF8p9iEs hG9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FavTetyh; 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=QUARANTINE 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 x8si60736733pln.298.2019.08.13.23.11.27; Tue, 13 Aug 2019 23:11:43 -0700 (PDT) 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=FavTetyh; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727491AbfHNGJG (ORCPT + 99 others); Wed, 14 Aug 2019 02:09:06 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:40492 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727452AbfHNGJE (ORCPT ); Wed, 14 Aug 2019 02:09:04 -0400 Received: by mail-lf1-f66.google.com with SMTP id b17so78468173lff.7 for ; Tue, 13 Aug 2019 23:09:02 -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 :mime-version:content-transfer-encoding; bh=nIdAGNiLkiiK2Gw0kPcR7I6xu5ZStD9Kxb2ECFc6UjY=; b=FavTetyhFsglyGujp7hKFmN5Wjrg8vatZ/OKeJnhnFCTNyNjm6FSQW5m7z4ex3otcK XNWNbkpobxRd8dgjYf9tHhgx9aHtDe4FhyV7utEEWuo615XqeQvu3KtvBsKqTrXAaLJ1 JuZoHI12nV9/EFhVOIcOLI4Efnu30Co0IfQpSZC5NSOOy30Y7vapcGtPogK7LmGHzLKY Or1T9GCBBheRfEcR8c9bnEU8DqDNZqWg9zraE2OVhBNP22FEH2TyDi1RHPMZVNkfSQO9 YuIyZtMpunFNx0/5XICae1ynEKsev56Mf9hGlsmEGDKtPGMhp8nU3Gz9uqEU2jIWK79A WWbA== 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:mime-version:content-transfer-encoding; bh=nIdAGNiLkiiK2Gw0kPcR7I6xu5ZStD9Kxb2ECFc6UjY=; b=MpoGAqHSsu5+zUpM0g/HNF0hgv6Y2rD37SK6Qn4JNiMbIObrakFre/DQ91BSv9U3an J43WVzDeqtki4lyTNAH3z+JgBn9tr4YaPvqnJq5lF1tlv3Th7quWRV7StT+DxsOjkuhv 8uYEFJQjg48PirSD+4Bpy6c3HVcMMEUOUcuRGXOOfqkNBLxTsnASd4Ep8kS5qE+9A8Jw st9uVhNX0vdgfupltNu70htSCNandMyjs2XxWWOzqOve/se6mSj56fFomoesJi2xfjju hF4Ywx1XK0XytrReLe3+Hbx4m3Ib0nHAi2BjBmkOwO/InMjdJZivbK+IVoDc7WCzURpj x0YA== X-Gm-Message-State: APjAAAUpsVe7JSwhnnU+g802fJnvm7863guAeDLS6pjUiJeBdoRSH7Mx IpZu4TPJOcwba3+w/HksWqo= X-Received: by 2002:a19:c511:: with SMTP id w17mr13345752lfe.31.1565762942016; Tue, 13 Aug 2019 23:09:02 -0700 (PDT) Received: from localhost.localdomain (c213-102-74-69.bredband.comhem.se. [213.102.74.69]) by smtp.gmail.com with ESMTPSA id s10sm3124235ljm.35.2019.08.13.23.08.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 23:09:01 -0700 (PDT) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com, wens@csie.org, linux-sunxi@googlegroups.com Cc: linux-arm-kernel@lists.infradead.org, lgirdwood@gmail.com, broonie@kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, be17068@iperbole.bo.it, Marcus Cooper Subject: [PATCH v5 02/15] ASoC: sun4i-i2s: Add set_tdm_slot functionality Date: Wed, 14 Aug 2019 08:08:41 +0200 Message-Id: <20190814060854.26345-3-codekipper@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814060854.26345-1-codekipper@gmail.com> References: <20190814060854.26345-1-codekipper@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marcus Cooper Codecs without a control connection such as i2s based HDMI audio and the Pine64 DAC require a different amount of 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 8201334a059b..7c37b6291df0 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -195,6 +195,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 { @@ -346,7 +349,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)); /* Set sign extension to pad out LSB with 0 */ regmap_field_write(i2s->field_fmt_sext, 0); @@ -450,7 +453,8 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, regmap_field_write(i2s->field_fmt_sr, sr); 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) @@ -693,10 +697,25 @@ 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, .set_sysclk = sun4i_i2s_set_sysclk, + .set_tdm_slot = sun4i_i2s_set_dai_tdm_slot, .trigger = sun4i_i2s_trigger, }; -- 2.22.0