msm: mdss: Update op mode register access for calibration

Update OP_MODE register access on all source pipes for
calibration service to enable/disable PA, IGC, six
zone, etc post processing blocks.

Change-Id: Id52d7af71e0c0ad758c3ca939c8e1991c1dcf6ff
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
msm: mdss: Prevent multiple completions for each read request

Each read request should only capture one histogram done. completion to
prevent future histograms from trying to read unavailable data. Makes sure
that the read request is set for both pipes before waiting for a new
histogram. Likewise, make sure the read request is unset for both pipes
after waiting. To prevent accumulation of histogram bins, only kick off
histograms when histogram state is IDLE (i.e. read or reset(recently
 zeroed) bins).

Change-Id: Idc1ebb14dce500a6e5dfc0261ecec992e727a380
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm: mdss: Remove redundant data from histogram info

Remove the 'is_kick_ready' variable from the histogram info since it is
duplicating col_en.

Change-Id: Ie2b3d5fae83d3030e79b323260223458eed174b0
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm: mdss: Fix ARGC error when writing LUT to registers

When updating the ARGC LUT registers, the data is incorrectly written
such that the arrays are off by one index. This patch fixes that error
by starting from the correct index.

Also, when the READ flag is enabled for ARGC, the dirty flag is no longer
set.

[myfluxi: This fixes lcd kcal lut access as well]

Change-Id: I7e8e19c51d5891cd11344a425f1a8ac47d57368c
Signed-off-by: Benet Clark <benetc@codeaurora.org>
msm: mdss: fix IGC access for calibration service

Fix IGC address range access on DSPP and SSPP pipes
for calibration service.

Change-Id: I5601f0da1088ea9c31d98e13d0cc5f9c7e33ce3b
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
msm: mdss: Add backlight attenuation mechanism in AD auto strength mode

AD backlight attenuation provides the ability to modulate backlight based
on calibration before feeding it to AD core for strength computation.

Change-Id: Iea011807b25882463b1142e17324fa0509007aa4
Signed-off-by: Ping Li <quicpingli@codeaurora.org>
msm: mdss: Move histogram completion initialization to pp_init

The histogram completion structure only needs to be initialized fully
once, and this can be done when the pp resource structure is created.
Otherwise, when enabling the histograms, it is sufficient to use the
reusable INIT_COMPLETION, in order to avoid any wait_queue errors.

Change-Id: Id4bfb19c91bd5ab07c01a5eb347ba50621fe8a97
Signed-off-by: Benet Clark <benetc@codeaurora.org>
msm: mdss: Fix locking error in histogram enable

There was a missing spinlock around the histogram enable which is
necessary. It has been added.

Change-Id: I0c06406682234134260281870b755ed559d34b9e
Signed-off-by: Benet Clark <benetc@codeaurora.org>
msm: mdss: Add missing locks in histogram collection for collect enable

The histogram state and collect enable need a spinlock around them when
being read or written to. There were a couple places where the spinlock
wasn't held when the values were being checked. The number of spinlock
accesses has been reduced in collection as well.

Change-Id: I2f7c200c436ec5e062ba11a8208f88af89b25e2d
Signed-off-by: Benet Clark <benetc@codeaurora.org>
msm: mdss: Check if histogram has been disabled in collect

Before setting the histogram back to read or idle, check if
the histogram has been disabled to prevent state corruption.

Change-Id: Ibe3d274077189a96358a75cbd7ac2687aabe9ea4
Signed-off-by: Benet Clark <benetc@codeaurora.org>
msm: mdss: Move histogram disable complete_all after intr disable

Previously, complete_all was called during histogram disablement before
the histogram interrupts were disabled, which can lead to issues if an
interrupt comes in between complete_all and interrupt disablement. Now
complete_all is called afterwards, which guarantees no more interrupts
will come.

Change-Id: I831a01ce8433470b337a42a644d98ab5807fdbd7
Signed-off-by: Benet Clark <benetc@codeaurora.org>
msm: mdss: Fix locking errors in histogram disable

There is a histogram variable that was missing the spinlock while it
was being read. It has been added.

Change-Id: I5f6d4246332a84c6a4cb3503ad7bbfaddb4a0fa8
Signed-off-by: Benet Clark <benetc@codeaurora.org>
msm: mdss: Fix locking errors in histogram setup

There is a check on histogram enable in histogram setup that was not
protected by the spinlock. It has been added.

Change-Id: I769422c803bb12de2030115a08d60ad7c7f38f15
Signed-off-by: Benet Clark <benetc@codeaurora.org>
msm: mdss: Add error message when histogram bin collection is incorrect

In the cases where histogram bin collection does not return the expected
number of bins, we return an error, however we do not print any error
message saying which DSPP had failed bin collection. In order to know
which pipe the histogram failed on, we must add an extra log.

Change-Id: I1fb39e146cd3367d3b97f10174573a5207284652
Signed-off-by: Benet Clark <benetc@codeaurora.org>
msm: mdss: Allow calib configure ioctl to access MDSS version register

Add MDSS version register address into the valid register list
for calib configuration ioctl.

Change-Id: I38137b94a0629bc961cb5c974212786f5ba2f9c4
Signed-off-by: Ping Li <quicpingli@codeaurora.org>
msm: mdss: Correct ARGC read write for all DSPP

Currently ARGC read write is done for DSPP0 irrespective of
dspp_num, as the dspp_num corresponding to the block provided
is not calculated.

Added the calculation of the dspp_num to get correct address
of ARGC registers.

Change-Id: Id787e76debb26d23d75d3cdb859a697b6f0016f5
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
msm: mdss: Copy IGC LUT data correctly to userspace

During IGC read operation, IGC LUT's data was copied to
userspace incorrectly because of swapping color components.

Fix component data swapping during IGC LUT data copy to
user space to provide the correct IGC LUT data to user space.

Change-Id: I301a3500f0e0c4bbf9f52affa66373585c72d987
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
msm: mdss: update layer mixer access for calibration tool

Calibration tool should have register access on all layer
mixers connected to DSPP pipe and WB path. It should
also have control layer register access to read
the current layer mixer configuration.

Change-Id: If2cc86c2e6f470e090746a400b16cb540948c3e9
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
mdss: Start wait for hist ready state past first kickoff

When the first histogram kickoff is done past reset, it might
be too late into the waiting period of completion. This
would cause a timeout even though data for the frame is made
available and interrupt is generated after timeout. This
causes a histogram read call to return with an error and
delay reading the data.

Edit to make the wait for ready to start after the first
kickoff. Add additional completion to denote first kickoff
and start wait after first kickoff wait has completed.

Change-Id: Ic9156b4d8852520715324707290287eb09df6195
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>
msm: mdss: Cleanup

Change-Id: I77af8078eb9c38986e7956aeba28961b6ca4c4c5