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>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
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>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
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.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
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>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
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>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
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>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
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>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
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>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
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>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
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>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
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>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: mdss: Prevent ALS data configuration when AD is disabled

If assertive display is disabled, backlight data structure is reset
to NULL, which in some conditons gets dereferenced or casuses
crash.

Change-Id: I535eac6d2f0aef222fc2846f80d72db1f3e3480d
Signed-off-by: Ping Li <quicpingli@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: mdss: Use DT offsets for post-processing

Change post-processing code to use device tree offsets when reading from
and writing to post-processing registers. The device tree defines the bases
of hardware blocks, and previously these bases were hardcoded. Now they are
parsed dynamically from the DT so that the post-processing code is scalable
for different targets

Change-Id: Ic503889459f7793ea68af4128d2d0955e6f6bef2
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Benet Clark <benetc@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: mdss: Make DSPP PP setup more modular

The previous DSPP PP setup function included config functions for each
of the different PP blocks except for dither. Now there is a dither setup
function, as well as an opmode setup function in order to clean up what is
done inside DSPP PP setup.

Change-Id: Ia347c35bb675e20531272566647a364f6e68468c
Signed-off-by: Benet Clark <benetc@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: mdss: Unlock correct mutex in AD setup

The incorrect mutex for the BL file descriptor was being unlocked
in AD setup. Removed the incorrect unlock and replaced it with an
unlock on the correct mutex.

Change-Id: I276823c34d1183b69d7af06bae8b02cb7e1b56b1
Signed-off-by: Benet Clark <benetc@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: mdss: Balance clock requests in histogram enable

Balance the clock requests in histogram enable to prevent clocks from being
left on.

Change-Id: I45fc029049b68cceb56d0dc40f7819aca0625a58
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: mdss: Fix dither matrix configuration

Configure entry 0 to entry 15 in dither matrix.

Change-Id: I1259c121e84078325e54d952cbd2671031df2978
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: mdss: Separate AD info from AD hardware base address

Splitting the AD info struct, which is used primarily to store state, from
the hardware blocks. Functionality is preserved by passing the structures
containing hardware information to the functions that execute the register
writes. This change is necessary for dual pipe operation where one AD state
machine controls more than one AD hardware block.

Change-Id: Ia0d8be6b70d121095df2bbaa102b7dedd26f2302
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: mdss: update kernel to support autogenerated dtsi files

Changes are to support autogenerated panel/mdss dtsi files
and their corresponding format

Signed-off-by: Arpita Banerjee <cabane@codeaurora.org>
Change-Id: Id7d33190f117f29ff5aca0021517020620a7afea
Signed-off-by: Dan Trifan <jimsth@gmail.com>
ARM: dts: msm: fix several mdss device tree gpio properties

The third tuple of reset and enable named gpio represents a flag which
is not accessed on mdss driver side, so specify them to be zero to
avoid the assumption that it means something. These properties for
msm8974 and msm8226 got changed due to GCDB update and they are
changed back to the original values.

Change-Id: Id4556a4db39e344669431e6a410c784d38afe090
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>

Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>