Skip to content

Commit 5aba21c

Browse files
authored
Merge pull request #601 from Strykar/main
drivers/video: Improve IT66021 EDID definitions and add new DTDs
2 parents 7111274 + 2d8ed5a commit 5aba21c

1 file changed

Lines changed: 52 additions & 23 deletions

File tree

src/driver/it66021.c

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ int IT66021_Get_VTMG(int *freq_ref) {
232232
}
233233

234234
for (i = 0; i < IT66121_9A_READ_N; i++) {
235-
for (j = IT66121_9A_READ_N - 1; j >= i; j--) {
235+
for (j = IT66121_9A_READ_N - 2; j >= i; j--) {
236236
if (r9a[j] > r9a[j + 1]) {
237237
int temp = r9a[j];
238238
r9a[j] = r9a[j + 1];
@@ -307,34 +307,63 @@ void IT66021_Set_CSMatrix(int cs) {
307307
}
308308

309309
void IT66021_edid() {
310-
// 0x49->0xc4 must set same data with edid[0x7f]
311-
// 0x49->0xc5 must set same data with edid[0xff]
312-
const uint8_t edid[256] = {
313-
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x26, 0x85, 0x02, 0x66, 0x01, 0x68, 0x00, 0x00,
314-
0x00, 0x17, 0x01, 0x03, 0x80, 0x73, 0x41, 0x78, 0x2A, 0x7C, 0x11, 0x9E, 0x59, 0x47, 0x9B, 0x27,
315-
0x10, 0x50, 0x54, 0x00, 0x00, 0x00, 0x81, 0xC0, 0x81, 0xE8, 0xD1, 0xC0, 0x01, 0x01, 0x01, 0x01,
316-
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3A, 0x80, 0xD0, 0x72, 0x38, 0x2D, 0x40, 0x58, 0x2C,
317-
0x45, 0x00, 0x10, 0x09, 0x00, 0x00, 0x00, 0x1E, 0x01, 0x1D, 0x00, 0x72, 0x51, 0xD0, 0x1E, 0x20,
318-
0x6E, 0x28, 0x55, 0x00, 0x10, 0x09, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x49,
319-
0x54, 0x45, 0x36, 0x38, 0x30, 0x32, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xFD,
320-
0x00, 0x30, 0x7A, 0x0F, 0x50, 0x10, 0x00, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x2C,
321-
0x02, 0x03, 0x17, 0x74, 0x44, 0x84, 0x9F, 0xA9, 0x90, 0x23, 0x09, 0x07, 0x07, 0x83, 0x01, 0x00,
322-
0x00, 0x65, 0x03, 0x0C, 0x00, 0x10, 0x00, 0x01, 0x1D, 0x00, 0x72, 0x51, 0xD0, 0x1E, 0x20, 0x6E,
323-
0x28, 0x55, 0x00, 0x10, 0x09, 0x00, 0x00, 0x00, 0x1E, 0x02, 0x3A, 0x80, 0xD0, 0x72, 0x38, 0x2D,
324-
0x40, 0x58, 0x2C, 0x45, 0x00, 0x10, 0x09, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00,
325-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
326-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
327-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
328-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDA};
310+
// Declared as static to prevent 256-byte stack allocation overhead
311+
static const uint8_t edid[256] = {
312+
/* ===== Base EDID block (0x00–0x7F) ===== */
313+
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
314+
0x26,0x85,0x02,0x66,0x01,0x68,0x00,0x00,
315+
0x00,0x17,0x01,0x03,0x80,0x73,0x41,0x78,
316+
0x2A,0x7C,0x11,0x9E,0x59,0x47,0x9B,0x27,
317+
0x10,0x50,0x54,0x00,0x00,0x00,0x81,0xC0,
318+
0x81,0xE8,0xD1,0xC0,0x01,0x01,0x01,0x01,
319+
0x01,0x01,0x01,0x01,0x01,0x01,
320+
/* DTD #1: 1920x1080 @ 60 Hz */
321+
0x02,0x3A,0x80,0xD0,0x72,0x38,0x2D,0x40,
322+
0x58,0x2C,0x45,0x00,0x10,0x09,0x00,0x00,
323+
0x00,0x1E,
324+
/* DTD #2: 1280x720 @ 60 Hz */
325+
0x01,0x1D,0x00,0x72,0x51,0xD0,0x1E,0x20,
326+
0x6E,0x28,0x55,0x00,0x10,0x09,0x00,0x00,
327+
0x00,0x18,
328+
/* Monitor name */
329+
0x00,0x00,0x00,0xFC,0x00,
330+
0x49,0x54,0x45,0x36,0x38,0x30,0x32,0x0A,
331+
0x20,0x20,0x20,0x20,0x20,
332+
/* Range limits */
333+
0x00,0x00,0x00,0xFD,0x00,
334+
0x30,0x7A,0x0F,0x50,0x10,0x00,0x0A,
335+
0x20,0x20,0x20,0x20,0x20,0x20,
336+
/* Extension count */
337+
0x01,
338+
/* Base EDID checksum (sum of bytes 0x00–0x7E == 0 mod 256) */
339+
/* Base EDID checksum explicitly pinned to byte 127 */
340+
[127] = 0x2C,
341+
/* ===== CEA Extension block (0x80–0xFF) ===== */
342+
/* CEA extension checksum (sum of bytes 0x80–0xFE == 0 mod 256) */
343+
/* C99 index 128 follows directly after 127 */
344+
0x02,0x03,0x17,0x74,
345+
0x44,0x84,0x9F,0xA9,0x90,0x23,0x09,0x07,
346+
0x07,0x83,0x01,0x00,
347+
0x00,0x65,0x03,0x0C,0x00,0x10,0x00,
348+
/* DTD #3: 1280x720 @ 50 Hz */
349+
0x29,0x1D,0x00,0x72,0x51,0xD0,0x1E,0x20,
350+
0x6E,0x28,0x55,0x00,0x10,0x09,0x00,0x00,
351+
0x00,0x1E,
352+
/* DTD #4: 960x720 @ 100 Hz (CVT-RB) */
353+
0x00,0x60,0x80,0x18,0x71,0x38,0x2D,0x40,
354+
0x58,0x2C,0x45,0x00,0x10,0x09,0x00,0x00,
355+
0x00,0x1E,
356+
/* C compiler automatically supplies 0x00 padding for the gap here */
357+
/* Extension checksum explicitly pinned to the final byte */
358+
[255] = 0x47
359+
};
329360
uint16_t i;
330361
I2C_L_Write(0x49, 0xc0, 0x40);
331362
I2C_L_Write(0x49, 0xc4, edid[0x7f]);
332363
I2C_L_Write(0x49, 0xc5, edid[0xff]);
333-
334364
for (i = 0; i < 256; i++) {
335365
I2C_L_Write(0x54, i, edid[i]);
336366
}
337-
338367
I2C_L_Write(0x49, 0xc0, 0x24);
339368
usleep(2000);
340369
I2C_L_Write(0x49, 0xc0, 0x04);
@@ -346,4 +375,4 @@ void IT66021_Set_Pclk(int inv, int dly) {
346375
I2C_L_Write(ADDR_IT66021, 0x50, 0xA0 + dly);
347376
else
348377
I2C_L_Write(ADDR_IT66021, 0x50, 0xB0 + dly);
349-
}
378+
}

0 commit comments

Comments
 (0)