Skip to content
Snippets Groups Projects
Commit a48aa3f4 authored by Mattijs Korpershoek's avatar Mattijs Korpershoek Committed by Vishal Mahaveer
Browse files

TI: add DMABUF_CARVEOUT custom allocator support for decoder

In 48 bits mode, the wave5 video decoder/encoder has a hardware limitation:

For each memory access, the upper 16 bits of the 48 bit address *must* be
identical.

In order to enforce this addressing limitation, we can use a different dmabuf
heap, named carveout[1].

Add support for the carveout heap allocator in plugin_store and make sure that
this allocator is used by default for all input buffers.

Note: the output allocator still uses gralloc.
This requires a custom gralloc implementation which uses the carveout heap
whenever the GRALLOC_USAGE_HW_VIDEO_{DECODER,ENCODER} flags are used.

To tell the c2 framework that this allocator is available, make sure to set the
c2-poolmask property:

    debug.stagefright.c2-poolmask=0x1f50000

(DMABUF_CARVEOUT is bit 24)

[1] https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/drivers/dma-buf/heaps/carveout-heap.c?h=ti-linux-6.1.y


Signed-off-by: default avatarMattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: default avatarGuillaume La Roque <glaroque@baylibre.com>
parent ecc2c5a1
No related branches found
No related tags found
No related merge requests found
...@@ -315,7 +315,7 @@ DecodeInterface::DecodeInterface(const std::string& name, ...@@ -315,7 +315,7 @@ DecodeInterface::DecodeInterface(const std::string& name,
bool secureMode = name.find(".secure") != std::string::npos; bool secureMode = name.find(".secure") != std::string::npos;
const C2Allocator::id_t inputAllocators[] = {secureMode ? V4L2AllocatorId::SECURE_LINEAR const C2Allocator::id_t inputAllocators[] = {secureMode ? V4L2AllocatorId::SECURE_LINEAR
: C2AllocatorStore::DEFAULT_LINEAR}; : V4L2AllocatorId::DMABUF_CARVEOUT};
const C2Allocator::id_t outputAllocators[] = {C2PlatformAllocatorStore::GRALLOC}; const C2Allocator::id_t outputAllocators[] = {C2PlatformAllocatorStore::GRALLOC};
const C2Allocator::id_t surfaceAllocator = const C2Allocator::id_t surfaceAllocator =
......
...@@ -348,7 +348,7 @@ c2_status_t C2CarveoutDmaBufAllocator::mapUsage(C2MemoryUsage usage, size_t capa ...@@ -348,7 +348,7 @@ c2_status_t C2CarveoutDmaBufAllocator::mapUsage(C2MemoryUsage usage, size_t capa
!(usage.expected & (C2MemoryUsage::CPU_READ | C2MemoryUsage::CPU_WRITE))) !(usage.expected & (C2MemoryUsage::CPU_READ | C2MemoryUsage::CPU_WRITE)))
*heap_name = "system-uncached"; *heap_name = "system-uncached";
else else
*heap_name = "system"; *heap_name = "carveout_video";
*flags = 0; *flags = 0;
res = C2_NO_INIT; res = C2_NO_INIT;
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <log/log.h> #include <log/log.h>
#include <v4l2_codec2/plugin_store/V4L2AllocatorId.h> #include <v4l2_codec2/plugin_store/V4L2AllocatorId.h>
#include <v4l2_codec2/plugin_store/C2CarveoutDmaBufAllocator.h>
#include <v4l2_codec2/plugin_store/VendorAllocatorLoader.h> #include <v4l2_codec2/plugin_store/VendorAllocatorLoader.h>
namespace android { namespace android {
...@@ -47,6 +48,9 @@ C2Allocator* createAllocator(C2Allocator::id_t allocatorId) { ...@@ -47,6 +48,9 @@ C2Allocator* createAllocator(C2Allocator::id_t allocatorId) {
return allocatorLoader->createAllocator(allocatorId); return allocatorLoader->createAllocator(allocatorId);
} }
if (allocatorId == V4L2AllocatorId::DMABUF_CARVEOUT)
return new C2CarveoutDmaBufAllocator(allocatorId);
ALOGI("%s(): Fallback to create C2AllocatorGralloc(id=%u)", __func__, allocatorId); ALOGI("%s(): Fallback to create C2AllocatorGralloc(id=%u)", __func__, allocatorId);
return new C2AllocatorGralloc(allocatorId, true); return new C2AllocatorGralloc(allocatorId, true);
} }
...@@ -98,6 +102,9 @@ C2BlockPool* createBlockPool(C2Allocator::id_t allocatorId, C2BlockPool::local_i ...@@ -98,6 +102,9 @@ C2BlockPool* createBlockPool(C2Allocator::id_t allocatorId, C2BlockPool::local_i
case V4L2AllocatorId::SECURE_GRAPHIC: case V4L2AllocatorId::SECURE_GRAPHIC:
return new C2BufferQueueBlockPool(allocator, poolId); return new C2BufferQueueBlockPool(allocator, poolId);
case V4L2AllocatorId::DMABUF_CARVEOUT:
return new C2PooledBlockPool(allocator, poolId);
default: default:
ALOGE("%s(): Unknown allocator id=%u", __func__, allocatorId); ALOGE("%s(): Unknown allocator id=%u", __func__, allocatorId);
return nullptr; return nullptr;
......
...@@ -14,6 +14,7 @@ namespace V4L2AllocatorId { ...@@ -14,6 +14,7 @@ namespace V4L2AllocatorId {
enum : C2AllocatorStore::id_t { enum : C2AllocatorStore::id_t {
SECURE_LINEAR = C2PlatformAllocatorStore::PLATFORM_END, SECURE_LINEAR = C2PlatformAllocatorStore::PLATFORM_END,
SECURE_GRAPHIC, SECURE_GRAPHIC,
DMABUF_CARVEOUT,
}; };
} // namespace V4L2AllocatorId } // namespace V4L2AllocatorId
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment