ASoc: msm: Refactor some codec functionality into separate files

- Add all codec driver common functionality in common file.
- Add separate files for codec drivers callback function
definitions to make it platform dependent.

Change-Id: I64665fcb420f9c7f3fa4bfdd2e7356347d7c48b2
Signed-off-by: Harmandeep Singh <hsingh@codeaurora.org>
msm: audio: qdsp6v2: Implement tunnel mode support in mp3 driver

Enable tunnel mode support in mp3 driver.

Change-Id: I9627dfe96c97ff61f1f6df7ad0e362da1402dd53
Signed-off-by: Karthik Reddy Katta <akkatta@codeaurora.org>
msm: audio: qdsp6v2: Fix noise in Tunnel mode Mp3/AAC audio playback

Modify the async_write API to send Encode bitstream buffer address
for non-tunnel mode with skipping meta data. And for tunnel mode
buffer address remains same as there is no meta data for
Tunnel mode and is sent to DSP without any change in this value.

Change-Id: Ie2ccd5a9ca2f72800afa11a818f65b90d374eb5b
Signed-off-by: Karthik Reddy Katta <akkatta@codeaurora.org>
msm: qdsp6v2: Reduce the step size of soft volume and soft pause.

With current step size, as there is raise in amplitude levels
abruptly, quality issues are observed. Reduce the step size to
zero to improve the performance.

Change-Id: Id0372a75736b610946a1ff53b4947e19ed62d400
CRs-fixed: 360715
Signed-off-by: Deepa Madiregama <dmadireg@codeaurora.org>
ASoc: msm: Refactor some codec functionality into separate files

- Add all codec driver common functionality in common files.
- Add separate files for callback function definitions.
- Add header files according to the platform.

Change-Id: I906811043d4bb33571f719f79988fbdb89f5c385
Signed-off-by: Harmandeep Singh <hsingh@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/Kconfig
	arch/arm/mach-msm/qdsp6v2/Makefile
	arch/arm/mach-msm/qdsp6v2/rtac.c
	sound/soc/msm/Kconfig
ASOC: Fix mutex unlock issues for error cases

Unlock mutex acquired within the same function during
error case handling, which was not unlocked before.
This could affect system stability if there are issues
in buffer memory allocations

Change-Id: I250dcb915181f4824375e31ab882ca021e61a65f
Signed-off-by: Swaminathan Sathappan <Swami@codeaurora.org>
msm: audio: qdsp6v2: PCM Encoder is configured to native channel count

Impact:
When the content switches from 5.1 channels to mono. Noise is heard
in one of the channels.

Problem:
At the start of the playback, number of output channels of PCM
Encoder is configured to 2 when the number of channels in the input
stream are greater than 2. This is done to confine maximum output
channels from PCM encoder to 2.

Change:
Modify output channel configuration of PCM encoder to native
channel count as Q6 decoder takes care for converting channel count
to 2 for the clips with channel count greater than 2.

Change-Id: I305e7c6d0e19977ae56503a8cdb0495231d51468
CRs-Fixed: 344426
Signed-off-by: Preetam Singh Ranawat <apranawat@codeaurora.org>
ASoc: msm: Add support for AAC and WMA decoders.

Add support for AAC and WMA decoders.

Change-Id: Iba66fdf71e852387015a0d03d0f1f9b5a0f09682
Signed-off-by: Harmandeep Singh <hsingh@codeaurora.org>

Conflicts:

	include/sound/apr_audio-v2.h
	include/sound/q6asm-v2.h
	sound/soc/msm/qdsp6v2/q6asm.c
msm: audio: qdsp6v2: Add RTAC voice lookup by CVP or CVS handle

Add functionality to look up RTAC voice structures by CVP
handle or CVS handle. The CVP ioctls now expect the CVP
handle to be sent instead of the CVS handle.

Change-Id: I2464e940a92b56632af45bc5649e323bed6113be
CRs-fixed: 397348
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
(cherry picked from commit cb32361aca99ffe1b3df2182fe4e5f8e857c05f1)
msm: audio: qdsp6v2: Set end of frame flag to avoid aac multiseek issue

