ASoC: qcom: qdsp6v2: fix crash due to asynchronous read/write

Whenever an async read command is issued to dsp when
the driver is not enabled, there is a crash in userspace.
The read command is disallowed in the driver and an error
is propagated to userspace which results in the crash.
The driver is re-enabled in a subsequent asynchronous write
command anyway, so the async read command can be allowed.
Ensure that read is allowed by removing a superfluous check.

CRs-Fixed: 675131
Signed-off-by: Satya Krishna Pindiproli <satyak@codeaurora.org>
Change-Id: I5d0598e37d08ac1090f98c24be49fd99c132e22f
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
asoc: msm: MBHC fixes, round 2

 * Reset the gnd-mic switch when the headset is inserted. Some
   headsets end up in a weird state otherwise.
 * Micbias does not need to be on all the time for regular headsets
   in order to detect button presses. Disable it.
 * Tweak the thresholds such that headsets which require 2.7V on
   micbias correctly start as HIGH_HPH. They will be corrected to
   headsets after the micbias is turned on in subsequent passes.

Change-Id: Ia846d95b81f2dcde1f14e77b0d69d6ab034b4bb4
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
asoc: msm: Check headset insertion for consistency

 * It's possible to get a noisy reading during polling when
   transitioning to PLUG_TYPE_HEADSET. Poll again to double
   check that it's really a headset.
 * This helps when music is at full volume and a headphone
   is inserted. Double-checking the reading vastly improves
   the case where a noisy reading causes a mic to be detected.

Change-Id: I6e0863a46cdfd5316d798bc9b8348927fa403890
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
asoc: msm: Enable spammy MBHC debugging

 * Accidentally got removed from previous patch. Enable spammy debugging
   so we can collect data about more types of headsets.

Change-Id: If65168e2fbb470562433f9738886025c51096ff6
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
asoc: msm: More MBHC tunings!

 * All day every day!
 * It seems that certain OEM handset makers who are also in the
   accessory biz have chosen resistence values which lie directly
   on the threshold of the reference design. I can only think of
   a few reasons why someone would do this.
 * Nice trolling, Xiaomi :)

Change-Id: I0ff08b0f2253f10422f16f00ef5a8911455c5348
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
asoc: msm: MBHC tunings forever!

 * Franco's Apple headset is right on the boundary for HIGH_HPH.
 * Move the threshold down to 180.

Change-Id: I487af13663cb74d55ff8a270bda917537284966f
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Implement kexec-hardboot

"Allows hard booting (i.e., with a full hardware reboot) to a kernel
previously loaded in memory by kexec.  This works around the problem of
soft-booted kernel hangs due to improper device shutdown and/or
reinitialization."
More info in /arch/arm/Kconfig.

Original author: Mike Kasick <mike@kasick.org>

Vojtech Bocek <vbocek@gmail.com>:
  I've ported it to hammerhead, it is based of my mako/grouper port, which is
  based of Asus TF201 patch ported by Jens Andersen <jens.andersen@gmail.com>

  Hammerhead is the first device I've ported this patch to which uses
  device tree binary instead of atags. It is also rather picky - its
  bootloader erases first 128MB of RAM on reboot, so following hacks had
  to be applied:
  * Copy dtb to location passed in r2 before jumping to kexecd' kernel,
    the kernel would just freeze when I left dtb above 128MB of RAM.
  * Copy kexecd' kernel to location in the first 128MB before jumping to it,
    the decompressor operates very slowly if the kernel is above the cached
    area, copying it lower and decompressing it afterwards is much faster.

  Same as my mako/flo patches, the guest kernel does not require any
  modifications, kexec-hardboot is equivalent to standard kexec.

  To support dtb, following commit was backported from the mainline:
    commit 4cabd1d9625c7d88acd143f4021fbef75394f154
    Author: Matthew Leach <matthew.leach@arm.com>
    Date:   Fri Sep 21 18:56:02 2012 +0100

      ARM: 7539/1: kexec: scan for dtb magic in segments

      This patch allows a dtb to be passed to a new kernel using the kexec
      mechinism.

      When loading segments from userspace, scan each segment's first four
      bytes for the dtb magic. If this is found set the kexec_boot_atags
      parameter to the relocate_kernel code to the phyical address of this
      segment.

Davide Pianca <kingbabasula@gmail.com>:
  Ported from https://gist.github.com/Tasssadar/7833796
  Adapted for bacon

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Revert some sched patches

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
sched: Rollback upstream backport

 * There are some stability issues under certain loads with this
   patchset. Rollback until we can revisit.

Revert "[backport] sched_rt: Upstream fixes"

This reverts commit 3aef4fdd36c3db6f5df88629ab0a9d6c42bae26c.

Revert "[backport] sched: Misc upstream scheduler improvements"

This reverts commit fa16d20f1c90bb0d7955b194d450891de680494e.

