1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
|
/*
* Samsung Exynos5 SoC series FIMC-IS driver
*
* exynos5 fimc-is video functions
*
* Copyright (c) 2011 Samsung Electronics Co., Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef IS_VIDEO_H
#define IS_VIDEO_H
#include <linux/version.h>
#include <media/v4l2-ioctl.h>
#include "is-type.h"
#include "is-mem.h"
#include "is-framemgr.h"
#include "is-metadata.h"
#include "is-config.h"
/* configuration by linux kernel version */
/*
* sensor scenario (26 ~ 31 bit)
*/
#define SENSOR_SCN_MASK 0xFC000000
#define SENSOR_SCN_SHIFT 26
/*
* stream type
* [0] : No reprocessing type
* [1] : reprocessing type
*/
#define INPUT_STREAM_MASK 0x03000000
#define INPUT_STREAM_SHIFT 24
/*
* senosr position
* [0] : rear
* [1] : front
* [2] : rear2
* [3] : secure
*/
#define INPUT_POSITION_MASK 0x00FF0000
#define INPUT_POSITION_SHIFT 16
/*
* video index
* [x] : connected capture video node index
*/
#define INPUT_VINDEX_MASK 0x0000FF00
#define INPUT_VINDEX_SHIFT 8
/*
* input type
* [0] : memory input
* [1] : on the fly input
* [2] : pipe input
*/
#define INPUT_INTYPE_MASK 0x000000F0
#define INPUT_INTYPE_SHIFT 4
/*
* stream leader
* [0] : No stream leader
* [1] : stream leader
*/
#define INPUT_LEADER_MASK 0x0000000F
#define INPUT_LEADER_SHIFT 0
#define IS_MAX_NODES IS_STREAM_COUNT
#define IS_INVALID_BUF_INDEX 0xFF
#define VIDEO_SSX_READY_BUFFERS 0
#define VIDEO_3XS_READY_BUFFERS 0
#define VIDEO_3XC_READY_BUFFERS 0
#define VIDEO_3XP_READY_BUFFERS 0
#define VIDEO_3XF_READY_BUFFERS 0
#define VIDEO_3XG_READY_BUFFERS 0
#define VIDEO_IXS_READY_BUFFERS 0
#define VIDEO_IXC_READY_BUFFERS 0
#define VIDEO_IXP_READY_BUFFERS 0
#define VIDEO_IXT_READY_BUFFERS 0
#define VIDEO_IXG_READY_BUFFERS 0
#define VIDEO_IXV_READY_BUFFERS 0
#define VIDEO_IXW_READY_BUFFERS 0
#define VIDEO_MEXC_READY_BUFFERS 0
#define VIDEO_ORBXC_READY_BUFFERS 0
#define VIDEO_SCC_READY_BUFFERS 0
#define VIDEO_SCP_READY_BUFFERS 0
#define VIDEO_DXS_READY_BUFFERS 0
#define VIDEO_DXC_READY_BUFFERS 0
#define VIDEO_DCPXS_READY_BUFFERS 0
#define VIDEO_DCPXC_READY_BUFFERS 0
#define VIDEO_MXS_READY_BUFFERS 0
#define VIDEO_MXP_READY_BUFFERS 0
#define VIDEO_VRA_READY_BUFFERS 0
#define VIDEO_SSXVC0_READY_BUFFERS 0
#define VIDEO_SSXVC1_READY_BUFFERS 0
#define VIDEO_SSXVC2_READY_BUFFERS 0
#define VIDEO_SSXVC3_READY_BUFFERS 0
#define VIDEO_PAFXS_READY_BUFFERS 0
#define VIDEO_CLHXS_READY_BUFFERS 0
#define VIDEO_CLHXC_READY_BUFFERS 0
#define IS_VIDEO_NAME(name) ("exynos-is-"name)
#define IS_VIDEO_SSX_NAME IS_VIDEO_NAME("ss")
#define IS_VIDEO_PRE_NAME IS_VIDEO_NAME("pre")
#define IS_VIDEO_3XS_NAME(id) IS_VIDEO_NAME("3"#id"s")
#define IS_VIDEO_3XC_NAME(id) IS_VIDEO_NAME("3"#id"c")
#define IS_VIDEO_3XP_NAME(id) IS_VIDEO_NAME("3"#id"p")
#define IS_VIDEO_3XF_NAME(id) IS_VIDEO_NAME("3"#id"f")
#define IS_VIDEO_3XG_NAME(id) IS_VIDEO_NAME("3"#id"g")
#define IS_VIDEO_IXS_NAME(id) IS_VIDEO_NAME("i"#id"s")
#define IS_VIDEO_IXC_NAME(id) IS_VIDEO_NAME("i"#id"c")
#define IS_VIDEO_IXP_NAME(id) IS_VIDEO_NAME("i"#id"p")
#define IS_VIDEO_IXT_NAME(id) IS_VIDEO_NAME("i"#id"t")
#define IS_VIDEO_IXW_NAME(id) IS_VIDEO_NAME("i"#id"w")
#define IS_VIDEO_IXG_NAME(id) IS_VIDEO_NAME("i"#id"g")
#define IS_VIDEO_IXV_NAME(id) IS_VIDEO_NAME("i"#id"v")
#define IS_VIDEO_MEXC_NAME(id) IS_VIDEO_NAME("me"#id"c")
#define IS_VIDEO_ORBXC_NAME(id) IS_VIDEO_NAME("orb"#id"c")
#define IS_VIDEO_MXS_NAME(id) IS_VIDEO_NAME("m"#id"s")
#define IS_VIDEO_MXP_NAME(id) IS_VIDEO_NAME("m"#id"p")
#define IS_VIDEO_VRA_NAME IS_VIDEO_NAME("vra")
#define IS_VIDEO_SSXVC0_NAME(id) IS_VIDEO_NAME("ss"#id"vc0")
#define IS_VIDEO_SSXVC1_NAME(id) IS_VIDEO_NAME("ss"#id"vc1")
#define IS_VIDEO_SSXVC2_NAME(id) IS_VIDEO_NAME("ss"#id"vc2")
#define IS_VIDEO_SSXVC3_NAME(id) IS_VIDEO_NAME("ss"#id"vc3")
#define IS_VIDEO_PAFXS_NAME(id) IS_VIDEO_NAME("p"#id"s")
#define IS_VIDEO_CLHXS_NAME(id) IS_VIDEO_NAME("cl"#id"s")
#define IS_VIDEO_CLHXC_NAME(id) IS_VIDEO_NAME("cl"#id"c")
struct is_device_ischain;
struct is_subdev;
struct is_queue;
struct is_video_ctx;
struct is_resourcemgr;
/* sysfs variable for debug */
extern struct is_sysfs_debug sysfs_debug;
enum is_video_dev_num {
IS_VIDEO_SS0_NUM = 1,
IS_VIDEO_SS1_NUM,
IS_VIDEO_SS2_NUM,
IS_VIDEO_SS3_NUM,
IS_VIDEO_SS4_NUM,
IS_VIDEO_SS5_NUM,
IS_VIDEO_BNS_NUM,
IS_VIDEO_PRE_NUM = 9,
IS_VIDEO_30S_NUM = 10,
IS_VIDEO_30C_NUM,
IS_VIDEO_30P_NUM,
IS_VIDEO_30F_NUM,
IS_VIDEO_30G_NUM,
IS_VIDEO_31S_NUM = 20,
IS_VIDEO_31C_NUM,
IS_VIDEO_31P_NUM,
IS_VIDEO_31F_NUM,
IS_VIDEO_31G_NUM,
IS_VIDEO_I0S_NUM = 30,
IS_VIDEO_I0C_NUM,
IS_VIDEO_I0P_NUM,
IS_VIDEO_I0V_NUM,
IS_VIDEO_I0W_NUM,
IS_VIDEO_I0T_NUM,
IS_VIDEO_I0G_NUM,
IS_VIDEO_I1S_NUM = 40,
IS_VIDEO_I1C_NUM,
IS_VIDEO_I1P_NUM,
IS_VIDEO_I1T_NUM,
IS_VIDEO_ME0C_NUM = 48,
IS_VIDEO_ME1C_NUM = 49,
IS_VIDEO_DCP0S_NUM = 50, /* Master */
IS_VIDEO_DCP0C_NUM, /* Master Main Capture */
IS_VIDEO_DCP1S_NUM, /* Slave */
IS_VIDEO_DCP1C_NUM, /* Slave Main Capture */
IS_VIDEO_DCP2C_NUM, /* Disparity + Confidence + Master */
/* CAMERAPP_VIDEONODE_GDC = 55, should be reserved */
IS_VIDEO_DCP3C_NUM = 56, /* Master Sub Capture */
IS_VIDEO_DCP4C_NUM, /* Slave Sub Capture */
IS_VIDEO_SCC_NUM,
IS_VIDEO_SCP_NUM,
IS_VIDEO_M0S_NUM = 60,
IS_VIDEO_M1S_NUM,
IS_VIDEO_M0P_NUM = 70,
IS_VIDEO_M1P_NUM,
IS_VIDEO_M2P_NUM,
IS_VIDEO_M3P_NUM,
IS_VIDEO_M4P_NUM,
IS_VIDEO_M5P_NUM,
IS_VIDEO_VRA_NUM = 80,
IS_VIDEO_D0S_NUM = 90,
IS_VIDEO_D0C_NUM,
IS_VIDEO_D1S_NUM,
IS_VIDEO_D1C_NUM,
IS_VIDEO_CLH0S_NUM = 94,
IS_VIDEO_CLH0C_NUM,
IS_VIDEO_ORB0C_NUM,
IS_VIDEO_ORB1C_NUM,
/* 100~109 : this section was reserved by jpeg etc. */
IS_VIDEO_SS0VC0_NUM = 110,
IS_VIDEO_SS0VC1_NUM,
IS_VIDEO_SS0VC2_NUM,
IS_VIDEO_SS0VC3_NUM,
IS_VIDEO_SS1VC0_NUM,
IS_VIDEO_SS1VC1_NUM,
IS_VIDEO_SS1VC2_NUM,
IS_VIDEO_SS1VC3_NUM,
IS_VIDEO_SS2VC0_NUM,
IS_VIDEO_SS2VC1_NUM,
IS_VIDEO_SS2VC2_NUM,
IS_VIDEO_SS2VC3_NUM,
IS_VIDEO_SS3VC0_NUM,
IS_VIDEO_SS3VC1_NUM,
IS_VIDEO_SS3VC2_NUM,
IS_VIDEO_SS3VC3_NUM,
IS_VIDEO_SS4VC0_NUM,
IS_VIDEO_SS4VC1_NUM,
IS_VIDEO_SS4VC2_NUM,
IS_VIDEO_SS4VC3_NUM,
IS_VIDEO_SS5VC0_NUM,
IS_VIDEO_SS5VC1_NUM,
IS_VIDEO_SS5VC2_NUM,
IS_VIDEO_SS5VC3_NUM,
IS_VIDEO_PAF0S_NUM = 140,
IS_VIDEO_PAF1S_NUM,
IS_VIDEO_PAF2S_NUM,
IS_VIDEO_32S_NUM = 150,
IS_VIDEO_32C_NUM,
IS_VIDEO_32P_NUM,
IS_VIDEO_32F_NUM,
IS_VIDEO_32G_NUM,
IS_VIDEO_MAX_NUM
};
enum is_video_type {
IS_VIDEO_TYPE_LEADER,
IS_VIDEO_TYPE_CAPTURE,
};
enum is_video_state {
IS_VIDEO_CLOSE,
IS_VIDEO_OPEN,
IS_VIDEO_S_INPUT,
IS_VIDEO_S_FORMAT,
IS_VIDEO_S_BUFS,
IS_VIDEO_STOP,
IS_VIDEO_START,
};
enum is_queue_state {
IS_QUEUE_BUFFER_PREPARED,
IS_QUEUE_BUFFER_READY,
IS_QUEUE_STREAM_ON,
IS_QUEUE_NEED_TO_REMAP, /* need remapped DVA with specific attribute */
IS_QUEUE_NEED_TO_KMAP, /* need permanent KVA for image planes */
IS_QUEUE_NEED_TO_EXTMAP, /* need ext plane for thumbnai, histgram */
};
struct is_frame_cfg {
struct is_fmt *format;
enum v4l2_colorspace colorspace;
enum v4l2_quantization quantization;
ulong flip;
u32 width;
u32 height;
u32 hw_pixeltype;
u32 size[IS_MAX_PLANES];
u32 bytesperline[IS_MAX_PLANES];
};
struct is_queue_ops {
int (*start_streaming)(void *qdevice,
struct is_queue *queue);
int (*stop_streaming)(void *qdevice,
struct is_queue *queue);
int (*s_format)(void *qdevice,
struct is_queue *queue);
int (*request_bufs)(void *qdevice,
struct is_queue *queue,
u32 count);
};
struct is_video_ops {
int (*qbuf)(struct is_video_ctx *vctx,
struct v4l2_buffer *buf);
int (*dqbuf)(struct is_video_ctx *vctx,
struct v4l2_buffer *buf,
bool blocking);
int (*done)(struct is_video_ctx *vctx,
u32 index, u32 state);
};
struct is_queue {
struct vb2_queue *vbq;
const struct is_queue_ops *qops;
struct is_framemgr framemgr;
struct is_frame_cfg framecfg;
u32 buf_maxcount;
u32 buf_rdycount;
u32 buf_refcount;
dma_addr_t buf_dva[IS_MAX_BUFS][IS_MAX_PLANES];
ulong buf_kva[IS_MAX_BUFS][IS_MAX_PLANES];
/* for debugging */
u32 buf_req;
u32 buf_pre;
u32 buf_que;
u32 buf_com;
u32 buf_dqe;
u32 id;
char name[IS_STR_LEN];
unsigned long state;
};
struct is_video_ctx {
u32 instance; /* logical stream id */
struct is_queue queue;
u32 refcount;
unsigned long state;
void *device;
void *next_device;
void *subdev;
struct is_video *video;
const struct vb2_ops *vb2_ops;
const struct vb2_mem_ops *vb2_mem_ops;
const struct is_vb2_buf_ops *is_vb2_buf_ops;
struct is_video_ops vops;
#if defined(MEASURE_TIME) && defined(MONITOR_TIME)
unsigned long long time[TMQ_END];
unsigned long long time_total[TMQ_END];
unsigned long time_cnt;
#endif
};
struct is_video {
u32 id;
enum is_video_type type;
atomic_t refcount;
struct mutex lock;
struct video_device vd;
struct is_resourcemgr *resourcemgr;
const struct vb2_mem_ops *vb2_mem_ops;
const struct is_vb2_buf_ops *is_vb2_buf_ops;
void *alloc_ctx;
struct semaphore smp_multi_input;
bool try_smp;
};
/* video context operation */
int open_vctx(struct file *file,
struct is_video *video,
struct is_video_ctx **vctx,
u32 instance,
u32 id,
const char *name);
int close_vctx(struct file *file,
struct is_video *video,
struct is_video_ctx *vctx);
/* queue operation */
int is_queue_setup(struct is_queue *queue,
void *alloc_ctx,
unsigned int *num_planes,
unsigned int sizes[],
struct device *alloc_devs[]);
int is_queue_buffer_queue(struct is_queue *queue,
struct vb2_buffer *vb);
int is_queue_buffer_init(struct vb2_buffer *vb);
void is_queue_buffer_cleanup(struct vb2_buffer *vb);
int is_queue_buffer_prepare(struct vb2_buffer *vb);
void is_queue_wait_prepare(struct vb2_queue *vbq);
void is_queue_wait_finish(struct vb2_queue *vbq);
int is_queue_start_streaming(struct is_queue *queue,
void *qdevice);
int is_queue_stop_streaming(struct is_queue *queue,
void *qdevice);
void is_queue_buffer_finish(struct vb2_buffer *vb);
/* video operation */
int is_video_probe(struct is_video *video,
char *video_name,
u32 video_number,
u32 vfl_dir,
struct is_mem *mem,
struct v4l2_device *v4l2_dev,
const struct v4l2_file_operations *fops,
const struct v4l2_ioctl_ops *ioctl_ops);
int is_video_open(struct is_video_ctx *vctx,
void *device,
u32 buf_rdycount,
struct is_video *video,
const struct vb2_ops *vb2_ops,
const struct is_queue_ops *qops);
int is_video_close(struct is_video_ctx *vctx);
int is_video_s_input(struct file *file,
struct is_video_ctx *vctx);
int is_video_poll(struct file *file,
struct is_video_ctx *vctx,
struct poll_table_struct *wait);
int is_video_mmap(struct file *file,
struct is_video_ctx *vctx,
struct vm_area_struct *vma);
int is_video_reqbufs(struct file *file,
struct is_video_ctx *vctx,
struct v4l2_requestbuffers *request);
int is_video_querybuf(struct file *file,
struct is_video_ctx *vctx,
struct v4l2_buffer *buf);
int is_video_set_format_mplane(struct file *file,
struct is_video_ctx *vctx,
struct v4l2_format *format);
int is_video_qbuf(struct is_video_ctx *vctx,
struct v4l2_buffer *buf);
int is_video_dqbuf(struct is_video_ctx *vctx,
struct v4l2_buffer *buf,
bool blocking);
int is_video_prepare(struct file *file,
struct is_video_ctx *vctx,
struct v4l2_buffer *buf);
int is_video_streamon(struct file *file,
struct is_video_ctx *vctx,
enum v4l2_buf_type type);
int is_video_streamoff(struct file *file,
struct is_video_ctx *vctx,
enum v4l2_buf_type type);
int is_video_s_ctrl(struct file *file,
struct is_video_ctx *vctx,
struct v4l2_control *ctrl);
int is_video_buffer_done(struct is_video_ctx *vctx,
u32 index, u32 state);
struct is_fmt *is_find_format(u32 pixelformat, u32 pixel_size);
extern int is_pre_video_probe(void *data);
extern int is_ssx_video_probe(void *data);
extern int is_30s_video_probe(void *data);
extern int is_30c_video_probe(void *data);
extern int is_30p_video_probe(void *data);
extern int is_30f_video_probe(void *data);
extern int is_30g_video_probe(void *data);
extern int is_31s_video_probe(void *data);
extern int is_31c_video_probe(void *data);
extern int is_31p_video_probe(void *data);
extern int is_31f_video_probe(void *data);
extern int is_31g_video_probe(void *data);
extern int is_32s_video_probe(void *data);
extern int is_32c_video_probe(void *data);
extern int is_32p_video_probe(void *data);
extern int is_32f_video_probe(void *data);
extern int is_32g_video_probe(void *data);
extern int is_i0s_video_probe(void *data);
extern int is_i0c_video_probe(void *data);
extern int is_i0p_video_probe(void *data);
extern int is_i0t_video_probe(void *data);
extern int is_i0g_video_probe(void *data);
extern int is_i0v_video_probe(void *data);
extern int is_i0w_video_probe(void *data);
extern int is_i1s_video_probe(void *data);
extern int is_i1c_video_probe(void *data);
extern int is_i1p_video_probe(void *data);
extern int is_me0c_video_probe(void *data);
extern int is_me1c_video_probe(void *data);
extern int is_orb0c_video_probe(void *data);
extern int is_orb1c_video_probe(void *data);
extern int is_d0s_video_probe(void *data);
extern int is_d0c_video_probe(void *data);
extern int is_d1s_video_probe(void *data);
extern int is_d1c_video_probe(void *data);
extern int is_dcp0s_video_probe(void *data);
extern int is_dcp0c_video_probe(void *data);
extern int is_dcp1s_video_probe(void *data);
extern int is_dcp1c_video_probe(void *data);
extern int is_dcp2c_video_probe(void *data);
extern int is_dcp3c_video_probe(void *data);
extern int is_dcp4c_video_probe(void *data);
extern int is_scc_video_probe(void *data);
extern int is_scp_video_probe(void *data);
extern int is_m0s_video_probe(void *data);
extern int is_m1s_video_probe(void *data);
extern int is_m0p_video_probe(void *data);
extern int is_m1p_video_probe(void *data);
extern int is_m2p_video_probe(void *data);
extern int is_m3p_video_probe(void *data);
extern int is_m4p_video_probe(void *data);
extern int is_m5p_video_probe(void *data);
extern int is_vra_video_probe(void *data);
extern int is_ssxvc0_video_probe(void *data);
extern int is_ssxvc1_video_probe(void *data);
extern int is_ssxvc2_video_probe(void *data);
extern int is_ssxvc3_video_probe(void *data);
extern int is_paf0s_video_probe(void *data);
extern int is_paf1s_video_probe(void *data);
extern int is_paf2s_video_probe(void *data);
extern int is_cl0s_video_probe(void *data);
extern int is_cl0c_video_probe(void *data);
#define GET_VIDEO(vctx) (vctx ? (vctx)->video : NULL)
#define GET_QUEUE(vctx) (vctx ? &(vctx)->queue : NULL)
#define GET_FRAMEMGR(vctx) (vctx ? &(vctx)->queue.framemgr : NULL)
#define GET_DEVICE(vctx) (vctx ? (vctx)->device : NULL)
#ifdef CONFIG_USE_SENSOR_GROUP
#define GET_DEVICE_ISCHAIN(vctx) (vctx ? (((vctx)->next_device) ? (vctx)->next_device : (vctx)->device) : NULL)
#else
#define GET_DEVICE_ISCHAIN(vctx) GET_DEVICE(vctx)
#endif
#define CALL_QOPS(q, op, args...) (((q)->qops->op) ? ((q)->qops->op(args)) : 0)
#define CALL_VOPS(v, op, args...) ((v) && ((v)->vops.op) ? ((v)->vops.op(v, args)) : 0)
#endif
|