msm_rotator: add rotator ref count to cleanup code

Perform cleanup of rotator sessions only if reference count reaches 0,
this avoids closing rotator sessions from sibling threads.

Change-Id: I83add90cc04faa90c372dde09a096c7a07be528a
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm_fb: display: vsync driven screen update

This patch will queue multiply surfaces and commit those
surfaces into mdp at same instance so that surfaces will
be blended and displayed at same time. Hardware vsync event
is deliver to frame work at user space via uevent. Both
queue and commit are controlled by frame work and
synchonized with vsync event. Therefore frame rate will
match with vsync rate.

Change-Id: If630a6d94fd38483ee313f575b1a71ed8bd65a52
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp.c
	drivers/video/msm/mdp4.h
	drivers/video/msm/mdp4_overlay.c
	drivers/video/msm/mdp4_overlay_mddi.c
	drivers/video/msm/mdp4_util.c
	drivers/video/msm/mipi_novatek.c
	drivers/video/msm/mipi_orise.c
	drivers/video/msm/mipi_renesas.c
	drivers/video/msm/mipi_simulator.c
	drivers/video/msm/mipi_toshiba.c
	drivers/video/msm/mipi_truly.c
	include/linux/msm_mdp.h
msm_fb: display: add out of range check for display sizes

MDP pipe or mixer size registers have 12-bit number, so boundary
checks are needed for those parameters. If not, input req sizes could
be very large 32 bit unsigned numbers, e.g. 0xffffffff, unsigned
operations may have overflow to pass all later checks, causing MDP
underruns or hang issues.

CRs-fixed: 380469
Change-Id: I096d7022ede21d54266b46a140782ab0348dd54b
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Siddhartha <agrawals@codeaurora.org>
msm_fb: display: vsync driven screen update II

Fix whitespace issues from the patch titled
msm_fb: display: vsync driven screen update

Change-Id: I96bf0210c20667486e48f5e20b7525cade098020
Signed-off-by: Siddhartha <agrawals@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay.c
	drivers/video/msm/mipi_simulator.c
	drivers/video/msm/mipi_truly.c
msm: panel: update HTC display code

Change-Id: Ic82a9706caabb7fdedb17a41e45e6175ee63fcdc
msm_fb: display:  free writeback buffer at correct time

When mdp pipe is freed at end of video play back, Writeback
buffer is freed while mdp still fetchs data from it. This cause
system crashed and blue screen shows on screen. This patch
will free writeback buffer at correct time.

Change-Id: I46a5031c13d86f943d6604713e1841b482dffe96
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm_fb: display: enable MDP interrupts base on panel interface

Enable necessary MDP interrupts base on panel to avoid
triggering dma_s isr handler.

Crs-fixed: 331668
Change-Id: I139a6193338a1b0a7c9cc7869e3ea1b3f9a65c4d
Signed-off-by: kuogee hsieh <khsieh@codeaurora.org>
Signed-off-by: Siddhartha <agrawals@codeaurora.org>
msm_fb: display: Assign proper destination rectangles to mdp blit

Add check for (90 + Flip Horizontal) and Flip Vertical cases to assign
proper destination rectangle parameters to avoid corrupted frame
buffer content.

CRs-Fixed: 344807
Change-Id: I7e7b0b8d26f08f63a6f9c55eedd37f31cf0348d7
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
msm_fb: Fix error in y-offset check logic in FB driver

After 4 KB alignment changes, the frame from 3rd buffer doesn't
get updated since during PUT_VSCREEN_INFO ioctl, the driver
returns -1 to userspace due to error in logic because the hole
size is not considered in calculating the logic for validity of
the y-offset. Change fixes this error.

Change-Id: Ib151970eacab4df36fb8274be0079bc814e93efe
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm_fb: Clean up the fix for error in y-offset check in FB driver

There is a failure observed in yres_virtual offset check and every
third frame gets skipped without an error message. Due to this high
fps is noticed in the test applications. Correct the yres_virtual
offset check.

Change-Id: Iddce0b75e0a9c466adad6eb5726203ae0586c27b
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
video: msm: PCC/GC config register protection

PCC/GC configuration registers are shared with other features. This patch
makes sure that the other features implementations don't overwrite the
existing settings for PCC/GC.

