aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/cdv/drv/psb_intel_hdmi_edid.h
blob: 583abb2942d7cef6e96bef7a1f88318012c1eaf4 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
/*
 * Copyright © 2011 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 * Authors:
 *	
 */
/* chunfeng.zhao@intel.com
  */
#ifndef PSB_INTEL_HDMI_EDID_H
#define PSB_INTEL_HDMI_EDID_H

//#include "..\\..\\Common\\Platform.h"

////////////////////////////////////////////
//
// Max number of EDID extensions possible
//
////////////////////////////////////////////
#define MAX_EDID_EXTENSIONS				254  //Max EDID blocks minus Block 0
#define NUM_BASEEDID_STANDARD_TIMING	8
#define MAX_BASEEDID_DTD_BLOCKS			4

#define MAX_VIC_DEFINED					128  

// New Macros for supporting EDID 1.4

// Macros for EDID Revision and Version
#define EDID_VERSION_1 0x01
#define EDID_REVISION_4 0x04

// Macros for CVT and GTF related support in Monitor descriptor
#define EDID14_CVT_TIMING_SUPPORTED 0x04
#define EDID14_DEFAULT_GTF_SUPPORTED 0x00
#define EDID14_SECONDARY_GTF_SUPPORTED 0x02

// Macros for display device data block in CEA.
#define EDID14_DISPLAY_DEVICE_DATA_TAG 0xFF
#define EDID14_DISPLAY_DEVICE_DATA_CHILD_TAG 0x02
#define EDID14_DISPLAY_DEVICE_DATA_LENGTH 0x20
#define EDID14_DISPLAY_PORT_INTERFACE 0x09

// Macros indicating digital interfaces supported by the display. 
#define EDID14_DVI_SUPPORTED 0x01
#define EDID14_DISPLAY_PORT_SUPPORTED 0x05
#define EDID14_HDMI_A_SUPPORTED 0x02
#define EDID14_HDMI_B_SUPPORTED 0x03

#define EDID14_MAX_MONITOR_DESCRIPTORS 0x03

// Macros related to EDID 1.4 Color Bit Depth support
#define EDID14_COLOR_BIT_DEPTH_UNDEFINED         0x00
#define EDID14_SIX_BITS_PER_PRIMARY_COLOR        0x06
#define EDID14_EIGHT_BITS_PER_PRIMARY_COLOR      0x08
#define EDID14_TEN_BITS_PER_PRIMARY_COLOR        0x0A
#define EDID14_TWELVE_BITS_PER_PRIMARY_COLOR     0x0C
#define EDID14_FOURTEEN_BITS_PER_PRIMARY_COLOR   0x0E
#define EDID14_SIXTEEN_BITS_PER_PRIMARY_COLOR    0x10
#define EDID14_INVALID_COLOR_BIT_DEPTH           0x07

// Macro for showing Color Bit Depth support for existing displays
#define EDID_EIGHT_BITS_PER_PRIMARY_COLOR        0x08

// Macro for Established Timings III Block descriptor 
#define EST_TIMINGS_III_BLOCK_TAG                0xF7
#define EST_TIMINGS_III_BLOCK_DATA_LENGTH        0x06

// Macro for indicating byte length
#define BYTE_LENGTH                              0x08

////////////////////////////////////////////
//
// Max number of EDID Blocks
//
////////////////////////////////////////////
#define MAX_EDID_BLOCKS					255 //According to E-EDID Standard doc.
#define EDID_BLOCK_SIZE					128

// Macros for EDID Revision and Version for EDID 1.3
#define EDID_VERSION_1_3 0x01
#define EDID_REVISION_1_3 0x03

////////////////////////////////////////////
// Base EDID header
////////////////////////////////////////////
static const unsigned char BASEEDID_Header[8] = {0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00};

// Display Range Limits Offset Flags.
// Applicable only from EDID 1.4 onwards
typedef union _edid_range_limits_flags {
	uint8_t	ucRangeLimitOffsetFlags;	// Range Limits Offset Flags
	struct {
		uint8_t	ucVerticalRateOffset   : 2; // Vertical Rate Offset
		uint8_t	ucHorizontalRateOffset : 2; // Horizontal Rate Offset
		uint8_t	ucReserved             : 4; // Reserved.
		};
} edid_range_limits_flags_t;

