Received: by 10.223.176.5 with SMTP id f5csp2564724wra; Sun, 28 Jan 2018 23:53:11 -0800 (PST) X-Google-Smtp-Source: AH8x227jeowu0kWUIfGR3i1K2Is1hQ89akJyk/rXCmKAXMHPnC4Tjka0qnQnmcS7CM5ZoUunDRjj X-Received: by 10.101.82.203 with SMTP id z11mr21280358pgp.164.1517212391436; Sun, 28 Jan 2018 23:53:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517212391; cv=none; d=google.com; s=arc-20160816; b=LIxVERQXXo4Ro849A+qAiuObcoLnbq/AWdakFA1dgB29RtwmHiV7wQw5FkP3rYlIh6 NEBG+JgeRarVHHTkMKcimG9I9nB8q970AnUC77j5uBxPIjeYssAErzT94nDnBtLRXKd0 3Evr1QB8u92cS/qUkfAQ6r73OdPVvEnnJ3J7shFHrkM6naFRY2wwAeUcjJTh3bQu97/z uN/3dVAe+qKpZKqJEeWiZj9Skt0G2UzA0/prlzAdgNOIb0pJJdQTDP2V66C9/Kc4860I TkhDa/a+ImvC2SWEhedprOymiKckNwUl+neisefkwMsMTe8obo3trlmuAZFEBkZqcn2S XUKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=vcDaQoEQaOf7vzXQ/WRwCBTMumQVI8U3kne0zimaQqI=; b=c4ulpQAsN1dmGv3osPHpXhuua2A08Kd+/FRPcwOSvupgv7WTZ1o/v3Yx+AB91KqTz0 evqwx6BIaYSH8Y6iJAEyYMVbnVDUZob6g+x5AS8wAhdvrMdJWTjFs9xvvFns3e7enWNE GFBNW0dOg01rty0qeLFu19eo36JfJZNg7M8nYhi0+kBmd3J8ERkXwp8TBop1N7n3CB5B 5i88a9uLDf1ibOUnf15apH4rjqEYE5JGtfUyAOptnM5azEjMwIe8ac498eDQhvI0SFda Sku/UBNShq6UOEuUp1iaPtYguts7TW92MQc78I2TEQWFiyLqbZ0imbVAvTHQ634h6j6d pbfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e4DI69NU; 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 o16si133397pgd.125.2018.01.28.23.52.45; Sun, 28 Jan 2018 23:53:11 -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=e4DI69NU; 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 S1751370AbeA2HwO (ORCPT + 99 others); Mon, 29 Jan 2018 02:52:14 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:50850 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbeA2HwN (ORCPT ); Mon, 29 Jan 2018 02:52:13 -0500 Received: by mail-it0-f65.google.com with SMTP id x128so7215162ite.0 for ; Sun, 28 Jan 2018 23:52:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vcDaQoEQaOf7vzXQ/WRwCBTMumQVI8U3kne0zimaQqI=; b=e4DI69NUrg9YWObf4+/MAa13qVNBnFTWqXPOyRmVF4L0TMKlrXvmsgKVexnWgkytc1 I844ppvSZAVKPL5Xknx2ofdXCeRKev+1SlZPEmvWuGJRiz0gNOP94Gqrefn85HduilCY Jlbhp70YNzbBtmNeq3F8pZFnBJEF7J9oPOkOsNhfaMvf2PPTSNG7WoW5iH/WdoHsAAEd Ks8O+E0GULMntA4Z1edPxRIFODDaDPY0dSlSNijvWr1QULTYy18tCf46pU2koNcJl1wL VQdKYL8p3NAZdVVgDdIGTJwRVSKC8zPWS1lrc9XkJ4raEr84Caf8oSGvuWSvfZ6x+tkR TwGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vcDaQoEQaOf7vzXQ/WRwCBTMumQVI8U3kne0zimaQqI=; b=Lzg/ok+h1xGYdXjEX+mEB7OAW4/9sjbo33COX2ZWwkuuc+E0TMoVNcIAIsM50fzHO4 YFT29BW2T/rovdG9rwRWYDvEwI812gQIAR2xXt5U9mPcZdcS4MsQmdnN3lqNU+G6zeVL yrQ/5GYAN6vm1R3NGV5DoJ8y7aPhuW0/+cOYbue309dSaRzUCXSBDhn3gbFJD5k19Nlp Run/lm5grEL55DNr+VVb65GdXFy5C57/cJXN12/LvlVSAUW+/lC3swf7E8fewlTaSyxn NYP07pWnfWPAiMJRCOkkDJrGKuqP5ZdrqgzD6HvbGEnw9i1TZjDbgV3fQX6fEGj1Q5wl pqoQ== X-Gm-Message-State: AKwxytf8/+Y0CoQd/RxewzWFefLkmKyN4QsxsrWsSdWAk0v5oK2VxqWg gFFguHju/eFliKUmu1eTeCDrugbzMr6KG10P58Y= X-Received: by 10.36.33.66 with SMTP id e63mr27105750ita.74.1517212332549; Sun, 28 Jan 2018 23:52:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.213.129 with HTTP; Sun, 28 Jan 2018 23:52:12 -0800 (PST) In-Reply-To: References: <20180124141101.12867-1-codekipper@gmail.com> <20180124141101.12867-2-codekipper@gmail.com> From: Code Kipper Date: Mon, 29 Jan 2018 08:52:12 +0100 Message-ID: Subject: Re: [linux-sunxi] [PATCH 1/3] ASoC: sun4i-i2s: Add set_tdm_slot functionality To: Chen-Yu Tsai Cc: Maxime Ripard , linux-arm-kernel , linux-sunxi , Liam Girdwood , Mark Brown , linux-kernel , Linux-ALSA , "Andrea Venturi (pers)" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29 January 2018 at 08:38, Chen-Yu Tsai wrote: > On Mon, Jan 29, 2018 at 3:34 PM, Code Kipper wrote: >> On 29 January 2018 at 02:50, Chen-Yu Tsai wrote: >>> On Wed, Jan 24, 2018 at 10:10 PM, wrote: >>>> 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; >>>> +} >>>> + >>> >>> IIRC some of the DAI controllers actually support TDM. Would this >>> change conflict with that in the future? >> >> Hi Wens, >> I'm not sure..I was looking for a clean example of being able to >> override the number of bclks in the lrclk width and some other >> devices(Rpi) were doing it this way. I open to suggestions, > > I'm not familiar with the issue either. If Mark doesn't have any > objections, we could merge it for now, and fix it later if there > are any complications. > > BTW, you didn't provide a device tree example (if any) for how > to use this. Hi Wens, here is an example that I use for the Pine64 audio hat. https://github.com/codekipper/linux-sunxi/commit/faa9dfba955bf71ca23b089b1cb678a14443216f#diff-1473a38b339685d191c5a87aab9c0fdfR80 I've done the same on the A64 for HDMI and analog audio which both use the i2s and seem to require 32bit LRCK width. BR, CK > > ChenYu > >> BR, >> CK >>> >>> Thanks >>> ChenYu >>> >>>> 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 >>>> >>>> -- >>>> You received this message because you are subscribed to the Google Groups "linux-sunxi" group. >>>> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout.