summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-07-28 01:08:06 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-07-28 01:08:06 +0000
commite4ceba00c782090f28e65f16f417d07f9861c7da (patch)
treeb486bd87d41c0839fe41c59c59d76b88ad24fa2b
parent342f3969292d10dee52dbb3ef5571411218195b3 (diff)
parent3b0a617ec84db1847a213f34d853df5f9cbbc6e1 (diff)
downloadgchips-e4ceba00c782090f28e65f16f417d07f9861c7da.tar.gz
Snap for 7588529 from 3b0a617ec84db1847a213f34d853df5f9cbbc6e1 to sc-d2-release
Change-Id: I6dd0284082aafaf7dddc5b77f870eb69930e7001
-rw-r--r--gralloc4/src/Android.bp1
-rw-r--r--gralloc4/src/libGralloc4Wrapper/include/gralloc4/gralloc_vendor_interface.h3
-rw-r--r--gralloc4/src/libGralloc4Wrapper/wrapper.cpp54
-rw-r--r--include/VendorVideoAPI.h9
-rw-r--r--libvendorgraphicbuffer/gralloc3/vendor_graphicbuffer_meta.cpp13
-rw-r--r--libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp54
-rw-r--r--libvendorgraphicbuffer/include/VendorGraphicBuffer.h3
7 files changed, 115 insertions, 22 deletions
diff --git a/gralloc4/src/Android.bp b/gralloc4/src/Android.bp
index 2a4a5e3..a3a254d 100644
--- a/gralloc4/src/Android.bp
+++ b/gralloc4/src/Android.bp
@@ -67,6 +67,7 @@ cc_library_shared {
"libnativewindow",
"libion_google",
"android.hardware.graphics.common@1.2",
+ "android.hardware.graphics.mapper@4.0",
"libdmabufheap",
"libgralloctypes",
"libdrm",
diff --git a/gralloc4/src/libGralloc4Wrapper/include/gralloc4/gralloc_vendor_interface.h b/gralloc4/src/libGralloc4Wrapper/include/gralloc4/gralloc_vendor_interface.h
index 45054c8..cbd98d9 100644
--- a/gralloc4/src/libGralloc4Wrapper/include/gralloc4/gralloc_vendor_interface.h
+++ b/gralloc4/src/libGralloc4Wrapper/include/gralloc4/gralloc_vendor_interface.h
@@ -43,8 +43,7 @@ void setFormat(Descriptor &descriptor, int format);
buffer_handle_t createNativeHandle(const Descriptor &descriptor);
-android::hardware::graphics::mapper::V4_0::Error retain(buffer_handle_t handle);
-android::hardware::graphics::mapper::V4_0::Error release(buffer_handle_t handle);
+int freeImportedHandle(void *handle);
} // namespace android::hardware::graphics::allocator::priv
diff --git a/gralloc4/src/libGralloc4Wrapper/wrapper.cpp b/gralloc4/src/libGralloc4Wrapper/wrapper.cpp
index 07374ad..c9d3381 100644
--- a/gralloc4/src/libGralloc4Wrapper/wrapper.cpp
+++ b/gralloc4/src/libGralloc4Wrapper/wrapper.cpp
@@ -188,22 +188,50 @@ buffer_handle_t createNativeHandle(const Descriptor &descriptor) {
return tmp_buffer;
}
-android::hardware::graphics::mapper::V4_0::Error retain(buffer_handle_t handle) {
- int err = mali_gralloc_reference_retain(handle);
- if (err == -EINVAL) {
- return android::hardware::graphics::mapper::V4_0::Error::BAD_BUFFER;
- } else if (err) {
- return android::hardware::graphics::mapper::V4_0::Error::NO_RESOURCES;
+int freeImportedHandle(void *handle)
+{
+ using android::hardware::graphics::mapper::V4_0::IMapper;
+ using android::hardware::graphics::mapper::V4_0::Error;
+
+ const private_handle_t *hnd = static_cast<private_handle_t *>(handle);
+
+ struct UnmapWork { void *base; size_t alloc_size; };
+ std::vector<UnmapWork> work(hnd->fd_count);
+
+ for (size_t i = 0; i < hnd->fd_count; ++i)
+ {
+ work[i].base = reinterpret_cast<void*>(hnd->bases[i]);
+ work[i].alloc_size = hnd->alloc_sizes[i];
+ }
+
+ static android::sp<IMapper> mapper = IMapper::getService();
+ if (!mapper)
+ {
+ ALOGE("libGralloc4Wrapper: %s failed to get a mapper", __func__);
+ return -1;
}
- return android::hardware::graphics::mapper::V4_0::Error::NONE;
-}
-android::hardware::graphics::mapper::V4_0::Error release(buffer_handle_t handle) {
- int err = mali_gralloc_reference_release(handle, true);
- if (err) {
- return android::hardware::graphics::mapper::V4_0::Error::BAD_BUFFER;
+ if (mapper->freeBuffer(handle) != Error::NONE)
+ {
+ ALOGE("libGralloc4Wrapper: %s couldn't freeBuffer(%p\n", __func__, handle);
+ return -1;
}
- return android::hardware::graphics::mapper::V4_0::Error::NONE;
+
+ {
+ bool unmapFailed = false;
+ for (const UnmapWork &w : work)
+ {
+ if (!w.base) { continue; }
+ if (int ret = munmap(w.base, w.alloc_size); ret)
+ {
+ ALOGE("libGralloc4Wrapper: %s couldn't unmap address %p (size %zu): %s", __func__, w.base, w.alloc_size, strerror(ret));
+ unmapFailed = true;
+ }
+ }
+ if (unmapFailed) { return -1; }
+ }
+
+ return 0;
}
} // namespace android::hardware::graphics::allocator::priv
diff --git a/include/VendorVideoAPI.h b/include/VendorVideoAPI.h
index 0ebf974..7dc2a09 100644
--- a/include/VendorVideoAPI.h
+++ b/include/VendorVideoAPI.h
@@ -42,6 +42,7 @@ typedef enum _ExynosVideoInfoType {
VIDEO_INFO_TYPE_YSUM_DATA = 0x1 << 3,
VIDEO_INFO_TYPE_HDR_DYNAMIC = 0x1 << 4,
VIDEO_INFO_TYPE_CHECK_PIXEL_FORMAT = 0x1 << 5,
+ VIDEO_INFO_TYPE_CROP_INFO = 0x1 << 8,
} ExynosVideoInfoType;
typedef struct _ExynosVideoYSUMData {
@@ -110,6 +111,13 @@ typedef struct _ExynosHdrDynamicInfo {
unsigned int reserved[42];
} ExynosHdrDynamicInfo;
+typedef struct _ExynosVideoCrop {
+ int left;
+ int top;
+ int width;
+ int height;
+} ExynosVideoCrop;
+
typedef struct _ExynosVideoDecData {
int nInterlacedType;
} ExynosVideoDecData;
@@ -132,6 +140,7 @@ typedef struct _ExynosVideoMeta {
ExynosHdrDynamicInfo sHdrDynamicInfo;
int nPixelFormat;
+ ExynosVideoCrop crop;
} ExynosVideoMeta;
int Exynos_parsing_user_data_registered_itu_t_t35(ExynosHdrDynamicInfo *dest, void *src);
diff --git a/libvendorgraphicbuffer/gralloc3/vendor_graphicbuffer_meta.cpp b/libvendorgraphicbuffer/gralloc3/vendor_graphicbuffer_meta.cpp
index f6322be..16e62bf 100644
--- a/libvendorgraphicbuffer/gralloc3/vendor_graphicbuffer_meta.cpp
+++ b/libvendorgraphicbuffer/gralloc3/vendor_graphicbuffer_meta.cpp
@@ -230,6 +230,19 @@ void* VendorGraphicBufferMeta::get_video_metadata_roiinfo(buffer_handle_t hnd)
return nullptr;
}
+/* This function is not used with gralloc3. return nullptr */
+buffer_handle_t VendorGraphicBufferMeta::import_buffer(buffer_handle_t hnd)
+{
+ UNUSED(hnd);
+ return nullptr;
+}
+
+/* This function is not used with gralloc3. */
+int VendorGraphicBufferMeta::free_buffer(buffer_handle_t hnd)
+{
+ return 0;
+}
+
void VendorGraphicBufferMeta::init(const buffer_handle_t handle)
{
const private_handle_t *gralloc_hnd = static_cast<const private_handle_t *>(handle);
diff --git a/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp b/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp
index 8d88231..9034019 100644
--- a/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp
+++ b/libvendorgraphicbuffer/gralloc4/vendor_graphicbuffer_meta.cpp
@@ -44,13 +44,13 @@ using android::hardware::graphics::mapper::V4_0::Error;
// libraries and should depend upon HAL (and it's extension) to call into
// Gralloc.
int mali_gralloc_reference_validate(buffer_handle_t handle) {
- auto hnd = static_cast<const private_handle_t *>(handle);
+ auto hnd = static_cast<const private_handle_t *>(handle);
- if (hnd->allocating_pid != getpid() && hnd->remote_pid != getpid()) {
- return -EINVAL;
- }
+ if (hnd->allocating_pid != getpid() && hnd->remote_pid != getpid()) {
+ return -EINVAL;
+ }
- return 0;
+ return 0;
}
const private_handle_t * convertNativeHandleToPrivateHandle(buffer_handle_t handle) {
@@ -105,6 +105,7 @@ int VendorGraphicBufferMeta::get_dataspace(buffer_handle_t hnd)
error = static_cast<Error>(decodeDataspace(tmpVec, &dataspace));
});
+
if (error != Error::NONE) {
ALOGE("Failed to get datasapce");
return -EINVAL;
@@ -154,7 +155,7 @@ int VendorGraphicBufferMeta::is_sbwc(buffer_handle_t buffer_hnd_p)
{
const private_handle_t *hnd = static_cast<const private_handle_t *>(buffer_hnd_p);
- return is_sbwc_format(static_cast<uint32_t>(hnd->alloc_format & MALI_GRALLOC_INTFMT_FMT_MASK));
+ return is_sbwc_format(static_cast<uint32_t>(hnd->alloc_format & MALI_GRALLOC_INTFMT_FMT_MASK));
}
#define GRALLOC_META_GETTER(__type__, __name__, __member__) \
@@ -166,7 +167,7 @@ __type__ VendorGraphicBufferMeta::get_##__name__(buffer_handle_t hnd) \
} \
-uint32_t VendorGraphicBufferMeta::get_format(buffer_handle_t hnd)
+uint32_t VendorGraphicBufferMeta::get_format(buffer_handle_t hnd)
{
const private_handle_t *gralloc_hnd = static_cast<const private_handle_t *>(hnd);
if (!gralloc_hnd)
@@ -304,6 +305,45 @@ void VendorGraphicBufferMeta::init(const buffer_handle_t handle)
unique_id = gralloc_hnd->backing_store_id;
}
+buffer_handle_t VendorGraphicBufferMeta::import_buffer(buffer_handle_t hnd)
+{
+ native_handle_t* handle = const_cast<native_handle_t*>(hnd);
+ if (!handle) {
+ return nullptr;
+ }
+
+ native_handle_t* bufferHandle = nullptr;
+ Error error = Error::NONE;
+ get_mapper()->importBuffer(handle, [&](const auto& tmpError, const auto& tmpBuffer) {
+ error = tmpError;
+ if (error != Error::NONE) {
+ return;
+ }
+ bufferHandle = static_cast<native_handle_t*>(tmpBuffer);
+ });
+
+ if (error != Error::NONE) {
+ ALOGE("[%s] Unable to import buffer", __FUNCTION__);
+ return nullptr;
+ }
+
+ return bufferHandle;
+}
+
+int VendorGraphicBufferMeta::free_buffer(buffer_handle_t hnd)
+{
+ native_handle_t* handle = const_cast<native_handle_t*>(hnd);
+ if (!handle) {
+ return -EINVAL;
+ }
+ Error error = get_mapper()->freeBuffer(handle);
+ if (error != Error::NONE) {
+ ALOGE("[%s] Failed to free buffer", __FUNCTION__);
+ return -EINVAL;
+ }
+ return 0;
+}
+
VendorGraphicBufferMeta::VendorGraphicBufferMeta(buffer_handle_t handle)
{
init(handle);
diff --git a/libvendorgraphicbuffer/include/VendorGraphicBuffer.h b/libvendorgraphicbuffer/include/VendorGraphicBuffer.h
index cc014cb..8dfd90d 100644
--- a/libvendorgraphicbuffer/include/VendorGraphicBuffer.h
+++ b/libvendorgraphicbuffer/include/VendorGraphicBuffer.h
@@ -145,6 +145,9 @@ public:
static int get_video_metadata_fd(buffer_handle_t);
static int get_dataspace(buffer_handle_t);
static int set_dataspace(buffer_handle_t hnd, android_dataspace_t dataspace);
+
+ static buffer_handle_t import_buffer(buffer_handle_t);
+ static int free_buffer(buffer_handle_t);
};