• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __UAPI_CAM_DEFS_H__
2 #define __UAPI_CAM_DEFS_H__
3 
4 #include <linux/videodev2.h>
5 #include <linux/types.h>
6 #include <linux/ioctl.h>
7 
8 
9 #define CAM_COMMON_OPCODE_BASE                  0x100
10 #define CAM_QUERY_CAP                           (CAM_COMMON_OPCODE_BASE + 0x1)
11 #define CAM_ACQUIRE_DEV                         (CAM_COMMON_OPCODE_BASE + 0x2)
12 #define CAM_START_DEV                           (CAM_COMMON_OPCODE_BASE + 0x3)
13 #define CAM_STOP_DEV                            (CAM_COMMON_OPCODE_BASE + 0x4)
14 #define CAM_CONFIG_DEV                          (CAM_COMMON_OPCODE_BASE + 0x5)
15 #define CAM_RELEASE_DEV                         (CAM_COMMON_OPCODE_BASE + 0x6)
16 #define CAM_SD_SHUTDOWN                         (CAM_COMMON_OPCODE_BASE + 0x7)
17 #define CAM_FLUSH_REQ                           (CAM_COMMON_OPCODE_BASE + 0x8)
18 #define CAM_COMMON_OPCODE_MAX                   (CAM_COMMON_OPCODE_BASE + 0x9)
19 
20 #define CAM_COMMON_OPCODE_BASE_v2           0x150
21 #define CAM_ACQUIRE_HW                      (CAM_COMMON_OPCODE_BASE_v2 + 0x1)
22 #define CAM_RELEASE_HW                      (CAM_COMMON_OPCODE_BASE_v2 + 0x2)
23 
24 #define CAM_EXT_OPCODE_BASE                     0x200
25 #define CAM_CONFIG_DEV_EXTERNAL                 (CAM_EXT_OPCODE_BASE + 0x1)
26 
27 #define CAM_HANDLE_USER_POINTER                 1
28 #define CAM_HANDLE_MEM_HANDLE                   2
29 
30 #define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_MASK    0xFFFFFF00
31 #define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_SHIFT   8
32 #define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_MASK    0xFF
33 #define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_SHIFT   0
34 
35 #define CAM_CMD_BUF_DMI                     0x1
36 #define CAM_CMD_BUF_DMI16                   0x2
37 #define CAM_CMD_BUF_DMI32                   0x3
38 #define CAM_CMD_BUF_DMI64                   0x4
39 #define CAM_CMD_BUF_DIRECT                  0x5
40 #define CAM_CMD_BUF_INDIRECT                0x6
41 #define CAM_CMD_BUF_I2C                     0x7
42 #define CAM_CMD_BUF_FW                      0x8
43 #define CAM_CMD_BUF_GENERIC                 0x9
44 #define CAM_CMD_BUF_LEGACY                  0xA
45 
46 #define CAM_UBWC_CFG_VERSION_1              1
47 
48 #ifdef CONFIG_BOARD_SUNFISH
49 
50 #define CAM_DUMP_REQ                        (CAM_COMMON_OPCODE_BASE_v2 + 0x3)
51 
52 struct cam_dump_req_cmd {
53        int64_t        issue_req_id;
54        int32_t        session_handle;
55        int32_t        link_hdl;
56        int32_t        dev_handle;
57        int32_t        error_type;
58        uint32_t       buf_handle;
59        int32_t        offset;
60        uint32_t       reserved;
61 };
62 
63 #endif /*CONFIG_BOARD_SUNFISH*/
64 
65 
66 enum flush_type_t {
67 	CAM_FLUSH_TYPE_REQ,
68 	CAM_FLUSH_TYPE_ALL,
69 	CAM_FLUSH_TYPE_MAX
70 };
71 
72 struct cam_control {
73 	uint32_t        op_code;
74 	uint32_t        size;
75 	uint32_t        handle_type;
76 	uint32_t        reserved;
77 	uint64_t        handle;
78 };
79 
80 #define VIDIOC_CAM_CONTROL \
81 	_IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_control)
82 
83 struct cam_hw_version {
84 	uint32_t major;
85 	uint32_t minor;
86 	uint32_t incr;
87 	uint32_t reserved;
88 };
89 
90 struct cam_iommu_handle {
91 	int32_t non_secure;
92 	int32_t secure;
93 };
94 
95 #define CAM_SECURE_MODE_NON_SECURE             0
96 #define CAM_SECURE_MODE_SECURE                 1
97 
98 #define CAM_FORMAT_BASE                         0
99 #define CAM_FORMAT_MIPI_RAW_6                   1
100 #define CAM_FORMAT_MIPI_RAW_8                   2
101 #define CAM_FORMAT_MIPI_RAW_10                  3
102 #define CAM_FORMAT_MIPI_RAW_12                  4
103 #define CAM_FORMAT_MIPI_RAW_14                  5
104 #define CAM_FORMAT_MIPI_RAW_16                  6
105 #define CAM_FORMAT_MIPI_RAW_20                  7
106 #define CAM_FORMAT_QTI_RAW_8                    8
107 #define CAM_FORMAT_QTI_RAW_10                   9
108 #define CAM_FORMAT_QTI_RAW_12                   10
109 #define CAM_FORMAT_QTI_RAW_14                   11
110 #define CAM_FORMAT_PLAIN8                       12
111 #define CAM_FORMAT_PLAIN16_8                    13
112 #define CAM_FORMAT_PLAIN16_10                   14
113 #define CAM_FORMAT_PLAIN16_12                   15
114 #define CAM_FORMAT_PLAIN16_14                   16
115 #define CAM_FORMAT_PLAIN16_16                   17
116 #define CAM_FORMAT_PLAIN32_20                   18
117 #define CAM_FORMAT_PLAIN64                      19
118 #define CAM_FORMAT_PLAIN128                     20
119 #define CAM_FORMAT_ARGB                         21
120 #define CAM_FORMAT_ARGB_10                      22
121 #define CAM_FORMAT_ARGB_12                      23
122 #define CAM_FORMAT_ARGB_14                      24
123 #define CAM_FORMAT_DPCM_10_6_10                 25
124 #define CAM_FORMAT_DPCM_10_8_10                 26
125 #define CAM_FORMAT_DPCM_12_6_12                 27
126 #define CAM_FORMAT_DPCM_12_8_12                 28
127 #define CAM_FORMAT_DPCM_14_8_14                 29
128 #define CAM_FORMAT_DPCM_14_10_14                30
129 #define CAM_FORMAT_NV21                         31
130 #define CAM_FORMAT_NV12                         32
131 #define CAM_FORMAT_TP10                         33
132 #define CAM_FORMAT_YUV422                       34
133 #define CAM_FORMAT_PD8                          35
134 #define CAM_FORMAT_PD10                         36
135 #define CAM_FORMAT_UBWC_NV12                    37
136 #define CAM_FORMAT_UBWC_NV12_4R                 38
137 #define CAM_FORMAT_UBWC_TP10                    39
138 #define CAM_FORMAT_UBWC_P010                    40
139 #define CAM_FORMAT_PLAIN8_SWAP                  41
140 #define CAM_FORMAT_PLAIN8_10                    42
141 #define CAM_FORMAT_PLAIN8_10_SWAP               43
142 #define CAM_FORMAT_YV12                         44
143 #define CAM_FORMAT_Y_ONLY                       45
144 #define CAM_FORMAT_DPCM_12_10_12                46
145 #define CAM_FORMAT_MAX                          47
146 
147 #define CAM_ROTATE_CW_0_DEGREE                  0
148 #define CAM_ROTATE_CW_90_DEGREE                 1
149 #define CAM_RORATE_CW_180_DEGREE                2
150 #define CAM_ROTATE_CW_270_DEGREE                3
151 
152 #define CAM_COLOR_SPACE_BASE                    0
153 #define CAM_COLOR_SPACE_BT601_FULL              1
154 #define CAM_COLOR_SPACE_BT601625                2
155 #define CAM_COLOR_SPACE_BT601525                3
156 #define CAM_COLOR_SPACE_BT709                   4
157 #define CAM_COLOR_SPACE_DEPTH                   5
158 #define CAM_COLOR_SPACE_MAX                     6
159 
160 #define CAM_BUF_INPUT                           1
161 #define CAM_BUF_OUTPUT                          2
162 #define CAM_BUF_IN_OUT                          3
163 
164 #define CAM_PACKET_DEV_BASE                     0
165 #define CAM_PACKET_DEV_IMG_SENSOR               1
166 #define CAM_PACKET_DEV_ACTUATOR                 2
167 #define CAM_PACKET_DEV_COMPANION                3
168 #define CAM_PACKET_DEV_EEPOM                    4
169 #define CAM_PACKET_DEV_CSIPHY                   5
170 #define CAM_PACKET_DEV_OIS                      6
171 #define CAM_PACKET_DEV_FLASH                    7
172 #define CAM_PACKET_DEV_FD                       8
173 #define CAM_PACKET_DEV_JPEG_ENC                 9
174 #define CAM_PACKET_DEV_JPEG_DEC                 10
175 #define CAM_PACKET_DEV_VFE                      11
176 #define CAM_PACKET_DEV_CPP                      12
177 #define CAM_PACKET_DEV_CSID                     13
178 #define CAM_PACKET_DEV_ISPIF                    14
179 #define CAM_PACKET_DEV_IFE                      15
180 #define CAM_PACKET_DEV_ICP                      16
181 #define CAM_PACKET_DEV_LRME                     17
182 #define CAM_PACKET_DEV_MAX                      18
183 
184 
185 #define CAM_PACKET_MAX_PLANES                   3
186 
187 struct cam_plane_cfg {
188 	uint32_t                width;
189 	uint32_t                height;
190 	uint32_t                plane_stride;
191 	uint32_t                slice_height;
192 	uint32_t                meta_stride;
193 	uint32_t                meta_size;
194 	uint32_t                meta_offset;
195 	uint32_t                packer_config;
196 	uint32_t                mode_config;
197 	uint32_t                tile_config;
198 	uint32_t                h_init;
199 	uint32_t                v_init;
200 };
201 
202 struct cam_ubwc_plane_cfg_v1 {
203 	uint32_t                port_type;
204 	uint32_t                meta_stride;
205 	uint32_t                meta_size;
206 	uint32_t                meta_offset;
207 	uint32_t                packer_config;
208 	uint32_t                mode_config_0;
209 	uint32_t                mode_config_1;
210 	uint32_t                tile_config;
211 	uint32_t                h_init;
212 	uint32_t                v_init;
213 };
214 
215 struct cam_cmd_buf_desc {
216 	int32_t                 mem_handle;
217 	uint32_t                offset;
218 	uint32_t                size;
219 	uint32_t                length;
220 	uint32_t                type;
221 	uint32_t                meta_data;
222 };
223 
224 struct cam_buf_io_cfg {
225 	int32_t                         mem_handle[CAM_PACKET_MAX_PLANES];
226 	uint32_t                        offsets[CAM_PACKET_MAX_PLANES];
227 	struct cam_plane_cfg            planes[CAM_PACKET_MAX_PLANES];
228 	uint32_t                        format;
229 	uint32_t                        color_space;
230 	uint32_t                        color_pattern;
231 	uint32_t                        bpp;
232 	uint32_t                        rotation;
233 	uint32_t                        resource_type;
234 	int32_t                         fence;
235 	int32_t                         early_fence;
236 	struct cam_cmd_buf_desc         aux_cmd_buf;
237 	uint32_t                        direction;
238 	uint32_t                        batch_size;
239 	uint32_t                        subsample_pattern;
240 	uint32_t                        subsample_period;
241 	uint32_t                        framedrop_pattern;
242 	uint32_t                        framedrop_period;
243 	uint32_t                        flag;
244 	uint32_t                        padding;
245 };
246 
247 struct cam_packet_header {
248 	uint32_t                op_code;
249 	uint32_t                size;
250 	uint64_t                request_id;
251 	uint32_t                flags;
252 	uint32_t                padding;
253 };
254 
255 struct cam_patch_desc {
256 	int32_t                 dst_buf_hdl;
257 	uint32_t                dst_offset;
258 	int32_t                 src_buf_hdl;
259 	uint32_t                src_offset;
260 };
261 
262 struct cam_packet {
263 	struct cam_packet_header        header;
264 	uint32_t                        cmd_buf_offset;
265 	uint32_t                        num_cmd_buf;
266 	uint32_t                        io_configs_offset;
267 	uint32_t                        num_io_configs;
268 	uint32_t                        patch_offset;
269 	uint32_t                        num_patches;
270 	uint32_t                        kmd_cmd_buf_index;
271 	uint32_t                        kmd_cmd_buf_offset;
272 	uint64_t                        payload[1];
273 
274 };
275 
276 struct cam_release_dev_cmd {
277 	int32_t                 session_handle;
278 	int32_t                 dev_handle;
279 };
280 
281 struct cam_start_stop_dev_cmd {
282 	int32_t                 session_handle;
283 	int32_t                 dev_handle;
284 };
285 
286 struct cam_config_dev_cmd {
287 	int32_t                 session_handle;
288 	int32_t                 dev_handle;
289 	uint64_t                offset;
290 	uint64_t                packet_handle;
291 };
292 
293 struct cam_query_cap_cmd {
294 	uint32_t        size;
295 	uint32_t        handle_type;
296 	uint64_t        caps_handle;
297 };
298 
299 struct cam_acquire_dev_cmd {
300 	int32_t         session_handle;
301 	int32_t         dev_handle;
302 	uint32_t        handle_type;
303 	uint32_t        num_resources;
304 	uint64_t        resource_hdl;
305 };
306 
307 #define CAM_API_COMPAT_CONSTANT                   0xFEFEFEFE
308 
309 #define CAM_ACQUIRE_HW_STRUCT_VERSION_1           1
310 
311 struct cam_acquire_hw_cmd_v1 {
312 	uint32_t        struct_version;
313 	uint32_t        reserved;
314 	int32_t         session_handle;
315 	int32_t         dev_handle;
316 	uint32_t        handle_type;
317 	uint32_t        data_size;
318 	uint64_t        resource_hdl;
319 };
320 
321 #define CAM_RELEASE_HW_STRUCT_VERSION_1           1
322 
323 struct cam_release_hw_cmd_v1 {
324 	uint32_t                struct_version;
325 	uint32_t                reserved;
326 	int32_t                 session_handle;
327 	int32_t                 dev_handle;
328 };
329 
330 struct cam_flush_dev_cmd {
331 	uint64_t       version;
332 	int32_t        session_handle;
333 	int32_t        dev_handle;
334 	uint32_t       flush_type;
335 	uint32_t       reserved;
336 	int64_t        req_id;
337 };
338 
339 struct cam_ubwc_config {
340 	uint32_t   api_version;
341 	uint32_t   num_ports;
342 	struct cam_ubwc_plane_cfg_v1
343 		   ubwc_plane_cfg[1][CAM_PACKET_MAX_PLANES - 1];
344 };
345 
346 struct cam_cmd_mem_region_info {
347 	int32_t   mem_handle;
348 	uint32_t  offset;
349 	uint32_t  size;
350 	uint32_t  flags;
351 };
352 
353 struct cam_cmd_mem_regions {
354 	uint32_t version;
355 	uint32_t num_regions;
356 	struct cam_cmd_mem_region_info map_info_array[1];
357 };
358 
359 
360 #endif /* __UAPI_CAM_DEFS_H__ */
361