hwc: Define and Use mSecureLock

Define and Use mSecureLock in composition and binder
thread. This is to ensure both variables mSecureMode
and mSecuring are updated in binder thread without
any context switch to composition thread

Change-Id: Ibd701bd3363515e2f7e8a9711bbc5b66053cfa03
HWC : Use Layer Caching in Video Only Use case on External

Currently Layer Caching is not used in Video only use case on
external. This causes GPU to redraw the UI layers every time.
This is causing under runs. This change will enable Layer
Caching in such use cases there by avoids  un necessary redraws.

Change-Id: Iedaf64b909dcd9d5b940c56c282c17a3b485637b
CRs-fixed: 514448
Hwc: Allow MDP comp for upto 2-Layers with Alpha & scaling

Since we are allocating RGB pipes first, we can allow
MDP composition Upto 2 Layers with Alpha and scaling.

Change-Id: I6ceb2b1a2f9d2228530529d93352dc466e39eadc
CRs-fixed: 523212
hwc: Increase precision in triming

Increase precision from float to double in triming calcs.
This improves the output. We need this since ultimately
we assign to int which would truncate excesses. With float
due to lower precision, we end up slightly lower than an
integral value.

Change-Id: I5d781b609be1761b746edf6503340f34a985b9e2
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: I26ca86639a5e62949f0e8b2a31d0bf17ce630551
hwc: Do not show animation on External display.

- When primary is animating, the animation should not be
  shown on the external display.
- Mark all app layers as HWC_OVERLAY on external during
  animation so that SF wont compose it on FB.
- Remove default arguments from setMDPflags function to get rid of
  issues hidden from the developer.

Change-Id: Ic557cabfd9f2518614777c0e993541e36e090850

Change-Id: Ic78645675b0aaab284fe2d0de8fffb4b26beabc7
Signed-off-by: ChampionSwimmer <championswimmer@aokp.co>

Conflicts:
	libhwcomposer/hwc_utils.cpp
Revert "HWC : Use Layer Caching in Video Only Use case on External"

This reverts commit edfc717febd64a8cb7dae671aec4c3670485c162.
display: External display refactor

  - cleans up external library
  - add separate library for virtual display
  - process virtual updates in its separate path
  in hwc.
  - Acquire blank mutex lock for one complete drawing
  cycle

Change-Id: Ib984c578464a131ecdb27ee48960f58d68b7a5a7
Signed-off-by: ChampionSwimmer <championswimmer@aokp.co>

Conflicts:
	Android.mk
	common.mk
hwc: fix aspect ratio calculations

- Make aspectratio calculations independent of ext dpy w/h
- pass hwc_rect_t to getAspectRatioPosition function instead of
  x, y, w, h
- overload getAspectRatioPosition func to return the upscaled
  or transformed position for a particular display based on the
  values set by SurfaceFlinger

Change-Id: I0be9b2b4b030bdd8e69dc1493dc8cbac31918c27
hwc: Call commit on primary & external in blank

* Call commit on primary mixer in hwc_blank after unsetting
the pipes
* Call commit on mixer connected to hdmi/wfd with
 wait_for_finish set to true. This is needed to ensure
composition on external is completed.

Change-Id: I1ca01a27fb6d8e9f61bf84babcc38b1daae87e58
hwc: Fix locking.

Remove the unnecessary blank lock, mdp comp lock, secure lock.
Rename the ext lock to a more appropriate draw lock.

The mdp comp lock is at an incorrect place and causes unwanted
objects to show up in dumpsys, since configDone hasnt cleaned
them up yet.

dump(), blank(), draw() should all acquire a common lock.
draw() includes prepare() and set().

Change-Id: I595547dd5a393a8af6cd8c9297d50793b715e658
Signed-off-by: ChampionSwimmer <championswimmer@aokp.co>

Conflicts:
	libhwcomposer/hwc.cpp
hwc: Fix Pause/Resume issues

  1. During PAUSE event, trigger an invalidate frame
     which will unset the pipes (in draw call) and invoke
     display commit as part of hwc_event thread.
     This is required to avoid iommu page faults arising when
     WFD encoder is in the middle of configuring buffers
     and providing to Writeback as part of RESUME event and
     Display HAL tries to invoke display commit as part of PAUSE.

  2. Allow usage of rotator for Primary when WFD is in Pause
     state.

The above changes are required to support secure/non-secure
video playback on HDCP WFD session and Pause/Resume.

Change-Id: I7391ae4cc7cd8b968873996a1a00fee5fbe6039c
hwc: Replace redundant display_commit with Overlay displayCommit

1. As part of Writeback class implementation, display commit is
implemented in Overlay class.
Replace display_commit function with Overlay::displayCommit
function.
2. Fix return value of hwc_blank function

Change-Id: Ie54fa9876495608a60216025e57cf4de7f6cb03c
hwc: Do not overwrite retireFenceFd if already set

* Do not overwrite retireFenceFd of displaylist in
hwc_set_virtual if it is already set

Change-Id: I785618bf3b266dc6fa8e881677df6e0849870ae7
hwc: Don't lock eventControl for vsync events

Locking here can lead to a delay in vsync disable/enable
where prepare/set is not yet completed. The HWC spec says that
eventControl needs to take effect immediately.
This lock was earlier present when we waited for SF to unblank
primary at startup and the vsync control ioctls could fail.
This is no longer necessary as we unblank primary on startup now.

Change-Id: I2bf18ae9235f8dd428a495a9a23af7f00f34ff1d
Signed-off-by: ChampionSwimmer <championswimmer@aokp.co>

Conflicts:
	libhwcomposer/hwc.cpp
HWC: Allow C2D composition when MDP composition fails

This change allows C2D to compose layers if MDP composition
fails for any reason, before falling back to GPU for targets
having dedicated 2D hardware.

Change-Id: I3017c088d3786e3013d0767eb813b7b75bf74855
CRs-fixed: 523272
libqdutils: Fix deadlock

The deadlock is caused due to mutex lock
Lock is not required at this point

CRs-fixed: 525354

Change-Id: Ibf7034d378a837f8bf9f6cc17fad84bc23a5932a
hwc: Perform MDP downscaling for WFD/HDMI Scenario

  On WFD/HDMI connection, if the configured resolution is less than
  Primary Resolution, Display HAL does the following:

  1. sends hpd notification to SF with primary resolution.
  2. configures MDP pipes with configured Resolution.

  This is done to improve UI quality as MDP has better downscale
  filter options compared to GPU.

Change-Id: I33570c13016a35ed6c5d22d4c34dfe75b2c605a1
display: Add BufferMirrorMode support for External

- In Buffer mirror mode, the output on the external should be rotated
  based on the primary orientation.
- this is used for the side sync feature.
- buffermirrormode has higher precedence over external orientation
- Add binder interface to enable/disable buffermirror mode

Change-Id: Ibea0af9627d69b4d42453adc868b113d82613437
hwc: Cleanup patch for SideSync and WFD/HDMI downscale feature

    Move block of code corresponds to SideSync and WFD/HDMI downscale
    feature to a seperate function.

Change-Id: Ib07cec61abf3a7226bc4dd2ebb9f313519114fd4