public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Bo Shen <voice.shen@atmel.com>
Cc: nicolas.ferre@atmel.com, plagnioj@jcrosoft.com,
	linux-sound@vger.kernel.org, alsa-devel@alsa-project.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] ASoC: atmel: add wm8904 based audio machine driver
Date: Thu, 18 Jul 2013 11:17:09 +0000	[thread overview]
Message-ID: <20130718111709.GL22506@sirena.org.uk> (raw)
In-Reply-To: <1374132483-25375-1-git-send-email-voice.shen@atmel.com>

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

On Thu, Jul 18, 2013 at 03:28:03PM +0800, Bo Shen wrote:
> add wm8904 based audio machine driver
> 
> the following ek board based on it
>   - at91sam9n12ek
>   - sama5d3xek (d31, d33, d34, d35)
> 
> Signed-off-by: Bo Shen <voice.shen@atmel.com>

Looks pretty good, a few fairly small issues below.

The binding document should be CCed to devicetree-discuss for review.

> +	atmel,audio-routing =
> +		"Headphone Jack", "HPOUTL",
> +		"Headphone Jack", "HPOUTR",
> +		"IN2L", "Line In Jack",
> +		"IN2R", "Line In Jack",
> +		"Mic", "MICBIAS",
> +		"IN1L", "Mic";

The widgets defined by the board should be documented in this binding.
Those from the CODEC should be documented in the CODEC binding.

> +#define MCLK_RATE 32768
> +
> +static struct clk *mclk;

This should be in driver data for the board.  Shouldn't the clock be
referenced using the clock bindings?

> +static int atmel_asoc_wm8904_init(struct snd_soc_pcm_runtime *rtd)
> +{
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	int ret;
> +
> +	ret = snd_soc_dai_set_sysclk(codec_dai, WM8904_CLK_FLL,
> +			12000000, SND_SOC_CLOCK_IN);
> +	if (ret < 0) {
> +		pr_err("%s -failed to set wm8904 SYSCLK\n", __func__);
> +		return ret;
> +	}

This is an odd thing to set the clock rate to and limits the sample
rates the board can play back.  It would be better to set the clock rate
based on the requested sample rate in hw_params - you're using the FLL
so may as well take advantage of the ability it offers to support all
sample rates.

> +static int atmel_asoc_wm8904_params(struct snd_pcm_substream *substream,
> +		struct snd_pcm_hw_params *params)
> +{
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	int ret;
> +
> +	ret = snd_soc_dai_set_pll(codec_dai, WM8904_FLL_MCLK, WM8904_FLL_MCLK,
> +		32768, params_rate(params) * 256);

Ah, in fact you do actually do that - it'd be clearer to put the
set_sysclk() after this.

> +	switch (level) {
> +	case SND_SOC_BIAS_ON:
> +	case SND_SOC_BIAS_PREPARE:
> +		if (!mclk_on) {
> +			ret = clk_prepare_enable(mclk);
> +			if (ret == 0)
> +				mclk_on = 1;
> +		}
> +		break;
> +	case SND_SOC_BIAS_STANDBY:
> +	case SND_SOC_BIAS_OFF:
> +		if (mclk_on)
> +			clk_disable_unprepare(mclk);
> +		mclk_on = 0;
> +		break;
> +	}

It's better to write this using the previous state than to have the
mclk_on flag - you want to enable on the standby->prepare transition and
disable on the standby->off transition.

> +static int atmel_asoc_wm8904_dt_init(struct platform_device *pdev)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	struct device_node *codec_np, *cpu_np;
> +	struct snd_soc_card *card = &atmel_asoc_wm8904_card;
> +	struct snd_soc_dai_link *dailink = &atmel_asoc_wm8904_dailink;
> +	int ret;
> +
> +	if (!np)
> +		return -1;

Return a real error code here.

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

  reply	other threads:[~2013-07-18 11:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-18  7:28 [PATCH] ASoC: atmel: add wm8904 based audio machine driver Bo Shen
2013-07-18 11:17 ` Mark Brown [this message]
2013-07-19  2:39   ` Bo Shen
2013-07-19  6:06     ` [alsa-devel] " Bo Shen
2013-07-19 10:32       ` Mark Brown
2013-07-19  9:42 ` Bo Shen
2013-07-19 18:06   ` 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=20130718111709.GL22506@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=voice.shen@atmel.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