libhwcomposer: Implement idletimeout fallback for MDP composition .

Background: On MDP compositon, MDP keeps reading contents from the
pipes even on Idle Screen i.e. even when HWC is not queueing any new
buffers to MDP. Above data traffic leads to high power consumption.

Implementation: This change introduces a timer in HWC which will
timeout if there are no updates in bypass composition path for
the period specified via debug.bypass.idletime. Also SurfaceFlinger
will be notified to redraw the current frame which will be composed
into FB.

Conflicts:

	libhwcomposer/hwcomposer.cpp

Change-Id: Ic3a467596068fa553271b5cd8c2831e544e3211d
(cherry picked from commit ad1d9a019234ab03dbc79b1ddb73c86e560e3e74)

Conflicts:

	libhwcomposer/hwcomposer.cpp
libhwcomposer: Set bypass transition flag before invalidate()

Set flag to ensure HWComposer::invalidate() does not draw with
bypass still enabled. Also, log comp bypass transition due to
idle-timeout.

Change-Id: I3343d092a92c9677d0b9d50ced094c96d229474a
(cherry picked from commit f27aebd66249d165c0a3342abf4064a5dc350a6d)
hwcomposer: Let the external display header be overloaded

Individual devices may want a different header

Change-Id: Ic2d9524dc2dfc4ff76e0516ac7cd02432f9c95f6
Fix heap corruption in overlay clients.

Fix heap corruption in overlay clients, caused by missing
compilation flags. All libraries using overlayLib.h should
have flags used for conditional member declaration in overlay.

CRs-fixed: 342959
(cherry picked from commit 42120b29500560ebedbd897e2e7adf7369eb0a21)

Change-Id: Idf613861c4dc67e96ecadf7ce7e37472cb4e4daf
hwcomposer: Add workaround for cropped layers during bypass

 * Some hardware cannot handle cropping during bypass, or reports
   invalid rects during orientation change. If the invalid rect is
   cropped, MDP gets into a weird broken state where layers turn
   transparent, display blinks, etc.
 * Also use the VG pipe for 2 layers instead of just 1 in this case, it
   eliminates flicker when unlocking the device.

Change-Id: Ia5cb1a368bcc8949ba224a8510f577450449f22e
Avoid 3D video layer for GPU composition

libhwcomposer: Donot mark the 3D layer below HWC_SKIP_LAYER
for GPU composition. In these cases, let the layer be
composed through composition type decided in hwc_prepare.
This helps us in avoiding the cases where 3D videos
cannot be composed through GPU.

CRs-Fixed: 346973

(cherry picked from commit 0331f07ed4b5a3cf5a2e358c8417ac9e8103bc07)

Change-Id: I9f6c53cc2da35109fe789074a9d1accc11372dd8
libhwcomposer: Implement register_proc in HWC

register_proc in HWC is used by SurfaceFlinger to register
callback functions with HWC. This can be used by HWC to invoke
SurfaceFlinger functions. Currently invalidate is the only function
registerd and can be used by HWC to trigger a screen re-draw.

CRs-Fixed: 342060
(cherry picked from commit 03a5cf4b9c52da2bfbd9706e85fddae63110ee9b)

Change-Id: I464370ebf63b93e0ce238395b5c165647d777575
Display/hwcomposer:Add support for intermediate down scaling

Copybit module has a limited stretch to up/down scale.
Hence we need to do a intermediate stretch before going
to final stretch.
CRs-fixed: 341196

Change-Id: Ic547fdb8e88072f9f89032f047d04a7a26bddf71
(cherry picked from commit 256bde19b8f912388e19390570e5ea36f0208cfe)
Unlock overlay buffers before going to suspend

In video playback through overlay, it is observed that, during
suspend/resume, genlock TIMEOUT errors are seen at the component
level.

drawLayerUsingOverlay() function locks buffers, but doesn't unlock
them, before going to suspend, making the genlock_lock_buffer calls
from video component to fail.

Unlock any overlay buffers before going to suspend.

CRs-fixed: 342878
(cherry picked from commit 4ffcd156710184fe492294fd55beea7d5f412116)

Change-Id: Id0165f370d05d9b4bdf71ddaea15cf00caa65896
hwcomposer: fix blank screen on external display.

