1
0
Fork 0
Commit Graph

106 Commits (redonkable)

Author SHA1 Message Date
Lars-Peter Clausen 427d204c86 ASoC: Remove snd_soc_cache_sync() implementation
This function has no more non regmap user, which means we can remove the
implementation of the function and associated functions and structure
fields.

For convenience we keep a static inline version of the function that
forwards calls to regcache_sync() unconditionally.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-09 09:06:30 +00:00
Lars-Peter Clausen 6cc79294ef ASoC: Forward calls to snd_soc_cache_sync() to regcache_sync()
For convenience for drivers that do not want to keep their own pointer to
regmap struct around forward calls to snd_soc_cache_sync() to
regcache_sync() if the driver is using regmap. This is similar to what we do
for snd_soc_read()/snd_soc_write().

This patch also fixes drivers which already have been converted to regmap,
but still use snd_soc_cache_sync() for trying to the sync the cache.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
2014-11-09 09:06:30 +00:00
Lars-Peter Clausen f4333203ec ASoC: Move name and id from CODEC/platform to component
The component struct already has a name and id field which are initialized to
the same values as the same fields in the CODEC and platform structs. So remove
them from the CODEC and platform structs and used the ones from the component
struct instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-21 21:04:24 +01:00
Mark Brown b5fc40d3b3 ASoC: cache: Fix error code when not using ASoC level cache
It is not an error to have no cache so we shouldn't return an error code
and cause our callers to fail, just silently do nothing instead.  Thanks
to Jarkko for identify the problematic commit.

Reported-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reported-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-02 16:08:21 +01:00
Xiubo Li b59dce53ef ASoC: cache: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
Since we cannot make sure the 'reg_size' will always be none zero here,
and then if 'reg_size' equals to zero, the kzalloc() will return ZERO_SIZE_PTR,
which equals to ((void *)16).

So this patch fix this with just doing the 'reg_size' zero check before calling
kzalloc().

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-01 20:02:17 +01:00
Lars-Peter Clausen 20a0ec27ea ASoC: Remove IO register modifier callbacks
There are no ASoC drivers left that use them and new drivers are supposed to use
regmap for this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-04-14 17:22:43 +01:00
Xiubo Li 931f27c6e8 ASoC: cache: Do the codec->reg_cache zero pionter check
For the snd_soc_cache_init(), the reg_size maybe zero and then the value
of codec->reg_cache, which is alloced via kzalloc, maybe equal to
ZERO_SIZE_PTR. If the reg parameter of snd_soc_cache_write() is large enough,
the cache[idx] = val maybe cause the kernel crash...

