// File: /workspace/github_cpp_makefile_star2_O2/rpavlik[P]edid-decode/parse-di-ext-block.cpp
// Function: edid_state::parse_digital_interface(unsigned char const*)
void edid_state::parse_digital_interface(const unsigned char *x)
{
	data_block = "Digital Interface";
	printf("  %s:\n", data_block.c_str());

	printf("    Supported Digital Interface: ");
	unsigned short v = x[2];
	switch (v) {
	case 0x00:
		printf("Analog Video Input\n");
		if (!memchk(x + 2, 12))
			fail("Bytes 0x02-0x0d should be 0.\n");
		return;
	case 0x01: printf("DVI\n"); break;
	case 0x02: printf("DVI Single Link\n"); break;
	case 0x03: printf("DVI Dual Link - High Resolution\n"); break;
	case 0x04: printf("DVI Dual Link - High Color\n"); break;
	case 0x05: printf("DVI - Consumer Electronics\n"); break;
	case 0x06: printf("Plug & Display\n"); break;
	case 0x07: printf("DFP\n"); break;
	case 0x08: printf("Open LDI - Single Link\n"); break;
	case 0x09: printf("Open LDI - Dual Link\n"); break;
	case 0x0a: printf("Open LDI - Consumer Electronics\n"); break;
	default:
		   printf("Unknown (0x%02x)\n", v);
		   fail("Unknown Digital Interface 0x%02x.\n", v);
		   break;
	}

	switch ((x[3]) >> 6) {
	case 0x00:
		if (!memchk(x + 3, 4))
			fail("Bytes 0x03-0x06 should be 0.\n");
		break;
	case 0x01:
		printf("    Version: %u.%u\n    Release: %u.%u\n", x[3] & 0x3f, x[4], x[5], x[6]);
		if (x[4] > 99)
			fail("Version number > 99.\n");
		if (x[6] > 99)
			fail("Release number > 99.\n");
		break;
	case 0x02:
		if (x[3] & 0x3f)
			fail("Bits 5-0 of byte 0x03 should be 0.\n");
		if (x[5] || x[6])
			fail("Bytes 0x05-0x06 should be 0.\n");
		printf("    Letter Designation: %c\n", x[4]);
		break;
	case 0x03:
		if (x[3] & 0x3f)
			fail("Bits 5-0 of byte 0x03 should be 0.\n");
		printf("    Date Code: Year %u Week %u Day %u\n", 1990 + x[4], x[5], x[6]);
		if (!x[5] || x[5] > 12)
			fail("Bad month number.\n");
		if (!x[6] || x[6] > 31)
			fail("Bad day number.\n");
		break;
	}

	v = x[7];
	printf("    Data Enable Signal Usage %sAvailable\n",
	       (v & 0x80) ? "" : "Not ");
	if (v & 0x80)
		printf("    Data Enable Signal %s\n",
		       (v & 0x40) ? "High" : "Low");
	else if (v & 0x40)
		fail("Bit 6 of byte 0x07 should be 0.\n");
	printf("    Edge of Shift Clock: ");
	switch ((v >> 4) & 0x03) {
	case 0: printf("Not specified\n"); break;
	case 1: printf("Use rising edge of shift clock\n"); break;
	case 2: printf("Use falling edge of shift clock\n"); break;
	case 3: printf("Use both edges of shift clock\n"); break;
	}
	printf("    HDCP is %ssupported\n", (v & 0x08) ? "" : "not ");
	printf("    Digital Receivers %ssupport Double Clocking of Input Data\n",
	       (v & 0x04) ? "" : "do not ");
	printf("    Packetized Digital Video is %ssupported\n", (v & 0x02) ? "" : "not ");
	if (v & 0x01)
		fail("Bit 0 of byte 0x07 should be 0.\n");

	v = x[8];
	printf("    Data Formats: ");
	switch (v) {
	case 0x15: printf("8-Bit Over 8-Bit RGB\n"); break;
	case 0x19: printf("12-Bit Over 12-Bit RGB\n"); break;
	case 0x24: printf("24-Bit MSB-Aligned RGB (Single Link)\n"); break;
	case 0x48: printf("48-Bit MSB-Aligned RGB (Dual Link - High Resolution)\n"); break;
	case 0x49: printf("48-Bit MSB-Aligned RGB (Dual Link - High Color)\n"); break;
	default:
		   printf("Unknown (0x%02x)\n", v);
		   fail("Unknown Data Format 0x%02x.\n", v);
		   break;
	}
	if (x[2] == 0x03 && v != 0x48)
		fail("Data Format should be 0x48, not 0x%02x.\n", v);
	if (x[2] == 0x04 && v != 0x49)
		fail("Data Format should be 0x49, not 0x%02x.\n", v);

	v = x[9];
	if (v) {
		printf("    Minimum Pixel Clock Frequency Per Link: %u MHz\n", v);
		if (v == 0xff)
			fail("Invalid Min-PCF 0x%02x.\n", v);
	}

	v = x[10] | (x[11] << 8);
	if (v) {
		printf("    Maximum Pixel Clock Frequency Per Link: %u MHz\n", v);
		if (v == 0xffff)
			fail("Invalid Max-PCF 0x%04x.\n", v);
	}

	v = x[12] | (x[13] << 8);
	if (v == 0xffff)
		printf("    Crossover Frequency: None - Single Link\n");
	else if (v)
		printf("    Crossover Frequency: %u MHz\n", v);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
addq $0x30, %rdi
leaq 0x137e6(%rip), %rsi     # 0x2b38e
callq 0x3460
movq 0x30(%r14), %rsi
leaq 0x7253(%rip), %rdi      # 0x1ee0b
xorl %eax, %eax
callq 0x3030
leaq 0x13f76(%rip), %rdi     # 0x2bb3c
xorl %eax, %eax
callq 0x3030
leaq 0x2(%rbx), %r14
movzbl 0x2(%rbx), %r15d
cmpq $0xa, %r15
ja 0x17dc9
leaq 0x13df9(%rip), %rax     # 0x2b9e0
movslq (%rax,%r15,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x1511b(%rip), %rdi     # 0x2cd12
callq 0x33b0
pushq $0xc
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x4fa5
testb %al, %al
jne 0x1817c
leaq 0x13f46(%rip), %rsi     # 0x2bb5e
xorl %edi, %edi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x362c
leaq 0x1508d(%rip), %rdi     # 0x2ccc3
callq 0x33b0
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13dbd(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1500a(%rip), %rdi     # 0x2cc69
callq 0x33b0
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13d94(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15076(%rip), %rdi     # 0x2ccfe
callq 0x33b0
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13d6b(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1502d(%rip), %rdi     # 0x2ccde
callq 0x33b0
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13d42(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x14fbb(%rip), %rdi     # 0x2cc95
callq 0x33b0
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13d19(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1500b(%rip), %rdi     # 0x2cd0e
callq 0x33b0
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13cf0(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x14f7c(%rip), %rdi     # 0x2cca8
callq 0x33b0
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13cc7(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x14f44(%rip), %rdi     # 0x2cc99
callq 0x33b0
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13c9e(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x14ecb(%rip), %rdi     # 0x2cc49
callq 0x33b0
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13c75(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x14ed7(%rip), %rdi     # 0x2cc7e
callq 0x33b0
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13c4c(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x713c(%rip), %rdi      # 0x1ef0c
movl %r15d, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x13d9b(%rip), %rsi     # 0x2bb7c
xorl %edi, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x362c
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13c0b(%rip), %rcx     # 0x2ba0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x4
popq %rsi
xorl %edx, %edx
callq 0x4fa5
testb %al, %al
jne 0x17f1c
leaq 0x13d7c(%rip), %rsi     # 0x2bb9f
jmp 0x17f13
testb $0x3f, %sil
je 0x17e3e
leaq 0x13ddb(%rip), %rsi     # 0x2bc10
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
cmpb $0x0, 0x5(%rbx)
jne 0x17e4a
cmpb $0x0, 0x6(%rbx)
je 0x17e5a
leaq 0x13de3(%rip), %rsi     # 0x2bc34
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
movzbl 0x4(%rbx), %esi
leaq 0x13ded(%rip), %rdi     # 0x2bc52
xorl %eax, %eax
callq 0x3030
jmp 0x17f1c
testb $0x3f, %sil
je 0x17e87
leaq 0x13d92(%rip), %rsi     # 0x2bc10
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
movzbl 0x4(%rbx), %esi
addl $0x7c6, %esi            # imm = 0x7C6
movzbl 0x5(%rbx), %edx
movzbl 0x6(%rbx), %ecx
leaq 0x13dce(%rip), %rdi     # 0x2bc6e
xorl %eax, %eax
callq 0x3030
movb 0x5(%rbx), %al
addb $-0xd, %al
cmpb $-0xd, %al
ja 0x17ec0
leaq 0x13dde(%rip), %rsi     # 0x2bc95
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
movb 0x6(%rbx), %al
addb $-0x20, %al
cmpb $-0x20, %al
ja 0x17f1c
leaq 0x13dd8(%rip), %rsi     # 0x2bca8
jmp 0x17f13
andl $0x3f, %esi
movzbl 0x4(%rbx), %edx
movzbl 0x5(%rbx), %ecx
movzbl 0x6(%rbx), %r8d
leaq 0x13cd4(%rip), %rdi     # 0x2bbbd
xorl %eax, %eax
callq 0x3030
cmpb $0x64, 0x4(%rbx)
jb 0x17f06
leaq 0x13ce7(%rip), %rsi     # 0x2bbe4
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
cmpb $0x64, 0x6(%rbx)
jb 0x17f1c
leaq 0x13ce7(%rip), %rsi     # 0x2bbfa
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
movzbl 0x7(%rbx), %r12d
testb %r12b, %r12b
leaq 0x79fe(%rip), %rsi      # 0x1f929
leaq 0x2d57(%rip), %r15      # 0x1ac89
cmovsq %r15, %rsi
leaq 0x13d7c(%rip), %rdi     # 0x2bcb9
xorl %eax, %eax
callq 0x3030
testb %r12b, %r12b
js 0x17f61
cmpb $0x40, %r12b
jb 0x17f85
leaq 0x13da8(%rip), %rsi     # 0x2bcfe
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
jmp 0x17f85
testb $0x40, %r12b
leaq 0x115bd(%rip), %rax     # 0x29529
leaq 0x115ba(%rip), %rsi     # 0x2952d
cmoveq %rax, %rsi
leaq 0x13d65(%rip), %rdi     # 0x2bce3
xorl %eax, %eax
callq 0x3030
leaq 0x13d93(%rip), %rdi     # 0x2bd1f
xorl %eax, %eax
callq 0x3030
movl %r12d, %eax
shrl $0x2, %eax
andl $0xc, %eax
leaq 0x13b39(%rip), %rcx     # 0x2badc
movslq (%rax,%rcx), %rdi
addq %rcx, %rdi
callq 0x33b0
testb $0x8, %r12b
leaq 0x13dda(%rip), %r13     # 0x2bd94
movq %r15, %rsi
cmoveq %r13, %rsi
leaq 0x13d71(%rip), %rdi     # 0x2bd39
xorl %eax, %eax
callq 0x3030
testb $0x4, %r12b
leaq 0x13db7(%rip), %rsi     # 0x2bd91
cmovneq %r15, %rsi
leaq 0x13d6d(%rip), %rdi     # 0x2bd52
xorl %eax, %eax
callq 0x3030
testb $0x2, %r12b
cmoveq %r13, %r15
leaq 0x13d9e(%rip), %rdi     # 0x2bd99
movq %r15, %rsi
xorl %eax, %eax
callq 0x3030
testb $0x1, %r12b
je 0x1801b
leaq 0x13db4(%rip), %rsi     # 0x2bdc6
xorl %edi, %edi
xorl %eax, %eax
callq 0x362c
movzbl 0x8(%rbx), %ebp
leaq 0x13dc1(%rip), %rdi     # 0x2bde7
xorl %eax, %eax
callq 0x3030
cmpl $0x49, %ebp
je 0x1808e
cmpl $0x19, %ebp
je 0x1804f
cmpl $0x24, %ebp
je 0x18061
cmpl $0x48, %ebp
je 0x18058
cmpl $0x15, %ebp
jne 0x1806a
leaq 0x14dd6(%rip), %rdi     # 0x2ce23
jmp 0x18095
leaq 0x14db6(%rip), %rdi     # 0x2ce0c
jmp 0x18095
leaq 0x14d53(%rip), %rdi     # 0x2cdb2
jmp 0x18095
leaq 0x14d7f(%rip), %rdi     # 0x2cde7
jmp 0x18095
leaq 0x6e9b(%rip), %rdi      # 0x1ef0c
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x13d79(%rip), %rsi     # 0x2bdfa
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x362c
jmp 0x1809a
leaq 0x14ced(%rip), %rdi     # 0x2cd82
callq 0x33b0
movb (%r14), %al
cmpb $0x3, %al
sete %cl
cmpb $0x48, %bpl
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x180c5
leaq 0x13d60(%rip), %rsi     # 0x2be17
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x362c
movb (%r14), %al
cmpb $0x4, %al
sete %al
cmpb $0x49, %bpl
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x180ea
leaq 0x13d61(%rip), %rsi     # 0x2be40
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x362c
movzbl 0x9(%rbx), %ebp
testl %ebp, %ebp
je 0x1811f
leaq 0x13d70(%rip), %rdi     # 0x2be69
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
cmpl $0xff, %ebp
jne 0x1811f
leaq 0x13d8c(%rip), %rsi     # 0x2be9d
xorl %edi, %edi
movl $0xff, %edx
xorl %eax, %eax
callq 0x362c
movzwl 0xa(%rbx), %ebp
testl %ebp, %ebp
je 0x18152
leaq 0x13d88(%rip), %rdi     # 0x2beb6
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
cmpw $-0x1, %bp
jne 0x18152
leaq 0x13da6(%rip), %rsi     # 0x2beea
xorl %edi, %edi
movl $0xffff, %edx           # imm = 0xFFFF
xorl %eax, %eax
callq 0x362c
movzwl 0xc(%rbx), %esi
testl %esi, %esi
je 0x1817c
cmpl $0xffff, %esi           # imm = 0xFFFF
jne 0x1818b
leaq 0x14ccf(%rip), %rdi     # 0x2ce38
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x33b0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13d71(%rip), %rdi     # 0x2bf03
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3030
nop