Revert "soc msm: lowering gain level and steps to avoid distortion"

This reverts commit 26ac4ec25b7d991b47e4a9bce9d8e53fb20daad9.
ASoc: msm: Add low latency playback and recording support.

- Add lowlatency pcm driver for Playback and Recording.
- Add support in target board files
- Add Recording Path to Multimedia5 FE DAI
- Add support in routing, platform, machine drivers
- Add low latency interfaces support in ASM and ADM drivers.

Change-Id: I1beb11db9010534e5aa91179ac6040a41622185d
Signed-off-by: Jayasena Sangaraboina <jsanga@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/board-8064.c
	arch/arm/mach-msm/board-8930.c
	arch/arm/mach-msm/board-8960.c
	include/sound/apr_audio.h
	sound/soc/msm/apq8064.c
	sound/soc/msm/msm-pcm-q6.c
	sound/soc/msm/msm-pcm-routing.c
	sound/soc/msm/msm-pcm-routing.h
	sound/soc/msm/msm8930.c
	sound/soc/msm/msm8960.c
	sound/soc/msm/qdsp6/q6adm.c
	sound/soc/msm/qdsp6/q6asm.c
ASoc: msm: Add lowlatency playback and recording routing
controls

- Add BT, FM, PROXY routing controls for lowlatency playback and
recording

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

Conflicts:
	sound/soc/msm/msm-pcm-routing.c

Change-Id: I3ecef21d1c445875b6140f3c3cfdec891b5f7b24
ASoc: msm: Update platform drivers to correctly access audio_client

Update platform driver open function call to access
audio_client pointer only after allocation to avoid crash.

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

Conflicts:
	sound/soc/msm/msm-compr-q6.c

Change-Id: I735e2af9067f3507927c83e2da108d5a65107740
ASoC: msm: Add volume support for Multimedia5

Add support for controlling pcm audio volume in DSP through
Multimedia5. Add TLV mixer control to set the pcm stream volume

Change-Id: Ie5f50c4f47ea57fe4be0aef1320c79a9d3fe7600
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
ASoC: msm: Add metadata mode changes to LPA driver

Playback hangs for three seconds on seeking to EOS. This is
because the lpa driver works on period size. Partial buffers
are not handled. Add metadata mode changes to LPA Driver to
support partial frames.

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

Conflicts:
	sound/soc/msm/msm-pcm-lpa.c
	sound/soc/msm/msm-pcm-q6.h
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>

Conflicts:
	sound/soc/msm/msm-compr-q6.c
	sound/soc/msm/qdsp6v2/msm-compr-q6-v2.c
	sound/soc/msm/qdsp6v2/msm-pcm-lpa-v2.c
	sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
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>

Conflicts:
	include/sound/compress_offload.h
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>

Conflicts:
	sound/soc/msm/qdsp6/q6voice.c
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: 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: 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>

Conflicts:
	sound/soc/msm/msm-compr-q6.c
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>
Revert "ASoC: msm: Support independent left-right channel volume control"

This reverts commit ce7ff8280df9050ed6acac88507dc1e05d3fb106.
msm_serial_hs: Fix synchronization between ADM and UART Cores

With current UART Core programming sequence, it is seen that ADM
and UART Core are going out of sync in few usecases with regression.
It is fixed by using Force RxStale feature of UART Core from
set_termios() and sending discard flush to ADM which would terminate
currently queued UART RX CMD to ADM. Add termios_in_progress check
to make decision about what kind flush to send on receiving RxStale
interrupt. It makes set_termios() more reboust and also keeps ADM
and UART Core in-sync.

Add dma_in_flight to keep check of UART Rx CMD status and BUG_ON if
UART driver is trying to queue one more UART RX CMD to ADM as UART
driver re-uses same UART RX CMD.

This change also adds check of currently set uartclk rate and next
required uartclk rate for new baud rate. If both are same it would
not call clk_set_rate() to set same uartclk rate again.