Revert "[backport]: sched: Load-based CPU boosting"

This reverts commit 54d5731ffe5a109691de3f61eeda14bd42942325.

Revert "sched: Remove get_online_cpus() usage"

This reverts commit 86b047357013e1d5c5547fd6d466dd75b90afc81.

Change-Id: I8bb638023a95df7ae7a44b06017c0190985e3f22
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
video: mdss: Sunlight readability enhancement support

 * This hardware supports a postprocessing mode which improves
   readbility in bright sunlight. Add support for enabling
   this mode when the backlight value crosses a threshold.
 * Enable the feature using /sys/class/graphics/fb0/sre
 * Also add a max backlight level for using CABC. It's not
   effective at full brightness and causes too much visible
   distortion with many images.

Change-Id: I213eb5d91e526c80a0dc88e6e05e6d6f35841fdf
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
mmc: core: Optimize entering HS400 mode

In the current HS400 selection sequence high speed mode is entered
twice unnecessarily. Skip the first hs selection as it is also done
as part of entering high speed DDR mode.

CRs-fixed: 707453
Change-Id: Id027af977fe416056a6fbef39da1a84e41d89e53
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Revert "qseecom: Add support to handle multiple app load & unload"

This reverts commit f856ce3045a68e12089c7dc2152f5c53bb259305.

Change-Id: I31b5994fb42118edd46e453b0d453225c92000a1
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
ARM: dts: msm: use a corner regulator for wcnss VDD_CX on all boards

Update wcnss nodes to use voltage corner regulators for VDD_CX on MSM8226,
MSM8610, MSM8974, and MSM8974Pro.

Also update the wcnss platform driver to use voltage corner values for the
VDD_CX regulator supply.

Change-Id: I3f42104c2609a8cd237a34c66ff76be4426e9de8
Signed-off-by: Yue Ma <yuem@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: mdss: double check mdp ping pong done state

There are cases where the irq trigger may get delayed for more than
expected, in such cases the ping pong done status may have been updated
by MDP hw. Add additional check to see if this has been triggered even
though interrupt wasn't scheduled for pingpong done.

Change-Id: I4730d166d95f238f4525eab2b5c99be40b30699b
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: mdss: always set mdp_busy when partial update is disabled

mdp_busy flag is used to serialze kickoff operations by ensuring
that any pending kickoffs are first completed before issuing any
new kickoffs. This avoids any potential mpd_busy_wait timeouts.
Therefore, for normal operations (partial update disabled), mdp_busy
flag should always be set. However, when partial update is enabled,
width and height of panel's ROI need to be checked before setting
mdp_busy flag. Otherwise mdp_busy_wait will timeout since no update
will be sent to the panel. In addition, perform roi merge from both
panels if roi-merge is enabled to decide whether column and page address
has changed. If it was changed, then new column and page address need
to be sent to the panel.

CRs-Fixed: 692382
Change-Id: Ib0070b84a626afffd4c51a65f59bc97aae1d8994
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
video: mdss: Color enhancement feature

 * Add support for color enhancement feature of JDI panel

Change-Id: I6bacd36a329a0c648a5541efdb87b1142aefbfdf
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
qcom: rpm-smd: Mask the interrupt before sending the sleep set.

Sending a sleep set would cause an SMD interrupt to fire. If the
interrupt was previously affine to a different CPU, it could cause a
premature wakeup of that CPU. Prevent this by masking the interrupt
before sending the sleep set.

Change-Id: I45734c6fa52b7f69c0d68c5b3cd221185a516248
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: mdss: refactor MDSS idle power collapse logic

MDSS GDSC can be turned off, or power-collased for command mode panels
in static screen use-cases. In the current implementation, the power
collapse is triggered by a worker thread in the interface driver
whenever once it enters the idle state. However, MDP driver already
registers pm_runtime callbacks for idle and suspend notifications and
also maintains a count of active overlay sessions. It is much simpler
and cleaner to trigger idle-power collapse based on that. This also
avoids unnecessary synchronization issues pertaining to the power
collapse worker thread.

Change-Id: I96ee339b96ad794b2d87d19d1c14768fca3fa192
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
video: mdss: Fixup power collapse

Change-Id: Iaf58e785e86c994b25001e6589162ba5c3043abc
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
msm: mdss: reset runtime status upon device resume

MDSS is power-collapsed in idle screen cases using the pm runtime
framework. However, it is possible that the runtime PM status may
not match with the post-system sleep status when the device is
resumed. This sometimes leads to the inconsistencies in MDSS
idle-power collapse upon system resume. To address this issue,
reset the runtime PM status in the pm resume handler.

Change-Id: I74b082d2ff80c3719996a482510ba24e1f5f8170
Signed-off-by: Aravind Venkateswaran <aravindh@codeaurora.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>