-
Notifications
You must be signed in to change notification settings - Fork 9
/
hdmirx.c
4328 lines (3742 loc) · 122 KB
/
hdmirx.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) 2009-2014
// ITE Tech. Inc. All Rights Reserved
// Proprietary and Confidential
///*****************************************
// @file <hdmirx.c>
// @author Jau-Chih.Tseng@ite.com.tw
// @date 2011/01/13
// @fileversion: HDMIRX_SAMPLE_2.09
//******************************************/
// #define OUTPUT_CCIR656
// #define OUTPUT_SYNC_EMBEDDED
// #define OUTPUT_16BIT_YUV422
// #define OUTPUT_24BIT_YUV422
// #define OUTPUT_24BIT_YUV444
#define OUTPUT_24BIT_RGB444
// #define HDMI_REPEATER // always output signal withtout tristate
///////////////////////////////////////////////////
// Rev 1.01
///////////////////////////////////////////////////
// reg6C = 0x03
// reg6B = 0x11
// reg3B = 0x40
// reg6E = 0x0C
///////////////////////////////////////////////////
// Rev 1.09
///////////////////////////////////////////////////
//Reg6C=0x00
//Reg93=0x43
//Reg94=0x4F
//Reg95=0x87
//Reg96=0x33
///////////////////////////////////////////////////
/*********************************************************************************
* HDMIRX HDMI RX sample code *
*********************************************************************************/
#include "hdmirx.h"
#ifndef DEBUG_PORT_ENABLE
#define DEBUG_PORT_ENABLE 0
#else
#pragma message("DEBUG_PORT_ENABLE defined\n")
#endif
///////////////////////////////////////////////////////////
// Definition.
///////////////////////////////////////////////////////////
// #define SetVideoMute(x)SetMUTE(~(B_TRI_VIDEOIO|B_TRI_VIDEO),(x)?(B_TRI_VIDEOIO|B_TRI_VIDEO):0)
#define SetSPDIFMUTE(x) SetMUTE(~(1<<O_TRI_SPDIF),(x)?(1<<O_TRI_SPDIF):0)
#define SetI2S3MUTE(x) SetMUTE(~(1<<O_TRI_I2S3),(x)?(1<<O_TRI_I2S3):0)
#define SetI2S2MUTE(x) SetMUTE(~(1<<O_TRI_I2S2),(x)?(1<<O_TRI_I2S2):0)
#define SetI2S1MUTE(x) SetMUTE(~(1<<O_TRI_I2S1),(x)?(1<<O_TRI_I2S1):0)
#define SetI2S0MUTE(x) SetMUTE(~(1<<O_TRI_I2S0),(x)?(1<<O_TRI_I2S0):0)
#define SetALLMute() SetMUTE(B_VDO_MUTE_DISABLE,(B_VDO_MUTE_DISABLE|B_TRI_ALL))
#define SwitchHDMIRXBank(x) HDMIRX_WriteI2C_Byte(REG_RX_BANK,(x)&1)
char _CODE * VStateStr[] = {
"VSTATE_Off",
"VSTATE_PwrOff",
"VSTATE_SyncWait ",
"VSTATE_SWReset",
"VSTATE_SyncChecking",
"VSTATE_HDCPSet",
"VSTATE_HDCP_Reset",
"VSTATE_ModeDetecting",
"VSTATE_VideoOn",
"VSTATE_ColorDetectReset",
"VSTATE_Reserved"
} ;
char _CODE *AStateStr[] = {
"ASTATE_AudioOff",
"ASTATE_RequestAudio",
"ASTATE_ResetAudio",
"ASTATE_WaitForReady",
"ASTATE_AudioOn",
"ASTATE_Reserved"
};
#if defined(OUTPUT_CCIR656)
#pragma message("OUTPUT_CCIR656 defined")
#define HDMIRX_OUTPUT_MAPPING (B_OUTPUT_16BIT)
#define HDMIRX_OUTPUT_TYPE (B_SYNC_EMBEDDED|B_CCIR565)
#define HDMIRX_OUTPUT_COLORMODE (B_OUTPUT_YUV422<<O_OUTPUT_COLOR_MODE)
#elif defined(OUTPUT_SYNC_EMBEDDED)
#pragma message("OUTPUT_SYNC_EMBEDDED defined")
#define HDMIRX_OUTPUT_MAPPING (B_OUTPUT_16BIT)
#define HDMIRX_OUTPUT_TYPE (B_SYNC_EMBEDDED)
#define HDMIRX_OUTPUT_COLORMODE (B_OUTPUT_YUV422<<O_OUTPUT_COLOR_MODE)
#elif defined(OUTPUT_16BIT_YUV422)
#pragma message("OUTPUT_16BIT_YUV422 defined")
#define HDMIRX_OUTPUT_MAPPING (B_OUTPUT_16BIT)
#define HDMIRX_OUTPUT_TYPE 0
#define HDMIRX_OUTPUT_COLORMODE (B_OUTPUT_YUV422<<O_OUTPUT_COLOR_MODE)
#elif defined(OUTPUT_24BIT_YUV422)
#pragma message("OUTPUT_24BIT_YUV422 defined")
#define HDMIRX_OUTPUT_MAPPING 0
#define HDMIRX_OUTPUT_TYPE 0
#define HDMIRX_OUTPUT_COLORMODE (B_OUTPUT_YUV422<<O_OUTPUT_COLOR_MODE)
#elif defined(OUTPUT_24BIT_YUV444)
#pragma message("OUTPUT_24BIT_YUV444 defined")
#define HDMIRX_OUTPUT_MAPPING 0
#define HDMIRX_OUTPUT_TYPE 0
#define HDMIRX_OUTPUT_COLORMODE (B_OUTPUT_YUV444<<O_OUTPUT_COLOR_MODE)
#else // if defined(OUTPUT_24BIT_RGB444)
#pragma message("OUTPUT_24BIT_RGB444 defined")
#define HDMIRX_OUTPUT_MAPPING 0
#define HDMIRX_OUTPUT_TYPE 0
#define HDMIRX_OUTPUT_COLORMODE (B_OUTPUT_RGB24<<O_OUTPUT_COLOR_MODE)
#endif
// 2009/02/10 added by Jau-Chih.Tseng@ite.com.tw
#define DEFAULT_START_FIXED_AUD_SAMPLEFREQ AUDFS_192KHz
//~Jau-Chih.Tseng@ite.com.tw 2009/02/10
#ifndef I2S_DSP_SETTING
#pragma message ("I2S_DSP_SETTING as 0x60 for 0T delay, 32bit I2S left justify audio.")
#define I2S_DSP_SETTING 0x60
#else
#pragma message ("predefined I2S_DSP_SETTING ....")
#endif
// 2009/11/04 modified by jau-chih.tseng@ite.com.tw
// marked for moving into typedef.h
// typedef struct {
// WORD HActive ;
// WORD VActive ;
// WORD HTotal ;
// WORD VTotal ;
// LONG PCLK ;
// BYTE xCnt ;
// WORD HFrontPorch ;
// WORD HSyncWidth ;
// WORD HBackPorch ;
// BYTE VFrontPorch ;
// BYTE VSyncWidth ;
// BYTE VBackPorch ;
// BYTE ScanMode:1 ;
// BYTE VPolarity:1 ;
// BYTE HPolarity:1 ;
// } HDMI_VTiming ;
//
// #define PROG 1
// #define INTERLACE 0
// #define Vneg 0
// #define Hneg 0
// #define Vpos 1
// #define Hpos 1
//~jau-chih.tseng@ite.com.tw 2009/11/04
///////////////////////////////////////////////////////////
// Public Data
///////////////////////////////////////////////////////////
BYTE ucDVISCDToffCNT=0; // 20091021 for VG-859 HDMI / DVI change issue
_IDATA Video_State_Type VState = VSTATE_PwrOff ;
_IDATA Audio_State_Type AState = ASTATE_AudioOff ;
///////////////////////////////////////////////////////////
// Global Data
///////////////////////////////////////////////////////////
static _IDATA USHORT VideoCountingTimer = 0 ;
static _IDATA USHORT AudioCountingTimer = 0 ;
static _IDATA USHORT MuteResumingTimer = 0 ;
static BOOL MuteAutoOff = FALSE ;
static _IDATA BYTE bGetSyncFailCount = 0 ;
static BYTE _IDATA bOutputVideoMode = F_MODE_EN_UDFILT | F_MODE_RGB24 ;
static BOOL EnaSWCDRRest = FALSE ;
BYTE _XDATA bDisableAutoAVMute = 0 ;
static BYTE ucRevision = 0xFF ;
BYTE _XDATA bHDCPMode = 0 ;
//2008/06/17 modified by jj_tseng@chipadvanced.com
#define LOOP_MSEC 32
#define MS_TimeOut(x) (((x)+LOOP_MSEC-1)/LOOP_MSEC)
// #define VSTATE_MISS_SYNC_COUNT MS_TimeOut(2000)// 2000ms, 2sec
#define VSTATE_MISS_SYNC_COUNT MS_TimeOut(8000)// 8000ms, 8sec
#define VSATE_CONFIRM_SCDT_COUNT MS_TimeOut(150)// 150ms // direct change into 8 times of loop.
#define AUDIO_READY_TIMEOUT MS_TimeOut(200)
#define AUDIO_CLEARERROR_TIMEOUT MS_TimeOut(1000)
#define MUTE_RESUMING_TIMEOUT MS_TimeOut(2500)// 2.5 sec
#define HDCP_WAITING_TIMEOUT MS_TimeOut(3000)// 3 sec
#define CDRRESET_TIMEOUT MS_TimeOut(3000)// 3 sec
#define VSTATE_SWRESET_COUNT MS_TimeOut(500)// 500ms
#define FORCE_SWRESET_TIMEOUT MS_TimeOut(15000)// 15000ms, 15sec
#define VIDEO_TIMER_CHECK_COUNT MS_TimeOut(1000)
#define SCDT_LOST_TIMEOUT 15
static _XDATA USHORT SWResetTimeOut = FORCE_SWRESET_TIMEOUT;
static _XDATA BYTE ucHDMIAudioErrorCount = 0 ;
// 2009/02/10 modified by Jau-Chih.Tseng@ite.com.tw
// static _XDATA BYTE ucAudioSampleClock = AUDFS_192KHz ; // 192KHz, to changed 48KHz
static _XDATA BYTE ucAudioSampleClock = DEFAULT_START_FIXED_AUD_SAMPLEFREQ ; // 192KHz, to changed 48KHz
//~Jau-Chih.Tseng@ite.com.tw 2009/02/10
BOOL bIntPOL = FALSE ;
static BOOL NewAVIInfoFrameF = FALSE ;
static BOOL MuteByPKG = OFF ;
static _XDATA BYTE bInputVideoMode ;
// 2006/12/04 added by jj_tseng@chipadvanced.com
static _XDATA BYTE prevAVIDB1 = 0 ;
static _XDATA BYTE prevAVIDB2 = 0 ;
//~jjtseng 2006/12/04
static _XDATA USHORT currHTotal ;
static _XDATA BYTE currXcnt ;
static BOOL currScanMode ;
static BOOL bGetSyncInfo(void);
// BYTE iVTimingIndex = 0xFF ;
static _XDATA AUDIO_CAPS AudioCaps ;
// 2009/11/04 removed by jau-chih.tseng@ite.com.tw
// to avoid the wrong space using on 8051 code.
// _XDATA HDMI_VTiming code *pVTiming ;
_XDATA HDMI_VTiming s_CurrentVM ;
//~jau-chih.tseng@ite.com.tw 2009/11/04
BYTE SCDTErrorCnt = 0;
///////////////////////////////////////////////////////////////////////
// Global Table
///////////////////////////////////////////////////////////////////////
#ifdef USE_MODE_TABLE
static HDMI_VTiming _CODE s_VMTable[] = {
{640,480,800,525,25175L,0x89,16,96,48,10,2,33,PROG,Vneg,Hneg}, //640x480@60Hz
{720,480,858,525,27000L,0x80,16,62,60,9,6,30,PROG,Vneg,Hneg}, //720x480@60Hz
{1280,720,1650,750,74000L,0x2E,110,40,220,5,5,20,PROG,Vpos,Hpos}, //1280x720@60Hz
{1920,540,2200,562,74000L,0x2E,88,44,148,2,5,15,INTERLACE,Vpos,Hpos}, //1920x1080(I)@60Hz
{720,240,858,262,13500L,0xFF,19,62,57,4,3,15,INTERLACE,Vneg,Hneg}, //720x480(I)@60Hz
{720,240,858,262,13500L,0xFF,19,62,57,4,3,15,PROG,Vneg,Hneg}, //720x480(I)@60Hz
{1440,240,1716,262,27000L,0x80,38,124,114,5,3,15,INTERLACE,Vneg,Hneg}, //1440x480(I)@60Hz
{1440,240,1716,263,27000L,0x80,38,124,114,5,3,15,PROG,Vneg,Hneg}, //1440x240@60Hz
{2880,240,3432,262,54000L,0x40,76,248,288,4,3,15,INTERLACE,Vneg,Hneg}, //2880x480(I)@60Hz
{2880,240,3432,262,54000L,0x40,76,248,288,4,3,15,PROG,Vneg,Hneg}, //2880x240@60Hz
{2880,240,3432,263,54000L,0x40,76,248,288,5,3,15,PROG,Vneg,Hneg}, //2880x240@60Hz
{1440,480,1716,525,54000L,0x40,32,124,120,9,6,30,PROG,Vneg,Hneg}, //1440x480@60Hz
{1920,1080,2200,1125,148352L,0x17,88,44,148,4,5,36,PROG,Vpos,Hpos}, //1920x1080@60Hz
{720,576,864,625,27000L,0x80,12,64,68,5,5,36,PROG,Vneg,Hneg}, //720x576@50Hz
{1280,720,1980,750,74000L,0x2E,440,40,220,5,5,20,PROG,Vpos,Hpos}, //1280x720@50Hz
{1920,540,2640,562,74000L,0x2E,528,44,148,2,5,15,INTERLACE,Vpos,Hpos}, //1920x1080(I)@50Hz
{1440/2,288,1728/2,312,13500L,0xFF,24/2,126/2,138/2,2,3,19,INTERLACE,Vneg,Hneg}, //1440x576(I)@50Hz
{1440,288,1728,312,27000L,0x80,24,126,138,2,3,19,INTERLACE,Vneg,Hneg}, //1440x576(I)@50Hz
{1440/2,288,1728/2,312,13500L,0xFF,24/2,126/2,138/2,2,3,19,PROG,Vneg,Hneg}, //1440x288@50Hz
{1440,288,1728,313,27000L,0x80,24,126,138,3,3,19,PROG,Vneg,Hneg}, //1440x288@50Hz
{1440,288,1728,314,27000L,0x80,24,126,138,4,3,19,PROG,Vneg,Hneg}, //1440x288@50Hz
{2880,288,3456,312,54000L,0x40,48,252,276,2,3,19,INTERLACE,Vneg,Hneg}, //2880x576(I)@50Hz
{2880,288,3456,312,54000L,0x40,48,252,276,2,3,19,PROG,Vneg,Hneg}, //2880x288@50Hz
{2880,288,3456,313,54000L,0x40,48,252,276,3,3,19,PROG,Vneg,Hneg}, //2880x288@50Hz
{2880,288,3456,314,54000L,0x40,48,252,276,4,3,19,PROG,Vneg,Hneg}, //2880x288@50Hz
{1440,576,1728,625,54000L,0x40,24,128,136,5,5,39,PROG,Vpos,Hneg}, //1440x576@50Hz
{1920,1080,2640,1125,148000L,0x17,528,44,148,4,5,36,PROG,Vpos,Hpos}, //1920x1080@50Hz
{1920,1080,2750,1125,74000L,0x2E,638,44,148,4,5,36,PROG,Vpos,Hpos}, //1920x1080@24Hz
{1920,1080,2640,1125,74000L,0x2E,528,44,148,4,5,36,PROG,Vpos,Hpos}, //1920x1080@25Hz
{1920,1080,2200,1125,74000L,0x2E,88,44,148,4,5,36,PROG,Vpos,Hpos}, //1920x1080@30Hz
// VESA mode
{640,350,832,445,31500L,0x6D,32,64,96,32,3,60,PROG,Vneg,Hpos}, // 640x350@85
{640,400,832,445,31500L,0x6D,32,64,96,1,3,41,PROG,Vneg,Hneg}, // 640x400@85
{832,624,1152,667,57283L,0x3C,32,64,224,1,3,39,PROG,Vneg,Hneg}, // 832x624@75Hz
{720,350,900,449,28322L,0x7A,18,108,54,59,2,38,PROG,Vneg,Hneg}, // 720x350@70Hz
{720,400,900,449,28322L,0x7A,18,108,54,13,2,34,PROG,Vpos,Hneg}, // 720x400@70Hz
{720,400,936,446,35500L,0x61,36,72,108,1,3,42,PROG,Vpos,Hneg}, // 720x400@85
{640,480,800,525,25175L,0x89,16,96,48,10,2,33,PROG,Vneg,Hneg}, // 640x480@60
{640,480,832,520,31500L,0x6D,24,40,128,9,3,28,PROG,Vneg,Hneg}, // 640x480@72
{640,480,840,500,31500L,0x6D,16,64,120,1,3,16,PROG,Vneg,Hneg}, // 640x480@75
{640,480,832,509,36000L,0x60,56,56,80,1,3,25,PROG,Vneg,Hneg}, // 640x480@85
{800,600,1024,625,36000L,0x60,24,72,128,1,2,22,PROG,Vpos,Hpos}, // 800x600@56
{800,600,1056,628,40000L,0x56,40,128,88,1,4,23,PROG,Vpos,Hpos}, // 800x600@60
{800,600,1040,666,50000L,0x45,56,120,64,37,6,23,PROG,Vpos,Hpos}, // 800x600@72
{800,600,1056,625,49500L,0x45,16,80,160,1,3,21,PROG,Vpos,Hpos}, // 800x600@75
{800,600,1048,631,56250L,0x3D,32,64,152,1,3,27,PROG,Vpos,Hpos}, // 800X600@85
{848,480,1088,517,33750L,0x66,16,112,112,6,8,23,PROG,Vpos,Hpos}, // 840X480@60
{1024,384,1264,408,44900L,0x4d,8,176,56,0,4,20,INTERLACE,Vpos,Hpos}, //1024x768(I)@87Hz
{1024,768,1344,806,65000L,0x35,24,136,160,3,6,29,PROG,Vneg,Hneg}, // 1024x768@60
{1024,768,1328,806,75000L,0x2E,24,136,144,3,6,29,PROG,Vneg,Hneg}, // 1024x768@70
{1024,768,1312,800,78750L,0x2B,16,96,176,1,3,28,PROG,Vpos,Hpos}, // 1024x768@75
{1024,768,1376,808,94500L,0x24,48,96,208,1,3,36,PROG,Vpos,Hpos}, // 1024x768@85
{1152,864,1600,900,108000L,0x20,64,128,256,1,3,32,PROG,Vpos,Hpos}, // 1152x864@75
{1280,768,1440,790,68250L,0x32,48,32,80,3,7,12,PROG,Vneg,Hpos}, // 1280x768@60-R
{1280,768,1664,798,79500L,0x2B,64,128,192,3,7,20,PROG,Vpos,Hneg}, // 1280x768@60
{1280,768,1696,805,102250L,0x21,80,128,208,3,7,27,PROG,Vpos,Hneg}, // 1280x768@75
{1280,768,1712,809,117500L,0x1D,80,136,216,3,7,31,PROG,Vpos,Hneg}, // 1280x768@85
{1280,960,1800,1000,108000L,0x20,96,112,312,1,3,36,PROG,Vpos,Hpos}, // 1280x960@60
{1280,960,1728,1011,148500L,0x17,64,160,224,1,3,47,PROG,Vpos,Hpos}, // 1280x960@85
{1280,1024,1688,1066,108000L,0x20,48,112,248,1,3,38,PROG,Vpos,Hpos}, // 1280x1024@60
{1280,1024,1688,1066,135000L,0x19,16,144,248,1,3,38,PROG,Vpos,Hpos}, // 1280x1024@75
{1280,1024,1728,1072,157500L,0x15,64,160,224,1,3,44,PROG,Vpos,Hpos}, // 1280X1024@85
{1360,768,1792,795,85500L,0x28,64,112,256,3,6,18,PROG,Vpos,Hpos}, // 1360X768@60
{1400,1050,1560,1080,101000L,0x22,48,32,80,3,4,23,PROG,Vneg,Hpos}, // 1400x768@60-R
{1400,1050,1864,1089,121750L,0x1C,88,144,232,3,4,32,PROG,Vpos,Hneg}, // 1400x768@60
{1400,1050,1896,1099,156000L,0x16,104,144,248,3,4,42,PROG,Vpos,Hneg}, // 1400x1050@75
{1400,1050,1912,1105,179500L,0x13,104,152,256,3,4,48,PROG,Vpos,Hneg}, // 1400x1050@85
{1440,900,1600,926,88750L,0x26,48,32,80,3,6,17,PROG,Vneg,Hpos}, // 1440x900@60-R
{1440,900,1904,934,106500L,0x20,80,152,232,3,6,25,PROG,Vpos,Hneg}, // 1440x900@60
{1440,900,1936,942,136750L,0x19,96,152,248,3,6,33,PROG,Vpos,Hneg}, // 1440x900@75
{1440,900,1952,948,157000L,0x16,104,152,256,3,6,39,PROG,Vpos,Hneg}, // 1440x900@85
{1600,1200,2160,1250,162000L,0x15,64,192,304,1,3,46,PROG,Vpos,Hpos}, // 1600x1200@60
{1600,1200,2160,1250,175500L,0x13,64,192,304,1,3,46,PROG,Vpos,Hpos}, // 1600x1200@65
{1600,1200,2160,1250,189000L,0x12,64,192,304,1,3,46,PROG,Vpos,Hpos}, // 1600x1200@70
{1600,1200,2160,1250,202500L,0x11,64,192,304,1,3,46,PROG,Vpos,Hpos}, // 1600x1200@75
{1600,1200,2160,1250,229500L,0x0F,64,192,304,1,3,46,PROG,Vpos,Hpos}, // 1600x1200@85
{1680,1050,1840,1080,119000L,0x1D,48,32,80,3,6,21,PROG,Vneg,Hpos}, // 1680x1050@60-R
{1680,1050,2240,1089,146250L,0x17,104,176,280,3,6,30,PROG,Vpos,Hneg}, // 1680x1050@60
{1680,1050,2272,1099,187000L,0x12,120,176,296,3,6,40,PROG,Vpos,Hneg}, // 1680x1050@75
{1680,1050,2288,1105,214750L,0x10,128,176,304,3,6,46,PROG,Vpos,Hneg}, // 1680x1050@85
{1792,1344,2448,1394,204750L,0x10,128,200,328,1,3,46,PROG,Vpos,Hneg}, // 1792x1344@60
{1792,1344,2456,1417,261000L,0x0D,96,216,352,1,3,69,PROG,Vpos,Hneg}, // 1792x1344@75
{1856,1392,2528,1439,218250L,0x0F,96,224,352,1,3,43,PROG,Vpos,Hneg}, // 1856x1392@60
{1856,1392,2560,1500,288000L,0x0C,128,224,352,1,3,104,PROG,Vpos,Hneg}, // 1856x1392@75
{1920,1200,2080,1235,154000L,0x16,48,32,80,3,6,26,PROG,Vneg,Hpos}, // 1920x1200@60-R
{1920,1200,2592,1245,193250L,0x11,136,200,336,3,6,36,PROG,Vpos,Hneg}, // 1920x1200@60
{1920,1200,2608,1255,245250L,0x0E,136,208,344,3,6,46,PROG,Vpos,Hneg}, // 1920x1200@75
{1920,1200,2624,1262,281250L,0x0C,144,208,352,3,6,53,PROG,Vpos,Hneg}, // 1920x1200@85
{1920,1440,2600,1500,234000L,0x0E,128,208,344,1,3,56,PROG,Vpos,Hneg}, // 1920x1440@60
{1920,1440,2640,1500,297000L,0x0B,144,224,352,1,3,56,PROG,Vpos,Hneg}, // 1920x1440@75
};
#define SizeofVMTable(sizeof(s_VMTable)/sizeof(HDMI_VTiming))
#else
#define SizeofVMTable 0
#endif
extern _CODE BYTE bCSCOffset_16_235[] ;
extern _CODE BYTE bCSCOffset_0_255[] ;
#if (defined(SUPPORT_OUTPUTYUV))&&(defined(SUPPORT_INPUTRGB))
extern _CODE BYTE bCSCMtx_RGB2YUV_ITU601_16_235[] ;
extern _CODE BYTE bCSCMtx_RGB2YUV_ITU601_0_255[] ;
extern _CODE BYTE bCSCMtx_RGB2YUV_ITU709_16_235[] ;
extern _CODE BYTE bCSCMtx_RGB2YUV_ITU709_0_255[] ;
#endif
#if (defined(SUPPORT_OUTPUTRGB))&&(defined(SUPPORT_INPUTYUV))
extern _CODE BYTE bCSCMtx_YUV2RGB_ITU601_16_235[] ;
extern _CODE BYTE bCSCMtx_YUV2RGB_ITU601_0_255[] ;
extern _CODE BYTE bCSCMtx_YUV2RGB_ITU709_16_235[] ;
extern _CODE BYTE bCSCMtx_YUV2RGB_ITU709_0_255[] ;
#endif
static BYTE ucCurrentHDMIPort = 0 ;
static BOOL AcceptCDRReset = TRUE ;
///////////////////////////////////////////////////////////
// Function Prototype
///////////////////////////////////////////////////////////
BOOL CheckHDMIRX(void);
void DumpHDMIRX(void);
// void DumpSync(PSYNC_INFO pSyncInfo);
// void GetSyncInfo(PSYNC_INFO pSyncInfo);
// static BOOL CheckOutOfRange(PSYNC_INFO pSyncInfo);
// BOOL ValidateMode(PSYNC_INFO pSyncInfo);
void Interrupt_Handler(void);
void Timer_Handler(void);
void Video_Handler(void);
static void HWReset_HDMIRX(void);
static void SWReset_HDMIRX(void);
// void Terminator_Reset();
void setHDMIRX_TerminatorOff(void);
void setHDMIRX_TerminatorOn(void);
void Terminator_Off(void);
void Terminator_On(void);
void Check_RDROM(void);
void RDROM_Reset(void);
void SetDefaultRegisterValue(void);
// static void LoadDefaultSyncPolarity();
// static void LoadDefaultHWMuteControl();
// static void LoadDefaultHWAmpControl();
// static void LoadDefaultAudioOutputMap();
// static void LoadDefaultVideoOutput();
// static void LoadDefaultInterruptType();
// static void LoadDefaultAudioSampleClock();
// static void LoadDefaultROMSetting();
static void LoadCustomizeDefaultSetting(void);
static void SetupAudio(void);
BOOL ReadRXIntPin(void);
// USHORT GetVFreq();
static void ClearIntFlags(BYTE flag);
static void ClearHDCPIntFlags(void);
BOOL IsSCDT(void);
BOOL CheckPlg5VPwr(void);
// BOOL CheckPlg5VPwrOn();
// BOOL CheckPlg5VPwrOff();
BOOL CheckHDCPFail(void);
void SetMUTE(BYTE AndMask, BYTE OrMask);
void SetMCLKInOUt(BYTE MCLKSelect);
void SetIntMask1(BYTE AndMask,BYTE OrMask);
void SetIntMask2(BYTE AndMask,BYTE OrMask);
void SetIntMask3(BYTE AndMask,BYTE OrMask);
void SetIntMask4(BYTE AndMask,BYTE OrMask);
void SetGeneralPktType(BYTE type);
BOOL IsHDMIRXHDMIMode(void);
static void EnableAudio(void);
///////////////////////////////////////////////////////////
// Audio Macro
///////////////////////////////////////////////////////////
#define SetForceHWMute(){ SetHWMuteCTRL((~B_HW_FORCE_MUTE),(B_HW_FORCE_MUTE)); }
#define SetHWMuteClrMode(){ SetHWMuteCTRL((~B_HW_AUDMUTE_CLR_MODE),(B_HW_AUDMUTE_CLR_MODE));}
#define SetHWMuteClr(){ SetHWMuteCTRL((~B_HW_MUTE_CLR),(B_HW_MUTE_CLR)); }
#define SetHWMuteEnable(){ SetHWMuteCTRL((~B_HW_MUTE_EN),(B_HW_MUTE_EN)); }
#define ClearForceHWMute(){ SetHWMuteCTRL((~B_HW_FORCE_MUTE),0); }
#define ClearHWMuteClrMode(){ SetHWMuteCTRL((~B_HW_AUDMUTE_CLR_MODE),0); }
#define ClearHWMuteClr(){ SetHWMuteCTRL((~B_HW_MUTE_CLR),0); }
#define ClearHWMuteEnable(){ SetHWMuteCTRL((~B_HW_MUTE_EN),0);}
///////////////////////////////////////////////////////////
// Function Prototype
///////////////////////////////////////////////////////////
void RXINT_5V_PwrOn(void);
void RXINT_5V_PwrOff(void);
void RXINT_SCDT_On(void);
void RXINT_SCDT_Off(void);
void RXINT_RXCKON(void);
void RXINT_VideoMode_Chg(void);
void RXINT_HDMIMode_Chg(void);
void RXINT_AVMute_Set(void);
void RXINT_AVMute_Clear(void);
void RXINT_SetNewAVIInfo(void);
void RXINT_ResetAudio(void);
void RXINT_ResetHDCP(void);
void TimerServiceISR(void);
static void VideoTimerHandler(void);
static void AudioTimerHandler(void);
static void MuteProcessTimerHandler(void);
void AssignVideoTimerTimeout(USHORT TimeOut);
void ResetVideoTimerTimeout(void);
void SwitchVideoState(Video_State_Type state);
void AssignAudioTimerTimeout(USHORT TimeOut);
void ResetAudioTimerTimeout(void);
void SwitchAudioState(Audio_State_Type state);
#define EnableMuteProcessTimer(){ MuteResumingTimer = MuteByPKG?MUTE_RESUMING_TIMEOUT:0 ; }
#define DisableMuteProcessTimer(){ MuteResumingTimer = 0 ; }
static void DumpSyncInfo(HDMI_VTiming *pVTiming);
#define StartAutoMuteOffTimer(){ MuteAutoOff = ON ; }
#define EndAutoMuteOffTimer(){ MuteAutoOff = OFF ; }
static void CDR_Reset(void);
//static void Reset_SCDTOFF(void);
static void SetVideoInputFormatWithoutInfoFrame(BYTE bInMode);
static void SetColorimetryByMode(void/* PSYNC_INFO pSyncInfo */);
void SetVideoInputFormatWithInfoFrame(void);
BOOL SetColorimetryByInfoFrame(void);
void SetColorSpaceConvert(void);
// BOOL CompareSyncInfo(PSYNC_INFO pSyncInfo1,PSYNC_INFO pSyncInfo2);
// void HDCP_Reset();
void SetDVIVideoOutput(void);
void SetNewInfoVideoOutput(void);
void ResetAudio(void);
void SetHWMuteCTRL(BYTE AndMask, BYTE OrMask);
void SetAudioMute(BOOL bMute);
static void SetVideoMute(BOOL bMute);
// void DelayUS(ULONG us);
//#ifndef _MCU_8051_
//void delay1ms(USHORT ms);
//void ErrorF(char *fmt,...);
//#endif
///////////////////////////////////////////////////////////
// Connection Interface
///////////////////////////////////////////////////////////
void
Check_HDMInterrupt()
{
Interrupt_Handler();
}
BOOL
CheckHDMIRX()
{
Timer_Handler();
Video_Handler();
if(VState == VSTATE_VideoOn &&(!MuteByPKG))
{
return TRUE ;
}
return FALSE ;
}
void
SelectHDMIPort(BYTE ucPort)
{
if(ucPort != CAT_HDMI_PORTA)
{
ucPort = CAT_HDMI_PORTB ;
}
if(ucPort != ucCurrentHDMIPort)
{
ucCurrentHDMIPort = ucPort ;
}
HDMIRX_DEBUG_PRINTF(("SelectHDMIPort ucPort = %d, ucCurrentHDMIPort = %d\n",(int)ucPort, (int)ucCurrentHDMIPort));
// switch HDMI port should
// 1. power down HDMI
// 2. Select HDMI Port
// 3. call InitCAT6011();
}
BYTE
GetCurrentHDMIPort()
{
return ucCurrentHDMIPort ;
}
void
InitHDMIRX(BOOL bFullInit)
{
BYTE uc ;
#ifndef DISABLE_HWRESET
if(bFullInit)
{
HWReset_HDMIRX();
}
#endif
Terminator_Off();
//////////////////////////////////////////////
// Initialize HDMIRX chip uc.
//////////////////////////////////////////////
HDMIRX_WriteI2C_Byte(REG_RX_PWD_CTRL0, 0);
#ifndef DISABLE_RESET_REFCLK
if(bFullInit)
{
// this reset will activate the I2C no ACK in this call.
HDMIRX_WriteI2C_Byte(REG_RX_RST_CTRL, B_REGRST); // register reset
}
#endif
// delay1ms(1); // wait for B_REGRST down to zero
// uc = HDMIRX_ReadI2C_Byte(REG_RX_HDCP_CTRL);
HDMIRX_WriteI2C_Byte(REG_RX_RST_CTRL, B_SWRST|B_CDRRST|B_EN_AUTOVDORST); // sw reset
// delay1ms(1);
ucRevision = HDMIRX_ReadI2C_Byte(0x04);
//// uc = 0x89 ; // for external ROM
//uc = B_EXTROM | B_HDCP_ROMDISWR | B_HDCP_EN ;
//HDMIRX_WriteI2C_Byte(REG_RX_HDCP_CTRL, uc);
if(ucCurrentHDMIPort==CAT_HDMI_PORTA)
{
uc = B_PORT_SEL_A|B_PWD_AFEALL|B_PWDC_ETC ;
}
else
{
uc = B_PORT_SEL_B|B_PWD_AFEALL|B_PWDC_ETC ;
}
HDMIRX_WriteI2C_Byte(REG_RX_PWD_CTRL1, uc);
HDMIRX_DEBUG_PRINTF(("InitHDMIRX(FALSE): reg07 = %02X, ucCurrentHDMIPort = %d\n",(int)HDMIRX_ReadI2C_Byte(07),(int)ucCurrentHDMIPort));
SetIntMask1(0,B_PWR5VON|B_SCDTON|B_PWR5VOFF|B_SCDTOFF);
SetIntMask2(0,B_NEW_AVI_PKG|B_PKT_SET_MUTE|B_PKT_CLR_MUTE);
SetIntMask3(0,B_ECCERR|B_R_AUTH_DONE|B_R_AUTH_START);
SetIntMask4(0,0) ; // B_M_RXCKON_DET);
SetDefaultRegisterValue();
LoadCustomizeDefaultSetting();
SetALLMute(); // MUTE ALL with tristate video, SPDIF and all I2S channel
// 2006/10/31 marked by jjtseng
// HDMIRX_WriteI2C_Byte(REG_RX_REGPKTFLAG_CTRL,B_INT_EVERYAVI);
//~jjtseng 2006/10/31
HDMIRX_WriteI2C_Byte(REG_RX_RST_CTRL, B_EN_AUTOVDORST); // normal operation
bDisableAutoAVMute = FALSE ;
if(ucRevision == 0xA2)
{
HDMIRX_WriteI2C_Byte(REG_RX_HDCP_CTRL, 0x09);
HDMIRX_WriteI2C_Byte(REG_RX_HDCP_CTRL, 0x19);
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// DO NOT MOVE THE ACTION LOCATION!!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if( bFullInit )
{
// this delay is the experience by previous project support compatibility issue.
delay1ms(200); // delay 0.2 sec by TPV project experience.
}
RDROM_Reset(); // it should be do SWRESET again AFTER RDROM_Reset().
HDMIRX_WriteI2C_Byte(REG_RX_RST_CTRL, B_SWRST|B_EN_AUTOVDORST); // sw reset
delay1ms(1);
SetALLMute();
HDMIRX_WriteI2C_Byte(REG_RX_RST_CTRL, B_EN_AUTOVDORST); // normal operation
// Terminator_Reset();
//
// // 2006/10/26 modified by jjtseng
// // SwitchVideoState(VSTATE_SyncWait);
// SwitchVideoState(VSTATE_PwrOff);
// //~jjtseng 2006/10/26
#ifndef MANUAL_TURNON_HDMIRX
if(bFullInit)
{
Terminator_Off();
SwitchVideoState(VSTATE_SWReset);
}
#endif
#ifdef SUPPORT_REPEATER
RxHDCPRepeaterCapabilityClear(B_ENABLE_FEATURE_1P1|B_ENABLE_FAST);
if(bHDCPMode & HDCP_REPEATER)
{
RxHDCPRepeaterCapabilitySet(B_ENABLE_REPEATER);
RxHDCPRepeaterCapabilityClear(B_KSV_READY);
}
else
{
RxHDCPRepeaterCapabilityClear(B_KSV_READY|B_ENABLE_REPEATER);
SetIntMask3(~(B_R_AUTH_DONE|B_R_AUTH_START),B_ECCERR);
}
#else
HDMIRX_WriteI2C_Byte(REG_RX_CDEPTH_CTRL,HDMIRX_ReadI2C_Byte(REG_RX_CDEPTH_CTRL)&0xF);
#endif // SUPPORT_REPEATER
AcceptCDRReset = TRUE;
#ifndef MANUAL_TURNON_HDMIRX
if(!bFullInit)
{
// if switch from power saving, the terminator should be off at first.
Terminator_On();
SwitchVideoState(VSTATE_PwrOff);
}
#endif
#ifdef MANUAL_TURNON_HDMIRX
Terminator_Off(); // turn on the HDMIRX state machine need to call Turn_HDMIRX(ON);
SwitchVideoState(VSTATE_Off);
#endif
}
void Turn_HDMIRX(BOOL bEnable)
{
HDMIRX_DEBUG_PRINTF3(("Turn_HDMIRX(%s)\n",bEnable?"ON":"OFF")) ;
if( bEnable )
{
SWReset_HDMIRX() ;
}
else
{
Terminator_Off();
SwitchVideoState(VSTATE_Off);
}
}
void PowerDownHDMI()
{
HDMIRX_WriteI2C_Byte(REG_RX_PWD_CTRL1, B_PWD_AFEALL|B_PWDC_ETC|B_PWDC_SRV|B_EN_AUTOPWD);
HDMIRX_WriteI2C_Byte(REG_RX_PWD_CTRL0, B_PWD_ALL);
}
BOOL IsHDMIRXInterlace()
{
if(HDMIRX_ReadI2C_Byte(REG_RX_VID_MODE)&B_INTERLACE)
{
return TRUE ;
}
return FALSE ;
}
WORD getHDMIRXHorzTotal()
{
BYTE uc[2] ;
WORD hTotal ;
uc[0] = HDMIRX_ReadI2C_Byte(REG_RX_VID_HTOTAL_L);
uc[1] = HDMIRX_ReadI2C_Byte(REG_RX_VID_HTOTAL_H);
hTotal =(WORD)(uc [1] & M_HTOTAL_H);
hTotal <<= 8 ;
hTotal |=(WORD)uc[0] ;
return hTotal ;
}
WORD getHDMIRXHorzActive()
{
BYTE uc[3] ;
WORD hTotal, hActive ;
uc[0] = HDMIRX_ReadI2C_Byte(REG_RX_VID_HTOTAL_L);
uc[1] = HDMIRX_ReadI2C_Byte(REG_RX_VID_HTOTAL_H);
uc[2] = HDMIRX_ReadI2C_Byte(REG_RX_VID_HACT_L);
hTotal =(WORD)(uc [1] & M_HTOTAL_H);
hTotal <<= 8 ;
hTotal |=(WORD)uc[0] ;
hActive =(WORD)(uc[1] >> O_HACT_H)& M_HACT_H ;
hActive <<= 8 ;
hActive |=(WORD)uc[2] ;
if((hActive |(1<<11))< hTotal)
{
hActive |= 1<<11 ;
}
return hActive ;
}
WORD getHDMIRXHorzFrontPorch()
{
BYTE uc[2] ;
WORD hFrontPorch ;
uc[0] = HDMIRX_ReadI2C_Byte(REG_RX_VID_H_FT_PORCH_L);
uc[1] =(HDMIRX_ReadI2C_Byte(REG_RX_VID_HSYNC_WID_H)>> O_H_FT_PORCH)& M_H_FT_PORCH ;
hFrontPorch =(WORD)uc[1] ;
hFrontPorch <<= 8 ;
hFrontPorch |=(WORD)uc[0] ;
return hFrontPorch ;
}
WORD getHDMIRXHorzSyncWidth()
{
BYTE uc[2] ;
WORD hSyncWidth ;
uc[0] = HDMIRX_ReadI2C_Byte(REG_RX_VID_HSYNC_WID_L);
uc[1] = HDMIRX_ReadI2C_Byte(REG_RX_VID_HSYNC_WID_H)& M_HSYNC_WID_H ;
hSyncWidth =(WORD)uc[1] ;
hSyncWidth <<= 8 ;
hSyncWidth |=(WORD)uc[0] ;
return hSyncWidth ;
}
WORD getHDMIRXHorzBackPorch()
{
WORD hBackPorch ;
hBackPorch = getHDMIRXHorzTotal()- getHDMIRXHorzActive()- getHDMIRXHorzFrontPorch()- getHDMIRXHorzSyncWidth();
return hBackPorch ;
}
WORD getHDMIRXVertTotal()
{
BYTE uc[3] ;
WORD vTotal, vActive ;
uc[0] = HDMIRX_ReadI2C_Byte(REG_RX_VID_VTOTAL_L);
uc[1] = HDMIRX_ReadI2C_Byte(REG_RX_VID_VTOTAL_H);
uc[2] = HDMIRX_ReadI2C_Byte(REG_RX_VID_VACT_L);
vTotal =(WORD)uc[1] & M_VTOTAL_H ;
vTotal <<= 8 ;
vTotal |=(WORD)uc[0] ;
vActive =(WORD)(uc[1] >> O_VACT_H)& M_VACT_H ;
vActive |=(WORD)uc[2] ;
if(vTotal >(vActive |(1<<10)))
{
vActive |= 1<<10 ;
}
// for vertical front porch bit lost, ...
#if 0
if(vActive == 600 && vTotal == 634)
{
vTotal = 666 ; // fix the 800x600@72 issue
}
#endif
return vTotal ;
}
WORD getHDMIRXVertActive()
{
BYTE uc[3] ;
WORD vTotal, vActive ;
uc[0] = HDMIRX_ReadI2C_Byte(REG_RX_VID_VTOTAL_L);
uc[1] = HDMIRX_ReadI2C_Byte(REG_RX_VID_VTOTAL_H);
uc[2] = HDMIRX_ReadI2C_Byte(REG_RX_VID_VACT_L);
vTotal =(WORD)uc[1] & M_VTOTAL_H ;
vTotal <<= 8 ;
vTotal |=(WORD)uc[0] ;
vActive =(WORD)(uc[1] >> O_VACT_H)& M_VACT_H ;
vActive <<= 8 ;
vActive |=(WORD)uc[2] ;
if(vTotal >(vActive |(1<<10)))
{
vActive |= 1<<10 ;
}
return vActive ;
}
WORD getHDMIRXVertFrontPorch()
{
WORD vFrontPorch ;
vFrontPorch =(WORD)HDMIRX_ReadI2C_Byte(REG_RX_VID_V_FT_PORCH)& 0xF ;
if(getHDMIRXVertActive()== 600 && getHDMIRXVertTotal()== 666)
{
vFrontPorch |= 0x20 ;
}
return vFrontPorch ;
}
WORD getHDMIRXVertSyncToDE()
{
WORD vSync2DE ;
vSync2DE =(WORD)HDMIRX_ReadI2C_Byte(REG_RX_VID_VSYNC2DE);
return vSync2DE ;
}
WORD getHDMIRXVertSyncWidth()
{
WORD vSync2DE ;
WORD vTotal, vActive, hActive ;
vSync2DE = getHDMIRXVertSyncToDE();
vTotal = getHDMIRXVertTotal();
vActive = getHDMIRXVertActive();
hActive = getHDMIRXHorzActive();
#ifndef HDMIRX_A1
// estamite value.
if(vActive < 300)
{
return 3 ;
}
if(hActive == 640 && hActive == 480)
{
if(HDMIRX_ReadI2C_Byte(REG_RX_VID_XTALCNT_128PEL)< 0x80)
{
return 3 ;
}
return 2;
}
return 5 ;
#endif
}
WORD getHDMIRXVertSyncBackPorch()
{
WORD vBackPorch ;
vBackPorch = getHDMIRXVertSyncToDE()- getHDMIRXVertSyncWidth();
return vBackPorch ;
}
BYTE getHDMIRXxCnt()
{
return HDMIRX_ReadI2C_Byte(REG_RX_VID_XTALCNT_128PEL);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BOOL getHDMIRXAudioInfo(BYTE *pbSampleFreq, BYTE *pbValidCh);
// Parameter: pointer of BYTE pbSampleFreq - return sample freq
// pointer of BYTE pbValidCh - return valid audio channel.
// Return: FALSE - no valid audio information during DVI mode.
// TRUE - valid audio information returned.
// Remark: if pbSampleFreq is not NULL, *pbSampleFreq will be filled in with one of the following values:
// 0 - 44.1KHz
// 2 - 48KHz
// 3 - 32KHz
// 8 - 88.2 KHz
// 10 - 96 KHz
// 12 - 176.4 KHz
// 14 - 192KHz
// Otherwise - invalid audio frequence.
// if pbValidCh is not NULL, *pbValidCh will be identified with the bit valie:
// bit[0] - '0' means audio channel 0 is not valid, '1' means it is valid.
// bit[1] - '0' means audio channel 1 is not valid, '1' means it is valid.
// bit[2] - '0' means audio channel 2 is not valid, '1' means it is valid.
// bit[3] - '0' means audio channel 3 is not valid, '1' means it is valid.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL getHDMIRXAudioInfo(BYTE *pbAudioSampleFreq, BYTE *pbValidCh)
{
#ifndef DISABLE_AUDIO_SUPPORT
if(IsHDMIRXHDMIMode())
{
if(pbAudioSampleFreq)
{
*pbAudioSampleFreq = HDMIRX_ReadI2C_Byte(REG_RX_FS)& M_Fs ;
}
if(pbValidCh)
{
*pbValidCh = HDMIRX_ReadI2C_Byte(REG_RX_AUDIO_CH_STAT);
if(*pbValidCh & B_AUDIO_LAYOUT)
{
*pbValidCh &= M_AUDIO_CH ;
}
else
{
*pbValidCh = B_AUDIO_SRC_VALID_0 ;
}
}
return TRUE ;
}
else
#endif
{
return FALSE ;
}
}
///////////////////////////////////////////////////////////
// Get Info Frame and HDMI Package
// Need upper program pass information and read them.
///////////////////////////////////////////////////////////
#ifdef GET_PACKAGE
// 2006/07/03 added by jjtseng
BOOL
GetAVIInfoFrame(BYTE *pData)
{
// BYTE checksum ;
// int i ;
if(pData == NULL)
{
return ER_FAIL ;
}
pData[0] = AVI_INFOFRAME_TYPE|0x80 ; // AVI InfoFrame
pData[1] = HDMIRX_ReadI2C_Byte(REG_RX_AVI_VER);
pData[2] = AVI_INFOFRAME_LEN ;
HDMIRX_ReadI2C_ByteN(REG_RX_AVI_DB0, pData+3,AVI_INFOFRAME_LEN+1);
return TRUE ;
}
//~jjtseng 2006/07/03
// 2006/07/03 added by jjtseng
BOOL
GetAudioInfoFrame(BYTE *pData)
{
// BYTE checksum ;
BYTE i ;
if(pData == NULL)
{
return FALSE ;
}
pData[0] = AUDIO_INFOFRAME_TYPE|0x80 ; // AUDIO InfoFrame
pData[1] = HDMIRX_ReadI2C_Byte(REG_RX_AUDIO_VER);
pData[2] = HDMIRX_ReadI2C_Byte(REG_RX_AUDIO_LEN); ;
HDMIRX_ReadI2C_ByteN(REG_RX_AUDIO_DB0, pData+3,6);
for( i = 5 ; i <= pData[2] ; i++ )
{
pData[4+i] = 0 ;
}
return TRUE ;
}