gralloc: Fixes for software composition

Check that the buffer is actually an ion buffer
before calling clean. This is needed for the case
where the physically contiguous framebuffer is mapped.
That framebuffer memory is used for bringup.

Change-Id: I2db84d4bfc3465d995f12e0860be3cafa0d4a81b
gralloc: Do not map framebuffer memory unless needed

The SurfaceFlinger opens the framebuffer module even when it
isn't necessary. It does this for some legacy hals.
Due to this we unnecessarily mmap the fb memory in gralloc.
Do not map this unless the property to use the framebuffer
memory is set.

We do further operations in fb_device_open based on the result of
mapFrameBuffer. However, if mapFrameBuffer is never done, we
could end up with a random crash when using the info values in
fb_device_open. Defaulting to an error value avoids this.

Change-Id: Ib4ebfdf9a63af0dabb53170342181bac0360baeb

Change-Id: I1e51f814611a3f2eb73f36d75e14d8725ca98474
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
gralloc: Backward compat for devices using older camera heap

Change-Id: I5d3feadd0c4dd629fcb3a750e9d4be0c6b3d6a6f
gralloc: Align protected allocations with the spec

The specification for GRALLOC_USAGE_PROTECTED indicates that
allocations with that flag must be protected by securing with
hardware. If such protection is not possible, the buffer must not
be composited. In our current software only the MM_HEAP is
secured. If we allocate protected buffers from any other heap we
block those from being displayed.

CRs-fixed: 465012
Change-Id: I9d47aba3d28192db3fcc394fd6b38efe42ae118b
libgralloc: Fix secure buffer issues.

-- Though buffer usage is not marked with any Heap, if usage flags
set with GRALLOC_USAGE_PROTECTED allocate from IOMMU heap.
-- Allow using  GRALLOC_USAGE_PROTECTED for non tz level protection.

Change-Id: Ie3c8bd8821f4ab344a2b798a723ab65d4ef5b44e
CRs-fixed: 484838
CRs-fixed: 480493
display: Add flag to allow legacy allocations from MM heap

 * New devices with IOMMU use the MM heap exclusively for protected
   buffers. We need to support the old behavior for devices with legacy
   userspace.
 * Enable the old behavior with TARGET_DISPLAY_INSECURE_MM_HEAP.

Change-Id: I7882354fa8f159c707be11d7021c18561abfb522
gralloc: Fix some differences with compatibility code

Change-Id: I0f41ff987b6b3f554e11ea2f259d778c8cee7fa2