gralloc: Add QtiMapperExtensions
This change moves extensions to QtiMapperExtensions to decouple
it from IMapper revisions. The function
QtiMapper::getMapperExtensions() is used to access the extensions
through a mapper instance. QtiMapper revision is incremented to
2.0 to reflect the change.
CRs-Fixed: 2451975
Change-Id: I7043bd380e9b7b3ea8d9bac4da3e886a5d46b631
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 6031a32..7dc2de6 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -35,3 +35,6 @@
#Clean display includes
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/include/qcom/display)
+
+# Clean old allocator rc file
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/vendor.qti.hardware.display.allocator@1.0-service.rc)
diff --git a/config/display-product.mk b/config/display-product.mk
index 9c9703a..5378cc8 100644
--- a/config/display-product.mk
+++ b/config/display-product.mk
@@ -3,7 +3,7 @@
android.hardware.graphics.composer@2.3-impl \
android.hardware.graphics.composer@2.3-service \
android.hardware.graphics.mapper@2.0-impl-qti-display \
- vendor.qti.hardware.display.allocator@1.0-service \
+ vendor.qti.hardware.display.allocator-service \
android.hardware.memtrack@1.0-impl \
android.hardware.memtrack@1.0-service \
android.hardware.light@2.0-impl \
diff --git a/gralloc/Android.mk b/gralloc/Android.mk
index 0955f56..6603f43 100644
--- a/gralloc/Android.mk
+++ b/gralloc/Android.mk
@@ -53,20 +53,6 @@
LOCAL_SRC_FILES := gr_allocator.cpp gr_buf_mgr.cpp gr_ion_alloc.cpp
include $(BUILD_SHARED_LIBRARY)
-#Get the display mapper version available
-qti_mapper1_1_version := $(shell \
- if [ -d "$(TOP)/vendor/qcom/opensource/interfaces/display/mapper/1.1" ];\
- then echo QTI_MAPPER_1_1; fi)
-
-qti_mapper_version := $(shell \
- if [ -d "$(TOP)/vendor/qcom/opensource/interfaces/display/mapper/1.0" ];\
- then echo QTI_MAPPER_1_0; fi)
-
-qti_allocator_version := $(shell \
- if [ -d "$(TOP)/vendor/qcom/opensource/interfaces/display/allocator/1.0" ];\
- then echo QTI_ALLOCATOR_1_0; fi)
-
-ifeq ($(qti_mapper_version), QTI_MAPPER_1_0)
#mapper
include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.graphics.mapper@2.0-impl-qti-display
@@ -82,23 +68,18 @@
libgrallocutils \
libgralloccore \
libsync \
- vendor.qti.hardware.display.mapper@1.0 \
+ vendor.qti.hardware.display.mapper@2.0 \
+ vendor.qti.hardware.display.mapperextensions@1.0 \
android.hardware.graphics.mapper@2.0 \
android.hardware.graphics.mapper@2.1
LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdgralloc\" -Wno-sign-conversion
-ifeq ($(qti_mapper1_1_version), QTI_MAPPER_1_1)
-LOCAL_SHARED_LIBRARIES += vendor.qti.hardware.display.mapper@1.1
-LOCAL_CFLAGS += -DQTI_MAPPER_1_1
-endif
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
-LOCAL_SRC_FILES := QtiMapper.cpp
+LOCAL_SRC_FILES := QtiMapper.cpp QtiMapperExtensions.cpp
include $(BUILD_SHARED_LIBRARY)
-endif
-ifeq ($(qti_allocator_version), QTI_ALLOCATOR_1_0)
#allocator
include $(CLEAR_VARS)
-LOCAL_MODULE := vendor.qti.hardware.display.allocator@1.0-service
+LOCAL_MODULE := vendor.qti.hardware.display.allocator-service
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_TAGS := optional
@@ -116,6 +97,5 @@
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
LOCAL_C_INCLUDES := $(common_includes) $(kernel_includes)
LOCAL_SRC_FILES := QtiAllocator.cpp service.cpp
-LOCAL_INIT_RC := vendor.qti.hardware.display.allocator@1.0-service.rc
+LOCAL_INIT_RC := vendor.qti.hardware.display.allocator-service.rc
include $(BUILD_EXECUTABLE)
-endif
diff --git a/gralloc/QtiMapper.cpp b/gralloc/QtiMapper.cpp
index dba446a..f040143 100644
--- a/gralloc/QtiMapper.cpp
+++ b/gralloc/QtiMapper.cpp
@@ -45,6 +45,7 @@
using gralloc::BufferInfo;
QtiMapper::QtiMapper() {
+ extensions_ = new QtiMapperExtensions();
buf_mgr_ = BufferManager::GetInstance();
ALOGD_IF(DEBUG, "Created QtiMapper instance");
}
@@ -263,281 +264,15 @@
return Void();
}
-Return<void> QtiMapper::getMapSecureBufferFlag(void *buffer, getMapSecureBufferFlag_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- auto hnd = static_cast<private_handle_t *>(buffer);
- int map_secure_buffer = 0;
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- if (getMetaData(hnd, GET_MAP_SECURE_BUFFER, &map_secure_buffer) != 0) {
- map_secure_buffer = 0;
- } else {
- err = Error::NONE;
- }
+Return<void> QtiMapper::getMapperExtensions(QtiMapper::getMapperExtensions_cb hidl_cb) {
+ if (extensions_ != nullptr) {
+ hidl_cb(Error::NONE, extensions_);
+ } else {
+ hidl_cb(Error::UNSUPPORTED, extensions_);
}
- hidl_cb(err, map_secure_buffer != 0);
return Void();
}
-Return<void> QtiMapper::getInterlacedFlag(void *buffer, getInterlacedFlag_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- auto hnd = static_cast<private_handle_t *>(buffer);
- int interlaced_flag = 0;
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- if (getMetaData(hnd, GET_PP_PARAM_INTERLACED, &interlaced_flag) != 0) {
- interlaced_flag = 0;
- } else {
- err = Error::NONE;
- }
- }
- hidl_cb(err, interlaced_flag != 0);
- return Void();
-}
-
-Return<void> QtiMapper::getCustomDimensions(void *buffer, getCustomDimensions_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- auto hnd = static_cast<private_handle_t *>(buffer);
- int stride = 0;
- int height = 0;
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- stride = hnd->width;
- height = hnd->height;
- gralloc::GetCustomDimensions(hnd, &stride, &height);
- err = Error::NONE;
- }
- hidl_cb(err, stride, height);
- return Void();
-}
-
-Return<void> QtiMapper::getRgbDataAddress(void *buffer, getRgbDataAddress_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- auto hnd = static_cast<private_handle_t *>(buffer);
- void *rgb_data = nullptr;
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- if (gralloc::GetRgbDataAddress(hnd, &rgb_data) == 0) {
- err = Error::NONE;
- }
- }
- hidl_cb(err, rgb_data);
- return Void();
-}
-
-Return<void> QtiMapper::calculateBufferAttributes(int32_t width, int32_t height, int32_t format,
- uint64_t usage,
- calculateBufferAttributes_cb hidl_cb) {
- unsigned int alignedw, alignedh;
- BufferInfo info(width, height, format, usage);
- gralloc::GetAlignedWidthAndHeight(info, &alignedw, &alignedh);
- bool ubwc_enabled = gralloc::IsUBwcEnabled(format, usage);
- hidl_cb(Error::NONE, alignedw, alignedh, ubwc_enabled);
- return Void();
-}
-
-Return<void> QtiMapper::getCustomFormatFlags(int32_t format, uint64_t usage,
- getCustomFormatFlags_cb hidl_cb) {
- uint64_t priv_flags = 0;
- auto err = Error::NONE;
- int32_t custom_format = format;
- if (gralloc::GetCustomFormatFlags(format, usage, &custom_format, &priv_flags) != 0) {
- err = Error::UNSUPPORTED;
- }
- hidl_cb(err, custom_format, priv_flags);
- return Void();
-}
-
-Return<void> QtiMapper::getColorSpace(void *buffer, getColorSpace_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- auto hnd = static_cast<private_handle_t *>(buffer);
- int color_space = 0;
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- gralloc::GetColorSpaceFromMetadata(hnd, &color_space);
- err = Error::NONE;
- }
- hidl_cb(err, color_space);
- return Void();
-}
-
-Return<void> QtiMapper::getYuvPlaneInfo(void *buffer, getYuvPlaneInfo_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- auto hnd = static_cast<private_handle_t *>(buffer);
- hidl_vec<YCbCrLayout> layout;
- layout.resize(2);
- android_ycbcr yuv_plane_info[2];
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- if (gralloc::GetYUVPlaneInfo(hnd, yuv_plane_info) == 0) {
- err = Error::NONE;
- for (int i=0; i < 2; i++) {
- layout[i].y = yuv_plane_info[i].y;
- layout[i].cr = yuv_plane_info[i].cr;
- layout[i].cb = yuv_plane_info[i].cb;
- layout[i].yStride = static_cast<uint32_t>(yuv_plane_info[i].ystride);
- layout[i].cStride = static_cast<uint32_t>(yuv_plane_info[i].cstride);
- layout[i].chromaStep = static_cast<uint32_t>(yuv_plane_info[i].chroma_step);
- }
- }
- }
- hidl_cb(err, layout);
- return Void();
-}
-
-Return<Error> QtiMapper::setSingleBufferMode(void *buffer, bool enable) {
- auto err = Error::BAD_BUFFER;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- if (setMetaData(hnd, SET_SINGLE_BUFFER_MODE, &enable) != 0) {
- err = Error::UNSUPPORTED;
- } else {
- err = Error::NONE;
- }
- }
- return err;
-}
-
-#ifdef QTI_MAPPER_1_1
-Return<void> QtiMapper::getFd(void *buffer, getFd_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- int fd = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- fd = hnd->fd;
- }
- hidl_cb(err, fd);
- return Void();
-}
-
-Return<void> QtiMapper::getWidth(void *buffer, getWidth_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- int width = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- width = hnd->width;
- }
- hidl_cb(err, width);
- return Void();
-}
-
-Return<void> QtiMapper::getHeight(void *buffer, getHeight_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- int height = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- height = hnd->height;
- }
- hidl_cb(err, height);
- return Void();
-}
-
-Return<void> QtiMapper::getFormat(void *buffer, getFormat_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- int format = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- format = hnd->format;
- }
- hidl_cb(err, format);
- return Void();
-}
-
-Return<void> QtiMapper::getPrivateFlags(void *buffer, getPrivateFlags_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- int flags = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- flags = hnd->flags;
- }
- hidl_cb(err, flags);
- return Void();
-}
-
-Return<void> QtiMapper::getUnalignedWidth(void *buffer, getUnalignedWidth_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- int unaligned_width = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- unaligned_width = hnd->unaligned_width;
- }
- hidl_cb(err, unaligned_width);
- return Void();
-}
-
-Return<void> QtiMapper::getUnalignedHeight(void *buffer, getUnalignedHeight_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- int unaligned_height = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- unaligned_height = hnd->unaligned_height;
- }
- hidl_cb(err, unaligned_height);
- return Void();
-}
-
-Return<void> QtiMapper::getLayerCount(void *buffer, getLayerCount_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- unsigned int layer_count = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- layer_count = hnd->layer_count;
- }
- hidl_cb(err, layer_count);
- return Void();
-}
-
-Return<void> QtiMapper::getId(void *buffer, getId_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- uint64_t id = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- id = hnd->id;
- }
- hidl_cb(err, id);
- return Void();
-}
-
-Return<void> QtiMapper::getUsageFlags(void *buffer, getUsageFlags_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- uint64_t usage = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- usage = hnd->usage;
- }
- hidl_cb(err, usage);
- return Void();
-}
-
-Return<void> QtiMapper::getSize(void *buffer, getSize_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- unsigned int size = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- size = hnd->size;
- }
- hidl_cb(err, size);
- return Void();
-}
-
-Return<void> QtiMapper::getOffset(void *buffer, getOffset_cb hidl_cb) {
- auto err = Error::BAD_BUFFER;
- unsigned int offset = 0;
- auto hnd = static_cast<private_handle_t *>(buffer);
- if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
- err = Error::NONE;
- offset = hnd->offset;
- }
- hidl_cb(err, offset);
- return Void();
-}
-#endif
-
// Methods from ::android::hidl::base::V1_0::IBase follow.
// When we are in passthrough mode, this method is used
diff --git a/gralloc/QtiMapper.h b/gralloc/QtiMapper.h
index a17870c..eca74f0 100644
--- a/gralloc/QtiMapper.h
+++ b/gralloc/QtiMapper.h
@@ -32,12 +32,9 @@
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
-#ifdef QTI_MAPPER_1_1
-#include <vendor/qti/hardware/display/mapper/1.1/IQtiMapper.h>
-#else
-#include <vendor/qti/hardware/display/mapper/1.0/IQtiMapper.h>
-#endif
+#include <vendor/qti/hardware/display/mapper/2.0/IQtiMapper.h>
+#include "QtiMapperExtensions.h"
#include "gr_buf_mgr.h"
namespace vendor {
namespace qti {
@@ -46,26 +43,24 @@
namespace mapper {
namespace implementation {
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::graphics::mapper::V2_0::IMapper;
-using ::android::hardware::graphics::mapper::V2_0::Error;
-using ::android::hardware::graphics::mapper::V2_0::YCbCrLayout;
-using ::android::hardware::graphics::common::V1_1::PixelFormat;
+using ::android::sp;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_handle;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::graphics::common::V1_1::PixelFormat;
+using ::android::hardware::graphics::mapper::V2_0::Error;
+using ::android::hardware::graphics::mapper::V2_0::IMapper;
+using ::android::hardware::graphics::mapper::V2_0::YCbCrLayout;
using ::android::hidl::base::V1_0::DebugInfo;
using ::android::hidl::base::V1_0::IBase;
-using ::android::sp;
-#ifdef QTI_MAPPER_1_1
-using ::vendor::qti::hardware::display::mapper::V1_1::IQtiMapper;
-#else
-using ::vendor::qti::hardware::display::mapper::V1_0::IQtiMapper;
-#endif
using gralloc::BufferManager;
+using ::vendor::qti::hardware::display::mapper::V2_0::IQtiMapper;
+using ::vendor::qti::hardware::display::mapperextensions::V1_0::IQtiMapperExtensions;
+using ::vendor::qti::hardware::display::mapperextensions::V1_0::implementation::QtiMapperExtensions;
using IMapper_2_1 = android::hardware::graphics::mapper::V2_1::IMapper;
using BufferDescriptorInfo_2_0 =
@@ -95,34 +90,9 @@
Return<void> getTransportSize(void* buffer, IMapper_2_1::getTransportSize_cb hidl_cb) override;
Return<void> createDescriptor_2_1(const BufferDescriptorInfo_2_1& descriptorInfo,
createDescriptor_2_1_cb _hidl_cb) override;
- Return<void> getMapSecureBufferFlag(void *buffer, getMapSecureBufferFlag_cb _hidl_cb) override;
- Return<void> getInterlacedFlag(void *buffer, getInterlacedFlag_cb _hidl_cb) override;
- Return<void> getCustomDimensions(void *buffer, getCustomDimensions_cb _hidl_cb) override;
- Return<void> getRgbDataAddress(void *buffer, getRgbDataAddress_cb _hidl_cb) override;
- Return<void> calculateBufferAttributes(int32_t width, int32_t height, int32_t format,
- uint64_t usage,
- calculateBufferAttributes_cb _hidl_cb) override;
- Return<void> getCustomFormatFlags(int32_t format, uint64_t usage,
- getCustomFormatFlags_cb _hidl_cb) override;
- Return<void> getColorSpace(void *buffer, getColorSpace_cb _hidl_cb) override;
- Return<void> getYuvPlaneInfo(void *buffer, getYuvPlaneInfo_cb _hidl_cb) override;
- Return<Error> setSingleBufferMode(void *buffer, bool enable) override;
-#ifdef QTI_MAPPER_1_1
- // Getters for fields present in private handle structure.
- Return<void> getFd(void *buffer, getFd_cb _hidl_cb) override;
- Return<void> getWidth(void *buffer, getWidth_cb _hidl_cb) override;
- Return<void> getHeight(void *buffer, getHeight_cb _hidl_cb) override;
- Return<void> getOffset(void *buffer, getOffset_cb _hidl_cb) override;
- Return<void> getSize(void *buffer, getSize_cb _hidl_cb) override;
- Return<void> getFormat(void *buffer, getFormat_cb _hidl_cb) override;
- Return<void> getPrivateFlags(void *buffer, getPrivateFlags_cb _hidl_cb) override;
- Return<void> getUnalignedWidth(void *buffer, getUnalignedWidth_cb _hidl_cb) override;
- Return<void> getUnalignedHeight(void *buffer, getUnalignedHeight_cb _hidl_cb) override;
- Return<void> getLayerCount(void *buffer, getLayerCount_cb _hidl_cb) override;
- Return<void> getId(void *buffer, getId_cb _hidl_cb) override;
- Return<void> getUsageFlags(void *buffer, getUsageFlags_cb _hidl_cb) override;
-#endif
+ Return<void> getMapperExtensions(getMapperExtensions_cb hidl_cb);
+ sp<mapperextensions::V1_0::IQtiMapperExtensions> extensions_ = nullptr;
private:
BufferManager *buf_mgr_ = nullptr;
diff --git a/gralloc/QtiMapperExtensions.cpp b/gralloc/QtiMapperExtensions.cpp
new file mode 100644
index 0000000..8b6f4c9
--- /dev/null
+++ b/gralloc/QtiMapperExtensions.cpp
@@ -0,0 +1,348 @@
+/*
+ * Copyright (c) 2019 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.
+ */
+
+#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL)
+#define DEBUG 0
+#include "QtiMapperExtensions.h"
+#include <cutils/trace.h>
+#include <qdMetaData.h>
+#include <sync/sync.h>
+#include "gr_utils.h"
+
+namespace vendor {
+namespace qti {
+namespace hardware {
+namespace display {
+namespace mapperextensions {
+namespace V1_0 {
+namespace implementation {
+
+using gralloc::BufferInfo;
+
+QtiMapperExtensions::QtiMapperExtensions() {}
+
+Return<void> QtiMapperExtensions::getMapSecureBufferFlag(void *buffer,
+ getMapSecureBufferFlag_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ int map_secure_buffer = 0;
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ if (getMetaData(hnd, GET_MAP_SECURE_BUFFER, &map_secure_buffer) != 0) {
+ map_secure_buffer = 0;
+ } else {
+ err = Error::NONE;
+ }
+ }
+ hidl_cb(err, map_secure_buffer != 0);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getInterlacedFlag(void *buffer, getInterlacedFlag_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ int interlaced_flag = 0;
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ if (getMetaData(hnd, GET_PP_PARAM_INTERLACED, &interlaced_flag) != 0) {
+ interlaced_flag = 0;
+ } else {
+ err = Error::NONE;
+ }
+ }
+ hidl_cb(err, interlaced_flag != 0);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getCustomDimensions(void *buffer,
+ getCustomDimensions_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ int stride = 0;
+ int height = 0;
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ stride = hnd->width;
+ height = hnd->height;
+ gralloc::GetCustomDimensions(hnd, &stride, &height);
+ err = Error::NONE;
+ }
+ hidl_cb(err, stride, height);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getRgbDataAddress(void *buffer, getRgbDataAddress_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ void *rgb_data = nullptr;
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ if (gralloc::GetRgbDataAddress(hnd, &rgb_data) == 0) {
+ err = Error::NONE;
+ }
+ }
+ hidl_cb(err, rgb_data);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::calculateBufferAttributes(int32_t width, int32_t height,
+ int32_t format, uint64_t usage,
+ calculateBufferAttributes_cb hidl_cb) {
+ unsigned int alignedw, alignedh;
+ BufferInfo info(width, height, format, usage);
+ gralloc::GetAlignedWidthAndHeight(info, &alignedw, &alignedh);
+ bool ubwc_enabled = gralloc::IsUBwcEnabled(format, usage);
+ hidl_cb(Error::NONE, alignedw, alignedh, ubwc_enabled);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getCustomFormatFlags(int32_t format, uint64_t usage,
+ getCustomFormatFlags_cb hidl_cb) {
+ uint64_t priv_flags = 0;
+ auto err = Error::NONE;
+ int32_t custom_format = format;
+ if (gralloc::GetCustomFormatFlags(format, usage, &custom_format, &priv_flags) != 0) {
+ err = Error::UNSUPPORTED;
+ }
+ hidl_cb(err, custom_format, priv_flags);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getColorSpace(void *buffer, getColorSpace_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ int color_space = 0;
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ gralloc::GetColorSpaceFromMetadata(hnd, &color_space);
+ err = Error::NONE;
+ }
+ hidl_cb(err, color_space);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getYuvPlaneInfo(void *buffer, getYuvPlaneInfo_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ hidl_vec<YCbCrLayout> layout;
+ layout.resize(2);
+ android_ycbcr yuv_plane_info[2];
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ if (gralloc::GetYUVPlaneInfo(hnd, yuv_plane_info) == 0) {
+ err = Error::NONE;
+ for (int i = 0; i < 2; i++) {
+ layout[i].y = yuv_plane_info[i].y;
+ layout[i].cr = yuv_plane_info[i].cr;
+ layout[i].cb = yuv_plane_info[i].cb;
+ layout[i].yStride = static_cast<uint32_t>(yuv_plane_info[i].ystride);
+ layout[i].cStride = static_cast<uint32_t>(yuv_plane_info[i].cstride);
+ layout[i].chromaStep = static_cast<uint32_t>(yuv_plane_info[i].chroma_step);
+ }
+ }
+ }
+ hidl_cb(err, layout);
+ return Void();
+}
+
+Return<Error> QtiMapperExtensions::setSingleBufferMode(void *buffer, bool enable) {
+ auto err = Error::BAD_BUFFER;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ if (setMetaData(hnd, SET_SINGLE_BUFFER_MODE, &enable) != 0) {
+ err = Error::UNSUPPORTED;
+ } else {
+ err = Error::NONE;
+ }
+ }
+ return err;
+}
+
+Return<void> QtiMapperExtensions::getFd(void *buffer, getFd_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ int fd = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ fd = hnd->fd;
+ }
+ hidl_cb(err, fd);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getWidth(void *buffer, getWidth_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ int width = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ width = hnd->width;
+ }
+ hidl_cb(err, width);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getHeight(void *buffer, getHeight_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ int height = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ height = hnd->height;
+ }
+ hidl_cb(err, height);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getFormat(void *buffer, getFormat_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ int format = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ format = hnd->format;
+ }
+ hidl_cb(err, format);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getPrivateFlags(void *buffer, getPrivateFlags_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ int flags = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ flags = hnd->flags;
+ }
+ hidl_cb(err, flags);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getUnalignedWidth(void *buffer, getUnalignedWidth_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ int unaligned_width = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ unaligned_width = hnd->unaligned_width;
+ }
+ hidl_cb(err, unaligned_width);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getUnalignedHeight(void *buffer, getUnalignedHeight_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ int unaligned_height = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ unaligned_height = hnd->unaligned_height;
+ }
+ hidl_cb(err, unaligned_height);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getLayerCount(void *buffer, getLayerCount_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ unsigned int layer_count = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ layer_count = hnd->layer_count;
+ }
+ hidl_cb(err, layer_count);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getId(void *buffer, getId_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ uint64_t id = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ id = hnd->id;
+ }
+ hidl_cb(err, id);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getUsageFlags(void *buffer, getUsageFlags_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ uint64_t usage = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ usage = hnd->usage;
+ }
+ hidl_cb(err, usage);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getSize(void *buffer, getSize_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ unsigned int size = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ size = hnd->size;
+ }
+ hidl_cb(err, size);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getOffset(void *buffer, getOffset_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ unsigned int offset = 0;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ err = Error::NONE;
+ offset = hnd->offset;
+ }
+ hidl_cb(err, offset);
+ return Void();
+}
+
+Return<void> QtiMapperExtensions::getSurfaceMetadata(void *buffer, getSurfaceMetadata_cb hidl_cb) {
+ auto err = Error::BAD_BUFFER;
+ auto hnd = static_cast<private_handle_t *>(buffer);
+ GraphicsMetadata surface_metadata;
+ if (buffer != nullptr && private_handle_t::validate(hnd) == 0) {
+ if (getMetaData(hnd, GET_GRAPHICS_METADATA, &surface_metadata) == 0) {
+ err = Error::NONE;
+ }
+ }
+ if (err != Error::NONE) {
+ hidl_cb(err, nullptr);
+ } else {
+ hidl_cb(err, &surface_metadata);
+ }
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace mapperextensions
+} // namespace display
+} // namespace hardware
+} // namespace qti
+} // namespace vendor
diff --git a/gralloc/QtiMapperExtensions.h b/gralloc/QtiMapperExtensions.h
new file mode 100644
index 0000000..45bb93e
--- /dev/null
+++ b/gralloc/QtiMapperExtensions.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2019 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 __QTIMAPPEREXTENSIONS_H__
+#define __QTIMAPPEREXTENSIONS_H__
+
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+#include <vendor/qti/hardware/display/mapperextensions/1.0/IQtiMapperExtensions.h>
+
+#include "gr_buf_mgr.h"
+namespace vendor {
+namespace qti {
+namespace hardware {
+namespace display {
+namespace mapperextensions {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::sp;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_handle;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::graphics::common::V1_1::PixelFormat;
+using ::android::hardware::graphics::mapper::V2_0::IMapper;
+using ::android::hidl::base::V1_0::DebugInfo;
+using ::android::hidl::base::V1_0::IBase;
+using gralloc::BufferManager;
+using ::vendor::qti::hardware::display::mapperextensions::V1_0::IQtiMapperExtensions;
+
+class QtiMapperExtensions : public IQtiMapperExtensions {
+ public:
+ QtiMapperExtensions();
+ Return<void> getMapSecureBufferFlag(void *buffer, getMapSecureBufferFlag_cb _hidl_cb) override;
+ Return<void> getInterlacedFlag(void *buffer, getInterlacedFlag_cb _hidl_cb) override;
+ Return<void> getCustomDimensions(void *buffer, getCustomDimensions_cb _hidl_cb) override;
+ Return<void> getRgbDataAddress(void *buffer, getRgbDataAddress_cb _hidl_cb) override;
+ Return<void> calculateBufferAttributes(int32_t width, int32_t height, int32_t format,
+ uint64_t usage,
+ calculateBufferAttributes_cb _hidl_cb) override;
+ Return<void> getCustomFormatFlags(int32_t format, uint64_t usage,
+ getCustomFormatFlags_cb _hidl_cb) override;
+ Return<void> getColorSpace(void *buffer, getColorSpace_cb _hidl_cb) override;
+ Return<void> getYuvPlaneInfo(void *buffer, getYuvPlaneInfo_cb _hidl_cb) override;
+ Return<Error> setSingleBufferMode(void *buffer, bool enable) override;
+ Return<void> getFd(void *buffer, getFd_cb _hidl_cb) override;
+ Return<void> getWidth(void *buffer, getWidth_cb _hidl_cb) override;
+ Return<void> getHeight(void *buffer, getHeight_cb _hidl_cb) override;
+ Return<void> getOffset(void *buffer, getOffset_cb _hidl_cb) override;
+ Return<void> getSize(void *buffer, getSize_cb _hidl_cb) override;
+ Return<void> getFormat(void *buffer, getFormat_cb _hidl_cb) override;
+ Return<void> getPrivateFlags(void *buffer, getPrivateFlags_cb _hidl_cb) override;
+ Return<void> getUnalignedWidth(void *buffer, getUnalignedWidth_cb _hidl_cb) override;
+ Return<void> getUnalignedHeight(void *buffer, getUnalignedHeight_cb _hidl_cb) override;
+ Return<void> getLayerCount(void *buffer, getLayerCount_cb _hidl_cb) override;
+ Return<void> getId(void *buffer, getId_cb _hidl_cb) override;
+ Return<void> getUsageFlags(void *buffer, getUsageFlags_cb _hidl_cb) override;
+ Return<void> getSurfaceMetadata(void *buffer, getSurfaceMetadata_cb _hidl_cb) override;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace mapperextensions
+} // namespace display
+} // namespace hardware
+} // namespace qti
+} // namespace vendor
+
+#endif // __QTIMAPPEREXTENSIONS_H__
diff --git a/gralloc/vendor.qti.hardware.display.allocator@1.0-service.rc b/gralloc/vendor.qti.hardware.display.allocator-service.rc
similarity index 80%
rename from gralloc/vendor.qti.hardware.display.allocator@1.0-service.rc
rename to gralloc/vendor.qti.hardware.display.allocator-service.rc
index 07bb2ff..ca2c7b9 100644
--- a/gralloc/vendor.qti.hardware.display.allocator@1.0-service.rc
+++ b/gralloc/vendor.qti.hardware.display.allocator-service.rc
@@ -1,4 +1,4 @@
-service vendor.qti.hardware.display.allocator /vendor/bin/hw/vendor.qti.hardware.display.allocator@1.0-service
+service vendor.qti.hardware.display.allocator /vendor/bin/hw/vendor.qti.hardware.display.allocator-service
class hal animation
user system
group graphics drmrpc