ASoC: wcd9xxx: fix HPHL DAC path enable sequence

The dac_ref_en bit should not be turned ON by codec
driver when headset is inserted. Setting the
dac_ref_en bit, and not resetting it when headset is
removed, will cause the DAPM framework to keep HPHL
DAC path connected.
This change returns the ownership of setting the
dac_ref_en bit to DAPM framework and fixes the HPHL DAC
path enablement issue when headset is inserted.

CRs-fixed: 483600
Change-Id: Iabfe09a82507579a443b87458dc8dba0d2cd5ce5
Signed-off-by: Banajit Goswami <bgoswa@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9320: Set HPH bias currents to low power mode

Setup the headphone path PA and DAC bias currents to low power
mode to increase power consumption efficiency

CRs-fixed: 485961
Change-Id: I9492e70f404f96502c7283b38f0d1f3738647d4c
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: msm: q6: update render flag to NON_DMA for handling underrun

In scenarios where the driver is in underrun state, restart
mechanism triggers when the render flag is in NON_DMA mode. The
compressed driver which is opened in mmap mode runs into underrun
scenarios when the valid buffer length is smaller than the
buffering in the DSP. Update render flag accordingly so that the
restart is trigger when driver is in underrun state.

CRs-Fixed: 487732
Change-Id: Ia4ee5dcf1d079ebef69e9ee627591bc039934add
Signed-off-by: Jitendra Singh Naruka <jnaruk@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: ultrasound: support up to eight TX and RX channels

Ultrasound digital pen service requires six TX channels for
the service performance improvement.

Change-Id: Id01f9cf2c9df6a55a72bfa395ffe1c2e85d8cdc7
Signed-off-by: Ravit Dennis <rdennis@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: msm: qdsp6v2: Update the routing for aux pcm usecase

Audio can be looped back between primary and secondary aux pcm
for some of the usecases.
Change adds routing table entry and support for allowing loopback.

Change-Id: I33754dac4c88dac3daa2a0d34fcd9a7d9d7d1f4a
CRs-fixed: 495000
Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: Change implementation to use callbacks

To use common mbhc code across multiple codecs, use
callback functions instead of mbhc version for each
codec. This will make the codec driver to handle the
codec dependent changes.

Change-Id: I83e1bab17a64add05baa83b6956e05fa5920be8a
Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: don't assume PA is off during insertion detection

The mbhc find plug type can possibly run with audio playback on headphone.
This means micbias source can be from vddio as well as hphl status isn't
reliable.
Change micbias source to cfilt and don't refer hphl status when playback
is running with headphone during plug type detection.

Change-Id: Ie902b64927964c787dd91982d9236015ef302891
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: Enhance class H controller to support dynamic CP voltage

Codecs can operate at a lower voltage for vdd_buck, whereas
this voltage source being shared, it is not guaranteed that the
codec will always receive exactly the requested voltage. Add support
to class H controller to handle dynamic switching of the chargepump
voltage.

Change-Id: I68f93e0b070ec51db9b958f56c797edb5cbe0c85
Signed-off-by: Bhalchandra Gajare <gajare@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: Avoid mic schmitt trigger while finding plug type

Do not enable mic schmitt trigger when the plug type
determination work is interrupted by another mechanical
or electrical mbhc interrupt. Otherwise, enabling mic
schmitt trigger will cause spurious unwanted electrical
interrupts to be generated while plug type is getting
determined.

Change-Id: I3dce10b874c903ec517a6683cbcbc8d2a3d82c92
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: introduce headphone impedance detection support

Different headphones have different impedance that results in volume level
difference on ears as lower impedance headphone will have higher
volume with the same gain on PAs.
Provide impedance of headphones to be able to adjust gain according to
impedance so user can have consistent volume level with different
headphones.

Change-Id: I707f34344cd0068507bdd8a0192eb7afea1147f2
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: Apply class H parameters based on impedance

Different headphones have different impedance that results in volume level
difference on ears as lower impedance headphone will have higher
volume with the same gain on PAs.
To get better output on headset configure class H controller
based on the impedance detected.

Change-Id: Ia4d62120e57122a52ec0030f7e883cbeb284631b
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: Add config variable to enable/disable impedance detection

Some of the codecs still do not support impedance detection feature.
Currently it is only enabled for wcd9320. So, add a config variable
to mbhc configuration to enable or disable impedance detection
calculation.

Change-Id: I2d32d4f3bbdcd6211accf1278dd5ab44d6520b6e
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: fix build warning

Fix warnings due to -Wmaybe-uninitialized in GCC

Change-Id: Ied264ec359620006f1beea26ab7457bb5367fcb7
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: register available conditions to resource manager

When mbhc driver isn't used, resource conditions from mbhc driver isn't
also available even though resources might be still available.
Make resource manager to get registration of available conditions to find
out if specific conditions are available.

CRs-fixed: 514718
Change-Id: I06309f7d1e9b2696c6dd421d6bef481c5d8f0cf8
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: improve mbhc button release detection performance

MBHC hardware block monitors microphone's voltage when button is pressed
to detect button release event.  Reprogram release threshold to narrow
down the threshold voltage to be able to detect button release quickly.

CRs-fixed: 509925
Change-Id: I9802564ea5467f7b5b23a87191ded6ed2f10ab98
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: request bandgap in slow mode

Since bandgap mode change requires clock block disablement when bandgap
get and clock put which are followed by clock get and bandgap put happen,
two clock get or put happen unnecessary.
Reqeust bandgap mode in slow mode to avoid unnecessary temporary clock
source changes.  Also regardless of this change, resource manager always
requests bandgap in slow mode as fast mode request is meaningless.

Change-Id: I6ff52d004cfab6372373b7405f66d8777b3396fd
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: Use lower voltage micbias for plug type determination

Enable current source during plug type determination
and use it for measuring mic voltages to minimize pop
noise resulting from higher voltage of mic bias.

Change-Id: I4e67a64dfbb3952c0bfebebb08eb030ce12ed8d0
CRs-fixed: 485047
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: msm: Enable current source for plug type detection

Enable current source for detecting plug type on tapan.
Update cs_enable_flags accordingly to use current source
during insertion, polling and removal of the plug.

Change-Id: Iab8a79ef377b5a3bdf9cefa6a9b5ad33ece9c8a7
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: wcd9xxx: Support to configure the code for media button

There is mismatch in button 0 code value that is used
in kernel and userspace. Configure the code for button 0
to match with that of userspace.

Change-Id: I3019807ee1e68e9990a12073fa11315e26575814
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ASoC: core: Use driver core probe deferral

In version 3.4 the driver core acquired probe deferral which is a core way
of doing essentially the same thing as ASoC has been doing since forever
to make sure that all the devices needed to make up the card are present
without needing open coding in the subsystem.

Make basic use of this probe deferral mechanism for the cards, removing the
need to handle partially instantiated cards. We should be able to remove
even more code than this, though some of the checks we're currently doing
should stay since they're about things like suppressing unneeded DAPM runs
rather than deferring probes.

In order to avoid robustness issues with our teardown paths (which do need
quite a bit of TLC) add a check for aux_devs prior to attempting to set
things up, this means that we've got a reasonable idea that everything will
be there before we start. As with the removal of partial instantiation
support more work will be needed to make this work neatly.

Change-Id: I97fa366385d9cf192c80da835777eb4651f526e2
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Git-commit: b19e6e7b763c7144bfe2ceccf988b64d66d6dd0a
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Acked-by: Liam Girdwood <lrg@ti.com>
[phaniu@codeaurora.org: resolve trivial merge conflicts]
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>