Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1418655

Re: [PATCH 2/4] ASoC: sunxi: Add Allwinner A10 Digital Audio driver

From Maxime Ripard <maxime.ripard@free-electrons.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/4] ASoC: sunxi: Add Allwinner A10 Digital Audio driver
Date 2016-06-09 23:10 +0200
Message-ID <rIfnc-3pv-33@gated-at.bofh.it> (permalink)
References <rFiAV-3aE-3@gated-at.bofh.it> <rFiAV-3aE-13@gated-at.bofh.it> <rFy2Z-4Jw-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi Mark,

On Thu, Jun 02, 2016 at 11:26:51AM +0100, Mark Brown wrote:
> > +static int sun4i_i2s_params_to_sr(struct snd_pcm_hw_params *params)
> > +{
> > +	switch (params_width(params)) {
> > +	case 16:
> > +		return 0;
> > +	}
> > +
> > +	return -EINVAL;
> > +}
> 
> The switch statement here and in the _wss() function look weird because
> they don't have default cases.  Since there's only one user of both
> functions it seems better to have the switch statements inline anyway.

I don't know, maybe it's just me, but I really find it cleaner that
way, and the compiler will probably inline it anyway. If you insist,
I'll change it though.


> > +	for (i = 0; sun4i_i2s_mclk_div[i].div; i++) {
> > +		const struct sun4i_i2s_clk_div *mdiv = sun4i_i2s_mclk_div + i;
> 
> Why not just write these as normal array lookups?

By normal, you mean using ARRAY_SIZE()?

> > +	/* Enable the first output line */
> > +	regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > +			   SUN4I_I2S_CTRL_SDO_EN_MASK,
> > +			   SUN4I_I2S_CTRL_SDO_EN(0));
> > +
> > +	/* Enable the first two channels */
> > +	regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_SEL_REG,
> > +		     SUN4I_I2S_TX_CHAN_SEL(2));
> > +
> > +	/* Map them to the two first samples coming in */
> > +	regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG,
> > +		     SUN4I_I2S_TX_CHAN_MAP(0, 0) | SUN4I_I2S_TX_CHAN_MAP(1, 1));
> 
> We don't undo these if setup fails...  do them once on probe?

Yep

> > +static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
> > +{
> > +        struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
> > +	u32 val;
> 
> More tab/space damage, there seems to be quite a bit in the rest of the
> driver.

Indeed, sorry for that.

> > +static int sun4i_i2s_dai_probe(struct snd_soc_dai *dai)
> > +{
> > +	struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
> > +
> > +	/* Enable the whole hardware block */
> > +	regmap_write(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > +		     SUN4I_I2S_CTRL_GL_EN);
> 
> Runtime PM?  It also seems like this is something that ought to be
> covered in the suspend and resume callbacks.

runtime_pm is supported, and uses the regmap cache to keep those
changes.

suspend and resume is not supported for that SoC yet, so I couldn't
test it properly (and isn't that redundant with runtime_pm?)

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/4] ASoC: sunxi: Add Allwinner A10 Digital Audio driver Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-06-01 20:00 +0200
  Re: [PATCH 2/4] ASoC: sunxi: Add Allwinner A10 Digital Audio driver Code Kipper <codekipper@gmail.com> - 2016-06-02 10:10 +0200
    Re: [PATCH 2/4] ASoC: sunxi: Add Allwinner A10 Digital Audio driver Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-06-09 23:10 +0200
  Re: [PATCH 2/4] ASoC: sunxi: Add Allwinner A10 Digital Audio driver Mark Brown <broonie@kernel.org> - 2016-06-02 12:30 +0200
    Re: [PATCH 2/4] ASoC: sunxi: Add Allwinner A10 Digital Audio driver Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-06-09 23:10 +0200
      Re: [PATCH 2/4] ASoC: sunxi: Add Allwinner A10 Digital Audio driver Mark Brown <broonie@kernel.org> - 2016-06-10 02:40 +0200
        Re: [PATCH 2/4] ASoC: sunxi: Add Allwinner A10 Digital Audio driver Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-06-10 09:40 +0200

csiph-web