ASoC: msm: Support independent left-right channel volume control

The current volume sent to DSP is averaged between left and
right channels. As a result with volume level as zero on one
channel and non zero on the other channel results to playback on
both channels. Add support to send left and right volumes to DSP

Change-Id: Icc5f182d138c841607ea356ec37a7f78b4ba770d
CRs-Fixed: 449284
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
Signed-off-by: Jay Wang <jaywang@codeaurora.org>
ALSA: include: Add new ioctl for metadata mode

Add a new ioctl to support metadata mode in lpa driver. This ioctl
allows lpa driver to work in default alsa compliant mode and also
metadata mode.

CRs-Fixed: 458904
Change-Id: I8111e8652bbfb6dd93bdbda69bd16f53b45cb756
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
ASoC: Avoid putting stream state to STOP when stream paused

When multiple Front-end are using the same Back-end, putting
the stream state for a Front-end to STOP will make the the Backend
stream to be released, when the front-end is paused. This will avoid
the Backend to be released (when another active front-end stream is
present).
Instead, put the stream state to PAUSED, which will keep the Back-end
ON.

Change-Id: Ic31bf90a09b605b91f6b9fe3c09361b1145581fb
CRs-fixed: 428825
Signed-off-by: Banajit Goswami <bgoswa@codeaurora.org>
ASoC: msm: Add support for external EC reference point

Add mux to sound card topology with output of mux routed
to CS voice uplink front-end as way to indicate external
EC reference point. Currently, MI2S_TX is the only
AFE input port defined for this MUX.

Change-Id: I0c81c579cc01bf92e743eda0e8dee15be2a8c01f
Signed-off-by: Venkat Sudhir <vsudhir@codeaurora.org>
ASoC: audio: Fix BE not disconnected even codec teardown

Scenario:
When FE1(LowLatency) comes in which opens BE1 and puts it in state
SND_SOC_DPCM_STATE_START. Similarly FE2(LPA) comes in with
connecting to same BE. Now FE2 is in SND_SOC_DPCM_STATE_PREPARE
state and waits for TRIGGER_START. Meanwhile FE1 is closed which
doesn't affect BE1 and FE2 which are connected.
Also, for FE2 pcm_close is called before TRIGGER_START itself.
In such a case, BE1 is not getting disconnected (afe_close is
not called) while Codec is teared down resulting in Slimbus
overflow.

Fix:
Whenever BE1 is found to be in SND_SOC_DPCM_STATE_START state
and FE1 being connected is not started yet, and close sequence
happens for this FE, then allow hw_free to happen for BE1 if
this is the only FE connected to this BE1. This allows BE to be
disconnected which calls afe_close then followed by Codec teardown
not resulting in any Slimbus overflows.

CRs-Fixed: 468118
Change-Id: I03a80a12c1fd0cf09bd2e3dfe1f1eb56589016d3
Signed-off-by: Laxminath Kasam <lkasam@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>
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>
ASoC: msm: skip sending volume in compressed pass through playback

For the playback use of compressed pass through on HDMI device,
post processing features are not supported and should not be sent to
DSP. Hence the change is now to send the volume only for the playback
of decode and render in DSP and skip for compressed pass through

CRs-Fixed: 442140
Change-Id: I2125f08baf1676f6bb1d13463a1f01dfe280963f
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
ASoC: msm: Fix for improper volume ramp up in tunnel playback

A disturbance is heard when resuming the playback after
switching from headset to speaker and back to headset with the
music paused for more than 3 sec. This is due to, data getting
rendered with the speaker volume where it had to played with headset
volume. Fix is to set the '0' as the initial volume.

Change-Id: Ie4726a7898620fb912279270e24fa15a45a437f9
CRs-fixed: 453704
Signed-off-by: Amal Paul <amal@codeaurora.org>
ASoC: msm: Fixes for underrun issue in LPA Playback

Update LPA platform driver to register restart callback.
The implementation of the callback is to issue a pending buffer
written by the application to restart the session when the dequeue
process is stopped due to underrun issue.
The callback is triggered from ALSA core when the framework
detects that the renderer stopped pulling data but the application
is still writing data. It runs in atomic context.

Fixes:
-A disturbance was heard when switching from one song
to the other, or when the song is paused for greater
than 3 seconds and then resumed
-This was due to the previous value of the track
volume being used in the lpa driver
-This was fixed by setting 0 as the initial volume

Change-Id: I035760937d032038fb3f3383dc87ecbdc5f4700d
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
ASoC: msm: Resume writes only for start command

For compressed and LPA drivers, set pending_buffers flag to 1 only if the client
issues a trigger_start command, not a pause_release command. This flag
is used to initiate writes to the dsp.

Change-Id: I503156863646210b460613a0b9a26a6bfb8854ed
CRs-Fixed: 442269, 449126
Signed-off-by: Haynes Mathew George <hgeorge@codeaurora.org>
ASoc: msm: update the pending buffer flags in underrun

Update the pending buffer flag on a driver underrun.
This causes a drain call to be rejected if the underrun
happens immediately after an EOS buffer has been given to the DSP
following a flush

CRs-Fixed: 463332
Change-Id: I2ba224a49e5af14ca909300afc0788cb4b21eb16
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
asoc: Kill logspam in compressed audio driver

Change-Id: I415036d4d8fd6729f1ee14a29dafc5efd6b98a4a
asoc: Add stream id to Samsung specific functions

Change-Id: Ibffc4ba974c8139744d3e1914988ae4ac6368eff
asoc: msm: Add flexible period count to pcm record driver

 In pcm recording, if buffers are not requested from dsp at real
 time then dsp drops the buffers and sends partial buffers. This
 is causing record failures. Pcm record platform driver has two
 periods. If system is loaded, read request will not be at real
 time. Add flexible period count to pcm record platform driver
 so client can configure the period count.

CRs-Fixed: 467746
Change-Id: Iadd47979f7b29a01fb8e6479383094a2ed1d93c5
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
msm_fb: Set RR sched policy for Glupdator thread

Set Round Robin Scheduling policy for GLUpdator
thread to improve performance.

Change-Id: I637ca364d325d6c847c73e8eec403e76094d93c5
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
Signed-off-by: Ken Zhang <kenz@codeaurora.org>