All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Tomoya MORINAGA <tomoya.rohm@gmail.com>
Cc: alsa-devel@alsa-project.org, qi.wang@intel.com,
	Takashi Iwai <tiwai@suse.de>,
	linux-kernel@vger.kernel.org, yong.y.wang@intel.com,
	kok.howg.ewe@intel.com, Liam Girdwood <lrg@ti.com>,
	joel.clark@intel.com
Subject: Re: [PATCH v6] sound/soc/codecs: add LAPIS Semiconductor ML26124
Date: Wed, 29 Feb 2012 23:51:48 +0000	[thread overview]
Message-ID: <20120229235147.GM8295@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1329976011-2251-1-git-send-email-tomoya.rohm@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 3325 bytes --]

On Thu, Feb 23, 2012 at 02:46:49PM +0900, Tomoya MORINAGA wrote:

> +	SOC_SINGLE_TLV("Playback Limitter Min Input Volume",
> +			ML26124_PL_MAXMIN_GAIN, 0, 7, 0, mingain),

Limiter.

> +	SOC_SINGLE("Zero Cross Comparator Switch", ML26124_PW_ZCCMP_PW_MNG, 1,
> +		    1, 0),

Usually just "ZC Switch".

> +	SOC_SINGLE("Digital Switch", ML26124_DVOL_CTL, 4, 1, 0),

This should probably be Digital Playback Switch so it lines up with the
volume control in the UIs (and the Volume controls should be Digital X
Volume).

> +static int ml26124_update_bits(struct snd_soc_codec *codec, unsigned short reg,
> +				unsigned int mask, unsigned int value)

Why are you open coding this in your driver?  There is no point in
replicating subsystem functionality.

> +if (!priv)
> +	return -1;
> +

Coding style and return real error codes (though this looks like it
should never happen).

