blob: e073c5c8e90053b9f96b7c94e13280c95318d825 [file] [log] [blame]
Jing Zhou8184f312017-01-31 14:06:30 -08001#ifndef __UAPI_LINUX_CAM_REQ_MGR_H
2#define __UAPI_LINUX_CAM_REQ_MGR_H
3
4#include <linux/videodev2.h>
5#include <linux/types.h>
6#include <linux/ioctl.h>
7#include <linux/media.h>
8#include <media/cam_defs.h>
9
10#define CAM_REQ_MGR_VNODE_NAME "cam-req-mgr-devnode"
11
Viswanadha Raju Thotakura92928c22017-04-03 22:25:10 -070012#define CAM_DEVICE_TYPE_BASE (MEDIA_ENT_F_OLD_BASE)
13#define CAM_VNODE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE)
14#define CAM_SENSOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 1)
15#define CAM_IFE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 2)
16#define CAM_ICP_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 3)
17#define CAM_LRME_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 4)
18#define CAM_JPEG_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 5)
19#define CAM_FD_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 6)
20#define CAM_CPAS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 7)
21#define CAM_CSIPHY_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 8)
22#define CAM_ACTUATOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 9)
Viswanadha Raju Thotakuraca448672017-04-08 22:35:10 -070023#define CAM_CCI_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 10)
Jigarkumar Zaladb3f8492017-04-20 14:14:29 -070024#define CAM_FLASH_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 11)
Jing Zhou8184f312017-01-31 14:06:30 -080025
26/* cam_req_mgr hdl info */
27#define CAM_REQ_MGR_HDL_IDX_POS 8
28#define CAM_REQ_MGR_HDL_IDX_MASK ((1 << CAM_REQ_MGR_HDL_IDX_POS) - 1)
29#define CAM_REQ_MGR_GET_HDL_IDX(hdl) (hdl & CAM_REQ_MGR_HDL_IDX_MASK)
30
31/**
32 * Max handles supported by cam_req_mgr
33 * It includes both session and device handles
34 */
35#define CAM_REQ_MGR_MAX_HANDLES 64
36#define MAX_LINKS_PER_SESSION 2
37
38/* V4L event type which user space will subscribe to */
39#define V4L_EVENT_CAM_REQ_MGR_EVENT (V4L2_EVENT_PRIVATE_START + 0)
40
41/* Specific event ids to get notified in user space */
42#define V4L_EVENT_CAM_REQ_MGR_SOF 0
43#define V4L_EVENT_CAM_REQ_MGR_ERROR 1
44#define V4L_EVENT_CAM_REQ_MGR_MAX 2
45
Jing Zhoudedc4762017-06-19 17:45:36 +053046/* SOF Event status */
47#define CAM_REQ_MGR_SOF_EVENT_SUCCESS 0
48#define CAM_REQ_MGR_SOF_EVENT_ERROR 1
49
Jing Zhou8184f312017-01-31 14:06:30 -080050/**
51 * Request Manager : flush_type
52 * @CAM_REQ_MGR_FLUSH_TYPE_ALL: Req mgr will remove all the pending
53 * requests from input/processing queue.
54 * @CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ: Req mgr will remove only particular
55 * request id from input/processing queue.
56 * @CAM_REQ_MGR_FLUSH_TYPE_MAX: Max number of the flush type
57 * @opcode: CAM_REQ_MGR_FLUSH_REQ
58 */
59#define CAM_REQ_MGR_FLUSH_TYPE_ALL 0
60#define CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ 1
61#define CAM_REQ_MGR_FLUSH_TYPE_MAX 2
62
63/**
64 * struct cam_req_mgr_event_data
65 * @session_hdl: session handle
66 * @link_hdl: link handle
67 * @frame_id: frame id
68 * @reserved: reserved for 64 bit aligngment
69 * @req_id: request id
70 * @tv_sec: timestamp in seconds
71 * @tv_usec: timestamp in micro seconds
72 */
73struct cam_req_mgr_event_data {
74 int32_t session_hdl;
75 int32_t link_hdl;
76 int32_t frame_id;
77 int32_t reserved;
78 int64_t req_id;
79 uint64_t tv_sec;
80 uint64_t tv_usec;
81};
82
83/**
84 * struct cam_req_mgr_session_info
85 * @session_hdl: In/Output param - session_handle
86 * @opcode1: CAM_REQ_MGR_CREATE_SESSION
87 * @opcode2: CAM_REQ_MGR_DESTROY_SESSION
88 */
89struct cam_req_mgr_session_info {
90 int32_t session_hdl;
91 int32_t reserved;
92};
93
94/**
95 * struct cam_req_mgr_link_info
96 * @session_hdl: Input param - Identifier for CSL session
97 * @num_devices: Input Param - Num of devices to be linked
98 * @dev_hdls: Input param - List of device handles to be linked
99 * @link_hdl: Output Param -Identifier for link
100 * @opcode: CAM_REQ_MGR_LINK
101 */
102struct cam_req_mgr_link_info {
103 int32_t session_hdl;
104 uint32_t num_devices;
105 int32_t dev_hdls[CAM_REQ_MGR_MAX_HANDLES];
106 int32_t link_hdl;
107};
108
109/**
110 * struct cam_req_mgr_unlink_info
111 * @session_hdl: input param - session handle
112 * @link_hdl: input param - link handle
113 * @opcode: CAM_REQ_MGR_UNLINK
114 */
115struct cam_req_mgr_unlink_info {
116 int32_t session_hdl;
117 int32_t link_hdl;
118};
119
120/**
121 * struct cam_req_mgr_flush_info
122 * @brief: User can tell drivers to flush a particular request id or
123 * flush all requests from its pending processing queue. Flush is a
124 * blocking call and driver shall ensure all requests are flushed
125 * before returning.
126 * @session_hdl: Input param - Identifier for CSL session
127 * @link_hdl: Input Param -Identifier for link
128 * @flush_type: User can cancel a particular req id or can flush
129 * all requests in queue
130 * @reserved: reserved for 64 bit aligngment
131 * @req_id: field is valid only if flush type is cancel request
132 * for flush all this field value is not considered.
133 * @opcode: CAM_REQ_MGR_FLUSH_REQ
134 */
135struct cam_req_mgr_flush_info {
136 int32_t session_hdl;
137 int32_t link_hdl;
138 uint32_t flush_type;
139 uint32_t reserved;
140 int64_t req_id;
141};
142
143/** struct cam_req_mgr_sched_info
144 * @session_hdl: Input param - Identifier for CSL session
145 * @link_hdl: Input Param -Identifier for link
146 * inluding itself.
147 * @bubble_enable: Input Param - Cam req mgr will do bubble recovery if this
148 * flag is set.
149 * @reserved: reserved field for alignment
150 * @req_id: Input Param - Request Id from which all requests will be flushed
151 */
152struct cam_req_mgr_sched_request {
153 int32_t session_hdl;
154 int32_t link_hdl;
155 int32_t bubble_enable;
156 int32_t reserved;
157 int64_t req_id;
158};
159
160/**
161 * struct cam_req_mgr_sync_mode
162 * @session_hdl: Input param - Identifier for CSL session
163 * @sync_enable: Input Param -Enable sync mode or disable
164 * @num_links: Input Param - Num of links in sync mode (Valid only
165 * when sync_enable is TRUE)
166 * @link_hdls: Input Param - Array of link handles to be in sync mode
167 * (Valid only when sync_enable is TRUE)
168 * @master_link_hdl: Input Param - To dictate which link's SOF drives system
169 * (Valid only when sync_enable is TRUE)
170 *
171 * @opcode: CAM_REQ_MGR_SYNC_MODE
172 */
173struct cam_req_mgr_sync_mode {
174 int32_t session_hdl;
175 int32_t sync_enable;
176 int32_t num_links;
177 int32_t link_hdls[MAX_LINKS_PER_SESSION];
178 int32_t master_link_hdl;
179 int32_t reserved;
180};
181
182/**
183 * cam_req_mgr specific opcode ids
184 */
185#define CAM_REQ_MGR_CREATE_DEV_NODES (CAM_COMMON_OPCODE_MAX + 1)
186#define CAM_REQ_MGR_CREATE_SESSION (CAM_COMMON_OPCODE_MAX + 2)
187#define CAM_REQ_MGR_DESTROY_SESSION (CAM_COMMON_OPCODE_MAX + 3)
188#define CAM_REQ_MGR_LINK (CAM_COMMON_OPCODE_MAX + 4)
189#define CAM_REQ_MGR_UNLINK (CAM_COMMON_OPCODE_MAX + 5)
190#define CAM_REQ_MGR_SCHED_REQ (CAM_COMMON_OPCODE_MAX + 6)
191#define CAM_REQ_MGR_FLUSH_REQ (CAM_COMMON_OPCODE_MAX + 7)
192#define CAM_REQ_MGR_SYNC_MODE (CAM_COMMON_OPCODE_MAX + 8)
193#define CAM_REQ_MGR_ALLOC_BUF (CAM_COMMON_OPCODE_MAX + 9)
194#define CAM_REQ_MGR_MAP_BUF (CAM_COMMON_OPCODE_MAX + 10)
195#define CAM_REQ_MGR_RELEASE_BUF (CAM_COMMON_OPCODE_MAX + 11)
196#define CAM_REQ_MGR_CACHE_OPS (CAM_COMMON_OPCODE_MAX + 12)
Jing Zhou8184f312017-01-31 14:06:30 -0800197/* end of cam_req_mgr opcodes */
198
199#define CAM_MEM_FLAG_HW_READ_WRITE (1<<0)
200#define CAM_MEM_FLAG_HW_READ_ONLY (1<<1)
201#define CAM_MEM_FLAG_HW_WRITE_ONLY (1<<2)
202#define CAM_MEM_FLAG_KMD_ACCESS (1<<3)
203#define CAM_MEM_FLAG_UMD_ACCESS (1<<4)
204#define CAM_MEM_FLAG_PROTECTED_MODE (1<<5)
205#define CAM_MEM_FLAG_CMD_BUF_TYPE (1<<6)
206#define CAM_MEM_FLAG_PIXEL_BUF_TYPE (1<<7)
207#define CAM_MEM_FLAG_STATS_BUF_TYPE (1<<8)
208#define CAM_MEM_FLAG_PACKET_BUF_TYPE (1<<9)
209#define CAM_MEM_FLAG_CACHE (1<<10)
Seemanta Dutta1c827da2017-04-05 17:34:05 -0700210#define CAM_MEM_FLAG_HW_SHARED_ACCESS (1<<11)
Jing Zhou8184f312017-01-31 14:06:30 -0800211
212#define CAM_MEM_MMU_MAX_HANDLE 16
213
214/* Maximum allowed buffers in existence */
215#define CAM_MEM_BUFQ_MAX 1024
216
217#define CAM_MEM_MGR_HDL_IDX_SIZE 16
218#define CAM_MEM_MGR_HDL_FD_SIZE 16
219#define CAM_MEM_MGR_HDL_IDX_END_POS 16
220#define CAM_MEM_MGR_HDL_FD_END_POS 32
221
222#define CAM_MEM_MGR_HDL_IDX_MASK ((1 << CAM_MEM_MGR_HDL_IDX_SIZE) - 1)
223
224#define GET_MEM_HANDLE(idx, fd) \
225 ((idx << (CAM_MEM_MGR_HDL_IDX_END_POS - CAM_MEM_MGR_HDL_IDX_SIZE)) | \
226 (fd << (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE))) \
227
228#define CAM_MEM_MGR_GET_HDL_IDX(hdl) (hdl & CAM_MEM_MGR_HDL_IDX_MASK)
229
230/**
231 * memory allocation type
232 */
233#define CAM_MEM_DMA_NONE 0
234#define CAM_MEM_DMA_BIDIRECTIONAL 1
235#define CAM_MEM_DMA_TO_DEVICE 2
236#define CAM_MEM_DMA_FROM_DEVICE 3
237
238
239/**
240 * memory cache operation
241 */
242#define CAM_MEM_CLEAN_CACHE 1
243#define CAM_MEM_INV_CACHE 2
244#define CAM_MEM_CLEAN_INV_CACHE 3
245
246
247/**
248 * struct cam_mem_alloc_out_params
249 * @buf_handle: buffer handle
250 * @fd: output buffer file descriptor
251 * @vaddr: virtual address pointer
252 */
253struct cam_mem_alloc_out_params {
254 uint32_t buf_handle;
255 int32_t fd;
256 uint64_t vaddr;
257};
258
259/**
260 * struct cam_mem_map_out_params
261 * @buf_handle: buffer handle
262 * @reserved: reserved for future
263 * @vaddr: virtual address pointer
264 */
265struct cam_mem_map_out_params {
266 uint32_t buf_handle;
267 uint32_t reserved;
268 uint64_t vaddr;
269};
270
271/**
272 * struct cam_mem_mgr_alloc_cmd
273 * @len: size of buffer to allocate
274 * @align: alignment of the buffer
275 * @mmu_hdls: array of mmu handles
276 * @num_hdl: number of handles
277 * @flags: flags of the buffer
278 * @out: out params
279 */
280/* CAM_REQ_MGR_ALLOC_BUF */
281struct cam_mem_mgr_alloc_cmd {
282 uint64_t len;
283 uint64_t align;
284 int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
285 uint32_t num_hdl;
286 uint32_t flags;
287 struct cam_mem_alloc_out_params out;
288};
289
290/**
291 * struct cam_mem_mgr_map_cmd
292 * @mmu_hdls: array of mmu handles
293 * @num_hdl: number of handles
294 * @flags: flags of the buffer
295 * @fd: output buffer file descriptor
296 * @reserved: reserved field
297 * @out: out params
298 */
299
300/* CAM_REQ_MGR_MAP_BUF */
301struct cam_mem_mgr_map_cmd {
302 int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
303 uint32_t num_hdl;
304 uint32_t flags;
305 int32_t fd;
306 uint32_t reserved;
307 struct cam_mem_map_out_params out;
308};
309
310/**
311 * struct cam_mem_mgr_map_cmd
312 * @buf_handle: buffer handle
313 * @reserved: reserved field
314 */
315/* CAM_REQ_MGR_RELEASE_BUF */
316struct cam_mem_mgr_release_cmd {
317 int32_t buf_handle;
318 uint32_t reserved;
319};
320
321/**
322 * struct cam_mem_mgr_map_cmd
323 * @buf_handle: buffer handle
324 * @ops: cache operations
325 */
326/* CAM_REQ_MGR_CACHE_OPS */
327struct cam_mem_cache_ops_cmd {
328 int32_t buf_handle;
329 uint32_t mem_cache_ops;
330};
331
Seemanta Dutta85afac72017-05-05 11:45:57 -0700332/**
333 * Request Manager : error message type
334 * @CAM_REQ_MGR_ERROR_TYPE_DEVICE: Device error message, fatal to session
335 * @CAM_REQ_MGR_ERROR_TYPE_REQUEST: Error on a single request, not fatal
336 * @CAM_REQ_MGR_ERROR_TYPE_BUFFER: Buffer was not filled, not fatal
337 */
338#define CAM_REQ_MGR_ERROR_TYPE_DEVICE 0
339#define CAM_REQ_MGR_ERROR_TYPE_REQUEST 1
340#define CAM_REQ_MGR_ERROR_TYPE_BUFFER 2
341
342/**
343 * struct cam_req_mgr_error_msg
344 * @error_type: type of error
345 * @request_id: request id of frame
346 * @device_hdl: device handle
347 * @reserved: reserved field
348 * @resource_size: size of the resource
349 */
350struct cam_req_mgr_error_msg {
351 uint32_t error_type;
352 uint32_t request_id;
353 int32_t device_hdl;
354 int32_t reserved;
355 uint64_t resource_size;
356};
357
358/**
359 * struct cam_req_mgr_frame_msg
Jing Zhoudedc4762017-06-19 17:45:36 +0530360 * @request_id: request id of the frame
361 * @frame_id: frame id of the frame
362 * @timestamp: timestamp of the frame
363 * @link_hdl: link handle associated with this message
364 * @sof_status: sof status success or fail
Seemanta Dutta85afac72017-05-05 11:45:57 -0700365 */
366struct cam_req_mgr_frame_msg {
367 uint64_t request_id;
Jing Zhoudedc4762017-06-19 17:45:36 +0530368 uint64_t frame_id;
Seemanta Dutta85afac72017-05-05 11:45:57 -0700369 uint64_t timestamp;
Jing Zhoudedc4762017-06-19 17:45:36 +0530370 int32_t link_hdl;
371 uint32_t sof_status;
Seemanta Dutta85afac72017-05-05 11:45:57 -0700372};
373
374/**
375 * struct cam_req_mgr_message
376 * @session_hdl: session to which the frame belongs to
377 * @reserved: reserved field
378 * @u: union which can either be error or frame message
379 */
380struct cam_req_mgr_message {
381 int32_t session_hdl;
382 union {
383 struct cam_req_mgr_error_msg err_msg;
384 struct cam_req_mgr_frame_msg frame_msg;
385 } u;
386};
Jing Zhou8184f312017-01-31 14:06:30 -0800387#endif /* __UAPI_LINUX_CAM_REQ_MGR_H */