From: Lars-Peter Clausen <lars@metafoo.de>
To: Daniel Mack <zonque@gmail.com>
Cc: alsa-devel@alsa-project.org, broonie@kernel.org
Subject: Re: [PATCH 3/4] ASoC: codecs: adau1701: switch to direct regmap API usage
Date: Sun, 09 Jun 2013 19:39:32 +0200 [thread overview]
Message-ID: <51B4BDD4.4070302@metafoo.de> (raw)
In-Reply-To: <1370605987-19290-4-git-send-email-zonque@gmail.com>
[...]
> +
> +static int adau1701_reg_write(void *context, unsigned int reg,
> + unsigned int value)
> +{
> + struct i2c_client *client = context;
> unsigned int i;
> unsigned int size;
> uint8_t buf[4];
> int ret;
>
> - size = adau1701_register_size(codec, reg);
> + size = adau1701_register_size(&client->dev, reg);
> if (size == 0)
> return -EINVAL;
>
> - snd_soc_cache_write(codec, reg, value);
> -
> buf[0] = 0x08;
This was actually a hack to let the register range start at 0x00. All the
configuration register start at 0x0800. Since we are using regmap now we
shouldn't need this anymore.
> buf[1] = reg;
>
> @@ -166,7 +177,7 @@ static int adau1701_write(struct snd_soc_codec *codec, unsigned int reg,
> value >>= 8;
> }
>
> - ret = i2c_master_send(to_i2c_client(codec->dev), buf, size + 2);
> + ret = i2c_master_send(client, buf, size + 2);
> if (ret == size + 2)
> return 0;
> else if (ret < 0)
> @@ -175,16 +186,47 @@ static int adau1701_write(struct snd_soc_codec *codec, unsigned int reg,
> return -EIO;
> }
>
> -static unsigned int adau1701_read(struct snd_soc_codec *codec, unsigned int reg)
> +static int adau1701_reg_read(void *context, unsigned int reg,
> + unsigned int *value)
> {
> - unsigned int value;
> - unsigned int ret;
> + int ret;
> + unsigned int i;
> + unsigned int size;
> + uint8_t send_buf[2], recv_buf[3];
> + struct i2c_client *client = context;
> + struct i2c_msg msgs[2] = {
> + {
> + .addr = client->addr,
> + .len = sizeof(send_buf),
> + .buf = send_buf,
> + },
> + {
> + .addr = client->addr,
> + .len = sizeof(recv_buf),
The length depends on the register size
> + .buf = recv_buf,
> + .flags = I2C_M_RD | I2C_M_STOP,
> + },
> + };
> +
> + size = adau1701_register_size(&client->dev, reg);
> + if (size == 0)
> + return -EINVAL;
>
> - ret = snd_soc_cache_read(codec, reg, &value);
> - if (ret)
> + send_buf[0] = 0x08;
> + send_buf[1] = reg;
> +
> + ret = i2c_transfer(client->adapter, msgs, 2);
ARRAY_SIZE(msgs)
> + if (ret < 0)
> return ret;
> + else if (ret != 2)
same here
> + return -EIO;
> +
> + *value = 0;
> +
> + for (i = 0; i < size; i++)
> + *value |= recv_buf[i] << (i * 8);
hm, how about:
*value <<= 8
*value |= recv_buf[i];
>
> - return value;
> + return 0;
> }
[...]
next prev parent reply other threads:[~2013-06-09 17:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 11:53 [PATCH 0/4] ASoC: codecs: some more improvements for adau1701 Daniel Mack
2013-06-07 11:53 ` [PATCH 1/4] ASoC: codecs: adau1701: factor out firmware reset Daniel Mack
2013-06-10 13:08 ` Lars-Peter Clausen
2013-06-10 13:09 ` Mark Brown
2013-06-07 11:53 ` [PATCH 2/4] ASoC: codecs: adau1701: allow configuration of PLL mode pins Daniel Mack
2013-06-09 17:12 ` Lars-Peter Clausen
2013-06-07 11:53 ` [PATCH 3/4] ASoC: codecs: adau1701: switch to direct regmap API usage Daniel Mack
2013-06-09 17:39 ` Lars-Peter Clausen [this message]
2013-06-07 11:53 ` [PATCH 4/4] ASoC: codecs: adau1701: add support for pin muxing Daniel Mack
2013-06-09 17:43 ` Lars-Peter Clausen
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=51B4BDD4.4070302@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=zonque@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.