summaryrefslogtreecommitdiff
path: root/gralloc4/src/hidl_common/Mapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'gralloc4/src/hidl_common/Mapper.h')
-rw-r--r--gralloc4/src/hidl_common/Mapper.h79
1 files changed, 52 insertions, 27 deletions
diff --git a/gralloc4/src/hidl_common/Mapper.h b/gralloc4/src/hidl_common/Mapper.h
index 6d114cc..c77128c 100644
--- a/gralloc4/src/hidl_common/Mapper.h
+++ b/gralloc4/src/hidl_common/Mapper.h
@@ -23,7 +23,9 @@
#include "mali_gralloc_log.h"
#include "core/mali_gralloc_bufferdescriptor.h"
-#include "4.x/gralloc_mapper_hidl_header.h"
+#include "MapperMetadata.h"
+#include "hidl_common.h"
+#include "mali_gralloc_error.h"
namespace arm
{
@@ -32,24 +34,42 @@ namespace mapper
namespace common
{
-using android::hardware::hidl_handle;
-using android::hardware::hidl_vec;
+
+using aidl::android::hardware::graphics::common::Rect;
+
using android::hardware::Void;
+class GrallocRect {
+ public:
+ int left;
+ int top;
+ int right;
+ int bottom;
+ GrallocRect(Rect rect) {
+ left = rect.left;
+ top = rect.top;
+ right = rect.right;
+ bottom = rect.bottom;
+ }
+#ifdef GRALLOC_MAPPER_4
+ GrallocRect(IMapper::Rect rect) {
+ left = rect.left;
+ top = rect.top;
+ right = rect.left + rect.width;
+ bottom = rect.top + rect.height;
+ }
+#endif
+};
+
/**
* Imports a raw buffer handle to create an imported buffer handle for use with
* the rest of the mapper or with other in-process libraries.
*
- * @param rawHandle [in] Raw buffer handle to import.
- * @param hidl_cb [in] HIDL Callback function to export output information
- * @param hidl_cb [in] HIDL callback function generating -
- * error : NONE upon success. Otherwise,
- * BAD_BUFFER for an invalid buffer
- * NO_RESOURCES when the raw handle cannot be imported
- * BAD_VALUE when any of the specified attributes are invalid
- * buffer : Imported buffer handle
+ * @param bufferHandle [in] Buffer handle to import.
+ * @param outBuffer [in] imported Buffer
*/
-void importBuffer(const hidl_handle &rawHandle, IMapper::importBuffer_cb hidl_cb);
+Error importBuffer(const native_handle_t *inBuffer, buffer_handle_t *outBuffer);
+
/**
* Frees a buffer handle and releases all the resources associated with it
@@ -59,7 +79,10 @@ void importBuffer(const hidl_handle &rawHandle, IMapper::importBuffer_cb hidl_cb
* @return Error::BAD_BUFFER for an invalid buffer / when failed to free the buffer
* Error::NONE on successful free
*/
-Error freeBuffer(void *buffer);
+Error freeBuffer(buffer_handle_t buffer);
+
+buffer_handle_t getBuffer(void *buffer);
+native_handle_t* removeBuffer(void **buffer);
/**
* Locks the given buffer for the specified CPU usage.
@@ -76,8 +99,7 @@ Error freeBuffer(void *buffer);
* bytesPerPixel: v3.X Only. Number of bytes per pixel in the buffer
* bytesPerStride: v3.X Only. Bytes per stride of the buffer
*/
-void lock(void *buffer, uint64_t cpuUsage, const IMapper::Rect &accessRegion, const hidl_handle &acquireFence,
- IMapper::lock_cb hidl_cb);
+Error lock(buffer_handle_t buffer, uint64_t cpuUsage, const GrallocRect &accessRegion, int acquireFence, void **outData);
/**
* Unlocks a buffer to indicate all CPU accesses to the buffer have completed
@@ -88,7 +110,7 @@ void lock(void *buffer, uint64_t cpuUsage, const IMapper::Rect &accessRegion, co
* BAD_BUFFER for an invalid buffer
* releaseFence: Referrs to a sync fence object
*/
-void unlock(void *buffer, IMapper::unlock_cb hidl_cb);
+Error unlock(const native_handle_t *buffer, int *releaseFence);
/**
* Validates the buffer against specified descriptor attributes
@@ -102,7 +124,9 @@ void unlock(void *buffer, IMapper::unlock_cb hidl_cb);
* Error::BAD_BUFFER upon bad buffer input
* Error::BAD_VALUE when any of the specified attributes are invalid
*/
+#ifdef GRALLOC_MAPPER_4
Error validateBufferSize(void *buffer, const IMapper::BufferDescriptorInfo &descriptorInfo, uint32_t stride);
+#endif
/**
* Get the transport size of a buffer
@@ -114,7 +138,7 @@ Error validateBufferSize(void *buffer, const IMapper::BufferDescriptorInfo &desc
* numFds: Number of file descriptors needed for transport
* numInts: Number of integers needed for transport
*/
-void getTransportSize(void *buffer, IMapper::getTransportSize_cb hidl_cb);
+Error getTransportSize(buffer_handle_t bufferHandle, uint32_t *outNumFds, uint32_t *outNumInts);
/**
* Test whether the given BufferDescriptorInfo is allocatable.
@@ -125,8 +149,9 @@ void getTransportSize(void *buffer, IMapper::getTransportSize_cb hidl_cb);
* BAD_VALUE, Otherwise,
* supported: Whether the description can be allocated
*/
-void isSupported(const IMapper::BufferDescriptorInfo &description, IMapper::isSupported_cb hidl_cb);
-
+#ifdef GRALLOC_MAPPER_4
+bool isSupported(const IMapper::BufferDescriptorInfo &description);
+#endif
/* TODO: implement this feature for exynos */
/**
* Flushes the CPU caches of a mapped buffer.
@@ -137,7 +162,7 @@ void isSupported(const IMapper::BufferDescriptorInfo &description, IMapper::isSu
* has not been locked.
* releaseFence: Empty fence signaling completion as all work is completed within the call.
*/
-void flushLockedBuffer(void *buffer, IMapper::flushLockedBuffer_cb hidl_cb);
+Error flushLockedBuffer(buffer_handle_t buffer);
/* TODO: implement this feature for exynos */
/**
@@ -148,7 +173,7 @@ void flushLockedBuffer(void *buffer, IMapper::flushLockedBuffer_cb hidl_cb);
* @return Error::NONE upon success.
* Error::BAD_BUFFER for an invalid buffer or a buffer that has not been locked.
*/
-Error rereadLockedBuffer(void *buffer);
+Error rereadLockedBuffer(buffer_handle_t handle);
/**
* Retrieves a Buffer's metadata value.
@@ -161,7 +186,7 @@ Error rereadLockedBuffer(void *buffer);
* UNSUPPORTED on error when reading or unsupported metadata type.
* metadata: Vector of bytes representing the metadata value.
*/
-void get(void *buffer, const IMapper::MetadataType &metadataType, IMapper::get_cb hidl_cb);
+Error get(buffer_handle_t buffer, const MetadataType &metadataType, std::vector<uint8_t> &vec);
/**
* Sets a Buffer's metadata value.
@@ -174,7 +199,7 @@ void get(void *buffer, const IMapper::MetadataType &metadataType, IMapper::get_c
* Error::BAD_BUFFER on invalid buffer argument.
* Error::UNSUPPORTED on error when writing or unsupported metadata type.
*/
-Error set(void *buffer, const IMapper::MetadataType &metadataType, const hidl_vec<uint8_t> &metadata);
+Error set(buffer_handle_t buffer, const MetadataType &metadataType, const frameworks_vec<uint8_t> &metadata);
/**
* Lists all the MetadataTypes supported by IMapper as well as a description
@@ -189,7 +214,7 @@ Error set(void *buffer, const IMapper::MetadataType &metadataType, const hidl_ve
* descriptions: vector of MetadataTypeDescriptions that represent the
* MetadataTypes supported by the device.
*/
-void listSupportedMetadataTypes(IMapper::listSupportedMetadataTypes_cb hidl_cb);
+std::vector<MetadataTypeDescription> listSupportedMetadataTypes();
/**
* Dumps a buffer's metadata.
@@ -203,7 +228,7 @@ void listSupportedMetadataTypes(IMapper::listSupportedMetadataTypes_cb hidl_cb);
* resources.
* bufferDump: Struct representing the metadata being dumped
*/
-void dumpBuffer(void *buffer, IMapper::dumpBuffer_cb hidl_cb);
+Error dumpBuffer(buffer_handle_t buffer, BufferDump &out);
/**
* Dumps the metadata for all the buffers in the current process.
@@ -215,7 +240,7 @@ void dumpBuffer(void *buffer, IMapper::dumpBuffer_cb hidl_cb);
* resources.
* bufferDumps: Vector of structs representing the buffers being dumped
*/
-void dumpBuffers(IMapper::dumpBuffers_cb hidl_cb);
+std::vector<BufferDump> dumpBuffers();
/**
* Returns the region of shared memory associated with the buffer that is
@@ -243,7 +268,7 @@ void dumpBuffers(IMapper::dumpBuffers_cb hidl_cb);
* reservedSize: the size of the reservedRegion that was requested
* in the BufferDescriptorInfo.
*/
-void getReservedRegion(void *buffer, IMapper::getReservedRegion_cb _hidl_cb);
+Error getReservedRegion(buffer_handle_t buffer, void **outReservedRegion, uint64_t &outReservedSize);
} // namespace common
} // namespace mapper