hwc: Fix the copybit threshold comparison

Change-Id: Ife9d54d4592e2427e8de6e67b4c8f62b676b2679
libcopybit: protect all c2d copybit API's

- Each client API exposed by the copybit C2D needs
  to be protected.
- Add protection for clear_copybit and blit_copybit
- This is needed as clear_copybit was overriding the
  mapped gpuaddr while copybitwaitthread was waiting
  for transaction to finish and unmap
- After waitforTimestamp, the new addresses were
  unmapped leading to GPU Page fault

Change-Id: Ieeac10e73b05d3b47e602b2de4b4e64892737c9c
CRs-fixed: 470430

Conflicts:
	libcopybit/copybit_c2d.cpp
copybit: Fix type conversion error for GCC 4.7

GCC 4.7 has stricter type conversion rules

Change-Id: I699cfe1ceafb5728fb8e6f34f7b1996d3c812e7e
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
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
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
libcopybit: Fix potential memory and surface leaks in c2d

- Check MAX_SURFACES while mapping GPU addr
 --- While mapping gpu address, first check if the request
     is less than the MAX_SURFACES allowed.
 --- Without this check, when the request exceeded MAX_SURFACES,
     there was memory leak as that gpu addr was not unmapped
- Map the destination surface only once
 --- The destination surface for the c2d blit will be the
     FRAME_BUFFER_TARGET per transaction
 --- Map this only once from the copybit_clear which is the first
     call by hwc for a transaction
- Increase MAX_RGB_SURFACES to 12
 --- To handle use cases where there are more than 8 RGB layers

Change-Id: Iffacde30ee88b9c21d0895cb1922aa981bb079e9
CRs-fixed: 475327