////////////////////////////////////////////
//
//	18-byte DTD block
//  Refer Table 3.16, 3.17 & 3.18 of 
//  EDID spec
//
////////////////////////////////////////////
typedef struct _edid_dtd_timing {
#pragma pack(1)

	int16_t wPixelClock;					// Pixel clock / 10000

	uint8_t ucHA_low;						// Lower 8 bits of H. active pixels
	uint8_t ucHBL_low;					// Lower 8 bits of H. blanking
	union {
		uint8_t ucHAHBL_high;
		struct {
			uint8_t	ucHBL_high : 4;		// Upper 4 bits of H. blanking
			uint8_t	ucHA_high  : 4;		// Upper 4 bits of H. active pixels
		};
	};

	uint8_t ucVA_low;						// Lower 8 bits of V. active lines
	uint8_t ucVBL_low;					// Lower 8 bits of V. blanking
	union {
		uint8_t ucVAVBL_high;
		struct {
			uint8_t	ucVBL_high : 4;		// Upper 4 bits of V. blanking
			uint8_t	ucVA_high  : 4;		// Upper 4 bits of V. active pixels
		};
	};

	uint8_t ucHSO_low;					// Lower 8 bits of H. sync offset
	uint8_t ucHSPW_low;					// Lower 8 bits of H. sync pulse width
	union {
		uint8_t ucVSOVSPW_low;
		struct {
			uint8_t	ucVSPW_low : 4;		// Lower 4 bits of V. sync pulse width
			uint8_t	ucVSO_low  : 4;		// Lower 4 bits of V. sync offset
		};
	};
	union {
		uint8_t ucHSVS_high;
		struct {
			uint8_t	ucVSPW_high : 2;	// Upper 2 bits of V. sync pulse width
			uint8_t	ucVSO_high  : 2;	// Upper 2 bits of V. sync offset
			uint8_t	ucHSPW_high : 2;	// Upper 2 bits of H. sync pulse width
			uint8_t	ucHSO_high  : 2;	// Upper 2 bits of H. sync offset
		};
	};

	uint8_t ucHIS_low;					// Lower 8 bits of H. image size in mm
	uint8_t ucVIS_low;					// Lower 8 bits of V. image size in mm
	union {
		uint8_t ucHISVIS_high;
		struct {
			uint8_t	ucVIS_high : 4;		// Upper 4 bits of V. image size
			uint8_t	ucHIS_high : 4;		// Upper 4 bits of H. image size
		};
	};

	uint8_t ucHBorder;					// H. border in pixels
	uint8_t ucVBorder;					// V. border in pixels

	union {
		uint8_t ucFlags;					// Hsync & Vsync polarity, etc. flags
		struct {
			uint8_t	ucStereo1	 : 1;	// Stereo definition with bit[6:5]
			uint8_t	ucHSync_Pol  : 1;	// Hsync polarity (0: Neg, 1: Pos)
			uint8_t	ucVSync_Pol  : 1;	// Vsync polarity (0: Neg, 1: Pos)
			uint8_t	ucSync_Conf  : 2;	// Sync configuration
										// 00 : Analog composite
										// 01 : Bipolar analog composite
										// 00 : Digital composite
										// 00 : Digital separate
			uint8_t	ucStereo2	 : 2;	// Stereo definition
										// 00 : Normal display, no stereo 
										// xx : Stereo definition with bit0
			uint8_t	ucInterlaced : 1;	// Interlaced / Non-interlaced
										// 0 : Non-interlaced
										// 1 : Interlaced
		};
	};

#pragma pack()
} edid_dtd_timing_t;


////////////////////////////////////////////
//
//	Standard timing identification
//  Refer Table 3.15 of EDID spec
//
////////////////////////////////////////////
typedef union _edid_std_timing {
	uint16_t  usStdTiming;

	struct {
#pragma pack(1)
		uint8_t	ucHActive;				// (HActive/8) - 31;
		struct {
			uint8_t	ucRefreshRate : 6;	// Refresh Rate - 60
			uint8_t	ucAspectRatio : 2;	// Aspect ratio (HActive/VActive)
										// 00:  1:1 Aspect ratio
										// 01:  4:3 Aspect ratio
										// 10:  5:4 Aspect ratio
										// 11: 16:9 Aspect ratio
		};
	};
#pragma pack()

} edid_std_timing_t;
////////////////////////////////////////////////////////
// Aspect Ratio def's as per Edid 1.3 Standard Timings
////////////////////////////////////////////////////////
#define EDID_STD_ASPECT_RATIO_16_10   0x0
#define EDID_STD_ASPECT_RATIO_4_3     0x1
#define EDID_STD_ASPECT_RATIO_5_4     0x2
#define EDID_STD_ASPECT_RATIO_16_9    0x3


////////////////////////////////////////////
//
//	Monitor range limits
//
////////////////////////////////////////////
typedef struct _monitor_range_limits {	
#pragma pack(1)

	uint8_t ucMin_vert_rate;			//Min Vertical Rate,in Hz
	uint8_t ucMax_vert_rate;			//Max Vertical Rate, in Hz
	uint8_t ucMin_horz_rate;			//Min Horizontal Rate, in Hz
	uint8_t ucMax_horz_rate;			//Max Horizontal Rate, in Hz
	uint8_t ucMax_pixel_clock;		//Max Pixel Clock,Value/10 Mhz
	uint8_t ucTiming_formula_support;	//00 - No Secondary Timing Formula Supported
									//02 - Secondary GTF Curve Supported
									//In EDID 1.4, this may indicate CVT support as well
	//If timing_formula_support is 02
	uint8_t ucReserved;				//00h
	uint8_t ucStart_freq;				//Horizontal Freq, Value/2, KHz
	uint8_t ucByte_C;					//C*2
	uint8_t ucLSB_M;					//LSB of M Value
	uint8_t ucMSB_M;					//MSB of M Value
	uint8_t ucByte_K;					//K Value
	uint8_t ucByte_J;					//J*2

#pragma pack()
} monitor_range_limits_t;

