[prev in list] [next in list] [prev in thread] [next in thread]
List: alsa-devel
Subject: [alsa-devel] ASoC: TI codecs and their crazy variable length registers
From: jonsmirl () gmail ! com (jonsmirl at gmail ! com)
Date: 2014-07-31 14:06:32
Message-ID: CAKON4Oy=FAH0NBoQaYBcsc1mxTSXJP1fT+bx2S=vyFUDp8BHuw () mail ! gmail ! com
[Download RAW message or body]
On Thu, Jul 31, 2014 at 3:01 AM, Lars-Peter Clausen <lars at metafoo.de> wrote:
> On 07/31/2014 01:17 AM, Mark Brown wrote:
>>
>> On Wed, Jul 30, 2014 at 05:56:36PM -0400, jonsmirl at gmail.com wrote:
>>
>>> I'm working on a TI codec attached via I2C. Just to make things
>>> interesting the registers have varying byte lengths of - 1,4,8,12,20
>>> bytes. What's the best strategy for using regmap with it?
>>
>>
>> I'd use the reg_read() and reg_write() callbacks to hide the registers
>> that will fit in an integer, the rest of the stack can pretend they've
>> got 32 bit values which should improve code reuse.[...]
>
>
> The adau1701 is a driver that for example does this.
>
Then use regmap_raw_read/regmap_raw_write for the registers over four bytes?
This might work generically if the size function was a regmap callback...
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[5];
int ret;
size = adau1701_register_size(&client->dev, reg);
if (size == 0)
return -EINVAL;
buf[0] = reg >> 8;
buf[1] = reg & 0xff;
for (i = size + 1; i >= 2; --i) {
buf[i] = value;
value >>= 8;
}
--
Jon Smirl
jonsmirl at gmail.com
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic