hc
2024-08-13 f258bb3ae540ccc311fd344a0121bba1928b85dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * SRAM DMA-Heap exporter && support alloc page and dmabuf on kernel
 *
 * Copyright (C) Rockchip Electronics Co., Ltd.
 *
 * Author: Huang Lee <Putin.li@rock-chips.com>
 */
#ifndef _LINUX_SRAM_HEAP_H
#define _LINUX_SRAM_HEAP_H
 
#include <linux/types.h>
#include <linux/dma-buf.h>
#include <linux/mm.h>
 
#if IS_REACHABLE(CONFIG_DMABUF_HEAPS_SRAM)
struct dma_buf *sram_heap_alloc_dma_buf(size_t size);
struct page *sram_heap_alloc_pages(size_t size);
void sram_heap_free_pages(struct page *p);
void sram_heap_free_dma_buf(struct dma_buf *dmabuf);
void *sram_heap_get_vaddr(struct dma_buf *dmabuf);
phys_addr_t sram_heap_get_paddr(struct dma_buf *dmabuf);
 
#else
static inline struct dma_buf *sram_heap_alloc_dma_buf(size_t size)
{
   return NULL;
}
 
static inline struct page *sram_heap_alloc_pages(size_t size)
{
   return NULL;
}
 
static inline void sram_heap_free_pages(struct page *p) {}
static inline void sram_heap_free_dma_buf(struct dma_buf *dmabuf) {}
 
static inline void *sram_heap_get_vaddr(struct dma_buf *dmabuf)
{
   return NULL;
}
 
static inline phys_addr_t sram_heap_get_paddr(struct dma_buf *dmabuf)
{
   return 0;
}
#endif
 
#endif