ASoC: msm: Fix for USB device switch

Add mutex locks to prevent sending multiple mem map
commands unless the previous one returns, because otherwise
the mem_handle is overwritten.

CRs-fixed: 646752
Change-Id: I2a472430d4505c9f74ed033260e1e99cb787e03a
Signed-off-by: Vicky Sehrawat <vickys@codeaurora.org>
ASoC: msm: propagate the error code from the compr driver

Propagate the error code to the upper layers to avoid the
unwanted sequence of the commands to DSP.

CRs-Fixed: 671241
Change-Id: I72b4700f01f6953c13e64878acf5bed882eb41a5
Signed-off-by: Aviral Gupta <aviralg@codeaurora.org>
ASoC: msm: set the master gain to 0 on DSP while configuring

- Mute media volume and play any music clip then reboot
the phone. Play music again noise comes. This noise
is introduced in DSP/LPASS.

- DSP suggestion is to mute master volume gain while
configuring ASM session to avoid such noise at
begining of asm playback.

Change-Id: I2aa2846d6e3e9a85c459534e9108e6fe7aebb962
Signed-off-by: Ramjee Singh <ramjee@codeaurora.org>

Conflicts:
	sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
ASoC: msm: qdsp6v2: clear old memhandle list when SSR happens

When SSR triggers, ASM gets RESET_EVENT callback.
Clear custom topology related old memhandle list here.
Otherwise for next ASM session opened after SSR,
old memhandle is sent to DSP and result in no audio.
Also, for ASM session while unmap during SSR, APR
command fail is expected, even then go ahead and
clear old mem handles relating to session.
Add changes to clear it from list.

CRs-Fixed: 592823, 589762, 592580, 590719, 589450, 593497
Change-Id: I10fc8190e929c7a4a344b1d393233e6cbcfcee97
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
ASoC: msm: qdsp6v2: Check for null data pointer

Add check for null data pointer in
aprv2_core_fn_q() and log error message if
true.

CRs-Fixed: 575228
Change-Id: I0d02913ced422ff3f396375c70ad6929908ee58d
Signed-off-by: Kenneth Westfield <kwestfie@codeaurora.org>
[SCSI] async: introduce 'async_domain' type

This is in preparation for teaching async_synchronize_full() to sync all
pending async work, and not just on the async_running domain.  This
conversion is functionally equivalent, just embedding the existing list
in a new async_domain type.

The .registered attribute is used in a later patch to distinguish
between domains that want to be flushed by async_synchronize_full()
versus those that only expect async_synchronize_{full|cookie}_domain to
be used for flushing.

Change-Id: I9ab0a06052d05da47c0a3d7f3ebc55e3968aa3cc
[jejb: add async.h to scsi_priv.h for struct async_domain]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Tested-by: Eldad Zack <eldad@fogrefinery.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
ASoC: Cold start latency reduction

This patch parallelizes FE (front end) and BE (back end)
when playback/capture path is set up. FE's and BE's which can
be parallelized should be indicated in corresponding machine file.
All the operations can be started asynchronously provided the usecase
supports asynchronous operation.
Parallelizing reduces the startup latency as both FE and BE opeations
run in parallel.

Change-Id: I9eeaf500b6d90d4def0adc1bdd6c219e49f676c7
Signed-off-by: Anish Kumar <kanish@codeaurora.org>

Conflicts:
	include/sound/soc-dpcm.h
	sound/soc/soc-compress.c
ASoC: msm: qdsp6v2: move hw_params into prepare

Asoc framework supports parallelization of operations
which reduces the startup latency.
Moving hw_params into prepare further reduces this start
up latency.

Change-Id: If38df2ba22daa94afdff8a7cd90263f4a1fafae7
Signed-off-by: Anish Kumar <kanish@codeaurora.org>

Conflicts:
	sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
ASoC: msm: Add MP2 decode support in compress driver

Add MP2 decoder support to ALSA compressed driver. It
allows user-space application to play MP2 audio data through
QDSP6.

Change-Id: I44c35ebe40a361c70bfde3caf88f4f4c6bb457e4
Signed-off-by: Dhananjay Kumar <dhakumar@codeaurora.org>

Conflicts:
	sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
ASoC: msm: Add support for WMA DSP decode

