History log of /sound/soc/soc-cache.c
Revision Date Author Comments
e9c039052be59753e6bcc7c8b59763899dc1161c 13-Jun-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Remove unused and about to be broken SND_SOC_CUSTOM I/O bus

This will be removed in -next so let's drop it from mainline as soon as
we can in order to minimise surprises.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
fd137e2bba53b7207cbae6a1312e89ef3ae55624 06-Jun-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Check for NULL register bank in snd_soc_get_cache_val()

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
f7391fce6a1553ed3375ee4d73f2deaa3fd69732 11-May-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Reintroduce do_spi_write()

There is an unfortunate difference in return values between spi_write()
and i2c_master_send() so we need an adaptor function to translate.

Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
6e28f976ec73aec688bf89a63ac719ba765e9360 10-May-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Use spi_write() for SPI writes

do_spi_write() is just an open coded copy of do_spi_write() so we can
delete it and just call spi_write() directly. Indeed, as a result of
recent refactoring all the SPI write functions are just very long
wrappers around spi_write() which don't add anything except for some
pointless copies so we can just use spi_write() as the hw_write
operation directly. It should be as type safe to do this as it is to do
the same thing with I2C and it saves us a bunch of code.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
063b7cc43fb2413238095b81f9b4a2ee2c52056b 10-May-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Remove byte swap in 4x12 SPI write

snd_soc_4_12_spi_write() contains a byte swap. Since this code was written
for an Analog CODEC on a Blackfin reference board it appears that this is
done because while Blackfin is little endian the CODEC is big endian (as
are most CODECs).

Push this up into the generic 4x12 write function and use cpu_to_be16() to
do the byte swap so things are more regular and things work on both CPU
endiannesses.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
051e994e9506e64259df34e91b028fe2470fbf2a 11-May-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Don't squash 16x8 registers down to 8 bits

Currently we'll force all registers to fit in 8 bits before passing
down to the I/O function. Looks like a cut'n'paste bug.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
64d27069755db41daa36e4770d88ebc57617559d 05-May-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Allow codec->cache_bypass to be used with snd_soc_hw_bulk_write_raw()

If we specifically want to write a block of data to the hw bypassing the
cache, then allow this to happen inside snd_soc_hw_bulk_write_raw().

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
f9861e17bd078f0a8c234157ddade03572415f8f 20-Apr-2011 Lu Guanqun <guanqun.lu@intel.com> ASoC: remove unused comment

`type` parameter is not longer used in `snd_soc_codec_set_cache_io`,
so remove this line.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
34bad69cf63efc761b05f603d99e121b83635c08 04-Apr-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Fix comment width in soc-cache.c

Lines should be less than 80 columns.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
d420d40e9c044e8fae7957ed82cd63d2afe4147f 04-Apr-2011 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Remove excessively verbose logging on I2C write

We don't need to log every I2C transfer, and certainly not at error level.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
898f8b0b65715843f7afd86f3867270dc9ed8b74 04-Apr-2011 Seungwhan Youn <sw.youn@samsung.com> ASoC: Fix to avoid compile error

This patch fixes to avoid compile error when ASoC codec doesn't use I2C
nor SPI on snd_soc_hw_bulk_write_raw().

Signed-off-by: Seungwhan Youn <sw.youn@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
f20eda5d8fafe35ca3c63ec8149a700a7db228a5 28-Mar-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Warn on syncing any non-writable registers

When syncing the cache, if the driver has given us a writable_register()
callback, use it to check if we are syncing a non-writable register
and if so warn the user.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
fbda18245beff52ec1edf096e7a77d4cdf3effb9 28-Mar-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Fix indentation issues

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
8020454c9a1ec5ac5801805896b5f69d0c573e17 24-Mar-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: Add default snd_soc_default_writable_register() callback

By using struct snd_soc_reg_access for the read/write/vol attributes
of the registers, we provide callbacks that automatically determine whether
a given register is readable/writable or volatile.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
acd61451e55ea5848a6ab50d39a103e146fcf7ba 22-Mar-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Return -ENOSYS instead of -EINVAL

These functions fail with -EINVAL if the corresponding callbacks
are not implemented. Change them to return -ENOSYS as it is more
appropriate for unimplemented callbacks.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
30539a18d366cff6b21f66a81e4d9dccc4a90c89 22-Mar-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Factor-out the SPI write code

