spmi: Add del_controller functionality

The del_controller function is required to release any client device
resources as well as the debugfs entries.  This patch adds that
functionality.

Change-Id: I91c6b840acfe002f096570cbe1867b302c475e60
Signed-off-by: Kenneth Heitke <kheitke@codeaurora.org>
spmi and gpio: qpnp: add pointer check in qpnp drivers

This patch is to fix KW errors in drivers. It's
neccessary to check NULL pointer before dereferencing it.
There're 4 issues related to it in qpnp-int.c and
qpnp-pin.c. Fix them by checking before.

CRs-Fixed: 505322
Change-Id: I2f82d1b24c219ef7e6b0977091fc353dac579cbc
Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>

Conflicts:
	drivers/spmi/qpnp-int.c
spmi: Add check for NULL and invalid controller pointer

Replace the BUG_ON() check with a NULL pointer check and verify that
the controller type is set appropriately.  This prevents a system crash
due to invalid input.

Change-Id: I858980ad54ba0d764219049a20b4ca3e9b77f72e
Signed-off-by: Kenneth Heitke <kheitke@codeaurora.org>
spmi: qpnp-int: call arbiter ops only when all peripheral irqs are disabled

The current driver calls arbiter ops when an interrupt is being
masked or unmasked. However, the arbiter ops were meant to be
called if all interrupts for a peripheral were disabled or
the first enable happens.  The driver ends up masking the peripheral
(i.e.  all the interrupts in that peripheral) if any one interrupt in
that peripheral is masked. There could be other interrupts enabled
which will not trigger after this.

Fix this by changing the driver to call the arbiter ops only
when all the interrupts in the peripheral are disabled or when
the first enable of an interrupt in that peripheral happens.

Also take this opportunity to clean up the arbiter ops calls to
specifically write to the INT_ACC_ENABLE bit instead of entire
register as specified in the data sheets.

Change-Id: If5835ac125f59d2964242758aa9f9ef145000af7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
spmi: qpnp-int: show resume irq

Add code to print the interrupts that woke up the device from
resume. Use syscore resume operation to print the interrupt
number.

Since most of the systems have only one arbiter control, it is
reasonable to create a file scoped PMIC arbiter pointer for the
syscore resume operation.

CRs-Fixed: 502334
Change-Id: Ib4be9273633a70527a853fb5792543d66c8d2303
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
spmi: Inline a function to remove compilation error

Compilation error is seen in spmi_dfs_add_controller
function when debug fs is disabled.
In this patch this function is defined as static
inline to remove this error.

CRs-Fixed: 555022
Change-Id: I66ac9ca9eeb1e25c68c9deff665258f4e036a678
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
ASoC: usb: change uevent value to digital USB HEADSET

The uevent of usb_audio has two components - analog, digital.
When usb_audio is set to 1, uevent is set to analog.
But, this is incorrect type. The usb audio interface should be
digital. So, it changed to 2 - digital.

Change-Id: I646301a15a8b3badd9f1794d98c451b2d9f42293
Signed-off-by: sangwoo <sangwoo2.park@lge.com>
ASoC: msm: Add routing for HFP using AFE and ASM Loopback

HFP hostless driver is used to loopback BT data into
SLIM_0_RX. And asm loopback MM6 is used for looping
data from mic to BT so that pre_proc effects can be
added.

Change-Id: Ic818b91c545a4d17043ecdf933d6d3398ad591d3
Signed-off-by: Vimal Puthanveed <vimalp@codeaurora.org>
ASoC: msm8974: Fix external speaker power amp shutdown sequence

External speaker power amplifier should be disabled when all
the lineout power amplifiers are shutdown. When lineout is
shutdown bit mask was not cleared, due to which external power
amplifier will not be shutdown. Change clears the
bit mask for each lineout that is powered down.

Change-Id: I740653cbb6605708b38c915d59415f5b7f0c6d74
CRs-fixed: 497619
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
ASoC: msm8974: Add support for HFP

