-
Notifications
You must be signed in to change notification settings - Fork 9
/
SONiX_UVC_TestAP.c
3559 lines (3059 loc) · 107 KB
/
SONiX_UVC_TestAP.c
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
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* test.c -- USB Video Class test application
*
* Copyright (C) 2005-2008
* Laurent Pinchart ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*/
/*
* WARNING: This is just a test application. Don't fill bug reports, flame me,
* curse me on 7 generations :-).
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <getopt.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/select.h>
#include <sys/time.h> //for timestamp incomplete error in kernel 2.6.21
#include <linux/videodev2.h>
#include <linux/version.h>
#include <sys/utsname.h>
#include <pthread.h>
#include "v4l2uvc.h"
#include "sonix_xu_ctrls.h"
#include "nalu.h"
#include "debug.h"
#include "cap_desc_parser.h"
#include "cap_desc.h"
#define TESTAP_VERSION "v1.0.22_SONiX_UVC_TestAP_Multi"
#ifndef min
#define min(x,y) (((x)<(y))?(x):(y))
#endif
#ifndef V4L2_PIX_FMT_H264
#define V4L2_PIX_FMT_H264 v4l2_fourcc('H','2','6','4') /* H264 */
#endif
#ifndef V4L2_PIX_FMT_MP2T
#define V4L2_PIX_FMT_MP2T v4l2_fourcc('M','P','2','T') /* MPEG-2 TS */
#endif
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) ((a)<<16+(b)<<8+(c))
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION (2,6,32)
#define V4L_BUFFERS_DEFAULT 6//16
#define V4L_BUFFERS_MAX 16//32
#else
#define V4L_BUFFERS_DEFAULT 3
#define V4L_BUFFERS_MAX 3
#endif
// chris +
#define H264_SIZE_HD ((1280<<16)|720)
#define H264_SIZE_VGA ((640<<16)|480)
#define H264_SIZE_QVGA ((320<<16)|240)
#define H264_SIZE_QQVGA ((160<<16)|112)
#define H264_SIZE_360P ((640<<16)|360)
#define H264_SIZE_180P ((320<<16)|180)
#define MULTI_STREAM_HD_QVGA 0x01
#define MULTI_STREAM_HD_180P 0x02
#define MULTI_STREAM_HD_360P 0x04
#define MULTI_STREAM_HD_VGA 0x08
#define MULTI_STREAM_HD_QVGA_VGA 0x10
#define MULTI_STREAM_QVGA_VGA 0x20
#define MULTI_STREAM_HD_180P_360P 0x40
#define MULTI_STREAM_360P_180P 0x80
// chris -
struct H264Format *gH264fmt = NULL;
int Dbg_Param = 0x1f;
struct thread_parameter
{
struct v4l2_buffer *buf;
void *mem[16];
int *dev;
unsigned int *nframes ;
unsigned char multi_stream_mjpg_enable;
};
typedef struct _still_info{
int width;
int height;
unsigned int format;
}still_info;
typedef struct _sf_cmd{
unsigned int addr;
unsigned int length;
}sf_cmd_t;
typedef struct _i2c_cmd{
unsigned char SlaveId;
unsigned int addr;
unsigned int addr_length;
unsigned char data[5];
unsigned int data_length;
}i2c_cmd_t;
#if 0
static void pantilt(int dev, char *dir, char *length)
{
struct v4l2_ext_control xctrls[2];
struct v4l2_ext_controls ctrls;
unsigned int angle = atoi(length);
char directions[9][2] = {
{ -1, 1 },
{ 0, 1 },
{ 1, 1 },
{ -1, 0 },
{ 0, 0 },
{ 1, 0 },
{ -1, -1 },
{ 0, -1 },
{ 1, -1 },
};
if (dir[0] == '5') {
xctrls[0].id = V4L2_CID_PANTILT_RESET;
xctrls[0].value = angle;
ctrls.count = 1;
ctrls.controls = xctrls;
} else {
xctrls[0].id = V4L2_CID_PAN_RELATIVE;
xctrls[0].value = directions[dir[0] - '1'][0] * angle;
xctrls[1].id = V4L2_CID_TILT_RELATIVE;
xctrls[1].value = directions[dir[0] - '1'][1] * angle;
ctrls.count = 2;
ctrls.controls = xctrls;
}
ioctl(dev, VIDIOC_S_EXT_CTRLS, &ctrls);
}
#endif
static int GetFreeRam(int* freeram)
{
FILE *meminfo = fopen("/proc/meminfo", "r");
char line[256];
if(meminfo == NULL)
{
TestAp_Printf(TESTAP_DBG_ERR, "/proc/meminfo can't open\n");
return 0;
}
while(fgets(line, sizeof(line), meminfo))
{
if(sscanf(line, "MemFree: %d kB", freeram) == 1)
{
*freeram <<= 10;
fclose(meminfo);
return 1;
}
}
fclose(meminfo);
return 0;
}
static int get_vendor_verson(int dev, unsigned char szFlashVendorVer[12])
{
return XU_SF_Read(dev, 0x154, szFlashVendorVer, 12);
}
static int video_open(const char *devname)
{
struct v4l2_capability cap;
int dev, ret;
dev = open(devname, O_RDWR);
if (dev < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Error opening device %s: %d.\n", devname, errno);
return dev;
}
memset(&cap, 0, sizeof cap);
ret = ioctl(dev, VIDIOC_QUERYCAP, &cap);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Error opening device %s: unable to query device.\n",
devname);
close(dev);
return ret;
}
#if 0
if ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Error opening device %s: video capture not supported.\n",
devname);
close(dev);
return -EINVAL;
}
#endif
printf( "Device %s opened: %s.\n", devname, cap.card);
return dev;
}
static void uvc_set_control(int dev, unsigned int id, int value)
{
struct v4l2_control ctrl;
int ret;
ctrl.id = id;
ctrl.value = value;
ret = ioctl(dev, VIDIOC_S_CTRL, &ctrl);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "unable to set gain control: %s (%d).\n",
strerror(errno), errno);
return;
}
}
static int video_set_format(int dev, unsigned int w, unsigned int h, unsigned int format)
{
struct v4l2_format fmt;
int ret;
memset(&fmt, 0, sizeof fmt);
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.width = w;
fmt.fmt.pix.height = h;
fmt.fmt.pix.pixelformat = format;
fmt.fmt.pix.field = V4L2_FIELD_ANY;
ret = ioctl(dev, VIDIOC_S_FMT, &fmt);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to set format: %d.\n", errno);
return ret;
}
TestAp_Printf(TESTAP_DBG_FLOW, "Video format set: width: %u height: %u buffer size: %u\n",
fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.sizeimage);
return 0;
}
static int video_set_still_format(int dev, unsigned int w, unsigned int h, unsigned int format)
{
struct v4l2_format fmt;
int ret;
memset(&fmt, 0, sizeof fmt);
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.width = w;
fmt.fmt.pix.height = h;
fmt.fmt.pix.pixelformat = format;
fmt.fmt.pix.field = V4L2_FIELD_ANY;
if(GetKernelVersion()> KERNEL_VERSION (3, 0, 36))
ret = ioctl(dev, UVCIOC_STILL_S_FMT_KNL3, &fmt);
else
ret = ioctl(dev, UVCIOC_STILL_S_FMT_KNL2, &fmt);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to set still format: %d.\n", errno);
if(errno == EINVAL)
TestAp_Printf(TESTAP_DBG_ERR, "still function doesn't support?(%d)\n", errno);
return ret;
}
TestAp_Printf(TESTAP_DBG_FLOW, "still format set: width: %u height: %u buffer size: %u\n",
fmt.fmt.pix.width, fmt.fmt.pix.height, fmt.fmt.pix.sizeimage);
return 0;
}
static int video_set_framerate(int dev, int framerate, unsigned int *MaxPayloadTransferSize)
{
struct v4l2_streamparm parm;
int ret;
memset(&parm, 0, sizeof parm);
parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
ret = ioctl(dev, VIDIOC_G_PARM, &parm);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to get frame rate: %d.\n", errno);
return ret;
}
TestAp_Printf(TESTAP_DBG_FLOW, "Current frame rate: %u/%u\n",
parm.parm.capture.timeperframe.numerator,
parm.parm.capture.timeperframe.denominator);
parm.parm.capture.timeperframe.numerator = 1;
parm.parm.capture.timeperframe.denominator = framerate;
ret = ioctl(dev, VIDIOC_S_PARM, &parm);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to set frame rate: %d.\n", errno);
return ret;
}
//yiling: get MaxPayloadTransferSize from sonix driver
if(MaxPayloadTransferSize)
*MaxPayloadTransferSize = parm.parm.capture.reserved[0];
ret = ioctl(dev, VIDIOC_G_PARM, &parm);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to get frame rate: %d.\n", errno);
return ret;
}
TestAp_Printf(TESTAP_DBG_FLOW, "Frame rate set: %u/%u\n",
parm.parm.capture.timeperframe.numerator,
parm.parm.capture.timeperframe.denominator);
return 0;
}
int video_get_framerate(int dev, int *framerate)
{
struct v4l2_streamparm parm;
int ret;
memset(&parm, 0, sizeof parm);
parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
ret = ioctl(dev, VIDIOC_G_PARM, &parm);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to get frame rate: %d.\n", errno);
return ret;
}
TestAp_Printf(TESTAP_DBG_FLOW, "Current frame rate: %u/%u\n",
parm.parm.capture.timeperframe.numerator,
parm.parm.capture.timeperframe.denominator);
*framerate = parm.parm.capture.timeperframe.denominator;
return 0;
}
static int video_reqbufs(int dev, int nbufs)
{
struct v4l2_requestbuffers rb;
int ret;
memset(&rb, 0, sizeof rb);
rb.count = nbufs;
rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
rb.memory = V4L2_MEMORY_MMAP;
ret = ioctl(dev, VIDIOC_REQBUFS, &rb);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to allocate buffers: %d.\n", errno);
return ret;
}
TestAp_Printf(TESTAP_DBG_FLOW, "%u buffers allocated.\n", rb.count);
return rb.count;
}
static int video_req_still_buf(int dev)
{
struct v4l2_requestbuffers rb;
int ret;
memset(&rb, 0, sizeof rb);
rb.count = 1;
rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
rb.memory = V4L2_MEMORY_MMAP;
if(GetKernelVersion()> KERNEL_VERSION (3, 0, 36))
ret = ioctl(dev, UVCIOC_STILL_REQBUF_KNL3, &rb);
else
ret = ioctl(dev, UVCIOC_STILL_REQBUF_KNL2, &rb);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to allocate still buffers: %d.\n", errno);
return ret;
}
TestAp_Printf(TESTAP_DBG_FLOW, "still buffers allocated.\n");
return rb.count;
}
static int video_enable(int dev, int enable)
{
int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
int ret;
ret = ioctl(dev, enable ? VIDIOC_STREAMON : VIDIOC_STREAMOFF, &type);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to %s capture: %d.\n",
enable ? "start" : "stop", errno);
return ret;
}
return 0;
}
static void video_query_menu(int dev, unsigned int id)
{
struct v4l2_querymenu menu;
int ret;
menu.index = 0;
while (1) {
menu.id = id;
ret = ioctl(dev, VIDIOC_QUERYMENU, &menu);
if (ret < 0)
break;
TestAp_Printf(TESTAP_DBG_FLOW, " %u: %.32s\n", menu.index, menu.name);
menu.index++;
};
}
static void video_list_controls(int dev)
{
struct v4l2_queryctrl query;
struct v4l2_control ctrl;
char value[12];
int ret;
#ifndef V4L2_CTRL_FLAG_NEXT_CTRL
unsigned int i;
for (i = V4L2_CID_BASE; i <= V4L2_CID_LASTP1; ++i) {
query.id = i;
#else
query.id = 0;
while (1) {
query.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
#endif
ret = ioctl(dev, VIDIOC_QUERYCTRL, &query);
if (ret < 0)
break;
if (query.flags & V4L2_CTRL_FLAG_DISABLED)
continue;
ctrl.id = query.id;
ret = ioctl(dev, VIDIOC_G_CTRL, &ctrl);
if (ret < 0)
strcpy(value, "n/a");
else
sprintf(value, "%d", ctrl.value);
TestAp_Printf(TESTAP_DBG_FLOW, "control 0x%08x %s min %d max %d step %d default %d current %s.\n",
query.id, query.name, query.minimum, query.maximum,
query.step, query.default_value, value);
if (query.type == V4L2_CTRL_TYPE_MENU)
video_query_menu(dev, query.id);
}
}
static void video_enum_inputs(int dev)
{
struct v4l2_input input;
unsigned int i;
int ret;
for (i = 0; ; ++i) {
memset(&input, 0, sizeof input);
input.index = i;
ret = ioctl(dev, VIDIOC_ENUMINPUT, &input);
if (ret < 0)
break;
if (i != input.index)
TestAp_Printf(TESTAP_DBG_FLOW, "Warning: driver returned wrong input index "
"%u.\n", input.index);
TestAp_Printf(TESTAP_DBG_FLOW, "Input %u: %s.\n", i, input.name);
}
}
static int video_get_input(int dev)
{
__u32 input;
int ret;
ret = ioctl(dev, VIDIOC_G_INPUT, &input);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to get current input: %s.\n", strerror(errno));
return ret;
}
return input;
}
static int video_set_input(int dev, unsigned int input)
{
__u32 _input = input;
int ret;
ret = ioctl(dev, VIDIOC_S_INPUT, &_input);
if (ret < 0)
TestAp_Printf(TESTAP_DBG_ERR, "Unable to select input %u: %s.\n", input,
strerror(errno));
return ret;
}
static void Enum_MaxPayloadTransSize(char *dev_name)
{
struct CapabiltyBinaryData CapData;
struct CapabilityDescriptor Cap_Desc;
struct InterfaceDesc Interface[2], Interface_tmp;
int i, j,k,l;
int ret, dev_tmp, dev[2];
char dev_name_tmp[20];
unsigned int MaxPayloadTransferSize[2];
Dbg_Param = 0x12;
dev_tmp = video_open(dev_name);
if (dev_tmp < 0)
return;
//get interface
GetInterface(dev_tmp,&Interface_tmp);
strcpy(dev_name_tmp, dev_name);
if(Interface_tmp.NumFormat == 2)
{
//dev_name is path of interface 1
dev[0] = dev_tmp;
memcpy(&Interface[0], &Interface_tmp, sizeof(struct InterfaceDesc));
//set interface 2
dev_name_tmp[10] += 1; // for string "/dev/videoX", if X>0, X++
dev[1]= video_open(dev_name_tmp);
if (dev_tmp < 0)
return;
GetInterface(dev[1],&Interface[1]);
}
else
{
//dev_name is path of interface 2
dev[1] = dev_tmp;
memcpy(&Interface[1], &Interface_tmp, sizeof(struct InterfaceDesc));
//set interface 1
dev_name_tmp[10] -= 1; // for string "/dev/videoX", if X>0, X--
dev[0]= video_open(dev_name_tmp);
if (dev[0] < 0)
return;
GetInterface(dev[0],&Interface[0]);
}
//get capability
GetCapability(dev[1], &CapData);
ParseCapability(CapData.pbuf, CapData.Lenght, &Cap_Desc);
//list bandwidth
for(i = 0; i<Cap_Desc.NumConfigs ;i++)
{
struct InterfaceDesc *pInterface;
struct MultiStreamCap *pCap_tmp, *pCap[2] = {NULL};
int if_index, fmt_index, frame_index, fmt[2], width, height;
struct FrameTypeDesc *pFrameDesc[2];
//get Cap descriptor
for(j = 0 ; j < Cap_Desc.Cfg_Desc[i].NumStreams ; j++)
{
pCap_tmp= &Cap_Desc.Cfg_Desc[i].MS_Cap[j];
if(pCap[min(pCap_tmp->UVCInterfaceNum,2)-1]==NULL)
pCap[min(pCap_tmp->UVCInterfaceNum,2)-1] = pCap_tmp;
}
//set format, width and height to device
for(j = 0 ; j < 2 ; j++)
{
if(pCap[j]==NULL)
continue;
//get interface
if_index = min(pCap[j]->UVCInterfaceNum,2)-1;
pInterface = &Interface[if_index];
//get format
fmt_index = min(pCap[j]->UVCFormatIndex, pInterface->NumFormat) - 1;
fmt[j] = pInterface->fmt[fmt_index];
//get frame
frame_index = min(pCap[j]->UVCFrameIndex, pInterface->NumFrame[fmt_index]) - 1;
pFrameDesc[j] = &pInterface->frame_info[fmt_index][frame_index];
width = pInterface->frame_info[fmt_index][frame_index].width;
height = pInterface->frame_info[fmt_index][frame_index].height;
video_set_format(dev[j], width, height, fmt[j]);
}
TestAp_Printf(TESTAP_DBG_BW, "config = %d\n", i+1);
//set bitrate and get the MaxPayloadTransferSize
if(pCap[0] && pCap[1]==NULL)
{
for(j = 0; j < pFrameDesc[0]->NumFPS; j++)
{
video_set_framerate(dev[0], pFrameDesc[0]->FPS[j], &MaxPayloadTransferSize[0]);
TestAp_Printf(TESTAP_DBG_BW, "fmt = %c%c%c%c, size = %4dx%4d, fps = %2d",
fmt[0]&0xff, (fmt[0]>>8)&0xff, (fmt[0]>>16)&0xff, (fmt[0]>>24)&0xff,
pFrameDesc[0]->width, pFrameDesc[0]->height, pFrameDesc[0]->FPS[j]);
TestAp_Printf(TESTAP_DBG_BW, "\tMaxPayloadTransferSize = 0x%x\n", MaxPayloadTransferSize[0]);
}
}
else if(pCap[0]==NULL && pCap[1])
{
for(j = 0; j < pFrameDesc[1]->NumFPS; j++)
{
video_set_framerate(dev[1], pFrameDesc[1]->FPS[j], &MaxPayloadTransferSize[1]);
TestAp_Printf(TESTAP_DBG_BW, "fmt = %c%c%c%c, size = %4dx%4d, fps = %2d",
fmt[1]&0xff, (fmt[1]>>8)&0xff, (fmt[1]>>16)&0xff, (fmt[1]>>24)&0xff,
pFrameDesc[1]->width, pFrameDesc[1]->height, pFrameDesc[1]->FPS[j]);
TestAp_Printf(TESTAP_DBG_BW, "\tMaxPayloadTransferSize = 0x%x\n", MaxPayloadTransferSize[1]);
}
}
else if(pCap[0] && pCap[1])
{
for(j = 0; j < pFrameDesc[0]->NumFPS; j++)
{
for(k = 0; k < pFrameDesc[1]->NumFPS; k++)
{
video_set_framerate(dev[0], pFrameDesc[0]->FPS[j], &MaxPayloadTransferSize[0]);
video_set_framerate(dev[1], pFrameDesc[1]->FPS[k], &MaxPayloadTransferSize[1]);
TestAp_Printf(TESTAP_DBG_BW, "(fmt = %c%c%c%c, size = %4dx%4d, fps = %2d), (fmt = %c%c%c%c, size = %4dx%4d, fps = %2d)",
fmt[0]&0xff, (fmt[0]>>8)&0xff, (fmt[0]>>16)&0xff, (fmt[0]>>24)&0xff,
pFrameDesc[0]->width, pFrameDesc[0]->height, pFrameDesc[0]->FPS[j],
fmt[1]&0xff, (fmt[1]>>8)&0xff, (fmt[1]>>16)&0xff, (fmt[1]>>24)&0xff,
pFrameDesc[1]->width, pFrameDesc[1]->height, pFrameDesc[1]->FPS[k]);
TestAp_Printf(TESTAP_DBG_BW, "\tMaxPayloadTransferSize = 0x%x(%x+%x)\n"
, MaxPayloadTransferSize[0]+MaxPayloadTransferSize[1]
, MaxPayloadTransferSize[0],MaxPayloadTransferSize[1]);
}
}
}
}
#if 0 //dbg
for(l = 0; l < 2; l ++)
{
TestAp_Printf(TESTAP_DBG_BW, "INTERFACE[%d]:\n", l+1);
TestAp_Printf(TESTAP_DBG_BW, "format num = %d\n", Interface[l].NumFormat);
for(i = 0; i < Interface[l].NumFormat;i++)
{
TestAp_Printf(TESTAP_DBG_BW, "\tformat[%d] = %x\n", i, Interface[l].fmt[i]);
for(j = 0; j < Interface[l].NumFrame[i];j++)
{
TestAp_Printf(TESTAP_DBG_BW, "\t\tframe[%d]: size = %d x %d \n", j, Interface[l].frame_info[i][j].width, Interface[l].frame_info[i][j].height);
for(k = 0; k<Interface[l].frame_info[i][j].NumFPS; k++)
TestAp_Printf(TESTAP_DBG_BW, "\t\t\tfps[%d]: fps = %d\n", k, Interface[l].frame_info[i][j].FPS[k]);
}
}
}
#endif
#if 0 //dbg
int index_i, index_j;
TestAp_Printf(TESTAP_DBG_BW, "num of cfg = %d\n", Cap_Desc.NumConfigs);
for(index_i = 0; index_i < Cap_Desc.NumConfigs ;index_i++)
{
TestAp_Printf(TESTAP_DBG_BW, "\tnum of string = %d\n", Cap_Desc.Cfg_Desc[index_i].NumStreams);
for(index_j = 0; index_j < Cap_Desc.Cfg_Desc[index_i].NumStreams;index_j++)
{
TestAp_Printf(TESTAP_DBG_BW, "\t\t[%d] %d %d %d %d %d %d %d %d %d %d %d %d \n", index_j, Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].UVCInterfaceNum,
Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].UVCFormatIndex , Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].UVCFrameIndex , Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].DemuxerIndex,
Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].FPSIndex, Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].BRCIndex, Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].OSDIndex,
Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].MDIndex, Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].PTZIIndex, Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].FPSGroup,
Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].BRCGroup, Cap_Desc.Cfg_Desc[index_i].MS_Cap[index_j].OSDGroup);
}
}
TestAp_Printf(TESTAP_DBG_BW, "num of demuxer = %d\n", Cap_Desc.NumDemuxers);
for(index_i = 0; index_i < Cap_Desc.NumDemuxers;index_i++)
{
TestAp_Printf(TESTAP_DBG_BW, "\t[%d] %d %d %d %d\n", index_i, Cap_Desc.demuxer_Desc[index_i].MSCDemuxIndex,
Cap_Desc.demuxer_Desc[index_i].DemuxID, Cap_Desc.demuxer_Desc[index_i].Width,
Cap_Desc.demuxer_Desc[index_i].Height);
}
TestAp_Printf(TESTAP_DBG_BW, "num of frameinterval = %d\n", Cap_Desc.NumFrameIntervals);
for(index_i = 0; index_i < Cap_Desc.NumFrameIntervals;index_i++)
{
TestAp_Printf(TESTAP_DBG_BW, "\t[%d] %d %d\n", index_i, Cap_Desc.FrameInt_Desc[index_i].FPSIndex,
Cap_Desc.FrameInt_Desc[index_i].FPSCount);
for(index_j = 0; index_j < Cap_Desc.FrameInt_Desc[index_i].FPSCount;index_j++)
TestAp_Printf(TESTAP_DBG_BW, "\t\t[%d] %d\n", index_j, Cap_Desc.FrameInt_Desc[index_i].FPS[index_j]);
}
TestAp_Printf(TESTAP_DBG_BW, "num of bitrate = %d\n", Cap_Desc.NumBitrate);
for(index_i = 0; index_i < Cap_Desc.NumBitrate;index_i++)
{
TestAp_Printf(TESTAP_DBG_BW, "\t[%d] %d %d\n", index_i, Cap_Desc.Bitrate_Desc[index_i].BRCIndex,
Cap_Desc.Bitrate_Desc[index_i].BRCMode);
}
#endif
close(dev[0]);
close(dev[1]);
Dbg_Param = 0x1f;
}
int get_still_image(int dev, unsigned int w, unsigned int h, unsigned int format)
{
char filename[30];
struct v4l2_buffer buf;
FILE *file = NULL;
int ret = 0, repeat_setting = 0;
void *mem;
static int counter = 0;
static int still_dev = 0, still_width = 0, still_height = 0, still_format = 0;
TestAp_Printf(TESTAP_DBG_FLOW, "%s ============>\n",__FUNCTION__);
if(still_dev == dev && still_width == w && still_height == h && still_format == format)
repeat_setting = 1;
//set file name
if(format == V4L2_PIX_FMT_MJPEG)
sprintf(filename, "still_img-%02u.jpg", counter);
else if(format == V4L2_PIX_FMT_YUYV)
sprintf(filename, "still_img-%02u.yuyv", counter);
TestAp_Printf(TESTAP_DBG_FLOW, "repeat_setting = %d, fname = %s\n",repeat_setting, filename);
if(!repeat_setting)
{
//set format
video_set_still_format(dev, w, h, format);
//request still buffer
ret = video_req_still_buf(dev);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to request still buffer(%d).\n", errno);
return ret;
}
}
//mmap
memset(&buf, 0, sizeof buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
if(GetKernelVersion()> KERNEL_VERSION (3, 0, 36))
ret = ioctl(dev, UVCIOC_STILL_QUERYBUF_KNL3, &buf);
else
ret = ioctl(dev, UVCIOC_STILL_QUERYBUF_KNL2, &buf);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to query still buffer(%d).\n", errno);
return ret;
}
TestAp_Printf(TESTAP_DBG_FLOW, "length: %u offset: %10u -- ", buf.length, buf.m.offset);
mem = mmap(0, buf.length, PROT_READ, MAP_SHARED, dev, buf.m.offset);
if (mem == MAP_FAILED) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to map still buffer(%d)\n", errno);
return -1;
}
TestAp_Printf(TESTAP_DBG_FLOW, "still Buffer mapped at address %p.\n", mem);
//get data
if(GetKernelVersion()> KERNEL_VERSION (3, 0, 36))
ret = ioctl(dev, UVCIOC_STILL_GET_FRAME_KNL3, &buf);
else
ret = ioctl(dev, UVCIOC_STILL_GET_FRAME_KNL2, &buf);
if (ret < 0) {
TestAp_Printf(TESTAP_DBG_ERR, "Unable to get still image(%d).\n", errno);
return ret;
}
TestAp_Printf(TESTAP_DBG_FLOW, "buf.bytesused = %d\n", buf.bytesused);
file = fopen(filename, "wb");
if (file != NULL)
fwrite(mem, buf.bytesused, 1, file);
fclose(file);
munmap(mem, buf.length);
counter ++;
TestAp_Printf(TESTAP_DBG_FLOW, "%s <============\n",__FUNCTION__);
still_dev = dev;
still_width = w;
still_height = h;
still_format = format;
return 0;
}
static void usage(const char *argv0)
{
TestAp_Printf(TESTAP_DBG_USAGE, "Usage: %s [options] device\n", argv0);
TestAp_Printf(TESTAP_DBG_USAGE, "Supported options:\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-c, --capture[=nframes] Capture frames\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-d, --delay Delay (in ms) before requeuing buffers\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-e, enum MaxPayloadTransferSize\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-f, --format format Set the video format (mjpg or yuyv)\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-h, --help Show this help screen\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-i, --input input Select the video input\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-l, --list-controls List available controls\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-n, --nbufs n Set the number of video buffers\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-s, --size WxH Set the frame size\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --fr framerate Set framerate\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-S, --save Save captured images to disk\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --enum-inputs Enumerate inputs\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --skip n Skip the first n frames\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-r, --record Record H264 file\n");
TestAp_Printf(TESTAP_DBG_USAGE, "--still get still image\n");
TestAp_Printf(TESTAP_DBG_USAGE, "--still2 fmt w h get still image\n");
TestAp_Printf(TESTAP_DBG_USAGE, "--bri-set values Set brightness values\n");
TestAp_Printf(TESTAP_DBG_USAGE, "--bri-get Get brightness values\n");
TestAp_Printf(TESTAP_DBG_USAGE, "--shrp-set values Set sharpness values\n");
TestAp_Printf(TESTAP_DBG_USAGE, "--shrp-get Get sharpness values\n");
TestAp_Printf(TESTAP_DBG_USAGE, "--dbg value Set level of debug message(bit0:usage, bit1:error, bit2:flow, bit3:frame)\n");
TestAp_Printf(TESTAP_DBG_USAGE, "--vnd-get Get vender version\n");
TestAp_Printf(TESTAP_DBG_USAGE, "SONiX XU supported options:\n");
TestAp_Printf(TESTAP_DBG_USAGE, "-a, --add-xuctrl Add Extension Unit Ctrl into Driver\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget id cs datasize d0 d1 ... XU Get command: xu_id control_selector data_size data_0 data_1 ...\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset id cs datasize d0 d1 ... XU Set command: xu_id control_selector data_size data_0 data_1 ...\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-chip Read SONiX Chip ID\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-qp Get H.264 QP values\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-qp val Set H.264 QP values: val\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-br Get H.264 bit rate (bps)\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-br val Set H.264 bit rate (bps) \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --asic-r addr [Hex] Read register address data\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --asic-w addr data [Hex] Write register address data\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --sf-r addr len [Hex] Read sf address data\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --i2c-r ID addr data_len [Hex] i2c read(fill Zero in LSB)\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --i2c-w ID addr data data_len [Hex] i2c write(fill Zero in LSB) \n");
#if(CARCAM_PROJECT == 0)
TestAp_Printf(TESTAP_DBG_USAGE, " --mf val Set Multi-Stream format:[1]HD+QVGA [2]HD+180p [4]HD+360p [8]HD+VGA [10]HD+QVGA+VGA [20]HD+QVGA [40]HD+180p+360p [80]360p+180p\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --mgs Get Multi-Stream Status. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --mgi Get Multi-Stream Info. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --msqp StreamID QP Set Multi-Stream QP. StreamID = 0 ~ 2 \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --mgqp StreamID Get Multi-Stream QP. StreamID = 0 ~ 2 \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --msbr StreamID Bitrate Set Multi-Stream Bitrate (bps). StreamID = 0 ~ 2 \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --mgbr StreamID Get Multi-Stream BitRate (bps). StreamID = 0 ~ 2 \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --mscvm StreamID H264Mode Set Multi-Stream H264 Mode. StreamID = 0 ~ 2(1:CBR 2:VBR) \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --mgcvm StreamID Get Multi-Stream H264 Mode. StreamID = 0 ~ 2 \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --msfr val Set Multi-Stream substream frame rate.\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --mgfr Get Multi-Stream substream frame rate.\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --msgop val Set Multi-Stream substream GOP(suggest GOP = fps-1).\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --mggop Get Multi-Stream substream GOP.\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --mse Enable Set Multi-Stream Enable : [0]Disable [1]H264 [3]H264+Mjpg. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --mge Get Multi-Stream Enable. \n");
#endif
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-timer Enable Set OSD Timer Counting 1:enable 0:disable\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-rtc year month day hour min sec Set OSD RTC\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-rtc Get OSD RTC\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-os Line Block Set OSD Line and Block Size (0~4)\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-os Get OSD Line and Block Size (0~4)\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-oc Font Border Set OSD Font and Border Color 0:Black 1:Red 2:Green 3:Blue 4:White\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-oc Get OSD Font and Border Color 0:Black 1:Red 2:Green 3:Blue 4:White\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-oe Line Block Set OSD Show 1:enable 0:disable\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-oe Get OSD Show 1:enable 0:disable\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-oas Line Block Set OSD Auto Scale 1:enable 0:disable\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-oas Get OSD Auto Scale 1:enable 0:disable\n");
#if(CARCAM_PROJECT == 0)
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-oms Stream0 Stream1 Stream2 Set OSD MultiStream Size (0~4)\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-oms Get OSD MultiStream Size (0~4)\n");
#endif
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-osp Type Row Col Set OSD Start Row and Col (unit:16)\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-osp Get OSD Start Row and Col (unit:16)\n");
#if(CARCAM_PROJECT == 0)
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-ostr Group '.....' Set OSD 2nd String.Group from 0 to 2.8 words per 1 Group.\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-ostr Group Get OSD 2nd String. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-omssp StreamID Row Col Set OSD Multi stream start row and col. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-omssp Get OSD Multi stream start raw and col. \n");
#endif
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-mde Enable Set Motion detect enable\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-mde Get Motion detect enable\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-mdt Thd Set Motion detect threshold (0~65535)\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-mdt Get Motion detect threshold\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-mdm m1 m2 ... m24 Set Motion detect mask\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-mdm Get Motion detect mask\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-mdr m1 m2 ... m24 Set Motion detect result\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-mdr Get Motion detect result\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-mjb Bitrate Set MJPG Bitrate (bps) \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-mjb Get MJPG Bitrate (bps) \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-if nframe Set H264 reset to IFrame. nframe : reset per nframe.\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-sei Set H264 SEI Header Enable.\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-sei Get H264 SEI Header Enable. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-gop Set H264 GOP. (1 ~ 4095)\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-gop Get H264 GOP. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-cvm Set H264 CBR/VBR mode(1:CBR 2:VBR)\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-cvm Get H264 CBR/VBR mode(1:CBR 2:VBR)\n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-mir Set Image mirror. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-mir Get Image mirror. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-flip Set Image flip. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-flip Get Image flip. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-gpio enable out_value Set GPIO ctrl(hex). \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-gpio Get GPIO ctrl. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-clr Set Image color. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-clr Get Image color. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-fde s1 s2 Set Frame drop enable. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-fde Get Frame drop enable. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-fdc s1 s2 Set Frame drop value. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-fdc Get Frame drop value. \n");
#if(CARCAM_PROJECT == 1)
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-car SpeedEn CoordinateEn CoordinateCtrl Set Car control . \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-car Get Car control. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-spd Speed Set Speed info. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-spd Get Speed info. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-coor1 Dir v1 v2 v3 v4 v5 v6 Set Coordinate info. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-coor1 Get Coordinate info. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuset-coor2 Dir v1 v2 v3 v4 Set Coordinate info. \n");
TestAp_Printf(TESTAP_DBG_USAGE, " --xuget-coor2 Get Coordinate info. \n");
#endif
}
#define OPT_ENUM_INPUTS 256
#define OPT_SKIP_FRAMES OPT_ENUM_INPUTS + 1
#define OPT_XU_ADD_CTRL OPT_ENUM_INPUTS + 2
#define OPT_XU_GET_CHIPID OPT_ENUM_INPUTS + 3
#define OPT_XU_GET_FMT OPT_ENUM_INPUTS + 4
#define OPT_XU_SET_FMT OPT_ENUM_INPUTS + 5
#define OPT_XU_SET_FPS OPT_ENUM_INPUTS + 6
#define OPT_XU_GET_QP OPT_ENUM_INPUTS + 7
#define OPT_XU_SET_QP OPT_ENUM_INPUTS + 8
#define OPT_XU_GET_BITRATE OPT_ENUM_INPUTS + 9
#define OPT_XU_SET_BITRATE OPT_ENUM_INPUTS + 10
#define OPT_XU_GET OPT_ENUM_INPUTS + 11
#define OPT_XU_SET OPT_ENUM_INPUTS + 12
#define OPT_BRIGHTNESS_GET OPT_ENUM_INPUTS + 13
#define OPT_BRIGHTNESS_SET OPT_ENUM_INPUTS + 14
#define OPT_SHARPNESS_GET OPT_ENUM_INPUTS + 15
#define OPT_SHARPNESS_SET OPT_ENUM_INPUTS + 16
#define OPT_ASIC_READ OPT_ENUM_INPUTS + 17
#define OPT_ASIC_WRITE OPT_ENUM_INPUTS + 18
#define OPT_MULTI_FORMAT OPT_ENUM_INPUTS + 19
#define OPT_MULTI_SET_BITRATE OPT_ENUM_INPUTS + 20
#define OPT_MULTI_GET_BITRATE OPT_ENUM_INPUTS + 21
#define OPT_OSD_TIMER_CTRL_SET OPT_ENUM_INPUTS + 22
#define OPT_OSD_RTC_SET OPT_ENUM_INPUTS + 23
#define OPT_OSD_RTC_GET OPT_ENUM_INPUTS + 24
#define OPT_OSD_SIZE_SET OPT_ENUM_INPUTS + 25
#define OPT_OSD_SIZE_GET OPT_ENUM_INPUTS + 26
#define OPT_OSD_COLOR_SET OPT_ENUM_INPUTS + 27
#define OPT_OSD_COLOR_GET OPT_ENUM_INPUTS + 28
#define OPT_OSD_SHOW_SET OPT_ENUM_INPUTS + 29
#define OPT_OSD_SHOW_GET OPT_ENUM_INPUTS + 30
#define OPT_OSD_AUTOSCALE_SET OPT_ENUM_INPUTS + 31
#define OPT_OSD_AUTOSCALE_GET OPT_ENUM_INPUTS + 32
#define OPT_OSD_MS_SIZE_SET OPT_ENUM_INPUTS + 33
#define OPT_OSD_MS_SIZE_GET OPT_ENUM_INPUTS + 34
#define OPT_OSD_POSITION_SET OPT_ENUM_INPUTS + 35
#define OPT_OSD_POSITION_GET OPT_ENUM_INPUTS + 36
#define OPT_MD_MODE_SET OPT_ENUM_INPUTS + 37
#define OPT_MD_MODE_GET OPT_ENUM_INPUTS + 38
#define OPT_MD_THRESHOLD_SET OPT_ENUM_INPUTS + 39
#define OPT_MD_THRESHOLD_GET OPT_ENUM_INPUTS + 40
#define OPT_MD_MASK_SET OPT_ENUM_INPUTS + 41
#define OPT_MD_MASK_GET OPT_ENUM_INPUTS + 42
#define OPT_MD_RESULT_SET OPT_ENUM_INPUTS + 43
#define OPT_MD_RESULT_GET OPT_ENUM_INPUTS + 44
#define OPT_MJPG_BITRATE_SET OPT_ENUM_INPUTS + 45
#define OPT_MJPG_BITRATE_GET OPT_ENUM_INPUTS + 46
#define OPT_H264_IFRAME_SET OPT_ENUM_INPUTS + 47
#define OPT_H264_SEI_SET OPT_ENUM_INPUTS + 48
#define OPT_H264_SEI_GET OPT_ENUM_INPUTS + 49
#define OPT_IMG_MIRROR_SET OPT_ENUM_INPUTS + 50
#define OPT_IMG_MIRROR_GET OPT_ENUM_INPUTS + 51