.. | .. |
---|
35 | 35 | extern unsigned char nvp6158_det_mode[16]; |
---|
36 | 36 | extern unsigned int nvp6158_gCoaxFirmUpdateFlag[16]; |
---|
37 | 37 | |
---|
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}; |
---|
41 | 41 | #ifdef _ENABLE_DET_DEBOUNCE_ |
---|
42 | 42 | NVP6158_INFORMATION_S nvp6158_s_raptor3_vfmts; |
---|
43 | 43 | #endif |
---|
.. | .. |
---|
47 | 47 | int tmp = 0; |
---|
48 | 48 | int i = 0, j= 0; |
---|
49 | 49 | |
---|
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 ); |
---|
52 | 54 | 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) { |
---|
61 | 59 | printk("0x%02x\r\n",i); |
---|
62 | | - } |
---|
63 | | - else |
---|
64 | | - { |
---|
| 60 | + } else { |
---|
65 | 61 | printk("0x%02x ",i); |
---|
66 | 62 | } |
---|
67 | 63 | } |
---|
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) { |
---|
79 | 70 | printk("0x%02x\r\n",tmp); |
---|
80 | | - } |
---|
81 | | - else |
---|
82 | | - { |
---|
| 71 | + } else { |
---|
83 | 72 | printk("0x%02x ",tmp); |
---|
84 | 73 | } |
---|
85 | 74 | } |
---|
.. | .. |
---|
90 | 79 | { |
---|
91 | 80 | unsigned char adc_value; |
---|
92 | 81 | |
---|
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 ); |
---|
96 | 86 | return adc_value; |
---|
97 | 87 | } |
---|
98 | 88 | |
---|
99 | 89 | void nvp6158_video_set_adcclk(unsigned char ch, unsigned char value) |
---|
100 | 90 | { |
---|
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 ); |
---|
104 | 95 | } |
---|
105 | 96 | |
---|
106 | 97 | static __maybe_unused void NVP6158_set_afe(unsigned char ch, unsigned char onoff) |
---|
.. | .. |
---|
121 | 112 | |
---|
122 | 113 | static __maybe_unused void nvp6158_datareverse(unsigned char chip, unsigned char port) |
---|
123 | 114 | { |
---|
124 | | -/* |
---|
125 | | -BANK1 0xCB[3:0],ÿ¸öbit¿ØÖÆÒ»¸öbt656µÄÊý¾Ý˳Ðò£¬1Ϊ·´Ðò£¬0ΪÕýÐò¡£ |
---|
126 | | -*/ |
---|
| 115 | + |
---|
127 | 116 | unsigned char tmp; |
---|
128 | 117 | gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x01); |
---|
129 | 118 | tmp = gpio_i2c_read(nvp6158_iic_addr[chip], 0xCB); |
---|
.. | .. |
---|
137 | 126 | unsigned char val_1x81; |
---|
138 | 127 | gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x01); |
---|
139 | 128 | val_1x81 = gpio_i2c_read(nvp6158_iic_addr[chip], 0x81); |
---|
140 | | - if(flag == 1) |
---|
141 | | - { |
---|
| 129 | + if(flag == 1) { |
---|
142 | 130 | val_1x81 |= 0x02; |
---|
143 | | - } |
---|
144 | | - else |
---|
145 | | - { |
---|
| 131 | + } else { |
---|
146 | 132 | val_1x81 &= 0xFD; |
---|
147 | 133 | } |
---|
148 | 134 | gpio_i2c_write(nvp6158_iic_addr[chip], 0x81, val_1x81); |
---|
.. | .. |
---|
185 | 171 | //VDO_1/2 disabled, VCLK_x disabled |
---|
186 | 172 | gpio_i2c_write(0x60, 0xFF, 0x01); |
---|
187 | 173 | gpio_i2c_write(0x60, 0xCA, 0x00); |
---|
188 | | - for(ch=0;ch<4;ch++) |
---|
189 | | - { |
---|
| 174 | + for(ch = 0; ch < 4; ch++) { |
---|
190 | 175 | gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x00); |
---|
191 | 176 | //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); |
---|
194 | 179 | |
---|
195 | | - gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x05+ch%4); |
---|
| 180 | + gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x05 + ch % 4); |
---|
196 | 181 | gpio_i2c_write(nvp6158_iic_addr[chip], 0x00, 0xD0); // Clamp speed |
---|
197 | 182 | gpio_i2c_write(nvp6158_iic_addr[chip], 0xA9, 0x80); |
---|
198 | 183 | gpio_i2c_write(nvp6158_iic_addr[chip], 0x76, 0x00); |
---|
.. | .. |
---|
227 | 212 | printk("debunce:0x%02X, debncIdx:%d\n", pInformation->debounce[ch][pInformation->debounceidx[ch]], pInformation->debounceidx[ch]); |
---|
228 | 213 | */ |
---|
229 | 214 | 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]; |
---|
231 | 217 | |
---|
232 | 218 | 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]) { |
---|
237 | 221 | break; |
---|
238 | 222 | } |
---|
239 | 223 | } |
---|
240 | | - if( i == MAX_DEBOUNCE_CNT ) |
---|
241 | | - { |
---|
| 224 | + if( i == MAX_DEBOUNCE_CNT ) { |
---|
242 | 225 | oFmtB5Def = NVP6158_NC_VD_AUTO_VFCtoFMTDEF(ch, oVfc); |
---|
243 | 226 | //if( ( oFmtB5Def != AHD30_5M_20P ) && ( oFmtB5Def != pInformation->prevideofmt[ch] ) ) |
---|
244 | 227 | if( ( ( oFmtB5Def != AHD30_5M_20P ) && ( oFmtB5Def != CVI_8M_15P ) && |
---|
245 | 228 | ( oFmtB5Def != CVI_8M_12_5P ) && ( oFmtB5Def != CVI_HD_30P_EX ) && |
---|
246 | 229 | ( 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]); |
---|
251 | 233 | ret = -1; |
---|
252 | 234 | } |
---|
253 | 235 | } |
---|
.. | .. |
---|
273 | 255 | void nvp6158_set_colorpattern(void) |
---|
274 | 256 | { |
---|
275 | 257 | int chip; |
---|
276 | | - for(chip=0;chip<nvp6158_cnt;chip++) |
---|
277 | | - { |
---|
| 258 | + for(chip = 0; chip < nvp6158_cnt; chip++) { |
---|
278 | 259 | gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x00); |
---|
279 | 260 | gpio_i2c_write(nvp6158_iic_addr[chip], 0x78, 0xaa); |
---|
280 | 261 | gpio_i2c_write(nvp6158_iic_addr[chip], 0x79, 0xaa); |
---|
.. | .. |
---|
298 | 279 | int chip; |
---|
299 | 280 | |
---|
300 | 281 | 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++) { |
---|
303 | 283 | gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x05); |
---|
304 | 284 | gpio_i2c_write(nvp6158_iic_addr[chip], 0x2c, 0x08); |
---|
305 | 285 | gpio_i2c_write(nvp6158_iic_addr[chip], 0x6a, 0x80); |
---|
.. | .. |
---|
326 | 306 | int chip; |
---|
327 | 307 | |
---|
328 | 308 | 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++) { |
---|
331 | 310 | gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x05); |
---|
332 | 311 | gpio_i2c_write(nvp6158_iic_addr[chip], 0x2c, 0x08); |
---|
333 | 312 | gpio_i2c_write(nvp6158_iic_addr[chip], 0x6a, 0x80); |
---|
.. | .. |
---|
382 | 361 | sNoVideo.devnum = ch/4; |
---|
383 | 362 | |
---|
384 | 363 | /* 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) |
---|
386 | 365 | nvp6158_video_input_vfc_read(&sVFC); |
---|
387 | 366 | else |
---|
388 | 367 | nvp6168_video_input_vfc_read(&sVFC); |
---|
389 | 368 | nvp6158_video_input_novid_read(&sNoVideo); |
---|
390 | 369 | svin_vfc_bak.ch = ch%4; |
---|
391 | 370 | 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) |
---|
393 | 372 | nvp6158_video_input_onvideo_check_data(&svin_vfc_bak); |
---|
394 | 373 | |
---|
395 | 374 | /* 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 |
---|
398 | 376 | /* convert vfc to formatDefine for APP and save videoloss information */ |
---|
399 | 377 | oCurVidFmt = NVP6158_NC_VD_AUTO_VFCtoFMTDEF(ch, sVFC.vfc); |
---|
400 | 378 | |
---|
401 | 379 | /* debouce */ |
---|
402 | 380 | pInformation->curvideofmt[ch] = oCurVidFmt; |
---|
403 | 381 | 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) { |
---|
411 | 385 | //nvp6158_channel_reset(ch); |
---|
412 | 386 | //nvp6158_adc_reset(ch); |
---|
413 | 387 | } |
---|
.. | .. |
---|
415 | 389 | } |
---|
416 | 390 | |
---|
417 | 391 | /* check novideo option */ |
---|
418 | | - if( !sNoVideo.novid ) |
---|
419 | | - { |
---|
| 392 | + if( !sNoVideo.novid ) { |
---|
420 | 393 | pInformation->curvideoloss[ch] = VIDEO_LOSS_ON; |
---|
421 | 394 | } |
---|
422 | 395 | |
---|
.. | .. |
---|
431 | 404 | * warning : |
---|
432 | 405 | *******************************************************************************/ |
---|
433 | 406 | #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,}; |
---|
435 | 408 | #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 |
---|
437 | 410 | #endif |
---|
438 | 411 | unsigned int nvp6158_video_fmt_det(const unsigned char ch, NVP6158_INFORMATION_S *ps_nvp6158_vfmts) |
---|
439 | 412 | { |
---|
.. | .. |
---|
453 | 426 | oCurVideofmt = ps_nvp6158_vfmts->curvideofmt[ch]; |
---|
454 | 427 | oPreVideofmt = ps_nvp6158_vfmts->prevideofmt[ch]; |
---|
455 | 428 | |
---|
456 | | - if( ps_nvp6158_vfmts->curvideoloss[ch] == VIDEO_LOSS_ON) |
---|
457 | | - { |
---|
| 429 | + if( ps_nvp6158_vfmts->curvideoloss[ch] == VIDEO_LOSS_ON) { |
---|
458 | 430 | /* 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) ) { |
---|
461 | 432 | oFmtDef = NVP6158_NC_VD_AUTO_VFCtoFMTDEF( ch, ps_nvp6158_vfmts->vfc[ch] ); |
---|
462 | 433 | sDevChInfo.ch = ch%4; |
---|
463 | 434 | sDevChInfo.devnum = ch/4; |
---|
464 | 435 | sDevChInfo.fmt_def = oFmtDef; |
---|
465 | | - if(oFmtDef == AHD30_5M_20P ) |
---|
466 | | - { |
---|
| 436 | + if(oFmtDef == AHD30_5M_20P ) { |
---|
467 | 437 | printk("[CH:%d] >> finding format: %x....\n", ch, oFmtDef); |
---|
468 | 438 | |
---|
469 | 439 | nvp6158_video_input_ahd_tvi_distinguish(&sDevChInfo); |
---|
470 | 440 | oFmtDef = sDevChInfo.fmt_def; |
---|
471 | 441 | |
---|
472 | 442 | 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 ) { |
---|
476 | 444 | if( oFmtDef == CVI_8M_15P ) |
---|
477 | 445 | printk("[CH:%d] >> finding format:CVI 8M 15P....\n", ch); |
---|
478 | 446 | else |
---|
479 | 447 | printk("[CH:%d] >> finding format:CVI 8M 12.5P....\n", ch); |
---|
480 | 448 | |
---|
481 | | - if(-1 == nvp6158_video_input_cvi_tvi_distinguish(&sDevChInfo)) |
---|
482 | | - { |
---|
| 449 | + if(-1 == nvp6158_video_input_cvi_tvi_distinguish(&sDevChInfo)) { |
---|
483 | 450 | printk("error nvp6158_video_input_cvi_tvi_distinguish\n"); |
---|
484 | 451 | return 1; |
---|
485 | 452 | } |
---|
486 | 453 | oFmtDef = sDevChInfo.fmt_def; |
---|
487 | 454 | |
---|
488 | | - if( oFmtDef == TVI_8M_15P ) |
---|
489 | | - { |
---|
| 455 | + if( oFmtDef == TVI_8M_15P ) { |
---|
490 | 456 | printk("[CH:%d] >> changing format:TVI 8M 15P....\n", ch); |
---|
491 | 457 | 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 ) { |
---|
495 | 459 | printk("[CH:%d] >> changing format:TVI 8M 12_5P....\n", ch); |
---|
496 | 460 | ps_nvp6158_vfmts->curvideofmt[ch] = TVI_8M_12_5P; |
---|
497 | 461 | } |
---|
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) { |
---|
503 | 464 | oFmtDef = CVI_HD_30P_EX; |
---|
504 | 465 | ps_nvp6158_vfmts->curvideofmt[ch] = CVI_HD_30P_EX; |
---|
505 | 466 | CVI_720P30[ch] = 1; |
---|
506 | 467 | 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 |
---|
509 | 469 | 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 ) { |
---|
513 | 471 | printk("[CH:%d] >> finding format: %x....\n", ch, oFmtDef); |
---|
514 | 472 | |
---|
515 | 473 | nvp6158_video_input_cvi_ahd_1080p_distinguish(&sDevChInfo); |
---|
516 | 474 | oFmtDef = sDevChInfo.fmt_def; |
---|
517 | 475 | |
---|
518 | | - if( oFmtDef == AHD20_1080P_25P ) |
---|
519 | | - { |
---|
| 476 | + if( oFmtDef == AHD20_1080P_25P ) { |
---|
520 | 477 | printk("[CH:%d] >> changing format:AHD 2M 25P....\n", ch); |
---|
521 | 478 | |
---|
522 | 479 | ps_nvp6158_vfmts->curvideofmt[ch] = AHD20_1080P_25P; |
---|
523 | 480 | } |
---|
524 | 481 | } |
---|
525 | 482 | |
---|
526 | | - if(ps_nvp6158_vfmts->vfc[ch] == 0x2B) |
---|
527 | | - { |
---|
| 483 | + if(ps_nvp6158_vfmts->vfc[ch] == 0x2B) { |
---|
528 | 484 | sDevChInfo.ch = ch%4; |
---|
529 | 485 | sDevChInfo.devnum = ch/4; |
---|
530 | 486 | sDevChInfo.fmt_def = ps_nvp6158_vfmts->vfc[ch]; |
---|
531 | 487 | nvp6158_video_input_ahd_tvi_distinguish(&sDevChInfo); |
---|
532 | 488 | oFmtDef = sDevChInfo.fmt_def; |
---|
533 | 489 | |
---|
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)) { |
---|
538 | 492 | printk("[CH:%d] >> changing format:TVI 4M 15P....\n", ch); |
---|
539 | 493 | |
---|
540 | 494 | ps_nvp6158_vfmts->curvideofmt[ch] = TVI_4M_15P; |
---|
541 | | - } |
---|
542 | | - else |
---|
| 495 | + } else |
---|
543 | 496 | ps_nvp6158_vfmts->curvideofmt[ch] = NC_VIVO_CH_FORMATDEF_UNKNOWN; |
---|
544 | 497 | } |
---|
545 | 498 | } |
---|
.. | .. |
---|
556 | 509 | #endif |
---|
557 | 510 | //nvp6158_set_chnmode(ch, ps_nvp6158_vfmts->prevideofmt[ch]); |
---|
558 | 511 | 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) ) { |
---|
562 | 513 | int ii = 0; |
---|
563 | 514 | int retry_cnt = 0; |
---|
564 | 515 | |
---|
.. | .. |
---|
584 | 535 | |
---|
585 | 536 | //nvp6158_video_input_manual_agc_stable_endi(&sDevChInfo, 1); |
---|
586 | 537 | |
---|
587 | | - for(ii = 0; ii < 20; ii++ ) |
---|
588 | | - { |
---|
| 538 | + for(ii = 0; ii < 20; ii++ ) { |
---|
589 | 539 | nvp6158_video_input_vfc_read( &sVFC_B13 ); |
---|
590 | 540 | nvp6158_video_input_onvideo_check_data( &sVFC_B5 ); |
---|
591 | 541 | |
---|
592 | | - if( ((sVFC_B5.vfc >> 4) & 0xf ) < 0x2) |
---|
593 | | - { |
---|
| 542 | + if( ((sVFC_B5.vfc >> 4) & 0xf ) < 0x2) { |
---|
594 | 543 | break; |
---|
595 | 544 | } |
---|
596 | 545 | |
---|
597 | | - if( sVFC_B13.vfc == 0x2b && sVFC_B5.vfc == 0x3f) |
---|
598 | | - { |
---|
| 546 | + if( sVFC_B13.vfc == 0x2b && sVFC_B5.vfc == 0x3f) { |
---|
599 | 547 | printk("[DRV] CH[%d] Bank13 0xF0 [%02x], Bank5 0xF0[%02x]\n", ch, sVFC_B13.vfc, sVFC_B5.vfc ); |
---|
600 | 548 | printk("[DRV] CH[%d] AFHD 15P or 12.5P [%d]\n" , ch, retry_cnt ); |
---|
601 | 549 | 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) { |
---|
605 | 551 | printk("[DRV] CH[%d] Bank13 0xF0 [%02x], Bank5 0xF0[%02x]\n", ch, sVFC_B13.vfc, sVFC_B5.vfc ); |
---|
606 | 552 | printk("[DRV] CH[%d] Unknown Status [%d] \n", ch, retry_cnt ); |
---|
607 | 553 | } |
---|
608 | 554 | |
---|
609 | | - if(retry_cnt >= 20 ) |
---|
610 | | - { |
---|
| 555 | + if(retry_cnt >= 20 ) { |
---|
611 | 556 | printk("CH[%d] Unknown Status Disitinguish Finished ...\n", ch ); |
---|
612 | 557 | break; |
---|
613 | 558 | } |
---|
.. | .. |
---|
621 | 566 | |
---|
622 | 567 | nvp6158_video_input_ahd_nrt_distinguish( &sDevChInfo ); |
---|
623 | 568 | |
---|
624 | | - if( sDevChInfo.fmt_def == NC_VIVO_CH_FORMATDEF_UNKNOWN ) |
---|
625 | | - { |
---|
| 569 | + if( sDevChInfo.fmt_def == NC_VIVO_CH_FORMATDEF_UNKNOWN ) { |
---|
626 | 570 | printk("[DRV] CH[%d] unknown format \n", ch); |
---|
627 | 571 | return 0; |
---|
628 | 572 | } |
---|
.. | .. |
---|
649 | 593 | |
---|
650 | 594 | } |
---|
651 | 595 | #ifdef _ENABLE_DET_DEBOUNCE_ |
---|
652 | | - else |
---|
653 | | - { |
---|
| 596 | + else { |
---|
654 | 597 | 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 ) ) { |
---|
657 | 599 | sDevChInfo.ch = ch % 4; |
---|
658 | 600 | sDevChInfo.devnum = ch/4; |
---|
659 | 601 | /* hide decoder */ |
---|
.. | .. |
---|
678 | 620 | } |
---|
679 | 621 | #endif |
---|
680 | 622 | } |
---|
681 | | - else |
---|
682 | | - { |
---|
| 623 | + else { |
---|
683 | 624 | /* no video */ |
---|
684 | | - if( oPreVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN ) |
---|
685 | | - { |
---|
| 625 | + if( oPreVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN ) { |
---|
686 | 626 | //nvp6158_set_chnmode(ch, NC_VIVO_CH_FORMATDEF_UNKNOWN); |
---|
687 | 627 | ps_nvp6158_vfmts->prevideofmt[ch] = NC_VIVO_CH_FORMATDEF_UNKNOWN; |
---|
688 | 628 | |
---|
.. | .. |
---|
722 | 662 | oCurVideofmt = ps_nvp6158_vfmts->curvideofmt[ch]; |
---|
723 | 663 | oPreVideofmt = ps_nvp6158_vfmts->prevideofmt[ch]; |
---|
724 | 664 | |
---|
725 | | - if( ps_nvp6158_vfmts->curvideoloss[ch] == VIDEO_LOSS_ON) |
---|
726 | | - { |
---|
| 665 | + if( ps_nvp6158_vfmts->curvideoloss[ch] == VIDEO_LOSS_ON) { |
---|
727 | 666 | /* 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) ) { |
---|
730 | 669 | oFmtDef = NVP6158_NC_VD_AUTO_VFCtoFMTDEF( ch, ps_nvp6158_vfmts->vfc[ch] ); |
---|
731 | 670 | sDevChInfo.ch = ch%4; |
---|
732 | 671 | sDevChInfo.devnum = ch/4; |
---|
733 | 672 | sDevChInfo.fmt_def = oFmtDef; |
---|
734 | 673 | |
---|
735 | | - if(oFmtDef == TVI_5M_20P) //needs 2nd identify |
---|
736 | | - { |
---|
| 674 | + if(oFmtDef == TVI_5M_20P) {//needs 2nd identify |
---|
737 | 675 | nvp6168_video_input_cvi_tvi_5M20p_distinguish(&sDevChInfo); |
---|
738 | 676 | oFmtDef = sDevChInfo.fmt_def; |
---|
739 | 677 | |
---|
.. | .. |
---|
746 | 684 | printk(">>>>> CH[%d], Set video format : 0x%02X\n", ch, oCurVideofmt); |
---|
747 | 685 | } |
---|
748 | 686 | |
---|
749 | | - } |
---|
750 | | - else |
---|
751 | | - { |
---|
| 687 | + } else { |
---|
752 | 688 | /* no video */ |
---|
753 | | - if( oPreVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN ) |
---|
754 | | - { |
---|
| 689 | + if( oPreVideofmt != NC_VIVO_CH_FORMATDEF_UNKNOWN ) { |
---|
755 | 690 | //nvp6158_set_chnmode(ch, NC_VIVO_CH_FORMATDEF_UNKNOWN); |
---|
756 | 691 | ps_nvp6158_vfmts->prevideofmt[ch] = NC_VIVO_CH_FORMATDEF_UNKNOWN; |
---|
757 | 692 | |
---|
.. | .. |
---|
770 | 705 | unsigned int vloss=0, i; |
---|
771 | 706 | unsigned char vlossperchip[4]; |
---|
772 | 707 | |
---|
773 | | - for(i=0;i<nvp6158_cnt;i++) |
---|
774 | | - { |
---|
| 708 | + for(i = 0; i < nvp6158_cnt; i++) { |
---|
775 | 709 | gpio_i2c_write(nvp6158_iic_addr[i], 0xFF, 0x00); |
---|
776 | 710 | vlossperchip[i] = (gpio_i2c_read(nvp6158_iic_addr[i], 0xA8)&0x0F); |
---|
777 | 711 | vloss |= (vlossperchip[i]<<(4*i)); |
---|
.. | .. |
---|
780 | 714 | return vloss; |
---|
781 | 715 | } |
---|
782 | 716 | 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}; |
---|
784 | 718 | static __maybe_unused unsigned char nvp6158_is_first_plugin(unsigned char ch) |
---|
785 | 719 | { |
---|
786 | 720 | unsigned int vloss=0; |
---|
.. | .. |
---|
836 | 770 | { |
---|
837 | 771 | unsigned char acc_ref=0; |
---|
838 | 772 | unsigned char check_cnt = 4; |
---|
839 | | - do{ |
---|
| 773 | + do { |
---|
840 | 774 | gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, 0x05+(ch%4)); |
---|
841 | 775 | acc_ref = gpio_i2c_read(nvp6158_iic_addr[ch/4], 0x27); |
---|
842 | 776 | gpio_i2c_write(nvp6158_iic_addr[ch/4], 0x23, 0x80); |
---|
.. | .. |
---|
1027 | 961 | unsigned char val_0x54; |
---|
1028 | 962 | unsigned char vfmt = chnmode%2; |
---|
1029 | 963 | |
---|
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)) { |
---|
1032 | 965 | gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, 0x00); |
---|
1033 | 966 | val_0x54 = gpio_i2c_read(nvp6158_iic_addr[ch/4], 0x54); |
---|
1034 | 967 | _CLE_BIT(val_0x54, (ch%4+4)); |
---|
.. | .. |
---|
1039 | 972 | gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, 0x05+ch%4); |
---|
1040 | 973 | gpio_i2c_write(nvp6158_iic_addr[ch/4], 0x69,0x01); |
---|
1041 | 974 | gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xB8,0xB8); |
---|
1042 | | - } |
---|
1043 | | - else |
---|
1044 | | - { |
---|
| 975 | + } else { |
---|
1045 | 976 | gpio_i2c_write(nvp6158_iic_addr[ch/4], 0xFF, 0x00); |
---|
1046 | 977 | val_0x54 = gpio_i2c_read(nvp6158_iic_addr[ch/4], 0x54); |
---|
1047 | 978 | _CLE_BIT(val_0x54, (ch%4+4)); |
---|
.. | .. |
---|
1055 | 986 | decoder_info.ch = ch%4; |
---|
1056 | 987 | decoder_info.devnum = ch/4; |
---|
1057 | 988 | decoder_info.fmt_def = chnmode; |
---|
1058 | | - if(__nvp6158_IsOver3MRTVideoFormat( &decoder_info )) |
---|
| 989 | + if(__nvp6158_IsOver3MRTVideoFormat( &decoder_info )) |
---|
1059 | 990 | nvp6158_set_chn_ycmerge(ch, 1); |
---|
1060 | | - else |
---|
| 991 | + else |
---|
1061 | 992 | nvp6158_set_chn_ycmerge(ch, 0); |
---|
1062 | 993 | if(nvp6158_chip_id[decoder_info.devnum]==NVP6158C_R0_ID || nvp6158_chip_id[decoder_info.devnum]==NVP6158_R0_ID) |
---|
1063 | 994 | nvp6158_video_input_onvideo_set( &decoder_info ); |
---|
.. | .. |
---|
1065 | 996 | nvp6168_video_input_onvideo_set( &decoder_info ); |
---|
1066 | 997 | } |
---|
1067 | 998 | |
---|
1068 | | - |
---|
1069 | | -/* |
---|
1070 | | -ÉèÖÃͨµÀģʽ |
---|
1071 | | -±äÁ¿ |
---|
1072 | | -ch: ͨµÀºÅ£¬È¡Öµ·¶Î§0~(nvp6158_cnt*4-1) |
---|
1073 | | -vfmt: 0:NTSC, 1:PAL |
---|
1074 | | -chnmode:ͨµÀģʽ£¬²Î¿¼NVP6158_VI_MODE. |
---|
1075 | | -*/ |
---|
1076 | 999 | int nvp6158_set_chnmode(const unsigned char ch, const unsigned char chnmode) |
---|
1077 | 1000 | { |
---|
1078 | 1001 | //unsigned char tmp; |
---|
.. | .. |
---|
1080 | 1003 | video_input_novid auto_novid; |
---|
1081 | 1004 | nvp6158_coax_str s_coax_str; |
---|
1082 | 1005 | |
---|
1083 | | - if(ch >= (nvp6158_cnt*4)) |
---|
1084 | | - { |
---|
| 1006 | + if(ch >= (nvp6158_cnt*4)) { |
---|
1085 | 1007 | printk("func[nvp6158_set_chnmode] Channel %d is out of range!!!\n", ch); |
---|
1086 | 1008 | return -1; |
---|
1087 | 1009 | } |
---|
1088 | 1010 | |
---|
1089 | 1011 | /* 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) { |
---|
1094 | 1014 | nvp6158_set_chn_commonvalue( ch, chnmode ); |
---|
1095 | 1015 | |
---|
1096 | 1016 | nvp6158_video_input_new_format_set(ch, chnmode); |
---|
.. | .. |
---|
1116 | 1036 | gpio_i2c_write(nvp6158_iic_addr[ch/4], 0x40+ch%4,0x00); |
---|
1117 | 1037 | |
---|
1118 | 1038 | nvp6158_show_ch(ch); |
---|
1119 | | - } |
---|
1120 | | - else |
---|
1121 | | - { |
---|
| 1039 | + } else { |
---|
1122 | 1040 | nvp6158_hide_ch(ch); |
---|
1123 | 1041 | auto_novid.ch = ch%4; |
---|
1124 | 1042 | auto_novid.devnum = ch/4; |
---|
.. | .. |
---|
1141 | 1059 | video_input_novid auto_novid; |
---|
1142 | 1060 | nvp6158_coax_str s_coax_str; |
---|
1143 | 1061 | |
---|
1144 | | - if(ch >= (nvp6158_cnt*4)) |
---|
1145 | | - { |
---|
| 1062 | + if(ch >= (nvp6158_cnt*4)) { |
---|
1146 | 1063 | printk("func[nvp6168_set_chnmode] Channel %d is out of range!!!\n", ch); |
---|
1147 | 1064 | return -1; |
---|
1148 | 1065 | } |
---|
1149 | 1066 | |
---|
1150 | 1067 | /* 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) { |
---|
1155 | 1070 | nvp6158_set_chn_commonvalue( ch, chnmode ); |
---|
1156 | 1071 | |
---|
1157 | 1072 | //nvp6158_video_input_new_format_set(ch, chnmode); |
---|
.. | .. |
---|
1177 | 1092 | gpio_i2c_write(nvp6158_iic_addr[ch/4], 0x40+ch%4,0x00); |
---|
1178 | 1093 | |
---|
1179 | 1094 | nvp6158_show_ch(ch); |
---|
1180 | | - } |
---|
1181 | | - else |
---|
1182 | | - { |
---|
| 1095 | + } else { |
---|
1183 | 1096 | nvp6158_hide_ch(ch); |
---|
1184 | 1097 | auto_novid.ch = ch%4; |
---|
1185 | 1098 | auto_novid.devnum = ch/4; |
---|
.. | .. |
---|
1197 | 1110 | |
---|
1198 | 1111 | |
---|
1199 | 1112 | /* |
---|
1200 | | -nvp6158ºÍnvp6158c¹²ÓÃͬһº¯Êý |
---|
1201 | | -portselÉÏÓвîÒ죬nvp6158cÖ»ÄÜʹÓÃ1ºÍ2£¬nvp6158ÓÐ4¸öport£¬¿ÉÒÔʹÓÃ0~3¡£ |
---|
1202 | 1113 | chip:chip select[0,1,2,3]; |
---|
1203 | 1114 | portsel: port select->6158c[1,2],6158[0,1,2,3]; |
---|
1204 | 1115 | portmode: port mode select[1mux,2mux,4mux] |
---|
.. | .. |
---|
1214 | 1125 | * Modify : |
---|
1215 | 1126 | * warning : |
---|
1216 | 1127 | *******************************************************************************/ |
---|
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) |
---|
1218 | 1130 | { |
---|
1219 | 1131 | unsigned char chipaddr = nvp6158_iic_addr[chip]; |
---|
1220 | 1132 | unsigned char tmp=0, tmp1=0, reg1=0, reg2=0; |
---|
1221 | 1133 | |
---|
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)) { |
---|
1224 | 1136 | printk("nvp6158C_set_portmode portsel[%d] error!!!\n", portsel); |
---|
1225 | 1137 | //return -1; |
---|
1226 | 1138 | } |
---|
1227 | 1139 | |
---|
1228 | | - switch(portmode) |
---|
1229 | | - { |
---|
| 1140 | + switch(portmode) { |
---|
1230 | 1141 | case NVP6158_OUTMODE_1MUX_SD: |
---|
1231 | 1142 | /*Output 720H/960H Single Channel data, Data Rate 37.125MHz,Pclk 37.125MHz, Single Edge.*/ |
---|
1232 | 1143 | gpio_i2c_write(chipaddr, 0xFF, 0x00); |
---|
.. | .. |
---|
1402 | 1313 | break; |
---|
1403 | 1314 | case NVP6158_OUTMODE_4MUX_MIX: |
---|
1404 | 1315 | /*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 */ |
---|
1406 | 1317 | gpio_i2c_write(chipaddr, 0xFF, 0x00); |
---|
1407 | 1318 | gpio_i2c_write(chipaddr, 0x56, 0x32); |
---|
1408 | 1319 | gpio_i2c_write(chipaddr, 0xFF, 0x01); |
---|
.. | .. |
---|
1432 | 1343 | gpio_i2c_write(chipaddr, 0xFF, 0x00); |
---|
1433 | 1344 | gpio_i2c_write(chipaddr, 0x56, 0x10); |
---|
1434 | 1345 | 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) { |
---|
1437 | 1348 | //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock. |
---|
1438 | 1349 | gpio_i2c_write(chipaddr, 0xC2, (((chid%4)+0x04)<<4)|((chid%4)+0x04)); |
---|
1439 | 1350 | gpio_i2c_write(chipaddr, 0xC3, (((chid%4)+0x04)<<4)|((chid%4)+0x04)); |
---|
.. | .. |
---|
1442 | 1353 | gpio_i2c_write(chipaddr, 0xC8, 0x00); |
---|
1443 | 1354 | gpio_i2c_write(chipaddr, 0xC9, 0x00); |
---|
1444 | 1355 | gpio_i2c_write(chipaddr, 0xCC+portsel, 0x86); //37.125MHz clock |
---|
1445 | | - } |
---|
1446 | | - else |
---|
1447 | | - { |
---|
| 1356 | + } else { |
---|
1448 | 1357 | //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock. |
---|
1449 | 1358 | gpio_i2c_write(chipaddr, 0xC0+portsel*4, (((chid%4)+0x0C)<<4)|((chid%4)+0x0C)); |
---|
1450 | 1359 | gpio_i2c_write(chipaddr, 0xC1+portsel*4, (((chid%4)+0x0C)<<4)|((chid%4)+0x0C)); |
---|
.. | .. |
---|
1459 | 1368 | gpio_i2c_write(chipaddr, 0xFF, 0x00); |
---|
1460 | 1369 | gpio_i2c_write(chipaddr, 0x56, 0x10); |
---|
1461 | 1370 | 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) { |
---|
1464 | 1373 | //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock. |
---|
1465 | 1374 | gpio_i2c_write(chipaddr, 0xC2, (((chid%4)+0x04)<<4)|((chid%4)+0x04)); |
---|
1466 | 1375 | gpio_i2c_write(chipaddr, 0xC3, (((chid%4)+0x04)<<4)|((chid%4)+0x04)); |
---|
.. | .. |
---|
1469 | 1378 | gpio_i2c_write(chipaddr, 0xC8, 0x00); |
---|
1470 | 1379 | gpio_i2c_write(chipaddr, 0xC9, 0x00); |
---|
1471 | 1380 | gpio_i2c_write(chipaddr, 0xCC+portsel, 0x06); //74.25MHz clock |
---|
1472 | | - } |
---|
1473 | | - else |
---|
1474 | | - { |
---|
| 1381 | + } else { |
---|
1475 | 1382 | //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock. |
---|
1476 | 1383 | gpio_i2c_write(chipaddr, 0xC0+portsel*4, (((chid%4)+0x0C)<<4)|((chid%4)+0x0C)); |
---|
1477 | 1384 | gpio_i2c_write(chipaddr, 0xC1+portsel*4, (((chid%4)+0x0C)<<4)|((chid%4)+0x0C)); |
---|
.. | .. |
---|
1486 | 1393 | gpio_i2c_write(chipaddr, 0xFF, 0x00); |
---|
1487 | 1394 | gpio_i2c_write(chipaddr, 0x56, 0x10); |
---|
1488 | 1395 | 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) { |
---|
1491 | 1398 | //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock. |
---|
1492 | 1399 | gpio_i2c_write(chipaddr, 0xC2, 0xdc); |
---|
1493 | 1400 | gpio_i2c_write(chipaddr, 0xC3, 0xdc); |
---|
.. | .. |
---|
1497 | 1404 | gpio_i2c_write(chipaddr, 0xC9, 0x22); |
---|
1498 | 1405 | gpio_i2c_write(chipaddr, 0xCD, 0x1f); //74.25MHz clock |
---|
1499 | 1406 | gpio_i2c_write(chipaddr, 0xCE, 0x1f); //74.25MHz clock |
---|
1500 | | - } |
---|
1501 | | - else |
---|
1502 | | - { |
---|
| 1407 | + } else { |
---|
1503 | 1408 | //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock. |
---|
1504 | 1409 | gpio_i2c_write(chipaddr, 0xC0+portsel*4, 0xdc); |
---|
1505 | 1410 | gpio_i2c_write(chipaddr, 0xC1+portsel*4, 0xdc); |
---|
.. | .. |
---|
1513 | 1418 | gpio_i2c_write(chipaddr, 0xFF, 0x00); |
---|
1514 | 1419 | gpio_i2c_write(chipaddr, 0x56, 0x10); |
---|
1515 | 1420 | 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) { |
---|
1518 | 1423 | //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock. |
---|
1519 | 1424 | gpio_i2c_write(chipaddr, 0xC2, 0x54); |
---|
1520 | 1425 | gpio_i2c_write(chipaddr, 0xC3, 0x54); |
---|
.. | .. |
---|
1524 | 1429 | gpio_i2c_write(chipaddr, 0xC9, 0x22); |
---|
1525 | 1430 | gpio_i2c_write(chipaddr, 0xCD, 0x56); //148.5MHz clock |
---|
1526 | 1431 | gpio_i2c_write(chipaddr, 0xCE, 0x56); //148.5MHz clock |
---|
1527 | | - } |
---|
1528 | | - else |
---|
1529 | | - { |
---|
| 1432 | + } else { |
---|
1530 | 1433 | //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock. |
---|
1531 | 1434 | gpio_i2c_write(chipaddr, 0xC0+portsel*4, 0xdc); |
---|
1532 | 1435 | gpio_i2c_write(chipaddr, 0xC1+portsel*4, 0xdc); |
---|
.. | .. |
---|
1570 | 1473 | gpio_i2c_write(chipaddr, 0xFF, 0x00); |
---|
1571 | 1474 | gpio_i2c_write(chipaddr, 0x56, 0x32); |
---|
1572 | 1475 | 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) { |
---|
1575 | 1478 | //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock. |
---|
1576 | 1479 | gpio_i2c_write(chipaddr, 0xC2, 0x54); |
---|
1577 | 1480 | gpio_i2c_write(chipaddr, 0xC3, 0x76); |
---|
.. | .. |
---|
1582 | 1485 | //dual_edge |
---|
1583 | 1486 | gpio_i2c_write(chipaddr, 0xCD, 0x06); //74.25MHz clock |
---|
1584 | 1487 | gpio_i2c_write(chipaddr, 0xCE, 0x06); //74.25MHz clock |
---|
1585 | | - } |
---|
1586 | | - else |
---|
1587 | | - { |
---|
| 1488 | + } else { |
---|
1588 | 1489 | //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock. |
---|
1589 | 1490 | gpio_i2c_write(chipaddr, 0xC0+portsel*4, 0xdc); |
---|
1590 | 1491 | gpio_i2c_write(chipaddr, 0xC1+portsel*4, 0xfe); |
---|
.. | .. |
---|
1599 | 1500 | gpio_i2c_write(chipaddr, 0xFF, 0x00); |
---|
1600 | 1501 | gpio_i2c_write(chipaddr, 0x56, 0x32); |
---|
1601 | 1502 | 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) { |
---|
1604 | 1505 | //6158C makes 2 bt656 ports to 1 bt1120 port. portsel=[1,2] to choose clock. |
---|
1605 | 1506 | gpio_i2c_write(chipaddr, 0xC2, 0x54); |
---|
1606 | 1507 | gpio_i2c_write(chipaddr, 0xC3, 0x76); |
---|
.. | .. |
---|
1610 | 1511 | gpio_i2c_write(chipaddr, 0xC9, 0x88); |
---|
1611 | 1512 | gpio_i2c_write(chipaddr, 0xCD, 0x40); //148.5MHz clock |
---|
1612 | 1513 | gpio_i2c_write(chipaddr, 0xCE, 0x40); //148.5MHz clock |
---|
1613 | | - } |
---|
1614 | | - else |
---|
1615 | | - { |
---|
| 1514 | + } else { |
---|
1616 | 1515 | //6158 makes 4 bt656 ports to 2 bt1120 port. portsel=[0,1] to choose clock. |
---|
1617 | 1516 | gpio_i2c_write(chipaddr, 0xC0+portsel*4, 0xdc); |
---|
1618 | 1517 | gpio_i2c_write(chipaddr, 0xC1+portsel*4, 0xfe); |
---|
.. | .. |
---|
1647 | 1546 | portmode==NVP6158_OUTMODE_2MUX_BT1120S ||\ |
---|
1648 | 1547 | portmode==NVP6158_OUTMODE_2MUX_BT1120S_720P ||\ |
---|
1649 | 1548 | portmode==NVP6158_OUTMODE_2MUX_BT1120S_1080P ||\ |
---|
1650 | | - portmode==NVP6158_OUTMODE_4MUX_BT1120S) |
---|
1651 | | - { |
---|
| 1549 | + portmode==NVP6158_OUTMODE_4MUX_BT1120S) { |
---|
1652 | 1550 | gpio_i2c_write(chipaddr, 0xFF, 0x01); |
---|
1653 | 1551 | gpio_i2c_write(chipaddr, 0xA0+portsel, 0x20); //TM clock mode sel manual |
---|
1654 | 1552 | printk("TM clock mode sel manual mode \n"); |
---|
1655 | 1553 | |
---|
1656 | | - } |
---|
1657 | | - else |
---|
1658 | | - { |
---|
| 1554 | + } else { |
---|
1659 | 1555 | gpio_i2c_write(chipaddr, 0xFF, 0x01); |
---|
1660 | 1556 | gpio_i2c_write(chipaddr, 0xA0+portsel, 0x00); //TM clock mode sel auto |
---|
1661 | 1557 | printk("TM clock mode sel auto mode \n"); |
---|
.. | .. |
---|
1671 | 1567 | enclk: enable clock pin, 1:enable,0:disable; |
---|
1672 | 1568 | endata: enable data port, 1:enable,0:disable; |
---|
1673 | 1569 | */ |
---|
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) |
---|
1675 | 1572 | { |
---|
1676 | 1573 | unsigned char reg_portctl; |
---|
1677 | 1574 | gpio_i2c_write(nvp6158_iic_addr[chip], 0xFF, 0x01); |
---|
1678 | 1575 | 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) { |
---|
1681 | 1578 | if(enclk == 1) |
---|
1682 | 1579 | _SET_BIT(reg_portctl, (portsel+5)); |
---|
1683 | 1580 | else |
---|
.. | .. |
---|
1687 | 1584 | _SET_BIT(reg_portctl, portsel); |
---|
1688 | 1585 | else |
---|
1689 | 1586 | _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) { |
---|
1693 | 1588 | if(enclk == 1) |
---|
1694 | 1589 | _SET_BIT(reg_portctl, (portsel+4)); |
---|
1695 | 1590 | else |
---|
.. | .. |
---|
1724 | 1619 | { |
---|
1725 | 1620 | unsigned char ch = 0; |
---|
1726 | 1621 | |
---|
1727 | | - for(ch = 0; ch < 4; ch++) |
---|
1728 | | - { |
---|
| 1622 | + for(ch = 0; ch < 4; ch++) { |
---|
1729 | 1623 | gpio_i2c_write(nvp6158_iic_addr[chip], 0xff, 0x0a + (ch / 2)); |
---|
1730 | 1624 | |
---|
1731 | 1625 | gpio_i2c_write(nvp6158_iic_addr[chip], 0x00 + ( 0x80 * (ch % 2)), 0x80 ); |
---|