ASoC: core: Update ALSA core to issue restart in underrun.

When compressed and pcm session is started the buffer pull will
Be from the DSP, in mmap mode for the scenario Hardware pointer
Is same as application pointer implies application has not filled the
Buffer to be send to DSP, and platform driver has to break and restart
The de queue process when the application has sufficient buffers.

When hardware pointer is same as application pointer it is an under run
Scenario where the ALSA framework has to trigger the under run and in HAL
The session has to re-prepare and re-triggered. based on the stop
Threshold, but in our system the stop threshold is INT_MAX which
Indicates that under run is not triggered in practical cases.

We have a brodcast usecase in which the mentioned under run case
Is hit mulitple times, and every time re-prepare and re-trigger will be
Expensive

Update the ASoC core framework to restart de queue process stopped
By platform Driver when the under run is hit, based on the available
Buffer and render flag, so the System will recover from the hang state.

To restart de queue process the ASoC core will be calling the restart
Callback registered by platform driver and this callback will be running in
Atomic context.

Change-Id: Ic9ea05a0dc6246346e9913493232882e2f5447d1
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
ALSA: include: Add new ioctl for metadata mode

Add a new ioctl to support metadata mode in lpa driver. This ioctl
allows lpa driver to work in default alsa compliant mode and also
metadata mode.

CRs-Fixed: 458904
Change-Id: I8111e8652bbfb6dd93bdbda69bd16f53b45cb756
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
ASoC: msm: Fixes for underrun issue in LPA Playback

Update LPA platform driver to register restart callback.
The implementation of the callback is to issue a pending buffer
written by the application to restart the session when the dequeue
process is stopped due to underrun issue.
The callback is triggered from ALSA core when the framework
detects that the renderer stopped pulling data but the application
is still writing data. It runs in atomic context.

Fixes:
-A disturbance was heard when switching from one song
to the other, or when the song is paused for greater
than 3 seconds and then resumed
-This was due to the previous value of the track
volume being used in the lpa driver
-This was fixed by setting 0 as the initial volume

Change-Id: I035760937d032038fb3f3383dc87ecbdc5f4700d
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
ASoC: msm: Resume writes only for start command

For compressed and LPA drivers, set pending_buffers flag to 1 only if the client
issues a trigger_start command, not a pause_release command. This flag
is used to initiate writes to the dsp.

Change-Id: I503156863646210b460613a0b9a26a6bfb8854ed
CRs-Fixed: 442269, 449126
Signed-off-by: Haynes Mathew George <hgeorge@codeaurora.org>
ASoC: msm: avoid negative time stamp check

Time stamp is unsigned. There is no need to check for
negative value.

Change-Id: I15e380f81e46908f6a9fe8d29c174de1b7c33173
CRs-fixed: 423372
Signed-off-by: Patrick Lai <plai@codeaurora.org>
ASoC: msm: proper error code for drain ioctl

If a drain ioctl on a compressed driver has been interrupted
by a reset ioctl, we need to return a proper error code for the
drain ioctl

Change-Id: I15f42a22b1cc13b3a0e2ae873adfcd1db2ac1e53
Signed-off-by: Haynes Mathew George <hgeorge@codeaurora.org>
CRs-Fixed: 445370
msm_fb: display: add an extra write of 0 to clear dsi-ack-err bit

In addition to writing 1 to clear dsi-ack-err bit, an extra write of 0
is also need to clear error bit completely.

CRs-fixed: 478443
Change-Id: Id4c3e2a5a29534d65601999d3bbf9f30ebc73896
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm_fb: Remove the extra freelist in display_commit

There is an extra freelist call to unmap IOMMU source buffers
in display_commit for LCDC interface. This is causing IOMMU
page faults during boot up on targets with LCDC interfaces.
Remove this extra freelist call.

Change-Id: I12a905efc82c5b9751acbc5941a66d0b58027509
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm_fb: display: Do a pre-fill to writeback buffers.

When switching mdp operating mode to blt, writeback buffers need
pre-fill. Move the pre-fill code from isr routine to do_blt, where
actual switch to blt mode happens.