fixes the black screen when external display is connected
during bypass and when video is paused.

(cherry picked from commit 2ffc188a6cad26a347e565211564640173f340ac)

Change-Id: I6caeda8bbc744a45164e2ae139345ba4aab55dab
CRs-fixed: 346284
qsd8k: hwcomposer: update drawLayerUsingCopybit

fe623a3 libhwcomposer: Remove dimension Align checks for copybit
5ceafe7 libhwcomposer: Make fb width 32 aligned.
4c56f52 Display/hwcomposer:Add support for intermediate down scaling

Change-Id: Id52e04db2055f1f58543eaf3a9b84e103af739b5
framebuffer: In enableHDMI, check if target supports true mirroring.

- check if the target supports true mirroring in fb_enableHDMIOutput
  instead of framebuffer HAL initialization.
- We check if the target can support true mirroring by using the RGB1
  pipe, with new driver changes, RGB1 pipe is allocated only after
  first display update.
- Hence moved this call to fb_enableHDMIOutput

(cherry picked from commit db5225cc97b7c42871d5674702e1ca48a5a27904)

Change-Id: I9838fb0bfe6d49c5de3a7b1f4c116bd93c7b375c
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
hardware/qcom/display: Fix overcounting frames with CALC_FPS

With a recent change, debug.gr.calcfps was enabled, frames were
being overcounted. This change fixes it.

CRs-fixed: 350335
(cherry picked from commit e8ea630b6b629403ad713b8cb3d912c4d54e7699)

Change-Id: I863072f3311c584edd30f7be74a3ab8122f05f01
libgralloc: fb size alignment to pagesize

Align framebuffer size and offset to pagesize, calculate
framebuffer size based on this alignment and use it for
mapping framebuffer in userspace and page flipping.

CRs-fixed: 332175

(cherry picked from commit d89b0493b4651fbaaeccccf0ae880cbf1a3a3479)

Change-Id: I7840f7f3c5c42852087cb9df6ae85680c971c601
libgralloc: fix the calculation of fb virtual y resolution

calculate the yresolution virtual according to the hole
introduced by 4k alignment of frame buffer.

CRs-fixed: 325134

(cherry picked from commit 464443a5d3b216e06e644d0e41c234490c3c46c2)

Change-Id: Id7a93e11e2f3c1d52a26ec3669a9d710c369bf41
liboverlay: set correct flags for external display channel

When external display is connected during video playback, the
flags to overlay was not set properly.
Pass the flags which comes from the hwc, by just changing the
WAIT_FOR_VSYNC(external should not wait for vsync)

(cherry picked from commit 857cfcba2d120d5da4916c7cb4fe119a08d1ce68)

Change-Id: I13100bebd223780eb9c709f384f0e4644e8295dc
liboverlay: Remove evening-out of layer destination coords.

Evening-out of layer destination coords causes a noticeable up & down
shift in the screen when video layer drawing switches between Overlay
and GPU. This is most easily observed during video playback or pause,
when a UI layer (like Menu) is displayed / hidden. Remove evening-out
of layer destination coords to fix the video layer "twitching" issue.

Change-Id: I3f43b53a7609c9ad8cc983c353fba6dc97460158
CRs-fixed: 348856 350073
qcom/display: Add support for video rotation on HDMI

- Enable rotator for HDMI for video
- cleanup updateOverlaySource API, it does not need
  orientation info

Change-Id: Id53a42cbc4265015ea2714d25df1b02af60ee5e4
CRs-fixed: 341691, 330719, 342199, 344308
liboverlay: Call overlay set ioctl, only if input params change.

Change-Id: I753c30be4062be10655d7072c795052ef65f87ae

Conflicts:

	liboverlay/overlayLibUI.cpp
Fix secure flags value in overlay.

Remove the member "secure" from overlay_buf_info.
This member was used to indicate secure content and this info was
later extracted out into existing flags. Now we use the same flags,
right from hwc to mark secure content.

The member above had junk value, since it wasnt initialized.
This caused, normal videos to fail with IOMMU. Removal of the member and
marking the existing flags fixes this.

Change-Id: Ib5a2439fde7114c20e478fbee5e4d276680c316a