Revert "cpufreq: interactive: Simplify frequency calculations"

This reverts commit 12eb52bcb246dd92b1e07725ce8778d62d557bc4.

We'll use this a bit smarter.

Change-Id: I0ca9f10f01720cc03de9b7084262ebf3a3a0e9e3
cpufreq: interactive: Support variable frequency calculations

Use a threshold value up to which we are evaluating the current
speed weighted by current load against each new choice of speed.
Above switch to the original frequency calculation proportional to
load relative to the max possible frequency which allows for more
dynamic and fair changes.

Default threshold is cpuinfo min which guarantees minimal freqs
and energy usage during (offloaded) media playback.

Also, choose the highest frequency below or at target, which
generally saves us one freq level.

Change-Id: Ic807cc89a6d5cfb47f353b0912ced489baae8cbf
msm: mdss: abstract the dsi command utility API

The dsi command parsing and construction functionalities
are hardware independent.  This is to abstract these
utility API, so that it can be shared with different versions
of  dsi host controllers.

Change-Id: I8481d9fd21e5eacc4542c72c064fa37d7fd3a11b
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
msm: mdss: Add an extra write of zero to clear dsi-ack-err bit

In addition to writing 1 to clear dsi-ack-err bit, an extra write
of 0 is also needed to clear error bit completely.

CRs-fixed: 574066
Change-Id: Ib9df9fe5f993605372ced8766874fa00538f505a
Signed-off-by: Shivaraj Shetty <shivaraj@codeaurora.org>
msm: mdss: Prevent excessive logging during rotation set failure

Changing the error log to debug log in case SMP reserve fails
for rotation. The use case falls back to GPU. Same is being
done in  case of mdp interface set path.

Change-Id: I00a9e05b3a04a87e354fd0e60ad900f4f71cdfc1
Signed-off-by: Vineet Bajaj <vbajaj@codeaurora.org>
msm: mdss: fix race condition between shutdown thread and fb ioctl

Currently all entires into fb driver are synchronized with shutdown
context except fb ioctl context. fb ioctl is an asynchronous entry to
fb driver which can be called simultaneously from two different user
processes. Synchronize these fb ioctls and shutdown context to prevent
race condition.

Change-Id: I81ce48159fce69caabc3336d70df2bd15c4ee44b
CRs-Fixed: 640199
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: expose mdss tearing check parameters

Tearing may happen for command mode panels when data transfer from mdp
to panel is not synced with panel's own update. These panel dependent
mdp parameters are used by mdp h/w logic to avoid tearing, so they can
be tuned through device tree settings for different panels.

CRs-fixed: 514910
Change-Id: Ibe9e27233692f8e50f36ce3b8be521a4d0097146
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: wb: Ensure iommu reference is available in wb terminate

In static screen case on command mode, when wifi display is
disconnected, buffers don't get free as there is a probability
that iommu is not attached. Ensure that iommu is attached when
wifi display terminate is called.

Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>

Change-Id: I9f5bb9db3024117da36f0c90af3c9f27ff27873f
msm: mdss: Add error handling support for DCS command APIs

Currently there is no error handling done for DSI DCS command
APIs like mdss_dsi_cmdlist_put. So for ESD thread use cases,
the caller functions of these DCS command APIs do not have error
propagated if the panel read/write commands fail. Hence add support
for error handling for these functions.

Change-Id: I0e558fd32fbfd8ae247b60c92fa2756159c3d3c6
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm: mdss: synchronize recovery handler access

The recovery handler is used in the dsi event thread, and
the recovery handler variable was configured from a different
thread.  Earlier, there is no synchronization between the two
threads accessing the recovery handler, causing kernel panics.

Change-Id: Iee990276fdabd65e2e1f2e3c21ad574fc0d8a7bc
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
msm: mdss: distinguish between mdp and dsi bus votes

For DSI read or write commands, they will also go through
axi bus.  Earlier, we were only voting for the mdp bus bandwidth.
In the case where the mdp bus bandwidth vote is 0 and there is
a DSI transaction, it will result in DSI hang.

Change-Id: Iafd9e06ae2050665392c6c74fece8f20cb6d44b1
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>
msm: mdss: Fix issues in gamma interface

Protect access to panel command struct by mutex,
this should help with ULPS stability during panel
on as well.  Also, remove the broken debug FS.

Change-Id: I975838eb4bc7fbf07f48c41dfe9a783c495e0afc
msm: mdss: Debug log for assertive display inputs

Log updates to ambient and strength inputs on assertive display.

Change-Id: Ie96baf2cb6f4af4c74e154322b870f4eb58cbfb2
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm: mdss: Update BL on first AD update

First AD update is not updating with current backlight value. Initialize
last_bl variable so that first request updates backlight along with user
specified input.

Change-Id: I453e5448229dbddb6204c0a654c267e1540c59a3
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm: mdss: Use primary display backlight in WB AD case

When AD is configured to run on the writeback display, it needs to use the
primary display's backlight configuration for getting, setting, and being
alerted to backlight changes since the writeback display does not have a
backlight to itself.

Change-Id: I615ce878a948798c1ce0c49c427e361c73798335
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Ping Li <quicpingli@codeaurora.org>
msm: mdss: Allow CMD panels for Assertive Display

Remove the check that prevented command mode panels from enabling assertive
display functionality.

Change-Id: Iecf0f518a45da556d1d9d0558a7d2dc572cc82da
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Ping Li <quicpingli@codeaurora.org>
msm: mdss: Don't calculate AD with zero backlight

Don't calculate AD strength when backlight is zero to prevent updates that
would not be visible from impacting screen when first backlight request
arrives.

Change-Id: Iabf10317ef40ae7bd940d94297a62975947c5ee4
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm: mdss: Store AD backlight notification function

Store Assertive Display backlight notification function while locked to
prevent race condition where AD is disabled while lock is released,
setting function pointer to NULL.

Change-Id: I7996a29595854ed8e50d0fff663a779c3ccd388f
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm: mdss: Update screen resolution for Assertive Display

Apply the latest screen resolution to AD hardware so that banding
artifacts are not generated.

Change-Id: I5df8a3de4551c5e45e0e8ff2b21b60549b479788
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Ping Li <quicpingli@codeaurora.org>
msm: mdss: Validate input argument

MDP kernel function allocates memory using one of the input
parameters. Add sanity check for this input parameter to
ensure proper memory allocation.

Change-Id: Ib7ff3b02e818c0d2a623fb3428fb93cc5bd8e41e
Signed-off-by: Shalabh Jain <shalabhj@codeaurora.org>