The handling of all snd_soc_x_y_spi_write() functions is similar.
Create a separate function and update all callers to use it.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
b8cbc195202d05efcda6af81c669577e3cb793e5 22-Mar-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Factor-out the hw_read() specific code

The handling of all snd_soc_x_y_read() functions is similar.
Factor it out into a separate function and update all callers.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
26e9984cbcdde100e5af15382f2297fef1ce7804 22-Mar-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Factor-out the hw_write() specific code

The handling of all snd_soc_x_y_write() functions is similar.
Factor it out into a separate function and update all functions
to use it.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
5fb609d435f0679ed322ddeb1fdafe6142463fdf 22-Mar-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Introduce raw bulk write support

As it has become more common to have to write firmware or similar
large chunks of data to the hardware, add a function to perform
raw bulk writes that bypass the cache. This only handles volatile
registers as we should avoid getting out of sync with the actual
cache.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
f3594f5c5c489d159f6d487a889d9d68ca4c0123 22-Mar-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Factor-out the I2C read code

The handling of all snd_soc_x_y_read_i2c() functions is similar.
Make a generic I2C read function and update all callers to use it.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
46fdaa3bec1bcaa36759b1f5e5e27245ae465b8f 07-Feb-2011 Dan Carpenter <error27@gmail.com> ASoC: soc-cache: dereferencing before checking

The patch c358e640a66 "ASoC: soc-cache: Add trace event for
snd_soc_cache_sync()" introduced a dereference of "codec->cache_ops"
before we had checked it for NULL.

I pulled the check forward, and then pulled everything in an indent
level.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
c358e640a669b528b32af5442c92b856de623e1c 21-Jan-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Add trace event for snd_soc_cache_sync()

This patch makes it easy to see when the syncing process begins and
ends. You can also enable the snd_soc_reg_write tracepoint to see
which registers are being synced.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
9978007befa5efdc16dc940631c594f420f96b09 19-Jan-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Apply the cache_bypass option

Incorporate the use of the cache_bypass functionality in the
syncing functions. The snd_soc_flat_cache_sync() need not be
hooked as there is no performance benefit from using the
cache_bypass option.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
dad8e7aeeb83a26d267e757e4c1cf69591850477 19-Jan-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Introduce the cache_bypass option

This is primarily needed to avoid writing back to the cache
whenever we are syncing the cache with the hardware. This gives a
performance benefit especially for large register maps.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
066d16c3e8194677a9aaeb06a45e4014387d16f1 13-Jan-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Add support for default readable()/volatile() functions

For common scenarios, device drivers can provide a table of all the
registers that are at least either readable/writable/volatile. The idea
is that if a register lookup fails, all of its read/write/vol members
will be zero and will be treated as default. This also reduces the
size of the register access array.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
aea170a099793abcd0e6de46b947458073204241 12-Jan-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Add reg_size as a member to snd_soc_codec

Simplify the use of reg_size, by calculating it once and storing it in
the codec structure for later reference. The value of reg_size is
reg_cache_size * reg_word_size.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
d779fce5d79525d66269c8f6e430e1515d697f3d 12-Jan-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Ensure flat compression uses a copy of the defaults cache

With the addition of the cache fallback functionality, it is necessary
to ensure that if the register defaults cache was marked as __devinitconst
and the LZO compression is not compiled in the kernel, the fallback to
flat compression will still use a copy of the defaults cache.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
1321e8838bf9bbc883450675d5c501cb8510f1a4 11-Jan-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Clean up the cache manipulation code

Use Takashi's clean up code to make the cache manipulation code more
readable.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
04f8fd176c9c105dc0025486cfab9dc779288b3e 11-Jan-2011 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Fix invalid memory access during snd_soc_lzo_cache_sync()

The size of the lzo syncing bitmap was incorrectly set to the size
of the cache times the word size, however, the correct size is the
size of the cache.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
68d44ee0bc70be30ea1ee936e6e21082193386cf 21-Dec-2010 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Make LZO cache compression optional

Make LZO cache compression optional as it pulls in the kernel wide LZO
implementation and rbtree compression is generally more efficient for
typical register maps, especially in terms of CPU performance.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
be4fcddd17f01ede0ff46cf86c5ab8c5adb37175 21-Dec-2010 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: If we can't find a cache compression type default to flat

