blob: b73675541a0c3445ce11ac21c3130a64c7e11521 [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
46/**
47 * Request Manager : flush_type
48 * @CAM_REQ_MGR_FLUSH_TYPE_ALL: Req mgr will remove all the pending
49 * requests from input/processing queue.
50 * @CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ: Req mgr will remove only particular
51 * request id from input/processing queue.
52 * @CAM_REQ_MGR_FLUSH_TYPE_MAX: Max number of the flush type
53 * @opcode: CAM_REQ_MGR_FLUSH_REQ
54 */
55#define CAM_REQ_MGR_FLUSH_TYPE_ALL 0
56#define CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ 1
57#define CAM_REQ_MGR_FLUSH_TYPE_MAX 2
58
59/**
60 * struct cam_req_mgr_event_data
61 * @session_hdl: session handle
62 * @link_hdl: link handle
63 * @frame_id: frame id
64 * @reserved: reserved for 64 bit aligngment
65 * @req_id: request id
66 * @tv_sec: timestamp in seconds
67 * @tv_usec: timestamp in micro seconds
68 */
69struct cam_req_mgr_event_data {
70 int32_t session_hdl;
71 int32_t link_hdl;
72 int32_t frame_id;
73 int32_t reserved;
74 int64_t req_id;
75 uint64_t tv_sec;
76 uint64_t tv_usec;
77};
78
79/**
80 * struct cam_req_mgr_session_info
81 * @session_hdl: In/Output param - session_handle
82 * @opcode1: CAM_REQ_MGR_CREATE_SESSION
83 * @opcode2: CAM_REQ_MGR_DESTROY_SESSION
84 */
85struct cam_req_mgr_session_info {
86 int32_t session_hdl;
87 int32_t reserved;
88};
89
90/**
91 * struct cam_req_mgr_link_info
92 * @session_hdl: Input param - Identifier for CSL session
93 * @num_devices: Input Param - Num of devices to be linked
94 * @dev_hdls: Input param - List of device handles to be linked
95 * @link_hdl: Output Param -Identifier for link
96 * @opcode: CAM_REQ_MGR_LINK
97 */
98struct cam_req_mgr_link_info {
99 int32_t session_hdl;
100 uint32_t num_devices;
101 int32_t dev_hdls[CAM_REQ_MGR_MAX_HANDLES];
102 int32_t link_hdl;
103};
104
105/**
106 * struct cam_req_mgr_unlink_info
107 * @session_hdl: input param - session handle
108 * @link_hdl: input param - link handle
109 * @opcode: CAM_REQ_MGR_UNLINK
110 */
111struct cam_req_mgr_unlink_info {
112 int32_t session_hdl;
113 int32_t link_hdl;
114};
115
116/**
117 * struct cam_req_mgr_flush_info
118 * @brief: User can tell drivers to flush a particular request id or
119 * flush all requests from its pending processing queue. Flush is a
120 * blocking call and driver shall ensure all requests are flushed
121 * before returning.
122 * @session_hdl: Input param - Identifier for CSL session
123 * @link_hdl: Input Param -Identifier for link
124 * @flush_type: User can cancel a particular req id or can flush
125 * all requests in queue
126 * @reserved: reserved for 64 bit aligngment
127 * @req_id: field is valid only if flush type is cancel request
128 * for flush all this field value is not considered.
129 * @opcode: CAM_REQ_MGR_FLUSH_REQ
130 */
131struct cam_req_mgr_flush_info {
132 int32_t session_hdl;
133 int32_t link_hdl;
134 uint32_t flush_type;
135 uint32_t reserved;
136 int64_t req_id;
137};
138
139/** struct cam_req_mgr_sched_info
140 * @session_hdl: Input param - Identifier for CSL session
141 * @link_hdl: Input Param -Identifier for link
142 * inluding itself.
143 * @bubble_enable: Input Param - Cam req mgr will do bubble recovery if this
144 * flag is set.
145 * @reserved: reserved field for alignment
146 * @req_id: Input Param - Request Id from which all requests will be flushed
147 */
148struct cam_req_mgr_sched_request {
149 int32_t session_hdl;
150 int32_t link_hdl;
151 int32_t bubble_enable;
152 int32_t reserved;
153 int64_t req_id;
154};
155
156/**
157 * struct cam_req_mgr_sync_mode
158 * @session_hdl: Input param - Identifier for CSL session
159 * @sync_enable: Input Param -Enable sync mode or disable
160 * @num_links: Input Param - Num of links in sync mode (Valid only
161 * when sync_enable is TRUE)
162 * @link_hdls: Input Param - Array of link handles to be in sync mode
163 * (Valid only when sync_enable is TRUE)
164 * @master_link_hdl: Input Param - To dictate which link's SOF drives system
165 * (Valid only when sync_enable is TRUE)
166 *
167 * @opcode: CAM_REQ_MGR_SYNC_MODE
168 */
169struct cam_req_mgr_sync_mode {
170 int32_t session_hdl;
171 int32_t sync_enable;
172 int32_t num_links;
173 int32_t link_hdls[MAX_LINKS_PER_SESSION];
174 int32_t master_link_hdl;
175 int32_t reserved;
176};
177
178/**
179 * cam_req_mgr specific opcode ids
180 */
181#define CAM_REQ_MGR_CREATE_DEV_NODES (CAM_COMMON_OPCODE_MAX + 1)
182#define CAM_REQ_MGR_CREATE_SESSION (CAM_COMMON_OPCODE_MAX + 2)
183#define CAM_REQ_MGR_DESTROY_SESSION (CAM_COMMON_OPCODE_MAX + 3)
184#define CAM_REQ_MGR_LINK (CAM_COMMON_OPCODE_MAX + 4)
185#define CAM_REQ_MGR_UNLINK (CAM_COMMON_OPCODE_MAX + 5)
186#define CAM_REQ_MGR_SCHED_REQ (CAM_COMMON_OPCODE_MAX + 6)
187#define CAM_REQ_MGR_FLUSH_REQ (CAM_COMMON_OPCODE_MAX + 7)
188#define CAM_REQ_MGR_SYNC_MODE (CAM_COMMON_OPCODE_MAX + 8)
189#define CAM_REQ_MGR_ALLOC_BUF (CAM_COMMON_OPCODE_MAX + 9)
190#define CAM_REQ_MGR_MAP_BUF (CAM_COMMON_OPCODE_MAX + 10)
191#define CAM_REQ_MGR_RELEASE_BUF (CAM_COMMON_OPCODE_MAX + 11)
192#define CAM_REQ_MGR_CACHE_OPS (CAM_COMMON_OPCODE_MAX + 12)
Jing Zhou8184f312017-01-31 14:06:30 -0800193/* end of cam_req_mgr opcodes */
194
195#define CAM_MEM_FLAG_HW_READ_WRITE (1<<0)
196#define CAM_MEM_FLAG_HW_READ_ONLY (1<<1)
197#define CAM_MEM_FLAG_HW_WRITE_ONLY (1<<2)
198#define CAM_MEM_FLAG_KMD_ACCESS (1<<3)
199#define CAM_MEM_FLAG_UMD_ACCESS (1<<4)
200#define CAM_MEM_FLAG_PROTECTED_MODE (1<<5)
201#define CAM_MEM_FLAG_CMD_BUF_TYPE (1<<6)
202#define CAM_MEM_FLAG_PIXEL_BUF_TYPE (1<<7)
203#define CAM_MEM_FLAG_STATS_BUF_TYPE (1<<8)
204#define CAM_MEM_FLAG_PACKET_BUF_TYPE (1<<9)
205#define CAM_MEM_FLAG_CACHE (1<<10)
Seemanta Dutta1c827da2017-04-05 17:34:05 -0700206#define CAM_MEM_FLAG_HW_SHARED_ACCESS (1<<11)
Jing Zhou8184f312017-01-31 14:06:30 -0800207
208#define CAM_MEM_MMU_MAX_HANDLE 16
209
210/* Maximum allowed buffers in existence */
211#define CAM_MEM_BUFQ_MAX 1024
212
213#define CAM_MEM_MGR_HDL_IDX_SIZE 16
214#define CAM_MEM_MGR_HDL_FD_SIZE 16
215#define CAM_MEM_MGR_HDL_IDX_END_POS 16
216#define CAM_MEM_MGR_HDL_FD_END_POS 32
217
218#define CAM_MEM_MGR_HDL_IDX_MASK ((1 << CAM_MEM_MGR_HDL_IDX_SIZE) - 1)
219
220#define GET_MEM_HANDLE(idx, fd) \
221 ((idx << (CAM_MEM_MGR_HDL_IDX_END_POS - CAM_MEM_MGR_HDL_IDX_SIZE)) | \
222 (fd << (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE))) \
223
224#define CAM_MEM_MGR_GET_HDL_IDX(hdl) (hdl & CAM_MEM_MGR_HDL_IDX_MASK)
225
226/**
227 * memory allocation type
228 */
229#define CAM_MEM_DMA_NONE 0
230#define CAM_MEM_DMA_BIDIRECTIONAL 1
231#define CAM_MEM_DMA_TO_DEVICE 2
232#define CAM_MEM_DMA_FROM_DEVICE 3
233
234
235/**
236 * memory cache operation
237 */
238#define CAM_MEM_CLEAN_CACHE 1
239#define CAM_MEM_INV_CACHE 2
240#define CAM_MEM_CLEAN_INV_CACHE 3
241
242
243/**
244 * struct cam_mem_alloc_out_params
245 * @buf_handle: buffer handle
246 * @fd: output buffer file descriptor
247 * @vaddr: virtual address pointer
248 */
249struct cam_mem_alloc_out_params {
250 uint32_t buf_handle;
251 int32_t fd;
252 uint64_t vaddr;
253};
254
255/**
256 * struct cam_mem_map_out_params
257 * @buf_handle: buffer handle
258 * @reserved: reserved for future
259 * @vaddr: virtual address pointer
260 */
261struct cam_mem_map_out_params {
262 uint32_t buf_handle;
263 uint32_t reserved;
264 uint64_t vaddr;
265};
266
267/**
268 * struct cam_mem_mgr_alloc_cmd
269 * @len: size of buffer to allocate
270 * @align: alignment of the buffer
271 * @mmu_hdls: array of mmu handles
272 * @num_hdl: number of handles
273 * @flags: flags of the buffer
274 * @out: out params
275 */
276/* CAM_REQ_MGR_ALLOC_BUF */
277struct cam_mem_mgr_alloc_cmd {
278 uint64_t len;
279 uint64_t align;
280 int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
281 uint32_t num_hdl;
282 uint32_t flags;
283 struct cam_mem_alloc_out_params out;
284};
285
286/**
287 * struct cam_mem_mgr_map_cmd
288 * @mmu_hdls: array of mmu handles
289 * @num_hdl: number of handles
290 * @flags: flags of the buffer
291 * @fd: output buffer file descriptor
292 * @reserved: reserved field
293 * @out: out params
294 */
295
296/* CAM_REQ_MGR_MAP_BUF */
297struct cam_mem_mgr_map_cmd {
298 int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
299 uint32_t num_hdl;
300 uint32_t flags;
301 int32_t fd;
302 uint32_t reserved;
303 struct cam_mem_map_out_params out;
304};
305
306/**
307 * struct cam_mem_mgr_map_cmd
308 * @buf_handle: buffer handle
309 * @reserved: reserved field
310 */
311/* CAM_REQ_MGR_RELEASE_BUF */
312struct cam_mem_mgr_release_cmd {
313 int32_t buf_handle;
314 uint32_t reserved;
315};
316
317/**
318 * struct cam_mem_mgr_map_cmd
319 * @buf_handle: buffer handle
320 * @ops: cache operations
321 */
322/* CAM_REQ_MGR_CACHE_OPS */
323struct cam_mem_cache_ops_cmd {
324 int32_t buf_handle;
325 uint32_t mem_cache_ops;
326};
327
328#endif /* __UAPI_LINUX_CAM_REQ_MGR_H */