CRs-Fixed: 345395
Change-Id: I5467a4c50eae214181d67a7976eee92c0ae26fe5
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp_dma_dsi_video.c
	drivers/video/msm/mdp_dma_lcdc.c
video: msm: Allow PCC/GC to be disabled/select bins

Current implementation would not set enable/disable bits to PCC/GC nor be
able to select the zero'th bin after selecting the first.

Change-Id: I0f52beb8914cdaecbabe913455c00fb9ea6100db
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Add QSEED API to MDP_PP IOCTL

Add the ability to program the QSEED Table 1 coefficients to the features
supported by the MSMFB_MDP_PP IOCTL

Doesn't support table2 writes currently, however, the code to write to them
is already present.

QSEED support is currently only configurable via a tuneable parameter that
maps to a small subset of possible  QSEED settings. By moving to the
MSMFB_MDP_PP IOCTL, QSEEDs tables will be able to programmed to any value
requested by userspace. This also allows for future expasion of the QSEED
feature by allowing dynamic loading of the table2 coefficients (rather than
only configuring them at init).

Change-Id: I7394e211169efb0e677391e2c150a6a6b8d0477c
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm_fb: display: Remove chicken bit config during video playback

Remove the chicket bit configuration and overlay status check
for MDP 4.0 v2.1 hardware version

CRs-Fixed: 313524
Change-Id: I0fd2db72a25a628398c9f794676d2178cdca78df
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4.h
	drivers/video/msm/mdp4_overlay.c
	drivers/video/msm/mdp4_overlay_mddi.c
video: msm: Resolve post processing memory leaks

Allocate memory for post processing only once. Free post processing memory
when MDP is removed.

CRs-fixed: 366325
Change-Id: I244f4e10a6933e2acaf69a83d8b91ee5f6e27557
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp.c
msm_fb: Check for Histogram NULL while queuing work

Don't queue the work if the user hasn't requested for the
histogram data

CRs-Fixed: 365729
Change-Id: I0b28097fa00f13a836c2ee9d35e8e4557f1c70f0
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
video: msm: Always queue histogram work

Always queue histogram read worker in order to gain concurrency protection
from the histogram management mutex (move previous checks/calls into worker
itself).

CRs-fixed: 363763
Change-Id: If9e3c13b5e4005f81fd1b5d2664af206b1decf5b
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp.c
video: msm: Always queue histogram work & lock histogram calls

Always queue histogram read worker in order to gain concurrency protection
from the histogram management mutex (move previous checks/calls into worker
itself).

Lock the mdp_histogram_start and mdp_histogram_stop calls with the same
lock used currently by mdp_do_histogram to maintain that every do_histogram
called between a start and stop will be completed.

Add a timeout to do_histogram wait_for_completion so that it will unlock
and yield to other histogram calls if it waits for longer than 33 msec.

CRs-fixed: 363763
Change-Id: Icc503aed4e60dd01941682003ca3dbc844aed8d9
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm_fb: Handle multiple histogram reader errors during suspend/resume

If a histogram reader waits for completion in the do_histogram ioctl
and during this time the device is suspended, the complete for this
gets called from mdp_histogram_ctrl_all() in the panel_next_off()
sequence. This results in mgmt->hist not set to NULL. The subsequent
do_histogram ioctls after device resume fail due to multiple reader
failure condition since the histogram irq will be enabled now from
the same mdp_histogram_ctrl_all() during panel_next_on() sequence and
this by-passes mgmt->hist getting set to NULL that is present in
histogram_start() ioctl. Handle this scenario.

Change-Id: Ib0485da24c0f09a3f26768b75231903c8a2e0033
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
video: msm: Fix corner cases of "read twice" error

Fix several cases where histogram's completion structure is completed
multiple times which causes the next histogram read to force the histogram
software state machine into believing that the histogram is always being
read by someone.

When the timeout in mdp_do_histogram times out and then soon after the work
that was being waited on completes, the next do_histogram call that is
processed will not wait (and thus will not have its hist field set to
NULL). This will cause all subsequent do_histograms to think that the
histogram is currently being read, and will cause the "read twice" message
to flood the kernel logs.

This error is fixed by always initializing the completion structure before
waiting for the histogram to complete. That way if the completion happens
after the timeout, instead of causing the error, the completion's internal
counter is reset to zero, which prevents the next histogram read from
completing without waiting.

Change-Id: Ic1bc4b8688cd191d226de1df15d389de09996106
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp.c