ASoC: rsnd: remove old clock style support

All platform which used old style was
switched to new style.
R-Car sound can remove old style clock support,
use device dependent clock now.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
(cherry picked from commit cedbc32960999da14b4a2aa877c88620a183e639)
(not present upstream)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: rsnd: remove compatibility code

Now, all platform is using new style rsnd_dai_platform_info.
Keeping compatibility is no longer needed.
We can cleanup code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
(cherry picked from commit 1b4f77f605e995fffbbadd93ada1be3cdcac9f1e)
(not present upstream)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: rsnd: add rsnd_path_parse() macro

Current R-Car sound supports only SRC/SSI,
but, other module will be supported.
This patch adds rsnd_path_parse() macro to share code

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
(cherry picked from commit 284de94f0d524d610481d0002a53896a392e52e0)
(not present upstream)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: rsnd: add rsnd_get_adinr()

SRC module is setting ADINR register,
but, R-Car sound device has many xxx_ADINR register.
This patch adds rsnd_get_adinr() to sharing code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
(cherry picked from commit d69d683225ec6903c52e30f47560195e23e6a506)
(not present upstream)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: rsnd: remove duplicate parameter from rsnd_mod_ops

Now, it can get rsnd_dai_stream pointer from rsnd_mod.
Remove duplicate parameter from rsnd_mod_ops

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
(cherry picked from commit 42da912a07abeb172746c74cda6ee6eabc9d3138)
(not present upstream)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: rsnd: enable to use multi parameter on rsnd_dai_call/rsnd_mod_call

rsnd_mod_ops would like to come to use multi parameter.
modify macro to enable it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
(cherry picked from commit 629ed7463c4ae5cd49c20a3e8d60f63a530b497b)
(not present upstream)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: rsnd: add DVC support

This patch adds DVC support which is member of CMD unit.
DVC requires new style (= rsnd_dai_platform_info) probing,
but is keeping compatible with old style.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
(cherry picked from commit ebe5f90da574edf4626618267d96aef6f1f8d0b5)
(not present upstream)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
devres: add kernel standard devm_k.alloc functions

Currently, devm_ managed memory only supports kzalloc.

Convert the devm_kzalloc implementation to devm_kmalloc and remove the
complete memset to 0 but still set the initial struct devres header and
whatever padding before data to 0.

Add the other normal alloc variants as static inlines with __GFP_ZERO
added to the gfp flag where appropriate:

	devm_kzalloc
	devm_kcalloc
	devm_kmalloc_array

Add gfp.h to device.h for the newly added static inlines.

akpm: the current API forces us to replace kmalloc() with kzalloc() when
performing devm_ conversions.  This adds a relatively minor overhead.
More significantly, it will defeat kmemcheck used-uninitialized checking,
and for a particular driver, losing used-uninitialised checking for their
core controlling data structures will significantly degrade kmemcheck
usefulness.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Sangjung Woo <sangjung.woo@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 64c862a839a8db2c02bbaa88b923d13e1208919d)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
devres: restore zeroing behavior of devres_alloc()

commit 64c862a8 (devres: add kernel standard devm_k.alloc functions) changed
the default behavior of alloc_dr() to no longer zero the allocated memory.  However,
only the devm.k.alloc() function were modified to pass in __GFP_ZERO which leaves
any users of devres_alloc() or __devres_alloc() with potentially wrong assumptions
about memory being zero'd upon allocation.

To fix, add __GFP_ZERO to devres_alloc() calls to preserve previous
behavior of zero'ing memory upon allocation.

Signed-off-by: Kevin Hilman <khilman@linaro.org>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6fffcfa7c0fc438d3667b4eb2074d94f69c12c7b)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
clk: add clock-indices support

Add a property called clock-indices to allow clock-output-names
to be used where the index used to lookup a clock is not a 1:1
mapping to the array position in the clock-output-names

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
(cherry picked from commit 7a0fc1a3df82d29e00b4c9f88a6b37450d6711f1)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: core: Implement devm_snd_soc_register_component()

Since with the wider use of devres many drivers are now only calling
snd_soc_unregister_component() in their remove functions providing a
managed version will save a reasonable amount of code.

Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit a0b03a616b08cf9d709812ff5cf7e9c0958d6807)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: snd_soc_codec includes snd_soc_component

Codec includes component by this patch,
and component moved to upside of codec
to avoid extra declaration.
Codec dai will be registered via component
by this patch.

