ASoC: wcd9xxx :Modify detection of Euro Headset

Detect the cable as EU Headset only if below conditions met.
1.Plug types for 1st, 2nd, 4th are consistent and equal to HEADSET.
2.Delta b/w 1st, 2nd, 4th is not more than WCD9XXX_CS_MEAS_DELTA_MAX_MV.
3.Plug type of the 3rd measurement is HEADPHONE.
4.Don't consider the status of HPHL.

Signed-off-by: Yeleswarapu, Nagaradhesh <nagaradh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Change in sequence of HPH Rx path

Change HPH Rx path sequence to enable Rx clock and reset Rx interpolator
path before HPH DACs enable to avoid pop during bringup of device path.

Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Set HPH PA register to volatile

Set HPH PA register to volatile to make sure the register will be
updated with proper bits during bringup

Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: Fix the sync problem after SSR

After SSR default registers needs to be restored. Then
we need to sync all the registers with cache values. This
fixes the problem where register values got changed
after SSR causing AAC clip playback failure.

Signed-off-by: Anish Kumar <kanish@codeaurora.org>
Signed-off-by: Fred Oh <fred@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: msm-hdmi-codec-rx: sync state with HDMI core

To keep the state of the HDMI core and HDMI audio
sessions congruent, audio checks the state of the
core on startup, then notifies the core of the
active audio session.  On shutdown, notifies the
core of the event.

Signed-off-by: Kenneth Westfield <kwestfie@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: msm-hdmi-codec-rx: update check for HDMI core state

HDMI Tx core driver API "hdmi_cable_status" returns 0
if cable is not connected and returns "1" if cable is
connected. Audio session should only be started when
HDMI cable status is "1". Update HDMI codec driver to
have this status correctly conveyed to HDMI audio
sessions on startup to notify the active audio session
not to proceed with HDMI audio settings any further.

Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: compress: Update lock for dpcm calls

Compress driver calls into the dpcm framework when
usecase is started/stopped.When calling dpcm framework
api's it should acquire dpcm mutex.
This change replaces the card mutex with dpcm mutex when
dpcm apis are called.

Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoc: msm: Read the MBHC interrupt initial status from device tree

Some device need to set MBHC gpio_level_insert as zero. So that value should
be configurable. We can read initial value from device tree for that.

If gpio_level_insert is zero, register WCD9XXX_A_MBHC_INSERT_DETECT is 0x6C.
otherwise, that value is 0x68.

If the initial value is set incorrectly, spurious interrupt would occur.

Change-Id: I27da1332d053da157311decf18985f633800c303
Signed-off-by: Sangwoo Park <sangwoo2.park@lge.com>
Signed-off-by: Devin Kim <dojip.kim@lge.com>
audio: ocmem: fix the ocmem driver crash during video playback

Triggering SSR during wait for client callback by the audio
ocmem driver causes de-reference of freed memory in ocmem_free
function. Fixed by assigning NULL to the ocmem buffer pointer after every
ocmem_free function call.

Signed-off-by: Anish Kumar <kanish@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: msm: Reset the stream open flag after CMD_CLOSE is sent to DSP

In case of gapless playback, driver does not wait for EOS. CMD_CLOSE
for stream one or two can be called from compress driver free before
EOS ACK for stream one is received. This can result in CMD_CLOSE to
be sent for already closed stream. Reset the stream open flag after
CMD_CLOSE is sent to DSP to prevent multiple CMD_CLOSE on same
stream.

Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: msm: qdsp6v2: fix possible integer overflow

Check integer overflow before multiplying struct size. If that happens
should return immediately. In addition if param length is greater than
MAX size from spec, better return error.

Signed-off-by: Fred Oh <fred@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: msm: Update the correct channel count for dolby configuration

Wfd supports both 5.1 and stereo pcm playback. Add the dolby
configuration for 5.1 playback on wfd.

Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoc: msm: Fix for pcm_read getting struck in alsa core.

Advance hardware pointer by period size even if the packet
size is 0. QDSP6 sometimes(for rapid device switches) gives
0 size packets and this results in elapsed_timeout in pcm core.

CRs-fixed: 578738
Change-Id: I4578b1d3566d5f3eea965102b00fdb4c6838765d
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
(cherry picked from commit 2c18c9501ce62998d8ad84fd7d47e5edb2a2b39f)
Fix Sterio Call Recording. as here http://review.cyanogenmod.org/#/c/64452/
ASoC: msm: qdsp6v2: Add upper bounds check on index

Add upper bounds check for return value of
q6audio_get_port_index().

Signed-off-by: Kenneth Westfield <kwestfie@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: msm: qdsp6: Add support to configure ISO and ARIB coefficients

Add support for configuring ISO or ARIB stereo mixing
coefficients. This change introduces a function with which,
AAC multi-channel driver can configure ISO or ARIB coefficients
according to configuration done by the client.

Signed-off-by: Amit Shekhar <ashekhar@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: msm: qdsp6v2: fix slow_talk not disabled issue

If slow talk is disabled from the settings menu after voice
call is ended, the command is not sent to dsp since the voc state
is not in VOC_RUN and on next call CVS still has slow talk property
enabled. Fix by disabling slow talk when voice call is ended.

Signed-off-by: Shiv Maliyappanahalli <smaliyap@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>