Skip to content
Snippets Groups Projects
Commit 64021a2e 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>
parent 79d9199e
No related branches found
No related tags found
No related merge requests found
...@@ -265,7 +265,7 @@ V4L2DecodeInterface::V4L2DecodeInterface(const std::string& name, ...@@ -265,7 +265,7 @@ V4L2DecodeInterface::V4L2DecodeInterface(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[] = {V4L2AllocatorId::V4L2_BUFFERPOOL}; const C2Allocator::id_t outputAllocators[] = {V4L2AllocatorId::V4L2_BUFFERPOOL};
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 <v4l2_codec2/plugin_store/C2VdaBqBlockPool.h> #include <v4l2_codec2/plugin_store/C2VdaBqBlockPool.h>
#include <v4l2_codec2/plugin_store/C2VdaPooledBlockPool.h> #include <v4l2_codec2/plugin_store/C2VdaPooledBlockPool.h>
#include <v4l2_codec2/plugin_store/C2CarveoutDmaBufAllocator.h>
#include <v4l2_codec2/plugin_store/V4L2AllocatorId.h> #include <v4l2_codec2/plugin_store/V4L2AllocatorId.h>
#include <v4l2_codec2/plugin_store/VendorAllocatorLoader.h> #include <v4l2_codec2/plugin_store/VendorAllocatorLoader.h>
...@@ -32,6 +33,9 @@ C2Allocator* createAllocator(C2Allocator::id_t allocatorId) { ...@@ -32,6 +33,9 @@ C2Allocator* createAllocator(C2Allocator::id_t allocatorId) {
return sAllocatorLoader->createAllocator(allocatorId); return sAllocatorLoader->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);
} }
...@@ -79,6 +83,9 @@ C2BlockPool* createBlockPool(C2Allocator::id_t allocatorId, C2BlockPool::local_i ...@@ -79,6 +83,9 @@ C2BlockPool* createBlockPool(C2Allocator::id_t allocatorId, C2BlockPool::local_i
case V4L2AllocatorId::SECURE_GRAPHIC: case V4L2AllocatorId::SECURE_GRAPHIC:
return new C2VdaBqBlockPool(allocator, poolId); return new C2VdaBqBlockPool(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;
......
...@@ -16,6 +16,7 @@ enum : C2AllocatorStore::id_t { ...@@ -16,6 +16,7 @@ enum : C2AllocatorStore::id_t {
V4L2_BUFFERPOOL, V4L2_BUFFERPOOL,
SECURE_LINEAR, SECURE_LINEAR,
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