-
Notifications
You must be signed in to change notification settings - Fork 2
/
imx335_sensor_ctl.c
1798 lines (1523 loc) · 67.8 KB
/
imx335_sensor_ctl.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
/*
* Copyright (c) Hunan Goke,Chengdu Goke,Shandong Goke. 2021. All rights reserved.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/mman.h>
#include <memory.h>
#include "comm_video.h"
#include "sns_ctrl.h"
#ifdef GPIO_I2C
#include "gpioi2c_ex.h"
#else
#include "i2c.h"
#endif
const unsigned char imx335_i2c_addr = 0x34; /* I2C Address of imx335 */
const unsigned int imx335_addr_byte = 2;
const unsigned int imx335_data_byte = 1;
static int g_fd[ISP_MAX_PIPE_NUM] = { [0 ...(ISP_MAX_PIPE_NUM - 1)] = -1 };
extern WDR_MODE_E genSensorMode;
extern GK_U8 gu8SensorImageMode;
extern GK_BOOL bSensorInit;
extern ISP_SNS_STATE_S *g_pastImx335[ISP_MAX_PIPE_NUM];
extern ISP_SNS_COMMBUS_U g_aunImx335BusInfo[];
#define IMX335_5M_30FPS_12BIT_LINEAR_MODE (0) //2592x1944
#define IMX335_5M_30FPS_10BIT_WDR_MODE (1) //2592x1944
//#define IMX335_4M_25FPS_10BIT_WDR_MODE (2) //2592x1520
#define IMX335_1520P_10BIT_MODE (2) //2592x1520
#define IMX335_4M_30FPS_10BIT_WDR_MODE (3) //2592x1520
#define IMX335_60FPS_BINNING_MODE (4) //1296x972
#define IMX335_60FPS_CROPPED_1080P_MODE (5) //1920x1080
#define IMX335_60FPS_FULL_1944P_MODE (6) //2592x1944
int IMX335_i2c_init(VI_PIPE ViPipe)
{
char acDevFile[16] = { 0 };
GK_U8 u8DevNum;
if (g_fd[ViPipe] >= 0) {
return GK_SUCCESS;
}
#ifdef GPIO_I2C
int ret;
g_fd[ViPipe] = open("/dev/gpioi2c_ex", O_RDONLY, S_IRUSR);
if (g_fd[ViPipe] < 0) {
ISP_TRACE(MODULE_DBG_ERR, "Open gpioi2c_ex error!\n");
return GK_FAILURE;
}
#else
int ret;
u8DevNum = g_aunImx335BusInfo[ViPipe].s8I2cDev;
snprintf(acDevFile, sizeof(acDevFile), "/dev/i2c-%u", u8DevNum);
g_fd[ViPipe] = open(acDevFile, O_RDWR, S_IRUSR | S_IWUSR);
if (g_fd[ViPipe] < 0) {
ISP_TRACE(MODULE_DBG_ERR, "Open /dev/i2c_drv-%u error!\n",
u8DevNum);
return GK_FAILURE;
}
ret = ioctl(g_fd[ViPipe], I2C_SLAVE_FORCE, (imx335_i2c_addr >> 1));
if (ret < 0) {
ISP_TRACE(MODULE_DBG_ERR, "I2C_SLAVE_FORCE error!\n");
close(g_fd[ViPipe]);
g_fd[ViPipe] = -1;
return ret;
}
#endif
return GK_SUCCESS;
}
int IMX335_i2c_exit(VI_PIPE ViPipe)
{
if (g_fd[ViPipe] >= 0) {
close(g_fd[ViPipe]);
g_fd[ViPipe] = -1;
return GK_SUCCESS;
}
return GK_FAILURE;
}
int IMX335_read_register(VI_PIPE ViPipe, int addr)
{
return GK_SUCCESS;
}
int IMX335_write_register(VI_PIPE ViPipe, GK_U32 addr, GK_U32 data)
{
if (g_fd[ViPipe] < 0) {
return GK_SUCCESS;
}
#ifdef GPIO_I2C
i2c_data.dev_addr = imx335_i2c_addr;
i2c_data.reg_addr = addr;
i2c_data.addr_byte_num = imx335_addr_byte;
i2c_data.data = data;
i2c_data.data_byte_num = imx335_data_byte;
ret = ioctl(g_fd[ViPipe], GPIO_I2C_WRITE, &i2c_data);
if (ret) {
ISP_TRACE(MODULE_DBG_ERR, "GPIO-I2C write faild!\n");
return ret;
}
#else
int idx = 0;
int ret;
char buf[8];
if (imx335_addr_byte == 2) {
buf[idx] = (addr >> 8) & 0xff;
idx++;
buf[idx] = addr & 0xff;
idx++;
} else {
}
if (imx335_data_byte == 2) {
} else {
buf[idx] = data & 0xff;
idx++;
}
ret = write(g_fd[ViPipe], buf, imx335_addr_byte + imx335_data_byte);
if (ret < 0) {
ISP_TRACE(MODULE_DBG_ERR, "I2C_WRITE error!\n");
return GK_FAILURE;
}
#endif
return GK_SUCCESS;
}
void IMX335_standby(VI_PIPE ViPipe)
{
return;
}
void IMX335_restart(VI_PIPE ViPipe)
{
return;
}
static void delay_ms(int ms)
{
usleep(ms * 1000);
}
void IMX335_linear_5M30_12bit_init(VI_PIPE ViPipe);
void IMX335_linear_5M30_12bit_40fps_init(VI_PIPE ViPipe);
void IMX335_wdr_5M30_10bit_init(VI_PIPE ViPipe);
void IMX335_wdr_4M25_10bit_init(VI_PIPE ViPipe);
void IMX335_wdr_4M30_10bit_init(VI_PIPE ViPipe);
void IMX335_binning_60pfs_init(VI_PIPE ViPipe);
void imx335_default_reg_init(VI_PIPE ViPipe)
{
GK_U32 i;
for (i = 0; i < g_pastImx335[ViPipe]->astRegsInfo[0].u32RegNum; i++) {
IMX335_write_register(ViPipe,
g_pastImx335[ViPipe]
->astRegsInfo[0]
.astI2cData[i]
.u32RegAddr,
g_pastImx335[ViPipe]
->astRegsInfo[0]
.astI2cData[i]
.u32Data);
}
}
void IMX335_init(VI_PIPE ViPipe)
{
WDR_MODE_E enWDRMode;
GK_BOOL bInit;
GK_U8 u8ImgMode;
bInit = g_pastImx335[ViPipe]->bInit;
enWDRMode = g_pastImx335[ViPipe]->enWDRMode;
u8ImgMode = g_pastImx335[ViPipe]->u8ImgMode;
if (bInit == GK_FALSE) {
/* sensor i2c init */
printf("binit false IMX335 i2c init\n");
IMX335_i2c_init(ViPipe);
}
/* When sensor first init, config all registers */
if (WDR_MODE_2To1_LINE == enWDRMode) {
if (u8ImgMode == IMX335_5M_30FPS_10BIT_WDR_MODE) {
IMX335_wdr_5M30_10bit_init(ViPipe);
//} else if (u8ImgMode == IMX335_4M_25FPS_10BIT_WDR_MODE) {
// IMX335_wdr_4M25_10bit_init(ViPipe);
} else if (u8ImgMode == IMX335_4M_30FPS_10BIT_WDR_MODE) {
IMX335_wdr_4M30_10bit_init(ViPipe);
}
else {
printf("IMX335_init Not support this mode\n");
return;
}
} else if (enWDRMode == WDR_MODE_NONE) {
switch (u8ImgMode) {
// - 2x2 binning @ 60fps
case IMX335_60FPS_BINNING_MODE: {
IMX335_binning_60pfs_init(ViPipe);
}; break;
case IMX335_60FPS_CROPPED_1080P_MODE: {
IMX335_cropped_60fps_1080p_init(ViPipe);
}; break;
case IMX335_1520P_10BIT_MODE: {
IMX335_cropped_41fps_2592_1520_init(ViPipe);
}; break;
case IMX335_60FPS_FULL_1944P_MODE: {
IMX335_linear_5M30_12bit_40fps_init(ViPipe);
}; break;
case IMX335_5M_30FPS_12BIT_LINEAR_MODE: {
IMX335_linear_5M30_12bit_init(ViPipe);
}; break;
default:{
IMX335_linear_5M30_12bit_init(ViPipe);
printf("IMX335_init unknown mode\n");
break;
}
}
} else {
printf("IMX335_init Not support this mode\n");
return;
}
imx335_default_reg_init(ViPipe);
g_pastImx335[ViPipe]->bInit = GK_TRUE;
return;
}
void IMX335_exit(VI_PIPE ViPipe)
{
IMX335_i2c_exit(ViPipe);
return;
}
//classic stock mode tweaked to 40fps
void IMX335_linear_5M30_12bit_40fps_init(VI_PIPE ViPipe)
{
//return IMX335_cropped_41fps_2592_1520_init(ViPipe);
//return IMX335_wdr_4M30_10bit_init(ViPipe);
//Restart the sensor and take default registry values
IMX335_write_register(ViPipe, 0x3004, 0x04);
IMX335_write_register(ViPipe, 0x3004, 0x00);
IMX335_write_register(ViPipe, 0x3000, 0x01);//pause
IMX335_write_register(ViPipe, 0x3002, 0x01);//continue
IMX335_write_register(ViPipe, 0x3004, 0x04);//restart
IMX335_write_register(ViPipe, 0x3004, 0x00);
delay_ms(18);//Not needed maybe
IMX335_write_register(ViPipe, 0x3000, 0x01); // standby
IMX335_write_register(ViPipe, 0x300C, 0x5B);
IMX335_write_register(ViPipe, 0x300D, 0x40);
IMX335_write_register(ViPipe, 0x3034, 0xA0); //HMAX default 0226h/0294h is for 25fps, 14A works 38fos
IMX335_write_register(ViPipe, 0x3035, 0x01);// 200 works at 32fps , 1B0 at 38fps, 190 at 41fps with problems!,
if (1==1){
IMX335_write_register(ViPipe, 0x3018, 0x00);//window mode, 0-default | 3-binning | 4- cropping
IMX335_write_register(ViPipe, 0x302C, 0x30);// HTRIMMING Horiz Start in cropping START
IMX335_write_register(ViPipe, 0x302D, 0x00);
IMX335_write_register(ViPipe, 0x302E, 0x38);//HNUM Horiz size 0A20 - 2592 cropping size designation
IMX335_write_register(ViPipe, 0x302F, 0x0A);//0798 for 1920
IMX335_write_register(ViPipe, 0x3030, 0x94);// VMAX default 1194h ,
IMX335_write_register(ViPipe, 0x3031, 0x11);//
IMX335_write_register(ViPipe, 0x3032, 0x00);
//IMX335_write_register(ViPipe, 0x3034, 0x26);//HMAX default 0226h/0294h is for 25fps, 14A works 38fos
//IMX335_write_register(ViPipe, 0x3035, 0x02);// 12C for 41fps
//This increases the FPS !!!
IMX335_write_register(ViPipe, 0x3034, 0xA0); //HMAX default 0226h/0294h is for 25fps, 14A works 38fos
IMX335_write_register(ViPipe, 0x3035, 0x01);// 200 works at 32fps , 1B0 at 38fps, 190 at 41fps with problems!,
IMX335_write_register(ViPipe, 0x3056, 0xAC); //Y_OUT_SIZE effective pixel lines 07ACh
IMX335_write_register(ViPipe, 0x3057, 0x07); //5B4h = 1440
IMX335_write_register(ViPipe, 0x3072, 0x28);// Vert Crop start 0x28
IMX335_write_register(ViPipe, 0x3073, 0x00);
IMX335_write_register(ViPipe, 0x3076, 0x58);//// AREA3_WIDTH_1 Vert Cropping Size designation * 2 , = Y_OUT_SIZE*2
IMX335_write_register(ViPipe, 0x3077, 0x0F);
}
IMX335_write_register(ViPipe, 0x3050, 0x00);
if (1==1){//return to defaults not working?!
IMX335_write_register(ViPipe, 0x3074, 0xB0);// AREA3_ST_Addr Upper left cropping postion
IMX335_write_register(ViPipe, 0x3075, 0x00);
IMX335_write_register(ViPipe, 0x30C6, 0x00);//Black Offset Addr 12h
IMX335_write_register(ViPipe, 0x30CE, 0x00);//UNRD_Line_Max in cropping
IMX335_write_register(ViPipe, 0x30D8, 0x4C);//UNREAD_ED_ADR in cropping
IMX335_write_register(ViPipe, 0x30D9, 0x10);
}
IMX335_write_register(ViPipe, 0x314C, 0xC0);
IMX335_write_register(ViPipe, 0x315A, 0x06);
IMX335_write_register(ViPipe, 0x316A, 0x7E);
IMX335_write_register(ViPipe, 0x319D, 0x00);
IMX335_write_register(ViPipe, 0x319E, 0x02); //// SYS_MODE = 891Mbps
IMX335_write_register(ViPipe, 0x31A1, 0x00);
IMX335_write_register(ViPipe, 0x3288, 0x21);
IMX335_write_register(ViPipe, 0x328A, 0x02);
IMX335_write_register(ViPipe, 0x3414, 0x05);
IMX335_write_register(ViPipe, 0x3416, 0x18);
IMX335_write_register(ViPipe, 0x341C, 0xFF);
IMX335_write_register(ViPipe, 0x341D, 0x01);
IMX335_write_register(ViPipe, 0x3648, 0x01);
IMX335_write_register(ViPipe, 0x364A, 0x04);
IMX335_write_register(ViPipe, 0x364C, 0x04);
IMX335_write_register(ViPipe, 0x3678, 0x01);
IMX335_write_register(ViPipe, 0x367C, 0x31);
IMX335_write_register(ViPipe, 0x367E, 0x31);
IMX335_write_register(ViPipe, 0x3706, 0x10);
IMX335_write_register(ViPipe, 0x3708, 0x03);
IMX335_write_register(ViPipe, 0x3714, 0x02);
IMX335_write_register(ViPipe, 0x3715, 0x02);
IMX335_write_register(ViPipe, 0x3716, 0x01);
IMX335_write_register(ViPipe, 0x3717, 0x03);
IMX335_write_register(ViPipe, 0x371C, 0x3D);
IMX335_write_register(ViPipe, 0x371D, 0x3F);
IMX335_write_register(ViPipe, 0x372C, 0x00);
IMX335_write_register(ViPipe, 0x372D, 0x00);
IMX335_write_register(ViPipe, 0x372E, 0x46);
IMX335_write_register(ViPipe, 0x372F, 0x00);
IMX335_write_register(ViPipe, 0x3730, 0x89);
IMX335_write_register(ViPipe, 0x3731, 0x00);
IMX335_write_register(ViPipe, 0x3732, 0x08);
IMX335_write_register(ViPipe, 0x3733, 0x01);
IMX335_write_register(ViPipe, 0x3734, 0xFE);
IMX335_write_register(ViPipe, 0x3735, 0x05);
IMX335_write_register(ViPipe, 0x3740, 0x02);
IMX335_write_register(ViPipe, 0x375D, 0x00);
IMX335_write_register(ViPipe, 0x375E, 0x00);
IMX335_write_register(ViPipe, 0x375F, 0x11);
IMX335_write_register(ViPipe, 0x3760, 0x01);
IMX335_write_register(ViPipe, 0x3768, 0x1B);
IMX335_write_register(ViPipe, 0x3769, 0x1B);
IMX335_write_register(ViPipe, 0x376A, 0x1B);
IMX335_write_register(ViPipe, 0x376B, 0x1B);
IMX335_write_register(ViPipe, 0x376C, 0x1A);
IMX335_write_register(ViPipe, 0x376D, 0x17);
IMX335_write_register(ViPipe, 0x376E, 0x0F);
IMX335_write_register(ViPipe, 0x3776, 0x00);
IMX335_write_register(ViPipe, 0x3777, 0x00);
IMX335_write_register(ViPipe, 0x3778, 0x46);
IMX335_write_register(ViPipe, 0x3779, 0x00);
IMX335_write_register(ViPipe, 0x377A, 0x89);
IMX335_write_register(ViPipe, 0x377B, 0x00);
IMX335_write_register(ViPipe, 0x377C, 0x08);
IMX335_write_register(ViPipe, 0x377D, 0x01);
IMX335_write_register(ViPipe, 0x377E, 0x23);
IMX335_write_register(ViPipe, 0x377F, 0x02);
IMX335_write_register(ViPipe, 0x3780, 0xD9);
IMX335_write_register(ViPipe, 0x3781, 0x03);
IMX335_write_register(ViPipe, 0x3782, 0xF5);
IMX335_write_register(ViPipe, 0x3783, 0x06);
IMX335_write_register(ViPipe, 0x3784, 0xA5);
IMX335_write_register(ViPipe, 0x3788, 0x0F);
IMX335_write_register(ViPipe, 0x378A, 0xD9);
IMX335_write_register(ViPipe, 0x378B, 0x03);
IMX335_write_register(ViPipe, 0x378C, 0xEB);
IMX335_write_register(ViPipe, 0x378D, 0x05);
IMX335_write_register(ViPipe, 0x378E, 0x87);
IMX335_write_register(ViPipe, 0x378F, 0x06);
IMX335_write_register(ViPipe, 0x3790, 0xF5);
IMX335_write_register(ViPipe, 0x3792, 0x43);
IMX335_write_register(ViPipe, 0x3794, 0x7A);
IMX335_write_register(ViPipe, 0x3796, 0xA1);
IMX335_write_register(ViPipe, 0x3A18, 0x7F);
IMX335_write_register(ViPipe, 0x3A1A, 0x37);
IMX335_write_register(ViPipe, 0x3A1C, 0x37);
IMX335_write_register(ViPipe, 0x3A1E, 0xF7);
IMX335_write_register(ViPipe, 0x3A1F, 0x00);
IMX335_write_register(ViPipe, 0x3A20, 0x3F);
IMX335_write_register(ViPipe, 0x3A22, 0x6F);
IMX335_write_register(ViPipe, 0x3A24, 0x3F);
IMX335_write_register(ViPipe, 0x3A26, 0x5F);
IMX335_write_register(ViPipe, 0x3A28, 0x2F);
imx335_default_reg_init(ViPipe);
IMX335_write_register(ViPipe, 0x3000, 0x00); // Standby Cancel
delay_ms(18);
IMX335_write_register(ViPipe, 0x3002, 0x00);
printf("----->> Sony IMX335_init_5M_2592x1944_12bit_linear 40fps Initial OK! <<-----\n");
}
//No chance 2592_1944_60fps meant to TEST configs
void IMX335__2592_1944_60fps10bit_init(VI_PIPE ViPipe)
{
//https://github.com/khadas/common_drivers/blob/68f0856b5fb80cb9c17b53ec367ff8d3c1ff142a/drivers/armisp/subdev/sensor/src/driver/sensor/IMX335_seq.h#L686
//Turned out wrong, changed a lot
//Restart the sensor and take default registry values
IMX335_write_register(ViPipe, 0x3004, 0x04);
IMX335_write_register(ViPipe, 0x3004, 0x00);
IMX335_write_register(ViPipe, 0x3000, 0x01);//pause
IMX335_write_register(ViPipe, 0x3002, 0x01);//continue
IMX335_write_register(ViPipe, 0x3004, 0x04);//restart
IMX335_write_register(ViPipe, 0x3004, 0x00);
delay_ms(18);//Not needed maybe
/*
{0x300C,0x5B,0xff,1},
{0x300D,0x40,0xff,1},
{0x3034,0x13,0xff,1},
{0x3035,0x01,0xff,1},
{0x3050,0x00,0xff,1},
{0x315A,0x02,0xff,1},
{0x316A,0x7E,0xff,1},
*/
//37Mhz
IMX335_write_register(ViPipe, 0x300C, 0xB6 ); // 0xB6- BCWAIT_TIME = 74.25
IMX335_write_register(ViPipe, 0x300D, 0x7F); // 0x7F - CPWAIT_TIME = 74.25
IMX335_write_register(ViPipe, 0x3018,0x00); //winmode normal mode
IMX335_write_register(ViPipe, 0x3034,0x26); //113h HMAX
IMX335_write_register(ViPipe, 0x3035,0x02); //HMAX
IMX335_write_register(ViPipe, 0x3050,0x00);
IMX335_write_register(ViPipe, 0x314C, 0x80); // INCKSEL1 =
IMX335_write_register(ViPipe, 0x314D, 0x00);
IMX335_write_register(ViPipe, 0x315A, 0x06); // x06 INCKSEL2 = 37.125 / 24 | 891
IMX335_write_register(ViPipe, 0x3168, 0x68); // INCKSEL3 = 37.125 / 74.25
IMX335_write_register(ViPipe, 0x316A, 0x7E); // INCKSEL4 = 37.125
IMX335_write_register(ViPipe,0x319D,0x00); //AD bits
IMX335_write_register(ViPipe, 0x319E, 0x01);//// SYS_MODE 1 = 1188Mbps, 2=891
IMX335_write_register(ViPipe,0x31A1,0x00);//Master mode
IMX335_write_register(ViPipe,0x3288,0x21);
IMX335_write_register(ViPipe,0x328A,0x02);
IMX335_write_register(ViPipe,0x3414,0x05);
IMX335_write_register(ViPipe,0x3416,0x18);
IMX335_write_register(ViPipe,0x341C,0xFF);//AD bits 01FFh=10
IMX335_write_register(ViPipe,0x341D,0x01);
IMX335_write_register(ViPipe,0x3648,0x01);
IMX335_write_register(ViPipe,0x364A,0x04);
IMX335_write_register(ViPipe,0x364C,0x04);
IMX335_write_register(ViPipe,0x3678,0x01);
IMX335_write_register(ViPipe,0x367C,0x31);
IMX335_write_register(ViPipe,0x367E,0x31);
IMX335_write_register(ViPipe,0x3706,0x10);
IMX335_write_register(ViPipe,0x3708,0x03);
IMX335_write_register(ViPipe,0x3714,0x02);
IMX335_write_register(ViPipe,0x3715,0x02);
IMX335_write_register(ViPipe,0x3716,0x01);
IMX335_write_register(ViPipe,0x3717,0x03);
IMX335_write_register(ViPipe,0x371C,0x3D);
IMX335_write_register(ViPipe,0x371D,0x3F);
IMX335_write_register(ViPipe,0x372C,0x00);
IMX335_write_register(ViPipe,0x372D,0x00);
IMX335_write_register(ViPipe,0x372E,0x46);
IMX335_write_register(ViPipe,0x372F,0x00);
IMX335_write_register(ViPipe,0x3730,0x89);
IMX335_write_register(ViPipe,0x3731,0x00);
IMX335_write_register(ViPipe,0x3732,0x08);
IMX335_write_register(ViPipe,0x3733,0x01);
IMX335_write_register(ViPipe,0x3734,0xFE);
IMX335_write_register(ViPipe,0x3735,0x05);
IMX335_write_register(ViPipe,0x3740,0x02);
IMX335_write_register(ViPipe,0x375D,0x00);
IMX335_write_register(ViPipe,0x375E,0x00);
IMX335_write_register(ViPipe,0x375F,0x11);
IMX335_write_register(ViPipe,0x3760,0x01);
IMX335_write_register(ViPipe,0x3768,0x1B);
IMX335_write_register(ViPipe,0x3769,0x1B);
IMX335_write_register(ViPipe,0x376A,0x1B);
IMX335_write_register(ViPipe,0x376B,0x1B);
IMX335_write_register(ViPipe,0x376C,0x1A);
IMX335_write_register(ViPipe,0x376D,0x17);
IMX335_write_register(ViPipe,0x376E,0x0F);
IMX335_write_register(ViPipe,0x3776,0x00);
IMX335_write_register(ViPipe,0x3777,0x00);
IMX335_write_register(ViPipe,0x3778,0x46);
IMX335_write_register(ViPipe,0x3779,0x00);
IMX335_write_register(ViPipe,0x377A,0x89);
IMX335_write_register(ViPipe,0x377B,0x00);
IMX335_write_register(ViPipe,0x377C,0x08);
IMX335_write_register(ViPipe,0x377D,0x01);
IMX335_write_register(ViPipe,0x377E,0x23);
IMX335_write_register(ViPipe,0x377F,0x02);
IMX335_write_register(ViPipe,0x3780,0xD9);
IMX335_write_register(ViPipe,0x3781,0x03);
IMX335_write_register(ViPipe,0x3782,0xF5);
IMX335_write_register(ViPipe,0x3783,0x06);
IMX335_write_register(ViPipe,0x3784,0xA5);
IMX335_write_register(ViPipe,0x3788,0x0F);
IMX335_write_register(ViPipe,0x378A,0xD9);
IMX335_write_register(ViPipe,0x378B,0x03);
IMX335_write_register(ViPipe,0x378C,0xEB);
IMX335_write_register(ViPipe,0x378D,0x05);
IMX335_write_register(ViPipe,0x378E,0x87);
IMX335_write_register(ViPipe,0x378F,0x06);
IMX335_write_register(ViPipe,0x3790,0xF5);
IMX335_write_register(ViPipe,0x3792,0x43);
IMX335_write_register(ViPipe,0x3794,0x7A);
IMX335_write_register(ViPipe,0x3796,0xA1);
// taken from manual for 1186 60fps/30fps
// --- Timings
/*
IMX335_write_register(ViPipe, 0x3A18, 0x8F);
IMX335_write_register(ViPipe, 0x3A1A, 0x4F);
IMX335_write_register(ViPipe, 0x3A1C, 0x47);
IMX335_write_register(ViPipe, 0x3A1E, 0x37);
IMX335_write_register(ViPipe, 0x3A1F, 0x01);
IMX335_write_register(ViPipe, 0x3A20, 0x4F);
IMX335_write_register(ViPipe, 0x3A22, 0x87);
IMX335_write_register(ViPipe, 0x3A24, 0x4F);
IMX335_write_register(ViPipe, 0x3A26, 0x7F);
IMX335_write_register(ViPipe, 0x3A28, 0x3F);
*/
// imx335_default_reg_init(ViPipe);
IMX335_write_register(ViPipe, 0x3000, 0x00); // Standby Cancel
delay_ms(18);
IMX335_write_register(ViPipe, 0x3002, 0x00);
printf("----->> Sony IMX335_init_5M_2592x1944_10bit_60fps Initial OK!!! <<-----\n");
}
//Cropped vertically, 16:9, on hi3516ec300 24fps at h265 are possible
void IMX335_cropped_41fps_2592_1520_init(VI_PIPE ViPipe)//added by trial and error by Tipoman.
{
SensorReset(ViPipe);
IMX335_write_register(ViPipe, 0x300C, 0x5B);
IMX335_write_register(ViPipe, 0x300D, 0x40);
//IMX335_write_register(ViPipe, 0x3018, 0x00);//window mode, 0-default | 3-binning | 4- cropping
IMX335_write_register(ViPipe, 0x3018, 0x04);//window mode, 0-default | 3-binning | 4- cropping
IMX335_write_register(ViPipe, 0x302C, 0x30);// HTRIMMING Horiz Start in cropping START
IMX335_write_register(ViPipe, 0x302D, 0x00);
IMX335_write_register(ViPipe, 0x302E, 0x20);//HNUM Horiz size 0A20 - 2592 cropping size designation
IMX335_write_register(ViPipe, 0x302F, 0x0A);//0798 for 1920
//2592x1944 2592x1520
//DevRect_w=2560 DevRect_h=1440
IMX335_write_register(ViPipe, 0x3030, 0x58);// VMAX default 1194h , 0CE4 for 2560x1440
IMX335_write_register(ViPipe, 0x3031, 0x0C);// Cropping 08F8h - 1024 0CE4 works at 41fps
IMX335_write_register(ViPipe, 0x3032, 0x00);
IMX335_write_register(ViPipe, 0x3034, 0x20);//HMAX default 0226h/0294h is for 25fps, 14A works 38fos
IMX335_write_register(ViPipe, 0x3035, 0x01);// 12C for 41fps
IMX335_write_register(ViPipe, 0x3056, 0x04); //Y_OUT_SIZE effective pixel lines 07ACh
IMX335_write_register(ViPipe, 0x3057, 0x06); //5B4h = 1440
IMX335_write_register(ViPipe, 0x3072, 0x28);// Vert Crop start 0x28
IMX335_write_register(ViPipe, 0x3073, 0x00);
IMX335_write_register(ViPipe, 0x3074, 0xB0);// AREA3_ST_Addr Upper left cropping postion
IMX335_write_register(ViPipe, 0x3075, 0x00);
IMX335_write_register(ViPipe, 0x3076, 0x08);//// AREA3_WIDTH_1 Vert Cropping Size designation * 2 , = Y_OUT_SIZE*2
IMX335_write_register(ViPipe, 0x3077, 0x0C);
IMX335_write_register(ViPipe, 0x3050, 0x00);
IMX335_write_register(ViPipe, 0x30C6, 0x12);//Black Offset Addr 12h
IMX335_write_register(ViPipe, 0x30CE, 0x64);//UNRD_Line_Max in cropping
IMX335_write_register(ViPipe, 0x30D8, 0x78);//UNREAD_ED_ADR in cropping
IMX335_write_register(ViPipe, 0x30D9, 0x0D);
IMX335_write_register(ViPipe, 0x314C, 0xC0);
IMX335_write_register(ViPipe, 0x315A, 0x06);
IMX335_write_register(ViPipe, 0x316A, 0x7E);
IMX335_write_register(ViPipe, 0x319D, 0x00);//00-10bit | 01 - 12bit
IMX335_write_register(ViPipe, 0x319E, 0x02);//// SYS_MODE = 891Mbps
IMX335_write_register(ViPipe, 0x31A1, 0x00);
IMX335_write_register(ViPipe, 0x3288, 0x21);
IMX335_write_register(ViPipe, 0x328A, 0x02);
IMX335_write_register(ViPipe, 0x3414, 0x05);
IMX335_write_register(ViPipe, 0x3416, 0x18);
IMX335_write_register(ViPipe, 0x341C, 0xFF); // Input AD bit, changing this affects output
IMX335_write_register(ViPipe, 0x341D, 0x01); //Input AD bit 0047-12bit | 01FF-10bit
IMX335_write_register(ViPipe, 0x3648, 0x01);
IMX335_write_register(ViPipe, 0x364A, 0x04);
IMX335_write_register(ViPipe, 0x364C, 0x04);
IMX335_write_register(ViPipe, 0x3678, 0x01);
IMX335_write_register(ViPipe, 0x367C, 0x31);
IMX335_write_register(ViPipe, 0x367E, 0x31);
IMX335_write_register(ViPipe, 0x3706, 0x10);
IMX335_write_register(ViPipe, 0x3708, 0x03);
IMX335_write_register(ViPipe, 0x3714, 0x02);
IMX335_write_register(ViPipe, 0x3715, 0x02);
IMX335_write_register(ViPipe, 0x3716, 0x01);
IMX335_write_register(ViPipe, 0x3717, 0x03);
IMX335_write_register(ViPipe, 0x371C, 0x3D);
IMX335_write_register(ViPipe, 0x371D, 0x3F);
IMX335_write_register(ViPipe, 0x372C, 0x00);
IMX335_write_register(ViPipe, 0x372D, 0x00);
IMX335_write_register(ViPipe, 0x372E, 0x46);
IMX335_write_register(ViPipe, 0x372F, 0x00);
IMX335_write_register(ViPipe, 0x3730, 0x89);
IMX335_write_register(ViPipe, 0x3731, 0x00);
IMX335_write_register(ViPipe, 0x3732, 0x08);
IMX335_write_register(ViPipe, 0x3733, 0x01);
IMX335_write_register(ViPipe, 0x3734, 0xFE);
IMX335_write_register(ViPipe, 0x3735, 0x05);
IMX335_write_register(ViPipe, 0x3740, 0x02);
IMX335_write_register(ViPipe, 0x375D, 0x00);
IMX335_write_register(ViPipe, 0x375E, 0x00);
IMX335_write_register(ViPipe, 0x375F, 0x11);
IMX335_write_register(ViPipe, 0x3760, 0x01);
IMX335_write_register(ViPipe, 0x3768, 0x1B);
IMX335_write_register(ViPipe, 0x3769, 0x1B);
IMX335_write_register(ViPipe, 0x376A, 0x1B);
IMX335_write_register(ViPipe, 0x376B, 0x1B);
IMX335_write_register(ViPipe, 0x376C, 0x1A);
IMX335_write_register(ViPipe, 0x376D, 0x17);
IMX335_write_register(ViPipe, 0x376E, 0x0F);
IMX335_write_register(ViPipe, 0x3776, 0x00);
IMX335_write_register(ViPipe, 0x3777, 0x00);
IMX335_write_register(ViPipe, 0x3778, 0x46);
IMX335_write_register(ViPipe, 0x3779, 0x00);
IMX335_write_register(ViPipe, 0x377A, 0x89);
IMX335_write_register(ViPipe, 0x377B, 0x00);
IMX335_write_register(ViPipe, 0x377C, 0x08);
IMX335_write_register(ViPipe, 0x377D, 0x01);
IMX335_write_register(ViPipe, 0x377E, 0x23);
IMX335_write_register(ViPipe, 0x377F, 0x02);
IMX335_write_register(ViPipe, 0x3780, 0xD9);
IMX335_write_register(ViPipe, 0x3781, 0x03);
IMX335_write_register(ViPipe, 0x3782, 0xF5);
IMX335_write_register(ViPipe, 0x3783, 0x06);
IMX335_write_register(ViPipe, 0x3784, 0xA5);
IMX335_write_register(ViPipe, 0x3788, 0x0F);
IMX335_write_register(ViPipe, 0x378A, 0xD9);
IMX335_write_register(ViPipe, 0x378B, 0x03);
IMX335_write_register(ViPipe, 0x378C, 0xEB);
IMX335_write_register(ViPipe, 0x378D, 0x05);
IMX335_write_register(ViPipe, 0x378E, 0x87);
IMX335_write_register(ViPipe, 0x378F, 0x06);
IMX335_write_register(ViPipe, 0x3790, 0xF5);
IMX335_write_register(ViPipe, 0x3792, 0x43);
IMX335_write_register(ViPipe, 0x3794, 0x7A);
IMX335_write_register(ViPipe, 0x3796, 0xA1);
IMX335_write_register(ViPipe, 0x3A18, 0x7F);
IMX335_write_register(ViPipe, 0x3A1A, 0x37);
IMX335_write_register(ViPipe, 0x3A1C, 0x37);
IMX335_write_register(ViPipe, 0x3A1E, 0xF7);
IMX335_write_register(ViPipe, 0x3A1F, 0x00);
IMX335_write_register(ViPipe, 0x3A20, 0x3F);
IMX335_write_register(ViPipe, 0x3A22, 0x6F);
IMX335_write_register(ViPipe, 0x3A24, 0x3F);
IMX335_write_register(ViPipe, 0x3A26, 0x5F);
IMX335_write_register(ViPipe, 0x3A28, 0x2F);
imx335_default_reg_init(ViPipe);
IMX335_write_register(ViPipe, 0x3000, 0x00); // Standby Cancel
delay_ms(18);
IMX335_write_register(ViPipe, 0x3002, 0x00);
printf("-------Sony IMX335__2592_1520_10bit_52fps Initial OK!-------\n");
}
void SensorReset(VI_PIPE ViPipe){
IMX335_write_register(ViPipe, 0x3000, 0x01); /* standby */
IMX335_write_register(ViPipe, 0x3001, 0x00);
delay_ms(18);//Not needed maybe
IMX335_write_register(ViPipe, 0x3002, 0x01);//continue
IMX335_write_register(ViPipe, 0x3003, 0x00);
delay_ms(18);//Not needed maybe
IMX335_write_register(ViPipe, 0x3004, 0x04);//restart
delay_ms(18);//Not needed maybe
IMX335_write_register(ViPipe, 0x3004, 0x00);
}
void IMX335_cropped_60fps_1080p_init(VI_PIPE ViPipe)//added by trial and error by Tipoman.
{
//Restart the sensor and take default registry values
/*
IMX335_write_register(ViPipe, 0x3004, 0x04);
IMX335_write_register(ViPipe, 0x3004, 0x00);
IMX335_write_register(ViPipe, 0x3000, 0x01);//pause
IMX335_write_register(ViPipe, 0x3002, 0x01);//continue
IMX335_write_register(ViPipe, 0x3004, 0x04);//restart
IMX335_write_register(ViPipe, 0x3004, 0x00);
delay_ms(18);//Not needed maybe
IMX335_write_register(ViPipe, 0x3000, 0x01); // standby
*/
SensorReset(ViPipe);
IMX335_write_register(ViPipe, 0x300C, 0x5B);
IMX335_write_register(ViPipe, 0x300D, 0x40);
//IMX335_write_register(ViPipe, 0x3018, 0x00);//window mode, 0-default | 3-binning | 4- cropping
IMX335_write_register(ViPipe, 0x3018, 0x04);//window mode, 0-default | 3-binning | 4- cropping
IMX335_write_register(ViPipe, 0x302C, 0x80);//HTRIMMING Horiz Start in cropping START
IMX335_write_register(ViPipe, 0x302D, 0x01);
IMX335_write_register(ViPipe, 0x302E, 0x98);//HNUM Horiz size 0A20 - 2592 cropping size designation
IMX335_write_register(ViPipe, 0x302F, 0x07);
//2592x1944 2592x1520
//DevRect_w=2560 DevRect_h=1440
IMX335_write_register(ViPipe, 0x3030, 0xF8);//VMAX default 1194h , 0CE4 for 2560x1440
IMX335_write_register(ViPipe, 0x3031, 0x08);// Cropping 08F8h - 1024 //Input AD
IMX335_write_register(ViPipe, 0x3032, 0x00);
IMX335_write_register(ViPipe, 0x3034, 0x6E);//HMAX default 0226h gives 59fps at 1080p, encoder can't handle more than 55!
IMX335_write_register(ViPipe, 0x3035, 0x01);//16Eh for 90fps
//Can do 90fps when encoder set at 1280x720 and 16Eh
IMX335_write_register(ViPipe, 0x3056, 0x4C); //Y_OUT_SIZE effective pixel lines 07ACh
IMX335_write_register(ViPipe, 0x3057, 0x04); //5B4h = 1440
IMX335_write_register(ViPipe, 0x3072, 0x28);// Vert Crop start
IMX335_write_register(ViPipe, 0x3073, 0x00);
IMX335_write_register(ViPipe, 0x3074, 0x10);// AREA3_ST_Addr Upper left cropping postion
IMX335_write_register(ViPipe, 0x3075, 0x04);
IMX335_write_register(ViPipe, 0x3076, 0x98);//// AREA3_WIDTH_1 Vert Cropping Size designation * 2 , = Y_OUT_SIZE*2
IMX335_write_register(ViPipe, 0x3077, 0x08);
IMX335_write_register(ViPipe, 0x3050, 0x00);
IMX335_write_register(ViPipe, 0x30C6, 0x12);//Black Offset Addr 12h
IMX335_write_register(ViPipe, 0x30CE, 0x64);//UNRD_Line_Max in cropping
IMX335_write_register(ViPipe, 0x30D8, 0x78);//UNREAD_ED_ADR in cropping
IMX335_write_register(ViPipe, 0x30D9, 0x0D);
IMX335_write_register(ViPipe, 0x314C, 0xC0);
IMX335_write_register(ViPipe, 0x315A, 0x06);
IMX335_write_register(ViPipe, 0x316A, 0x7E);
IMX335_write_register(ViPipe, 0x319D, 0x00);//00-10bit | 01 - 12bit
IMX335_write_register(ViPipe, 0x319E, 0x02);//// SYS_MODE = 891Mbps
IMX335_write_register(ViPipe, 0x31A1, 0x00);
IMX335_write_register(ViPipe, 0x3288, 0x21);
IMX335_write_register(ViPipe, 0x328A, 0x02);
IMX335_write_register(ViPipe, 0x3414, 0x05);
IMX335_write_register(ViPipe, 0x3416, 0x18);
IMX335_write_register(ViPipe, 0x341C, 0xFF); // Input AD bit, changing this affects output
IMX335_write_register(ViPipe, 0x341D, 0x01); //Input AD bit 0047-12bit | 01FF-10bit
IMX335_write_register(ViPipe, 0x3648, 0x01);
IMX335_write_register(ViPipe, 0x364A, 0x04);
IMX335_write_register(ViPipe, 0x364C, 0x04);
IMX335_write_register(ViPipe, 0x3678, 0x01);
IMX335_write_register(ViPipe, 0x367C, 0x31);
IMX335_write_register(ViPipe, 0x367E, 0x31);
IMX335_write_register(ViPipe, 0x3706, 0x10);
IMX335_write_register(ViPipe, 0x3708, 0x03);
IMX335_write_register(ViPipe, 0x3714, 0x02);
IMX335_write_register(ViPipe, 0x3715, 0x02);
IMX335_write_register(ViPipe, 0x3716, 0x01);
IMX335_write_register(ViPipe, 0x3717, 0x03);
IMX335_write_register(ViPipe, 0x371C, 0x3D);
IMX335_write_register(ViPipe, 0x371D, 0x3F);
IMX335_write_register(ViPipe, 0x372C, 0x00);
IMX335_write_register(ViPipe, 0x372D, 0x00);
IMX335_write_register(ViPipe, 0x372E, 0x46);
IMX335_write_register(ViPipe, 0x372F, 0x00);
IMX335_write_register(ViPipe, 0x3730, 0x89);
IMX335_write_register(ViPipe, 0x3731, 0x00);
IMX335_write_register(ViPipe, 0x3732, 0x08);
IMX335_write_register(ViPipe, 0x3733, 0x01);
IMX335_write_register(ViPipe, 0x3734, 0xFE);
IMX335_write_register(ViPipe, 0x3735, 0x05);
IMX335_write_register(ViPipe, 0x3740, 0x02);
IMX335_write_register(ViPipe, 0x375D, 0x00);
IMX335_write_register(ViPipe, 0x375E, 0x00);
IMX335_write_register(ViPipe, 0x375F, 0x11);
IMX335_write_register(ViPipe, 0x3760, 0x01);
IMX335_write_register(ViPipe, 0x3768, 0x1B);
IMX335_write_register(ViPipe, 0x3769, 0x1B);
IMX335_write_register(ViPipe, 0x376A, 0x1B);
IMX335_write_register(ViPipe, 0x376B, 0x1B);
IMX335_write_register(ViPipe, 0x376C, 0x1A);
IMX335_write_register(ViPipe, 0x376D, 0x17);
IMX335_write_register(ViPipe, 0x376E, 0x0F);
IMX335_write_register(ViPipe, 0x3776, 0x00);
IMX335_write_register(ViPipe, 0x3777, 0x00);
IMX335_write_register(ViPipe, 0x3778, 0x46);
IMX335_write_register(ViPipe, 0x3779, 0x00);
IMX335_write_register(ViPipe, 0x377A, 0x89);
IMX335_write_register(ViPipe, 0x377B, 0x00);
IMX335_write_register(ViPipe, 0x377C, 0x08);
IMX335_write_register(ViPipe, 0x377D, 0x01);
IMX335_write_register(ViPipe, 0x377E, 0x23);
IMX335_write_register(ViPipe, 0x377F, 0x02);
IMX335_write_register(ViPipe, 0x3780, 0xD9);
IMX335_write_register(ViPipe, 0x3781, 0x03);
IMX335_write_register(ViPipe, 0x3782, 0xF5);
IMX335_write_register(ViPipe, 0x3783, 0x06);
IMX335_write_register(ViPipe, 0x3784, 0xA5);
IMX335_write_register(ViPipe, 0x3788, 0x0F);
IMX335_write_register(ViPipe, 0x378A, 0xD9);
IMX335_write_register(ViPipe, 0x378B, 0x03);
IMX335_write_register(ViPipe, 0x378C, 0xEB);
IMX335_write_register(ViPipe, 0x378D, 0x05);
IMX335_write_register(ViPipe, 0x378E, 0x87);
IMX335_write_register(ViPipe, 0x378F, 0x06);
IMX335_write_register(ViPipe, 0x3790, 0xF5);
IMX335_write_register(ViPipe, 0x3792, 0x43);
IMX335_write_register(ViPipe, 0x3794, 0x7A);
IMX335_write_register(ViPipe, 0x3796, 0xA1);
IMX335_write_register(ViPipe, 0x3A18, 0x7F);
IMX335_write_register(ViPipe, 0x3A1A, 0x37);
IMX335_write_register(ViPipe, 0x3A1C, 0x37);
IMX335_write_register(ViPipe, 0x3A1E, 0xF7);
IMX335_write_register(ViPipe, 0x3A1F, 0x00);
IMX335_write_register(ViPipe, 0x3A20, 0x3F);
IMX335_write_register(ViPipe, 0x3A22, 0x6F);
IMX335_write_register(ViPipe, 0x3A24, 0x3F);
IMX335_write_register(ViPipe, 0x3A26, 0x5F);
IMX335_write_register(ViPipe, 0x3A28, 0x2F);
imx335_default_reg_init(ViPipe);
IMX335_write_register(ViPipe, 0x3000, 0x00); // Standby Cancel
delay_ms(18);
IMX335_write_register(ViPipe, 0x3002, 0x00);
printf("------=>Sony IMX335_Cropped_1920x1080_10bit_90fps Initial OK!-------\n");
}
void IMX335_wdr_5M30_10bit_init(VI_PIPE ViPipe)
{
IMX335_write_register(ViPipe, 0x3000, 0x01);
IMX335_write_register(ViPipe, 0x3002, 0x01);
IMX335_write_register(ViPipe, 0x300C, 0x5B);
IMX335_write_register(ViPipe, 0x300D, 0x40);
IMX335_write_register(ViPipe, 0x3018, 0x00);
IMX335_write_register(ViPipe, 0x302C, 0x30);
IMX335_write_register(ViPipe, 0x302D, 0x00);
IMX335_write_register(ViPipe, 0x302E, 0x38);
IMX335_write_register(ViPipe, 0x302F, 0x0A);
IMX335_write_register(ViPipe, 0x3030, 0xB5);
IMX335_write_register(ViPipe, 0x3031, 0x0F);
IMX335_write_register(ViPipe, 0x3032, 0x00);
IMX335_write_register(ViPipe, 0x3034, 0x2C);
IMX335_write_register(ViPipe, 0x3035, 0x01);
IMX335_write_register(ViPipe, 0x304E, 0x00);
IMX335_write_register(ViPipe, 0x304F, 0x00);
IMX335_write_register(ViPipe, 0x3050, 0x00);
IMX335_write_register(ViPipe, 0x3072, 0x28);
IMX335_write_register(ViPipe, 0x3073, 0x00);
IMX335_write_register(ViPipe, 0x3074, 0xB0);
IMX335_write_register(ViPipe, 0x3075, 0x00);
IMX335_write_register(ViPipe, 0x3076, 0x58);
IMX335_write_register(ViPipe, 0x3077, 0x0F);
IMX335_write_register(ViPipe, 0x3078, 0x01);
IMX335_write_register(ViPipe, 0x3079, 0x02);
IMX335_write_register(ViPipe, 0x307A, 0xFF);
IMX335_write_register(ViPipe, 0x307B, 0x02);
IMX335_write_register(ViPipe, 0x307C, 0x00);
IMX335_write_register(ViPipe, 0x307D, 0x00);
IMX335_write_register(ViPipe, 0x307E, 0x00);
IMX335_write_register(ViPipe, 0x307F, 0x00);
IMX335_write_register(ViPipe, 0x3080, 0x01);
IMX335_write_register(ViPipe, 0x3081, 0x02);
IMX335_write_register(ViPipe, 0x3082, 0xFF);
IMX335_write_register(ViPipe, 0x3083, 0x02);
IMX335_write_register(ViPipe, 0x3084, 0x00);
IMX335_write_register(ViPipe, 0x3085, 0x00);
IMX335_write_register(ViPipe, 0x3086, 0x00);
IMX335_write_register(ViPipe, 0x3087, 0x00);
IMX335_write_register(ViPipe, 0x30A4, 0x33);
IMX335_write_register(ViPipe, 0x30A8, 0x10);
IMX335_write_register(ViPipe, 0x30A9, 0x04);
IMX335_write_register(ViPipe, 0x30AC, 0x00);
IMX335_write_register(ViPipe, 0x30AD, 0x00);
IMX335_write_register(ViPipe, 0x30B0, 0x10);
IMX335_write_register(ViPipe, 0x30B1, 0x08);
IMX335_write_register(ViPipe, 0x30B4, 0x00);
IMX335_write_register(ViPipe, 0x30B5, 0x00);
IMX335_write_register(ViPipe, 0x30B6, 0x00);
IMX335_write_register(ViPipe, 0x30B7, 0x00);
IMX335_write_register(ViPipe, 0x3112, 0x08);
IMX335_write_register(ViPipe, 0x3113, 0x00);
IMX335_write_register(ViPipe, 0x3116, 0x08);
IMX335_write_register(ViPipe, 0x3117, 0x00);
IMX335_write_register(ViPipe, 0x314C, 0x38);
IMX335_write_register(ViPipe, 0x314D, 0x01);
IMX335_write_register(ViPipe, 0x315A, 0x07);
IMX335_write_register(ViPipe, 0x3167, 0x02);
IMX335_write_register(ViPipe, 0x3168, 0xA9);
IMX335_write_register(ViPipe, 0x316A, 0x7F);
IMX335_write_register(ViPipe, 0x3199, 0x00);
IMX335_write_register(ViPipe, 0x319D, 0x00);
IMX335_write_register(ViPipe, 0x319E, 0x02);
IMX335_write_register(ViPipe, 0x31A0, 0x2A);
IMX335_write_register(ViPipe, 0x3300, 0x00);
IMX335_write_register(ViPipe, 0x3302, 0x32);
IMX335_write_register(ViPipe, 0x341C, 0xFF);
IMX335_write_register(ViPipe, 0x341D, 0x01);
IMX335_write_register(ViPipe, 0x3A00, 0x01);
IMX335_write_register(ViPipe, 0x3A01, 0x03);
IMX335_write_register(ViPipe, 0x3A04, 0x48);
IMX335_write_register(ViPipe, 0x3A05, 0x09);
IMX335_write_register(ViPipe, 0x3A18, 0x6F);
IMX335_write_register(ViPipe, 0x3A19, 0x00);
IMX335_write_register(ViPipe, 0x3A1A, 0x2F);
IMX335_write_register(ViPipe, 0x3A1B, 0x00);
IMX335_write_register(ViPipe, 0x3A1C, 0x2F);
IMX335_write_register(ViPipe, 0x3A1D, 0x00);
IMX335_write_register(ViPipe, 0x3A1E, 0xD7);
IMX335_write_register(ViPipe, 0x3A1F, 0x00);
IMX335_write_register(ViPipe, 0x3A20, 0x37);
IMX335_write_register(ViPipe, 0x3A21, 0x00);
IMX335_write_register(ViPipe, 0x3A22, 0x5F);
IMX335_write_register(ViPipe, 0x3A23, 0x00);
IMX335_write_register(ViPipe, 0x3A24, 0x37);
IMX335_write_register(ViPipe, 0x3A25, 0x00);
IMX335_write_register(ViPipe, 0x3A26, 0x57);
IMX335_write_register(ViPipe, 0x3A27, 0x00);