hwc: Reset Layer cache on idle timeout

In the case where MDP composition is possible but we fall back to
the idle timeout, there is a possibility that all of the layer
handles that were cached in the _earlier_ idle timeout are the
same in the _next_ idle timeout. This could cause us to display a
stale frame. Reset LayerCache in prepare if we are in the idle
frame.

Change-Id: I3ab1b0f28044975978a32e082976b038242697d0
hwc: Sync for rotator

Implement sync for rotator.
If a buffer is rotated, it can be used by producer soon after
rotation (and it wont have to wait until vsync).

Mdp waits for the rotator buffer's release fence to signal
to start display.

Hwc waits for previous access to rotator buffer by MDP to finish
before using it.

Change-Id: I5664806a17c44d58af62a2825ce454089fcd31cf

Conflicts:
	libhwcomposer/hwc_utils.cpp
overlay: Use correct downscale for rotator.

Downscale is calculated based on area of dst and src.
Apply sqrt of downscale to each dimension.

Change-Id: I9def4ea5073e0e49a05103505a6b6f5013f0d579
liboverlay: round off rotator downscale factor to nearest integer.

This reduces the MDP clock and bandwidth requirements and
avoids falling back to GPU composition.

CRs-fixed: 457295

Change-Id: I4408ee0485248987342df63669f1a6894ea0dd73
qdutils: Retrieve MDP revision and pipes information from driver.

Userspace can retrieve MDP revision number and number of different
types of MDP pipes (RGB,VG,DMA) information from driver. Add target
specific flag as previous MDP versions do not provide this support.

- Make use of this information while maintaining PipeBook.
- Move PipeBook related functions from overlay utils to PipeBook.

Change-Id: I46578bb27e515c4b9525d90b6619c11d7749914f

Conflicts:
	liboverlay/overlayUtils.cpp
	liboverlay/overlayUtils.h
overlay: Bring back debug.mdpcomp.maxlayer

 * We're having underrun issues with 4-layer composition. It generally
   works, but when the system CPU ramps down and the device is mostly
   idle, underrun is happening.
 * Limiting to 3 layers solves the problem temporarily on these devices.
 * Readd the option so that the issue can be debugged without afflicting
   our current users with massive amounts of flickering.

Change-Id: I7ab7d013f65eaf12a3d21a91229dcaad6a815069
libhwcomposer: align rotator source buffers for tile format.

for tile format make the rotator source buffers aligned to 64 X 32.
This avoids rotator hang during source fetch.

Change-Id: I9e42788cc6f538b155c073028ce41bf48e1d9349
CRs-fixed: 473297
hwc: Fallback to GPU if source image width or height is less than 2

There is h/w limitation when MDP_OP_SCALE_RGB_ENHANCED bit and
MDP4_OP_SCALEX_EN or MDP_OP_SCALEY_EN bit is set.
The minimum block size is 2x2. MDP will hang if the source RGB image
height or width is equal to 1. Hence fallback to GPU in such cases.

Change-Id: I7333b097fd26bfb888865de9c39d1664bc87acca
CRs-fixed: 477581
libgralloc: Change CAMERA_HEAP to ADSP_HEAP

This changes GRALLOC_USAGE_PRIVATE_CAMERA_HEAP to
GRALLOC_USAGE_PRIVATE_ADSP_HEAP as the CAMERA_HEAP
is not used anymore

Change-Id: I5a95f68c4c7f4445ade2398dd239faad9ed16b22

Conflicts:
	libgralloc/alloc_controller.cpp
	libgralloc/gralloc_priv.h
libhwcomposer: print a log if there is any delay in vsync read.

If there is a delay in vsync read print a warning message if
vsync status is enabled.

Change-Id: Iac875323fca441ff5261f8e9ddef2936e433e84e
CRs-fixed: 462993
hwc: Do not include Framebuffer area in calculating total area

In dynamic composition, While calculating total render area of
application layers to decide on which composition to choose,
FrameBuffer layer area shall not be added to the total render area.

Change-Id: I712b601031c6faac2d077a8d601cbf9fa82f3d5b
CRs-fixed: 482264
libcopybit: Fix GPU page fault on c2d use

On HDMI connect or other use cases where finish_copybit
is called, reset dst_surface_mapped and dst_surface_base
as destination surface is already unmapped.

CRs-fixed: 481685
Change-Id: I0073a46178e6b1ecfdbf0a08d8790af4271bc37b
hwc: Only enable vsync delay logging for debug builds

Change-Id: I56d0c67b3742358d4cd7439c7b6f735e0a35a055