1 #ifndef __MSMB_PPROC_H
2 #define __MSMB_PPROC_H
3 
4 #ifdef MSM_CAMERA_BIONIC
5 #include <sys/types.h>
6 #endif
7 #ifdef CONFIG_COMPAT
8 #include <linux/compat.h>
9 #endif
10 #include <linux/videodev2.h>
11 #include <linux/types.h>
12 #include <media/msmb_generic_buf_mgr.h>
13 
14 /* Should be same as VIDEO_MAX_PLANES in videodev2.h */
15 #define MAX_PLANES VIDEO_MAX_PLANES
16 /* PARTIAL_FRAME_STRIPE_COUNT must be even */
17 #define PARTIAL_FRAME_STRIPE_COUNT 4
18 
19 #define MAX_NUM_CPP_STRIPS 8
20 #define MSM_CPP_MAX_NUM_PLANES 3
21 #define MSM_CPP_MIN_FRAME_LENGTH 13
22 #define MSM_CPP_MAX_FRAME_LENGTH 4096
23 #define MSM_CPP_MAX_FW_NAME_LEN 32
24 #define MAX_FREQ_TBL 10
25 
26 enum msm_cpp_frame_type {
27 	MSM_CPP_OFFLINE_FRAME,
28 	MSM_CPP_REALTIME_FRAME,
29 };
30 
31 enum msm_vpe_frame_type {
32 	MSM_VPE_OFFLINE_FRAME,
33 	MSM_VPE_REALTIME_FRAME,
34 };
35 
36 struct msm_cpp_buffer_info_t {
37 	int32_t fd;
38 	uint32_t index;
39 	uint32_t offset;
40 	uint8_t native_buff;
41 	uint8_t processed_divert;
42 	uint32_t identity;
43 };
44 
45 struct msm_cpp_stream_buff_info_t {
46 	uint32_t identity;
47 	uint32_t num_buffs;
48 	struct msm_cpp_buffer_info_t *buffer_info;
49 };
50 
51 enum msm_cpp_batch_mode_t {
52 	BATCH_MODE_NONE,
53 	BATCH_MODE_VIDEO,
54 	BATCH_MODE_PREVIEW
55 };
56 
57 struct msm_cpp_batch_info_t {
58 	enum msm_cpp_batch_mode_t  batch_mode;
59 	uint32_t batch_size;
60 	uint32_t intra_plane_offset[MAX_PLANES];
61 	uint32_t pick_preview_idx;
62 	uint32_t cont_idx;
63 };
64 
65 struct msm_cpp_frame_info_t {
66 	int32_t frame_id;
67 	struct timeval timestamp;
68 	uint32_t inst_id;
69 	uint32_t identity;
70 	uint32_t client_id;
71 	enum msm_cpp_frame_type frame_type;
72 	uint32_t num_strips;
73 	uint32_t msg_len;
74 	uint32_t *cpp_cmd_msg;
75 	int src_fd;
76 	int dst_fd;
77 	struct timeval in_time, out_time;
78 	void __user *cookie;
79 	int32_t *status;
80 	int32_t duplicate_output;
81 	uint32_t duplicate_identity;
82 	uint32_t feature_mask;
83 	uint8_t we_disable;
84 	struct msm_cpp_buffer_info_t input_buffer_info;
85 	struct msm_cpp_buffer_info_t output_buffer_info[8];
86 	struct msm_cpp_buffer_info_t duplicate_buffer_info;
87 	struct msm_cpp_buffer_info_t tnr_scratch_buffer_info[2];
88 	uint32_t reserved;
89 	uint8_t partial_frame_indicator;
90 	/* the followings are used only for partial_frame type
91 	 * and is only used for offline frame processing and
92 	 * only if payload big enough and need to be split into partial_frame
93 	 * if first_payload, kernel acquires output buffer
94 	 * first payload must have the last stripe
95 	 * buffer addresses from 0 to last_stripe_index are updated.
96 	 * kernel updates payload with msg_len and stripe_info
97 	 * kernel sends top level, plane level, then only stripes
98 	 * starting with first_stripe_index and
99 	 * ends with last_stripe_index
100 	 * kernel then sends trailing flag at frame done,
101 	 * if last payload, kernel queues the output buffer to HAL
102 	 */
103 	uint8_t first_payload;
104 	uint8_t last_payload;
105 	uint32_t first_stripe_index;
106 	uint32_t last_stripe_index;
107 	uint32_t stripe_info_offset;
108 	uint32_t stripe_info;
109 	struct msm_cpp_batch_info_t  batch_info;
110 };
111 
112 struct msm_cpp_pop_stream_info_t {
113 	int32_t frame_id;
114 	uint32_t identity;
115 };
116 
117 struct cpp_hw_info {
118 	uint32_t cpp_hw_version;
119 	uint32_t cpp_hw_caps;
120 	unsigned long freq_tbl[MAX_FREQ_TBL];
121 	uint32_t freq_tbl_count;
122 };
123 
124 struct msm_vpe_frame_strip_info {
125 	uint32_t src_w;
126 	uint32_t src_h;
127 	uint32_t dst_w;
128 	uint32_t dst_h;
129 	uint32_t src_x;
130 	uint32_t src_y;
131 	uint32_t phase_step_x;
132 	uint32_t phase_step_y;
133 	uint32_t phase_init_x;
134 	uint32_t phase_init_y;
135 };
136 
137 struct msm_vpe_buffer_info_t {
138 	int32_t fd;
139 	uint32_t index;
140 	uint32_t offset;
141 	uint8_t native_buff;
142 	uint8_t processed_divert;
143 };
144 
145 struct msm_vpe_stream_buff_info_t {
146 	uint32_t identity;
147 	uint32_t num_buffs;
148 	struct msm_vpe_buffer_info_t *buffer_info;
149 };
150 
151 struct msm_vpe_frame_info_t {
152 	int32_t frame_id;
153 	struct timeval timestamp;
154 	uint32_t inst_id;
155 	uint32_t identity;
156 	uint32_t client_id;
157 	enum msm_vpe_frame_type frame_type;
158 	struct msm_vpe_frame_strip_info strip_info;
159 	unsigned long src_fd;
160 	unsigned long dst_fd;
161 	struct ion_handle *src_ion_handle;
162 	struct ion_handle *dest_ion_handle;
163 	unsigned long src_phyaddr;
164 	unsigned long dest_phyaddr;
165 	unsigned long src_chroma_plane_offset;
166 	unsigned long dest_chroma_plane_offset;
167 	struct timeval in_time, out_time;
168 	void *cookie;
169 
170 	struct msm_vpe_buffer_info_t input_buffer_info;
171 	struct msm_vpe_buffer_info_t output_buffer_info;
172 };
173 
174 struct msm_pproc_queue_buf_info {
175 	struct msm_buf_mngr_info buff_mgr_info;
176 	uint8_t is_buf_dirty;
177 };
178 
179 struct msm_cpp_clock_settings_t {
180 	unsigned long clock_rate;
181 	uint64_t avg;
182 	uint64_t inst;
183 };
184 
185 #define VIDIOC_MSM_CPP_CFG \
186 	_IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_camera_v4l2_ioctl_t)
187 
188 #define VIDIOC_MSM_CPP_GET_EVENTPAYLOAD \
189 	_IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct msm_camera_v4l2_ioctl_t)
190 
191 #define VIDIOC_MSM_CPP_GET_INST_INFO \
192 	_IOWR('V', BASE_VIDIOC_PRIVATE + 2, struct msm_camera_v4l2_ioctl_t)
193 
194 #define VIDIOC_MSM_CPP_LOAD_FIRMWARE \
195 	_IOWR('V', BASE_VIDIOC_PRIVATE + 3, struct msm_camera_v4l2_ioctl_t)
196 
197 #define VIDIOC_MSM_CPP_GET_HW_INFO \
198 	_IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct msm_camera_v4l2_ioctl_t)
199 
200 #define VIDIOC_MSM_CPP_FLUSH_QUEUE \
201 	_IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct msm_camera_v4l2_ioctl_t)
202 
203 #define VIDIOC_MSM_CPP_ENQUEUE_STREAM_BUFF_INFO \
204 	_IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_camera_v4l2_ioctl_t)
205 
206 #define VIDIOC_MSM_CPP_DEQUEUE_STREAM_BUFF_INFO \
207 	_IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_v4l2_ioctl_t)
208 
209 #define VIDIOC_MSM_VPE_CFG \
210 	_IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_camera_v4l2_ioctl_t)
211 
212 #define VIDIOC_MSM_VPE_TRANSACTION_SETUP \
213 	_IOWR('V', BASE_VIDIOC_PRIVATE + 9, struct msm_camera_v4l2_ioctl_t)
214 
215 #define VIDIOC_MSM_VPE_GET_EVENTPAYLOAD \
216 	_IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct msm_camera_v4l2_ioctl_t)
217 
218 #define VIDIOC_MSM_VPE_GET_INST_INFO \
219 	_IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_camera_v4l2_ioctl_t)
220 
221 #define VIDIOC_MSM_VPE_ENQUEUE_STREAM_BUFF_INFO \
222 	_IOWR('V', BASE_VIDIOC_PRIVATE + 12, struct msm_camera_v4l2_ioctl_t)
223 
224 #define VIDIOC_MSM_VPE_DEQUEUE_STREAM_BUFF_INFO \
225 	_IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_camera_v4l2_ioctl_t)
226 
227 #define VIDIOC_MSM_CPP_QUEUE_BUF \
228 	_IOWR('V', BASE_VIDIOC_PRIVATE + 14, struct msm_camera_v4l2_ioctl_t)
229 
230 #define VIDIOC_MSM_CPP_APPEND_STREAM_BUFF_INFO \
231 	_IOWR('V', BASE_VIDIOC_PRIVATE + 15, struct msm_camera_v4l2_ioctl_t)
232 
233 #define VIDIOC_MSM_CPP_SET_CLOCK \
234 	_IOWR('V', BASE_VIDIOC_PRIVATE + 16, struct msm_camera_v4l2_ioctl_t)
235 
236 #define VIDIOC_MSM_CPP_POP_STREAM_BUFFER \
237 	_IOWR('V', BASE_VIDIOC_PRIVATE + 17, struct msm_camera_v4l2_ioctl_t)
238 
239 #define VIDIOC_MSM_CPP_IOMMU_ATTACH \
240 	_IOWR('V', BASE_VIDIOC_PRIVATE + 18, struct msm_camera_v4l2_ioctl_t)
241 
242 #define VIDIOC_MSM_CPP_IOMMU_DETACH \
243 	_IOWR('V', BASE_VIDIOC_PRIVATE + 19, struct msm_camera_v4l2_ioctl_t)
244 
245 #define VIDIOC_MSM_CPP_DELETE_STREAM_BUFF\
246 	_IOWR('V', BASE_VIDIOC_PRIVATE + 20, struct msm_camera_v4l2_ioctl_t)
247 
248 
249 #define V4L2_EVENT_CPP_FRAME_DONE  (V4L2_EVENT_PRIVATE_START + 0)
250 #define V4L2_EVENT_VPE_FRAME_DONE  (V4L2_EVENT_PRIVATE_START + 1)
251 
252 struct msm_camera_v4l2_ioctl_t {
253 	uint32_t id;
254 	size_t len;
255 	int32_t trans_code;
256 	void __user *ioctl_ptr;
257 };
258 
259 #ifdef CONFIG_COMPAT
260 struct msm_cpp_frame_info32_t {
261 	int32_t frame_id;
262 	struct compat_timeval timestamp;
263 	uint32_t inst_id;
264 	uint32_t identity;
265 	uint32_t client_id;
266 	enum msm_cpp_frame_type frame_type;
267 	uint32_t num_strips;
268 	uint32_t msg_len;
269 	compat_uint_t cpp_cmd_msg;
270 	int src_fd;
271 	int dst_fd;
272 	struct compat_timeval in_time, out_time;
273 	compat_caddr_t cookie;
274 	compat_int_t status;
275 	int32_t duplicate_output;
276 	uint32_t duplicate_identity;
277 	uint32_t feature_mask;
278 	uint8_t we_disable;
279 	struct msm_cpp_buffer_info_t input_buffer_info;
280 	struct msm_cpp_buffer_info_t output_buffer_info[8];
281 	struct msm_cpp_buffer_info_t duplicate_buffer_info;
282 	struct msm_cpp_buffer_info_t tnr_scratch_buffer_info[2];
283 	uint32_t reserved;
284 	uint8_t partial_frame_indicator;
285 	/* the followings are used only for partial_frame type
286 	 * and is only used for offline frame processing and
287 	 * only if payload big enough and need to be split into partial_frame
288 	 * if first_payload, kernel acquires output buffer
289 	 * first payload must have the last stripe
290 	 * buffer addresses from 0 to last_stripe_index are updated.
291 	 * kernel updates payload with msg_len and stripe_info
292 	 * kernel sends top level, plane level, then only stripes
293 	 * starting with first_stripe_index and
294 	 * ends with last_stripe_index
295 	 * kernel then sends trailing flag at frame done,
296 	 * if last payload, kernel queues the output buffer to HAL
297 	 */
298 	uint8_t first_payload;
299 	uint8_t last_payload;
300 	uint32_t first_stripe_index;
301 	uint32_t last_stripe_index;
302 	uint32_t stripe_info_offset;
303 	uint32_t stripe_info;
304 	struct msm_cpp_batch_info_t  batch_info;
305 };
306 
307 struct msm_cpp_clock_settings32_t {
308 	compat_long_t clock_rate;
309 	uint64_t avg;
310 	uint64_t inst;
311 };
312 
313 struct msm_cpp_stream_buff_info32_t {
314 	uint32_t identity;
315 	uint32_t num_buffs;
316 	compat_caddr_t buffer_info;
317 };
318 
319 struct msm_pproc_queue_buf_info32_t {
320 	struct msm_buf_mngr_info32_t buff_mgr_info;
321 	uint8_t is_buf_dirty;
322 };
323 
324 struct cpp_hw_info_32_t {
325 	uint32_t cpp_hw_version;
326 	uint32_t cpp_hw_caps;
327 	compat_long_t freq_tbl[MAX_FREQ_TBL];
328 	uint32_t freq_tbl_count;
329 };
330 
331 
332 #define VIDIOC_MSM_CPP_CFG32 \
333 	_IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_camera_v4l2_ioctl32_t)
334 
335 #define VIDIOC_MSM_CPP_GET_EVENTPAYLOAD32 \
336 	_IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct msm_camera_v4l2_ioctl32_t)
337 
338 #define VIDIOC_MSM_CPP_GET_INST_INFO32 \
339 	_IOWR('V', BASE_VIDIOC_PRIVATE + 2, struct msm_camera_v4l2_ioctl32_t)
340 
341 #define VIDIOC_MSM_CPP_LOAD_FIRMWARE32 \
342 	_IOWR('V', BASE_VIDIOC_PRIVATE + 3, struct msm_camera_v4l2_ioctl32_t)
343 
344 #define VIDIOC_MSM_CPP_GET_HW_INFO32 \
345 	_IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct msm_camera_v4l2_ioctl32_t)
346 
347 #define VIDIOC_MSM_CPP_FLUSH_QUEUE32 \
348 	_IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct msm_camera_v4l2_ioctl32_t)
349 
350 #define VIDIOC_MSM_CPP_ENQUEUE_STREAM_BUFF_INFO32 \
351 	_IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_camera_v4l2_ioctl32_t)
352 
353 #define VIDIOC_MSM_CPP_DEQUEUE_STREAM_BUFF_INFO32 \
354 	_IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_v4l2_ioctl32_t)
355 
356 #define VIDIOC_MSM_VPE_CFG32 \
357 	_IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_camera_v4l2_ioctl32_t)
358 
359 #define VIDIOC_MSM_VPE_TRANSACTION_SETUP32 \
360 	_IOWR('V', BASE_VIDIOC_PRIVATE + 9, struct msm_camera_v4l2_ioctl32_t)
361 
362 #define VIDIOC_MSM_VPE_GET_EVENTPAYLOAD32 \
363 	_IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct msm_camera_v4l2_ioctl32_t)
364 
365 #define VIDIOC_MSM_VPE_GET_INST_INFO32 \
366 	_IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_camera_v4l2_ioctl32_t)
367 
368 #define VIDIOC_MSM_VPE_ENQUEUE_STREAM_BUFF_INFO32 \
369 	_IOWR('V', BASE_VIDIOC_PRIVATE + 12, struct msm_camera_v4l2_ioctl32_t)
370 
371 #define VIDIOC_MSM_VPE_DEQUEUE_STREAM_BUFF_INFO32 \
372 	_IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_camera_v4l2_ioctl32_t)
373 
374 #define VIDIOC_MSM_CPP_QUEUE_BUF32 \
375 	_IOWR('V', BASE_VIDIOC_PRIVATE + 14, struct msm_camera_v4l2_ioctl32_t)
376 
377 #define VIDIOC_MSM_CPP_APPEND_STREAM_BUFF_INFO32 \
378 	_IOWR('V', BASE_VIDIOC_PRIVATE + 15, struct msm_camera_v4l2_ioctl32_t)
379 
380 #define VIDIOC_MSM_CPP_SET_CLOCK32 \
381 	_IOWR('V', BASE_VIDIOC_PRIVATE + 16, struct msm_camera_v4l2_ioctl32_t)
382 
383 #define VIDIOC_MSM_CPP_POP_STREAM_BUFFER32 \
384 	_IOWR('V', BASE_VIDIOC_PRIVATE + 17, struct msm_camera_v4l2_ioctl32_t)
385 
386 #define VIDIOC_MSM_CPP_IOMMU_ATTACH32 \
387 	_IOWR('V', BASE_VIDIOC_PRIVATE + 18, struct msm_camera_v4l2_ioctl32_t)
388 
389 #define VIDIOC_MSM_CPP_IOMMU_DETACH32 \
390 	_IOWR('V', BASE_VIDIOC_PRIVATE + 19, struct msm_camera_v4l2_ioctl32_t)
391 
392 #define VIDIOC_MSM_CPP_DELETE_STREAM_BUFF32\
393 	_IOWR('V', BASE_VIDIOC_PRIVATE + 20, struct msm_camera_v4l2_ioctl32_t)
394 
395 struct msm_camera_v4l2_ioctl32_t {
396 	uint32_t id;
397 	uint32_t len;
398 	int32_t trans_code;
399 	compat_caddr_t ioctl_ptr;
400 };
401 #endif
402 
403 #endif /* __MSMB_PPROC_H */
404