So this patch fix this via doing the zero pionter check of it.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
2014-03-04 12:32:19 +08:00
Mark Brown 108145a606 Merge remote-tracking branch 'asoc/topic/warn' into asoc-next 2013-11-08 10:43:41 +00:00
Takashi Iwai a6ed0608bd ASoC: Replace BUG() with WARN()
BUG() used in the driver is just to spit the stack trace on buggy
points, not really needed to stop the whole operation.  For that
purpose, it'd be more convenient to use WARN() instead with more
error information.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-11-07 19:55:21 +00:00
Lars-Peter Clausen f90fb3f778 ASoC: Remove infrastructure for supporting multiple cache types
The only cache type left is the flat cache and new other cache types won't be
added since new drivers are supposed to use regmap directly for IO and caching.
This patch removes the snd_soc_cache_ops indirection that was added to support
multiple cache types and modifies the code to always use the flat cache
directly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-17 00:37:03 +01:00
Lars-Peter Clausen a94ed23436 ASoC: Remove 'reg_size' field from snd_soc_codec struct
The reg_size field is calculated in snd_soc_register_codec() and then used
exactly once in snd_soc_flat_cache_init(). Since it is calculated based on other
fields from the codec struct just move the calculation to
snd_soc_flat_cache_init() and remove the 'reg_size' field from the codec struct.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-17 00:37:03 +01:00
Lars-Peter Clausen b012aa619e ASoC: Remove reg_def_copy
reg_def_copy was introduced in commit 3335ddca ("ASoC: soc-cache: Use
reg_def_copy instead of reg_cache_default") to keep a copy of the register
defaults around in case the register defaults where placed in the __devinitdata
section. With the __devinitdata section gone we effectivly keep the same data
around twice. This patch removes reg_def_copy and uses reg_cache_default
directly instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-17 00:37:03 +01:00
Lars-Peter Clausen 175ee39e8f ASoC: Remove support for reg_access_defaults
No users of reg_access_defaults are left and new drivers are going to use regmap
for this, so support for it can be removed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
2013-09-17 00:37:02 +01:00
Liam Girdwood 204b62c6bc ASoC: cache: Standardise ASoC cache messages
Currently ASoC has a mixture of message prefixes e.g. "ASoC", "asoc"
or none and message types e.g. pr_debug or dev_dbg.

Make sure all ASoC core messages use the same "ASoC" prefix and
convert any component device specific messages to use dev_dbg
instead of pr_debug.

Signed-off-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2012-11-21 11:39:51 +09:00
Mark Brown 1dfb6efd87 ASoC: Remove rbtree register cache
All users now use regmap directly so delete the ASoC version of the code.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-12-13 00:20:28 +08:00
Mark Brown c9016a7937 ASoC: Remove LZO cache type
There are no current users and new drivers ought to be using the regmap
API and its cache implementation directly so just delete the ASoC copy.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-11-10 13:08:09 +00:00
Paul Gortmaker d81a6d7176 sound: Add export.h for THIS_MODULE/EXPORT_SYMBOL where needed
These aren't modules, but they do make use of these macros, so
they will need export.h to get that definition.  Previously,
they got it via the implicit module.h inclusion.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-10-31 19:31:22 -04:00
Mark Brown 0f8dd4ce47 Merge branch 'for-3.1' into for-3.2 2011-08-31 09:46:42 +01:00
Lars-Peter Clausen 6c5b756aaa ASoC: Fix register cache sync register_writable WARN_ONs
Currently the condition for these WARN_ONs is reversed and they are placed
before the actual check whether we are going to write to that register. So if
the codec implements the register_writable callback we'll get a warning for each
writable register when syncing the register cache.

While we are at it change the check to use snd_soc_codec_writable_register
instead of open-coding it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-08-31 09:46:16 +01:00
Axel Lin 3a52f19ee6 ASoC: soc-cache: Remove unneeded codec_drv pointer variable in snd_soc_lzo_get_blksize
Since commit aea170a099
"ASoC: soc-cache: Add reg_size as a member to snd_soc_codec",
the codec_drv pointer variable is not used in snd_soc_lzo_get_blksize.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-08-15 22:52:03 +09:00
Axel Lin 31e12dd377 ASoC: soc-cache: Remove unneeded codec_drv pointer variable in snd_soc_flat_cache_init
Since commit d779fce5d7
"ASoC: soc-cache: Ensure flat compression uses a copy of the defaults cache",
the codec_drv pointer variable is not used any more.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-08-15 22:52:02 +09:00
Mark Brown 5bef44f9b4 ASoC: Move register I/O code into a separate file
For clarity and to help ongoing refactoring in this area create a new file
to contain the physical I/O functions, separating them out from the cache
operations.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
2011-06-13 18:56:10 +01:00
Mark Brown f0c4205b54 ASoC: Factor out redundant read() functions
We've got a whole bunch of functions which just call straight through to
do_hw_read(). Simplify this situation by removing them and using hw_read()
directly.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
2011-06-13 14:22:57 +01:00
Mark Brown ffdaa48aed ASoC: Suppress restore of default register values for rbtree cache sync
Currently the rbtree code will write out the entire register map when
doing a cache sync which is wasteful and will slow things down. Check
to see if the value we're about to write is the default and don't bother
restoring it if it is, either the value will have been retained or the
device will have been reset and holds the value already.

We should really store the defaults in the nodes but this resolves the
immediate issue.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
2011-06-08 15:24:36 +01:00
Mark Brown bd4f2acb8d Merge branch 'for-3.0' into for-3.1 2011-06-06 19:34:58 +01:00
Mark Brown fd137e2bba 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>
2011-06-06 19:34:11 +01:00
Mark Brown d21685ec25 Merge branch 'for-2.6.40' into for-2.6.41 2011-05-30 10:54:18 +08:00
Mark Brown 2ac8b6f41a ASoC: Use explicit endianness conversion in snd_soc_16_8_write()
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
2011-05-27 22:01:40 +08:00
Mark Brown 94228bcf8c ASoC: Use cpu_to_be16() in 8x16 write
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
2011-05-27 22:00:58 +08:00
Mark Brown f06f136fe0 ASoC: Convert 7x9 write to use cpu_to_be16()
Run the data through cpu_to_be16() so it's at least clear what we're up to.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
2011-05-27 22:00:38 +08:00
Mark Brown 60c655e62f ASoC: Convert 16x16 write to use cpu_to_be16()
Make it clear what we're doing.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@ti.com>
2011-05-24 18:41:09 +08:00
Dimitris Papastamos 7e146b5586 ASoC: soc-cache: Cache a pointer to the last accessed rbnode
Whenever we are doing a read or a write through the rbtree code, we'll
cache a pointer to the rbnode.  To avoid looking up the register
everytime we do a read or a write, we first check if it can be found in
the cached register block, otherwise we traverse the rbtree and finally
cache the rbnode for future use.

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>
2011-05-20 11:22:06 +01:00
Dimitris Papastamos 0944cc392e ASoC: soc-cache: Block based rbtree compression
This patch prepares the ground for the actual rbtree optimization patch
which will save a pointer to the last accessed rbnode that was used
in either the read() or write() functions.

Each rbnode manages a variable length block of registers.  There can be no
two nodes with overlapping blocks.  Each block has a base register and a
currently top register, all the other registers, if any, lie in between these
two and in ascending order.

The reasoning behind the construction of this rbtree is simple.  In the
snd_soc_rbtree_cache_init() function, we iterate over the register defaults
provided by the driver.  For each register value that is non-zero we
insert it in the rbtree.  In order to determine in which rbnode we need
to add the register, we first look if there is another register already
added that is adjacent to the one we are about to add.  If that is the case
we append it in that rbnode block, otherwise we create a new rbnode
with a single register in its block and add it to the tree.

In the next patch, where a cached rbnode is used by both the write() and the
read() functions, we also check if the register we are about to add is in the
cached rbnode (the least recently accessed one) and if so we append it in that
rbnode block.

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>
2011-05-20 11:21:53 +01:00
Mark Brown f7391fce6a 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>
2011-05-15 08:50:59 -07:00
Mark Brown 6e28f976ec 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>
2011-05-11 15:56:03 +02:00
Mark Brown 063b7cc43f 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>
2011-05-11 15:55:45 +02:00
Mark Brown 051e994e95 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>
2011-05-11 15:55:06 +02:00
Dimitris Papastamos 64d2706975 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>
2011-05-08 14:38:31 +01:00
Lu Guanqun f9861e17bd 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>
2011-04-20 13:50:16 +01:00
Mark Brown 34bad69cf6 ASoC: Fix comment width in soc-cache.c
Lines should be less than 80 columns.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-04-05 08:26:08 +09:00
Mark Brown d420d40e9c 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>
2011-04-05 08:25:39 +09:00
Seungwhan Youn 898f8b0b65 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>
2011-04-05 08:23:00 +09:00
Dimitris Papastamos f20eda5d8f 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>
2011-03-31 06:21:29 +09:00
Dimitris Papastamos fbda18245b 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>
2011-03-31 06:20:37 +09:00
Dimitris Papastamos 8020454c9a 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>
2011-03-26 17:45:16 +00:00
Dimitris Papastamos acd61451e5 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>
2011-03-26 17:45:08 +00:00
Dimitris Papastamos 30539a18d3 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>
2011-03-26 17:44:56 +00:00
Dimitris Papastamos b8cbc19520 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>
2011-03-26 17:44:48 +00:00
Dimitris Papastamos 26e9984cbc 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>
2011-03-26 17:44:38 +00:00
Dimitris Papastamos 5fb609d435 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>
2011-03-26 17:44:14 +00:00