This makes it easier to make cache types build time configurable as we
don't have a hard dependency on a given cache being built in.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
465d7fcc913373783dbb4cdcf03ea05b430930d4 14-Dec-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: A few minor stylistic changes

Remove redundant parentheses/spaces in the use of the sizeof
operator.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
0d735eaa2c1d80c997fd775b679e36b80b8e85d1 06-Dec-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Add optional cache name member to snd_soc_cache_ops

Added an optional name member to snd_soc_cache_ops to enable more
sensible diagnostic messages during cache init, exit and sync.

Remove redundant newline in source code.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
001ae4c0350a35e8358514326e5c3d165357979a 02-Dec-2010 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Constify struct snd_soc_codec_driver

Allow the CODEC driver structure to be marked const by making all
the APIs that use it do so.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
3335ddca9367675f4ee0bd50cc70402c4919a10d 02-Dec-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Use reg_def_copy instead of reg_cache_default

Make sure to use codec->reg_def_copy instead of codec_drv->reg_cache_default
wherever necessary. This change is necessary because in the next patch we
move the cache initialization code outside snd_soc_register_codec() and by that
time any data marked as __devinitconst such as the original reg_cache_default
array might have already been freed by the kernel.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
23bbce34f47762ce944ea9b8b3b3e05e220c6a2e 02-Dec-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: Add compress_type as a member to snd_soc_codec

We need to keep a copy of the compress_type supplied by the codec driver
so that we can override it if necessary with whatever the machine driver
has provided us with. The reason for not modifying the codec->driver
struct directly is that ideally we'd like to keep it const.

Adjust the code in soc-cache and soc-core to make use of the compress_type
member in the snd_soc_codec struct.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
c3acec2671cc448bc549b06b561ae2454238e9a0 02-Dec-2010 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Move active copy of CODEC read and write into runtime structure

We shouldn't be assigning to the driver structure (which really ought
to be const, further patch to follow) though there's unlikely to be any
actual problem except in the unlikely case that two devices with the
same driver but different bus types appear in the same system.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
09c74a9d0b0bedff16d0881db8cc0054a5e34f47 29-Nov-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Fix memory overflow in LZO initialization

The bitmap_zero() nbits argument was improperly set to reg_size
but the underlying buffer was bmp_size long. This caused the memset
to zero past the end of the allocated buffer and into the kernel heap
causing strange kernel crashes sometimes by overwriting critical
kernel structures.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
df0701bb8660107e811bddba6e4933385f697a21 29-Nov-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Ensure consistent cache naming

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
7a33d4ce8231f789548ce6e25f75894a6c8508a5 29-Nov-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Add error checking in the *_cache_sync functions

Ensure that we report any errors encountered during reads/writes
in the cache syncing functions.

Remove redundant newline in the source code.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
a7f387d5afd5e1102f909ab611370014f1f59ae2 11-Nov-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Add support for rbtree based register caching

This patch adds support for rbtree compression when storing the
register cache. It does this by not adding any uninitialized registers
(those whose value is 0). If any of those registers is written
with a nonzero value they get added into the rbtree.

Consider a sample device with a large sparse register map. The
register indices are between [0, 0x31ff]. An array of 12800 registers
is thus created each of which is 2 bytes. This results in a 25kB
region. This array normally lives outside soc-core, normally in the
driver itself. The original soc-core code would kmemdup this region
resulting in 50kB total memory. When using the rbtree compression
technique and __devinitconst on the original array the figures are
as follows. For this typical device, you might have 100 initialized
registers, that is registers that are nonzero by default. We build
an rbtree with 100 nodes, each of which is 24 bytes. This results
in ~2kB of memory. Assuming that the target arch can freeup the
memory used by the initial __devinitconst array, we end up using
about ~2kB bytes of actual memory. The memory footprint will increase
as uninitialized registers get written and thus new nodes created in
the rbtree. In practice, most of those registers are never changed.
If the target arch can't freeup the __devinitconst array, we end up
using a total of ~27kB. The difference between the rbtree and the LZO
caching techniques, is that if using the LZO technique the size of
the cache will increase slower as more uninitialized registers get
changed.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
cc28fb8e7d55d4d7c1661dc0b236f4faddecdd9e 11-Nov-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Add support for LZO register caching

This patch adds support for LZO compression when storing the register
cache. The initial register defaults cache is marked as __devinitconst
and the only change required for a driver to use LZO compression is
to set the compress_type member in codec->driver to SND_SOC_LZO_COMPRESSION.

