media: tegra: nvavp: Fix heap overflow
[linux-3.10.git] / include / linux / tegra_nvavp.h
1 /*
2  * include/linux/tegra_nvavp.h
3  *
4  * Copyright (c) 2012-2016, NVIDIA CORPORATION.  All rights reserved.
5  *
6  * This file is licensed under the terms of the GNU General Public License
7  * version 2. This program is licensed "as is" without any warranty of any
8  * kind, whether express or implied.
9  */
10
11 #ifndef __LINUX_TEGRA_NVAVP_H
12 #define __LINUX_TEGRA_NVAVP_H
13
14 #include <linux/ioctl.h>
15 #include <linux/types.h>
16
17 #define NVAVP_MAX_RELOCATION_COUNT 65
18
19 /* avp submit flags */
20 #define NVAVP_FLAG_NONE         0x00000000
21 #define NVAVP_UCODE_EXT         0x00000001 /*use external ucode provided */
22
23 enum {
24         NVAVP_MODULE_ID_CPU     = 1,
25         NVAVP_MODULE_ID_AVP     = 2,
26         NVAVP_MODULE_ID_VCP     = 3,
27         NVAVP_MODULE_ID_BSEA    = 27,
28         NVAVP_MODULE_ID_VDE     = 28,
29         NVAVP_MODULE_ID_MPE     = 29,
30         NVAVP_MODULE_ID_EMC     = 75,
31 };
32
33 struct nvavp_cmdbuf {
34         __u32 mem;
35         __u32 offset;
36         __u32 words;
37 };
38
39 struct nvavp_reloc {
40         __u32 cmdbuf_mem;
41         __u32 cmdbuf_offset;
42         __u32 target;
43         __u32 target_offset;
44 };
45
46 struct nvavp_syncpt {
47         __u32 id;
48         __u32 value;
49 };
50
51 #ifdef CONFIG_COMPAT
52 struct nvavp_pushbuffer_submit_hdr_v32 {
53         struct nvavp_cmdbuf     cmdbuf;
54         __u32 relocs;
55         __u32 num_relocs;
56         __u32 syncpt;
57         __u32 flags;
58 };
59 #endif
60
61 struct nvavp_pushbuffer_submit_hdr {
62         struct nvavp_cmdbuf     cmdbuf;
63         struct nvavp_reloc      *relocs;
64         __u32                   num_relocs;
65         struct nvavp_syncpt     *syncpt;
66         __u32                   flags;
67 };
68
69 struct nvavp_set_nvmap_fd_args {
70         __u32 fd;
71 };
72
73 struct nvavp_clock_args {
74         __u32 id;
75         __u32 rate;
76 };
77
78 enum nvavp_clock_stay_on_state {
79         NVAVP_CLOCK_STAY_ON_DISABLED = 0,
80         NVAVP_CLOCK_STAY_ON_ENABLED
81 };
82
83 struct nvavp_clock_stay_on_state_args {
84         enum nvavp_clock_stay_on_state  state;
85 };
86
87 struct nvavp_num_cpus_args {
88         __u32 min_online_cpus;
89 };
90
91 struct nvavp_map_args {
92         __s32 fd;
93         __u32 addr;
94 };
95
96 struct nvavp_channel_open_args {
97         __u32 channel_fd;
98 };
99
100 #define NVAVP_IOCTL_MAGIC               'n'
101
102 #define NVAVP_IOCTL_SET_NVMAP_FD        _IOW(NVAVP_IOCTL_MAGIC, 0x60, \
103                                         struct nvavp_set_nvmap_fd_args)
104 #define NVAVP_IOCTL_GET_SYNCPOINT_ID    _IOR(NVAVP_IOCTL_MAGIC, 0x61, \
105                                         __u32)
106 #define NVAVP_IOCTL_PUSH_BUFFER_SUBMIT  _IOWR(NVAVP_IOCTL_MAGIC, 0x63, \
107                                         struct nvavp_pushbuffer_submit_hdr)
108 #ifdef CONFIG_COMPAT
109 #define NVAVP_IOCTL_PUSH_BUFFER_SUBMIT32        _IOWR(NVAVP_IOCTL_MAGIC, 0x63, \
110                                         struct nvavp_pushbuffer_submit_hdr_v32)
111 #endif
112 #define NVAVP_IOCTL_SET_CLOCK           _IOWR(NVAVP_IOCTL_MAGIC, 0x64, \
113                                         struct nvavp_clock_args)
114 #define NVAVP_IOCTL_GET_CLOCK           _IOR(NVAVP_IOCTL_MAGIC, 0x65, \
115                                         struct nvavp_clock_args)
116 #define NVAVP_IOCTL_WAKE_AVP            _IOR(NVAVP_IOCTL_MAGIC, 0x66, \
117                                         __u32)
118 #define NVAVP_IOCTL_FORCE_CLOCK_STAY_ON _IOW(NVAVP_IOCTL_MAGIC, 0x67, \
119                                         struct nvavp_clock_stay_on_state_args)
120 #define NVAVP_IOCTL_ENABLE_AUDIO_CLOCKS  _IOWR(NVAVP_IOCTL_MAGIC, 0x68, \
121                                         struct nvavp_clock_args)
122 #define NVAVP_IOCTL_DISABLE_AUDIO_CLOCKS _IOWR(NVAVP_IOCTL_MAGIC, 0x69, \
123                                         struct nvavp_clock_args)
124 #define NVAVP_IOCTL_SET_MIN_ONLINE_CPUS _IOWR(NVAVP_IOCTL_MAGIC, 0x70, \
125                                         struct nvavp_num_cpus_args)
126 #define NVAVP_IOCTL_MAP_IOVA            _IOWR(NVAVP_IOCTL_MAGIC, 0x71, \
127                                         struct nvavp_map_args)
128 #define NVAVP_IOCTL_UNMAP_IOVA          _IOW(NVAVP_IOCTL_MAGIC, 0x72, \
129                                         struct nvavp_map_args)
130 #define NVAVP_IOCTL_CHANNEL_OPEN        _IOR(NVAVP_IOCTL_MAGIC, 0x73, \
131                                         struct nvavp_channel_open_args)
132
133 #define NVAVP_IOCTL_MIN_NR              _IOC_NR(NVAVP_IOCTL_SET_NVMAP_FD)
134 #define NVAVP_IOCTL_MAX_NR              _IOC_NR(NVAVP_IOCTL_CHANNEL_OPEN)
135
136 #define NVAVP_IOCTL_CHANNEL_MAX_ARG_SIZE        \
137                                 sizeof(struct nvavp_pushbuffer_submit_hdr)
138 #endif /* __LINUX_TEGRA_NVAVP_H */