ASoc: msm: Increase default buffersize to 4k for audio playback

- Increase default buffersize to 4k from 2k for audio playback
  when HAL is configured with deep buffer output.

bug-id: 7129131
Signed-off-by: SathishKumar Mani <smani@codeaurora.org>

Change-Id: I12ddbbc2423552b1c069b435ec49839173bb4649
msm-pcm-q6: Add support for flexible recording period size

- Current implementation supports only fixed buffer size
  of 320 bytes only for audio recording. This results in
  performance overhead for recording at higher sample rate.
- Added support for flexible period size so that user can
  use larger buffers for recording at higher sample rates.

Signed-off-by: SathishKumar Mani<smani@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>

Change-Id: I50c66bbe67b7d35ef299c4d1123a95ff7e9bedfb
ASoC: msm: Decrease the playback period size of PCM driver

To support the deep buffer output, the playback buffer size is
increased to 4k from 2k. Reverting the change as the support for
deep buffer output is no longer valid.

Change-Id: I5034245bde4b55a5816506fbdfeac970a8e7804b
CRs-Fixed: 438177
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
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>
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: Modify min and max period bytes and num periods

Modify min and max period bytes and number of periods in
compressed driver so as to be consistent with lpa and to
meet ION memory requirements. This avoids using huge
buffer sizes for tunnel decode.

Change-Id: Ib71da4cebfc097e7aeaf0ca0e65ee847ba7cceb7
Signed-off-by: Phani Kumar Uppalapati <phanik@codeaurora.org>
ASoC: compr: change sequence of softvol

As the ASM session is opened in hw_param the soft volume does
not take effect. Hence move it to hw_param so its applied after
asm open.

CRs-Fixed: 434323
Change-Id: I1ce24d74382bd2c1926df2d63ff2eb40b0652f95
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
ASoC: msm: Register restart api for under run issue.

Update compressed platform driver to register an restart callback.
Implementation of the restart callback is to issue an pending buffer
Written by application to restart the session when  the de queue
Process is stopped due to underrun issue.

Restart callback is triggered from the ALSA core framework when
Framework detects that the render stopped pulling the data
And application is writtig the data.

This callback will be running in atomic context.

Change-Id: Iada382f39bd052beeb0b1d165959d510fa51ff7c
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
ASoC: msm: Allow drain only if a write was called

For compressed drivers, allow the drain ioctl only if
there are pending writes. Return a proper error (-EWOULDBLOCK) otherwise.

Change-Id: I4799351a8930c44d88d6968802df98896fc1531a
Signed-off-by: Haynes Mathew George <hgeorge@codeaurora.org>
CRs-Fixed: 445370
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: 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: 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>
ASoC: msm: Fix wrong wait_event_timeout timeout checks

wait_event_timeout returns zero when there is a timeout.
Change fixes the condition check to handle timeouts.

Change-Id: I01184cce0c98a82bb205023b07dd4dd2d91b42ad
CRs-Fixed: 487821
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>