ASoC: msm: Add support to enable SRS feature on DSP

Add new mixer controls for setting SRS parameters which
enables SRS on DSP. Add required structures and commands
for enabling SRS

Change-Id: Ife0c8223c534dd3daad10dd5fec18630da732611
Signed-off-by: Sriranjan Srikantam <cssrika@codeaurora.org>

Conflicts:

	include/sound/apr_audio.h
	sound/soc/msm/msm-pcm-routing.c
ASoC: msm: Fix SRS key not being sent to DSP sometimes problem

SRS parameters are not updated sometimes when new adm session is
opened and DSP picks up invalid key from default values and plays
some undesired demo ring or noise. Fix this by sending the SRS
parameters everytime adm session is opened. Add a flag to check
if SRS is ever enabled and send parameters only if flag is set

Change-Id: Ib22e6ff74e4376936caa510a632a6a3c3727e034
Signed-off-by: Sriranjan Srikantam <cssrika@codeaurora.org>

Conflicts:

	sound/soc/msm/msm-pcm-routing.c
ASoc: msm: Add support for audio recording with EC.

- Add Mixer controls for Reference Rx device to be
used as a endpoint2 in adm open for echo cancellation.
- Add logic to support echo cancellation for audio
recording with fluence topology.

Change-Id: I7b83c3fc1a19fef7826bc8c3671e2565e393566a
Signed-off-by: Jayasena Sangaraboina <jsanga@codeaurora.org>

Conflicts:

	sound/soc/msm/msm-pcm-routing.c
ASoC: msm: update SRS Tru media control structure with rreg initialization

When SRS Tru media topology is enabled the mixer controls set from
userspace are not sent to driver as the validation fails with
the missing field initialization in the structure. Update the same
to receive the SRS parameters from userspace

Change-Id: Ia2bf800a540adf3bcc2a99fc6e0d9b043c826272
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
ASoC: msm: flush if prior and current backends rate not matching

It is found that during device switch from one backend
with one sample rate to another backend with another sample rate,
the command to QDSP6 ADM which maps audio stream session to a
particular backend would not get carried out until pending
data of audio stream session from previous backend is either
read out or flushed. This scenario occurs when application
stops providing more buffers to retrieve captured data.
Remedy is to flush upon detection of rate mismatching

Change-Id: I2c01c036d9bb71f938a6795337f08948bd986553
CRs-fixed: 422205
Signed-off-by: Patrick Lai <plai@codeaurora.org>
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>

Conflicts:

	sound/soc/msm/msm-pcm-q6.c
	sound/soc/msm/msm-pcm-routing.c
	sound/soc/msm/qdsp6/q6asm.c
ASoc: msm: Fix for pcm_read getting struck in alsa core.

Advance hardware pointer by period size even if the packet
coming from qdsp6 is of less size. QDSP6 sometimes
(for rapid device switches) gives packets worth less
than period size and this results in hw_ptr appl_ptr mismatch.

CRs-Fixed: 486276
CRs-Fixed: 488449
Change-Id: I893f9a52e4cd507fd72e4a7aba3c5fa76527d1bf
Signed-off-by: Sidipotu Ashok <sashok@codeaurora.org>
ALSA: control: add support for ENUMERATED user space controls

Handling of user control elements was implemented for all types except
ENUMERATED.  This type will be needed for the device-specific mixers of
upcoming FireWire drivers.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: control: remove compilation warning on 32-bit

This was introduced by 'ALSA: control: add support for ENUMERATED user
space controls' which adds a u64 variable that gets cast to a pointer:

sound/core/control.c: In function 'snd_ctl_elem_init_enum_names':
sound/core/control.c:1089: warning: cast to pointer from integer of different size

Cast to uintptr_t before casting to pointer to avoid the warning.

Signed-off-by: Olof Johansson <olof@lixom.net>
[cl: replace long with uintptr_t]
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: hwdep: silence integer overflow warning

Smatch complains that if device is INT_MAX then device + 1 can
overflow.  It just means we would have an annoying loop while we
check all the devices from -2147483648 to SNDRV_MINOR_HWDEPS.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: oss-mixer - use strlcpy() instead strcpy()

