From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Chen-Yu Tsai <wens@csie.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
"Andrea Venturi (pers)" <be17068@iperbole.bo.it>,
Liam Girdwood <lgirdwood@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Code Kipper <codekipper@gmail.com>,
linux-sunxi <linux-sunxi@googlegroups.com>,
Mark Brown <broonie@kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>
Subject: Re: [linux-sunxi] [PATCH 1/3] ASoC: sun4i-i2s: Add set_tdm_slot functionality
Date: Mon, 29 Jan 2018 09:40:39 +0100 [thread overview]
Message-ID: <20180129084039.bysenf2y72hqbajq@flea.lan> (raw)
In-Reply-To: <CAGb2v65-Cg4GNL6YcJin6x27bu+R4-X8zjhjYO3pnpatGvE+ew@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 4016 bytes --]
On Mon, Jan 29, 2018 at 03:38:40PM +0800, Chen-Yu Tsai wrote:
> On Mon, Jan 29, 2018 at 3:34 PM, Code Kipper <codekipper@gmail.com> wrote:
> > On 29 January 2018 at 02:50, Chen-Yu Tsai <wens@csie.org> wrote:
> >> On Wed, Jan 24, 2018 at 10:10 PM, <codekipper@gmail.com> wrote:
> >>> From: Marcus Cooper <codekipper@gmail.com>
> >>>
> >>> 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 <codekipper@gmail.com>
> >>> ---
> >>> 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.
Could it be that it's just not i2s but some other format?
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
next prev parent reply other threads:[~2018-01-29 8:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-24 14:10 [PATCH 0/3] ASoC: sun4i-i2s: Updates to the driver codekipper-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <20180124141101.12867-1-codekipper-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-24 14:10 ` [PATCH 1/3] ASoC: sun4i-i2s: Add set_tdm_slot functionality codekipper-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <20180124141101.12867-2-codekipper-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-29 1:50 ` Chen-Yu Tsai
2018-01-29 7:34 ` [linux-sunxi] " Code Kipper
[not found] ` <CAEKpxBn6FNLCN22Bax1RiTdZbsHOqq6Ls5k2JYz6QJt4_77ffA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-01-29 7:38 ` Chen-Yu Tsai
[not found] ` <CAGb2v65-Cg4GNL6YcJin6x27bu+R4-X8zjhjYO3pnpatGvE+ew-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-01-29 7:52 ` Code Kipper
2018-01-29 8:40 ` Maxime Ripard [this message]
2018-01-29 11:32 ` [linux-sunxi] " Mark Brown
[not found] ` <20180129113248.GA10969-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2018-01-29 12:28 ` Code Kipper
2018-01-29 12:31 ` [linux-sunxi] " Mark Brown
2018-01-24 14:11 ` [PATCH 2/3] ASoC: sun4i-i2s: Do not divide clocks when slave codekipper-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <20180124141101.12867-3-codekipper-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-25 2:33 ` Chen-Yu Tsai
2018-01-24 14:11 ` [PATCH 3/3] ASoC: sun4i-i2s: Add regmap field to sign extend sample codekipper-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <20180124141101.12867-4-codekipper-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-24 17:41 ` Code Kipper
2018-01-25 8:41 ` Maxime Ripard
2018-01-25 9:03 ` Code Kipper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180129084039.bysenf2y72hqbajq@flea.lan \
--to=maxime.ripard@free-electrons.com \
--cc=alsa-devel@alsa-project.org \
--cc=be17068@iperbole.bo.it \
--cc=broonie@kernel.org \
--cc=codekipper@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).