> +static int ml26124_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
> +				  int div_id, int div)
> +{
> +	struct snd_soc_codec *codec = codec_dai->codec;
> +
> +	switch (div_id) {
> +	case ML26124_MCLK:
> +		ml26124_update_bits(codec, ML26124_CLK_CTL,
> +				      BIT(0) | BIT(1), div);
> +		break;

Why can't the driver calculate this automatically given the MCLK?

> +	case SND_SOC_BIAS_ON:
> +		pr_debug("%s: level=ON priv=%p\n", __func__, priv);

There's already more than enough logging in the subsystem for this.

> +		/* VMID ON */
> +		ml26124_update_bits(codec, ML26124_PW_REF_PW_MNG,
> +				    ML26124_VMID, ML26124_VMID);
> +		msleep(500);

This looks like it should be _STANDBY - usually VMID must be on to power
everything else.

> +static int ml26124_pcm_trigger(struct snd_pcm_substream *substream,
> +			      int cmd, struct snd_soc_dai *codec_dai)
> +{
> +	struct snd_soc_codec *codec = codec_dai->codec;
> +
> +	switch (cmd) {
> +	case SNDRV_PCM_TRIGGER_STOP:
> +	case SNDRV_PCM_TRIGGER_SUSPEND:
> +	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
> +		ml26124_update_bits(codec, ML26124_REC_PLYBAK_RUN, 0x3,
> +				    0);

I'm not sure you've tested this, you can't do I2C I/O from atomic
context and trigger is atomic.  What does this control actually do?

> +		return 0;
> +		break;

Duplicate return and break here.

> +static int ml26124_resume(struct snd_soc_codec *codec)
> +{
> +	struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
> +
> +	regcache_sync(priv->regmap);
> +	ml26124_set_bias_level(codec, SND_SOC_BIAS_STANDBY);

Setting the bias level will duplicate the sync.

> +static int ml26124_probe(struct snd_soc_codec *codec)
> +{
> +	int ret;
> +	struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
> +	codec->control_data = priv->regmap;
> +
> +	ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
> +	if (ret < 0) {
> +		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
> +		return ret;
> +	}

You're mixing regmap API usage and ASoC level I2C, this should be
_REGMAP.

> +/* power down chip */
> +static struct snd_soc_codec_driver soc_codec_dev_ml26124 = {

This comment is misplaced.

> +static struct i2c_driver ml26124_i2c_driver = {
> +	.driver = {
> +		.name = "ml26124-codec",

No -codec, the device only does one thing.

> +static int __init ml26124_modinit(void)
> +{
> +	int ret;
> +
> +	ret = i2c_add_driver(&ml26124_i2c_driver);
> +	if (ret != 0)

module_i2c_driver().

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



WARNING: multiple messages have this Message-ID (diff)
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Tomoya MORINAGA <tomoya.rohm@gmail.com>
Cc: Liam Girdwood <lrg@ti.com>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.de>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	qi.wang@intel.com, yong.y.wang@intel.com, joel.clark@intel.com,
	kok.howg.ewe@intel.com
Subject: Re: [PATCH v6] sound/soc/codecs: add LAPIS Semiconductor ML26124
Date: Wed, 29 Feb 2012 23:51:48 +0000	[thread overview]
Message-ID: <20120229235147.GM8295@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1329976011-2251-1-git-send-email-tomoya.rohm@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3325 bytes --]

On Thu, Feb 23, 2012 at 02:46:49PM +0900, Tomoya MORINAGA wrote:

> +	SOC_SINGLE_TLV("Playback Limitter Min Input Volume",
> +			ML26124_PL_MAXMIN_GAIN, 0, 7, 0, mingain),

Limiter.

> +	SOC_SINGLE("Zero Cross Comparator Switch", ML26124_PW_ZCCMP_PW_MNG, 1,
> +		    1, 0),

Usually just "ZC Switch".

> +	SOC_SINGLE("Digital Switch", ML26124_DVOL_CTL, 4, 1, 0),

This should probably be Digital Playback Switch so it lines up with the
volume control in the UIs (and the Volume controls should be Digital X
Volume).

> +static int ml26124_update_bits(struct snd_soc_codec *codec, unsigned short reg,
> +				unsigned int mask, unsigned int value)

Why are you open coding this in your driver?  There is no point in
replicating subsystem functionality.

> +if (!priv)
> +	return -1;
> +

Coding style and return real error codes (though this looks like it
should never happen).

> +static int ml26124_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
> +				  int div_id, int div)
> +{
> +	struct snd_soc_codec *codec = codec_dai->codec;
> +
> +	switch (div_id) {
> +	case ML26124_MCLK:
> +		ml26124_update_bits(codec, ML26124_CLK_CTL,
> +				      BIT(0) | BIT(1), div);
> +		break;

Why can't the driver calculate this automatically given the MCLK?

> +	case SND_SOC_BIAS_ON:
> +		pr_debug("%s: level=ON priv=%p\n", __func__, priv);

There's already more than enough logging in the subsystem for this.

> +		/* VMID ON */
> +		ml26124_update_bits(codec, ML26124_PW_REF_PW_MNG,
> +				    ML26124_VMID, ML26124_VMID);
> +		msleep(500);

This looks like it should be _STANDBY - usually VMID must be on to power
everything else.

> +static int ml26124_pcm_trigger(struct snd_pcm_substream *substream,
> +			      int cmd, struct snd_soc_dai *codec_dai)
> +{
> +	struct snd_soc_codec *codec = codec_dai->codec;
> +
> +	switch (cmd) {
> +	case SNDRV_PCM_TRIGGER_STOP:
> +	case SNDRV_PCM_TRIGGER_SUSPEND:
> +	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
> +		ml26124_update_bits(codec, ML26124_REC_PLYBAK_RUN, 0x3,
> +				    0);

I'm not sure you've tested this, you can't do I2C I/O from atomic
context and trigger is atomic.  What does this control actually do?

> +		return 0;
> +		break;

Duplicate return and break here.

> +static int ml26124_resume(struct snd_soc_codec *codec)
> +{
> +	struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
> +
> +	regcache_sync(priv->regmap);
> +	ml26124_set_bias_level(codec, SND_SOC_BIAS_STANDBY);

Setting the bias level will duplicate the sync.

> +static int ml26124_probe(struct snd_soc_codec *codec)
> +{
> +	int ret;
> +	struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec);
> +	codec->control_data = priv->regmap;
> +
> +	ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
> +	if (ret < 0) {
> +		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
> +		return ret;
> +	}

You're mixing regmap API usage and ASoC level I2C, this should be
_REGMAP.

> +/* power down chip */
> +static struct snd_soc_codec_driver soc_codec_dev_ml26124 = {

This comment is misplaced.

> +static struct i2c_driver ml26124_i2c_driver = {
> +	.driver = {
> +		.name = "ml26124-codec",

No -codec, the device only does one thing.

> +static int __init ml26124_modinit(void)
> +{
> +	int ret;
> +
> +	ret = i2c_add_driver(&ml26124_i2c_driver);
> +	if (ret != 0)

module_i2c_driver().

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2012-02-29 23:51 UTC|newest]

Thread overview: 123+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-23  5:46 [PATCH v6] sound/soc/codecs: add LAPIS Semiconductor ML26124 Tomoya MORINAGA
2012-02-23  5:46 ` Tomoya MORINAGA
2012-02-23  5:46 ` [PATCH v3] sound/soc/lapis: add platform driver for ML7213 Tomoya MORINAGA
2012-02-23  5:46   ` Tomoya MORINAGA
2012-03-02 16:39   ` Mark Brown
2012-03-02 16:39     ` Mark Brown
2012-03-06  5:48     ` Tomoya MORINAGA
2012-03-06 11:52       ` Mark Brown
2012-03-06 11:52         ` Mark Brown
2012-03-07  1:30         ` Tomoya MORINAGA
2012-03-07  1:30           ` Tomoya MORINAGA
2012-03-07 11:46           ` Mark Brown
2012-03-07 11:46             ` Mark Brown
2012-03-08  2:06             ` Tomoya MORINAGA
2012-03-08  2:06               ` Tomoya MORINAGA
2012-03-08 11:05               ` Mark Brown
2012-03-08 11:05                 ` Mark Brown
2012-03-09  6:26                 ` Tomoya MORINAGA
2012-03-09  6:26                   ` Tomoya MORINAGA
2012-03-09  6:39                   ` [PATCH v4] " Tomoya MORINAGA
2012-03-19 12:00                     ` [PATCH v5] " Tomoya MORINAGA
2012-03-19 12:00                       ` Tomoya MORINAGA
2012-03-21 16:09                       ` Mark Brown
2012-03-21 16:09                         ` Mark Brown
2012-03-22  0:12                         ` Tomoya MORINAGA
2012-03-26 15:40                           ` Mark Brown
2012-03-26 15:40                             ` Mark Brown
2012-05-23  4:17                             ` Tomoya MORINAGA
2012-05-23  9:41                               ` Mark Brown
2012-05-23  9:41                                 ` Mark Brown
2012-05-23 23:46                                 ` Tomoya MORINAGA
2012-05-23 23:46                                   ` Tomoya MORINAGA
2012-05-24 10:07                                   ` Mark Brown
2012-05-24 10:07                                     ` Mark Brown
2012-05-25  9:30                                     ` Tomoya MORINAGA
2012-05-25  9:30                                       ` Tomoya MORINAGA
2012-05-25 10:20                                       ` Vinod Koul
2012-05-25 10:20                                         ` [alsa-devel] " Vinod Koul
2012-05-27 22:19                                         ` Mark Brown
2012-05-27 22:19                                           ` [alsa-devel] " Mark Brown
2012-05-30 10:50                                           ` Tomoya MORINAGA
2012-05-30 10:50                                             ` [alsa-devel] " Tomoya MORINAGA
2012-05-30 12:14                                             ` Mark Brown
2012-05-31  5:38                                               ` Tomoya MORINAGA
2012-05-31  5:38                                                 ` [alsa-devel] " Tomoya MORINAGA
2012-05-31 10:45                                                 ` Mark Brown
2012-05-31 10:45                                                   ` [alsa-devel] " Mark Brown
2012-06-01  8:13                                                   ` Tomoya MORINAGA
2012-06-01  8:13                                                     ` [alsa-devel] " Tomoya MORINAGA
2012-06-01  8:30                                                     ` Mark Brown
2012-06-01  8:30                                                       ` [alsa-devel] " Mark Brown
2012-06-11  7:05                                                       ` Tomoya MORINAGA
2012-06-11  7:05                                                         ` [alsa-devel] " Tomoya MORINAGA
2012-06-11  8:54                                                         ` Mark Brown
2012-06-11  8:54                                                           ` [alsa-devel] " Mark Brown
2012-06-13 10:41                                                           ` Tomoya MORINAGA
2012-06-13 10:41                                                             ` [alsa-devel] " Tomoya MORINAGA
2012-06-13 12:11                                                             ` Mark Brown
2012-06-13 12:11                                                               ` [alsa-devel] " Mark Brown
2012-05-28  5:35                                         ` Tomoya MORINAGA
2012-05-28  5:35                                           ` [alsa-devel] " Tomoya MORINAGA
2012-02-23  5:46 ` [PATCH v5] sound/soc/lapis: add machine driver for ML7213 Carrier Board Tomoya MORINAGA
2012-02-23  5:46   ` Tomoya MORINAGA
2012-03-02 13:05   ` Mark Brown
2012-03-02 13:05     ` Mark Brown
2012-03-06  5:49     ` Tomoya MORINAGA
2012-03-06 11:54       ` Mark Brown
2012-03-06 11:54         ` Mark Brown
2012-03-07  1:57         ` Tomoya MORINAGA
2012-03-07  1:57           ` Tomoya MORINAGA
2012-03-09  6:38           ` [PATCH v6] " Tomoya MORINAGA
2012-03-09  6:38             ` Tomoya MORINAGA
2012-03-14 14:45             ` Mark Brown
2012-03-14 14:45               ` Mark Brown
2012-03-15  4:50               ` Tomoya MORINAGA
2012-03-15 10:50                 ` Mark Brown
2012-03-15 10:50                   ` Mark Brown
2012-03-16  4:07                   ` Tomoya MORINAGA
2012-03-16  4:07                     ` Tomoya MORINAGA
2012-03-16 19:06                     ` Mark Brown
2012-03-16 19:06                       ` Mark Brown
2012-03-18 23:45                       ` Tomoya MORINAGA
2012-03-18 23:45                         ` Tomoya MORINAGA
2012-03-19 12:02                         ` [PATCH v7] " Tomoya MORINAGA
2012-03-19 19:21                           ` Mark Brown
2012-03-19 19:21                             ` Mark Brown
2012-03-21  0:51                             ` Tomoya MORINAGA
2012-03-21  0:51                               ` Tomoya MORINAGA
2012-02-29 23:51 ` Mark Brown [this message]
2012-02-29 23:51   ` [PATCH v6] sound/soc/codecs: add LAPIS Semiconductor ML26124 Mark Brown
2012-03-02  8:16   ` Tomoya MORINAGA
2012-03-02 12:58     ` Mark Brown
2012-03-06  3:03       ` Tomoya MORINAGA
2012-03-06 10:00         ` Mark Brown
2012-03-06 10:49           ` Tomoya MORINAGA
2012-03-06 12:12             ` Mark Brown
2012-03-06 12:12               ` Mark Brown
2012-03-07  2:16               ` Tomoya MORINAGA
2012-03-07  2:16                 ` Tomoya MORINAGA
2012-03-07 11:48                 ` Mark Brown
2012-03-08  2:24                   ` Tomoya MORINAGA
2012-03-08  2:24                     ` Tomoya MORINAGA
2012-03-08 11:47                     ` Mark Brown
2012-03-08 11:47                       ` Mark Brown
2012-03-09  6:37                       ` [PATCH v7] " Tomoya MORINAGA
2012-03-09  6:37                         ` Tomoya MORINAGA
2012-03-14 14:39                         ` Mark Brown
2012-03-14 14:39                           ` Mark Brown
2012-03-15  4:51                           ` Tomoya MORINAGA
2012-03-15  4:51                             ` [alsa-devel] " Tomoya MORINAGA
2012-03-14 17:40                     ` [alsa-devel] [PATCH v6] " Lars-Peter Clausen
2012-03-14 17:45                       ` Mark Brown
2012-03-14 17:45                         ` [alsa-devel] " Mark Brown
2012-03-15  6:29                       ` Tomoya MORINAGA
2012-03-15  6:29                         ` [alsa-devel] " Tomoya MORINAGA
2012-03-16  9:55                         ` Tomoya MORINAGA
2012-03-16  9:55                           ` [alsa-devel] " Tomoya MORINAGA
2012-03-17 21:52                           ` Mark Brown
2012-03-19 11:59                             ` [PATCH v8] " Tomoya MORINAGA
2012-03-19 19:07                               ` Mark Brown
2012-03-19 19:07                                 ` Mark Brown
2012-03-21  0:57                                 ` Tomoya MORINAGA
2012-03-21  0:57                                   ` Tomoya MORINAGA

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=20120229235147.GM8295@opensource.wolfsonmicro.com \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=joel.clark@intel.com \
    --cc=kok.howg.ewe@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=qi.wang@intel.com \
    --cc=tiwai@suse.de \
    --cc=tomoya.rohm@gmail.com \
    --cc=yong.y.wang@intel.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.