ASoC: qcom: qdsp6v2: fix crash due to asynchronous read/write

Whenever an async read command is issued to dsp when
the driver is not enabled, there is a crash in userspace.
The read command is disallowed in the driver and an error
is propagated to userspace which results in the crash.
The driver is re-enabled in a subsequent asynchronous write
command anyway, so the async read command can be allowed.
Ensure that read is allowed by removing a superfluous check.

CRs-Fixed: 675131
Signed-off-by: Satya Krishna Pindiproli <satyak@codeaurora.org>
Change-Id: I5d0598e37d08ac1090f98c24be49fd99c132e22f
ASoC: msm: audio-effects: improve logging

Make logs more meaningful by logging values where ever
applicable.

Change-Id: I0fd0e62e543480762096d64c7ee7c92eb1204126
Signed-off-by: Dhananjay Kumar <dhakumar@codeaurora.org>
ASoC: msm: EOS timeout now based on audio data

The timeout value, in relation to waiting for the
EOS command completion message from ADSP, is now
based on the time it will take the ADSP to stream
the remaining audio buffers.

Change-Id: I76fa7d97b91052afd8884aab40bc5df040951be5
Signed-off-by: Kenneth Westfield <kwestfie@codeaurora.org>
ASoC: msm: qdsp6v2: fix rtac command failure

In rtac driver, while sending PP_Params for ADM copp
to DSP, token needs to be port_id whereas coppid is used.
Replace it with port_id to avoid failure in command
and timeout issue.

Change-Id: I77ab13ea14e8d6c25514bdeed24db37ef8113a75
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
ASoC: msm: Fix ADM GET PARAM callback

Add size check on inband get param call and do
not process inband if RTAC is active.

Change-Id: I2c099f5ea254a214f224dda556773a7fe6754fe5
CRs-fixed: 548397
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
ASoC: msm: Add bounds checking to ADM get params

Add additional bounds checking to ADM get params.
Validate that all buffer sizes are valid before
dereferencing.

Change-Id: If7c7a5ae6a56812e9c4a11a38c9bdc78f42d09f3
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
msm: usbaudio: remove usbaudiosdev switch

- Remove usbaudiosdev switch to avoid reporting
  analog dock headset for USB headset

Change-Id: Ib5f505385742b708a98f13ab6fd98808b6d1803e
Signed-off-by: Divya Narayanan Poojary <dnaray@codeaurora.org>
ALSA: Avoid endless sleep after disconnect

    When disconnect callback is called, each component should wake up
    sleepers and check card->shutdown flag for avoiding the endless sleep
    blocking the proper resource release.

    Selectively taken from 0914f7961babbf28aaa2f19b453951fb4841c03f
    from kernel/msm-3.10

Change-Id: Id5f19eef3b3db030854b7d40a188d5b23ed8da45
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Divya Narayanan Poojary <dnaray@codeaurora.org>
ASoC: msm: update min buffer count and size

Update minimum buffer size and count to provide more
options to the client.

Change-Id: Ia303978f4e4b230e021a2ae35146328b1c594460
Signed-off-by: Divya Narayanan Poojary <dnaray@codeaurora.org>
ASoC: pcm: update the start-up sequence for playback

Codec should be started before the adsp to ensure that there is no data
loss during playback.Current sequence enables the adsp first followed by
codec.This change updates the sequence prevent any playback data loss.

Change-Id: Iaf01d153f41a2f94d302ae7f4c1c98b1361dd24f
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
ASoC: q6asm: Fix the memory leak during the SSR

If a session is released during the SSR, then the memory unmap
command to DSP fails. This results in not releasing up the memory
block shared among apps and the DSP.
Fix by checking if the session has been invalidated during the SSR
and free up the memory during the close command.

Change-Id: I66251e624e5cc1abd816c2e4647997482b96c771
Signed-off-by: Aviral Gupta <aviralg@codeaurora.org>
ASoC: update codec driver to handle new SSR design.