Add support for HFP for 8974 target.
Front end dai for HFP hostless for RX and MM6 for TX for HFP

Change-Id: I0406bd2b10c3daab4d583c690f27a9ba1d09af60
Signed-off-by: Vimal Puthanveed <vimalp@codeaurora.org>

Conflicts:
	sound/soc/msm/msm8974.c
ASoC: msm: Defer probe during sound card registration

ASoC framework returns probe defer when all the
components of the sound card are not registered.
MSM audio machine driver has to handle the probe
defer gracefully.

Change-Id: I39a65fe17c31205a9d8c3610fa0909fbf7891a83
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
ASoC: msm: qdsp6v2: Add timestamp in voip frame header

Uplink timestamp needs to propagate to userspace for AV sync.
timestamp field is added in voip frame header to
capture the timestamp from LPASS for each uplink packet.

Change-Id: Id701df56e5a3d36bf83771ba9731c61a03dae3ba
Signed-off-by: Helen Zeng <xiaoyunz@codeaurora.org>
ASoc: msm: Fix for pcm_read getting struck in alsa core.

Advance hardware pointer by period size even if the packet
size is 0. QDSP6 sometimes(for rapid device switches) gives
0 size packets and this results in elapsed_timeout in pcm core.

CRs-fixed: 578738
Change-Id: I4578b1d3566d5f3eea965102b00fdb4c6838765d
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
(cherry picked from commit 2c18c9501ce62998d8ad84fd7d47e5edb2a2b39f)
ASoC: msm: qdsp6v2: Add support for probe deferral in audio ocmem driver

It is possible that ocmem notifier register would return
EPROBE_DEFER when ocmem driver probe is not completed
successfully. Add support to handle this probe deferral
in audio-ocmem driver.

CRs-fixed: 565880
Change-Id: Ia314cd6d2f6f48478406604115e616d7cabfc15c
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
ASoC: msm: q6: check upper bounds when copy ac3 params

Although AC3 maximum param size is fixed, better check upper bounds
when copy user data. It might cause overflow, possibly cause memory
corruption.

Change-Id: I2f7cec8edd9e013de1433ea06480b963ec307196
Signed-off-by: Fred Oh <fred@codeaurora.org>
ASoC: msm: qdsp6v2: Fix bug in device V2 command

This change is to fix missing braces in Device V2
command. Without the braces Device V2 command will
return error code even though the command is
successful. Device V2 command is used to send device
configuration to CVD during voice call. This command
is used to inform ADSP about internal or external EC mode.

CRs-Fixed: 492994
Change-Id: I2bf12b8cdbc6765bffb2ed9e6460160cf8afa81a
Signed-off-by: Venkat Sudhir <vsudhir@codeaurora.org>
ASoC: msm: Move ASM custom topology data out of Debugfs define

Move variables used for ASM custom topology out of
the debugfs define. ASM custom topology should be
enabled even when debugfs is not.

Change-Id: Ie16191c04d80981e48e11ddda71ccbe1ccbc18ca
CRs-fixed: 551711
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
ASoC: msm: Add missing backends for Multimedia4

Some backends for the front-end Multimedia4 is missing in the
routing driver. This results tunnel recording failure for
USB headset/BT SCO usecases.

Change-Id: I7998309df4e7da9545bdc75e9b67873cc0417870
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>

Conflicts:
	sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
ASoC: msm: Add error returns to ACDB driver

Change the ACDB kernel driver to return error codes
for any failures.

Change-Id: Ib2ffab8c9e5e9a044bbaaf83bd879d6b17c3918d
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
ASoC: msm: Add voice volume boost support

Add support for the volume boost feature. Volume
boost pushes a new voice volume table with boosted
gains. To support this feature new API's are added
to the voice driver to register & deregister the
voice volume table. New IOCTLs are also added for
audio_acdb to support registering & deregistering
tables.

Change-Id: I154fdedad78760393e2cd8cc11fa10178dfce320
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>

Conflicts:
	sound/soc/msm/qdsp6v2/q6voice.c