gralloc: Implement getters in QTIMapper 1.1
Add getters for members of private handle structure.
CRs-Fixed: 2411578
Change-Id: Ic683eaa233149f302a5cb913c5fb701f117f2058
diff --git a/gralloc/Android.mk b/gralloc/Android.mk
index 400b245..758b95e 100644
--- a/gralloc/Android.mk
+++ b/gralloc/Android.mk
@@ -53,6 +53,10 @@
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" ];\
@@ -82,6 +86,10 @@
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
include $(BUILD_SHARED_LIBRARY)
diff --git a/gralloc/QtiMapper.cpp b/gralloc/QtiMapper.cpp
index a885a7b..dc1b40c 100644
--- a/gralloc/QtiMapper.cpp
+++ b/gralloc/QtiMapper.cpp
@@ -40,7 +40,6 @@
namespace hardware {
namespace display {
namespace mapper {
-namespace V1_0 {
namespace implementation {
using gralloc::BufferInfo;
@@ -393,6 +392,152 @@
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
@@ -409,7 +554,6 @@
}
} // namespace implementation
-} // namespace V1_0
} // namespace mapper
} // namespace display
} // namespace hardware
diff --git a/gralloc/QtiMapper.h b/gralloc/QtiMapper.h
index b132a67..a17870c 100644
--- a/gralloc/QtiMapper.h
+++ b/gralloc/QtiMapper.h
@@ -32,7 +32,11 @@
#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 "gr_buf_mgr.h"
namespace vendor {
@@ -40,7 +44,6 @@
namespace hardware {
namespace display {
namespace mapper {
-namespace V1_0 {
namespace implementation {
using ::android::hardware::Return;
@@ -57,7 +60,11 @@
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 IMapper_2_1 = android::hardware::graphics::mapper::V2_1::IMapper;
@@ -101,6 +108,22 @@
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
+
private:
BufferManager *buf_mgr_ = nullptr;
Error CreateDescriptor(const BufferDescriptorInfo_2_1& descriptor_info,
@@ -115,7 +138,6 @@
extern "C" IQtiMapper *HIDL_FETCH_IQtiMapper(const char *name);
} // namespace implementation
-} // namespace V1_0
} // namespace mapper
} // namespace display
} // namespace hardware