WMA V9 and WMA Pro tunnel-mode supports are added to
compressed driver. It allows user-space application to
decode WMA V9 and WMA Pro audio stream through QDSP6.

Change-Id: I99407d00b618a627e6d762be9abea4abd2410b8b
Signed-off-by: Manish Dewangan <manish@codeaurora.org>
Signed-off-by: Dhananjay Kumar <dhakumar@codeaurora.org>

Conflicts:
	sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
ASoC: msm: Fix wma pro block alignment parameter

The current code assigns and sends the wrong block
alignment information to the adsp because of which wma pro
playback fails. The fix assigns the correct block alignment
information for wma pro.

Change-Id: Ide475bbb8f98cd0201c2f8635a3ed831cd460194
Signed-off-by: Aravind Kumar <akumark@codeaurora.org>
ASoC: qdsp6: Add MP2 decoder format support

New ASM message format is added to support tunnel-mode MP2
decoder through QDSP6.

Change-Id: Icc25aae0945ac6cd3ba9d6eeacd8528dee952ae3
Signed-off-by: Dhananjay Kumar <dhakumar@codeaurora.org>
ASoC: msm: qdsp6v2: Update pcm media format block to use correct stream id

Repeat mode is not working in pcm offload path. When two streams
are used in a single session pcm format block should be sent
specific to each stream. Data sent on stream 2 is ignored by DSP
because pcm format block is always sent on stream 1. Fix is to
update pcm media format block to use correct stream id before
data is sent to DSP.

CRs-Fixed: 673510
Change-Id: Id9369f9927fbd301ed6020ea9e35942b54305610
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>

Conflicts:
	sound/soc/msm/qdsp6v2/q6asm.c
ASoC: compress: fix the target not going to TCXO shutdown

The error code propagated from the flush cmd in the trigger stop
is causing the error in the state of the soc compress framework.
This hinders in closing the BE connected to the FE.
If the AFE is not closed it prevents the target to go into TCXO
shutdown.
Fixed by removing the error handling of the flush command in the
trigger stop, since failure in flush doesn't signify the
failure in the stop command.

CRs-Fixed: 687111
Change-Id: I8f6e2bfbd0e59516ede2359dda4cedf027948a72
Signed-off-by: Aviral Gupta <aviralg@codeaurora.org>
Revert "ASoC: compr: Disable soft-pause for compress playback"

This reverts commit ece021021f54cfe776713d1bbaa6340a735b297f.

Change-Id: Ifd5997e125cf98d636b590dd0ea15f7f625e1695
Signed-off-by: Scott Mertz <smertz@cyngn.com>
ASoC: msm: Complete the wait_event request when SSR is triggered

LPA platform driver should complete the wait_event request when it
knows that SSR(sub system restart) has happened. There is no point
waiting and bailing out after timeout.

CRs-Fixed: 575060
Change-Id: Ia4a3a63c4e5f0a3153480998effe1c323c6ed6a5
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
ASoC: msm: qdsp6v2: Add support to improve debug logging

Improve debug logs by adding function names. This
change is required to fix rarely reproducible
customer issues.

Change-Id: Iea1ee6e91853f24e53608699c0b82fb4373bc8eb
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
ASoC: msm: qdsp6v2: update platform driver for 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.

CRs-Fixed: 661491
Change-Id: Id0b4950ffc0eb130dbfdce36375629a683752044
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
ASoC: msm: unblock the calls sent to the driver during SSR

Return error code ENETRESET from the platform driver
during the SSR recovery.
This facilitates the client to handle the error code
and take corrective measures rather than being blocked
on the call.

CRs-Fixed: 683288
Change-Id: I618edf0276bbe8826b47edec39df0dd4f87ffe93
Signed-off-by: Aviral Gupta <aviralg@codeaurora.org>
ASoC: msm: qdsp6v2: Fix read error using mmap

When capture session is started in mmap mode then
read commands are issued to ADSP after close command
is issued. This causes read failure as ADSP will not
process the successive read commands after issuing
close command. This change prevents issuing read
command to ADSP when capture session is not in running
state.

Crs-Fixed: 518008
Change-Id: I780fd42dffcd5ee4c051314aaf5f5b537815d8fe
Signed-off-by: Venkat Sudhir <vsudhir@codeaurora.org>