For a typical device whose register map would normally occupy 25kB or 50kB
by using the LZO compression technique, one can get down to ~5-7kB. There
might be a performance penalty associated with each individual read/write
due to decompressing/compressing the underlying cache, however that should not
be noticeable. These memory benefits depend on whether the target architecture
can get rid of the memory occupied by the original register defaults cache
which is marked as __devinitconst. Nevertheless there will be some memory
gain even if the target architecture can't get rid of the original register
map, this should be around ~30-32kB instead of 50kB.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
7a30a3db34cc7b2180a1a6c4a51d19d93c8a8b80 11-Nov-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Add support for flat register caching

This patch introduces the new caching API and migrates the
old caching interface into the new one. The flat register caching
technique does not use compression at all and it is equivalent to
the old caching technique. One can still access codec->reg_cache
directly but this is not advised as that will not be portable
across different caching strategies.

None of the existing drivers need to be changed to adapt to this
caching technique. There should be no noticeable overhead associated
with using the new caching API.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
5aaa062c27273d21d1f52ddc20e697b6466057d4 08-Nov-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Use BUG_ON() for unsupported hw_read() calls

Instead of dereferencing a NULL function pointer and falling apart
use BUG_ON() for any unimplemented hw_read() calls.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
11dbf0acb4aba818a4f0600996216be55667b400 03-Nov-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Remove unnecessary debugging info

No need to print the register-value pair again, as we've already hooked
snd_soc_write() for that matter.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
f479fd93d4028afccf155dec736c6d49cde92571 04-Oct-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: soc-cache: Add spi_write support for all I/O types

Ensure that all drivers that use SPI and I2C will work properly
by providing SPI write functions for all different I/O types.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
005d65fbac28e6cf32c76e95163012eb326f37e4 22-Sep-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: Fix incorrect parameter to snd_soc_codec_volatile_register

We need to pass the register index and not the register value.
This patch depends on my previous patch "ASoC: Delegate to hw
specific read for volatile registers".

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
db49c146a8c0e8d49c0ff029c2496d47660dfb28 22-Sep-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: Delegate to hw specific read for volatile registers

Ensure that reads on volatile registers will correctly delegate
to the bus specific read function.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
3e13f65e3aa51fc7009afc554683a0b182c057f5 23-Sep-2010 Takashi Iwai <tiwai@suse.de> ASoC: adapt multi-componentism again

Go back to the new world order.

(Also fixed indentation.)

Signed-off-by: Takashi Iwai <tiwai@suse.de>
0077ca0b5c986477e33451b797b6e7dc92a8bbc0 22-Sep-2010 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Fix multi-componentism

Spot the build testing.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
391d8a04fc0f0d603642daa07f379e17c88001c9 21-Sep-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: Return -1 instead of -EINVAL to ensure consistency

The code can't really cope with I/O errors, so it would be better
to be consistent throughout all cache functions and return -1 instead
of -EINVAL.

The return value of snd_soc_read(...) is mostly checked in the probe
function and nowhere else.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
d47372e852391d0c6553dfbc7c4c56b89b527e13 21-Sep-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: Fix soc-cache buffer overflow bug

Make sure we stay within the cache boundaries when updating the
register cache.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
fa6d52938906305356555e37e38939c7bad8fd7a 21-Sep-2010 Dimitris Papastamos <dp@opensource.wolfsonmicro.com> ASoC: Fix soc-cache buffer overflow bug

Make sure we stay within the cache boundaries when updating the
register cache.

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
a6d14342dc46f0ef94cccf323fd9481de84b458f 12-Aug-2010 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Automatically determine control_data for soc-cache users

Since the provision of a struct device for the CODEC is now mandatory
we can use container_of() to locate the struct i2c_client and struct
spi_device for relevant devices, removing the need to manually set it
in each driver.

A further patch will automate selection of the control type based on
the bus_type of the struct device, further reducing the amount of
driver code required.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
f0fba2ad1b6b53d5360125c41953b7afcd6deff0 17-Mar-2010 Liam Girdwood <lrg@slimlogic.co.uk> ASoC: multi-component - ASoC Multi-Component Support

This patch extends the ASoC API to allow sound cards to have more than one
CODEC and more than one platform DMA controller. This is achieved by dividing
some current ASoC structures that contain both driver data and device data into
structures that only either contain device data or driver data. i.e.

