2 * drivers/video/tegra/nvmap/nvmap_ioctl.h
4 * ioctl declarations for nvmap
6 * Copyright (c) 2010, NVIDIA Corporation.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #ifndef __VIDEO_TEGRA_NVMAP_IOCTL_H
24 #define __VIDEO_TEGRA_NVMAP_IOCTL_H
26 #include <linux/ioctl.h>
27 #include <linux/file.h>
29 #include <mach/nvmap.h>
32 NVMAP_HANDLE_PARAM_SIZE = 1,
33 NVMAP_HANDLE_PARAM_ALIGNMENT,
34 NVMAP_HANDLE_PARAM_BASE,
35 NVMAP_HANDLE_PARAM_HEAP,
39 NVMAP_CACHE_OP_WB = 0,
41 NVMAP_CACHE_OP_WB_INV,
45 struct nvmap_create_handle {
47 __u32 key; /* ClaimPreservedHandle */
48 __u32 id; /* FromId */
49 __u32 size; /* CreateHandle */
54 struct nvmap_alloc_handle {
61 struct nvmap_map_caller {
62 __u32 handle; /* hmem */
63 __u32 offset; /* offset into hmem; should be page-aligned */
64 __u32 length; /* number of bytes to map */
66 unsigned long addr; /* user pointer */
69 struct nvmap_rw_handle {
70 unsigned long addr; /* user pointer */
71 __u32 handle; /* hmem */
72 __u32 offset; /* offset into hmem */
73 __u32 elem_size; /* individual atom size */
74 __u32 hmem_stride; /* delta in bytes between atoms in hmem */
75 __u32 user_stride; /* delta in bytes between atoms in user */
76 __u32 count; /* number of atoms to copy */
79 struct nvmap_pin_handle {
80 unsigned long handles; /* array of handles to pin/unpin */
81 unsigned long addr; /* array of addresses to return */
82 __u32 count; /* number of entries in handles */
85 struct nvmap_handle_param {
91 struct nvmap_cache_op {
98 #define NVMAP_IOC_MAGIC 'N'
100 /* Creates a new memory handle. On input, the argument is the size of the new
101 * handle; on return, the argument is the name of the new handle
103 #define NVMAP_IOC_CREATE _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
104 #define NVMAP_IOC_CLAIM _IOWR(NVMAP_IOC_MAGIC, 1, struct nvmap_create_handle)
105 #define NVMAP_IOC_FROM_ID _IOWR(NVMAP_IOC_MAGIC, 2, struct nvmap_create_handle)
107 /* Actually allocates memory for the specified handle */
108 #define NVMAP_IOC_ALLOC _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle)
110 /* Frees a memory handle, unpinning any pinned pages and unmapping any mappings
112 #define NVMAP_IOC_FREE _IO(NVMAP_IOC_MAGIC, 4)
114 /* Maps the region of the specified handle into a user-provided virtual address
115 * that was previously created via an mmap syscall on this fd */
116 #define NVMAP_IOC_MMAP _IOWR(NVMAP_IOC_MAGIC, 5, struct nvmap_map_caller)
118 /* Reads/writes data (possibly strided) from a user-provided buffer into the
119 * hmem at the specified offset */
120 #define NVMAP_IOC_WRITE _IOW(NVMAP_IOC_MAGIC, 6, struct nvmap_rw_handle)
121 #define NVMAP_IOC_READ _IOW(NVMAP_IOC_MAGIC, 7, struct nvmap_rw_handle)
123 #define NVMAP_IOC_PARAM _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param)
125 /* Pins a list of memory handles into IO-addressable memory (either IOVMM
126 * space or physical memory, depending on the allocation), and returns the
127 * address. Handles may be pinned recursively. */
128 #define NVMAP_IOC_PIN_MULT _IOWR(NVMAP_IOC_MAGIC, 10, struct nvmap_pin_handle)
129 #define NVMAP_IOC_UNPIN_MULT _IOW(NVMAP_IOC_MAGIC, 11, struct nvmap_pin_handle)
131 #define NVMAP_IOC_CACHE _IOW(NVMAP_IOC_MAGIC, 12, struct nvmap_cache_op)
133 /* Returns a global ID usable to allow a remote process to create a handle
134 * reference to the same handle */
135 #define NVMAP_IOC_GET_ID _IOWR(NVMAP_IOC_MAGIC, 13, struct nvmap_create_handle)
137 #define NVMAP_IOC_MAXNR (_IOC_NR(NVMAP_IOC_GET_ID))
139 int nvmap_ioctl_pinop(struct file *filp, bool is_pin, void __user *arg);
141 int nvmap_ioctl_get_param(struct file *filp, void __user* arg);
143 int nvmap_ioctl_getid(struct file *filp, void __user *arg);
145 int nvmap_ioctl_alloc(struct file *filp, void __user *arg);
147 int nvmap_ioctl_free(struct file *filp, unsigned long arg);
149 int nvmap_ioctl_create(struct file *filp, unsigned int cmd, void __user *arg);
151 int nvmap_map_into_caller_ptr(struct file *filp, void __user *arg);
153 int nvmap_ioctl_cache_maint(struct file *filp, void __user *arg);
155 int nvmap_ioctl_rw_handle(struct file *filp, int is_read, void __user* arg);