// File: /workspace/github_cpp_makefile_star2_O1/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 0x1395a(%rip), %rcx     # 0x3134e
movl $0x11, %r8d
xorl %esi, %esi
callq 0x3390
movq 0x30(%r14), %rsi
leaq 0x73af(%rip), %rdi      # 0x24dbb
xorl %eax, %eax
callq 0x3030
leaq 0x140e2(%rip), %rdi     # 0x31afc
xorl %eax, %eax
callq 0x3030
leaq 0x2(%rbx), %r14
movzbl 0x2(%rbx), %r15d
cmpq $0xa, %r15
ja 0x1dc1f
leaq 0x13f65(%rip), %rax     # 0x319a0
movslq (%rax,%r15,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x15287(%rip), %rdi     # 0x32cd2
callq 0x3380
movq %r14, %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x5b92
testb %al, %al
jne 0x1dfbb
leaq 0x140b0(%rip), %rsi     # 0x31b1e
xorl %edi, %edi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37ec
leaq 0x151f7(%rip), %rdi     # 0x32c83
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13f27(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15174(%rip), %rdi     # 0x32c29
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13efe(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x151e0(%rip), %rdi     # 0x32cbe
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13ed5(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15197(%rip), %rdi     # 0x32c9e
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13eac(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15125(%rip), %rdi     # 0x32c55
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13e83(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15175(%rip), %rdi     # 0x32cce
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13e5a(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x150e6(%rip), %rdi     # 0x32c68
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13e31(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x150ae(%rip), %rdi     # 0x32c59
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13e08(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15035(%rip), %rdi     # 0x32c09
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13ddf(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15041(%rip), %rdi     # 0x32c3e
callq 0x3380
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13db6(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x7296(%rip), %rdi      # 0x24ebc
movl %r15d, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x13f05(%rip), %rsi     # 0x31b3c
xorl %edi, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x37ec
leaq 0x3(%rbx), %rdi
movzbl 0x3(%rbx), %esi
movl %esi, %eax
shrl $0x6, %eax
leaq 0x13d75(%rip), %rcx     # 0x319cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x4, %esi
xorl %edx, %edx
callq 0x5b92
testb %al, %al
jne 0x1dd74
leaq 0x13ee4(%rip), %rsi     # 0x31b5f
jmp 0x1dd6b
testb $0x3f, %sil
je 0x1dc96
leaq 0x13f43(%rip), %rsi     # 0x31bd0
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
cmpb $0x0, 0x5(%rbx)
jne 0x1dca2
cmpb $0x0, 0x6(%rbx)
je 0x1dcb2
leaq 0x13f4b(%rip), %rsi     # 0x31bf4
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
movzbl 0x4(%rbx), %esi
leaq 0x13f55(%rip), %rdi     # 0x31c12
xorl %eax, %eax
callq 0x3030
jmp 0x1dd74
testb $0x3f, %sil
je 0x1dcdf
leaq 0x13efa(%rip), %rsi     # 0x31bd0
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
movzbl 0x4(%rbx), %esi
addl $0x7c6, %esi            # imm = 0x7C6
movzbl 0x5(%rbx), %edx
movzbl 0x6(%rbx), %ecx
leaq 0x13f36(%rip), %rdi     # 0x31c2e
xorl %eax, %eax
callq 0x3030
movb 0x5(%rbx), %al
addb $-0xd, %al
cmpb $-0xd, %al
ja 0x1dd18
leaq 0x13f46(%rip), %rsi     # 0x31c55
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
movb 0x6(%rbx), %al
addb $-0x20, %al
cmpb $-0x20, %al
ja 0x1dd74
leaq 0x13f40(%rip), %rsi     # 0x31c68
jmp 0x1dd6b
andl $0x3f, %esi
movzbl 0x4(%rbx), %edx
movzbl 0x5(%rbx), %ecx
movzbl 0x6(%rbx), %r8d
leaq 0x13e3c(%rip), %rdi     # 0x31b7d
xorl %eax, %eax
callq 0x3030
cmpb $0x64, 0x4(%rbx)
jb 0x1dd5e
leaq 0x13e4f(%rip), %rsi     # 0x31ba4
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
cmpb $0x64, 0x6(%rbx)
jb 0x1dd74
leaq 0x13e4f(%rip), %rsi     # 0x31bba
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
movzbl 0x7(%rbx), %r12d
testb %r12b, %r12b
leaq 0x7b56(%rip), %rsi      # 0x258d9
leaq 0x2eef(%rip), %r15      # 0x20c79
cmovsq %r15, %rsi
leaq 0x13ee4(%rip), %rdi     # 0x31c79
xorl %eax, %eax
callq 0x3030
testb %r12b, %r12b
js 0x1ddb9
cmpb $0x40, %r12b
jb 0x1dddd
leaq 0x13f10(%rip), %rsi     # 0x31cbe
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
jmp 0x1dddd
testb $0x40, %r12b
leaq 0x11725(%rip), %rax     # 0x2f4e9
leaq 0x11722(%rip), %rsi     # 0x2f4ed
cmoveq %rax, %rsi
leaq 0x13ecd(%rip), %rdi     # 0x31ca3
xorl %eax, %eax
callq 0x3030
leaq 0x13efb(%rip), %rdi     # 0x31cdf
xorl %eax, %eax
callq 0x3030
movl %r12d, %eax
shrl $0x2, %eax
andl $0xc, %eax
leaq 0x13ca1(%rip), %rcx     # 0x31a9c
movslq (%rax,%rcx), %rdi
addq %rcx, %rdi
callq 0x3380
testb $0x8, %r12b
leaq 0x13f42(%rip), %r13     # 0x31d54
movq %r15, %rsi
cmoveq %r13, %rsi
leaq 0x13ed9(%rip), %rdi     # 0x31cf9
xorl %eax, %eax
callq 0x3030
testb $0x4, %r12b
leaq 0x13f1f(%rip), %rsi     # 0x31d51
cmovneq %r15, %rsi
leaq 0x13ed5(%rip), %rdi     # 0x31d12
xorl %eax, %eax
callq 0x3030
testb $0x2, %r12b
cmoveq %r13, %r15
leaq 0x13f06(%rip), %rdi     # 0x31d59
movq %r15, %rsi
xorl %eax, %eax
callq 0x3030
testb $0x1, %r12b
je 0x1de73
leaq 0x13f1c(%rip), %rsi     # 0x31d86
xorl %edi, %edi
xorl %eax, %eax
callq 0x37ec
movzbl 0x8(%rbx), %ebp
leaq 0x13f29(%rip), %rdi     # 0x31da7
xorl %eax, %eax
callq 0x3030
cmpl $0x23, %ebp
jle 0x1dea6
cmpl $0x24, %ebp
je 0x1debd
cmpl $0x48, %ebp
je 0x1dec6
cmpl $0x49, %ebp
jne 0x1dfe6
leaq 0x14e9e(%rip), %rdi     # 0x32d42
jmp 0x1ded6
cmpl $0x15, %ebp
je 0x1decf
cmpl $0x19, %ebp
jne 0x1dfe6
leaq 0x14f11(%rip), %rdi     # 0x32dcc
jmp 0x1ded6
leaq 0x14ee3(%rip), %rdi     # 0x32da7
jmp 0x1ded6
leaq 0x14ea5(%rip), %rdi     # 0x32d72
jmp 0x1ded6
leaq 0x14f0d(%rip), %rdi     # 0x32de3
callq 0x3380
cmpb $0x3, (%r14)
sete %al
cmpb $0x48, %bpl
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1df02
leaq 0x13ee0(%rip), %rsi     # 0x31dd7
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x37ec
cmpb $0x4, (%r14)
sete %al
cmpb $0x49, %bpl
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1df29
leaq 0x13ee2(%rip), %rsi     # 0x31e00
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x37ec
movzbl 0x9(%rbx), %ebp
testl %ebp, %ebp
je 0x1df5e
leaq 0x13ef1(%rip), %rdi     # 0x31e29
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
cmpl $0xff, %ebp
jne 0x1df5e
leaq 0x13f0d(%rip), %rsi     # 0x31e5d
xorl %edi, %edi
movl $0xff, %edx
xorl %eax, %eax
callq 0x37ec
movzwl 0xa(%rbx), %ebp
testl %ebp, %ebp
je 0x1df91
leaq 0x13f09(%rip), %rdi     # 0x31e76
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
cmpw $-0x1, %bp
jne 0x1df91
leaq 0x13f27(%rip), %rsi     # 0x31eaa
xorl %edi, %edi
movl $0xffff, %edx           # imm = 0xFFFF
xorl %eax, %eax
callq 0x37ec
movzwl 0xc(%rbx), %esi
testl %esi, %esi
je 0x1dfbb
cmpl $0xffff, %esi           # imm = 0xFFFF
jne 0x1dfca
leaq 0x14e50(%rip), %rdi     # 0x32df8
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 0x13ef2(%rip), %rdi     # 0x31ec3
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3030
leaq 0x6ecf(%rip), %rdi      # 0x24ebc
movl %ebp, %esi
xorl %eax, %eax
callq 0x3030
leaq 0x13dbd(%rip), %rsi     # 0x31dba
xorl %edi, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x37ec
jmp 0x1dedb
nop