ANDROID: dma-heap: Provide accessors so that in-kernel drivers can allocate dmabufs from specific heaps

This allows drivers who don't want to create their own
DMA-BUF exporter to be able to allocate DMA-BUFs directly
from existing DMA-BUF Heaps.

There is some concern that the premise of DMA-BUF heaps is
that userland knows better about what type of heap memory
is needed for a pipeline, so it would likely be best for
drivers to import and fill DMA-BUFs allocated by userland
instead of allocating one themselves, but this is still
up for debate.

Unfortunately we don't have any public users of this, so
we cannot push it upstream. However, vendors have asked
for this, so I'm submitting it to Andorid Common in the
hopes that we can eventually find what vendors are doing.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I7b5ef690cefd2bfbbc2e01220ada49e44ef4fa04
Bug: 154341375
This commit is contained in:
John Stultz
2020-05-05 18:40:52 +00:00
parent 349e8360c9
commit 8e1ec97355
2 changed files with 45 additions and 1 deletions

View File

@@ -62,4 +62,43 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info);
*/
void dma_heap_put(struct dma_heap *heap);
/**
* dma_heap_find - Returns the registered dma_heap with the specified name
* @name: Name of the heap to find
*
* NOTE: dma_heaps returned from this function MUST be released
* using dma_heap_put() when the user is done.
*/
struct dma_heap *dma_heap_find(const char *name);
/**
* dma_heap_buffer_alloc - Allocate dma-buf from a dma_heap
* @heap: dma_heap to allocate from
* @len: size to allocate
* @fd_flags: flags to set on returned dma-buf fd
* @heap_flags: flags to pass to the dma heap
*
* This is for internal dma-buf allocations only.
*/
struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
unsigned int fd_flags,
unsigned int heap_flags);
/** dma_heap_buffer_free - Free dma_buf allocated by dma_heap_buffer_alloc
* @dma_buf: dma_buf to free
*
* This is really only a simple wrapper to dma_buf_put()
*/
void dma_heap_buffer_free(struct dma_buf *);
/**
* dma_heap_bufferfd_alloc - Allocate dma-buf fd from a dma_heap
* @heap: dma_heap to allocate from
* @len: size to allocate
* @fd_flags: flags to set on returned dma-buf fd
* @heap_flags: flags to pass to the dma heap
*/
int dma_heap_bufferfd_alloc(struct dma_heap *heap, size_t len,
unsigned int fd_flags,
unsigned int heap_flags);
#endif /* _DMA_HEAPS_H */