1 /*
2  * This file is auto-generated. Modifications will be lost.
3  *
4  * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5  * for more information.
6  */
7 #ifndef __UAPI_LINUX_CAM_REQ_MGR_H
8 #define __UAPI_LINUX_CAM_REQ_MGR_H
9 #include <linux/videodev2.h>
10 #include <linux/types.h>
11 #include <linux/ioctl.h>
12 #include <linux/media.h>
13 #include <media/cam_defs.h>
14 #define CAM_REQ_MGR_VNODE_NAME "cam-req-mgr-devnode"
15 #define CAM_DEVICE_TYPE_BASE (MEDIA_ENT_F_OLD_BASE)
16 #define CAM_VNODE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE)
17 #define CAM_SENSOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 1)
18 #define CAM_IFE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 2)
19 #define CAM_ICP_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 3)
20 #define CAM_LRME_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 4)
21 #define CAM_JPEG_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 5)
22 #define CAM_FD_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 6)
23 #define CAM_CPAS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 7)
24 #define CAM_CSIPHY_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 8)
25 #define CAM_ACTUATOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 9)
26 #define CAM_CCI_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 10)
27 #define CAM_FLASH_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 11)
28 #define CAM_EEPROM_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 12)
29 #define CAM_OIS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 13)
30 #define CAM_CUSTOM_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 14)
31 #define CAM_REQ_MGR_HDL_IDX_POS 8
32 #define CAM_REQ_MGR_HDL_IDX_MASK ((1 << CAM_REQ_MGR_HDL_IDX_POS) - 1)
33 #define CAM_REQ_MGR_GET_HDL_IDX(hdl) (hdl & CAM_REQ_MGR_HDL_IDX_MASK)
34 #define CAM_REQ_MGR_MAX_HANDLES 64
35 #define CAM_REQ_MGR_MAX_HANDLES_V2 128
36 #define MAX_LINKS_PER_SESSION 2
37 #define V4L_EVENT_CAM_REQ_MGR_EVENT (V4L2_EVENT_PRIVATE_START + 0)
38 #define V4L_EVENT_CAM_REQ_MGR_SOF 0
39 #define V4L_EVENT_CAM_REQ_MGR_ERROR 1
40 #define V4L_EVENT_CAM_REQ_MGR_SOF_BOOT_TS 2
41 #define V4L_EVENT_CAM_REQ_MGR_VSYNC_TS 3
42 #define V4L_EVENT_CAM_REQ_MGR_CUSTOM_EVT 4
43 #define CAM_REQ_MGR_SOF_EVENT_SUCCESS 0
44 #define CAM_REQ_MGR_SOF_EVENT_ERROR 1
45 #define CAM_REQ_MGR_LINK_ACTIVATE 0
46 #define CAM_REQ_MGR_LINK_DEACTIVATE 1
47 #define CAM_REQ_MGR_FLUSH_TYPE_ALL 0
48 #define CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ 1
49 #define CAM_REQ_MGR_FLUSH_TYPE_MAX 2
50 #define CAM_REQ_MGR_SYNC_MODE_NO_SYNC 0
51 #define CAM_REQ_MGR_SYNC_MODE_SYNC 1
52 struct cam_req_mgr_event_data {
53   int32_t session_hdl;
54   int32_t link_hdl;
55   int32_t frame_id;
56   int32_t reserved;
57   int64_t req_id;
58   uint64_t tv_sec;
59   uint64_t tv_usec;
60 };
61 struct cam_req_mgr_session_info {
62   int32_t session_hdl;
63   int32_t reserved;
64 };
65 struct cam_req_mgr_link_info {
66   int32_t session_hdl;
67   uint32_t num_devices;
68   int32_t dev_hdls[CAM_REQ_MGR_MAX_HANDLES];
69   int32_t link_hdl;
70 };
71 struct cam_req_mgr_link_info_v2 {
72   int32_t session_hdl;
73   uint32_t num_devices;
74   int32_t dev_hdls[CAM_REQ_MGR_MAX_HANDLES_V2];
75   int32_t link_hdl;
76 };
77 struct cam_req_mgr_ver_info {
78   uint32_t version;
79   union {
80     struct cam_req_mgr_link_info link_info_v1;
81     struct cam_req_mgr_link_info_v2 link_info_v2;
82   } u;
83 };
84 struct cam_req_mgr_unlink_info {
85   int32_t session_hdl;
86   int32_t link_hdl;
87 };
88 struct cam_req_mgr_flush_info {
89   int32_t session_hdl;
90   int32_t link_hdl;
91   uint32_t flush_type;
92   uint32_t reserved;
93   int64_t req_id;
94 };
95 struct cam_req_mgr_sched_request {
96   int32_t session_hdl;
97   int32_t link_hdl;
98   int32_t bubble_enable;
99   int32_t sync_mode;
100   int32_t additional_timeout;
101   int32_t reserved;
102   int64_t req_id;
103 };
104 struct cam_req_mgr_sync_mode {
105   int32_t session_hdl;
106   int32_t sync_mode;
107   int32_t num_links;
108   int32_t link_hdls[MAX_LINKS_PER_SESSION];
109   int32_t master_link_hdl;
110   int32_t reserved;
111 };
112 struct cam_req_mgr_link_control {
113   int32_t ops;
114   int32_t session_hdl;
115   int32_t num_links;
116   int32_t reserved;
117   int32_t link_hdls[MAX_LINKS_PER_SESSION];
118 };
119 #define CAM_REQ_MGR_CREATE_DEV_NODES (CAM_COMMON_OPCODE_MAX + 1)
120 #define CAM_REQ_MGR_CREATE_SESSION (CAM_COMMON_OPCODE_MAX + 2)
121 #define CAM_REQ_MGR_DESTROY_SESSION (CAM_COMMON_OPCODE_MAX + 3)
122 #define CAM_REQ_MGR_LINK (CAM_COMMON_OPCODE_MAX + 4)
123 #define CAM_REQ_MGR_UNLINK (CAM_COMMON_OPCODE_MAX + 5)
124 #define CAM_REQ_MGR_SCHED_REQ (CAM_COMMON_OPCODE_MAX + 6)
125 #define CAM_REQ_MGR_FLUSH_REQ (CAM_COMMON_OPCODE_MAX + 7)
126 #define CAM_REQ_MGR_SYNC_MODE (CAM_COMMON_OPCODE_MAX + 8)
127 #define CAM_REQ_MGR_ALLOC_BUF (CAM_COMMON_OPCODE_MAX + 9)
128 #define CAM_REQ_MGR_MAP_BUF (CAM_COMMON_OPCODE_MAX + 10)
129 #define CAM_REQ_MGR_RELEASE_BUF (CAM_COMMON_OPCODE_MAX + 11)
130 #define CAM_REQ_MGR_CACHE_OPS (CAM_COMMON_OPCODE_MAX + 12)
131 #define CAM_REQ_MGR_LINK_CONTROL (CAM_COMMON_OPCODE_MAX + 13)
132 #define CAM_REQ_MGR_LINK_V2 (CAM_COMMON_OPCODE_MAX + 14)
133 #define CAM_REQ_MGR_REQUEST_DUMP (CAM_COMMON_OPCODE_MAX + 15)
134 #define CAM_MEM_FLAG_HW_READ_WRITE (1 << 0)
135 #define CAM_MEM_FLAG_HW_READ_ONLY (1 << 1)
136 #define CAM_MEM_FLAG_HW_WRITE_ONLY (1 << 2)
137 #define CAM_MEM_FLAG_KMD_ACCESS (1 << 3)
138 #define CAM_MEM_FLAG_UMD_ACCESS (1 << 4)
139 #define CAM_MEM_FLAG_PROTECTED_MODE (1 << 5)
140 #define CAM_MEM_FLAG_CMD_BUF_TYPE (1 << 6)
141 #define CAM_MEM_FLAG_PIXEL_BUF_TYPE (1 << 7)
142 #define CAM_MEM_FLAG_STATS_BUF_TYPE (1 << 8)
143 #define CAM_MEM_FLAG_PACKET_BUF_TYPE (1 << 9)
144 #define CAM_MEM_FLAG_CACHE (1 << 10)
145 #define CAM_MEM_FLAG_HW_SHARED_ACCESS (1 << 11)
146 #define CAM_MEM_FLAG_CDSP_OUTPUT (1 << 12)
147 #define CAM_MEM_FLAG_DISABLE_DELAYED_UNMAP (1 << 13)
148 #define CAM_MEM_MMU_MAX_HANDLE 16
149 #define CAM_MEM_BUFQ_MAX 1024
150 #define CAM_MEM_MGR_SECURE_BIT_POS 15
151 #define CAM_MEM_MGR_HDL_IDX_SIZE 15
152 #define CAM_MEM_MGR_HDL_FD_SIZE 16
153 #define CAM_MEM_MGR_HDL_IDX_END_POS 16
154 #define CAM_MEM_MGR_HDL_FD_END_POS 32
155 #define CAM_MEM_MGR_HDL_IDX_MASK ((1 << CAM_MEM_MGR_HDL_IDX_SIZE) - 1)
156 #define GET_MEM_HANDLE(idx,fd) ((idx & CAM_MEM_MGR_HDL_IDX_MASK) | (fd << (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE)))
157 #define GET_FD_FROM_HANDLE(hdl) (hdl >> (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE))
158 #define CAM_MEM_MGR_GET_HDL_IDX(hdl) (hdl & CAM_MEM_MGR_HDL_IDX_MASK)
159 #define CAM_MEM_MGR_SET_SECURE_HDL(hdl,flag) ((flag) ? (hdl |= (1 << CAM_MEM_MGR_SECURE_BIT_POS)) : ((hdl) &= ~(1 << CAM_MEM_MGR_SECURE_BIT_POS)))
160 #define CAM_MEM_MGR_IS_SECURE_HDL(hdl) (((hdl) & (1 << CAM_MEM_MGR_SECURE_BIT_POS)) >> CAM_MEM_MGR_SECURE_BIT_POS)
161 #define CAM_MEM_DMA_NONE 0
162 #define CAM_MEM_DMA_BIDIRECTIONAL 1
163 #define CAM_MEM_DMA_TO_DEVICE 2
164 #define CAM_MEM_DMA_FROM_DEVICE 3
165 #define CAM_MEM_CLEAN_CACHE 1
166 #define CAM_MEM_INV_CACHE 2
167 #define CAM_MEM_CLEAN_INV_CACHE 3
168 struct cam_mem_alloc_out_params {
169   uint32_t buf_handle;
170   int32_t fd;
171   uint64_t vaddr;
172 };
173 struct cam_mem_map_out_params {
174   uint32_t buf_handle;
175   uint32_t reserved;
176   uint64_t vaddr;
177 };
178 struct cam_mem_mgr_alloc_cmd {
179   uint64_t len;
180   uint64_t align;
181   int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
182   uint32_t num_hdl;
183   uint32_t flags;
184   struct cam_mem_alloc_out_params out;
185 };
186 struct cam_mem_mgr_map_cmd {
187   int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
188   uint32_t num_hdl;
189   uint32_t flags;
190   int32_t fd;
191   uint32_t reserved;
192   struct cam_mem_map_out_params out;
193 };
194 struct cam_mem_mgr_release_cmd {
195   int32_t buf_handle;
196   uint32_t reserved;
197 };
198 struct cam_mem_cache_ops_cmd {
199   int32_t buf_handle;
200   uint32_t mem_cache_ops;
201 };
202 #define CAM_REQ_MGR_ERROR_TYPE_DEVICE 0
203 #define CAM_REQ_MGR_ERROR_TYPE_REQUEST 1
204 #define CAM_REQ_MGR_ERROR_TYPE_BUFFER 2
205 #define CAM_REQ_MGR_ERROR_TYPE_RECOVERY 3
206 #define CAM_REQ_MGR_ERROR_TYPE_SOF_FREEZE 4
207 #define CAM_REQ_MGR_ERROR_TYPE_FULL_RECOVERY 5
208 struct cam_req_mgr_error_msg {
209   uint32_t error_type;
210   uint32_t request_id;
211   int32_t device_hdl;
212   int32_t link_hdl;
213   uint64_t resource_size;
214 };
215 struct cam_req_mgr_frame_msg {
216   uint64_t request_id;
217   uint64_t frame_id;
218   uint64_t timestamp;
219   uint64_t bf_timestamp;
220   int32_t link_hdl;
221   uint32_t sof_status;
222   uint32_t frame_id_meta;
223   uint32_t reserved;
224 };
225 struct cam_req_mgr_custom_msg {
226   uint32_t custom_type;
227   uint64_t request_id;
228   uint64_t frame_id;
229   uint64_t timestamp;
230   int32_t link_hdl;
231   uint64_t custom_data;
232 };
233 struct cam_req_mgr_message {
234   int32_t session_hdl;
235   int32_t reserved;
236   union {
237     struct cam_req_mgr_error_msg err_msg;
238     struct cam_req_mgr_frame_msg frame_msg;
239     struct cam_req_mgr_custom_msg custom_msg;
240   } u;
241 };
242 #endif
243