hwc: Configure MDP with updated content attributes of PTOR layers

Since there is no content underneath a PTOR layer, all overlapped
contents have been composed by Copybit on render buffer. So for a
PTOR layer, we can set blending to HWC_BLENDING_NONE and planeAlpha
to 0xFF. And the transform for the PTOR layer should be set to 0 to
avoid MDP flipping again.

Change-Id: I26fec26dcde4d9b0b62f94107a013d82074628b5
hwc: mdpcomp: Free pipeinfo objects every drawing round

Free pipeinfo objects every round on reset, irrespective of the
number of layers to avoid any possible leaks.

Change-Id: Ia47c968f6ee64cbb56be72336305bf11a45c2ee5
hwc: Remove getNonWormHoleRegion optimization for primary

Remove getNonwormHoleRegion optimization for primary because.
1. This overrides fbUpdatingRect optimization for primary.
2. sourceCrop and displayframe are always full screen for primary.

Change-Id: Ic6867c23ace40fcf36657cbbf1293cb4eb171a67
liboverlay: Invoke commit before freeing the writeback device

MDP releases resources programmed for the WB device only when the
device is not used by anyone else. So freeing up the WB device from
HWC doesn't always guarantee that all the pipes staged on the
device will be freed up. Always invoke the commit explicitly
before releasing WB device to unstage the resources.

Change-Id: I1d98b489eda3baf12449f84edfb3b3f8b84158d9
h/q/d: Read minimum width and height values of the panel ROI

Read minimum width and height restrictions on ROI of a panel
through sysfs node.

Change-Id: I0e4c35cdcaee06e77955725565cfbed2f0fd91e9
hwc: src split: Fix unwanted scaling with H-flip

Source split splits the crop and position into half, but if the
widths are odd and the left, right crops are swapped for H-flip, it
induces a scaling that is unaccounted for while allocating pipes.
This could lead to DMA pipes having scaling.

To fix this, the patch manipulates position width, if a swap happens.

Change-Id: I1b3ed582740fd49e651407be422820f60fe59cc6
hwc\overlay: Remove support for foreground override

Remove support for overriding a layer's z to set it up for foreground.
This is unused and can be achieved using pipes staged at required
z-orders.

Change-Id: Ia4688beed770c44c20d201a2dc5687252e002981
overlay: Add support for rotator downscale

Add support for rotator downscale. This is enabled from 8994 onwards
Constraints:
--Downscale should be a power of 2, max upto 32
--Both directions should have equal downscale
--{src_w, src_h} mod downscale = 0
--No BWC
--No Interlaced video support

The rotator's destination rect is modified to reflect the presence of
downscale. Any downscale calcs should be done only after adjusting
crop to meet rotator's requirements.

Smaller downscale is used if we need to chop off any more than 1
line or pixel.

Change-Id: Id07d62fefa3213035f16cca49497800716484a95
hwc/overlay: Implement rotator caching

* A non-updating layer requiring rotation, can make use of
the older rotator buffer written when the layer got first
updated, rather than invoking a new rotator cycle.

* A rotator play is avoided in cases where incoming layer
buffer fd, offset, whf, src-rect, dst-rect, etc are similar
to that of the previous input layer to the rotator.

* For ex: In a usecase where video layer updates happen at
30fps and all other asynchrous UI updates happen at 60fps,
instead of the traditional 60 calls of rotator play per sec,
we now do only 30 thereby saving rotator bandwidth.

* Property "debug.rotcache.disable" can be used to disable
this feature.

Change-Id: I1d1c352c63007b7e0b4fee40882086ccd2f5a4aa
gralloc: fix getYUVPlaneInfo for YV12 format

- Use proper alignment for cstride while calculating the
  ycbcr info for YV12 format
- This fixes the corruption issue when the video is composed
  using GPU

CRs-fixed: 711696
Change-Id: I776cc6c5ce781ea3de25b5d8427345b512a8305a
gralloc: Use ION fd in FB handle

- After mmap, use the meta data ioctl to get the ION fd
  for the framebuffer memory as GPU expects buffers to
  from ION
- Set appropriate flags for the framebuffer private handle
- Remove unused members

Change-Id: I45c4917d9811cd3b3800adf222b92f41f97430c0
Limit #ROT-SESSIONS to 4 in LayerRotMap and RotMgr

* Limit the number of rotator sessions to 4 both in
LayerRotMap and RotMgr structures

* Make use of MDPVersion getter fuctions to check
for maxMixerWidth and maxDownScale supported by MDP

Change-Id: I27dac877807fbb4ed6fcb3500a3a318a2ef5d8b2
qdutils: Parse rotator downscale feature

Parse rotator downscale feature from the capabilities sysfs node

Change-Id: I346a20d4879682e115eb2f8f74afd41dca31e930
qdutils : Read max mixer width from drivers.

Read the maximum width mixer can output from drivers
and consider this in identifying if dual pipes are required
to support a layer. So far above 2K dimensions we are using dual
pipes, but 8x39 mixer output can be upto 2560. So there is no
need of dual pipes as long as pipe data is less than this limit.
Compare layer/panel resolutions against this limit to deduce
if there is a need for dual pipes or split.

Change-Id: I52e1d28e381327d4f0b00f5ea8547c1e6157313c
hwc: Fix compiler warning

Fix compiler warning messages due to narrowed conversions.

Change-Id: Ifa770683fa9af7d5280c9117520276e04100302c
gralloc: Fix incorrect handle validation check

The YUV plane info reported to driver has an incorrect handle
check. Use the check correctly.

Change-Id: Ice6388a3d8b91bfa5373e850e3102c6ccf92eb75
display: Remove ashmem header includes

Ashmem use in gralloc has been deprecated for some time. Remove
the stale headers.

Change-Id: Ie048c377b649c0639ffeefe9af41f7a5caaf0382
libqdutils: Readd macro for compatibility

Change-Id: I4f0d684e3e2272f7a70ede3cde9b9020173da058
hwc: Handle validateAndSet failures in AD prepare call

When validateAndSet fails we must reset the mDoable flag to false and
close the fb device. This will prevent making a draw call using
invalid resource references and prevent any fd leaks.

Additionally, we should only turn AD on if there are no configuration
errors during prepare call. This will prevent toggling AD between
on/off state in the face of continuous failures.

Change-Id: I15502dbf64c6203092aa13e001bab5d27b0e17ec
hwc: Conditionally compile dirtyRect under QCOM_BSP for copybit

Conditionally compile layer's dirtyRect under QCOM_BSP in the copybit
file to prevent breaking builds that don't have this member in
headers.

Change-Id: I1669c5eefd1f48e45625797ef1508b5a6f23e6b1