From: Lars-Peter Clausen <lars@metafoo.de>
To: Marek Belisko <marek.belisko@gmail.com>
Cc: perex@perex.cz, tiwai@suse.de, alsa-devel@alsa-project.org,
linux-doc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org,
lgirdwood@gmail.com, rob.herring@calxeda.com,
linux-kernel@vger.kernel.org,
Marek Belisko <marek.belisko@streamunlimited.com>,
broonie@kernel.org, rob@landley.net, grant.likely@linaro.org,
zonque@gmail.com
Subject: Re: [alsa-devel] [PATCH] ASoC: Add PCM1681 codec driver.
Date: Mon, 01 Jul 2013 14:37:09 +0200 [thread overview]
Message-ID: <51D177F5.2040805@metafoo.de> (raw)
In-Reply-To: <1372251928-15706-1-git-send-email-marek.belisko@streamunlimited.com>
On 06/26/2013 03:05 PM, Marek Belisko wrote:
[...]
> +static int pcm1681_deemph[] = { 44100, 48000, 32000 };
const
> +
> +static int pcm1681_set_deemph(struct snd_soc_codec *codec)
> +{
> + struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec);
> + int i = 0, val = -1, ret;
> +
> + if (priv->deemph)
> + for (i = 0; i < ARRAY_SIZE(pcm1681_deemph); i++)
> + if (pcm1681_deemph[i] == priv->rate)
> + val = i;
> +
> + /* enable choosen frequency */
> + if (val != -1)
> + regmap_update_bits(priv->regmap, PCM1681_DEEMPH_CONTROL,
> + PCM1681_DEEMPH_RATE_MASK, val);
So if the current sample rate doesn't match any of the available deempth rates
the current setting is kept. This doesn't seem right.
> +
> + /* enable/disable deemphasis functionality */
> + ret = regmap_update_bits(priv->regmap, PCM1681_DEEMPH_CONTROL,
> + PCM1681_DEEMPH_MASK, priv->deemph);
> +
> + return ret;
> +}
> +
[...]
> +
> +static int pcm1681_digital_mute(struct snd_soc_dai *dai, int mute)
> +{
> + struct snd_soc_codec *codec = dai->codec;
> + struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec);
> + int ret, val = 0;
> +
> + if (mute)
> + val = PCM1681_SOFT_MUTE_ALL;
> +
> + ret = regmap_write(priv->regmap, PCM1681_SOFT_MUTE, val);
How about just
return regmap_write(...)
> + if (ret < 0)
> + return ret;
> +
> + return 0;
> +}
> +
[...]
> +static const DECLARE_TLV_DB_SCALE(pcm1681_dac_tlv, -6350, 50, 1);
> +
> +static const struct snd_kcontrol_new pcm1681_controls[] = {
> + SOC_DOUBLE_R_TLV("PCM1681 Channel 1/2 Playback Volume",
> + PCM1681_ATT_CONTROL(1), PCM1681_ATT_CONTROL(2), 0,
> + 0x7f, 0, pcm1681_dac_tlv),
> + SOC_DOUBLE_R_TLV("PCM1681 Channel 3/4 Playback Volume",
> + PCM1681_ATT_CONTROL(3), PCM1681_ATT_CONTROL(4), 0,
> + 0x7f, 0, pcm1681_dac_tlv),
> + SOC_DOUBLE_R_TLV("PCM1681 Channel 5/6 Playback Volume",
> + PCM1681_ATT_CONTROL(5), PCM1681_ATT_CONTROL(6), 0,
> + 0x7f, 0, pcm1681_dac_tlv),
> + SOC_DOUBLE_R_TLV("PCM1681 Channel 7/8 Playback Volume",
> + PCM1681_ATT_CONTROL(7), PCM1681_ATT_CONTROL(8), 0,
> + 0x7f, 0, pcm1681_dac_tlv),
> + SOC_SINGLE_BOOL_EXT("PCM1681 De-emphasis Switch", 0,
> + pcm1681_get_deemph, pcm1681_put_deemph),
> +};
The name of the codec should probably not be in the control names.
[...]
> +#ifdef CONFIG_OF
> +static const struct of_device_id pcm1681_dt_ids[] = {
> + { .compatible = "ti,pcm1681", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, pcm1681_dt_ids);
> +#endif
> +
> +static const struct regmap_config pcm1681_regmap = {
> + .reg_bits = 8,
> + .val_bits = 8,
> + .max_register = ARRAY_SIZE(pcm1681_reg_defaults),
max_register is the last register in the register map, so usually this would be
ARRAY_SIZE(...) + 1
> + .reg_defaults = pcm1681_reg_defaults,
> + .num_reg_defaults = ARRAY_SIZE(pcm1681_reg_defaults),
> + .writeable_reg = pcm1681_writeable_reg,
> + .readable_reg = pcm1681_accessible_reg,
> +};
[...]
> +
> +static struct snd_soc_codec_driver soc_codec_dev_pcm1681 = {
> + .probe = pcm1681_probe,
> + .remove = pcm1681_remove,
> + .controls = pcm1681_controls,
> + .num_controls = ARRAY_SIZE(pcm1681_controls),
> +};
> +
> +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
Since the driver only supports I2C there is no need for this ifdef
[...]
prev parent reply other threads:[~2013-07-01 12:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-26 13:05 [PATCH] ASoC: Add PCM1681 codec driver Marek Belisko
2013-06-26 13:16 ` Daniel Mack
2013-06-26 13:46 ` Marek Belisko
2013-06-26 13:55 ` Daniel Mack
2013-06-26 14:25 ` Mark Brown
2013-06-26 14:30 ` Mark Brown
2013-06-27 7:49 ` Marek Belisko
2013-07-01 12:37 ` Lars-Peter Clausen [this message]
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=51D177F5.2040805@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marek.belisko@gmail.com \
--cc=marek.belisko@streamunlimited.com \
--cc=perex@perex.cz \
--cc=rob.herring@calxeda.com \
--cc=rob@landley.net \
--cc=tiwai@suse.de \
--cc=zonque@gmail.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 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).