From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Rajeev Kumar <rajeev-dlh.kumar@st.com>
Cc: tiwai@suse.de, alsa-devel@alsa-project.org, lrg@slimlogic.co.uk
Subject: Re: [PATCH 2/2] sound: asoc: Adding support for STA529 Audio Codec
Date: Thu, 17 Mar 2011 15:17:43 +0000 [thread overview]
Message-ID: <20110317151743.GH31411@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1300361016-26242-3-git-send-email-rajeev-dlh.kumar@st.com>
On Thu, Mar 17, 2011 at 04:53:36PM +0530, Rajeev Kumar wrote:
> +#define STA529_VERSION "0.1"
> +static const u8 sta529_reg[STA529_CACHEREGNUM] = {
Remove the version number, the kernel version should be good enough.
Also check the vertical spacing in your code - there should be a blank
between the above two.
> +/* reading from register cache: sta529 register value */
> +static inline unsigned int
> +sta529_read_reg_cache(struct snd_soc_codec *codec, u32 reg)
Use the generic register cache code - this looks to be a very 8 bit data
8 bit address map.
> + val = sta529_read_reg_cache(codec, STA529_S2PCFG0);
> + val |= mode;
> + /*this setting will be used with actual h/w */
> + sta529_write(codec, STA529_S2PCFG0, val);
Use snd_soc_update_bits() - this will fix the issue you currently have
where you'll never clear bits which were previously set.
> +spear_sta_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id,
> + unsigned int freq, int dir)
> +{
> + int ret = -EINVAL;
> + struct clk *clk;
> +
> + clk = clk_get_sys(NULL, "i2s_ref_clk");
> + if (IS_ERR(clk)) {
> + ret = PTR_ERR(clk);
> + goto err_clk;
> + }
> + if (clk_set_rate(clk, freq))
> + goto err_put_clk;
Your CODEC driver shouldn't be requesting clocks that are part of the
CPU. Just let the machine driver tell you what the clock rate is and
let it worry about making sure the clock is actually there.
> + struct snd_soc_codec *codec = dai->codec;
> +
> + u8 mute_reg = sta529_read_reg_cache(codec, STA529_FFXCFG0) &
> + ~CODEC_MUTE_VAL;
> +
> + if (mute)
> + mute_reg |= CODEC_MUTE_VAL;
> +
> + sta529_write(codec, STA529_FFXCFG0, mute_reg);
snd_soc_update_bits().
> + switch (level) {
> + case SND_SOC_BIAS_ON:
> + case SND_SOC_BIAS_PREPARE:
> + sta529_write(codec, STA529_FFXCFG0, sts & POWER_STBY);
> + break;
> + case SND_SOC_BIAS_STANDBY:
> + case SND_SOC_BIAS_OFF:
> + sta529_write(codec, STA529_FFXCFG0, sts | ~POWER_STBY);
> +
> + break;
Odd indentation here too.
> + dev_info(codec->dev, "spear Audio Codec %s", STA529_VERSION);
Remove this - if you were reading something like the chip revision from
the device announcing that would be fine.
> + cache = codec->reg_cache;
> + for (i = 0; i < ARRAY_SIZE(sta529_reg); i++) {
> + data[0] = i;
> + data[1] = cache[i];
> + codec->hw_write(codec->control_data, data, NUM_OF_MSG);
> + }
You should be using the chip defaults for the most part and therefore
should have no reason to write back to hardware in probe()
> + .name = "sta529-codec",
Drop the -codec.
> +#define SPEAR_PCM_RATES SNDRV_PCM_RATE_48000
> +#define SPEAR_PCM_FORMAT SNDRV_PCM_FMTBIT_S16_LE
These are for your CPU not for your CODEC, even if they're the same they
should have different names.
> +#define S2PC_VALUE 0x98
> +#define CLOCK_OUT 0x60
> +#define LEFT_J_DATA_FORMAT 0x00
> +#define I2S_DATA_FORMAT 0x02
> +#define RIGHT_J_DATA_FORMAT 0x04
> +#define RIGHT_J_DATA_FORMAT 0x04
> +#define CODEC_MUTE_VAL 0x80
> +#define NUM_OF_MSG 2
> +#define POWER_STBY 0xBF
All these should be namespaced or moved into the driver.
next prev parent reply other threads:[~2011-03-17 15:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-17 11:23 [PATCH 0/2] Adding support for ASoC drivers on SPEAr13XX platform Rajeev Kumar
2011-03-17 11:23 ` [PATCH 1/2] sound: asoc: Adding support for SPEAr13XX ASoC driver Rajeev Kumar
2011-03-17 11:23 ` [PATCH 2/2] sound: asoc: Adding support for STA529 Audio Codec Rajeev Kumar
2011-03-17 15:17 ` Mark Brown [this message]
2011-03-18 6:12 ` rajeev
2011-03-18 11:39 ` Mark Brown
2011-03-21 11:29 ` rajeev
2011-03-21 12:07 ` Mark Brown
2011-03-22 5:53 ` rajeev
2011-03-22 11:34 ` Mark Brown
2011-03-17 15:05 ` [PATCH 1/2] sound: asoc: Adding support for SPEAr13XX ASoC driver Mark Brown
2011-03-18 7:19 ` rajeev
2011-03-18 11:43 ` Mark Brown
2011-03-21 11:29 ` rajeev
2011-03-29 6:54 ` rajeev
2011-03-29 7:56 ` 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=20110317151743.GH31411@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=lrg@slimlogic.co.uk \
--cc=rajeev-dlh.kumar@st.com \
--cc=tiwai@suse.de \
/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).