hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/media/i2c/nvp6158_drv/nvp6158_video.c
....@@ -35,9 +35,9 @@
3535 extern unsigned char nvp6158_det_mode[16];
3636 extern unsigned int nvp6158_gCoaxFirmUpdateFlag[16];
3737
38
-unsigned char nvp6158_motion_sens_tbl[8]= {0xe0,0xc8,0xa0,0x98,0x78,0x68,0x50,0x48};
39
-unsigned char nvp6158_ch_mode_status[16]={[0 ... 15]=0xff};
40
-unsigned char nvp6158_ch_vfmt_status[16]={[0 ... 15]=0xff};
38
+unsigned char nvp6158_motion_sens_tbl[8] = {0xe0, 0xc8, 0xa0, 0x98, 0x78, 0x68, 0x50, 0x48};
39
+unsigned char nvp6158_ch_mode_status[16] = {[0 ... 15] = 0xff};
40
+unsigned char nvp6158_ch_vfmt_status[16] = {[0 ... 15] = 0xff};
4141 #ifdef _ENABLE_DET_DEBOUNCE_
4242 NVP6158_INFORMATION_S nvp6158_s_raptor3_vfmts;
4343 #endif
....@@ -47,39 +47,28 @@
4747 int tmp = 0;
4848 int i = 0, j= 0;
4949
50
- printk("***************IIC ADDR 0x%02x - CH[%02d] *****************\r\n", nvp6158_iic_addr[ch/4], ch );
51
- printk("***************Chip[0x%02x] Bank[0x%x]*****************\r\n", nvp6158_iic_addr[ch/4], bank );
50
+ printk("***************IIC ADDR 0x%02x - CH[%02d] *****************\r\n",
51
+ nvp6158_iic_addr[ch/4], ch );
52
+ printk("***************Chip[0x%02x] Bank[0x%x]*****************\r\n",
53
+ nvp6158_iic_addr[ch/4], bank );
5254 gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, bank );
53
- for (i = 0;i<=0xF;i++)
54
- {
55
- if(i==0)
56
- {
57
- printk(" 0x%02x ",i);
58
- }
59
- else if (i==0xF)
60
- {
55
+ for (i = 0; i <= 0xF; i++) {
56
+ if(i == 0) {
57
+ printk("0x%02x ",i);
58
+ } else if (i==0xF) {
6159 printk("0x%02x\r\n",i);
62
- }
63
- else
64
- {
60
+ } else {
6561 printk("0x%02x ",i);
6662 }
6763 }
68
- for (i = 0;i<=0xF;i++)
69
- {
70
- for(j = 0;j<=0xF;j++)
71
- {
72
- tmp = gpio_i2c_read(nvp6158_iic_addr[ch/4], (i<<4)|j);
73
- if (j==0)
74
- {
75
- printk("0x%02x-0x%02x ",(i<<4)|j,tmp);
76
- }
77
- else if (j==0xF)
78
- {
64
+ for (i = 0; i <= 0xF; i++) {
65
+ for(j = 0; j <= 0xF; j++) {
66
+ tmp = gpio_i2c_read(nvp6158_iic_addr[ch / 4], (i << 4) | j);
67
+ if (j == 0) {
68
+ printk("0x%02x-0x%02x ",(i << 4) | j, tmp);
69
+ } else if (j == 0xF) {
7970 printk("0x%02x\r\n",tmp);
80
- }
81
- else
82
- {
71
+ } else {
8372 printk("0x%02x ",tmp);
8473 }
8574 }
....@@ -90,17 +79,19 @@
9079 {
9180 unsigned char adc_value;
9281
93
- gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, 0x01);
94
- adc_value = gpio_i2c_read(nvp6158_iic_addr[ch/4], 0x84+ch%4);
95
- printk(">>>>> DRV[%s:%d] CH:%d, Bank:0x%02x, ADC clock delay:0x%x\n", __func__, __LINE__, ch, nvp6158_iic_addr[ch/4], adc_value );
82
+ gpio_i2c_write(nvp6158_iic_addr[ch / 4], 0xFF, 0x01);
83
+ adc_value = gpio_i2c_read(nvp6158_iic_addr[ch / 4], 0x84 + ch % 4);
84
+ printk(">>>>> DRV[%s:%d] CH:%d, Bank:0x%02x, ADC clock delay:0x%x\n",
85
+ __func__, __LINE__, ch, nvp6158_iic_addr[ch/4], adc_value );
9686 return adc_value;
9787 }
9888
9989 void nvp6158_video_set_adcclk(unsigned char ch, unsigned char value)
10090 {
101
- gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, 0x01);
102
- gpio_i2c_write(nvp6158_iic_addr[ch/4], 0x84+ch%4, value);
103
- printk(">>>>> DRV[%s:%d] CH:%d, Bank:0x%02x, ADC clock delay:0x%x\n", __func__, __LINE__, ch, nvp6158_iic_addr[ch/4], value );
91
+ gpio_i2c_write(nvp6158_iic_addr[ch / 4], 0xFF, 0x01);
92
+ gpio_i2c_write(nvp6158_iic_addr[ch / 4], 0x84 + ch % 4, value);
93
+ printk(">>>>> DRV[%s:%d] CH:%d, Bank:0x%02x, ADC clock delay:0x%x\n",
94
+ __func__, __LINE__, ch, nvp6158_iic_addr[ch/4], value );
10495 }
10596
10697 static __maybe_unused void NVP6158_set_afe(unsigned char ch, unsigned char onoff)
....@@ -121,9 +112,7 @@
121112
122113 static __maybe_unused void nvp6158_datareverse(unsigned char chip, unsigned char port)
123114 {
124
-/*
125
-BANK1 0xCB[3:0],ÿ¸öbit¿ØÖÆÒ»¸öbt656µÄÊý¾Ý˳Ðò£¬1Ϊ·´Ðò£¬0ΪÕýÐò¡£
126
-*/
115
+
127116 unsigned char tmp;
128117 gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x01);
129118 tmp = gpio_i2c_read(nvp6158_iic_addr[chip], 0xCB);
....@@ -137,12 +126,9 @@
137126 unsigned char val_1x81;
138127 gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x01);
139128 val_1x81 = gpio_i2c_read(nvp6158_iic_addr[chip], 0x81);
140
- if(flag == 1)
141
- {
129
+ if(flag == 1) {
142130 val_1x81 |= 0x02;
143
- }
144
- else
145
- {
131
+ } else {
146132 val_1x81 &= 0xFD;
147133 }
148134 gpio_i2c_write(nvp6158_iic_addr[chip], 0x81, val_1x81);
....@@ -185,14 +171,13 @@
185171 //VDO_1/2 disabled, VCLK_x disabled
186172 gpio_i2c_write(0x60, 0xFF, 0x01);
187173 gpio_i2c_write(0x60, 0xCA, 0x00);
188
- for(ch=0;ch<4;ch++)
189
- {
174
+ for(ch = 0; ch < 4; ch++) {
190175 gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x00);
191176 //gpio_i2c_write(nvp6158_iic_addr[chip], 0x00+ch, 0x10);
192
- gpio_i2c_write(nvp6158_iic_addr[chip], 0x22+4*ch, 0x0B);
193
- gpio_i2c_write(nvp6158_iic_addr[chip], 0x23+4*ch, 0x41);
177
+ gpio_i2c_write(nvp6158_iic_addr[chip], 0x22+ 4 * ch, 0x0B);
178
+ gpio_i2c_write(nvp6158_iic_addr[chip], 0x23+ 4 * ch, 0x41);
194179
195
- gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x05+ch%4);
180
+ gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x05 + ch % 4);
196181 gpio_i2c_write(nvp6158_iic_addr[chip], 0x00, 0xD0); // Clamp speed
197182 gpio_i2c_write(nvp6158_iic_addr[chip], 0xA9, 0x80);
198183 gpio_i2c_write(nvp6158_iic_addr[chip], 0x76, 0x00);
....@@ -227,27 +212,24 @@
227212 printk("debunce:0x%02X, debncIdx:%d\n", pInformation->debounce[ch][pInformation->debounceidx[ch]], pInformation->debounceidx[ch]);
228213 */
229214 pInformation->debounceidx[ch]++;
230
- pInformation->debounceidx[ch] = ( (pInformation->debounceidx[ch] % MAX_DEBOUNCE_CNT) == 0 ) ? 0 : pInformation->debounceidx[ch];
215
+ pInformation->debounceidx[ch] = ( (pInformation->debounceidx[ch] % MAX_DEBOUNCE_CNT) == 0 ) ?
216
+ 0 : pInformation->debounceidx[ch];
231217
232218 oVfc = pInformation->debounce[ch][pInformation->debounceidx[ch]];
233
- for( i = 0; i < MAX_DEBOUNCE_CNT; i++ )
234
- {
235
- if( oVfc != pInformation->debounce[ch][i])
236
- {
219
+ for( i = 0; i < MAX_DEBOUNCE_CNT; i++ ) {
220
+ if( oVfc != pInformation->debounce[ch][i]) {
237221 break;
238222 }
239223 }
240
- if( i == MAX_DEBOUNCE_CNT )
241
- {
224
+ if( i == MAX_DEBOUNCE_CNT ) {
242225 oFmtB5Def = NVP6158_NC_VD_AUTO_VFCtoFMTDEF(ch, oVfc);
243226 //if( ( oFmtB5Def != AHD30_5M_20P ) && ( oFmtB5Def != pInformation->prevideofmt[ch] ) )
244227 if( ( ( oFmtB5Def != AHD30_5M_20P ) && ( oFmtB5Def != CVI_8M_15P ) &&
245228 ( oFmtB5Def != CVI_8M_12_5P ) && ( oFmtB5Def != CVI_HD_30P_EX ) &&
246229 ( oFmtB5Def != AHD20_1080P_25P ) && ( oFmtB5Def != AHD20_1080P_30P ) &&
247
- ( oFmtB5Def != CVI_FHD_25P ) )
248
- && ( oFmtB5Def != pInformation->prevideofmt[ch] ) )
249
- {
250
- printk("\n\n\n>>>>>>WATCH OUT<<<<<<ch[%d] oVfc[%2x]oFmtB5Def[%2x] != pInformation->prevideofmt[%2x]\n\n\n", ch, oVfc, oFmtB5Def , pInformation->prevideofmt[ch]);
230
+ ( oFmtB5Def != CVI_FHD_25P ) ) && ( oFmtB5Def != pInformation->prevideofmt[ch] ) ) {
231
+ printk("\n\n\n>>>>>>WATCH OUT<<<<<<ch[%d] oVfc[%2x]oFmtB5Def[%2x] != pInformation->prevideofmt[%2x]\n\n\n",
232
+ ch, oVfc, oFmtB5Def , pInformation->prevideofmt[ch]);
251233 ret = -1;
252234 }
253235 }
....@@ -273,8 +255,7 @@
273255 void nvp6158_set_colorpattern(void)
274256 {
275257 int chip;
276
- for(chip=0;chip<nvp6158_cnt;chip++)
277
- {
258
+ for(chip = 0; chip < nvp6158_cnt; chip++) {
278259 gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x00);
279260 gpio_i2c_write(nvp6158_iic_addr[chip], 0x78, 0xaa);
280261 gpio_i2c_write(nvp6158_iic_addr[chip], 0x79, 0xaa);
....@@ -298,8 +279,7 @@
298279 int chip;
299280
300281 printk("[NVP6158_VIDEO] %s(%d) \n", __func__, __LINE__);
301
- for(chip=0;chip<nvp6158_cnt;chip++)
302
- {
282
+ for(chip = 0; chip < nvp6158_cnt; chip++) {
303283 gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x05);
304284 gpio_i2c_write(nvp6158_iic_addr[chip], 0x2c, 0x08);
305285 gpio_i2c_write(nvp6158_iic_addr[chip], 0x6a, 0x80);
....@@ -326,8 +306,7 @@
326306 int chip;
327307
328308 printk("[NVP6158_VIDEO] %s(%d) \n", __func__, __LINE__);
329
- for(chip=0;chip<nvp6158_cnt;chip++)
330
- {
309
+ for(chip = 0; chip < nvp6158_cnt; chip++) {
331310 gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x05);
332311 gpio_i2c_write(nvp6158_iic_addr[chip], 0x2c, 0x08);
333312 gpio_i2c_write(nvp6158_iic_addr[chip], 0x6a, 0x80);
....@@ -382,32 +361,27 @@
382361 sNoVideo.devnum = ch/4;
383362
384363 /* get vfc and videoloss */
385
- if(nvp6158_chip_id[ch/4]==NVP6158C_R0_ID || nvp6158_chip_id[ch/4]==NVP6158_R0_ID)
364
+ if(nvp6158_chip_id[ch/4]==NVP6158C_R0_ID || nvp6158_chip_id[ch/4] == NVP6158_R0_ID)
386365 nvp6158_video_input_vfc_read(&sVFC);
387366 else
388367 nvp6168_video_input_vfc_read(&sVFC);
389368 nvp6158_video_input_novid_read(&sNoVideo);
390369 svin_vfc_bak.ch = ch%4;
391370 svin_vfc_bak.devnum = ch/4;
392
- if(nvp6158_chip_id[ch/4]==NVP6158C_R0_ID || nvp6158_chip_id[ch/4]==NVP6158_R0_ID)
371
+ if(nvp6158_chip_id[ch/4]==NVP6158C_R0_ID || nvp6158_chip_id[ch/4] == NVP6158_R0_ID)
393372 nvp6158_video_input_onvideo_check_data(&svin_vfc_bak);
394373
395374 /* check vfc&videoloss and run debounce */
396
- if(((((sVFC.vfc >> 4 ) & 0xF) != 0xF) && ((sVFC.vfc & 0x0F) != 0xF)) && !sNoVideo.novid) // OnVideo
397
- {
375
+ if(((((sVFC.vfc >> 4 ) & 0xF) != 0xF) && ((sVFC.vfc & 0x0F) != 0xF)) && !sNoVideo.novid) {// OnVideo
398376 /* convert vfc to formatDefine for APP and save videoloss information */
399377 oCurVidFmt = NVP6158_NC_VD_AUTO_VFCtoFMTDEF(ch, sVFC.vfc);
400378
401379 /* debouce */
402380 pInformation->curvideofmt[ch] = oCurVidFmt;
403381 pInformation->vfc[ch] = sVFC.vfc;
404
- }
405
- else if(((((sVFC.vfc >> 4 ) & 0xF) == 0xF) && ((sVFC.vfc & 0x0F) == 0xF)) && !sNoVideo.novid)
406
- {
407
- if(nvp6158_chip_id[ch/4]==NVP6158C_R0_ID || nvp6158_chip_id[ch/4]==NVP6158_R0_ID)
408
- {
409
- if(svin_vfc_bak.vfc == 0xFF)
410
- {
382
+ } else if (((((sVFC.vfc >> 4 ) & 0xF) == 0xF) && ((sVFC.vfc & 0x0F) == 0xF)) && !sNoVideo.novid) {
383
+ if(nvp6158_chip_id[ch/4]==NVP6158C_R0_ID || nvp6158_chip_id[ch/4]==NVP6158_R0_ID) {
384
+ if(svin_vfc_bak.vfc == 0xFF) {
411385 //nvp6158_channel_reset(ch);
412386 //nvp6158_adc_reset(ch);
413387 }
....@@ -415,8 +389,7 @@
415389 }
416390
417391 /* check novideo option */
418
- if( !sNoVideo.novid )
419
- {
392
+ if( !sNoVideo.novid ) {
420393 pInformation->curvideoloss[ch] = VIDEO_LOSS_ON;
421394 }
422395
....@@ -431,9 +404,9 @@
431404 * warning :
432405 *******************************************************************************/
433406 #if(AHD_720P30_Detect_Count == 0)
434
-static int CVI_720P30[16]={0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,};
407
+static int CVI_720P30[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,};
435408 #else
436
-static int CVI_720P30[16]={1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1}; //2020-12-16 for ahd 720p30 detect slow
409
+static int CVI_720P30[16]={1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; //2020-12-16 for ahd 720p30 detect slow
437410 #endif
438411 unsigned int nvp6158_video_fmt_det(const unsigned char ch, NVP6158_INFORMATION_S *ps_nvp6158_vfmts)
439412 {
....@@ -453,93 +426,73 @@
453426 oCurVideofmt = ps_nvp6158_vfmts->curvideofmt[ch];
454427 oPreVideofmt = ps_nvp6158_vfmts->prevideofmt[ch];
455428
456
- if( ps_nvp6158_vfmts->curvideoloss[ch] == VIDEO_LOSS_ON)
457
- {
429
+ if( ps_nvp6158_vfmts->curvideoloss[ch] == VIDEO_LOSS_ON) {
458430 /* on video */
459
- if( (oCurVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN) && (oPreVideofmt == NC_VIVO_CH_FORMATDEF_UNKNOWN) )
460
- {
431
+ if( (oCurVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN) && (oPreVideofmt == NC_VIVO_CH_FORMATDEF_UNKNOWN) ) {
461432 oFmtDef = NVP6158_NC_VD_AUTO_VFCtoFMTDEF( ch, ps_nvp6158_vfmts->vfc[ch] );
462433 sDevChInfo.ch = ch%4;
463434 sDevChInfo.devnum = ch/4;
464435 sDevChInfo.fmt_def = oFmtDef;
465
- if(oFmtDef == AHD30_5M_20P )
466
- {
436
+ if(oFmtDef == AHD30_5M_20P ) {
467437 printk("[CH:%d] >> finding format: %x....\n", ch, oFmtDef);
468438
469439 nvp6158_video_input_ahd_tvi_distinguish(&sDevChInfo);
470440 oFmtDef = sDevChInfo.fmt_def;
471441
472442 ps_nvp6158_vfmts->curvideofmt[ch] = oFmtDef;
473
- }
474
- else if( oFmtDef == CVI_8M_15P || oFmtDef == CVI_8M_12_5P )
475
- {
443
+ } else if( oFmtDef == CVI_8M_15P || oFmtDef == CVI_8M_12_5P ) {
476444 if( oFmtDef == CVI_8M_15P )
477445 printk("[CH:%d] >> finding format:CVI 8M 15P....\n", ch);
478446 else
479447 printk("[CH:%d] >> finding format:CVI 8M 12.5P....\n", ch);
480448
481
- if(-1 == nvp6158_video_input_cvi_tvi_distinguish(&sDevChInfo))
482
- {
449
+ if(-1 == nvp6158_video_input_cvi_tvi_distinguish(&sDevChInfo)) {
483450 printk("error nvp6158_video_input_cvi_tvi_distinguish\n");
484451 return 1;
485452 }
486453 oFmtDef = sDevChInfo.fmt_def;
487454
488
- if( oFmtDef == TVI_8M_15P )
489
- {
455
+ if( oFmtDef == TVI_8M_15P ) {
490456 printk("[CH:%d] >> changing format:TVI 8M 15P....\n", ch);
491457 ps_nvp6158_vfmts->curvideofmt[ch] = TVI_8M_15P;
492
- }
493
- else if( oFmtDef == TVI_8M_12_5P )
494
- {
458
+ } else if( oFmtDef == TVI_8M_12_5P ) {
495459 printk("[CH:%d] >> changing format:TVI 8M 12_5P....\n", ch);
496460 ps_nvp6158_vfmts->curvideofmt[ch] = TVI_8M_12_5P;
497461 }
498
- }
499
- else if( oFmtDef == AHD20_720P_30P_EX_Btype/* || oFmtDef == CVI_HD_30P_EX*/)
500
- {
501
- if(CVI_720P30[ch] == 0)
502
- {
462
+ } else if( oFmtDef == AHD20_720P_30P_EX_Btype/* || oFmtDef == CVI_HD_30P_EX*/) {
463
+ if(CVI_720P30[ch] == 0) {
503464 oFmtDef = CVI_HD_30P_EX;
504465 ps_nvp6158_vfmts->curvideofmt[ch] = CVI_HD_30P_EX;
505466 CVI_720P30[ch] = 1;
506467 printk("[CH:%d] >> AHD20_720P_30P_EX_Btype changing format:CVI CVI_HD_30P_EX ....\n", ch); //2020-12-16
507
- }
508
- else
468
+ } else
509469 printk("[CH:%d] >> AHD20_720P_30P_EX_Btype non changing format:CVI CVI_HD_30P_EX ....\n", ch); //2020-12-16
510
- }
511
- else if(oFmtDef == CVI_FHD_25P )
512
- {
470
+ } else if(oFmtDef == CVI_FHD_25P ) {
513471 printk("[CH:%d] >> finding format: %x....\n", ch, oFmtDef);
514472
515473 nvp6158_video_input_cvi_ahd_1080p_distinguish(&sDevChInfo);
516474 oFmtDef = sDevChInfo.fmt_def;
517475
518
- if( oFmtDef == AHD20_1080P_25P )
519
- {
476
+ if( oFmtDef == AHD20_1080P_25P ) {
520477 printk("[CH:%d] >> changing format:AHD 2M 25P....\n", ch);
521478
522479 ps_nvp6158_vfmts->curvideofmt[ch] = AHD20_1080P_25P;
523480 }
524481 }
525482
526
- if(ps_nvp6158_vfmts->vfc[ch] == 0x2B)
527
- {
483
+ if(ps_nvp6158_vfmts->vfc[ch] == 0x2B) {
528484 sDevChInfo.ch = ch%4;
529485 sDevChInfo.devnum = ch/4;
530486 sDevChInfo.fmt_def = ps_nvp6158_vfmts->vfc[ch];
531487 nvp6158_video_input_ahd_tvi_distinguish(&sDevChInfo);
532488 oFmtDef = sDevChInfo.fmt_def;
533489
534
- if( oFmtDef == TVI_4M_15P )
535
- {
536
- if((nvp6158_det_mode[ch] == NVP6158_DET_MODE_AUTO)||(nvp6158_det_mode[ch] == NVP6158_DET_MODE_TVI))
537
- {
490
+ if( oFmtDef == TVI_4M_15P ) {
491
+ if((nvp6158_det_mode[ch] == NVP6158_DET_MODE_AUTO)||(nvp6158_det_mode[ch] == NVP6158_DET_MODE_TVI)) {
538492 printk("[CH:%d] >> changing format:TVI 4M 15P....\n", ch);
539493
540494 ps_nvp6158_vfmts->curvideofmt[ch] = TVI_4M_15P;
541
- }
542
- else
495
+ } else
543496 ps_nvp6158_vfmts->curvideofmt[ch] = NC_VIVO_CH_FORMATDEF_UNKNOWN;
544497 }
545498 }
....@@ -556,9 +509,7 @@
556509 #endif
557510 //nvp6158_set_chnmode(ch, ps_nvp6158_vfmts->prevideofmt[ch]);
558511 printk(">>>>> CH[%d], Set video format : 0x%02X\n", ch, oCurVideofmt);
559
- }
560
- else if( (oCurVideofmt == NC_VIVO_CH_FORMATDEF_UNKNOWN ) && (oPreVideofmt == NC_VIVO_CH_FORMATDEF_UNKNOWN) )
561
- {
512
+ } else if( (oCurVideofmt == NC_VIVO_CH_FORMATDEF_UNKNOWN ) && (oPreVideofmt == NC_VIVO_CH_FORMATDEF_UNKNOWN) ) {
562513 int ii = 0;
563514 int retry_cnt = 0;
564515
....@@ -584,30 +535,24 @@
584535
585536 //nvp6158_video_input_manual_agc_stable_endi(&sDevChInfo, 1);
586537
587
- for(ii = 0; ii < 20; ii++ )
588
- {
538
+ for(ii = 0; ii < 20; ii++ ) {
589539 nvp6158_video_input_vfc_read( &sVFC_B13 );
590540 nvp6158_video_input_onvideo_check_data( &sVFC_B5 );
591541
592
- if( ((sVFC_B5.vfc >> 4) & 0xf ) < 0x2)
593
- {
542
+ if( ((sVFC_B5.vfc >> 4) & 0xf ) < 0x2) {
594543 break;
595544 }
596545
597
- if( sVFC_B13.vfc == 0x2b && sVFC_B5.vfc == 0x3f)
598
- {
546
+ if( sVFC_B13.vfc == 0x2b && sVFC_B5.vfc == 0x3f) {
599547 printk("[DRV] CH[%d] Bank13 0xF0 [%02x], Bank5 0xF0[%02x]\n", ch, sVFC_B13.vfc, sVFC_B5.vfc );
600548 printk("[DRV] CH[%d] AFHD 15P or 12.5P [%d]\n" , ch, retry_cnt );
601549 break;
602
- }
603
- else if( ( sVFC_B5.vfc != 0x2f || sVFC_B5.vfc != 0x3f ) && (sVFC_B13.vfc != 0x2b))
604
- {
550
+ } else if(sVFC_B5.vfc != 0x2f) {
605551 printk("[DRV] CH[%d] Bank13 0xF0 [%02x], Bank5 0xF0[%02x]\n", ch, sVFC_B13.vfc, sVFC_B5.vfc );
606552 printk("[DRV] CH[%d] Unknown Status [%d] \n", ch, retry_cnt );
607553 }
608554
609
- if(retry_cnt >= 20 )
610
- {
555
+ if(retry_cnt >= 20 ) {
611556 printk("CH[%d] Unknown Status Disitinguish Finished ...\n", ch );
612557 break;
613558 }
....@@ -621,8 +566,7 @@
621566
622567 nvp6158_video_input_ahd_nrt_distinguish( &sDevChInfo );
623568
624
- if( sDevChInfo.fmt_def == NC_VIVO_CH_FORMATDEF_UNKNOWN )
625
- {
569
+ if( sDevChInfo.fmt_def == NC_VIVO_CH_FORMATDEF_UNKNOWN ) {
626570 printk("[DRV] CH[%d] unknown format \n", ch);
627571 return 0;
628572 }
....@@ -649,11 +593,9 @@
649593
650594 }
651595 #ifdef _ENABLE_DET_DEBOUNCE_
652
- else
653
- {
596
+ else {
654597 ret = nvp6158_AutoDebouceCheck( ch, &nvp6158_s_raptor3_vfmts ); //note!!!!
655
- if( ( ret == -1 ) && ( nvp6158_gCoaxFirmUpdateFlag[ch] == 0 ) )
656
- {
598
+ if( ( ret == -1 ) && ( nvp6158_gCoaxFirmUpdateFlag[ch] == 0 ) ) {
657599 sDevChInfo.ch = ch % 4;
658600 sDevChInfo.devnum = ch/4;
659601 /* hide decoder */
....@@ -678,11 +620,9 @@
678620 }
679621 #endif
680622 }
681
- else
682
- {
623
+ else {
683624 /* no video */
684
- if( oPreVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN )
685
- {
625
+ if( oPreVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN ) {
686626 //nvp6158_set_chnmode(ch, NC_VIVO_CH_FORMATDEF_UNKNOWN);
687627 ps_nvp6158_vfmts->prevideofmt[ch] = NC_VIVO_CH_FORMATDEF_UNKNOWN;
688628
....@@ -722,18 +662,16 @@
722662 oCurVideofmt = ps_nvp6158_vfmts->curvideofmt[ch];
723663 oPreVideofmt = ps_nvp6158_vfmts->prevideofmt[ch];
724664
725
- if( ps_nvp6158_vfmts->curvideoloss[ch] == VIDEO_LOSS_ON)
726
- {
665
+ if( ps_nvp6158_vfmts->curvideoloss[ch] == VIDEO_LOSS_ON) {
727666 /* on video */
728
- if( (oCurVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN) && (oPreVideofmt == NC_VIVO_CH_FORMATDEF_UNKNOWN) )
729
- {
667
+ if( (oCurVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN) &&
668
+ (oPreVideofmt == NC_VIVO_CH_FORMATDEF_UNKNOWN) ) {
730669 oFmtDef = NVP6158_NC_VD_AUTO_VFCtoFMTDEF( ch, ps_nvp6158_vfmts->vfc[ch] );
731670 sDevChInfo.ch = ch%4;
732671 sDevChInfo.devnum = ch/4;
733672 sDevChInfo.fmt_def = oFmtDef;
734673
735
- if(oFmtDef == TVI_5M_20P) //needs 2nd identify
736
- {
674
+ if(oFmtDef == TVI_5M_20P) {//needs 2nd identify
737675 nvp6168_video_input_cvi_tvi_5M20p_distinguish(&sDevChInfo);
738676 oFmtDef = sDevChInfo.fmt_def;
739677
....@@ -746,12 +684,9 @@
746684 printk(">>>>> CH[%d], Set video format : 0x%02X\n", ch, oCurVideofmt);
747685 }
748686
749
- }
750
- else
751
- {
687
+ } else {
752688 /* no video */
753
- if( oPreVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN )
754
- {
689
+ if( oPreVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN ) {
755690 //nvp6158_set_chnmode(ch, NC_VIVO_CH_FORMATDEF_UNKNOWN);
756691 ps_nvp6158_vfmts->prevideofmt[ch] = NC_VIVO_CH_FORMATDEF_UNKNOWN;
757692
....@@ -770,8 +705,7 @@
770705 unsigned int vloss=0, i;
771706 unsigned char vlossperchip[4];
772707
773
- for(i=0;i<nvp6158_cnt;i++)
774
- {
708
+ for(i = 0; i < nvp6158_cnt; i++) {
775709 gpio_i2c_write(nvp6158_iic_addr[i], 0xFF, 0x00);
776710 vlossperchip[i] = (gpio_i2c_read(nvp6158_iic_addr[i], 0xA8)&0x0F);
777711 vloss |= (vlossperchip[i]<<(4*i));
....@@ -780,7 +714,7 @@
780714 return vloss;
781715 }
782716 static unsigned char nvp6158_vloss_pre = 0xFF;
783
-static unsigned char nvp6158_ch_first_plug_status[8]={1,1,1,1,1,1,1,1};
717
+static unsigned char nvp6158_ch_first_plug_status[8]={1, 1, 1, 1, 1, 1, 1, 1};
784718 static __maybe_unused unsigned char nvp6158_is_first_plugin(unsigned char ch)
785719 {
786720 unsigned int vloss=0;
....@@ -836,7 +770,7 @@
836770 {
837771 unsigned char acc_ref=0;
838772 unsigned char check_cnt = 4;
839
- do{
773
+ do {
840774 gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, 0x05+(ch%4));
841775 acc_ref = gpio_i2c_read(nvp6158_iic_addr[ch/4], 0x27);
842776 gpio_i2c_write(nvp6158_iic_addr[ch/4], 0x23, 0x80);
....@@ -1027,8 +961,7 @@
1027961 unsigned char val_0x54;
1028962 unsigned char vfmt = chnmode%2;
1029963
1030
- if((chnmode <= AHD20_SD_H960_2EX_Btype_PAL) && (chnmode>=AHD20_SD_H960_NT))
1031
- {
964
+ if((chnmode <= AHD20_SD_H960_2EX_Btype_PAL) && (chnmode>=AHD20_SD_H960_NT)) {
1032965 gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, 0x00);
1033966 val_0x54 = gpio_i2c_read(nvp6158_iic_addr[ch/4], 0x54);
1034967 _CLE_BIT(val_0x54, (ch%4+4));
....@@ -1039,9 +972,7 @@
1039972 gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, 0x05+ch%4);
1040973 gpio_i2c_write(nvp6158_iic_addr[ch/4], 0x69,0x01);
1041974 gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xB8,0xB8);
1042
- }
1043
- else
1044
- {
975
+ } else {
1045976 gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, 0x00);
1046977 val_0x54 = gpio_i2c_read(nvp6158_iic_addr[ch/4], 0x54);
1047978 _CLE_BIT(val_0x54, (ch%4+4));
....@@ -1055,9 +986,9 @@
1055986 decoder_info.ch = ch%4;
1056987 decoder_info.devnum = ch/4;
1057988 decoder_info.fmt_def = chnmode;
1058
- if(__nvp6158_IsOver3MRTVideoFormat( &decoder_info ))
989
+ if(__nvp6158_IsOver3MRTVideoFormat( &decoder_info ))
1059990 nvp6158_set_chn_ycmerge(ch, 1);
1060
- else
991
+ else
1061992 nvp6158_set_chn_ycmerge(ch, 0);
1062993 if(nvp6158_chip_id[decoder_info.devnum]==NVP6158C_R0_ID || nvp6158_chip_id[decoder_info.devnum]==NVP6158_R0_ID)
1063994 nvp6158_video_input_onvideo_set( &decoder_info );
....@@ -1065,14 +996,6 @@
1065996 nvp6168_video_input_onvideo_set( &decoder_info );
1066997 }
1067998
1068
-
1069
-/*
1070
-ÉèÖÃͨµÀģʽ
1071
-±äÁ¿
1072
-ch: ͨµÀºÅ£¬È¡Öµ·¶Î§0~(nvp6158_cnt*4-1)
1073
-vfmt: 0:NTSC, 1:PAL
1074
-chnmode:ͨµÀģʽ£¬²Î¿¼NVP6158_VI_MODE.
1075
-*/
1076999 int nvp6158_set_chnmode(const unsigned char ch, const unsigned char chnmode)
10771000 {
10781001 //unsigned char tmp;
....@@ -1080,17 +1003,14 @@
10801003 video_input_novid auto_novid;
10811004 nvp6158_coax_str s_coax_str;
10821005
1083
- if(ch >= (nvp6158_cnt*4))
1084
- {
1006
+ if(ch >= (nvp6158_cnt*4)) {
10851007 printk("func[nvp6158_set_chnmode] Channel %d is out of range!!!\n", ch);
10861008 return -1;
10871009 }
10881010
10891011 /* set video format each format */
1090
- if(chnmode < NC_VIVO_CH_FORMATDEF_MAX)
1091
- {
1092
- if(NC_VIVO_CH_FORMATDEF_UNKNOWN != chnmode)
1093
- {
1012
+ if(chnmode < NC_VIVO_CH_FORMATDEF_MAX) {
1013
+ if(NC_VIVO_CH_FORMATDEF_UNKNOWN != chnmode) {
10941014 nvp6158_set_chn_commonvalue( ch, chnmode );
10951015
10961016 nvp6158_video_input_new_format_set(ch, chnmode);
....@@ -1116,9 +1036,7 @@
11161036 gpio_i2c_write(nvp6158_iic_addr[ch/4], 0x40+ch%4,0x00);
11171037
11181038 nvp6158_show_ch(ch);
1119
- }
1120
- else
1121
- {
1039
+ } else {
11221040 nvp6158_hide_ch(ch);
11231041 auto_novid.ch = ch%4;
11241042 auto_novid.devnum = ch/4;
....@@ -1141,17 +1059,14 @@
11411059 video_input_novid auto_novid;
11421060 nvp6158_coax_str s_coax_str;
11431061
1144
- if(ch >= (nvp6158_cnt*4))
1145
- {
1062
+ if(ch >= (nvp6158_cnt*4)) {
11461063 printk("func[nvp6168_set_chnmode] Channel %d is out of range!!!\n", ch);
11471064 return -1;
11481065 }
11491066
11501067 /* set video format each format */
1151
- if(chnmode < NC_VIVO_CH_FORMATDEF_MAX)
1152
- {
1153
- if(NC_VIVO_CH_FORMATDEF_UNKNOWN != chnmode)
1154
- {
1068
+ if(chnmode < NC_VIVO_CH_FORMATDEF_MAX) {
1069
+ if(NC_VIVO_CH_FORMATDEF_UNKNOWN != chnmode) {
11551070 nvp6158_set_chn_commonvalue( ch, chnmode );
11561071
11571072 //nvp6158_video_input_new_format_set(ch, chnmode);
....@@ -1177,9 +1092,7 @@
11771092 gpio_i2c_write(nvp6158_iic_addr[ch/4], 0x40+ch%4,0x00);
11781093
11791094 nvp6158_show_ch(ch);
1180
- }
1181
- else
1182
- {
1095
+ } else {
11831096 nvp6158_hide_ch(ch);
11841097 auto_novid.ch = ch%4;
11851098 auto_novid.devnum = ch/4;
....@@ -1197,8 +1110,6 @@
11971110
11981111
11991112 /*
1200
-nvp6158ºÍnvp6158c¹²ÓÃͬһº¯Êý
1201
-portselÉÏÓвîÒ죬nvp6158cÖ»ÄÜʹÓÃ1ºÍ2£¬nvp6158ÓÐ4¸öport£¬¿ÉÒÔʹÓÃ0~3¡£
12021113 chip:chip select[0,1,2,3];
12031114 portsel: port select->6158c[1,2],6158[0,1,2,3];
12041115 portmode: port mode select[1mux,2mux,4mux]
....@@ -1214,19 +1125,19 @@
12141125 * Modify :
12151126 * warning :
12161127 *******************************************************************************/
1217
-int nvp6158_set_portmode(const unsigned char chip, const unsigned char portsel, const unsigned char portmode, const unsigned char chid)
1128
+int nvp6158_set_portmode(const unsigned char chip, const unsigned char portsel,
1129
+ const unsigned char portmode, const unsigned char chid)
12181130 {
12191131 unsigned char chipaddr = nvp6158_iic_addr[chip];
12201132 unsigned char tmp=0, tmp1=0, reg1=0, reg2=0;
12211133
1222
- if((portsel!=1) && (portsel!=2) && (nvp6158_chip_id[chip]==NVP6158C_R0_ID || nvp6158_chip_id[chip] == NVP6168C_R0_ID))
1223
- {
1134
+ if((portsel!=1) && (portsel!=2) && (nvp6158_chip_id[chip]==NVP6158C_R0_ID ||
1135
+ nvp6158_chip_id[chip] == NVP6168C_R0_ID)) {
12241136 printk("nvp6158C_set_portmode portsel[%d] error!!!\n", portsel);
12251137 //return -1;
12261138 }
12271139
1228
- switch(portmode)
1229
- {
1140
+ switch(portmode) {
12301141 case NVP6158_OUTMODE_1MUX_SD:
12311142 /*Output 720H/960H Single Channel data, Data Rate 37.125MHz,Pclk 37.125MHz, Single Edge.*/
12321143 gpio_i2c_write(chipaddr, 0xFF, 0x00);
....@@ -1402,7 +1313,7 @@
14021313 break;
14031314 case NVP6158_OUTMODE_4MUX_MIX:
14041315 /*HD,1920H,FHD-X 4mux mix,Data Rate 297MHz,Pclk 297MHz, Dual Edge.
1405
- SOC VI Port Abandon some data£¬realize 1920H->960H */
1316
+ SOC VI Port Abandon some data��realize 1920H->960H */
14061317 gpio_i2c_write(chipaddr, 0xFF, 0x00);
14071318 gpio_i2c_write(chipaddr, 0x56, 0x32);
14081319 gpio_i2c_write(chipaddr, 0xFF, 0x01);
....@@ -1432,8 +1343,8 @@
14321343 gpio_i2c_write(chipaddr, 0xFF, 0x00);
14331344 gpio_i2c_write(chipaddr, 0x56, 0x10);
14341345 gpio_i2c_write(chipaddr, 0xFF, 0x01);
1435
- if(nvp6158_chip_id[chip] == NVP6158C_R0_ID || nvp6158_chip_id[chip] == NVP6168C_R0_ID)
1436
- {
1346
+ if(nvp6158_chip_id[chip] == NVP6158C_R0_ID ||
1347
+ nvp6158_chip_id[chip] == NVP6168C_R0_ID) {
14371348 //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock.
14381349 gpio_i2c_write(chipaddr, 0xC2, (((chid%4)+0x04)<<4)|((chid%4)+0x04));
14391350 gpio_i2c_write(chipaddr, 0xC3, (((chid%4)+0x04)<<4)|((chid%4)+0x04));
....@@ -1442,9 +1353,7 @@
14421353 gpio_i2c_write(chipaddr, 0xC8, 0x00);
14431354 gpio_i2c_write(chipaddr, 0xC9, 0x00);
14441355 gpio_i2c_write(chipaddr, 0xCC+portsel, 0x86); //37.125MHz clock
1445
- }
1446
- else
1447
- {
1356
+ } else {
14481357 //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock.
14491358 gpio_i2c_write(chipaddr, 0xC0+portsel*4, (((chid%4)+0x0C)<<4)|((chid%4)+0x0C));
14501359 gpio_i2c_write(chipaddr, 0xC1+portsel*4, (((chid%4)+0x0C)<<4)|((chid%4)+0x0C));
....@@ -1459,8 +1368,8 @@
14591368 gpio_i2c_write(chipaddr, 0xFF, 0x00);
14601369 gpio_i2c_write(chipaddr, 0x56, 0x10);
14611370 gpio_i2c_write(chipaddr, 0xFF, 0x01);
1462
- if(nvp6158_chip_id[chip] == NVP6158C_R0_ID || nvp6158_chip_id[chip] == NVP6168C_R0_ID)
1463
- {
1371
+ if(nvp6158_chip_id[chip] == NVP6158C_R0_ID ||
1372
+ nvp6158_chip_id[chip] == NVP6168C_R0_ID) {
14641373 //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock.
14651374 gpio_i2c_write(chipaddr, 0xC2, (((chid%4)+0x04)<<4)|((chid%4)+0x04));
14661375 gpio_i2c_write(chipaddr, 0xC3, (((chid%4)+0x04)<<4)|((chid%4)+0x04));
....@@ -1469,9 +1378,7 @@
14691378 gpio_i2c_write(chipaddr, 0xC8, 0x00);
14701379 gpio_i2c_write(chipaddr, 0xC9, 0x00);
14711380 gpio_i2c_write(chipaddr, 0xCC+portsel, 0x06); //74.25MHz clock
1472
- }
1473
- else
1474
- {
1381
+ } else {
14751382 //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock.
14761383 gpio_i2c_write(chipaddr, 0xC0+portsel*4, (((chid%4)+0x0C)<<4)|((chid%4)+0x0C));
14771384 gpio_i2c_write(chipaddr, 0xC1+portsel*4, (((chid%4)+0x0C)<<4)|((chid%4)+0x0C));
....@@ -1486,8 +1393,8 @@
14861393 gpio_i2c_write(chipaddr, 0xFF, 0x00);
14871394 gpio_i2c_write(chipaddr, 0x56, 0x10);
14881395 gpio_i2c_write(chipaddr, 0xFF, 0x01);
1489
- if(nvp6158_chip_id[chip] == NVP6158C_R0_ID || nvp6158_chip_id[chip] == NVP6168C_R0_ID)
1490
- {
1396
+ if(nvp6158_chip_id[chip] == NVP6158C_R0_ID ||
1397
+ nvp6158_chip_id[chip] == NVP6168C_R0_ID) {
14911398 //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock.
14921399 gpio_i2c_write(chipaddr, 0xC2, 0xdc);
14931400 gpio_i2c_write(chipaddr, 0xC3, 0xdc);
....@@ -1497,9 +1404,7 @@
14971404 gpio_i2c_write(chipaddr, 0xC9, 0x22);
14981405 gpio_i2c_write(chipaddr, 0xCD, 0x1f); //74.25MHz clock
14991406 gpio_i2c_write(chipaddr, 0xCE, 0x1f); //74.25MHz clock
1500
- }
1501
- else
1502
- {
1407
+ } else {
15031408 //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock.
15041409 gpio_i2c_write(chipaddr, 0xC0+portsel*4, 0xdc);
15051410 gpio_i2c_write(chipaddr, 0xC1+portsel*4, 0xdc);
....@@ -1513,8 +1418,8 @@
15131418 gpio_i2c_write(chipaddr, 0xFF, 0x00);
15141419 gpio_i2c_write(chipaddr, 0x56, 0x10);
15151420 gpio_i2c_write(chipaddr, 0xFF, 0x01);
1516
- if(nvp6158_chip_id[chip] == NVP6158C_R0_ID || nvp6158_chip_id[chip] == NVP6168C_R0_ID)
1517
- {
1421
+ if(nvp6158_chip_id[chip] == NVP6158C_R0_ID ||
1422
+ nvp6158_chip_id[chip] == NVP6168C_R0_ID) {
15181423 //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock.
15191424 gpio_i2c_write(chipaddr, 0xC2, 0x54);
15201425 gpio_i2c_write(chipaddr, 0xC3, 0x54);
....@@ -1524,9 +1429,7 @@
15241429 gpio_i2c_write(chipaddr, 0xC9, 0x22);
15251430 gpio_i2c_write(chipaddr, 0xCD, 0x56); //148.5MHz clock
15261431 gpio_i2c_write(chipaddr, 0xCE, 0x56); //148.5MHz clock
1527
- }
1528
- else
1529
- {
1432
+ } else {
15301433 //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock.
15311434 gpio_i2c_write(chipaddr, 0xC0+portsel*4, 0xdc);
15321435 gpio_i2c_write(chipaddr, 0xC1+portsel*4, 0xdc);
....@@ -1570,8 +1473,8 @@
15701473 gpio_i2c_write(chipaddr, 0xFF, 0x00);
15711474 gpio_i2c_write(chipaddr, 0x56, 0x32);
15721475 gpio_i2c_write(chipaddr, 0xFF, 0x01);
1573
- if(nvp6158_chip_id[chip] == NVP6158C_R0_ID || nvp6158_chip_id[chip] == NVP6168C_R0_ID)
1574
- {
1476
+ if(nvp6158_chip_id[chip] == NVP6158C_R0_ID ||
1477
+ nvp6158_chip_id[chip] == NVP6168C_R0_ID) {
15751478 //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock.
15761479 gpio_i2c_write(chipaddr, 0xC2, 0x54);
15771480 gpio_i2c_write(chipaddr, 0xC3, 0x76);
....@@ -1582,9 +1485,7 @@
15821485 //dual_edge
15831486 gpio_i2c_write(chipaddr, 0xCD, 0x06); //74.25MHz clock
15841487 gpio_i2c_write(chipaddr, 0xCE, 0x06); //74.25MHz clock
1585
- }
1586
- else
1587
- {
1488
+ } else {
15881489 //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock.
15891490 gpio_i2c_write(chipaddr, 0xC0+portsel*4, 0xdc);
15901491 gpio_i2c_write(chipaddr, 0xC1+portsel*4, 0xfe);
....@@ -1599,8 +1500,8 @@
15991500 gpio_i2c_write(chipaddr, 0xFF, 0x00);
16001501 gpio_i2c_write(chipaddr, 0x56, 0x32);
16011502 gpio_i2c_write(chipaddr, 0xFF, 0x01);
1602
- if(nvp6158_chip_id[chip] == NVP6158C_R0_ID || nvp6158_chip_id[chip] == NVP6168C_R0_ID)
1603
- {
1503
+ if(nvp6158_chip_id[chip] == NVP6158C_R0_ID ||
1504
+ nvp6158_chip_id[chip] == NVP6168C_R0_ID) {
16041505 //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock.
16051506 gpio_i2c_write(chipaddr, 0xC2, 0x54);
16061507 gpio_i2c_write(chipaddr, 0xC3, 0x76);
....@@ -1610,9 +1511,7 @@
16101511 gpio_i2c_write(chipaddr, 0xC9, 0x88);
16111512 gpio_i2c_write(chipaddr, 0xCD, 0x40); //148.5MHz clock
16121513 gpio_i2c_write(chipaddr, 0xCE, 0x40); //148.5MHz clock
1613
- }
1614
- else
1615
- {
1514
+ } else {
16161515 //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock.
16171516 gpio_i2c_write(chipaddr, 0xC0+portsel*4, 0xdc);
16181517 gpio_i2c_write(chipaddr, 0xC1+portsel*4, 0xfe);
....@@ -1647,15 +1546,12 @@
16471546 portmode==NVP6158_OUTMODE_2MUX_BT1120S ||\
16481547 portmode==NVP6158_OUTMODE_2MUX_BT1120S_720P ||\
16491548 portmode==NVP6158_OUTMODE_2MUX_BT1120S_1080P ||\
1650
- portmode==NVP6158_OUTMODE_4MUX_BT1120S)
1651
- {
1549
+ portmode==NVP6158_OUTMODE_4MUX_BT1120S) {
16521550 gpio_i2c_write(chipaddr, 0xFF, 0x01);
16531551 gpio_i2c_write(chipaddr, 0xA0+portsel, 0x20); //TM clock mode sel manual
16541552 printk("TM clock mode sel manual mode \n");
16551553
1656
- }
1657
- else
1658
- {
1554
+ } else {
16591555 gpio_i2c_write(chipaddr, 0xFF, 0x01);
16601556 gpio_i2c_write(chipaddr, 0xA0+portsel, 0x00); //TM clock mode sel auto
16611557 printk("TM clock mode sel auto mode \n");
....@@ -1671,13 +1567,14 @@
16711567 enclk: enable clock pin, 1:enable,0:disable;
16721568 endata: enable data port, 1:enable,0:disable;
16731569 */
1674
-void nvp6158_set_portcontrol(const unsigned char chip, const unsigned char portsel, const unsigned char enclk, const unsigned char endata)
1570
+void nvp6158_set_portcontrol(const unsigned char chip, const unsigned char portsel,
1571
+ const unsigned char enclk, const unsigned char endata)
16751572 {
16761573 unsigned char reg_portctl;
16771574 gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x01);
16781575 reg_portctl = gpio_i2c_read(nvp6158_iic_addr[chip], 0xCA);
1679
- if(nvp6158_chip_id[chip] == NVP6158C_R0_ID || nvp6158_chip_id[chip] == NVP6168C_R0_ID)
1680
- {
1576
+ if(nvp6158_chip_id[chip] == NVP6158C_R0_ID ||
1577
+ nvp6158_chip_id[chip] == NVP6168C_R0_ID) {
16811578 if(enclk == 1)
16821579 _SET_BIT(reg_portctl, (portsel+5));
16831580 else
....@@ -1687,9 +1584,7 @@
16871584 _SET_BIT(reg_portctl, portsel);
16881585 else
16891586 _CLE_BIT(reg_portctl, portsel);
1690
- }
1691
- else if(nvp6158_chip_id[chip] == NVP6158_R0_ID)
1692
- {
1587
+ } else if(nvp6158_chip_id[chip] == NVP6158_R0_ID) {
16931588 if(enclk == 1)
16941589 _SET_BIT(reg_portctl, (portsel+4));
16951590 else
....@@ -1724,8 +1619,7 @@
17241619 {
17251620 unsigned char ch = 0;
17261621
1727
- for(ch = 0; ch < 4; ch++)
1728
- {
1622
+ for(ch = 0; ch < 4; ch++) {
17291623 gpio_i2c_write(nvp6158_iic_addr[chip], 0xff, 0x0a + (ch / 2));
17301624
17311625 gpio_i2c_write(nvp6158_iic_addr[chip], 0x00 + ( 0x80 * (ch % 2)), 0x80 );