Current component register function
is used for cpu, and it is using
dai/dais functions properly to keep
existing cpu dai name.

And now, it will be used from codec also.
But codec driver had been used dais function only
even though it was single dai.
This patch adds new flag which can selects
dai/dais function on component register
function to keep existing codec dai name.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit d191bd8de8c61619563f2b19f1fdcc0944ff1a72)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: add .of_xlate_dai_name on snd_soc_component_driver

ASoC sound driver requires CPU/CODEC drivers for probing,
and each CPU/CODEC has some DAI on it.
Then, "dai name matching" have been used to identify
CPU-CODEC DAI pair on ASoC.

But, the "dai port number matching" is now required from DeviceTree.
The solution of this issue is to replace
the dai port number into dai name.
Now, CPU/CODEC are based on struct snd_soc_component,
and it can care above as common issue.

This patch adds .of_xlate_dai_name callback interface
on struct snd_soc_component_driver,
and snd_soc_of_get_dai_name() which is using .of_xlate_dai_name.

Then, #sound-dai-cells which enables DAI specifier is required
on CPU/CODEC device tree properties.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit cb470087669a3fab1958fec79dd7db280b33f178)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: add snd_soc_of_parse_audio_simple_widgets for DT

This patch adds snd_soc_of_parse_audio_simple_widgets() and supports
below style of widgets name on DT:

	"template-wname", "user supplied wname"

For instance:
	simple-audio-widgets =
		"Microphone", "Microphone Jack",
		"Line", "Line In Jack",
		"Line", "Line Out Jack",
		"Headphone", "Headphone Jack",
		"Speaker", "Speaker External";

The "template-wname" currently includes: "Microphone", "Line", "Headphone"
and "Speaker".

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit 9a6d48605e632e84db2895cf752c65b3c908cd09)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: core: add TDM slot parsing from DT supports

For some CPU/CODEC DAI devices the TDM slot infomation maybe needed. This
patch adds the slot parsing from DT supports.

TDM slot properties:
    dai-tdm-slot-num : Number of slots in use.
    dai-tdm-slot-width :  Width in bits for each slot.

For instance:
    dai-tdm-slot-num = <2>;
    dai-tdm-slot-width = <8>;

And for each spcified driver, there could be one .of_xlate_tdm_slot_mask()
to specify a explicit mapping of the channels and the slots. If it's absent
the default snd_soc_of_xlate_tdm_slot_mask() will be used to generating the
tx and rx masks.

For snd_soc_of_xlate_tdm_slot_mask(), the tx and rx masks will use a 1 bit
for an active slot as default, and the default active bits are at the LSB of
the masks.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit 89c6785715592a6b082b3f9f28c27bb14b041c7d)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: core: Add devm_snd_soc_register_card()

Simplify error handling and remove repetitive (and rarely executed) code
for unregistration by providing a devm_snd_soc_register() card.

Signed-off-by: Mark Brown <broonie@linaro.org>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
(cherry picked from commit 0e4ff5c806263bf40ee5409ac283b776f0c11e41)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: Use strlcpy() for copying in snd_soc_info_enum_double()

The provided texts aren't guaranteed to be in the fixed size.
Spotted by coverity CID 139318.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit a19685cb72bb6a80ac453e76b3ab3bb7770e1742)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: dapm: Remove unnecessary loop

The condition 'i == item' is only true when, well, 'i' equals 'item'.
So just use 'item' directly as the index into the array.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit 58fee775b7a18a0174931af6174536560785d500)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: core: set_tdm_slot() will return -ENOTSUPP if no operation provided

Make it easier for generic code to work with set_tdm_slot() by distinguishing
between the operation not being supported and an error as is done.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit b2cbb6e1c1544fc889ee7d6c6a6c229c20cd03cd)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
ASoC: core: Add signed register volume control logic

Some codecs use signed volume control representation with non standard
register sizes, e.g. 6 or 7 bit signed integers.

This patch adds generic signed register volume control logic to
soc-core. Instead of a fixed width signed register control, this
implementation uses a 'min' value and the signed bit location to translate
it to an absolute volume. Using the 'sign_bit' we can calculate a
correct mask for the register values and translate it back into signed
integers of standard size.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit f227b88f0fce5f9b82aa934f8829a741c2e06d82)
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>

Conflicts:
	include/sound/soc.h
	sound/soc/soc-core.c