// File: rpavlik[P]edid-decode/parse-base-block.cpp
// Function: edid_state::detailed_epi(unsigned char const*)
void edid_state::detailed_epi(const unsigned char *x)
{
	data_block = "EPI Descriptor";
	printf("    %s:\n", data_block.c_str());

	unsigned v = x[5] & 0x07;

	printf("      Bits per pixel: %u\n", 18 + v * 6);
	if (v > 2)
		fail("Invalid bits per pixel.\n");
	v = (x[5] & 0x18) >> 3;
	printf("      Pixels per clock: %u\n", 1 << v);
	if (v > 2)
		fail("Invalid pixels per clock.\n");
	v = (x[5] & 0x60) >> 5;
	printf("      Data color mapping: %sconventional\n", v ? "non-" : "");
	if (v > 1)
		fail("Unknown data color mapping (0x%02x).\n", v);
	if (x[5] & 0x80)
		fail("Non-zero reserved field in byte 5.\n");

	v = x[6] & 0x0f;
	printf("      Interface type: ");
	switch (v) {
	case 0x00: printf("LVDS TFT\n"); break;
	case 0x01: printf("monoSTN 4/8 Bit\n"); break;
	case 0x02: printf("colorSTN 8/16 Bit\n"); break;
	case 0x03: printf("18 Bit TFT\n"); break;
	case 0x04: printf("24 Bit TFT\n"); break;
	case 0x05: printf("TMDS\n"); break;
	default:
		   printf("Unknown (0x%02x)\n", v);
		   fail("Invalid interface type 0x%02x.\n", v);
		   break;
	}
	printf("      DE polarity: DE %s active\n",
	       (x[6] & 0x10) ? "low" : "high");
	printf("      FPSCLK polarity: FPSCLK %sinverted\n",
	       (x[6] & 0x20) ? "" : "not ");
	if (x[6] & 0xc0)
		fail("Non-zero reserved field in byte 6.\n");

	printf("      Vertical display mode: %s\n",
	       (x[7] & 0x01) ? "Up/Down reverse mode" : "normal");
	printf("      Horizontal display mode: %s\n",
	       (x[7] & 0x02) ? "Left/Right reverse mode" : "normal");
	if (x[7] & 0xfc)
		fail("Non-zero reserved field in byte 7.\n");

	v = x[8] & 0x0f;
	printf("      Total power on sequencing delay: ");
	if (v)
		printf("%u ms\n", v * 10);
	else
		printf("VGA controller default\n");
	v = (x[8] & 0xf0) >> 4;
	printf("      Total power off sequencing delay: ");
	if (v)
		printf("%u ms\n", v * 10);
	else
		printf("VGA controller default\n");

	v = x[9] & 0x0f;
	printf("      Contrast power on sequencing delay: ");
	if (v)
		printf("%u ms\n", v * 10);
	else
		printf("VGA controller default\n");
	v = (x[9] & 0xf0) >> 4;
	printf("      Contrast power off sequencing delay: ");
	if (v)
		printf("%u ms\n", v * 10);
	else
		printf("VGA controller default\n");

	v = x[10] & 0x2f;
	const char *s = (x[10] & 0x80) ? "" : " (ignored)";

	printf("      Backlight brightness control: %u steps%s\n", v, s);
	printf("      Backlight enable at boot: %s%s\n",
	       (x[10] & 0x40) ? "off" : "on", s);
	printf("      Backlight control enable: %s\n",
	       (x[10] & 0x80) ? "enabled" : "disabled");

	v = x[11] & 0x2f;
	s = (x[11] & 0x80) ? "" : " (ignored)";

	printf("      Contrast voltable control: %u steps%s\n", v, s);
	if (x[11] & 0x40)
		fail("Non-zero reserved field in byte 11.\n");
	printf("      Contrast control enable: %s\n",
	       (x[11] & 0x80) ? "enabled" : "disabled");

	if (x[12] || x[13] || x[14] || x[15] || x[16])
		fail("Non-zero values in reserved bytes 12-16.\n");

	printf("      EPI Version: %u.%u\n", (x[17] & 0xf0) >> 4, x[17] & 0x0f);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x28(%rbp)
addq $0x30, %rdi
leaq 0x2387d(%rip), %rsi     # 0x340e0
callq 0x4420
movq -0x28(%rbp), %rdi
addq $0x30, %rdi
callq 0x4150
movq %rax, %rsi
leaq 0x23870(%rip), %rdi     # 0x340ef
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
andl $0x7, %eax
movl %eax, -0x14(%rbp)
imull $0x6, -0x14(%rbp), %esi
addl $0x12, %esi
leaq 0x23856(%rip), %rdi     # 0x340f8
movb $0x0, %al
callq 0x4050
cmpl $0x2, -0x14(%rbp)
jbe 0x108bf
xorl %edi, %edi
leaq 0x2385a(%rip), %rsi     # 0x34112
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
andl $0x18, %eax
sarl $0x3, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %ecx
movl $0x1, %esi
shll %cl, %esi
leaq 0x2384a(%rip), %rdi     # 0x3412b
movb $0x0, %al
callq 0x4050
cmpl $0x2, -0x14(%rbp)
jbe 0x108fe
xorl %edi, %edi
leaq 0x23850(%rip), %rsi     # 0x34147
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
andl $0x60, %eax
sarl $0x5, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %ecx
leaq 0x1f5a0(%rip), %rsi     # 0x2feb9
leaq 0x2386c(%rip), %rax     # 0x3418c
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq 0x23834(%rip), %rdi     # 0x34162
movb $0x0, %al
callq 0x4050
cmpl $0x1, -0x14(%rbp)
jbe 0x1094e
movl -0x14(%rbp), %edx
xorl %edi, %edi
leaq 0x2384a(%rip), %rsi     # 0x34191
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x10970
xorl %edi, %edi
leaq 0x2384e(%rip), %rsi     # 0x341b7
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %eax
andl $0xf, %eax
movl %eax, -0x14(%rbp)
leaq 0x23856(%rip), %rdi     # 0x341db
xorl %eax, %eax
callq 0x4050
movl -0x14(%rbp), %eax
movq %rax, -0x30(%rbp)
subq $0x5, %rax
ja 0x10a0d
movq -0x30(%rbp), %rax
leaq 0x20cd8(%rip), %rcx     # 0x3167c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2383e(%rip), %rdi     # 0x341f2
movb $0x0, %al
callq 0x4050
jmp 0x10a31
leaq 0x23838(%rip), %rdi     # 0x341fc
movb $0x0, %al
callq 0x4050
jmp 0x10a31
leaq 0x23839(%rip), %rdi     # 0x3420d
movb $0x0, %al
callq 0x4050
jmp 0x10a31
leaq 0x2383c(%rip), %rdi     # 0x34220
movb $0x0, %al
callq 0x4050
jmp 0x10a31
leaq 0x23838(%rip), %rdi     # 0x3422c
movb $0x0, %al
callq 0x4050
jmp 0x10a31
leaq 0x246aa(%rip), %rdi     # 0x350ae
movb $0x0, %al
callq 0x4050
jmp 0x10a31
movl -0x14(%rbp), %esi
leaq 0x23821(%rip), %rdi     # 0x34238
movb $0x0, %al
callq 0x4050
movl -0x14(%rbp), %edx
xorl %edi, %edi
leaq 0x23820(%rip), %rsi     # 0x3424a
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %ecx
andl $0x10, %ecx
leaq 0x2384c(%rip), %rsi     # 0x3428f
leaq 0x23841(%rip), %rax     # 0x3428b
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq 0x23812(%rip), %rdi     # 0x3426a
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %ecx
andl $0x20, %ecx
leaq 0x30bd3(%rip), %rsi     # 0x41644
leaq 0x1f441(%rip), %rax     # 0x2feb9
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq 0x2380e(%rip), %rdi     # 0x34294
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %eax
andl $0xc0, %eax
cmpl $0x0, %eax
je 0x10aaf
xorl %edi, %edi
leaq 0x23816(%rip), %rsi     # 0x342be
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %ecx
andl $0x1, %ecx
leaq 0x23857(%rip), %rsi     # 0x34318
leaq 0x2383b(%rip), %rax     # 0x34303
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq 0x2380c(%rip), %rdi     # 0x342e2
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %ecx
andl $0x2, %ecx
leaq 0x23829(%rip), %rsi     # 0x34318
leaq 0x2384c(%rip), %rax     # 0x34342
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq 0x2381b(%rip), %rdi     # 0x3431f
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %eax
andl $0xfc, %eax
cmpl $0x0, %eax
je 0x10b2d
xorl %edi, %edi
leaq 0x23834(%rip), %rsi     # 0x3435a
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
movzbl 0x8(%rax), %eax
andl $0xf, %eax
movl %eax, -0x14(%rbp)
leaq 0x2383c(%rip), %rdi     # 0x3437e
movb $0x0, %al
callq 0x4050
cmpl $0x0, -0x14(%rbp)
je 0x10b63
imull $0xa, -0x14(%rbp), %esi
leaq 0x2e2c7(%rip), %rdi     # 0x3ee21
movb $0x0, %al
callq 0x4050
jmp 0x10b71
leaq 0x2383c(%rip), %rdi     # 0x343a6
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x8(%rax), %eax
andl $0xf0, %eax
sarl $0x4, %eax
movl %eax, -0x14(%rbp)
leaq 0x23833(%rip), %rdi     # 0x343be
movb $0x0, %al
callq 0x4050
cmpl $0x0, -0x14(%rbp)
je 0x10bac
imull $0xa, -0x14(%rbp), %esi
leaq 0x2e27e(%rip), %rdi     # 0x3ee21
movb $0x0, %al
callq 0x4050
jmp 0x10bba
leaq 0x237f3(%rip), %rdi     # 0x343a6
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %eax
andl $0xf, %eax
movl %eax, -0x14(%rbp)
leaq 0x23818(%rip), %rdi     # 0x343e7
movb $0x0, %al
callq 0x4050
cmpl $0x0, -0x14(%rbp)
je 0x10bf0
imull $0xa, -0x14(%rbp), %esi
leaq 0x2e23a(%rip), %rdi     # 0x3ee21
movb $0x0, %al
callq 0x4050
jmp 0x10bfe
leaq 0x237af(%rip), %rdi     # 0x343a6
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %eax
andl $0xf0, %eax
sarl $0x4, %eax
movl %eax, -0x14(%rbp)
leaq 0x237fa(%rip), %rdi     # 0x34412
movb $0x0, %al
callq 0x4050
cmpl $0x0, -0x14(%rbp)
je 0x10c39
imull $0xa, -0x14(%rbp), %esi
leaq 0x2e1f1(%rip), %rdi     # 0x3ee21
movb $0x0, %al
callq 0x4050
jmp 0x10c47
leaq 0x23766(%rip), %rdi     # 0x343a6
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0xa(%rax), %eax
andl $0x2f, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movzbl 0xa(%rax), %edx
andl $0x80, %edx
leaq 0x237d4(%rip), %rax     # 0x3443e
leaq 0x1f248(%rip), %rcx     # 0x2feb9
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
leaq 0x237bf(%rip), %rdi     # 0x34449
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0xa(%rax), %ecx
andl $0x40, %ecx
leaq 0x24092(%rip), %rsi     # 0x34d35
leaq 0x237f5(%rip), %rax     # 0x3449f
cmpl $0x0, %ecx
cmovneq %rax, %rsi
movq -0x20(%rbp), %rdx
leaq 0x237bd(%rip), %rdi     # 0x34479
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0xa(%rax), %ecx
andl $0x80, %ecx
leaq 0x237f7(%rip), %rsi     # 0x344cf
leaq 0x237e8(%rip), %rax     # 0x344c7
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq 0x237b6(%rip), %rdi     # 0x344a3
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0xb(%rax), %eax
andl $0x2f, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movzbl 0xb(%rax), %edx
andl $0x80, %edx
leaq 0x23727(%rip), %rax     # 0x3443e
leaq 0x1f19b(%rip), %rcx     # 0x2feb9
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
leaq 0x237a1(%rip), %rdi     # 0x344d8
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0xb(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x10d5e
xorl %edi, %edi
leaq 0x237ae(%rip), %rsi     # 0x34505
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
movzbl 0xb(%rax), %ecx
andl $0x80, %ecx
leaq 0x2375c(%rip), %rsi     # 0x344cf
leaq 0x2374d(%rip), %rax     # 0x344c7
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq 0x237a2(%rip), %rdi     # 0x3452a
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
cmpb $0x0, 0xc(%rax)
jne 0x10dc1
movq -0x10(%rbp), %rax
cmpb $0x0, 0xd(%rax)
jne 0x10dc1
movq -0x10(%rbp), %rax
cmpb $0x0, 0xe(%rax)
jne 0x10dc1
movq -0x10(%rbp), %rax
cmpb $0x0, 0xf(%rax)
jne 0x10dc1
movq -0x10(%rbp), %rax
cmpb $0x0, 0x10(%rax)
je 0x10dd1
xorl %edi, %edi
leaq 0x23783(%rip), %rsi     # 0x3454d
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
movzbl 0x11(%rax), %esi
andl $0xf0, %esi
sarl $0x4, %esi
movq -0x10(%rbp), %rax
movzbl 0x11(%rax), %edx
andl $0xf, %edx
leaq 0x23783(%rip), %rdi     # 0x34577
movb $0x0, %al
callq 0x4050
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)