vidc:720p: Fix first buffer with EOS flag in video decoder

The video driver is throwing error for erronious header
input buffer with EOS flag enabled. This commit will
fix the error case by amending the EOS handling for the
first buffer.

CRs-fixed: 370048
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
(cherry picked from commit ed4b2afe41aa4dec5bf06823da35e33645d558a1)

Change-Id: Ibbd7079347917b7ac84c69789df66dca96a3bdd6
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
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
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit d60ac323a1e3e7086ef2d77c866d5ed482d2a4e9)

Change-Id: I14eacda2bd92c8f1fb89cfe4fdc1c9624b09a359
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp.c
msm: Use immediate operations instead of PC-relative loads

Use immediate operations for creating constants in
__enable_mmu to avoid a situation where the constant area
may not have been fully mapped by the initial identity
mapping.

CRs-Fixed: 375963
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit c00dfe2cd0edb8d891261e7c3f24a50ccd233d17)

Change-Id: I5eb962ca70be36ced5ed9953f954f11dac0d42d3
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: idle-v7: Write Krait-specific bits before WFI

Certain variants of the Krait processor require a
modification of an implementation-defined register prior to
executing the WFI instruction.

CRs-Fixed: 375963
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit ae920e776de8271232a524031f07e9fd605b5b30)

Change-Id: Iaa1af291662092bbd36800da568de20c66e55417
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
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 363763
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
(cherry picked from commit ff42a9a426ab9a76d75a29464412807dd72ceb13)

Change-Id: If5e6a5ad525e895ff7c2f27666cc7a445c485cb4
Signed-off-by: Srivalli Oguri <oguri@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
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit c0d815c2a4118d1ba51e316c6cb59bee4d68eb9b)

Change-Id: I8970021ff300c08131bdc1fbf3efdc74623bdb90
Signed-off-by: Srivalli Oguri <oguri@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
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 56a123baaab84af584fbbf5cbb29955ec5c92f39)

Change-Id: I803b6457523d1af13cc83e459a8b0fe2829badf8
Signed-off-by: Srivalli Oguri <oguri@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.

CRs-fixed: 363763
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
(cherry picked from commit a43f44b44ee221df11ad84b8536c1c8d5373cbaf)

Change-Id: If0a45a8215a969bf6f137e19f2536d6d4abce156
Signed-off-by: Srivalli Oguri <oguri@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.

CRs-fixed: 363763
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 3d297368b8199b07bda815915e94ecb5761561b0)

Change-Id: Ibb47ceae75fdd7347b1c3474cb16a394eff40446
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp.c