summaryrefstree
path: root/kernel/include/linux/ion_exynos.h
blob: 3dae22717cf93c71f14ad9cb447e2657b7c7d474 (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * include/linux/ion_exynos.h
 *
 * Copyright (C) 2018 Samsung Electronics Co., Ltd.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef __LINUX_ION_EXYNOS_H__
#define __LINUX_ION_EXYNOS_H__

#include <linux/dma-direction.h>

struct dma_buf_attachment;

#define ION_FLAG_CACHED 1
#define ION_FLAG_NOZEROED 8
#define ION_FLAG_PROTECTED 16

#ifdef CONFIG_ION_EXYNOS
struct dma_buf *ion_alloc_dmabuf(const char *heap_name,
				 size_t len, unsigned int flags);
bool ion_cached_dmabuf(struct dma_buf *dmabuf);
bool ion_hwrender_dmabuf(struct dma_buf *dmabuf);
#else
static inline struct dma_buf *ion_alloc_dmabuf(const char *heap_name,
					       size_t len, unsigned int flags)
{
	return ERR_PTR(-ENODEV);
}

static inline bool ion_cached_dmabuf(struct dma_buf *dmabuf)
{
	return false;
}

static inline bool ion_cached_hwrender(struct dma_buf *dmabuf)
{
	return false;
}
#endif

#if defined(CONFIG_EXYNOS_IOVMM) && defined(CONFIG_ION_EXYNOS)
#define IOMMU_EXYNOS_SECURE	(1 << 0)

dma_addr_t ion_iovmm_map(struct dma_buf_attachment *attachment,
			 off_t offset, size_t size,
			 enum dma_data_direction direction, int prop);
void ion_iovmm_unmap(struct dma_buf_attachment *attachment, dma_addr_t iova);
dma_addr_t ion_iovmm_map_attr(struct dma_buf_attachment *attachment,
			      off_t offset, size_t size,
			      enum dma_data_direction direction, int prop,
			      int map_attr);
void ion_iovmm_unmap_attr(struct dma_buf_attachment *attachment,
			  dma_addr_t iova, int map_attr);
#else
static inline dma_addr_t ion_iovmm_map(struct dma_buf_attachment *attachment,
				       off_t offset, size_t size,
				       enum dma_data_direction direction,
				       int prop)
{
	return -ENODEV;
}
#define ion_iovmm_unmap(attachment, iova) do { } while (0)
static inline dma_addr_t ion_iovmm_map_attr(struct dma_buf_attachment *attachment,
					    off_t offset, size_t size,
					    enum dma_data_direction direction,
					    int prop, int map_attr)
{
	return -ENODEV;
}
#define ion_iovmm_unmap_attr(attachment, iova, map_attr) do { } while (0)

#endif

#endif /* __LINUX_ION_EXYNOS_H__ */