All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liam Girdwood <lrg@slimlogic.co.uk>
To: Marek Vasut <marek.vasut@gmail.com>
Cc: alsa-devel@alsa-project.org, broonie@opensource.wolfsonmicro.com
Subject: Re: [PATCH] WM8750: Convert to new API
Date: Fri, 26 Mar 2010 10:08:12 +0000	[thread overview]
Message-ID: <1269598092.3757.48.camel@odin> (raw)
In-Reply-To: <1269570193-8151-1-git-send-email-marek.vasut@gmail.com>

On Fri, 2010-03-26 at 03:23 +0100, Marek Vasut wrote:
> Register the WM8750 as a SPI or I2C device. This patch mostly shuffles code
> around. Hugely inspired by WM8753 which was already converted.
> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> ---
>  sound/soc/codecs/wm8750.c |  411 +++++++++++++++++++++++++--------------------
>  1 files changed, 232 insertions(+), 179 deletions(-)
> 

This looks mostly fine. Just a comment on the codec IO.

> diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
> index 475c67a..c7ee6d2 100644
> --- a/sound/soc/codecs/wm8750.c
> +++ b/sound/soc/codecs/wm8750.c
> @@ -29,13 +29,6 @@
>  
>  #include "wm8750.h"
>  
> -#define WM8750_VERSION "0.12"
> -
> -/* codec private data */
> -struct wm8750_priv {
> -	unsigned int sysclk;
> -};
> -
>  /*
>   * wm8750 register cache
>   * We can't read the WM8750 register space when we
> @@ -55,6 +48,59 @@ static const u16 wm8750_reg[] = {
>  	0x0079, 0x0079, 0x0079,          /* 40 */
>  };
>  
> +/* codec private data */
> +struct wm8750_priv {
> +	unsigned int sysclk;
> +	struct snd_soc_codec codec;
> +	u16 reg_cache[ARRAY_SIZE(wm8750_reg)];
> +};
> +
> +/*
> + * read wm8750 register cache
> + */
> +static inline unsigned int wm8750_read_reg_cache(struct snd_soc_codec *codec,
> +	unsigned int reg)
> +{
> +	u16 *cache = codec->reg_cache;
> +	if (reg < 1 || reg >= (ARRAY_SIZE(wm8750_reg) + 1))
> +		return -1;
> +	return cache[reg - 1];
> +}
> +
> +/*
> + * write wm8750 register cache
> + */
> +static inline void wm8750_write_reg_cache(struct snd_soc_codec *codec,
> +	unsigned int reg, unsigned int value)
> +{
> +	u16 *cache = codec->reg_cache;
> +	if (reg < 1 || reg >= (ARRAY_SIZE(wm8750_reg) + 1))
> +		return;
> +	cache[reg - 1] = value;
> +}
> +
> +/*
> + * write to the WM8750 register space
> + */
> +static int wm8750_write(struct snd_soc_codec *codec, unsigned int reg,
> +	unsigned int value)
> +{
> +	u8 data[2];
> +
> +	/* data is
> +	 *   D15..D9 WM8750 register offset
> +	 *   D8...D0 register data
> +	 */
> +	data[0] = (reg << 1) | ((value >> 8) & 0x0001);
> +	data[1] = value & 0x00ff;
> +
> +	wm8750_write_reg_cache(codec, reg, value);
> +	if (codec->hw_write(codec->control_data, data, 2) == 2)
> +		return 0;
> +	else
> +		return -EIO;
> +}
> +

We should probably use the codec IO helpers in soc-cache.c for codec
read/write() e.g.

snd_soc_codec_set_cache_io(codec, 7, 9, wm8750->control_type);

This can set up the WM8750 for 7 address bits and 9 data bits and mean
less code in the driver.

Thanks

Liam

-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

  reply	other threads:[~2010-03-26 10:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-26  2:23 [PATCH] WM8750: Convert to new API Marek Vasut
2010-03-26 10:08 ` Liam Girdwood [this message]
2010-03-26 10:39 ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2010-03-26 14:19 Marek Vasut
2010-03-26 16:37 ` Liam Girdwood
2010-03-29 12:48 ` Mark Brown
2010-03-29 21:16   ` Marek Vasut
2010-03-30  9:40     ` Mark Brown
2010-04-04 23:45       ` Marek Vasut
2010-04-05 13:41 [PATCH 2/3] WM8750: Fix SPITZ machine Mark Brown
2010-04-08 14:51 ` [PATCH] WM8750: Convert to new API Marek Vasut
2010-04-08 14:51   ` Marek Vasut
2010-04-08 14:58   ` Mark Brown
2010-04-08 14:58     ` Mark Brown
2010-04-08 14:59 Marek Vasut
2010-04-08 14:59 ` Marek Vasut
2010-04-08 15:05 ` Mark Brown
2010-04-08 18:48 Marek Vasut
2010-04-08 18:48 ` Marek Vasut
2010-04-09 11:50 ` Liam Girdwood
2010-04-09 12:00 ` Mark Brown
2010-04-09 12:00   ` 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=1269598092.3757.48.camel@odin \
    --to=lrg@slimlogic.co.uk \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=marek.vasut@gmail.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.