////////////////////////////////////////////
//
// Color point
//
////////////////////////////////////////////
typedef struct _color_point {
#pragma pack(1)

	uint8_t ucWhite_point_index_number_1;
	uint8_t ucWhite_low_bits_1;
	uint8_t ucWhite_x_1;
	uint8_t ucWhite_y_1;
	uint8_t ucWhite_gamma_1;
	uint8_t ucWhite_point_index_number_2;
	uint8_t ucWhite_low_bits_2;
	uint8_t ucWhite_x_2;
	uint8_t ucWhite_y_2;
	uint8_t ucWhite_gamma_2;
	uint8_t ucByte_15;
	uint8_t ucByte_16_17[2];

#pragma pack()
} color_point_t;

////////////////////////////////////////////
//
//	Monitor description descriptor
//  Refer Table 3.19 & 3.20 of EDID spec
//
////////////////////////////////////////////
#define BASEEDID_MONITORSN_MDDATATYPE			0xFF
#define BASEEDID_ASCIISTRING_MDDATATYPE			0xFE
#define BASEEDID_MONITORRANGELIMIT_MDDATATYPE	0xFD
#define BASEEDID_MONITORNAME_MDDATATYPE			0xFC
#define BASEEDID_COLORPOINT_MDDATATYPE			0xFB
#define BASEEDID_STDTIMINGS_MDDATATYPE			0xFA

// Structure definition for Established Timings III monitor block
typedef struct _est_timings_iii_block {
#pragma pack(1)
	// The first byte will show the VESA DMTS Standard Version. 
	// The following six bytes will have the Timings Bit Mask.
	// Right now only 6 bytes are used for this!!!
	// Rest is reserved.
	uint8_t ucVesaDMTVersion;	//Byte 0 indicating the VESA DMT Version.
	uint8_t ucTimingBitMask[6];// Next 6 bytes indicating the Timing Bit Mask Bytes used in Est Timing III.
	uint8_t bReserved[6];//Next 6 bytes are reserved
#pragma pack()
} est_timings_iii_block_t;

typedef struct _monitor_descriptor {
#pragma pack(1)

	int16_t wFlag;			// = 0000 when block is used as descriptor
	uint8_t ucFlag0;		// Reserved

	uint8_t ucDataTypeTag;

	uint8_t ucFlag1;		// 00 for descriptor
	
	union {

		// Monitor S/N (ucDataTypeTag = FF)
		uint8_t ucMonitorSerialNumber[13];

		// ASCII string (ucDataTypeTag = FE)
		uint8_t ucASCIIString[13];

		// Monitor range limit (ucDataTypeTag = FD)
		monitor_range_limits_t MonitorRangeLimits;

		// Monitor name (ucDataTypeTag = FC)
		uint8_t ucMonitorName[13];

		// Color point (ucDataTypeTag = FB)
		color_point_t ColorPoint;

		// ESTABLISHED TIMINGS III BLOCK = F7 (Added for EDID 1.4)
		est_timings_iii_block_t stEstTimingsIIIBlock;

		// Standard timings (ucDataTypeTag = FA)
		struct {
			edid_std_timing_t ExtraStdTiming[6];
			uint8_t ucFixedValueOfA0;		// Should be 0xA0
		};

		// Manufacturer specific value (ucDataTypeTag = 0F-00)
		uint8_t ucMfgSpecificData[13];
	};

#pragma pack()
} monitor_descriptor_t;

////////////////////////////////////////////
//
//	EDID PnP ID fields
//
////////////////////////////////////////////
typedef union _baseedid_pnpid {
	uint8_t		VendorProductID[10];	// Vendor / Product identification

	struct {
		uint8_t ManufacturerID[2];	// Bytes 8, 9: Manufacturer ID 
		uint8_t ProductID[2];			// Bytes 10, 11: Product ID
		uint8_t SerialNumber[4];		// Bytes 12-15: Serial numbers
		uint8_t WeekOfManufacture;	// Byte 16: Week of manufacture
		uint8_t YearOfManufacture;	// Byte 17: Year of manufacture
	};
} baseedid_pnpid_t;

//
// Chromaticity structure
// Table 3.12 of Base Block for details
//
typedef struct _baseedid_chromaticity_block {
    union{
            uint8_t RedGreenLowBits;           // Byte 1
           struct{
                uint8_t ucGreenYLowBits   : 2; // bit 1:0
                uint8_t ucGreenXLowBits   : 2; // bit 3:2
                uint8_t ucRedYLowBits     : 2; // bit 5:4
                uint8_t ucRedXLowBits     : 2; // bit 7:6
            };
        };

    union{
            uint8_t ucBlueWhiteLowBits;       // Byte 2
           struct{
                uint8_t ucWhiteYLowBits   : 2; // bit 1:0
                uint8_t ucWhiteXLowBits   : 2; // bit 3:2
                uint8_t ucBlueYLowBits    : 2; // bit 5:4
                uint8_t ucBlueXLowBits    : 2; // bit 7:6
            };
        };

    uint8_t ucRedXUpperBits; // bit 9:2          Byte 3
    uint8_t ucRedYUpperBits; // bit 9:2          Byte 4

    uint8_t ucGreenXUpperBits; // bit 9:2        Byte 5
    uint8_t ucGreenYUpperBits; // bit 9:2        Byte 6

    uint8_t ucBlueXUpperBits; // bit 9:2         Byte 7
    uint8_t ucBlueYUpperBits; // bit 9:2         Byte 8

    uint8_t ucWhiteXUpperBits; // bit 9:2        Byte 9
    uint8_t ucWhiteYUpperBits; // bit 9:2        Byte 10
} baseedid_chromaticity_block_t;

