hwc: Check for correct screen state before enabling vsync

Sometimes vsync would not be disabled before the display is
blanked.
This was due to the vsync disable ioctl being kicked off in a
thread different from the event control which surfaceflinger
called. So, while the calls from surfaceflinger are in order, the
order of execution wasn't always the same. Hence, making sure
ioctls are called in the same context to ensure order.

Also
- Make blanking/unblanking logs show the operation as a string.
- Add a debug property to dump vsync timestamps (needs framework
reboot)
- Remove a log which showed delay in reading vsync. This log was
unreliable when vsync is disabled and we're still reading from
the sysfs node.

Change-Id: Ibec04e9ffebd0ac6e1d32b7031e3668abd9390ff
CRs-fixed: 443113

Conflicts:
	libhwcomposer/hwc_utils.h
hwc: Check vsync state before sending it up

The vsync enable ioctl is called in  a separate thread in a
recent change
Hence it was now possible that vsync could be disabled but
SurfaceFlinger still received a vsync. With this check we make
sure that doesn't happen.

Change-Id: I459c0b98ab9ce972d86a361c5ecdfe0c1a2d0e74
Merge "hwc: Check for correct screen state before enabling vsync"
Merge "hwc: Check vsync state before sending it up"
hwc: Add support for clearing with c2d

When blending translucent layers or transitioning with c2d,
sometimes the frame is blended with stale framebuffer content.
Clear the frame with C2D fill surface before drawing.

CRs-fixed: 462461
Change-Id: I1dca477fe88d77f4f0fa4846b155404f348e911d
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

Conflicts:
	libcopybit/copybit_c2d.cpp
hwc/copybit: Add check for Max layers support.

Add check in copybit for Max. layers supported by HWC. Increase
max. RGB surfaces to MAX_NUM_LAYERS to support known use cases.

CRs-Fixed: 481226
Change-Id: Ie30ab0ef3047a304133cb547902ae11fecc5db22
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
Merge "hwc: Add support for clearing with c2d"
Merge "libcopybit: Fix potential memory and surface leaks in c2d"
Merge "hwc/copybit: Add check for Max layers support."
Merge "libcopybit: Fix GPU page fault on c2d use"
libexternal: disable HPD during initialization.

- Disable HPD at start, it will be enabled later
  when the display is powered on
- This fixes the issue where the HDMI mirroring
  was not working when there was a framework reboot
  or adb shell stop/start

Change-Id: I56d706ebae281297a8ec6517a4fb8e5cdda27617
CRs-fixed: 533372
Signed-off-by: Nirmal Abraham <nabrah@codeaurora.org>
Merge "libexternal: disable HPD during initialization."
overlay: Reset allocation on all pipes, if commit fails.

If commit fails on a pipe, overlay hal needs to reset allocation
on all pipes for the given display. As MDP Comp fails, it falls
back to video and PipeBook logic does not pick-up those pipes on
which commit was successful. Driver sets new pipes and un-stages
previously set pipes (with same z-order). Pipe clean-up happens
and then in next round, PipeBook logic picks-up previous pipes
hence userspcae and driver remain out of sync.

Change-Id: I963fbdf89f346184688c5bcac2824606a5f7a0f2
libcopybit: Remove usage of C2D_NO_BILINEAR_BIT

Remove usage of C2D_NO_BILINEAR_BIT in the config mask.
This enables using the BILINEAR filter for scaling and
improves the image quality

Change-Id: Ic9b61fe3ed5b16e63971fe542928640a13d92764
CRs-fixed: 453925
libcopybit: Use blending parameters passed by HWC

Instead of assuming the premultiplied alpha based on the color
format, use the blending parameter passed by the HWC.

Change-Id: Ib494644b6f9c4bf13d8ea28327ccc2058a52aae8
CRs-fixed: 466732
Merge "overlay: Reset allocation on all pipes, if commit fails."
Merge "libcopybit: Remove usage of C2D_NO_BILINEAR_BIT"
Merge "libcopybit: Use blending parameters passed by HWC"