struct snd_soc_codec ---> struct snd_soc_codec (device data)
+-> struct snd_soc_codec_driver (driver data)

struct snd_soc_platform ---> struct snd_soc_platform (device data)
+-> struct snd_soc_platform_driver (driver data)

struct snd_soc_dai ---> struct snd_soc_dai (device data)
+-> struct snd_soc_dai_driver (driver data)

struct snd_soc_device ---> deleted

This now allows ASoC to be more tightly aligned with the Linux driver model and
also means that every ASoC codec, platform and (platform) DAI is a kernel
device. ASoC component private data is now stored as device private data.

The ASoC sound card struct snd_soc_card has also been updated to store lists
of it's components rather than a pointer to a codec and platform. The PCM
runtime struct soc_pcm_runtime now has pointers to all its components.

This patch adds DAPM support for ASoC multi-component and removes struct
snd_soc_socdev from DAPM core. All DAPM calls are now made on a card, codec
or runtime PCM level basis rather than using snd_soc_socdev.

Other notable multi-component changes:-

* Stream operations now de-reference less structures.
* close_delayed work() now runs on a DAI basis rather than looping all DAIs
in a card.
* PM suspend()/resume() operations can now handle N CODECs and Platforms
per sound card.
* Added soc_bind_dai_link() to bind the component devices to the sound card.
* Added soc_dai_link_probe() and soc_dai_link_remove() to probe and remove
DAI link components.
* sysfs entries can now be registered per component per card.
* snd_soc_new_pcms() functionailty rolled into dai_link_probe().
* snd_soc_register_codec() now does all the codec list and mutex init.

This patch changes the probe() and remove() of the CODEC drivers as follows:-

o Make CODEC driver a platform driver
o Moved all struct snd_soc_codec list, mutex, etc initialiasation to core.
o Removed all static codec pointers (drivers now support > 1 codec dev)
o snd_soc_register_pcms() now done by core.
o snd_soc_register_dai() folded into snd_soc_register_codec().

CS4270 portions:
Acked-by: Timur Tabi <timur@freescale.com>

Some TLV320aic23 and Cirrus platform fixes.
Signed-off-by: Ryan Mallon <ryan@bluewatersys.com>

TI CODEC and OMAP fixes
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>

Samsung platform and misc fixes :-
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Jassi Brar <jassi.brar@samsung.com>
Signed-off-by: Seungwhan Youn <sw.youn@samsung.com>

MPC8610 and PPC fixes.
Signed-off-by: Timur Tabi <timur@freescale.com>

i.MX fixes and some core fixes.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

J4740 platform fixes:-
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

CC: Tony Lindgren <tony@atomide.com>
CC: Nicolas Ferre <nicolas.ferre@atmel.com>
CC: Kevin Hilman <khilman@deeprootsystems.com>
CC: Sascha Hauer <s.hauer@pengutronix.de>
CC: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
CC: Kuninori Morimoto <morimoto.kuninori@renesas.com>
CC: Daniel Gloeckner <dg@emlix.com>
CC: Manuel Lauss <mano@roarinelk.homelinux.net>
CC: Mike Frysinger <vapier.adi@gmail.com>
CC: Arnaud Patard <apatard@mandriva.com>
CC: Wan ZongShun <mcuos.com@gmail.com>

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
ac770267a7cd85a747b6111db46f66d1515e7cd7 07-Aug-2010 Cliff Cai <cliff.cai@analog.com> ASoC: register cache should be 1 byte aligned for 1 byte long register

Signed-off-by: Cliff Cai <cliff.cai@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@kernel.org
985d8c4c9eb18bd7b295c73a5ab1fc990e5ed182 03-May-2010 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Add debug output tracing all cache register writes

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
f4bee1bb0083869b1b7d73c6eda7703a7aae0506 18-Mar-2010 Barry Song <21cnbao@gmail.com> ASoC: soc-cache: let reg be AND'ed by 0xff instead of data buffer for 8_8 mode

The registers for AD193X are defined as 0x800-0x810 for spi which uses
16_8 mode, for i2c to support AD1937, we will use 8_8 mode, only the low
byte of 0x800-0x810 is valid. The patch will not destory other codecs,
but make soc cache interface more useful.