////////////////////////////////////////////
//
//	128-byte EDID 1.x block0 structure
//
////////////////////////////////////////////
typedef struct _baseedid_1_x {
#pragma pack(1)

	//
	// Header: 8 bytes (Table 3.3 of EDID spec)
	char		Header[8];		// EDID1.x header "0 FFh FFh FFh FFh FFh FFh 0"
	
	//
	// Vendor/Product ID: 10 bytes (Table 3.4, 3.5 & 3.6 of EDID spec)
	//baseedid_pnpid_t;
	union {
		uint8_t		VendorProductID[10];	// Vendor / Product identification
		struct {
			uint8_t ManufacturerID[2];	// Bytes 8, 9: Manufacturer ID 
			uint8_t ProductID[2];			// Bytes 10, 11: Product ID
			uint8_t SerialNumber[4];		// Bytes 12-15: Serial numbers
			uint8_t WeekOfManufacture;	// Byte 16: Week of manufacture
			uint8_t YearOfManufacture;	// Byte 17: Year of manufacture
		};
	};
	
	//
	// EDID structure Version/Revision: 2 bytes (Table 3.7 of EDID spec)
	uint8_t		ucVersion;		// EDID version no.
	uint8_t		ucRevision;		// EDID revision no.
	
	//
	// Basic display parameters & features: 5 bytes (Table 3.8 of EDID spec)
	union {
		uint8_t	ucVideoInput;	// Video input definition (Refer Table 3.9 of EDID spec)

		struct {
			uint8_t	ucSyncInput	 : 4;	// Sync input supported (iff ucDigitInput = 0)
			uint8_t	ucSetup		 : 1;	// Display setup (iff ucDigitInput = 0)
			uint8_t	ucSigLevStd	 : 2;	// Signal level Standard (iff ucDigitInput = 0)

			uint8_t	ucDigitInput : 1;	// 1: Digital input; 0: Analog input
		};
	};
	
	// Image size (Table 3.10 of EDID spec)
	uint8_t		ucMaxHIS;		// Maximum H. image size in cm
	uint8_t		ucMaxVIS;		// Maximum V. image size in cm
	
	// Gamma (display transfer characteristic)
	uint8_t		ucGamma;		// Display gamma value	[= (gamma*100)-100]
	
	// Feature support (Table 3.11 of EDID spec)
	union {
		uint8_t	ucDMPSFeature;	// DPMS feature support
		
		struct {
			uint8_t	ucGTFSupport : 1;	// GTF timing support (1: Yes)
			uint8_t	ucPTM		 : 1;	// Preferred timing is 1st DTD (1: Yes) [Must if EDID >= 1.3]
			uint8_t	ucColorSpace : 1;	// Use STD color space (1:Yes) [If set ColorChars should match sRGB values in EDID spec Appendix A]
			uint8_t	ucDispType	 : 2;	// Display type
										// 00: Monochrome
										// 01: R/G/B color display
										// 10: Non R/G/B multicolor display
										// 11: Undefined
			uint8_t	ucActiveOff	 : 1;	// Active off (Display consumes less power/blanks out when it receives an out of range timing)
			uint8_t	ucSuspend	 : 1;	// Suspend	(Refer VESA DPMS spec)
			uint8_t	ucStandBy	 : 1;	// Stand-by	(Refer VESA DPMS spec)
		};
	};

	//
	// Phosphor or Filter Chromaticity: 10 bytes
	uint8_t		ColorChars[10];	// Color characteristics	(Refer Table 3.12 of EDID spec)

	//
	// Established timings: 3 bytes (Table 3.14 of EDID spec)
	union {
		uint8_t EstTiming1;
		struct {
			uint8_t bSupports800x600_60	: 1;
			uint8_t bSupports800x600_56	: 1;
			uint8_t bSupports640x480_75	: 1;
			uint8_t bSupports640x480_72	: 1;
			uint8_t bSupports640x480_67	: 1;
			uint8_t bSupports640x480_60	: 1;
			uint8_t bSupports720x400_88	: 1;
			uint8_t bSupports720x400_70	: 1;
		};
	};
	union {
		uint8_t EstTiming2;
		struct {
			uint8_t bSupports1280x1024_75	: 1;
			uint8_t bSupports1024x768_75	: 1;
			uint8_t bSupports1024x768_70	: 1;
			uint8_t bSupports1024x768_60	: 1;
			uint8_t bSupports1024x768_87i : 1;
			uint8_t bSupports832x624_75	: 1;
			uint8_t bSupports800x600_75	: 1;
			uint8_t bSupports800x600_72	: 1;
		};
	};
	union {
		uint8_t MfgTimings;
		struct {
			uint8_t bMfgReservedTimings	: 7;
			uint8_t bSupports1152x870_75	: 1;
		};
	};

	//
	// Standard timings: 8 bytes (Table 3.15 of EDID spec)
	edid_std_timing_t	StdTiming[NUM_BASEEDID_STANDARD_TIMING];	// 8 Standard timing support

	//
	// Detailed timing section - 72 bytes (4*18 bytes)
	union {
		edid_dtd_timing_t	DTD[MAX_BASEEDID_DTD_BLOCKS];			// Four DTD data blocks

		monitor_descriptor_t MonitorInfo[MAX_BASEEDID_DTD_BLOCKS];
	};
	
	uint8_t		ucNumExtBlocks;	// Number of extension EDID blocks
	uint8_t		ucChecksum;		// Checksum of the EDID block

#pragma pack()
} baseedid_1_x_t;

////////////////////////////////////////////
//
//	128-byte EDID 1.4 block0 structure
//  EDID 1.4 block0 structure is different from 1.3 block0
//  Thats why this new structure has been added 
//  Changes are commented in the structure itself
//
////////////////////////////////////////////
typedef struct _baseedid_1_4 {
#pragma pack(1)

	//
	// Header: 8 bytes (Table 3.3 of EDID spec)
	char		Header[8];		// EDID1.x header "0 FFh FFh FFh FFh FFh FFh 0"
	
	//
	// Vendor/Product ID: 10 bytes (Table 3.4, 3.5 & 3.6 of EDID spec)
	union {
		uint8_t		VendorProductID[10];	// Vendor / Product identification
		struct {
			uint8_t ManufacturerID[2];	// Bytes 8, 9: Manufacturer ID 
			uint8_t ProductID[2];			// Bytes 10, 11: Product ID
			uint8_t SerialNumber[4];		// Bytes 12-15: Serial numbers
			uint8_t WeekOfManufacture;	// Byte 16: Week of manufacture
			uint8_t YearOfManufacture;	// Byte 17: Year of manufacture
		};
	};
	
	//
	// EDID structure Version/Revision: 2 bytes (Table 3.7 of EDID spec)
	uint8_t		ucVersion;		// EDID version no.
	uint8_t		ucRevision;		// EDID revision no.
	
	//
	// Basic display parameters & features: 5 bytes (Table 3.8 of EDID spec)
	union {
		uint8_t	ucVideoInput;	// Video input definition (Refer Table 3.9 of EDID spec)

		struct {
			uint8_t	ucSyncInput	 : 4;	// Sync input supported (iff ucDigitInput = 0)
			uint8_t	ucSetup		 : 1;	// Display setup (iff ucDigitInput = 0)
			uint8_t	ucSigLevStd	 : 2;	// Signal level Standard (iff ucDigitInput = 0)

			uint8_t	ucDigitInput : 1;	// 1: Digital input; 0: Analog input
		};
		// This structure has been introduced to reflect the changes in EDID 1.4 spec
		// This sturcture shows new meaning of VIDEO INPUT DEFINITION when input is digital 
		struct {
			uint8_t	ucDigitalVideoInterface : 4;	// Digital Video Interface Standard Supported.
			uint8_t	ucColorBitDepth			: 3;	// Color Bit Depth. 
													// 0 0 0 -- Color Bit Depth is undefined
													// 0 0 1 -- 6 Bits per Primary Color
													// 0 1 0 -- 8 Bits per Primary Color
													// 0 1 1 -- 10 Bits per Primary Color
													// 1 0 0 -- 12 Bits per Primary Color
													// 1 0 1 -- 14 Bits per Primary Color
													// 1 1 0 -- 16 Bits per Primary Color
													// 1 1 1 -- Reserved (Do Not Use)
			uint8_t	bIsDigitalVideoSignalInterface	: 1; // Bit 7
		};
	};
	
	// As per the EDID spec 1.4, the following two fields can be aspect ratios as well. 
	union {
			uint8_t ucMaxHIS; // Maximum H. image size in cm 
			uint8_t ucARLandscape; // Landscape Aspect raio as per EDID 1.4 spec
	};
	union {
			uint8_t ucMaxVIS; // Maximum V. image size in cm 
			uint8_t ucARPortrait; // Portrait Aspect raio as per EDID 1.4 spec
	};
	
	// Gamma (display transfer characteristic)
	uint8_t		ucGamma;		// Display gamma value	[= (gamma*100)-100]
	
	// Feature support (Table 3.11 of EDID spec)
	union {
		uint8_t	ucDMPSFeature;	// DPMS feature support
		
		struct {
			uint8_t	ucContinuousDisplay : 1;	// Display is continuous or non-continuous (1: Yes)
			uint8_t	ucPTM		 : 1;	// Preferred timing mode indicates native pixel format and native RR. 
			uint8_t	ucColorSpace : 1;	// Use STD color space (1:Yes) [If set ColorChars should match sRGB values in EDID spec Appendix A]
			uint8_t	ucDispType	 : 2;	// Display type
										// 00: Monochrome
										// 01: R/G/B color display
										// 10: Non R/G/B multicolor display
										// 11: Undefined
			uint8_t	ucActiveOff	 : 1;	// Active off (Display consumes less power/blanks out when it receives an out of range timing)
			uint8_t	ucSuspend	 : 1;	// Suspend	(Refer VESA DPMS spec)
			uint8_t	ucStandBy	 : 1;	// Stand-by	(Refer VESA DPMS spec)
		};

		struct {
			uint8_t	bReserved0 : 1;
			uint8_t	bReserved1 : 1;
			uint8_t	bReserved2 : 1;
			uint8_t	ucColorEncodingFormat	 : 2;	// Supported Color Encoding Format if Video Input is digital
													// 00: RGB 4:4:4
													// 01: RGB 4:4:4 & YCrCb 4:4:4
													// 10: RGB 4:4:4 & YCrCb 4:2:2
													// 11: RGB 4:4:4 & YCrCb 4:4:4 & YCrCb 4:2:2
			uint8_t	bReserved3 : 1;
			uint8_t	bReserved4 : 1;
			uint8_t	bReserved5 : 1;
		};
	};

	//
	// Phosphor or Filter Chromaticity: 10 bytes
	uint8_t		ColorChars[10];	// Color characteristics	(Refer Table 3.12 of EDID spec)

	//
	// Established timings: 3 bytes (Table 3.14 of EDID spec)
	union {
		uint8_t EstTiming1;
		struct {
			uint8_t bSupports800x600_60	: 1;
			uint8_t bSupports800x600_56	: 1;
			uint8_t bSupports640x480_75	: 1;
			uint8_t bSupports640x480_72	: 1;
			uint8_t bSupports640x480_67	: 1;
			uint8_t bSupports640x480_60	: 1;
			uint8_t bSupports720x400_88	: 1;
			uint8_t bSupports720x400_70	: 1;
		};
	};
	union {
		uint8_t EstTiming2;
		struct {
			uint8_t bSupports1280x1024_75	: 1;
			uint8_t bSupports1024x768_75	: 1;
			uint8_t bSupports1024x768_70	: 1;
			uint8_t bSupports1024x768_60	: 1;
			uint8_t bSupports1024x768_87i : 1;
			uint8_t bSupports832x624_75	: 1;
			uint8_t bSupports800x600_75	: 1;
			uint8_t bSupports800x600_72	: 1;
		};
	};
	union {
		uint8_t MfgTimings;
		struct {
			uint8_t bMfgReservedTimings	: 7;
			uint8_t bSupports1152x870_75	: 1;
		};
	};

	//
	// Standard timings: 8 bytes (Table 3.15 of EDID spec)
	edid_std_timing_t StdTiming[NUM_BASEEDID_STANDARD_TIMING];	// 8 Standard timing support

	// Detailed timing section - 72 bytes (4*18 bytes)
	// As per the new spec 1.4, the first Detailed Timing Section should contain the PREFERED TIMING BLOCK
	edid_dtd_timing_t PreferedTimingMode;
	// The rest 54 bytes of the Detailed Timing Section. 
	union {
		edid_dtd_timing_t DTD[MAX_BASEEDID_DTD_BLOCKS - 1];			// Three DTD data blocks

		monitor_descriptor_t MonitorInfo[MAX_BASEEDID_DTD_BLOCKS - 1]; // Three Monitor Descriptor blocks
	};
	
	uint8_t		ucNumExtBlocks;	// Number of extension EDID blocks
	uint8_t		ucChecksum;		// Checksum of the EDID block

#pragma pack()
} baseedid_1_4_t;


//*****************************************************
//*****************************************************
//
// DATA STRUCTURES AND DEFINITIONS FOR CE-EXTENSION
//
//*****************************************************
//*****************************************************

/////////////////////////////////
//
//CE - Extension Block Structure
//
/////////////////////////////////
typedef struct _ce_edid {
	uint8_t	ucTag;
	uint8_t	ucRevision;
	uint8_t	ucDTDOffset;
	uint8_t	ucCapabilty;
	uint8_t	data[123];
	uint8_t   ucCheckSum;   
} ce_edid_t;

////////////////////////////////////////////
//
//CE - Video Capability Data block structure
//
////////////////////////////////////////////
typedef union _video_cap_data_block {
    uint8_t ucValue;
    struct
    {
        uint8_t ucCEScanBehavior        :2; // Indicates scan behavior of CE mode
        uint8_t ucITScanBehavior        :2; // Indicates scan behavior of IT mode
        uint8_t ucPTScanBehavior        :2; // Indicates scan behavior of Preferred mode
        uint8_t ucQuantRangeSelectable  :1; // Indicates if RGB Quantization Range can be overridden
        uint8_t ucReserved              :1;
    };
} video_cap_data_block_t;

////////////////////////////////////////////
//
//CEA Extn Block Byte3 structure
//
////////////////////////////////////////////
typedef union _cea_ext_capability {
    uint8_t ucValue;
    struct
    {
        uint8_t ucTotalNativeDTDs     :4; // Total number of DTDs in extension block
        uint8_t ucSupportsYCBCR422    :1; // Indicates support for YCBCR 4:2:2
        uint8_t ucSupportsYCBCR444    :1; // Indicates support for YCBCR 4:4:4
        uint8_t ucSupportsBasicAudio  :1; // Indicates support for Basic audio
        uint8_t ucUnderscansITFormats :1; // Indicates underscan behavior of IT formats
    };
} cea_ext_capability_t;

////////////////////////////////////////////
//
//CE - Video Capability Data block structure
//
////////////////////////////////////////////
typedef enum {
    FORMAT_NOT_SUPPORTED        = 0, // Format is not supported
    ALWAYS_OVERSCANNED          = 1, // Format is always overscanned
    ALWAYS_UNDERSCANNED         = 2, // Format is always underscanned
    SUPPORTS_OVER_AND_UNDERSCAN = 3  // Sink supports both overscan and underscan
} cea_scan_behavior_t;


/////////////////////////////////
//
// #defines required for CE Etxn
//
/////////////////////////////////
#define CEA_EXT_TAG 0x02
#define CEA_EXT_SUPPORTED_VERSION 0x03
#define CEA_EXT_861_REVISION 0x01

#define CEA_USE_EXTENDED_TAG   0x7

#define CEA_AUDIO_DATABLOCK         0x1
#define CEA_VIDEO_DATABLOCK         0x2
#define CEA_VENDOR_DATABLOCK        0x3
#define CEA_SPEAKER_DATABLOCK       0x4
#define CEA_VIDEO_CAP_DATABLOCK     0x0

#define CEA_DATABLOCK_TAG_MASK                  0xE0
#define CEA_DATABLOCK_LENGTH_MASK               0x1F
#define CEA_SHORT_VIDEO_DESCRIPTOR_CODE_MASK    0x7F
#define CEA_NATIVE_FORMAT_BIT_MASK              0x80

#define CEA_HDMI_IEEE_REG_ID    0x00000C03
#define CEA_EDID_HEADER_SZIE    0x04

// Extended Data block type
// This bit definitions are as per CE 861-D spec
#define CEA_COLORIMETRY_DATABLOCK   0x5
    #define CE_COLORIMETRY_MD0_MASK BIT0     
    #define CE_COLORIMETRY_MD1_MASK BIT1
    #define CE_COLORIMETRY_MD2_MASK BIT3
#if 0
//==================================================================================
//==================================================================================
//	DATA Structure definitions for VTB parsing.....
//  Reference VESA Documents are VTB Extension(Release A) & CVT standard version 1.1
//===================================================================================
//	#defines for VTB-EXT
//===================================================================================

#define VTB_EXT_TAG	0x10
#define	VTB_EXT_SUPPORTED_VERSION 0x03

#define	VTB_MAX_DTD_TIMINGS			 6
#define	VTB_MAX_CVT_TIMINGS			40
#define	VTB_MAX_STANDARD_TIMINGS	61

#define VTB_DTD_OFFSET		5
#define VTB_DTD_SIZE		18
#define	VTB_CVT_SIZE		3
#define VTB_ST_SIZE			2

// This struct is for VTB Extension block.
typedef struct _VTB_EXT
{
	uint8_t	ucTag;
	uint8_t	ucVersion;
	uint8_t	ulNumDTD;
	uint8_t	ulNumCVT;
	uint8_t	ulNumST;
	uint8_t	DATA[122];
	uint8_t	ucChecksum;
}VTB_EXT, *PVTB_EXT;

// Following struct is for CVT descriptor (Version 1.1)
typedef struct _VTB_CVT_TIMING 
{
#pragma pack(1)	

	uint8_t	ucVA_low;		// Lower 8 bits of Vertical size. This Vsize = (vertical active lines/2)-1. 
							//	Range for VA lines is 2 to 8192. CVT supprts only an even no. of active lines per frame.
	
	union {					
		uint8_t	ucVA_high_AR;
		struct {
		
			uint8_t	ucReserved00	:2;		//Bits 1-0 are reserved and set to 00h
			uint8_t	ucAspectRatio	:2;		//	Aspect Ratio specifier bits.
											// 00:	 4:3 Aspect ratio
											// 01:	16:9 Aspect ratio
											// 10:	16:10 Aspect ratio
											// 11: Undefined (Reserved)
			
			
			uint8_t	ucVA_high	:4;			//	Upper 4 bits of Vertical Size.
		};
	};

	union {
		uint8_t	ucRefresh_Rate_Bits;
		struct	{
			
			uint8_t	ucRR_60Hz_RB	:1;		// When set, indicates 60Hz support with Reduced Blanking.
			uint8_t	ucRR_85Hz	:1;			//				||	   85Hz				||												.
			uint8_t	ucRR_75Hz	:1;			//				||	   75Hz				||												.
			uint8_t	ucRR_60Hz	:1;			//				||	   60Hz				||												.
			uint8_t	ucRR_50Hz	:1;			// When set, indicates 50Hz Refrash Rate with CRT Blanking supports specified pixel format.
			uint8_t	ucPreferredRefresh_Rate	:2;		// Preferred Refresh Rate specifier bits.
											// 00:	50 Hz
											// 01:	60 Hz (this means either CRT blanking or Reduced Blanking whichever is supported. 
											//				If both are supported, then RB is preferred.)
											// 10:	75 Hz
											// 11:	85 Hz	
			
			uint8_t	ucReserved0	:1;			// This bit is reserved and set to '0'.
			
		};
	};
#pragma	pack()
} VTB_CVT_TIMING, *PVTB_CVT_TIMING;


// This struct is for storing extracted Info from CVT descriptor....
// This is defined by author.....not based on CVT specs.
typedef struct _CVT_INFO		
{
	ULONG ulYRes;
	ULONG ulXRes;
	ULONG ulRRate[5];			//As max 5 Refresh Rates can be supported.
	BOOLEAN bRed_Blank_Req[5];
	BOOLEAN bPreferred_RR[5];   //To set flag for Preffered RR
	ULONG ulNumRates;			//Number of Refresh rates Supported. (Max. 5)
} CVT_INFO, *PCVT_INFO;
#endif 
// This structure is for stroing the Display device Data retreived from CEA block
// This is defined as per the Display Device Data Block standard.
typedef struct _display_device_data {
#pragma pack (1)
	union 
	{
		uint8_t ucTagAndLength; // Data Block Tag and Block Length. should be 0xFF
		struct
		{
			uint8_t ucLength : 5;
			uint8_t ucTag : 3;
		};
	};
	uint8_t ucChildTag; // Child tag required as per CEA spec  should be 0x02
	union
	{
		uint8_t ucInterfaceType;
		struct
		{
			uint8_t ucNumOfChannels : 4;// Number of channels supported
			uint8_t ucInterfaceCode : 4;// Interface code 
		};
	};
	union
	{
		uint8_t ucVerAndRel;
		struct
		{
			uint8_t ucRelease : 4;// Release 
			uint8_t ucVersion : 4;// Version.
		};
	};
	uint8_t ucContentProtectionSuppFlag;// Flag indicating support for content protection. 
	union
	{
		uint16_t usClockFrequency;// Clock Frequency
		struct
		{
			uint16_t usMinClockFrequency : 6; // First 6 bits indicates Min frequency
			uint16_t usMaxClockFrequency : 10;// Next 10 bits indicates Max frequency
		};
	};
	union
	{
		uint8_t ucNativePixelFormat[4];// Pixel Format
		struct
		{
			uint8_t ucHorizontalPixelCntLower;// Lower byte value of the Horizontal pixel count
			uint8_t ucHorizontalPixelCntUpper;// Upper byte value of the Horizontal pixel count
			uint8_t ucVerticalPixelCntLower;//  Lower byte value of the vertical pixel count
			uint8_t ucVerticalPixelCntUpper; // Upper byte value of the vertical pixel count
		};
	};
	uint8_t ucAspectRatio;// Byte indicating Aspect ratio. 
	union 
	{
		uint8_t ucOrientationAndRotation;
		struct
		{
			uint8_t ucScanDirection : 2;// Scan direction.
			uint8_t ucZeroPixelLocation : 2;// Zero Pixel Location.
			uint8_t ucRotationCapability : 2;// Indicates rotation capability
			uint8_t ucDefaultOrientation : 2;// Default Orientation.
		};
	};
	uint8_t ucSubPixelInfo;// Sub-Pixle Information.
	uint8_t ucHorizontalPitch;// Horizontal Pitch
	uint8_t ucVerticalPitch;// Vertical Pitch
	union
	{
		uint8_t ucMiscDisplayCapabilities;
		struct
		{
			uint8_t bReserved : 3;
			uint8_t ucDeinterlacing : 1;// indicates deinterlacing support
			uint8_t ucOverdriverNotRecommended : 1;
			uint8_t ucDirectDrive : 1;// indicates DirectDrive support
			uint8_t ucDithering : 2;// indicates Dithering support.
		};
	};
	union
	{
		uint8_t ucAudioFlags;// Flags indicating Audio details
		struct
		{
			uint8_t bReserved1 : 4;
			uint8_t ucAudioInputOverride : 1;// Indicates Audio Input Override
			uint8_t ucSeparateAudioInputs : 1;// Indicates Separate Audio Inputs
			uint8_t ucAudioInputOnVideoInterface : 1;// Shows whether Audio input is through the video interface.
		};
	};
	union
	{
		uint8_t ucAudioDelayFlags; // Audio Delay Flags
		struct
		{
			uint8_t ucAudioDelay : 7;// Absolute offset between the audio and video signals.
			uint8_t ucAudioSign : 1;// Indicates positive or negative delay.
		};
	};
	union
	{
		uint8_t ucFrameRateAndModeConversion;
		struct
		{
			uint8_t ucFrameRateRange : 6;//Device Frame rate Range
			uint8_t ucFrameRateConversion : 2;//00 � No dedicated rate conversion hardware is provided;
											//01 � The display provides a single frame buffer
											//10 � The display provides double-buffering
											//11- The display provides frame-rate conversion involving interframe interpolation
		};
	};
	uint8_t ucDeviceNativeRate;// Device Native Frame rate
	union
	{
		uint8_t ucColorBitDepth;// Color bit depth
		struct
		{
			uint8_t ucDisplayDeviceColBitDepth : 4; // Color bit depth of the display device
			uint8_t ucInterfaceColBitDepth : 4;// color bit depth supported by the interface.h
		};
	};
	uint8_t ucAddPrimaryChromaticities[8];// Additional Primary Chromaticities.
	union
	{
		uint8_t ucResponseTimeFlags;
		struct
		{
			uint8_t ucResponseTime : 7;// Time for transition.
			uint8_t ucBlackToWhite : 1;// if 1, then transition from black to white
									// if 0, then transition from white to black
		};
	};
	union
	{
		uint8_t ucOverscanInformation;
		struct
		{
			uint8_t ucVerticalPercentage : 4;// Percentage of Overscan in vertical direction.
			uint8_t ucHorizontalPercentage : 4;// Percentage of Overscan in horizontal direction.
		};
	};
#pragma pack()
} display_device_data_t;

//=========================================================================
//=========================================================================
// #defines for Block Map Ext.
//=========================================================================
//=========================================================================
#define BLOCK_MAP_EXT_TAG 0xF0

#endif // EDIDSTRUCTS_H