UART baud rate change request (i.e. executing set_termios()) can come
asynchronously and time to program ADM hardware with queued CMD by ADM
driver is non-deterministic. It is required by UART driver to confirm
that queued RX CMD is programmed with ADM hardware before going with
requested baud rate change operation. Hence this change wait in
set_termios() for ADM driver to program queued RX CMD before going ahead
with baud rate. Otherwise ADM may encounter data bus error with UART RX
channel which is unrecoverable.

Change-Id: I678e91420b33a49ce8b6a5a29c6309f9ff6f5c4a
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
msm_serial_hs: Disable UART RxStale before Force RxStale in set_termios

There is possible race for handling normal RxStale event and Force
Rxstale event with UART Core, when Force RxStale is issued from
set_termios(). Hence on baud rate change request disable RxStale event
mechanism, and invoke Force RxStale. With RxStale event mechanism
disabled, Force RxStale still generates interrupt.

Fix possible race condition if before completion of previous UART RX CMD
flush, set_termios() request is received. With this case it is quite
possible that rx_tlet() queues one UART RX CMD with ADM driver and also
set_termios() queues one more UART RX CMD which would results with
queueing same UART RX CMD twice with ADM driver. With this device would
crash as the ADM driver will not be able to de-reference the second UART
RX CMD work. Hence add check in set_termios with rx.flush value as
FLUSH_DATA_READY which confirms that flush is initiated but it is not
completed and wait for rx.flush to become FLUSH_NONE which would happen
only once flush is completed and new UART RX CMD is being queued with ADM
driver.

Reduce waiting time for discard flush completion as it is already waited
for queued UART Rx CMD to be programmed with ADM hardware. Hence change
wait time out from 300 jiffies to 50 mseconds.

Add an API to get important UART core registers values which can be called
from error condition. Use the same when discard flush timeout happens with
set_termios(), when rx.dma_in_flight is not set with set_termios() and when
multiple UART RX CMD queueing condition is seen in msm_hs_start_rx_locked()
API.

CRs-Fixed: 486260
Change-Id: I9fd17e453fad619609e76e8b3a72a4f47210cff9
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
bluetooth: Remove bluesleep_bcm

Squash of the following commits:

Revert "bluetooth: Fix race conditions in BT LPM"

This reverts commit 096a4f8d351d1ed5e0cfea9dd896b89f78d2f438.

Conflicts:
	drivers/tty/serial/msm_serial_hs.c

Change-Id: Ie9f39e7976b085a80e838bba2bc820f312ee8a71

Revert "bluetooth: Add low-power mode to support Bluedroid"

This reverts commit 595c90c30e5cfa8f91b795fe57a6a796f00beb71.

Conflicts:
	drivers/tty/serial/msm_serial_hs.c

Change-Id: Ia4941f5b650dcd66a32a870e6c726b68dd46329c

Revert "Add bluedroid compatible bluesleep and utilize it."

This reverts commit df67b974ec101f4ee6b241a82313c8e85b44b237.

Change-Id: I7e1dd61062deb071c3a9d00872d63310234060b4

Conflicts:

	drivers/bluetooth/bluesleep_bcm.c
bluetooth: bluesleep: Bluetooth active power management driver

A new driver is implemented to actively manage the bluetooth module
power. bluesleep also tries to manage the power of the transport used.

Two signals (GPIOs) are used to manage the power events.

BT_WAKE  : signal from HOST to BT chip to intimate BT chip can sleep.
HOST_WAKE: signal from BT chip to HOST to intimate HOST should wakeup/
activate the transport modules required for BT communication.

Change-Id: I96202e1cc67dbcbcfa2be874aa2d845e8350f755
bluetooth: Fixed ld mismatched symbols

The driver data structure referenced a function point which is defined
as __init data. This caused symbol mismatch error. This could be fixed
by defined driver data with __init macro, otherwise, by cancel __init on
probe function. Have this done in a safe way.

This file is removed in upstream. It seems that is the only chance to
fix it in our own repository.

Reviewed-on: http://git-master/r/20931
Reviewed-by: David Schalig <dschalig@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Chao Jiang <chaoj@nvidia.com>

Change-Id: I3eba3578c84d8ec67707a276841d72f98c47267d