blob: 1196a336fc094e68ee219fbef6f5cedc0d106cd8 [file] [log] [blame]
Googler9398cc32022-12-02 17:21:52 +08001/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
2/*
3 * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
4 */
5
6#ifndef __LINUX_AMLOGIC_ION_H__
7#define __LINUX_AMLOGIC_ION_H__
8
9#include <linux/types.h>
10#include <linux/ion.h>
11
12/**
13 * CUSTOM IOCTL - CMD
14 */
15
16#define DION_ERROR(fmt, args ...) pr_err("ion_dev: " fmt, ## args)
17#define DION_INFO(fmt, args ...) pr_info("ion_dev: " fmt, ## args)
18#define DION_DEBUG(fmt, args ...) pr_debug("ion_dev: " fmt, ## args)
19
20#define ION_IOC_MESON_PHYS_ADDR 8
21#define ION_FLAG_EXTEND_MESON_SECURE_VDEC_HEAP BIT(28)
22#define ION_FLAG_EXTEND_MESON_HEAP_SECURE BIT(29)
23#define ION_FLAG_EXTEND_MESON_HEAP BIT(30)
24#define ION_FLAG_EXTEND_PROTECTED BIT(31)
25
26struct ion_cma_heap {
27 struct ion_heap heap;
28 struct cma *cma;
29
30 bool is_added;
31 unsigned long max_can_alloc_size;
32 unsigned long alloced_size;
33 /* protect size account */
34 struct mutex mutex;
35};
36
37struct meson_phys_data {
38 int handle;
39 unsigned int phys_addr;
40 unsigned int size;
41};
42
43/**
44 * meson_ion_share_fd_to_phys -
45 * associate with a fd
46 * @fd: passed from the user space
47 * @addr point to the physical address
48 * @size point to the size of this ion buffer
49 */
50
51int meson_ion_share_fd_to_phys(int fd, phys_addr_t *addr, size_t *len);
52void meson_ion_buffer_to_phys(struct ion_buffer *buffer,
53 phys_addr_t *addr, size_t *len);
54unsigned int meson_ion_cma_heap_id_get(void);
55unsigned int meson_ion_fb_heap_id_get(void);
56unsigned int meson_ion_codecmm_heap_id_get(void);
57struct ion_heap *ion_secure_heap_create(phys_addr_t base,
58 unsigned long size);
59void ion_secure_heap_destroy(struct ion_heap *heap);
60
61
62extern struct ion_heap_ops codec_mm_heap_ops;
63extern struct ion_heap_ops ion_cma_ops;
64
65#endif