Update codec driver to reduce the time for wait to check Q6 core
is ready.

LNX.LA.3.7 Change-Id: I06f7124dda56bf867df32c3a03a63e1ee0e2bd94

Change-Id: I2067772e2cb66a1b7a59a84ccf072927580a38ee
Signed-off-by: Divya Narayanan Poojary <dnaray@codeaurora.org>
ASoC: wcd9320: fix the no audio issue on triggering SSR

After the SSR is triggered there is possibility of the  mismatch
among  the cache register values and the actual hardware registers
values. Due to this some of the registers doesn't gets updated when
the enable sequence is triggered. This results incomplete path
getting enabled resulting in no audio.
Fix by updating the registers to the reset state and updating the
cache also. Also restart the mbhc for the proper headset detection

LNX.LA.3.7 Change-Id: I851c303928dad1a0f36951ad40ac0b6a912e1757

Change-Id: I00b6bc97ca8ab26bd2d4d25b5e0d967595075f65
Signed-off-by: Aviral Gupta <aviralg@codeaurora.org>
Signed-off-by: Divya Narayanan Poojary <dnaray@codeaurora.org>
ASoC: msm: reorg q6core header file

This is needed to allow include from
non soc folder.

CRs-Fixed: 689849
Change-Id: I753012d5ce9c5a788e75b4edf9b0099b58b30ec0
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
ASoC: msm: qdsp6v2: Add SLIMBUS 3 TX port as valid port

Add Slimbus 3 TX port to the list of valid ports.
Otherwise opening of this port will fail.

CRs-fixed: 682168
Change-Id: I53bdde37afb4c5b0773eff86bfcc45541532e4e7
Signed-off-by: Damir Didjusto <damird@codeaurora.org>
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
sched: Fix reference to stale task_struct in try_to_wake_up()

try_to_wake_up() currently drops p->pi_lock and later checks for need
to notify cpufreq governor on task migrations or wakeups. However the
woken task could exit between the time p->pi_lock is released and the
time the test for notification is run. As a result, the test for
notification could refer to an exited task. task_notify_on_migrate(p)
could thus lead to invalid memory reference.

Fix this by running the test for notification with task's pi_lock
held.

Change-Id: I1c7a337473d2d8e79342a015a179174ce00702e1
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
ASoC: msm: update platform driver to handle new SSR design.

Update PCM platform driver to handle the reset events during
SSR and also unblock the write wait according to
the new SSR design

Change-Id: Id0b4950ffc0eb130dbfdce36375629a683752044
CRs-Fixed: 661491
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
ASoC: msm: qdsp6v2: requeue read buffers in mmap device switch

When device switch happens, ASM might return a 0 length
buffer. For MMAP style capture cases, buffers need to be
re-queued at the event handler for this case, otherwise
ASM will have no buffers to read data into after the
device is over successful.

CRs-fixed: 700614
Change-Id: I2b8930a3058bbe3979405d5de04d3371291db42d
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
ASoC: msm: qdsp6v2: check proxy port is open when closing

The current logic opens the afe proxy port only if the
proxy instance virtual port is opened. If only
pcm instance virtual port is opened and a close of the
afe proxy port is attempted, this causes the device to
crash due to a wait event timeout as the driver tries
to close an unopened afe port.
The change ensures that only if both the virtual ports
are opened, which in effect starts the proxy port,
the afe close commands for the proxy port is sent to DSP,
else return immediately.

Change-Id: I9450001c608208f3d8da22b2881a88db1c21d950
Signed-off-by: Aravind Kumar <akumark@codeaurora.org>
ASoC: qdsp6v2: update perf mode flag for LL capture cases

Read perf mode flag from platform data and update to the
audio client structure, so that the right settings can be
applied to ADM for Low-latency capture use-case.
Also, update the correct bit value for ASM perf mode flag
sent to DSP.

Change-Id: If1f8b9e657a409fd9d2af19ff004a797fd987788
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>