ASoC: msm: qdsp6v2: fix the crash issues due to NULL pointer

If adsp subsystem restart happens, ac and apr handles are not valid
any more. While recovering subsystem restart and reassign proper
handles protection from accessing NULL pointer is required.

CRs-fixed: 513414
Change-Id: Idb60d3504a37c0de708846a4f8517f9d75eb9078
Signed-off-by: Fred Oh <fred@codeaurora.org>
ASoc: msm: qdsp6: Add ultra low latency playback support

Using ULL further reduces continuous latency when
compared to the current low latency path.
This is achieved by having no post-processing in
the DSP along with smaller buffer sizes

Change-Id: I81cb10db575b0fd3405fe6d051ccce4f8496bb32
Signed-off-by: Aleksander Holynski <aholynsk@codeaurora.org>
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
ASoC: qdsp6: Add support for gapless audio playback

Update ASM driver to support for gapless audio playback in
tunnel mode.

Change-Id: Id1f25afef25b3636fb50dc08b5feb803150d1b59
Signed-off-by: Ravi Kumar Alamanda <ralama@codeaurora.org>
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
ASoC: msm: Add support for gapless audio playback

Update compress driver to enable gapless mode in DSP to
achieve gapless audio playback in compress offload mode.

Change-Id: I212178025996f28ff5a3ddc361ceb7bd70b5d192
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
Signed-off-by: Ravi Kumar Alamanda <ralama@codeaurora.org>
ASoC: qdsp6: Add support for custom topology

Update ASM driver to send commands to DSP to enable
custom topology for enabling audio post processing
effects in POPP.

Change-Id: Ic222b5045820ebabb79148c8e51f5fd90fcd1410
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
Signed-off-by: Ravi Kumar Alamanda <ralama@codeaurora.org>
ASoC: qdsp6: Add support for audio post processing effects

Add interface to support configuring equlaizer, bass boost,
virtualizer and reverb effects in DSP for tunnel mode of
playback.

Change-Id: Ie1512e340315302691327b6379a0935170dc57a7
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
Signed-off-by: Ravi Kumar Alamanda <ralama@codeaurora.org>
ASoC: msm: Add support to enable audio post processing in DSP

Add interface to support configuring equlaizer, bass boost,
virtualizer and reverb effects in DSP for tunnel mode of
playback.

Change-Id: I5ed578df1e1cb860734d2205c0895e82cfbdfbfc
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
Signed-off-by: Ravi Kumar Alamanda <ralama@codeaurora.org>
ASoC: msm: Add playback support for AC3/EC3 in compress driver

- Dolby DS1 supports both AC3 and EC3 playback in compress
  path. Add code in offload compress driver to support
  playback of AC3/EC3 formats.

Change-Id: I4fb5ee01c47dd7ac083c6180693b87e9fbb4fa0a
Signed-off-by: Mingming Yin <mingming@codeaurora.org>
ASoC: msm: Enable initial/trailing silence removal

For gapless audio playback, the DSP HW decoder needs to
remove the initial and trailing samples from the decoder
output according to meta data present in the stream. This
change is to enable the silence removal by sending the
meta data down to DSP.

Change-Id: I8f9d5d64fee5874ef1eb2aba2ae38730cfe3e9bb
Signed-off-by: Ravi Kumar Alamanda <ralama@codeaurora.org>
ASoC: msm: Handle RESET_EVENTS in compress driver

Listen for RESET_EVENTS message in the q6asm callback and move
compress driver to an error state. All ops except free() are rejected
in this state.

Change-Id: Id12dba9e3a40b01f02e516857cb32af8f9e4cb60
Signed-off-by: Haynes Mathew George <hgeorge@codeaurora.org>
ASoC: msm: Disable gapless offload playback by default

Add a flag to platform private data to enable/disable gapless
playback. The platform data is updated by mixer control.
If gapless playback is disabled ignore next track and handle
partial drain as full drain. The stream is opened in gapless
mode based on the paltform data.

Change-Id: I36cea976bcb53f50069653aec4f0f8cc869f491a
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
ASoC: msm: Do not allow commands during gapless transition.

During gapless playback if flush is sent to the driver before EOS
acknowledgement from DSP, the playback is switched to stream one.
On EOS ack the stream one is closed resulting in no audio. The fix
is to not allow pause/resume/flush commands during transition from
one clip to other during gapless playback. Playback should move to
the second stream if the playback enters transition period.

