libqcomui: Allocate idleTimer dynamically and arm it to expire once

This change:
    1) Allocates idletimer object dynamically in HWC to explicitly
       initalize its members
    2) Modifies idleTimer arming logic to expire only once after given
       timer delay

CRs-Fixed: 365305

(cherry picked from commit 3091112c6af4ef75e911d59e73029a72704c0f11)

Change-Id: I28f1ffbbbe8dc70d4ae6065866f77ff91bfe3cf9
hwc: Fix deadlock due to async signal handler.

If an async signal handler tries to acquire a lock,
which the "active thread" already holds, we hit a deadlock.

--Remove signal handler.
--Create a separate thread for invalidating drawing after
  a specific timeout.

Flow:
Draw thread asks invalidator thread to sleep on an MDP comp update.
On invalidator thread wakeup, if there were no MDP comp draw updates,
it triggers a forcible draw using c2d / gpu + close MDP comp channels.

CRs-fixed: 365753
(cherry picked from commit 14fe810804ac16b36d56c39eb402ad08658c5e62)

Change-Id: I61bd325e4d92fd5d6ea8e9e13b8aa8c0139880b5
LibOverlay: Set fg flag for Secondary Display

Enable fb_en for VG2 overlay if DISABLE_FRAMEBUFFER_FETCH is set.

CRs-fixed: 352855, 355921
(cherry picked from commit 27a4dd525c84139c4c3a8724d13c6989b6b34d0e)

Change-Id: Ib76f2cbdac84eae7f422be410dda023b89d87a2d
Framebuffer : Pass actual display buffer size

When opening the HDMI mirroring channel, use actual display size.

Change-Id: Ib3a6563de50844575d01df828c8ccedf06c58dc1
libhwcomposer: force secure buffers to MDP.

For secure buffers even if display coordinates are out of
screen bounds, calculate right clip coordinates and push it
to MDP as GPU can not render secire buffers.

CRs-fixed: 363835
(cherry picked from commit f0ba936c52da7ff80ba014d3af4b6aa1d40b61f5)

Conflicts:

	libhwcomposer/hwcomposer.cpp

Change-Id: I40c94f167bcb44788e4a674bbc38ea4a939c5710
(cherry picked from commit f0ba936c52da7ff80ba014d3af4b6aa1d40b61f5)
libhwcomposer: force secure buffers to MDP.

For secure buffers even if display coordinates are out of
screen bounds, calculate right clip coordinates and push it
to MDP as GPU can not render secire buffers.

Change-Id: I3f4ccc2cc583f9aac2e26891fa69b7dae0556c1c
CRs-fixed: 363835
libhwcomposer: Add check for downscaling with alpha in MDP composition.

MDP supports downscaling with alpha only in RGB pipes. This change checks
for the number of layers which need downscaling with alpha and falls back
to FB composition if we have more than one such layers since bypass have
access to only RGB2 pipe in MDP composition.

CRs-fixed: 356654
(cherry picked from commit 70d7fac863b1565c81d58add028590001dc7e402)

Conflicts:

	libhwcomposer/hwcomposer.cpp

Change-Id: I089e0424cce3f6beeb904bbab4b3c43da9a6f2d4
hardware/qcom/display: tilerendering with fbo boundaries

provied support for tilerednering when switching rendertargets

Change-Id: I4909f1560a83cefeab453cfd4c3d80176bf2bc6d
liboverlay: Fix the horizontal displacement issue on 3D
video on 2D TV

In 3D video capture, right and left cameras are placed at different
view point. so there will be a difference in right and left views.
currently we are displaying left view on the primary panel and right
view on the external display.

Change: Display left view of 3D video on both primary and external
2D display devices.

CRs-fixed: 368673

(cherry picked from commit 28c5f1a802bcaa469da55bac9899511e3fa99974)

Change-Id: Ie17191995815678cbfcf995b67522019322e4bb1
Revert "hardware/qcom/display: tilerendering with fbo boundaries"

This reverts commit ef8bc412ebbc66962d525face6ee9b779f1bb800.
libcopybit: Fix UI blur with C2D composition

Enable bi-linear filtering in c2d to fix UI blur
with C2D composition.

CRs-fixed: 367578
(cherry picked from commit fb408361715418a32fc0d0f6379603f131898d26)

Change-Id: Ie46f4fb40a4c6a9e10d31ad444894d4735e9d542
libgralloc: error handling of fb HAL

if an ioctl fails during  mapping framebuffer device
close the file descriptor before return. Also add a print
to identify the error.

CRs-fixed: 368566
(cherry picked from commit 49625915b0ea98ede6037694208a6e5dfc923a40)

Conflicts:

	libgralloc/framebuffer.cpp

Change-Id: If84a65f7af5cd6c506711760beb933f62df130a0
libgralloc : Correct the usage of pmem ioctl

Return error only if the ioctl PMEM_ALLOCATE_ALIGNED
returns negative value.

CRs-Fixed: 375513

(cherry picked from commit b1caf041824cedc268ced33e47a166070ec84f29)

Change-Id: Ie5e926648ff845dc04ce06e5c57e27dd214d1b45
libhwcomposer: Check for downscaling with alpha based on target

Downscaling with alpha is not handled by the RGB pipes
on targets with MDP version less than 4.2. In such cases
MDP composition is not possible and we fallback to FB.

Change-Id: Ic65a0f407c52549c5bbf5eb93c63a948864f08ab
hardware/qcom/display: Fix CALC_FPS overcounting frames

The overcounting of frames by CALC_FPS bug got re-introduced by a recent
change. This change fixes it again. With this change, debug.gr.calcfps
enabled gives correct FPS.

Change-Id: Ib39efe346d1c779da0e0657a3a47f0b07c8569bb
CRs-fixed: 378682
libhwcomposer: Fix secure buffers issues

For non-overlay targets also, force secure buffers to MDP even if
display coordinates are out of screen bounds.calculate right clip
coordinates and push it to MDP as GPU can not rendersecure buffers.
-Also move crop rects calculation from overlay to a common place.

CRs-fixed: 377160
CRs-fixed: 372835
CRs-fixed: 376078
(cherry picked from commit Ifa4725610b5f66d04e1103e7b34331e71214c65c)

Change-Id: I282b696afd3103ce3bf877c64e376f76641996f7
libqcomui: Use qcomuiClearRegion for Dynamic composition

Dynamic composition switches between c2d or gpu based on the
render region of the current frame. If c2d is choosen, it
should use qcomuiClearRegion for clearing the FB.

Change-Id: I110f831d7bc37a681ae22bc448869fcf5203c468
hwcomposer: Determine fb index for external display device
liboverlay: fix incorrect initialization of crop

Remove incorrect initialization of crop in setsource.
Crop will be set in setCrop.

CRs-fixed: 374460
(cherry picked from commit 724b0618e06375b2aa062f9c07d3fb601feae680)

Change-Id: Idf7fdb3a84f3924eb0ccc313bb3eb19ed959a390
qcom/display: Temporarily remove some logcat spam

Change-Id: I34646b4d2f05bc6f6a4b043f8163f8d9d2c1dc4a