// File: /workspace/github_cpp_makefile_star2_O3/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
movq 0x38(%r14), %rdx
leaq 0x13d2e(%rip), %rcx     # 0x3138e
movl $0x11, %r8d
xorl %esi, %esi
callq 0x3390
movq 0x30(%r14), %rsi
leaq 0x7793(%rip), %rdi      # 0x24e0b
xorl %eax, %eax
callq 0x3030
leaq 0x144b6(%rip), %rdi     # 0x31b3c
xorl %eax, %eax
callq 0x3030
leaq 0x2(%rbx), %r14
movzbl 0x2(%rbx), %r15d
cmpq $0xa, %r15
ja 0x1d88b
leaq 0x14339(%rip), %rax     # 0x319e0
movslq (%rax,%r15,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x1565b(%rip), %rdi     # 0x32d12
callq 0x3380
movq %r14, %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x5ba5
testb %al, %al
jne 0x1dc1d
leaq 0x14484(%rip), %rsi     # 0x31b5e
xorl %edi, %edi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37cc
leaq 0x155cb(%rip), %rdi     # 0x32cc3
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x142fb(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15548(%rip), %rdi     # 0x32c69
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x142d2(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x155b4(%rip), %rdi     # 0x32cfe
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x142a9(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1556b(%rip), %rdi     # 0x32cde
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x14280(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x154f9(%rip), %rdi     # 0x32c95
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x14257(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15549(%rip), %rdi     # 0x32d0e
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x1422e(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x154ba(%rip), %rdi     # 0x32ca8
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x14205(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15482(%rip), %rdi     # 0x32c99
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x141dc(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15409(%rip), %rdi     # 0x32c49
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x141b3(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15415(%rip), %rdi     # 0x32c7e
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x1418a(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x767a(%rip), %rdi      # 0x24f0c
movl %r15d, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x142d9(%rip), %rsi     # 0x31b7c
xorl %edi, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x37cc
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x14149(%rip), %rcx     # 0x31a0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x4, %esi
xorl %edx, %edx
callq 0x5ba5
testb %al, %al
jne 0x1d9e0
leaq 0x142b8(%rip), %rsi     # 0x31b9f
jmp 0x1d9d7
testb $0x3f, %sil
je 0x1d902
leaq 0x14317(%rip), %rsi     # 0x31c10
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
cmpb $0x0, 0x5(%rbx)
jne 0x1d90e
cmpb $0x0, 0x6(%rbx)
je 0x1d91e
leaq 0x1431f(%rip), %rsi     # 0x31c34
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
movzbl 0x4(%rbx), %esi
leaq 0x14329(%rip), %rdi     # 0x31c52
xorl %eax, %eax
callq 0x3030
jmp 0x1d9e0
testb $0x3f, %sil
je 0x1d94b
leaq 0x142ce(%rip), %rsi     # 0x31c10
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
movzbl 0x4(%rbx), %esi
addl $0x7c6, %esi            # imm = 0x7C6
movzbl 0x5(%rbx), %edx
movzbl 0x6(%rbx), %ecx
leaq 0x1430a(%rip), %rdi     # 0x31c6e
xorl %eax, %eax
callq 0x3030
movb 0x5(%rbx), %al
addb $-0xd, %al
cmpb $-0xd, %al
ja 0x1d984
leaq 0x1431a(%rip), %rsi     # 0x31c95
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
movb 0x6(%rbx), %al
addb $-0x20, %al
cmpb $-0x20, %al
ja 0x1d9e0
leaq 0x14314(%rip), %rsi     # 0x31ca8
jmp 0x1d9d7
andl $0x3f, %esi
movzbl 0x4(%rbx), %edx
movzbl 0x5(%rbx), %ecx
movzbl 0x6(%rbx), %r8d
leaq 0x14210(%rip), %rdi     # 0x31bbd
xorl %eax, %eax
callq 0x3030
cmpb $0x64, 0x4(%rbx)
jb 0x1d9ca
leaq 0x14223(%rip), %rsi     # 0x31be4
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
cmpb $0x64, 0x6(%rbx)
jb 0x1d9e0
leaq 0x14223(%rip), %rsi     # 0x31bfa
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
movzbl 0x7(%rbx), %r12d
testb %r12b, %r12b
leaq 0x7f3a(%rip), %rsi      # 0x25929
leaq 0x3293(%rip), %r15      # 0x20c89
cmovsq %r15, %rsi
leaq 0x142b8(%rip), %rdi     # 0x31cb9
xorl %eax, %eax
callq 0x3030
testb %r12b, %r12b
js 0x1da25
cmpb $0x40, %r12b
jb 0x1da49
leaq 0x142e4(%rip), %rsi     # 0x31cfe
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
jmp 0x1da49
testb $0x40, %r12b
leaq 0x11af9(%rip), %rax     # 0x2f529
leaq 0x11af6(%rip), %rsi     # 0x2f52d
cmoveq %rax, %rsi
leaq 0x142a1(%rip), %rdi     # 0x31ce3
xorl %eax, %eax
callq 0x3030
leaq 0x142cf(%rip), %rdi     # 0x31d1f
xorl %eax, %eax
callq 0x3030
movl %r12d, %eax
shrl $0x2, %eax
andl $0xc, %eax
leaq 0x14075(%rip), %rcx     # 0x31adc
movslq (%rax,%rcx), %rdi
addq %rcx, %rdi
callq 0x3380
testb $0x8, %r12b
leaq 0x14316(%rip), %r13     # 0x31d94
movq %r15, %rsi
cmoveq %r13, %rsi
leaq 0x142ad(%rip), %rdi     # 0x31d39
xorl %eax, %eax
callq 0x3030
testb $0x4, %r12b
leaq 0x142f3(%rip), %rsi     # 0x31d91
cmovneq %r15, %rsi
leaq 0x142a9(%rip), %rdi     # 0x31d52
xorl %eax, %eax
callq 0x3030
testb $0x2, %r12b
cmoveq %r13, %r15
leaq 0x142da(%rip), %rdi     # 0x31d99
movq %r15, %rsi
xorl %eax, %eax
callq 0x3030
testb $0x1, %r12b
je 0x1dadf
leaq 0x142f0(%rip), %rsi     # 0x31dc6
xorl %edi, %edi
xorl %eax, %eax
callq 0x37cc
movzbl 0x8(%rbx), %ebp
leaq 0x142fd(%rip), %rdi     # 0x31de7
xorl %eax, %eax
callq 0x3030
cmpl $0x23, %ebp
jle 0x1db12
cmpl $0x24, %ebp
je 0x1db29
cmpl $0x48, %ebp
je 0x1db32
cmpl $0x49, %ebp
jne 0x1dc48
leaq 0x15272(%rip), %rdi     # 0x32d82
jmp 0x1db47
cmpl $0x15, %ebp
je 0x1db40
cmpl $0x19, %ebp
jne 0x1dc48
leaq 0x152e5(%rip), %rdi     # 0x32e0c
jmp 0x1db47
leaq 0x152b7(%rip), %rdi     # 0x32de7
jmp 0x1db47
leaq 0x15279(%rip), %rdi     # 0x32db2
callq 0x3380
jmp 0x1db64
leaq 0x152dc(%rip), %rdi     # 0x32e23
callq 0x3380
cmpb $0x3, (%r14)
jne 0x1db64
leaq 0x142be(%rip), %rsi     # 0x31e17
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x37cc
cmpb $0x4, (%r14)
sete %al
cmpb $0x49, %bpl
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1db8b
leaq 0x142c0(%rip), %rsi     # 0x31e40
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x37cc
movzbl 0x9(%rbx), %ebp
testl %ebp, %ebp
je 0x1dbc0
leaq 0x142cf(%rip), %rdi     # 0x31e69
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
cmpl $0xff, %ebp
jne 0x1dbc0
leaq 0x142eb(%rip), %rsi     # 0x31e9d
xorl %edi, %edi
movl $0xff, %edx
xorl %eax, %eax
callq 0x37cc
movzwl 0xa(%rbx), %ebp
testl %ebp, %ebp
je 0x1dbf3
leaq 0x142e7(%rip), %rdi     # 0x31eb6
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
cmpw $-0x1, %bp
jne 0x1dbf3
leaq 0x14305(%rip), %rsi     # 0x31eea
xorl %edi, %edi
movl $0xffff, %edx           # imm = 0xFFFF
xorl %eax, %eax
callq 0x37cc
movzwl 0xc(%rbx), %esi
testl %esi, %esi
je 0x1dc1d
cmpl $0xffff, %esi           # imm = 0xFFFF
jne 0x1dc2c
leaq 0x1522e(%rip), %rdi     # 0x32e38
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3380
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x142d0(%rip), %rdi     # 0x31f03
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3030
leaq 0x72bd(%rip), %rdi      # 0x24f0c
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x1419b(%rip), %rsi     # 0x31dfa
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x37cc
jmp 0x1db4c
nop