This is mostly a static checker fix more than anything else.  We're
copying from a 64 char buffer into a 44 char buffer.

The 64 character buffer is str[] in snd_mixer_oss_build_test_all().
The call tree is:
	snd_mixer_oss_build_test_all()
	-> snd_mixer_oss_build_test()
	   -> snd_mixer_oss_build_test().

We never actually do fill str[] buffer all the way to 64 characters.
The longest string is:
	sprintf(str, "%s Playback Switch", ptr->name);
ptr->name is a 32 character buffer so 32 plus 16 characters for
" Playback Switch" still puts us over the 44 limit from "id.name".

Most likely ptr->name never gets filled to the limit, but we can't
really change the size of that buffer so lets just use strlcpy() here
and be safe.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: pcm: add snd_pcm_hw_rule_noresample()

Add a helper function to allow drivers to disable hardware resampling
when the application has specified the SNDRV_PCM_HW_PARAMS_NORESAMPLE
flag.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
ASoc: msm: Modify debug messages with correct levels

Modify some of the debug messages in codec driver and
afe driver to debug from error to prevent excessive
logging

Change-Id: Ib0ccf0708cfd7965b52a5f672e7e681ff182b3d6
CRs-fixed: 355418
Signed-off-by: Swaminathan Sathappan <Swami@codeaurora.org>

Conflicts:
	drivers/mfd/wcd9xxx-slimslave.c
ALSA: pcm - Avoid GFP_ATOMIC in snd_pcm_link()

GFP_ATOMIC is used in snd_pcm_link() just because the kmalloc is
called inside a lock.  Since this function isn't too critical for
speed and is rarely called in practice, better to allocate the chunk
at first before spinlock and free it in error paths, so that
GFP_KERNEL can be used.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

Conflicts:
	sound/core/pcm_native.c

Change-Id: I93676349c5a04e1b31c22761a1f9a729d6af1d1d
ALSA: pcm - Export snd_pcm_lib_default_mmap() helper

Export the default mmap function, snd_pcm_lib_default_mmap().
The upcoming non-snooping support in HD-audio driver will use this
to override the mmap method.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: rawmidi - Use workq for event handling

Kill tasklet usage in rawmidi core code.  Use workq for the event callback
instead of tasklet (which is used only in core/seq/seq_midi.c).

Signed-off-by: Takashi Iwai <tiwai@suse.de>
audio: remove handset pop-noise

When receiver opens immediately after it is  closed, the pop-noise occurs.

Change-Id: I8e5374edea9f8710963b7669e64b109db2354650
ASoC: msm: qdsp6: check for invalid port index

Function which converts port ID to port index can return
error value if port ID is invalid. Caller should not
blindly use return value without checking

Change-Id: I02b8112b6714e3364758907e7078bcbb88d45b6b
Signed-off-by: Patrick Lai <plai@codeaurora.org>
Asoc: msm: Set the right topology during in call voice recording

Obsereved silence in incall voice recording with dual mic, when fluence is
enabled.Fluence topology is applied even on audio recording path.Default topology
is set for incall voice recording.

CRs-Fixed: 454359
Change-Id: I9d34f00e424355fdc183ce1a5769c4083b6ae6a7
Signed-off-by: Sidipotu Ashok <sashok@codeaurora.org>
Asoc: msm: Configure sampling rate to 48KHz for quad-mic topology

Quad-mic calibration data is based on 48KHz instead of 16KHz, so
making change to use the default ADM COPP rate which is 48KHz.

Change-Id: I61fc28ec40c73a9c194521aea6eceeea3db811e9
CRs-Fixed: 344905
Signed-off-by: Jay Wang <jaywang@codeaurora.org>
Asoc: msm: Configure sampling rate to 48KHz for quad-mic topology

Quad-mic calibration data is based on 48KHz instead of 16KHz, so
making change to use the default ADM COPP rate which is 48KHz when
multi-channel ADM open function is called

Change-Id: I0d9a9b6f1197e4c034920f534f9e7db7d8aac41f
Signed-off-by: Jay Wang <jaywang@codeaurora.org>