- During aac playback, multiple seek lead to target freeze.
- DSP starts decoding when internal buffer size maximum is
  reached, hence, if there are corrupted frames in that buffer,
  the entire set will not be decoded. This results in target freeze.
- Fix is to set the end of frame flag in the buffers that
  are sent to DSP for decoding.

(cherry picked from commit 08508ac42fed7b1e3a7a9b7e098dfb4ceff8b836)

Signed-off-by: Swaminathan Sathappan <Swami@codeaurora.org>

Change-Id: Ic34272222dcb1df42d7e2fe5d028d513b8cf452f
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
msm: Add support for amr-wb+ non-tunnel driver

-Non tunnel playback is use case where compressed
 data is sent to driver(for decoding) and
 caller expects PCM data back from the driver.
-Add non-tunnel driver for amr-wb+.
-Add support for amr-wb+ in asm driver

Change-Id: I266e70dff0466a20b0435da840a31a8a1774cf35
Signed-off-by: Ajit Khare <ajitk@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/qdsp6v2/Makefile
arm: msm: qdsp6v2: update to finite loop

The reason why the original code requires infinite loop
cannot be accounted for. However, it seems reasonable to
wait for 10 minutes.

Change-Id: I057f7ac8a83585abbc4ccd63a721df82f71ea045
Signed-off-by: Patrick Lai <plai@codeaurora.org>
msm: audio: qdsp6v2: remove unmap ion region before disable

In the use case of audio playback in non tunnel mode, in audio release
unmap is called twice, before and after audio disable. This is
resulting to request DSP to unmap the region twice. Remove the unmap of
the ion region before audio disable.

CRs-Fixed: 443535

Change-Id: Iba44647063c85ab48091888ab5a583b6208dbb3e
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
arm: mach-msm: qdsp6v2: update dual mono setting check

AUDIO_AAC_DUAL_MONO_PL_PR is 0 anyway and dual mono
setting is defined as unsigned value. Hence,
there is no need if new setting is less than
AUDIO_AAC_DUAL_MONO_PL_PR.

Change-Id: I2e18a875e211d05d100d827fcd5b67545de168ac
Signed-off-by: Patrick Lai <plai@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/qdsp6v2/audio_aac.c
	arch/arm/mach-msm/qdsp6v2/audio_multi_aac.c
arm: mach-msm: qdsp6v2: remove unnecessary write count check

write count is never going to be negative value

Change-Id: Ie9468d4fbcccb2b7df87cbb67d0a911e584c8e62
Signed-off-by: Patrick Lai <plai@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/qdsp6v2/q6core.c
msm: audio: qdsp6v2: Fix seek issue in tunnel player

- Seeking to 0 position during tunnel playback, music stream
  jumps to incorrect postion.
- Initial buffer after seek to new position is corrupted as
  flush ioctl is not synchronous. Ioctl FLUSH is posting
  CMD_FLUSH to DSP, but WRITE_DONE to user space are posted
  even before it receives FLUSH ack from DSP.
- Fix is to wait for FLUSH ack from DSP, then post the
  WRITE_DONE events to user space, which will ensure FLUSH
  is completely handled.

CRs-Fixed: 425420,458910
Change-Id: Ieca3353dba3a67af39a2967659034f073acf5277
Signed-off-by: Deepa Madiregama <dmadireg@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/qdsp6v2/audio_utils_aio.h
	arch/arm/mach-msm/qdsp6v2/q6audio_v1_aio.c
msm: audio: qdsp6v2: Fix the issue of memory unmap

- Target freeze observed during monkey run.
- Memory unmap getting called from interrupt context,
  which is causing scheduling during atomic operation.
- Avoid calling memory unmap from interrupt context.

(cherry picked from commit a64fae9ba272ba2f689f30bc7b33c8a1fe4445e5)
Signed-off-by: Deepa Madiregama <dmadireg@codeaurora.org>

Change-Id: Iab9372ba1b2d560c7e161f39483478f0342ac30a
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
msm: audio: qdsp6v2: Fix command sequence issue in Non-tunnel player

The CMD_CLOSE and CMD_UNMAP needs to be sequentially sent to dsp.
Avoid sending CMD_UNMAP if CMD_CLOSE is not sent.

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