From: Alexander <subaparts@yandex.ru>
To: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Cc: alsa-devel@alsa-project.org, broonie@opensource.wolfsonmicro.com,
ryan@bluewatersys.com, linux-arm-kernel@lists.infradead.org,
lrg@slimlogic.co.uk
Subject: Re: [PATCH] ASoC: CS4271 codec support
Date: Mon, 17 Jan 2011 16:37:29 +0300 [thread overview]
Message-ID: <1295271449.16460.34.camel@r60e> (raw)
In-Reply-To: <1295260210.11031.38.camel@dplaptop.localdomain>
Dear Dimitris,
On Mon, 2011-01-17 at 10:30 +0000, Dimitris Papastamos wrote:
> On Mon, 2011-01-17 at 01:35 +0300, Alexander wrote:
> > +/* CS4271 default register settings, except auto-mute is off */
> > +static const u8 cs4271_dflt_reg[CS4271_NR_REGS] = {
> > + 0, 0, 0, CS4271_DACVOL_ATAPI_AL_BR, 0, 0, 0,
> > + CS4271_MODE2_CPEN | CS4271_MODE2_PDN,
> > +};
>
> I'd be better to leave these as defaults, and perform any initialization
> in the the cs4271_probe() function.
It's space optimized without affecting readability. I can rename it to
cs4271_init_reg[].
>
> > + /* Configure DAC */
> > + val = cs4271_clk_tab[i].speed_mode;
> > +
> > + if (cs4271->master)
> > + val |= cs4271_clk_tab[i].mclk_master | CS4271_MODE1_MASTER;
> > + else
> > + val |= cs4271_clk_tab[i].mclk_slave;
>
> This should ideally live in cs4271_set_dai_fmt().
It's space optimized for particular codec hardware without affecting
readability.
>
> > + switch (cs4271->mode) {
> > + case SND_SOC_DAIFMT_LEFT_J:
> > + val |= CS4271_MODE1_DAC_DIF_LJ;
> > + break;
> > + case SND_SOC_DAIFMT_I2S:
> > + val |= CS4271_MODE1_DAC_DIF_I2S;
> > + break;
> > + default:
> > + dev_err(codec->dev, "Invalid DAI format\n");
> > + return -EINVAL;
> > + }
>
> Same here.
Same here.
>
> > +/* CS4271 controls */
> > +static DECLARE_TLV_DB_SCALE(cs4271_dac_tlv, -12700, 100, 0);
>
> Are you use this doesn't mute the DAC? If so the the last parameter
> should be 1.
No I do not use this, some people asked for this last time I've tried to
submit this code. And no, this doesn't mute the DAC.
>
> > +#ifdef CONFIG_PM
> > +static int cs4271_soc_suspend(struct snd_soc_codec *codec, pm_message_t mesg)
> > +{
> > + /* Set power-down bit */
> > + snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN,
> > + CS4271_MODE2_PDN);
> > +
> > + return 0;
> > +}
> > +#else
> > +#define cs4271_soc_suspend NULL
> > +#endif /* CONFIG_PM */
> > +
> > +/* This function used also in codec probe function and not only for PM */
> > +static int cs4271_soc_resume(struct snd_soc_codec *codec)
> > +{
> > + int ret;
> > +
> > + /* Restore codec state */
> > + ret = cs4271_write_cache(codec);
> > + if (ret < 0)
> > + return ret;
> > +
> > + /* then disable the power-down bit */
> > + snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN, 0);
> > +
> > + return 0;
> > +}
>
> Consider setting the set_bias_level callback and performing the required
> work in there. You can then trigger a change in the bias levels by
> calling your cs4271_set_bias_level() function from within your suspend()
> and resume() functions.
>
> > + /*
> > + * In case of I2C, chip address specified in board data.
> > + * So cache IO operations use 8 bit codec register address.
> > + * In case of SPI, chip address and register address
> > + * passed together as 16 bit value.
> > + * Anyway, register address is masked with 0xFF inside
> > + * soc-cache code.
> > + */
>
> Have you tested your driver using both SPI and I2C?
Yes.
>
> > + ret = (cs4271->bus_type == SND_SOC_SPI) ? 16 : 8;
>
> Please avoid using the ternary operator like this.
What's wrong with it?
>
> > + ret = snd_soc_codec_set_cache_io(codec, ret, 8, cs4271->bus_type);
> > + if (ret) {
> > + dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
> > + return ret;
> > + }
> > +
> > + ret = cs4271_soc_resume(codec);
> > + if (ret < 0)
> > + return ret;
>
> This should also changed to a call to
> cs4271_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
>
There is no need for DAPM on hardware I consider. I can even remove PM
stuff. Someone may implement it later, if CS4271 would appear on
something except Cirrus dev. boards.
> Thanks,
> Dimitris
>
>
Thanks,
Alexander.
WARNING: multiple messages have this Message-ID (diff)
From: subaparts@yandex.ru (Alexander)
To: linux-arm-kernel@lists.infradead.org
Subject: [alsa-devel] [PATCH] ASoC: CS4271 codec support
Date: Mon, 17 Jan 2011 16:37:29 +0300 [thread overview]
Message-ID: <1295271449.16460.34.camel@r60e> (raw)
In-Reply-To: <1295260210.11031.38.camel@dplaptop.localdomain>
Dear Dimitris,
On Mon, 2011-01-17 at 10:30 +0000, Dimitris Papastamos wrote:
> On Mon, 2011-01-17 at 01:35 +0300, Alexander wrote:
> > +/* CS4271 default register settings, except auto-mute is off */
> > +static const u8 cs4271_dflt_reg[CS4271_NR_REGS] = {
> > + 0, 0, 0, CS4271_DACVOL_ATAPI_AL_BR, 0, 0, 0,
> > + CS4271_MODE2_CPEN | CS4271_MODE2_PDN,
> > +};
>
> I'd be better to leave these as defaults, and perform any initialization
> in the the cs4271_probe() function.
It's space optimized without affecting readability. I can rename it to
cs4271_init_reg[].
>
> > + /* Configure DAC */
> > + val = cs4271_clk_tab[i].speed_mode;
> > +
> > + if (cs4271->master)
> > + val |= cs4271_clk_tab[i].mclk_master | CS4271_MODE1_MASTER;
> > + else
> > + val |= cs4271_clk_tab[i].mclk_slave;
>
> This should ideally live in cs4271_set_dai_fmt().
It's space optimized for particular codec hardware without affecting
readability.
>
> > + switch (cs4271->mode) {
> > + case SND_SOC_DAIFMT_LEFT_J:
> > + val |= CS4271_MODE1_DAC_DIF_LJ;
> > + break;
> > + case SND_SOC_DAIFMT_I2S:
> > + val |= CS4271_MODE1_DAC_DIF_I2S;
> > + break;
> > + default:
> > + dev_err(codec->dev, "Invalid DAI format\n");
> > + return -EINVAL;
> > + }
>
> Same here.
Same here.
>
> > +/* CS4271 controls */
> > +static DECLARE_TLV_DB_SCALE(cs4271_dac_tlv, -12700, 100, 0);
>
> Are you use this doesn't mute the DAC? If so the the last parameter
> should be 1.
No I do not use this, some people asked for this last time I've tried to
submit this code. And no, this doesn't mute the DAC.
>
> > +#ifdef CONFIG_PM
> > +static int cs4271_soc_suspend(struct snd_soc_codec *codec, pm_message_t mesg)
> > +{
> > + /* Set power-down bit */
> > + snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN,
> > + CS4271_MODE2_PDN);
> > +
> > + return 0;
> > +}
> > +#else
> > +#define cs4271_soc_suspend NULL
> > +#endif /* CONFIG_PM */
> > +
> > +/* This function used also in codec probe function and not only for PM */
> > +static int cs4271_soc_resume(struct snd_soc_codec *codec)
> > +{
> > + int ret;
> > +
> > + /* Restore codec state */
> > + ret = cs4271_write_cache(codec);
> > + if (ret < 0)
> > + return ret;
> > +
> > + /* then disable the power-down bit */
> > + snd_soc_update_bits(codec, CS4271_MODE2, CS4271_MODE2_PDN, 0);
> > +
> > + return 0;
> > +}
>
> Consider setting the set_bias_level callback and performing the required
> work in there. You can then trigger a change in the bias levels by
> calling your cs4271_set_bias_level() function from within your suspend()
> and resume() functions.
>
> > + /*
> > + * In case of I2C, chip address specified in board data.
> > + * So cache IO operations use 8 bit codec register address.
> > + * In case of SPI, chip address and register address
> > + * passed together as 16 bit value.
> > + * Anyway, register address is masked with 0xFF inside
> > + * soc-cache code.
> > + */
>
> Have you tested your driver using both SPI and I2C?
Yes.
>
> > + ret = (cs4271->bus_type == SND_SOC_SPI) ? 16 : 8;
>
> Please avoid using the ternary operator like this.
What's wrong with it?
>
> > + ret = snd_soc_codec_set_cache_io(codec, ret, 8, cs4271->bus_type);
> > + if (ret) {
> > + dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
> > + return ret;
> > + }
> > +
> > + ret = cs4271_soc_resume(codec);
> > + if (ret < 0)
> > + return ret;
>
> This should also changed to a call to
> cs4271_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
>
There is no need for DAPM on hardware I consider. I can even remove PM
stuff. Someone may implement it later, if CS4271 would appear on
something except Cirrus dev. boards.
> Thanks,
> Dimitris
>
>
Thanks,
Alexander.
next prev parent reply other threads:[~2011-01-17 13:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-16 22:35 [PATCH] ASoC: CS4271 codec support Alexander
2011-01-16 22:35 ` Alexander
2011-01-17 10:30 ` Dimitris Papastamos
2011-01-17 10:30 ` [alsa-devel] " Dimitris Papastamos
2011-01-17 13:37 ` Alexander [this message]
2011-01-17 13:37 ` Alexander
2011-01-17 15:40 ` Mark Brown
2011-01-17 15:40 ` [alsa-devel] " Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2011-01-19 18:22 Alexander
2011-01-20 9:31 ` Dimitris Papastamos
2011-01-20 22:13 ` Liam Girdwood
2011-01-21 18:22 ` Mark Brown
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=1295271449.16460.34.camel@r60e \
--to=subaparts@yandex.ru \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=dp@opensource.wolfsonmicro.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=lrg@slimlogic.co.uk \
--cc=ryan@bluewatersys.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.