video: msm: Clear previous histogram data on next startup

Clear the pointer to the userspace histogram struct when histogram is
started. Previously, when the histogram was stopped while a histogram read
was in progress, the pointer was not cleared, causing the next histogram
read to think that someone was already using the histogram.

CRs-Fixed: 361640
(cherry picked from commit 19e4b71f617e307cacf0be077e08bec5c37df290)

Change-Id: If09017149e98b35c49603372c554aa4c97f2de82
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Check for multiple readers of histogram

Check to ensure that only one reader attempts to read one frame's worth of
data from a histogram block. Prevent the case where two readers attempt to
get data, but end up causing a loop where neither of them do.

CRs-Fixed: 361640
(cherry picked from commit 71cf95bf1100ab5de55bf3858d40996be7dc445e)

Change-Id: I48878d9fe02d96f306894ed9acc47bf41cd9984b
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm: Avoid waking readers on failed histogram copy

Avoid waking up the waiting histogram reader when the current histogram has
failed to copy. Additionally, clean up initialization of histogram
workqueue (was initialized twice).

CRs-Fixed: 361640
(cherry picked from commit 0dc81db9cf48d869987e8fa8ab8914fcec964bda)

Change-Id: I376c0193b8e34aba5b0aef54feb9504f450ffff4
Signed-off-by: Carl Vanderlip <carlv@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
(cherry picked from commit ff42a9a426ab9a76d75a29464412807dd72ceb13)

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
(cherry picked from commit c0d815c2a4118d1ba51e316c6cb59bee4d68eb9b)

Change-Id: If9e3c13b5e4005f81fd1b5d2664af206b1decf5b
Signed-off-by: Carl Vanderlip <carlv@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
(cherry picked from commit d60ac323a1e3e7086ef2d77c866d5ed482d2a4e9)

Change-Id: I244f4e10a6933e2acaf69a83d8b91ee5f6e27557
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
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
(cherry picked from commit 56a123baaab84af584fbbf5cbb29955ec5c92f39)

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.

(cherry picked from commit a43f44b44ee221df11ad84b8536c1c8d5373cbaf)

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.

(cherry picked from commit 3d297368b8199b07bda815915e94ecb5761561b0)

Change-Id: Ic1bc4b8688cd191d226de1df15d389de09996106
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
video: msm_fb: Increase display timeout to 2 seconds

One second time out for no frame update, as in current implementation,
does not allow CABL to reach minimum backlight level possible because
histograms dont get generated after one second. So increase time out
period to two seconds which seem to be sufficient for complete black to
complete white and vice versa transitions.

CRs-Fixed: 370804
(cherry picked from commit 1bb4edf9242b0397975636a4442318713a53b5e6)

Change-Id: I0712924d669abcb820654cd6ca5f7da37bed57e6
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
msm: debug_patch: CLOSE SERVER HANG

Change-Id: Iec1f8aabbc97b4f9ad53e58f1189fd8dab79559a
Signed-off-by: Ankit Premrajka <ankitp@codeaurora.org>
Bluetooth: Disable sniff when the subrate values doesnt match.

Found there is possibility of sniff subrate collision with some
IOT devices. When this collision happned if the remote device
send subrate values that doesn't match with DUT supported
values exit sniff mode. This will allow DUT to reconfigure
sniff after idle time.

CRs-fixed: 380811
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
(cherry picked from commit a7c3d7e6d905bab198003f16316971ae872eec9f)

Change-Id: Ibe3d02c6a404bbce677c7d980f0ad124e31bca26
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
Bluetooth: fix shutdown on SCO sockets

shutdown should wait for SCO link to be properly disconnected before
detroying the socket, otherwise an application using the socket may
assume link is properly disconnected before it really happens which
can be a problem when e.g synchronizing profile switch.

CRs-fixed: 365445
Signed-off-by: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
(cherry picked from commit 2e02b861173406a1287a53ca7b836a4ad5fd4255)

Change-Id: Icc38e940f8008d908077dbdea16bc5c6420d1371
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
Bluetooth: Block SCO disconnect operation on BT_CLOSED state.

Have maximum blocking time for shutdown operation as DISCONNECT_TIMEOUT.
During this period when SCO connection closes, the userspace will be
updated on the close operation. Existing approach of immidiate return
on shutdown call can cause synchronization issues on SCO state between
kernel and userspace. This happens when disconnect operation takes
more time at kernel space.

CRs-fixed: 365445
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
(cherry picked from commit f799996e309cad545b3a7f84ef6f333a09c8b876)

Change-Id: Ifa74d2568d2ee157a605a405017d4cc0f05d41fc
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
Revert "msm: board 8960 and 8064: Increase ion heap size for audio."

This reverts commit 55b2745e6b6baccceab2073fa75066ffd91c8051.

Change-Id: I504fc9771d02086bd1317ec73e5b8cc2909e0866
Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>
(cherry picked from commit 9fc93298996dddb47f65b358e4b5ff623af6e7be)
Revert "msm: Remove the pmem audio devices."

This reverts commit 95da2adec27b94d6a82b074177c6635186fffd39.

Change-Id: I35fec81f2990860527b9cfc93c0baf68c8ae59fc
Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>
Revert "msm: board-8930: Remove the pmem audio devices."

This reverts commit 6b6f17e810a31cbc34b9cfa1becbe8da17e6d697.

Change-Id: I857f2ad3cb3e0fdec1d733b87792dfc2736f335b
Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>
Revert "msm: audio: qdsp6v2: Update ACDB driver to use ION"

This reverts commit c710ea7e67cc332bb76037f465cd95c32ebaa096.

Change-Id: I90afd90f97bec8007c1088d90cb8cc6513e54769
Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>
Revert "msm: audio: qdsp6v2: Replace PMEM with ION in Audio Decoder drivers"

This reverts commit 940a101f5026b1bc54d0dd84ef8763ad300641e2.

Change-Id: I3eaeb6df34d3c249de6b311249249ebc6831fdc1
Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>
Revert "msm: audio: qdsp6v2: Replace PMEM with ION in LPA driver"

This reverts commit 7b36be6cb7d66125c494a236e5efb47ec1f4161e.

Change-Id: I40da91b25bbffb3e4b07d026b8571e4ce72d9905
Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>