CRs-fixed: 471098
Change-Id: I0f845397894c749ac518a1fa605f84cd5fc2ad15
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm_fb: display: fix the hang issue caused by solidfill pipe

When mdp pipe solidfill mode is disabled, the staled pipe info is used
to update mdp pipe regs. This caused mdp hang. Since
mdp4_overlay_rgb_setup function already resets solidfill mode, this
patch removes any pipe register updates that are related to disabling
solidfill mode.

CRs-fixed: 467555
Change-Id: I23f4b29731c9097ab0cc38baa00cd35bc536d2ba
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm_fb: Fix adb shell start/stop issue when bypass enabled

Currently when 2/3/4 layer bypass is enabled, doing a adb shell
stop/start is failing overlay and composition happens through
GPU. Fix this issue by proper overlay configuration during this
scenario.

Change-Id: Ia04f1839bf80ed552671e48445af63a4dcd6bdfd
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm_fb: display: add mfd null pointer and mfd panel_power_on checks

These checks are necessary for the situations where display is off but
vsync ctrl enable or disable is still called.

CRs-Fixed: 462586
Change-Id: I2ee43ff323da38359f3bff28669df19b87d8343d
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm_fb: display: keep borderfill pipe's iommu info

Keep borderfill pipe's iommu info during base layer pipe
swap with original base layer pipe. Otherwise, borderfill
pipe's may contain original base layer pipe's iommu info
which cause iommu page fault due to same iommu buffer is
unmapped two times.

CRs-fixed: 436711
Change-Id: Ibdb792055287283c4449db07c2de2901aa4fe9b6
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm_fb: display: fix iommu leak during base layer swap

Retain RGB1 iommu information during  base layer swap
so that iommu used by RGB1 can be freed back to pool later.

Change-Id: Ibed85179284743dc8a9d1434f0c81626b0567e16
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
(cherry picked from commit be46f9f596c5172438a74759d48ca7db600cd737)
msm_fb: display: Configure solidfill color to black

The solidfill color was getting reset to to default state to white.
Correctly reseting to black by default.

Crs-Fixed: 453600
Change-Id: I203ce61867d009509bf6acd01169f1fb0b223652
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm_fb: dsiplay: fix frame buffer f_count leak

Frame buffer maintains a reference count (f_count) which increased
by fget() and decreased by fput(). overlay play will apply
fget() to frame buffer if it was the soruce buffer and fput()
will be applied to it after pipe commit done. However there has
extra fput() apply to frame buffer at the time pipe is freed.
This patch fix the problem by  clear MDP_MEMORY_ID_TYPE_FB from
pipe's flags to avoid extra fput() applying to frame buffer.

CRs-fixed: 411394
Change-Id: Ib2b72e6277480b5ace23cda554be485d9d477b3d
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm_fb: display: return fail if pipe still staged

Pipe is not un-staged from mixer when it is unset.
It expects a pan_display() to un-stage it out of mixer.
Return fail at overlay_set() if pipe was still stage
at mixer.

CRs-fixed: 399193, 393979
Change-Id: I562f6e133bb239b30f4f53669dbf1cc5ddf80d02
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
sync: Fix race condition between merge and signal

The copied sync_pt was activated immediately. If the sync_pt was
signaled before the entire merge was completed, the new fence's pt_list
could be iterated over while it is still in the process of being
created.

Moving the the sync_pt_activate call for all new sync_pts to after both
the sync_fence_copy_pts and the sync_fence_merge_pts calls ensure that
the pt_list is complete and immutable before it can be reached from the
timeline's active list.

Change-Id: I7aa4d404a822347b6ce148018d2a66e4f6a20c78
Signed-off-by: Erik Gilling <konkers@android.com>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Signed-off-by: Uma Maheshwari Bhiram <ubhira@codeaurora.org>
sync: don't log wait timeouts when timeout = 0

Signed-off-by: Erik Gilling <konkers@android.com>
sync: fix timeout = 0 wait behavior

Change-Id: I8b9254e92c26d9f44abbc0c77fb44624de947013
Signed-off-by: Jamie Gennis <jgennis@google.com>