Signed-off-by: Barry Song <barry.song@analog.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
85dfcdffc227717fd218b9a86b507d9b7a3c321d 18-Mar-2010 Cliff Cai <cliff.cai@analog.com> ASoC: soc-cache: add i2c read entry for 8_8 mode

Signed-off-by: Cliff Cai <cliff.cai@analog.com>
Signed-off-by: Barry Song <barry.song@analog.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
bc6552f4717e07e7737b5dc17883c2ff99f2a315 05-Mar-2010 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Add 16/16 registers to soc-cache

I2C only at the minute.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
a3032b47c46920ed3f2fd58e64f484e3dab49f23 01-Feb-2010 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Add a cache_sync bit to the CODEC structure

Add a bit to the CODEC structure indicating if a cache sync is required.
By default this will be set if a cache only write is done to a soc-cache
register cache. This allows us to avoid syncing the cache back after
using cache only writes if there were no changes.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
8c961bcca1d10be4f2c06375eb561679167653a0 01-Feb-2010 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Allow CODECs to ask soc-cache to suppress physical writes

Currently the soc-cache code will always write to the device, meaning
that we need the device to be powered and active at pretty much all
times the system is active. Allowing cache only writes lays some
groundwork for future enhancements to allow devices to be put into a
full off state when the audio subsystem is idle.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
994dc4245d3f50329da4ead453a5dfcfbc716a0d 27-Jan-2010 Barry Song <21cnbao@gmail.com> ASoC: ad1938: use soc-cache framework for codec registers access

Signed-off-by: Barry Song <Barry.Song@analog.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
63b62ab0d52c736b3274b294df962e0a4b7aae79 27-Jan-2010 Barry Song <21cnbao@gmail.com> ASoC: ad1836: use soc-cache framework for codec registers access

Signed-off-by: Barry Song <Barry.Song@analog.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
8998c89907f84f7e25536c1c670a134c831e682f 31-Dec-2009 Barry Song <21cnbao@gmail.com> ASoC: soc-cache: cleanup training whitespace and coding style

Signed-off-by: Barry Song <21cnbao@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
d62ab3589462d406e98731799361f46095467882 21-Sep-2009 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Convert soc-cache to use C99 style initialisers for the table

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
341c9b84bc01040bd5c75140303e32f6b10098f3 06-Sep-2009 Joonyoung Shim <jy0922.shim@samsung.com> ASoC: Factor out I2C 8 bit address 8 bit data I/O

This patch is for the AK4671 codec driver using this format.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
17244c24f95ba61a12b6afeab5780a1e3f1a4c57 11-Aug-2009 Randy Dunlap <randy.dunlap@oracle.com> ASoC: fix I2C build errors

Fix soc build errors when I2C is built as a loadable module:

(.text+0x5d26b): undefined reference to `i2c_master_send'
soc-cache.c:(.text+0x5d32d): undefined reference to `i2c_transfer'

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
27ded041f03026e8c6be9efc626e11ddfb4620c1 11-Jul-2009 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Factor out 7 bit register 9 bit data SPI write

This converts all the Wolfson drivers using this format (the only devices
that do) except WM8753 to use it.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
afa2f1066e7288a9e4f8e3fda277da245219dffc 11-Jul-2009 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Factor out I2C 8 bit address 16 bit data I/O

As part of this refactoring the type of the CODEC hw_read operation
is changed to match the regular read operation.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
7084a42b965d972079201414d19a399e65b26099 10-Jul-2009 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Add I/O control bus information to factored out cache setup

While writes tend to be able to use a fairly bus independant format to
do the writes reads are all bus specific. To allow us to factor out
this code include the bus type as a parameter when setting up the
cache.

Initially just use this to factor out hw_write_t for I2C.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
17a52fd60a0a0e617ed94aadb1b19751a8fa219e 05-Jul-2009 Mark Brown <broonie@opensource.wolfsonmicro.com> ASoC: Begin to factor out register cache I/O functions

A lot of CODECs share the same register data formats and therefore
replicate the code to manage access to and caching of the register
map. In order to reduce code duplication centralised versions of
this code will be introduced with drivers able to configure the use
of the common code by calling the new snd_soc_codec_set_cache_io()
API call during startup.

As an initial user the 7 bit address/9 bit data format used by many
Wolfson devices is supported for write only CODECs and the drivers
with straightforward register cache implementations are converted to
use it.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>