USB: Set power supply online status to false after cable disconnect

During bootup, power supply online status is set to true in
qpnp_charger_probe() as soon as usb cable insert is detected by
PMIC without waiting for notification from USB driver.
Later when usb cable is disconnected before charger detection
mechanism starts, online status is not set to false by USB.
As part of cable disconnect, USB checks in msm_otg_notify_charger()
whether the cur_power is same as requested mA, if both are same
then USB does not call power_supply_set_online() to set it to false.

Fix the issue by setting power supply online status to false for
the scenario when usb cable is disconected during bootup before
charger detection mechanism is completed.

Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cma: Drop the right mutex

The lock that was locked was cma->lock not cma_mutex. Drop
the right one when breaking out of the loop.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cma: Add support for memory limits

Currently, when dynamically placing regions CMA will allow the memory
to be placed anywhere, including highmem. Due to system restrictions,
regions may need to be placed in a smaller range. Add support to
devicetree to allow these regions to have an upper bound on where they
will be placed.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
[skhiani@codeaurora.org: Resolve merge conflicts]
Signed-off-by: Susheel Khiani <skhiani@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
qcom-cpufreq: Block hotplug until cpufreq is ready

Hotplug before qcom-cpufreq is ready could lead to inconsistent CPU
clock state. Block hotplug by returning NOTIFY_BAD in hotplug callback
until qcom-cpufreq is probed.

Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
qcom-cpufreq: Fix hotplug blocking logic

Change 2b63b10 qcom-cpufreq: Block hotplug until cpufreq is ready
intended to block hotplug until qcom-cpufreq driver has got all
clocks. However, its implementation still leaves a small window when
CPU 0 has got its clock but others haven't. If a hotplug happens on
another CPU that doesn't have its clock pointer, refcount of that CPU
clock will again be wrong.

Fix the issue by introducing a ready flag.

Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: vidc: Fix a race condition with core instances list

All list operations for core instances list needs to be
protected by mutex. Add mutex for the same.While adding
the new instance to the core instances list, the list
needs to be protected by mutex. This is protected by
incorrect mutex.Fix an issue to acquire proper mutex.

Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: vidc: Add error handling for load resource failure

- If the clip dimensions are less than/equal to the max dimensions,
  then FW returns HFI_ERR_SESSION_UNSUPPORTED_SETTING.
- Added error handling for load resource failure.

Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: vidc: send video cmd opcode in apr packets to Q6

Q6 expects video command opcode in apr command packets
sent to it,  instead of the individual command id.
Also remove redundant Q6 functions.

Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: vidc: Set error concealment color to FW.

Add property to inform error concealment color to firmware.
With this change error concealment color is set to green.
If the error concealment color is set to any other color besides
green, then some frames have green padding and some will have non-green
padding(because error concealment color is mostly set on only first frame).
This can cause YUV mismatches between runs resulting in failure in
certification testcases.

Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
Signed-off-by: Manish Kumar <manishku@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Set HPH PA register to volatile

Set HPH PA register to volatile to make sure the register will be
updated with proper bits during bringup

Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: Fix the sync problem after SSR

After SSR default registers needs to be restored. Then
we need to sync all the registers with cache values. This
fixes the problem where register values got changed
after SSR causing AAC clip playback failure.

Signed-off-by: Anish Kumar <kanish@codeaurora.org>
Signed-off-by: Fred Oh <fred@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Change in sequence of HPH Rx path

Change HPH Rx path sequence to enable Rx clock and reset Rx interpolator
path before HPH DACs enable to avoid pop during bringup of device path.

Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9320: Avoid NULL pointer access

It is possible that taiko private data will
be accessed without creating memory when
sound card is not registered. Avoid kernel
crash by checking it for NULL and return without
access.

Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Add check for buffer overflow

Current code does not check if the indexes of array
codec_dai being accessed is within the maximum
number of codec dais for a particular codec. The change
adds this check and ensures that indexes outside the
bounds of array are not accessed.

Signed-off-by: Aravind Kumar <akumark@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Enable current source support for 2nd mic detection

Use current source to detect presence of second mic if MICBIAS
for primary and secondary mic is not shared. If MICBIAS is shared,
do not use detection with current source.

Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: check NULL pointer access for wcd9xxx

It may be possible that device up gets called
before slim probe and this leads to NULL pointer
access. Avoid the NULL pointer access before
processing device up.

Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9306: Add DMIC sample rate support to wcd9306

Add the capability to read DMIC sample rate from device
tree file to wcd9306. This enables different sample rates
without changing the codec driver.

Signed-off-by: Damir Didjusto <damird@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Correct OCP IRQ mapping for Tapan

OCP interrupt mapping bit number is changed in Tapan codec,
so correct the interrupt mapping accordingly.

Signed-off-by: Yeleswarapu, Nagaradhesh <nagaradh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: add device_reset functions for taiko and tapan

When slimbus is reset reset_device callback is called. In this event codec
driver should reset the codec so that codec can be enumulated again.

Signed-off-by: Fred Oh <fred@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ASoC: wcd9xxx: Add check for NULL pointer and buffer overflow

Current code has possible scenarios where NULL pointer
could be dereferenced or an out-of-bound index of array
could be accessed. The change checks the pointer for NULL
before they are dereferenced and checks for buffer overflows
to ensure out of bound indexes of arrays are not
accessed.

Signed-off-by: Aravind Kumar <akumark@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>