From: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
To: Lu Guanqun <guanqun.lu@intel.com>
Cc: ALSA <alsa-devel@alsa-project.org>, Takashi Iwai <tiwai@suse.de>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Wang Xingchao <xingchao.wang@intel.com>,
Koul Vinod <vinod.koul@intel.com>, Liam Girdwood <lrg@ti.com>
Subject: Re: [PATCH 01/19] ASoC: upd9976: Add Renesas uPD9976 codec driver
Date: Wed, 4 May 2011 15:46:00 +0100 [thread overview]
Message-ID: <20110504144600.GA7366@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <20110504134458.32443.45825.stgit@localhost>
On Wed, May 04, 2011 at 09:44:58PM +0800, Lu Guanqun wrote:
> uPD9976 is a complex codec, however this patch only provides basic playback
> functionality for headphone. More functionality will be added bit by bit in the
> following patches.
>
> Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
> Signed-off-by: Wang Xingchao <xingchao.wang@intel.com>
> +static inline unsigned int upd9976_read(struct snd_soc_codec *codec,
> + unsigned int reg)
> +{
> + u8 value = 0;
> + int ret;
> +
> + ret = intel_scu_ipc_ioread8(reg, &value);
> + if (ret)
> + pr_err("upd9976 read of 0x%x failed, error: %d\n", reg, ret);
> + return value;
> +}
dev_err() would be more preferable.
> +static int upd9976_audio_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
> +{
> + struct snd_soc_codec *codec = dai->codec;
> + unsigned int mode, mask;
> +
> + mask = BIT(5) | BIT(4);
> + mode = 0;
> +
> + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
> + case SND_SOC_DAIFMT_I2S:
> + mode |= BIT(4);
> + break;
> + case SND_SOC_DAIFMT_RIGHT_J:
> + mode |= BIT(5);
> + break;
> + case SND_SOC_DAIFMT_LEFT_J:
> + mode |= BIT(5) | BIT(4);
> + break;
> + }
> +
> + mask |= BIT(7) | BIT(3);
> +
> + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
> + case SND_SOC_DAIFMT_CBM_CFM:
> + case SND_SOC_DAIFMT_CBM_CFS:
> + mode |= BIT(7) | BIT(3);
> + break;
> + }
> +
> + return snd_soc_update_bits(codec, UPD9976_AUDIOPORT1, mask, mode);
> +}
I am not sure whether the BIT() macro is more confusing than helpful.
> +static int upd9976_audio_hw_params(struct snd_pcm_substream *substream,
> + struct snd_pcm_hw_params *params,
> + struct snd_soc_dai *dai)
> +{
> + struct snd_soc_codec *codec = dai->codec;
> + unsigned int tmp;
> +
> + switch (params_format(params)) {
> + case SNDRV_PCM_FORMAT_S16_LE:
> + tmp = 0x00;
> + break;
> + case SNDRV_PCM_FORMAT_S24_LE:
> + tmp = 0x03;
> + break;
> + case SNDRV_PCM_FORMAT_S18_3LE:
> + tmp = 0x01;
> + break;
> + case SNDRV_PCM_FORMAT_S20_3LE:
> + tmp = 0x02;
> + break;
> + default:
> + return -EINVAL;
> + }
> + snd_soc_update_bits(codec, UPD9976_AUDIOPORT1,
> + BIT(2)|BIT(1)|BIT(0), tmp);
> +
> + switch (params_rate(params)) {
> + case 8000:
> + tmp = 0x00;
> + break;
> + case 11025:
> + tmp = 0x01;
> + break;
> + case 12000:
> + tmp = 0x02;
> + break;
> + case 16000:
> + tmp = 0x03;
> + break;
> + case 22050:
> + tmp = 0x04;
> + break;
> + case 24000:
> + tmp = 0x05;
> + break;
> + case 32000:
> + tmp = 0x07;
> + break;
> + case 44100:
> + tmp = 0x08;
> + break;
> + case 48000:
> + tmp = 0x09;
> + break;
> + default:
> + return -EINVAL;
> + }
Looks fine, I'd rather use an array though.
> +static int upd9976_set_bias_level(struct snd_soc_codec *codec,
> + enum snd_soc_bias_level level)
> +{
> + switch (level) {
> + case SND_SOC_BIAS_ON:
> + break;
> +
> + case SND_SOC_BIAS_PREPARE:
> + if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) {
> + snd_soc_update_bits(codec, UPD9976_VAUDIOCNT,
> + 0x27, 0x27);
> + snd_soc_update_bits(codec, UPD9976_VREFPLL,
> + 0x35, 0x35);
> + }
> + break;
> +
> + case SND_SOC_BIAS_STANDBY:
> + snd_soc_write(codec, UPD9976_VAUDIOCNT, 0x25);
> + snd_soc_write(codec, UPD9976_VREFPLL, 0x10);
> + break;
> +
> + case SND_SOC_BIAS_OFF:
> + snd_soc_write(codec, UPD9976_VREFPLL, 0);
> + snd_soc_write(codec, UPD9976_VAUDIOCNT, 0x24);
> + break;
> + }
Why not snd_soc_update_bits()? These should normally be DAPM widgets.
> +static int upd9976_codec_probe(struct snd_soc_codec *codec)
> +{
> + upd9976_set_bias_level(codec, SND_SOC_BIAS_OFF);
> +
> + return 0;
> +}
Why SND_SOC_BIAS_OFF and not SND_SOC_BIAS_STANDBY?
> +static int upd9976_codec_remove(struct snd_soc_codec *codec)
> +{
> + return 0;
> +}
You can call upd9976_set_bias_level(codec, SND_SOC_BIAS_OFF) here.
Thanks,
Dimitris
next prev parent reply other threads:[~2011-05-04 14:46 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-04 13:44 [PATCH 00/19] ASoC for moorestown Lu Guanqun
2011-05-04 13:44 ` [PATCH 01/19] ASoC: upd9976: Add Renesas uPD9976 codec driver Lu Guanqun
2011-05-04 14:34 ` Mark Brown
2011-05-04 15:05 ` Lu Guanqun
2011-05-05 3:14 ` Koul, Vinod
2011-05-05 3:51 ` Lu Guanqun
2011-05-04 15:07 ` Takashi Iwai
2011-05-04 15:18 ` Lu Guanqun
2011-05-04 15:38 ` Takashi Iwai
2011-05-04 16:15 ` Mark Brown
2011-05-05 0:33 ` Lu Guanqun
2011-05-05 0:30 ` Lu Guanqun
2011-05-04 16:13 ` Mark Brown
2011-05-05 16:26 ` Lu Guanqun
2011-05-06 9:37 ` Mark Brown
2011-05-04 14:46 ` Dimitris Papastamos [this message]
2011-05-04 15:12 ` Lu Guanqun
2011-05-04 16:11 ` Mark Brown
2011-05-05 3:12 ` Koul, Vinod
2011-05-05 8:07 ` Mark Brown
2011-05-04 13:45 ` [PATCH 02/19] ASoC: sst_platform: add cpu dai driver for moorestown platform Lu Guanqun
2011-05-05 3:23 ` Koul, Vinod
2011-05-05 4:48 ` Lu Guanqun
2011-05-05 9:26 ` Koul, Vinod
2011-05-05 8:05 ` Mark Brown
2011-05-05 9:28 ` Koul, Vinod
2011-05-05 10:26 ` Mark Brown
2011-05-05 10:00 ` Koul, Vinod
2011-05-05 13:46 ` Mark Brown
2011-05-05 14:55 ` Koul, Vinod
2011-05-06 9:37 ` Mark Brown
2011-05-04 13:45 ` [PATCH 03/19] ASoC: mrst_machine: add moorestown machine driver Lu Guanqun
2011-05-04 14:55 ` Dimitris Papastamos
2011-05-04 15:25 ` Lu Guanqun
2011-05-04 13:45 ` [PATCH 04/19] ASoC: mrst_machine: add speaker widget to " Lu Guanqun
2011-05-04 16:17 ` Mark Brown
2011-05-04 13:45 ` [PATCH 05/19] ASoC: mrst_machine: enable user to select different output Lu Guanqun
2011-05-04 16:22 ` Mark Brown
2011-05-05 0:34 ` Lu Guanqun
2011-05-04 13:45 ` [PATCH 06/19] ASoC: upd9976: add capture ability for dai driver Lu Guanqun
2011-05-04 16:22 ` Mark Brown
2011-05-04 13:45 ` [PATCH 07/19] ASoC: sst_platform: add capture capability for cpu " Lu Guanqun
2011-05-04 13:45 ` [PATCH 08/19] ASoC: upd9976: add DMIC support Lu Guanqun
2011-05-04 15:03 ` Dimitris Papastamos
2011-05-04 15:20 ` Lu Guanqun
2011-05-04 13:45 ` [PATCH 09/19] ASoC: upd9976: add Analog MIC support Lu Guanqun
2011-05-04 13:45 ` [PATCH 10/19] ASoC: upd9976: add microphone bias support Lu Guanqun
2011-05-04 16:25 ` Mark Brown
2011-05-05 0:40 ` Lu Guanqun
2011-05-04 13:45 ` [PATCH 11/19] ASoC: upd9976: add jack detection function Lu Guanqun
2011-05-04 16:32 ` Mark Brown
2011-05-05 0:37 ` Lu Guanqun
2011-05-04 13:45 ` [PATCH 12/19] ASoC: mrst_machine: add capture functionality Lu Guanqun
2011-05-04 13:45 ` [PATCH 13/19] ASoC: mrst_machine: add jack detection support Lu Guanqun
2011-05-04 13:46 ` [PATCH 14/19] ASoC: upd9976: add mute switch for DMIC Lu Guanqun
2011-05-04 13:46 ` [PATCH 15/19] ASoC: upd9976: add mute switch for analog Lu Guanqun
2011-05-04 13:46 ` [PATCH 16/19] ASoC: mrst_machine: make DMIC's output to PCM2 mono Lu Guanqun
2011-05-04 13:46 ` [PATCH 17/19] ASoC: mrst_machine: make MIC2 pseudo-differential Lu Guanqun
2011-05-04 13:46 ` [PATCH 18/19] ASoC: upd9976: add capture volume for analog inputs Lu Guanqun
2011-05-04 13:46 ` [PATCH 19/19] ASoC: upd9976: add capture volume for DMIC Lu Guanqun
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=20110504144600.GA7366@opensource.wolfsonmicro.com \
--to=dp@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=guanqun.lu@intel.com \
--cc=lrg@ti.com \
--cc=tiwai@suse.de \
--cc=vinod.koul@intel.com \
--cc=xingchao.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 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).