Change-Id: I1be30956cce677e153ef5b8a362de303fec7620a

Conflicts:
	sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c

Signed-off-by: Panwar Vivek <vpanwa@codeaurora.org>
ALSA: compress: Memset timestamp structure to zero.

snd_compr_tstamp is initialized using aggregate initialization
that does not zero out the padded bytes. Initialize timestamp
structure to zero using memset to avoid this.

CRs-Fixed: 568717
Change-Id: I7a7d188705161f06201f1a1f2945bb6acd633d5d
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
ALSA: pcm: check for integer overflow during multiplication

Channel info data structure is parsed from userspace and if
user does not set the no. of channels correctly, it could lead
to security vulnerability if we don't check for overflow when the
no. of channels is multiplied with pcm bit width. Add a condition
to check for overflow during multiplication.

CRs-fixed: 537818
Change-Id: Ib9631b6e45d77b39be2c27343d4aee3e9244d8cc
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
ALSA: core: Fix crash by avoiding appl_ptr crossing 32-bit boundary

Incase of A2DP usecase using proxy driver, appl_ptr has
boundary value as 0x60000000 frames in sw_params for stereo(2 channels).
When this value crosses 0x40000000, then userspace calculating
appl_ptr at bytes results in crossing 32-bit value 0x100000000,
and points to 0x0 offset which can result in crash or pop.
To avoid above scenario, set the sw_params appl_ptr boundary value
within 0x40000000. Added proper check at sw_params update
to set this value correctly within 32-bit boundary(frames).

Change-Id: I537a04156699d90549a0a468ae19539ecd552d3b
CRs-Fixed: 483203
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
msm: usbaudio: Add check for NULL before dereferencing

kzalloc() and usb_ifnum_to_if() both APIs can return NULL. Current
code is not checking return value and derefencing which may crash
device if it is set to NULL. Fix this by checking return value
against NULL and handling the same.

CRs-Fixed: 562273
Change-Id: I0d2c910f43321e94fc447b19ae3e3207727e24f3
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
ASoC: Compress: Check and set pcm_new driver op

Check and set if pcm_new driver op is initialized by the driver.
This allows the compress offload drivers to register mixer
controls.

Change-Id: If54fa36cf19cbca7239d6e3e30455472e9a173d8
Signed-off-by: Ravi Kumar Alamanda <ralama@codeaurora.org>
ASoC :msm: Increase Proxy buffering

-Proxy buffering can overflow if BT playback setup takes a lot of time
-Fix this by increasing the proxy buffer size so that we will end
 up buffering the additional data that can come in during this time

Change-Id: I3b9acc848e0922bb26c87845fc6164f4266fbfa9
Signed-off-by: Amit Shekhar <ashekhar@codeaurora.org>

ASoC: msm: Increase Proxy buffering

-Proxy buffering can overflow if BT playback setup takes
longer than usual.
-Fix this by increasing the proxy buffer size so that
we will end up buffering the additional data that can come
in during this time.

Change-Id: I5d091ff12036a80dbf50fd14556b13852dd0cc24
CRs-Fixed: 547254
Signed-off-by: Amit Shekhar <ashekhar@codeaurora.org>

Revert "ASoC: msm: Increase Proxy buffering"

This reverts commit c1a463e27329c0a0016ccfc38c513bb760f82337

Change-Id: I88ffb9822184d8f227799a97a7cbceaf2f80f769
ASoC: msm: Fix playback failure on device switch during ULL playback

When a device switch happens for ultra low latency playback, we are
opening a regular playback COPP. ULL stream is routed to a non ULL
COPP. ULL stream can be only routed to a ULL COPP. This results in
playback failures. The fix is to use the perf mode flag as a
part of front end instead of back end dai.

Change-Id: I07f3f02b1414d2826a2f2d3f79b1bc0337cd3c32
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
ASoC: msm: qdsp6v2: Set ADM sample rate to 48Khz for ULL

ULL copp can only operate at sample rate of 48Khz. BT SCO back end
sets sample rate is 8Khz. ADM open for  ULL fails when backend is
BT SCO. Set the sample rate to 48Khz when adm is opened for a ULL
device session.

Change-Id: I18f18466324eebf2a2c8884b6e531155707996f4
CRs-Fixed: 545401 545397
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>