gralloc: Add allocator and mapper HALs
Implement the hidl .hal interfaces directly instead of using the
default shims.
This is required since new additions to .hal will no longer be
added to the legacy gralloc1 C header.
Change-Id: If577a14f75d7d13da0ff656c96ab451d21c910ce
diff --git a/sdm/libs/hwc2/Android.mk b/sdm/libs/hwc2/Android.mk
index 04992dc..0e839ce 100644
--- a/sdm/libs/hwc2/Android.mk
+++ b/sdm/libs/hwc2/Android.mk
@@ -18,9 +18,11 @@
LOCAL_CLANG := true
LOCAL_SHARED_LIBRARIES := libsdmcore libqservice libbinder libhardware libhardware_legacy \
- libutils libcutils libsync libqdutils libqdMetaData libdl \
+ libutils libcutils libsync libqdutils libqdMetaData \
libsdmutils libc++ liblog libgrallocutils libui libgpu_tonemapper \
- libhidlbase libhidltransport vendor.display.config@1.0
+ libhidlbase libhidltransport vendor.display.config@1.0 \
+ android.hardware.graphics.mapper@2.0\
+ android.hardware.graphics.allocator@2.0
ifeq ($(display_config_version), DISPLAY_CONFIG_1_1)
LOCAL_SHARED_LIBRARIES += vendor.display.config@1.1
diff --git a/sdm/libs/hwc2/hwc_buffer_allocator.cpp b/sdm/libs/hwc2/hwc_buffer_allocator.cpp
index 84fbd80..4210501 100644
--- a/sdm/libs/hwc2/hwc_buffer_allocator.cpp
+++ b/sdm/libs/hwc2/hwc_buffer_allocator.cpp
@@ -33,75 +33,38 @@
#include <utils/constants.h>
#include <utils/debug.h>
+#include "gr_utils.h"
#include "hwc_buffer_allocator.h"
#include "hwc_debugger.h"
-#include "gr_utils.h"
#define __CLASS__ "HWCBufferAllocator"
+using android::hardware::graphics::common::V1_0::PixelFormat;
+using android::hardware::graphics::mapper::V2_0::BufferDescriptor;
+using android::hardware::graphics::mapper::V2_0::Error;
+using android::hardware::hidl_handle;
+using android::hardware::hidl_vec;
+
namespace sdm {
DisplayError HWCBufferAllocator::Init() {
- int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module_);
- if (err != 0) {
- DLOGE("FATAL: can not get GRALLOC module");
- return kErrorResources;
+ allocator_ = IAllocator::getService();
+ mapper_ = IMapper::getService();
+
+ if (mapper_ == nullptr || allocator_ == nullptr) {
+ DLOGE("Unable to get mapper or allocator");
+ return kErrorCriticalResource;
}
-
- err = gralloc1_open(module_, &gralloc_device_);
- if (err != 0) {
- DLOGE("FATAL: can not open GRALLOC device");
- return kErrorResources;
- }
-
- if (gralloc_device_ == nullptr) {
- DLOGE("FATAL: gralloc device is null");
- return kErrorResources;
- }
-
- CreateBufferDescriptor_ = reinterpret_cast<GRALLOC1_PFN_CREATE_DESCRIPTOR>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_CREATE_DESCRIPTOR));
- DestroyBufferDescriptor_ = reinterpret_cast<GRALLOC1_PFN_DESTROY_DESCRIPTOR>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_DESTROY_DESCRIPTOR));
- AllocateBuffer_ = reinterpret_cast<GRALLOC1_PFN_ALLOCATE>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_ALLOCATE));
- ReleaseBuffer_ = reinterpret_cast<GRALLOC1_PFN_RELEASE>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_RELEASE));
- SetBufferDimensions_ = reinterpret_cast<GRALLOC1_PFN_SET_DIMENSIONS>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_SET_DIMENSIONS));
- SetBufferFormat_ = reinterpret_cast<GRALLOC1_PFN_SET_FORMAT>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_SET_FORMAT));
- SetConsumerUsage_ = reinterpret_cast<GRALLOC1_PFN_SET_CONSUMER_USAGE>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_SET_CONSUMER_USAGE));
- SetProducerUsage_ = reinterpret_cast<GRALLOC1_PFN_SET_PRODUCER_USAGE>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_SET_PRODUCER_USAGE));
- LockBuffer_ = reinterpret_cast<GRALLOC1_PFN_LOCK>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_LOCK));
- UnlockBuffer_ = reinterpret_cast<GRALLOC1_PFN_UNLOCK>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_UNLOCK));
- Perform_ = reinterpret_cast<GRALLOC1_PFN_PERFORM>(
- gralloc_device_->getFunction(gralloc_device_, GRALLOC1_FUNCTION_PERFORM));
-
return kErrorNone;
}
DisplayError HWCBufferAllocator::Deinit() {
- if (gralloc_device_ != nullptr) {
- int err = gralloc1_close(gralloc_device_);
- if (err != 0) {
- DLOGE("FATAL: can not close GRALLOC device");
- return kErrorResources;
- }
- }
return kErrorNone;
}
DisplayError HWCBufferAllocator::AllocateBuffer(BufferInfo *buffer_info) {
- DisplayError sdm_err = kErrorNone;
const BufferConfig &buffer_config = buffer_info->buffer_config;
AllocatedBufferInfo *alloc_buffer_info = &buffer_info->alloc_buffer_info;
- uint32_t width = buffer_config.width;
- uint32_t height = buffer_config.height;
int format;
uint64_t alloc_flags = 0;
int error = SetBufferInfo(buffer_config.format, &format, &alloc_flags);
@@ -110,11 +73,11 @@
}
if (buffer_config.secure) {
- alloc_flags |= GRALLOC1_PRODUCER_USAGE_PROTECTED;
+ alloc_flags |= BufferUsage::PROTECTED;
}
if (buffer_config.secure_camera) {
- alloc_flags |= GRALLOC1_PRODUCER_USAGE_CAMERA;
+ alloc_flags |= BufferUsage::CAMERA_OUTPUT;
}
if (!buffer_config.cache) {
@@ -123,45 +86,51 @@
}
if (buffer_config.gfx_client) {
- alloc_flags |= GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE;
+ alloc_flags |= BufferUsage::GPU_TEXTURE;
}
- gralloc1_producer_usage_t producer_usage = static_cast<gralloc1_producer_usage_t>(alloc_flags);
- gralloc1_consumer_usage_t consumer_usage = static_cast<gralloc1_consumer_usage_t>(alloc_flags |
- GRALLOC1_CONSUMER_USAGE_HWCOMPOSER);
- gralloc1_buffer_descriptor_t descriptor_id = {};
- buffer_handle_t buf = nullptr;
+ alloc_flags |= BufferUsage::COMPOSER_OVERLAY;
+
+ IMapper::BufferDescriptorInfo descriptor_info;
+ descriptor_info.width = buffer_config.width;
+ descriptor_info.height = buffer_config.height;
+ descriptor_info.layerCount = 1;
+ descriptor_info.format = static_cast<PixelFormat>(format);
+ descriptor_info.usage = alloc_flags;
+ auto descriptor = BufferDescriptor();
+ auto hidl_err = Error::NONE;
+
+ mapper_->createDescriptor(descriptor_info, [&](const auto &_error, const auto &_descriptor) {
+ hidl_err = _error;
+ descriptor = _descriptor;
+ });
+ if (hidl_err != Error::NONE) {
+ DLOGE("Failed to create descriptor");
+ return kErrorMemory;
+ }
+
+ hidl_handle raw_handle = nullptr;
private_handle_t *hnd = nullptr;
- // CreateBuffer
- if (CreateBufferDescriptor_(gralloc_device_, &descriptor_id) != GRALLOC1_ERROR_NONE) {
- DLOGE("CreateBufferDescriptor failed gr_device=%p", gralloc_device_);
- return kErrorParameters;
+ allocator_->allocate(descriptor, 1,
+ [&](const auto &_error, const auto &_stride, const auto &_buffers) {
+ hidl_err = _error;
+ raw_handle = _buffers[0];
+ });
+ if (hidl_err != Error::NONE) {
+ DLOGE("Failed to allocate buffer");
+ return kErrorMemory;
}
- if (SetBufferDimensions_(gralloc_device_, descriptor_id, width, height) != GRALLOC1_ERROR_NONE) {
- DLOGE("SetBufferDimensions failed gr_device=%x desc=%d", gralloc_device_, descriptor_id);
- sdm_err = kErrorParameters;
- goto CleanupOnError;
- }
- if (SetBufferFormat_(gralloc_device_, descriptor_id, format) != GRALLOC1_ERROR_NONE) {
- DLOGE("SetBufferFormat failed gr_device=%x desc=%d", gralloc_device_, descriptor_id);
- sdm_err = kErrorParameters;
- goto CleanupOnError;
- }
- if (SetConsumerUsage_(gralloc_device_, descriptor_id, consumer_usage) != GRALLOC1_ERROR_NONE) {
- DLOGE("SetConsumerUsage failed gr_device=%x desc=%d", gralloc_device_, descriptor_id);
- sdm_err = kErrorParameters;
- goto CleanupOnError;
- }
- if (SetProducerUsage_(gralloc_device_, descriptor_id, producer_usage) != GRALLOC1_ERROR_NONE) {
- DLOGE("SetProducerUsage failed gr_device=%x desc=%d", gralloc_device_, descriptor_id);
- sdm_err = kErrorParameters;
- goto CleanupOnError;
- }
- if (AllocateBuffer_(gralloc_device_, 1, &descriptor_id, &buf) != GRALLOC1_ERROR_NONE) {
- DLOGE("AllocateBuffer failed gr_device=%x desc=%d", gralloc_device_, descriptor_id);
- sdm_err = kErrorMemory;
- goto CleanupOnError;
+
+ const native_handle_t *buf = nullptr;
+ mapper_->importBuffer(raw_handle, [&](const auto &_error, const auto &_buffer) {
+ hidl_err = _error;
+ buf = static_cast<const native_handle_t *>(_buffer);
+ });
+
+ if (hidl_err != Error::NONE) {
+ DLOGE("Failed to import buffer into HWC");
+ return kErrorMemory;
}
hnd = (private_handle_t *)buf; // NOLINT
@@ -172,45 +141,45 @@
alloc_buffer_info->size = hnd->size;
buffer_info->private_data = reinterpret_cast<void *>(hnd);
-CleanupOnError:
- DestroyBufferDescriptor_(gralloc_device_, descriptor_id);
- return sdm_err;
+ return kErrorNone;
}
DisplayError HWCBufferAllocator::FreeBuffer(BufferInfo *buffer_info) {
DisplayError err = kErrorNone;
- buffer_handle_t hnd = static_cast<buffer_handle_t>(buffer_info->private_data);
- ReleaseBuffer_(gralloc_device_, hnd);
- AllocatedBufferInfo *alloc_buffer_info = &buffer_info->alloc_buffer_info;
+ auto hnd = reinterpret_cast<void *>(buffer_info->private_data);
+ mapper_->freeBuffer(hnd);
+ AllocatedBufferInfo &alloc_buffer_info = buffer_info->alloc_buffer_info;
- alloc_buffer_info->fd = -1;
- alloc_buffer_info->stride = 0;
- alloc_buffer_info->size = 0;
+ alloc_buffer_info.fd = -1;
+ alloc_buffer_info.stride = 0;
+ alloc_buffer_info.size = 0;
buffer_info->private_data = NULL;
return err;
}
void HWCBufferAllocator::GetCustomWidthAndHeight(const private_handle_t *handle, int *width,
int *height) {
- Perform_(gralloc_device_, GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE, handle,
- width, height);
+ *width = handle->width;
+ *height = handle->height;
+ gralloc::GetCustomDimensions(const_cast<private_handle_t *>(handle), width, height);
}
void HWCBufferAllocator::GetAlignedWidthAndHeight(int width, int height, int format,
uint32_t alloc_type, int *aligned_width,
int *aligned_height) {
- int tile_enabled;
- gralloc1_producer_usage_t producer_usage = GRALLOC1_PRODUCER_USAGE_NONE;
- gralloc1_consumer_usage_t consumer_usage = GRALLOC1_CONSUMER_USAGE_NONE;
+ uint64_t usage = 0;
if (alloc_type & GRALLOC_USAGE_HW_FB) {
- consumer_usage = GRALLOC1_CONSUMER_USAGE_CLIENT_TARGET;
+ usage |= BufferUsage::COMPOSER_CLIENT_TARGET;
}
if (alloc_type & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC) {
- producer_usage = GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
+ usage |= GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
}
-
- Perform_(gralloc_device_, GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES, width, height, format,
- producer_usage, consumer_usage, aligned_width, aligned_height, &tile_enabled);
+ uint32_t aligned_w = UINT(width);
+ uint32_t aligned_h = UINT(height);
+ gralloc::BufferInfo info(width, height, format, usage);
+ gralloc::GetAlignedWidthAndHeight(info, &aligned_w, &aligned_h);
+ *aligned_width = INT(aligned_w);
+ *aligned_height = INT(aligned_h);
}
uint32_t HWCBufferAllocator::GetBufferSize(BufferInfo *buffer_info) {
@@ -235,12 +204,7 @@
}
uint32_t aligned_width = 0, aligned_height = 0, buffer_size = 0;
- gralloc1_producer_usage_t producer_usage = GRALLOC1_PRODUCER_USAGE_NONE;
- gralloc1_consumer_usage_t consumer_usage = GRALLOC1_CONSUMER_USAGE_NONE;
- // TODO(user): Currently both flags are treated similarly in gralloc
- producer_usage = gralloc1_producer_usage_t(alloc_flags);
- consumer_usage = gralloc1_consumer_usage_t(alloc_flags);
- gralloc1::BufferInfo info(width, height, format, producer_usage, consumer_usage);
+ gralloc::BufferInfo info(width, height, format, alloc_flags);
GetBufferSizeAndDimensions(info, &buffer_size, &aligned_width, &aligned_height);
return buffer_size;
}
@@ -394,12 +358,7 @@
}
uint32_t aligned_width = 0, aligned_height = 0, buffer_size = 0;
- gralloc1_producer_usage_t producer_usage = GRALLOC1_PRODUCER_USAGE_NONE;
- gralloc1_consumer_usage_t consumer_usage = GRALLOC1_CONSUMER_USAGE_NONE;
- // TODO(user): Currently both flags are treated similarly in gralloc
- producer_usage = gralloc1_producer_usage_t(alloc_flags);
- consumer_usage = gralloc1_consumer_usage_t(alloc_flags);
- gralloc1::BufferInfo info(width, height, format, producer_usage, consumer_usage);
+ gralloc::BufferInfo info(width, height, format, alloc_flags);
GetBufferSizeAndDimensions(info, &buffer_size, &aligned_width, &aligned_height);
allocated_buffer_info->stride = UINT32(aligned_width);
allocated_buffer_info->aligned_width = UINT32(aligned_width);
@@ -426,7 +385,7 @@
hnd.flags = private_handle_t::PRIV_FLAGS_UBWC_ALIGNED;
}
- int ret = gralloc1::GetBufferLayout(&hnd, stride, offset, num_planes);
+ int ret = gralloc::GetBufferLayout(&hnd, stride, offset, num_planes);
if (ret < 0) {
DLOGE("GetBufferLayout failed");
return kErrorParameters;
@@ -436,24 +395,42 @@
}
DisplayError HWCBufferAllocator::MapBuffer(const private_handle_t *handle, int acquire_fence) {
- void* buffer_ptr = NULL;
- const gralloc1_rect_t accessRegion = {
- .left = 0,
- .top = 0,
- .width = 0,
- .height = 0
- };
- LockBuffer_(gralloc_device_, handle, GRALLOC1_PRODUCER_USAGE_CPU_READ,
- GRALLOC1_CONSUMER_USAGE_NONE, &accessRegion, &buffer_ptr, acquire_fence);
+ void *buffer_ptr = NULL;
+ const IMapper::Rect access_region = {.left = 0, .top = 0, .width = 0, .height = 0};
+
+ NATIVE_HANDLE_DECLARE_STORAGE(acquire_fence_storage, 1, 0);
+ hidl_handle acquire_fence_handle;
+ if (acquire_fence >= 0) {
+ auto h = native_handle_init(acquire_fence_storage, 1, 0);
+ h->data[0] = acquire_fence;
+ acquire_fence_handle = h;
+ }
+
+ auto hnd = const_cast<private_handle_t *>(handle);
+ mapper_->lock(reinterpret_cast<void *>(hnd), (uint64_t)BufferUsage::CPU_READ_OFTEN,
+ access_region, acquire_fence_handle, [&](const auto &_error, const auto &_buffer) {
+ if (_error == Error::NONE) {
+ buffer_ptr = _buffer;
+ }
+ });
+
if (!buffer_ptr) {
return kErrorUndefined;
}
-
return kErrorNone;
}
-DisplayError HWCBufferAllocator::UnmapBuffer(const private_handle_t *handle, int* release_fence) {
- return (DisplayError)(UnlockBuffer_(gralloc_device_, handle, release_fence));
+DisplayError HWCBufferAllocator::UnmapBuffer(const private_handle_t *handle, int *release_fence) {
+ DisplayError err = kErrorNone;
+ *release_fence = -1;
+ auto hnd = const_cast<private_handle_t *>(handle);
+ mapper_->unlock(reinterpret_cast<void *>(hnd),
+ [&](const auto &_error, const auto &_release_fence) {
+ if (_error != Error::NONE) {
+ err = kErrorUndefined;
+ }
+ });
+ return err;
}
} // namespace sdm
diff --git a/sdm/libs/hwc2/hwc_buffer_allocator.h b/sdm/libs/hwc2/hwc_buffer_allocator.h
index 7df88a4..2846b89 100644
--- a/sdm/libs/hwc2/hwc_buffer_allocator.h
+++ b/sdm/libs/hwc2/hwc_buffer_allocator.h
@@ -1,41 +1,44 @@
/*
-* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are
-* met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above
-* copyright notice, this list of conditions and the following
-* disclaimer in the documentation and/or other materials provided
-* with the distribution.
-* * Neither the name of The Linux Foundation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-#ifdef USE_GRALLOC1
+ * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#ifndef __HWC_BUFFER_ALLOCATOR_H__
#define __HWC_BUFFER_ALLOCATOR_H__
#include <fcntl.h>
#include <sys/mman.h>
-#include <hardware/gralloc1.h>
+#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
+#include <android/hardware/graphics/mapper/2.0/IMapper.h>
#include "gralloc_priv.h"
+using android::hardware::graphics::allocator::V2_0::IAllocator;
+using android::hardware::graphics::mapper::V2_0::IMapper;
+
namespace sdm {
template <class Type>
@@ -56,32 +59,16 @@
int *aligned_width, int *aligned_height);
DisplayError GetAllocatedBufferInfo(const BufferConfig &buffer_config,
AllocatedBufferInfo *allocated_buffer_info);
- DisplayError GetBufferLayout(const AllocatedBufferInfo &buf_info,
- uint32_t stride[4], uint32_t offset[4],
- uint32_t *num_planes);
+ DisplayError GetBufferLayout(const AllocatedBufferInfo &buf_info, uint32_t stride[4],
+ uint32_t offset[4], uint32_t *num_planes);
int SetBufferInfo(LayerBufferFormat format, int *target, uint64_t *flags);
DisplayError MapBuffer(const private_handle_t *handle, int acquire_fence);
- DisplayError UnmapBuffer(const private_handle_t *handle, int* release_fence);
+ DisplayError UnmapBuffer(const private_handle_t *handle, int *release_fence);
private:
- gralloc1_device_t *gralloc_device_ = nullptr;
- const hw_module_t *module_ = nullptr;
- GRALLOC1_PFN_CREATE_DESCRIPTOR CreateBufferDescriptor_ = nullptr;
- GRALLOC1_PFN_DESTROY_DESCRIPTOR DestroyBufferDescriptor_ = nullptr;
- GRALLOC1_PFN_ALLOCATE AllocateBuffer_ = nullptr;
- GRALLOC1_PFN_RELEASE ReleaseBuffer_ = nullptr;
- GRALLOC1_PFN_SET_DIMENSIONS SetBufferDimensions_ = nullptr;
- GRALLOC1_PFN_SET_FORMAT SetBufferFormat_ = nullptr;
- GRALLOC1_PFN_SET_CONSUMER_USAGE SetConsumerUsage_ = nullptr;
- GRALLOC1_PFN_SET_PRODUCER_USAGE SetProducerUsage_ = nullptr;
- GRALLOC1_PFN_LOCK LockBuffer_ = nullptr;
- GRALLOC1_PFN_UNLOCK UnlockBuffer_ = nullptr;
- GRALLOC1_PFN_PERFORM Perform_ = nullptr;
+ android::sp<IMapper> mapper_;
+ android::sp<IAllocator> allocator_;
};
} // namespace sdm
#endif // __HWC_BUFFER_ALLOCATOR_H__
-#else
-#include "../hwc/hwc_buffer_allocator.h"
-#endif // __HWC_BUFFER_ALLOCATOR_H__
-
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index e42ed41..91e47ef 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -42,10 +42,6 @@
#include "hwc_tonemapper.h"
#include "hwc_session.h"
-#ifndef USE_GRALLOC1
-#include <gr.h>
-#endif
-
#ifdef QTI_BSP
#include <hardware/display_defs.h>
#endif
@@ -547,11 +543,7 @@
const private_handle_t *handle =
reinterpret_cast<const private_handle_t *>(layer->input_buffer.buffer_id);
if (handle) {
-#ifdef USE_GRALLOC1
if (handle->buffer_type == BUFFER_TYPE_VIDEO) {
-#else
- if (handle->bufferType == BUFFER_TYPE_VIDEO) {
-#endif
layer_stack_.flags.video_present = true;
}
// TZ Protected Buffer - L1
@@ -1724,13 +1716,8 @@
flags |= private_handle_t::PRIV_FLAGS_UBWC_ALIGNED;
}
-#ifdef USE_GRALLOC1
buffer_allocator_->GetAlignedWidthAndHeight(INT(x_pixels), INT(y_pixels), format, usage,
&aligned_width, &aligned_height);
-#else
- AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(INT(x_pixels), INT(y_pixels), format,
- INT(usage), aligned_width, aligned_height);
-#endif
// TODO(user): How does the dirty region get set on the client target? File bug on Google
client_target_layer->composition = kCompositionGPUTarget;
diff --git a/sdm/libs/hwc2/hwc_display_virtual.cpp b/sdm/libs/hwc2/hwc_display_virtual.cpp
index e1949ba..11193bb 100644
--- a/sdm/libs/hwc2/hwc_display_virtual.cpp
+++ b/sdm/libs/hwc2/hwc_display_virtual.cpp
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,9 +31,6 @@
#include <utils/debug.h>
#include <sync/sync.h>
#include <stdarg.h>
-#ifndef USE_GRALLOC1
-#include <gr.h>
-#endif
#include "hwc_display_virtual.h"
#include "hwc_debugger.h"
diff --git a/sdm/libs/hwc2/hwc_layers.cpp b/sdm/libs/hwc2/hwc_layers.cpp
index 0f860d8..96e7499 100644
--- a/sdm/libs/hwc2/hwc_layers.cpp
+++ b/sdm/libs/hwc2/hwc_layers.cpp
@@ -17,16 +17,12 @@
* limitations under the License.
*/
+#include "hwc_layers.h"
+#include <utils/debug.h>
#include <stdint.h>
#include <utility>
-#include <qdMetaData.h>
-
-#include "hwc_layers.h"
-#ifndef USE_GRALLOC1
-#include <gr.h>
-#endif
-#include <utils/debug.h>
#include <cmath>
+#include <qdMetaData.h>
#define __CLASS__ "HWCLayer"
@@ -220,11 +216,7 @@
LayerBuffer *layer_buffer = &layer_->input_buffer;
int aligned_width, aligned_height;
-#ifdef USE_GRALLOC1
buffer_allocator_->GetCustomWidthAndHeight(handle, &aligned_width, &aligned_height);
-#else
- AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(handle, aligned_width, aligned_height);
-#endif
LayerBufferFormat format = GetSDMFormat(handle->format, handle->flags);
if ((format != layer_buffer->format) || (UINT32(aligned_width) != layer_buffer->width) ||