[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <51D177F5.2040805@metafoo.de>
Date: Mon, 01 Jul 2013 14:37:09 +0200
From: Lars-Peter Clausen <lars@...afoo.de>
To: Marek Belisko <marek.belisko@...il.com>
CC: perex@...ex.cz, tiwai@...e.de, alsa-devel@...a-project.org,
linux-doc@...r.kernel.org, devicetree-discuss@...ts.ozlabs.org,
lgirdwood@...il.com, rob.herring@...xeda.com,
linux-kernel@...r.kernel.org,
Marek Belisko <marek.belisko@...eamunlimited.com>,
broonie@...nel.org, rob@...dley.net, grant.likely@...aro.org,
zonque@...il.com
Subject: Re: [alsa-devel] [PATCH] ASoC: Add PCM1681 codec driver.
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
[...]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists