Skip to content

Commit 99566c7

Browse files
committed
Implement edid.S as edid.h and edid-private.h
Signed-off-by: Mubashshir <ahmubashshir@gmail.com>
1 parent 476a016 commit 99566c7

2 files changed

Lines changed: 465 additions & 0 deletions

File tree

edid-private.h

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
/*
2+
edid-private.h: EDID data template
3+
4+
Copyright (C) 2012 Carsten Emde <C.Emde@osadl.org>
5+
Copyright (C) 2023 Mubashshir <ahmubashshir@gmail.com>
6+
7+
This program is free software; you can redistribute it and/or
8+
modify it under the terms of the GNU General Public License
9+
as published by the Free Software Foundation; either version 2
10+
of the License, or (at your option) any later version.
11+
12+
This program is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with this program; if not, write to the Free Software
19+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*/
21+
22+
23+
#ifndef __EDID_PRIVATE_H__
24+
#define __EDID_PRIVATE_H__
25+
edid_start: .data
26+
/* Fixed header pattern */
27+
header: .byte 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00
28+
29+
#define __swap16(v1) ((v1>>8)+((v1&0xff)<<8))
30+
#define __msbs2(v1,v2) ((((v1>>8)&0x0f)<<4)+((v2>>8)&0x0f))
31+
#define __msbs4(v1,v2,v3,v4) \
32+
(((v1&0x03)>>2)+((v2&0x03)>>4)+((v3&0x03)>>6)+((v4&0x03)>>8))
33+
#define __pixdpi2mm(pix,dpi) ((pix*25)/dpi)
34+
#define __count_impl(X) X
35+
#define __count(X) __count_impl(X)
36+
#define count() __count(__COUNTER__)
37+
#define PROCESS(NAME, ...) ___COUNT(count(), NAME, ## __VA_ARGS__)
38+
#define ___COUNT(num, NAME, ...) __IMPL_ ## NAME(num, ## __VA_ARGS__)
39+
#define __label(pref, mid, suff) pref ## mid ## suff:
40+
#define __required_symbol(section) .ifndef section; .err; .endif
41+
42+
43+
#define __IMPL_BEGIN(num, \
44+
VER, REV, \
45+
M, F, G, \
46+
YEAR, WEEK, \
47+
PROD, SERIAL \
48+
)\
49+
mfg_id: .hword __swap16(((((M-'@')&0x1f)<<10)+(((F-'@')&0x1f)<<5)+((G-'@')&0x1f))); \
50+
prod_code: .hword PROD; \
51+
serial_number: .long SERIAL; \
52+
week: .byte WEEK; \
53+
year: .byte YEAR-1990; \
54+
.if VER != 1; .err; .endif; \
55+
version: .byte VER; \
56+
.if REV < 0 || REV > 4; .err; .endif; \
57+
revision: .byte REV
58+
59+
60+
#define __VIDEO_DIGITAL(X) 0b10000000 | X
61+
#define __VIDEO_ANALOG(X) 0b00000000 | X
62+
#define __IMPL_VIDEO(num, TYPE, MODE) \
63+
video_parms: .byte __VIDEO_##TYPE(MODE)
64+
65+
#define __IMPL_MAX_SIZE(num, X, Y, DPI) \
66+
max_size: .byte (__pixdpi2mm(X, DPI)/10) , (__pixdpi2mm(Y, DPI)/10)
67+
68+
#define __IMPL_GAMMA(num, X) \
69+
gamma: .byte X
70+
71+
#define __IMPL_DSP(num, X) \
72+
dsp_features: .byte X
73+
74+
#define __IMPL_LSB(num, color_pair, v1x, v1y, v2x, v2y) \
75+
color_pair ## _lsb: .byte \
76+
((v1x & 0b11)<<6) \
77+
| ((v1y & 0b11)<<4) \
78+
| ((v2x & 0b11)<<2) \
79+
| ((v2y & 0b11)<<0)
80+
81+
#define __IMPL_MSB(num, color, x, y) \
82+
color ## _x_y_msb: .byte x, y
83+
84+
#define __IMPL_EST_TIMING(num, B7, B6, B5, B4, B3, B2, B1, B0) \
85+
etimings_##num: .byte \
86+
(B7<<7) | \
87+
(B6<<6) | \
88+
(B5<<5) | \
89+
(B4<<4) | \
90+
(B3<<3) | \
91+
(B2<<2) | \
92+
(B1<<1) | \
93+
(B0<<0)
94+
95+
#define __IMPL_STD_RES(num, type, ...) \
96+
std_res_ ## num: __STD_RES_##type(num, ## __VA_ARGS__)
97+
98+
#define __STD_RES_PAD(num)\
99+
.fill 1,2,0x0101
100+
101+
/* Standard timing */
102+
/* X resolution, less 31, divided by 8 (256-2288 pixels) */
103+
/* Y resolution, X:Y pixel ratio
104+
Bits 7-6 X:Y pixel ratio: 00=16:10; 01=4:3; 10=5:4; 11=16:9.
105+
Bits 5-0 Vertical frequency, less 60 (60-123 Hz) */
106+
#define __STD_RES_RATIO(num, X, RATIO, FREQ)\
107+
.byte (X/8)-31, (RATIO<<6)+FREQ-60
108+
109+
#define __IMPL_DSC(num, type, ...) \
110+
dsc ## num: __DSC_##type(num, ## __VA_ARGS__)
111+
112+
#define __DSC_DUMMY(num) \
113+
.byte 0, 0, 0, 0x10; \
114+
.fill 12,1,0x01; \
115+
.byte 0x0a, 0x20
116+
117+
#define __DSC_DTD(num, CLK, DPI, FEATURES, \
118+
XPIX, YPIX, \
119+
XOFFSET, YOFFSET, \
120+
XPULSE, YPULSE, \
121+
XBLANK, YBLANK, \
122+
XBORDER, YBORDER) \
123+
/* Pixel clock in 10 kHz units. (0.-655.35 MHz, little-endian) */ \
124+
.hword CLK/10; \
125+
/* Horizontal active pixels 8 lsbits (0-4095) */ \
126+
.byte XPIX&0xff; \
127+
/* Horizontal blanking pixels 8 lsbits (0-4095)
128+
End of active to start of next active. */ \
129+
.byte XBLANK&0xff; \
130+
/* Bits 7-4 Horizontal active pixels 4 msbits
131+
Bits 3-0 Horizontal blanking pixels 4 msbits */ \
132+
.byte __msbs2(XPIX,XBLANK); \
133+
/* Vertical active lines 8 lsbits (0-4095) */ \
134+
.byte YPIX&0xff; \
135+
/* Vertical blanking lines 8 lsbits (0-4095) */ \
136+
.byte YBLANK&0xff; \
137+
/* Bits 7-4 Vertical active lines 4 msbits
138+
Bits 3-0 Vertical blanking lines 4 msbits */ \
139+
.byte __msbs2(YPIX,YBLANK); \
140+
/* Horizontal sync offset pixels 8 lsbits (0-1023) From blanking start */\
141+
.byte XOFFSET&0xff; \
142+
/* Horizontal sync pulse width pixels 8 lsbits (0-1023) */ \
143+
.byte XPULSE&0xff; \
144+
/* Bits 7-4 Vertical sync offset lines 4 lsbits -63)
145+
Bits 3-0 Vertical sync pulse width lines 4 lsbits -63) */ \
146+
.byte ((YOFFSET-63)<<4)+(YPULSE-63); \
147+
/* Bits 7-6 Horizontal sync offset pixels 2 msbits
148+
Bits 5-4 Horizontal sync pulse width pixels 2 msbits
149+
Bits 3-2 Vertical sync offset lines 2 msbits
150+
Bits 1-0 Vertical sync pulse width lines 2 msbits */ \
151+
.byte __msbs4(XOFFSET,XPULSE,YOFFSET,YPULSE); \
152+
/* Horizontal display size, mm, 8 lsbits (0-4095 mm, 161 in) */ \
153+
.byte __pixdpi2mm(XPIX, DPI)&0xff; \
154+
/* Vertical display size, mm, 8 lsbits (0-4095 mm, 161 in) */\
155+
.byte __pixdpi2mm(YPIX, DPI)&0xff; \
156+
/* Bits 7-4 Horizontal display size, mm, 4 msbits
157+
Bits 3-0 Vertical display size, mm, 4 msbits */ \
158+
.byte __msbs2(__pixdpi2mm(XPIX, DPI),__pixdpi2mm(YPIX, DPI)); \
159+
/* Horizontal border pixels (each side; total is twice this) */ \
160+
.byte XBORDER; \
161+
/* Vertical border lines (each side; total is twice this) */ \
162+
.byte YBORDER; \
163+
/* Bit 7 Interlaced
164+
Bits 6-5 Stereo mode: 00=No stereo; other values depend on bit 0:
165+
Bit 0=0: 01=Field sequential, sync=1 during right; 10=similar,
166+
sync=1 during left; 11=4-way interleaved stereo
167+
Bit 0=1 2-way interleaved stereo: 01=Right image on even lines;
168+
10=Left image on even lines; 11=side-by-side
169+
Bits 4-3 Sync type: 00=Analog composite; 01=Bipolar analog composite;
170+
10=Digital composite (on HSync); 11=Digital separate
171+
Bit 2 If digital separate: Vertical sync polarity (1=positive)
172+
Other types: VSync serrated (HSync during VSync)
173+
Bit 1 If analog sync: Sync on all 3 RGB lines (else green only)
174+
Digital: HSync polarity (1=positive)
175+
Bit 0 2-way line-interleaved stereo, if bits 4-3 are not 00. */ \
176+
.byte FEATURES
177+
178+
#define __DSC_ALNUM(num, data) \
179+
.byte 0,0; /* Not a detailed timing descriptor */ \
180+
.byte 0; /* Must be zero */\
181+
.byte 0xfe;/* Descriptor is monitor range limits */\
182+
.byte 0; /* Must be zero */\
183+
dsc##num##_start:\
184+
.ascii data; \
185+
dsc##num##_end:\
186+
.byte 0x0a; /* End marker */\
187+
.fill 12-((dsc##num##_end)-(dsc##num##_start)), 1, 0x20 /* Padded spaces */
188+
189+
#define __DSC_RAW(num, type, data) \
190+
.byte 0,0; /* Not a detailed timing descriptor */ \
191+
.byte 0; /* Must be zero */\
192+
.byte type;/* Descriptor is monitor range limits */\
193+
.byte 0; /* Must be zero */\
194+
dsc##num##_start:\
195+
data; \
196+
dsc##num##_end:\
197+
.byte 0x0a; /* End marker */\
198+
.fill 12-((dsc##num##_end)-(dsc##num##_start)), 1, 0x20 /* Padded spaces */
199+
200+
#define __IMPL_EXTENSIONS(num, x) \
201+
extensions: .byte x /* Number of extensions to follow */
202+
203+
#define __IMPL_END(num) \
204+
checksum: .byte CRC /* Sum of all bytes must be 0 (mod 256) */
205+
206+
#define __required_section_count(num, req) \
207+
.if num != req; \
208+
.err; \
209+
.endif;
210+
#endif /* __EDID_PRIVATE_H__ */

0 commit comments

Comments
 (0)