msm_fb: display: Send current timestamp if vsync time not available

Send current kernel timestamp if vsyncs timestamp is zero. This
happens if the kernel hasnt yet received the vsync interrupt.

(cherry picked from commit baba51f9b7e861309f79af3cdefa33b0da0834f4)

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

Conflicts:

	drivers/video/msm/mdp4_overlay_dsi_video.c
msm: kgsl: Add support for Android's sync point

The Android sync point framework will replace the synchronization
previously implemented by genlock. This change implements the KGSL
component of the sync point framework by creating a fence that is
automatically signaled by KGSL when it's timestamp expires. The
fence FD is returned to the user driver so that another process
can wait for the sync point.

Change-Id: Ifee38dfde00e551f3524f7a37833938dcdb64905
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:

	drivers/gpu/msm/Makefile
	drivers/gpu/msm/kgsl.c
	include/linux/msm_kgsl.h
sync: driver commits

- Revert "base: sync: signal a sync pt when not adding to the
active_list"
- sync: Fix error paths
- sync: add tracepoint support
- sync: refactor sync debug printing
- sync: use proper barriers when waiting indefinitely
- sync: update new fence status with sync_fence_signal_pt
- sync: dump sync state of fence errors
- sync: protect unlocked access to fence status
- base: sync: signal a sync pt when not adding to the active_list
- sync: improve timeout dumps
- sync: use correct signed type when handling SYNC_IOC_WAIT
- sync: dump sync state to console on timeout
- sync: clean up compiler warnings
- sync: fix erase-o in sync_fence_wait
- sync: change wait timeout to mirror poll semantics
- sync: add reference counting to timelines
- sync: add internal refcounting to fences
- sync: optimize fence merges
- sync: reorder sync_fence_release
- sync: export sync API symbols
- sync: allow async waits to be canceled

Change-Id: Id65ecdd395782d487773bdf7baa3ed681a72b729
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
Cleanup after merge from CodeAurora

Change-Id: Ib74f8ef938f97b683c51262b5eb4614050b96132

Conflicts:

	drivers/video/msm/mdp4_overlay_dsi_video.c
	drivers/video/msm/mdp4_overlay_lcdc.c
	drivers/video/msm/msm_fb.c
drivers: qcache: Port various fixes from zcache

 * Fix various lockups to improve stability

Change-Id: Ifeec71a934aa5f08b1b0b57bb05e22d0d7bf84e6
ion: Fix build with qcache disabled

 * Qcache is still unstable and buggy, but currently crashes if fully
   disabled on 8960.
 * Allow disabling of Qcache for 8960 and fix the dependency in msm_ion.

Change-Id: I3b2fc40ecce757530b64ddabb03081aaa425b603
msm: vidc: Allow client to request sps/pps per IDR frame

Expose SET_SPS_PPS_FOR_IDR to allow client request sps/pper per IDR
frame.

Change-Id: I0316d751bd1e0b412972cba9d4d59b142500a51d
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
msm_fb: Clear real pipe attributes in the pipe free

Clear original pipe attributes in the pipe free call.

Change-Id: I776869e7997e5b70e4c2b102e1a394034247bbcd
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp4_overlay.c
msm_fb: display: empty pending queue during suspend

Overlay_play() adds a pipe into pending queue and pan_display()
will commit those pipes to hardware and empty queue. This patch
will make sure queue is empty at suspend so that no unexpected
pipes will be commited to hardware by pan_display() at resume.
Otherwise, iommu page fault may happen.

Change-Id: Ib35c247550bb8754f9bff68a6352022d58c55ff8
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp4_overlay_dsi_video.c
	drivers/video/msm/mdp4_overlay_dtv.c
	drivers/video/msm/mdp4_overlay_lcdc.c
[ARM] msm: call video start function

Change-Id: Ib8ef8d2c0e0d550a2d100dd90334400f6761f6ac
Signed-off-by: Iliyan Malchev <malchev@google.com>
Revert "msm: display: fence fd releasing"

This reverts commit e221a8a6c352028e4ebf6de314cf1285a022ca77.
display: removed the code exhausts file descriptor in mdp overlay and rotator.

Fix the problem crashed while playing video clips and VT camera test.
ion_share_dma_buf is called in pr_debug.
So, it is called depends on build option and makes crash problem.

Change-Id: Ia96fdb7838eb2f3cdf979d8e0f886cb64eba6ca8

Conflicts:

	drivers/video/msm/mdp4_overlay.c
msm_fb: Display: Fix Dithering issue for rgb565 format

Using RGB888 as source format and rgb565 as destination pixel format,
will cause image corruption on the display. Fix this issue by
setting the destination format as RGB888 in MDP and DSI controller
pixel format as RGB565 for DSI specific panels.

CRs-Fixed: 377484
Change-Id: If58976ee9cd4825efb39437170e54796fa2213e0
Signed-off-by: Chandan Uddaraju <chandanu@codeaurora.org>
video: msm_fb: Ensure backlight is scaled atomically.

Ensure that when backlight scaling ratio or backlight level is being
changed that the operation execute atomically. This prevents a backlight
level change from being overwritten when it interrupts a backlight scale
update.

CRs-Fixed: 404017
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit ce328861aa1f4fa489e9abfc9d1e02b13af2ba47)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
(cherry picked from commit 0584596f75f8f2b184b8be1a0479ee61e449acba)

Change-Id: Ifb4bd5e823815b51dae38f1b8647b80d21b8ee45
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
usb: gadget: adb: Only enable the gadget when adbd is ready

When adb is enabled, only connect the gadget when adbd is ready. If adbd
dies or is restarted (e.g. "adb root"), the gadget is disconnected when
the adb device is close, and it is re-connected once adb re-open the
device.

- Add callbacks to adb, similar to FunctionFs callbacks, to notify the
  gadget when the daemon is ready or closed.
- Refcount calls to android_enable/android_disable to enable the gadget
  only once all the function daemons are ready.
- Add enable/disble to android_usb_function to notify the function when
  it is added/removed from the list of enabled functions.

Change-Id: Id54ff85aec9cf8715c94b4f9bd6137a79ad58bfc
Signed-off-by: Benoit Goby <benoit@android.com>

Conflicts:

	drivers/usb/gadget/android.c
usb: gadget: android: Don't allow changing the functions list if enabled

Change-Id: I3ad39b420ce79a8602a7eca1daac1f56b30bad5c
Signed-off-by: Benoit Goby <benoit@android.com>

Conflicts:

	drivers/usb/gadget/android.c
msm: display: display idle checking update

msm_fb_blank_sub might be called for UNBLANK from
display update work queue, which is at commit state.
Idle detection is invalid in this situation
Add detection for external snd earlyuspend/resume interface.

Change-Id: I1b08d10c9c494b9b3df5e95c4a54036877d5653f
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
msm: dsi: use timeout for dma transfer

Use wait_for_completion_timeout instead of wait_for_completion
not to stuck in the kernel even when the DMA fails.

Change-Id: I29702c3c62f78399c173d660bbbc17a07ed27468
Signed-off-by: Iliyan Malchev <malchev@google.com>

Conflicts:

	drivers/video/msm/mipi_dsi_host.c
mdp: Do not start LUT for overlay0

The post processing daemon is not used currently.
Enabling the LUT without using it can potentially
cause display hangs.
msm: mdp: Remove mixer1 blt for external

BLT mode is not needed for external displays since
there is no extra downscaling needed for videos.