summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2015-05-11 15:02:50 -0700
committerJason Sams <jsams@google.com>2015-05-11 15:02:50 -0700
commitf82b626e0479ce4a23ebff1fc088e073dcabaa30 (patch)
tree791670c30202628658777ad2c88f5e9831021f7c
parent6063b3ef8f88f5b4f29994b58ef0c883c4bea066 (diff)
downloadrs-f82b626e0479ce4a23ebff1fc088e073dcabaa30.tar.gz
Add USAGE_OEM
Allow OEMs to pass data from other HW blocks via internal extension. Change-Id: I78c19f5eec462aff7d8a5408f2f16cfc9b78c036
-rw-r--r--cpp/Allocation.cpp1
-rw-r--r--driver/rsdCore.cpp2
-rw-r--r--rsAllocation.cpp17
-rw-r--r--rsDefines.h3
-rw-r--r--rsDriverLoader.cpp1
-rw-r--r--rs_hal.h2
6 files changed, 23 insertions, 3 deletions
diff --git a/cpp/Allocation.cpp b/cpp/Allocation.cpp
index cae51911..fcba9e9a 100644
--- a/cpp/Allocation.cpp
+++ b/cpp/Allocation.cpp
@@ -49,6 +49,7 @@ Allocation::Allocation(void *id, sp<RS> rs, sp<const Type> t, uint32_t usage) :
RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET |
RS_ALLOCATION_USAGE_IO_INPUT |
RS_ALLOCATION_USAGE_IO_OUTPUT |
+ RS_ALLOCATION_USAGE_OEM |
RS_ALLOCATION_USAGE_SHARED)) != 0) {
ALOGE("Unknown usage specified.");
}
diff --git a/driver/rsdCore.cpp b/driver/rsdCore.cpp
index d9b11d26..9c4755c5 100644
--- a/driver/rsdCore.cpp
+++ b/driver/rsdCore.cpp
@@ -102,6 +102,8 @@ extern "C" bool rsdHalQueryHal(RsHalInitEnums entry, void **fnPtr) {
case RS_HAL_ALLOCATION_INIT:
fnPtr[0] = (void *)rsdAllocationInit; break;
+ case RS_HAL_ALLOCATION_INIT_OEM:
+ fnPtr[0] = (void *)nullptr; break;
case RS_HAL_ALLOCATION_INIT_ADAPTER:
fnPtr[0] = (void *)rsdAllocationAdapterInit; break;
case RS_HAL_ALLOCATION_DESTROY:
diff --git a/rsAllocation.cpp b/rsAllocation.cpp
index 0e742423..a7601a46 100644
--- a/rsAllocation.cpp
+++ b/rsAllocation.cpp
@@ -70,9 +70,22 @@ Allocation * Allocation::createAllocation(Context *rsc, const Type *type, uint32
return nullptr;
}
- Allocation *a = new (allocMem) Allocation(rsc, type, usages, mc, ptr);
+ bool success = false;
+ Allocation *a = nullptr;
+ if (usages & RS_ALLOCATION_USAGE_OEM) {
+ if (rsc->mHal.funcs.allocation.initOem != nullptr) {
+ a = new (allocMem) Allocation(rsc, type, usages, mc, nullptr);
+ success = rsc->mHal.funcs.allocation.initOem(rsc, a, type->getElement()->getHasReferences(), ptr);
+ } else {
+ rsc->setError(RS_ERROR_FATAL_DRIVER, "Allocation Init called with USAGE_OEM but driver does not support it");
+ return nullptr;
+ }
+ } else {
+ a = new (allocMem) Allocation(rsc, type, usages, mc, ptr);
+ success = rsc->mHal.funcs.allocation.init(rsc, a, type->getElement()->getHasReferences());
+ }
- if (!rsc->mHal.funcs.allocation.init(rsc, a, type->getElement()->getHasReferences())) {
+ if (!success) {
rsc->setError(RS_ERROR_FATAL_DRIVER, "Allocation::Allocation, alloc failure");
delete a;
return nullptr;
diff --git a/rsDefines.h b/rsDefines.h
index 92874708..fdb07208 100644
--- a/rsDefines.h
+++ b/rsDefines.h
@@ -96,7 +96,8 @@ enum RsAllocationUsageType {
RS_ALLOCATION_USAGE_IO_OUTPUT = 0x0040,
RS_ALLOCATION_USAGE_SHARED = 0x0080,
- RS_ALLOCATION_USAGE_ALL = 0x00FF
+ RS_ALLOCATION_USAGE_OEM = 0x8000,
+ RS_ALLOCATION_USAGE_ALL = 0x80FF
};
enum RsAllocationMipmapControl {
diff --git a/rsDriverLoader.cpp b/rsDriverLoader.cpp
index 528af0fa..2bc53b6a 100644
--- a/rsDriverLoader.cpp
+++ b/rsDriverLoader.cpp
@@ -82,6 +82,7 @@ static bool LoadHalTable(Context *rsc, HalQueryHal fn, bool loadGraphics) {
ret &= fn(RS_HAL_SCRIPT_UPDATE_CACHED_OBJECT, (void **)&rsc->mHal.funcs.script.updateCachedObject);
ret &= fn(RS_HAL_ALLOCATION_INIT, (void **)&rsc->mHal.funcs.allocation.init);
+ ret &= fn(RS_HAL_ALLOCATION_INIT_OEM, (void **)&rsc->mHal.funcs.allocation.initOem);
ret &= fn(RS_HAL_ALLOCATION_INIT_ADAPTER, (void **)&rsc->mHal.funcs.allocation.initAdapter);
ret &= fn(RS_HAL_ALLOCATION_DESTROY, (void **)&rsc->mHal.funcs.allocation.destroy);
ret &= fn(RS_HAL_ALLOCATION_GET_GRALLOC_BITS, (void **)&rsc->mHal.funcs.allocation.grallocBits);
diff --git a/rs_hal.h b/rs_hal.h
index b4070ac1..77c2d261 100644
--- a/rs_hal.h
+++ b/rs_hal.h
@@ -190,6 +190,7 @@ typedef struct {
struct {
bool (*init)(const Context *rsc, Allocation *alloc, bool forceZero);
+ bool (*initOem)(const Context *rsc, Allocation *alloc, bool forceZero, void *usrPtr);
bool (*initAdapter)(const Context *rsc, Allocation *alloc);
void (*destroy)(const Context *rsc, Allocation *alloc);
uint32_t (*grallocBits)(const Context *rsc, Allocation *alloc);
@@ -400,6 +401,7 @@ enum RsHalInitEnums {
RS_HAL_ALLOCATION_GENERATE_MIPMAPS = 2023,
RS_HAL_ALLOCATION_UPDATE_CACHED_OBJECT = 2024,
RS_HAL_ALLOCATION_ADAPTER_OFFSET = 2025,
+ RS_HAL_ALLOCATION_INIT_OEM = 2026,
RS_HAL_SAMPLER_INIT = 3000,
RS_HAL_SAMPLER_DESTROY = 3001,