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

	printf("    Sub-Pixel Layout: ");
	unsigned char v = x[0x0e];
	switch (v) {
	case 0x00: printf("Not defined\n"); break;
	case 0x01: printf("RGB\n"); break;
	case 0x02: printf("BGR\n"); break;
	case 0x03: printf("Quad Pixel - G at bottom left & top right\n"); break;
	case 0x04: printf("Quad Pixel - G at bottom right & top left\n"); break;
	default:
		   printf("Unknown (0x%02x)\n", v);
		   fail("Unknown Sub-Pixel Layout 0x%02x.\n", v);
		   break;
	}
	printf("    Sub-Pixel Configuration: ");
	v = x[0x0f];
	switch (v) {
	case 0x00: printf("Not defined\n"); break;
	case 0x01: printf("Delta (Tri-ad)\n"); break;
	case 0x02: printf("Stripe\n"); break;
	case 0x03: printf("Stripe Offset\n"); break;
	case 0x04: printf("Quad Pixel\n"); break;
	default:
		   printf("Unknown (0x%02x)\n", v);
		   fail("Unknown Sub-Pixel Configuration 0x%02x.\n", v);
		   break;
	}
	printf("    Sub-Pixel Shape: ");
	v = x[0x10];
	switch (v) {
	case 0x00: printf("Not defined\n"); break;
	case 0x01: printf("Round\n"); break;
	case 0x02: printf("Square\n"); break;
	case 0x03: printf("Rectangular\n"); break;
	case 0x04: printf("Oval\n"); break;
	case 0x05: printf("Elliptical\n"); break;
	default:
		   printf("Unknown (0x%02x)\n", v);
		   fail("Unknown Sub-Pixel Shape 0x%02x.\n", v);
		   break;
	}
	if (x[0x11])
		printf("    Horizontal Dot/Pixel Pitch: %.2f mm\n",
		       x[0x11] / 100.0);
	if (x[0x12])
		printf("    Vertical Dot/Pixel Pitch: %.2f mm\n",
		       x[0x12] / 100.0);
	v = x[0x13];
	printf("    Display Device %s a Fixed Pixel Format\n",
	       (v & 0x80) ? "has" : "does not have");
	printf("    View Direction: ");
	switch ((v & 0x60) >> 5) {
	case 0x00: printf("Not specified\n"); break;
	case 0x01: printf("Direct\n"); break;
	case 0x02: printf("Reflected\n"); break;
	case 0x03: printf("Direct & Reflected\n"); break;
	}
	printf("    Display Device uses %stransparent background\n",
	       (v & 0x10) ? "" : "non-");
	printf("    Physical Implementation: ");
	switch ((v & 0x0c) >> 2) {
	case 0x00: printf("Not specified\n"); break;
	case 0x01: printf("Large Image device for group viewing\n"); break;
	case 0x02: printf("Desktop or personal display\n"); break;
	case 0x03: printf("Eyepiece type personal display\n"); break;
	}
	printf("    Monitor/display does %ssupport DDC/CI\n",
	       (v & 0x02) ? "" : "not ");
	if (v & 0x01)
		fail("Bit 0 of byte 0x13 should be 0.\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x30(%rbp)
leaq 0x16109(%rip), %rsi     # 0x418bc
callq 0x4420
movq -0x30(%rbp), %rdi
callq 0x4150
movq %rax, %rsi
leaq 0x8926(%rip), %rdi      # 0x340f1
xorl %eax, %eax
movb %al, -0x21(%rbp)
callq 0x4050
movb -0x21(%rbp), %al
leaq 0x160ec(%rip), %rdi     # 0x418cb
callq 0x4050
movq -0x10(%rbp), %rax
movb 0xe(%rax), %al
movb %al, -0x11(%rbp)
movzbl -0x11(%rbp), %eax
movq %rax, -0x20(%rbp)
subq $0x4, %rax
ja 0x2b860
movq -0x20(%rbp), %rax
leaq 0x1597d(%rip), %rcx     # 0x41184
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x105b5(%rip), %rdi     # 0x3bdcc
movb $0x0, %al
callq 0x4050
jmp 0x2b886
leaq 0x15eac(%rip), %rdi     # 0x416d3
movb $0x0, %al
callq 0x4050
jmp 0x2b886
leaq 0x160ab(%rip), %rdi     # 0x418e2
movb $0x0, %al
callq 0x4050
jmp 0x2b886
leaq 0x160a0(%rip), %rdi     # 0x418e7
movb $0x0, %al
callq 0x4050
jmp 0x2b886
leaq 0x160bb(%rip), %rdi     # 0x41912
movb $0x0, %al
callq 0x4050
jmp 0x2b886
movzbl -0x11(%rbp), %esi
leaq 0x89cd(%rip), %rdi      # 0x34238
movb $0x0, %al
callq 0x4050
movzbl -0x11(%rbp), %edx
xorl %edi, %edi
leaq 0x160be(%rip), %rsi     # 0x4193d
movb $0x0, %al
callq 0x47d0
leaq 0x160d2(%rip), %rdi     # 0x4195f
xorl %eax, %eax
callq 0x4050
movq -0x10(%rbp), %rax
movb 0xf(%rax), %al
movb %al, -0x11(%rbp)
movzbl -0x11(%rbp), %eax
movq %rax, -0x38(%rbp)
subq $0x4, %rax
ja 0x2b910
movq -0x38(%rbp), %rax
leaq 0x158e1(%rip), %rcx     # 0x41198
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x10505(%rip), %rdi     # 0x3bdcc
movb $0x0, %al
callq 0x4050
jmp 0x2b936
leaq 0x160a6(%rip), %rdi     # 0x4197d
movb $0x0, %al
callq 0x4050
jmp 0x2b936
leaq 0x160a6(%rip), %rdi     # 0x4198d
movb $0x0, %al
callq 0x4050
jmp 0x2b936
leaq 0x1609e(%rip), %rdi     # 0x41995
movb $0x0, %al
callq 0x4050
jmp 0x2b936
leaq 0x1609d(%rip), %rdi     # 0x419a4
movb $0x0, %al
callq 0x4050
jmp 0x2b936
movzbl -0x11(%rbp), %esi
leaq 0x891d(%rip), %rdi      # 0x34238
movb $0x0, %al
callq 0x4050
movzbl -0x11(%rbp), %edx
xorl %edi, %edi
leaq 0x16081(%rip), %rsi     # 0x419b0
movb $0x0, %al
callq 0x47d0
leaq 0x1609c(%rip), %rdi     # 0x419d9
xorl %eax, %eax
callq 0x4050
movq -0x10(%rbp), %rax
movb 0x10(%rax), %al
movb %al, -0x11(%rbp)
movzbl -0x11(%rbp), %eax
movq %rax, -0x40(%rbp)
subq $0x5, %rax
ja 0x2b9d0
movq -0x40(%rbp), %rax
leaq 0x15845(%rip), %rcx     # 0x411ac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x10455(%rip), %rdi     # 0x3bdcc
movb $0x0, %al
callq 0x4050
jmp 0x2b9f6
leaq 0x16068(%rip), %rdi     # 0x419ef
movb $0x0, %al
callq 0x4050
jmp 0x2b9f6
leaq 0x1605f(%rip), %rdi     # 0x419f6
movb $0x0, %al
callq 0x4050
jmp 0x2b9f6
leaq 0x16057(%rip), %rdi     # 0x419fe
movb $0x0, %al
callq 0x4050
jmp 0x2b9f6
leaq 0x16054(%rip), %rdi     # 0x41a0b
movb $0x0, %al
callq 0x4050
jmp 0x2b9f6
leaq 0x1604a(%rip), %rdi     # 0x41a11
movb $0x0, %al
callq 0x4050
jmp 0x2b9f6
movzbl -0x11(%rbp), %esi
leaq 0x885d(%rip), %rdi      # 0x34238
movb $0x0, %al
callq 0x4050
movzbl -0x11(%rbp), %edx
xorl %edi, %edi
leaq 0x1602e(%rip), %rsi     # 0x41a1d
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
cmpb $0x0, 0x11(%rax)
je 0x2ba26
movq -0x10(%rbp), %rax
movzbl 0x11(%rax), %eax
cvtsi2sd %eax, %xmm0
movsd 0x3624(%rip), %xmm1     # 0x2f038
divsd %xmm1, %xmm0
leaq 0x1601f(%rip), %rdi     # 0x41a3e
movb $0x1, %al
callq 0x4050
movq -0x10(%rbp), %rax
cmpb $0x0, 0x12(%rax)
je 0x2ba56
movq -0x10(%rbp), %rax
movzbl 0x12(%rax), %eax
cvtsi2sd %eax, %xmm0
movsd 0x35f4(%rip), %xmm1     # 0x2f038
divsd %xmm1, %xmm0
leaq 0x16018(%rip), %rdi     # 0x41a67
movb $0x1, %al
callq 0x4050
movq -0x10(%rbp), %rax
movb 0x13(%rax), %al
movb %al, -0x11(%rbp)
movb -0x11(%rbp), %al
testb %al, %al
leaq 0x1604e(%rip), %rax     # 0x41aba
leaq 0x1604b(%rip), %rsi     # 0x41abe
cmovsq %rax, %rsi
leaq 0x16010(%rip), %rdi     # 0x41a8e
xorl %eax, %eax
movb %al, -0x49(%rbp)
callq 0x4050
movb -0x49(%rbp), %al
leaq 0x1603a(%rip), %rdi     # 0x41acc
callq 0x4050
movzbl -0x11(%rbp), %eax
andl $0x60, %eax
shrl $0x5, %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x3, %eax
ja 0x2bafe
movq -0x48(%rbp), %rax
leaq 0x1570d(%rip), %rcx     # 0x411c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15ab3(%rip), %rdi     # 0x4157a
movb $0x0, %al
callq 0x4050
jmp 0x2bafe
leaq 0x1600a(%rip), %rdi     # 0x41ae1
movb $0x0, %al
callq 0x4050
jmp 0x2bafe
leaq 0x1600b(%rip), %rdi     # 0x41af2
movb $0x0, %al
callq 0x4050
jmp 0x2bafe
leaq 0x15ff2(%rip), %rdi     # 0x41ae9
movb $0x0, %al
callq 0x4050
movzbl -0x11(%rbp), %eax
movb %al, %cl
leaq 0x43ae(%rip), %rax      # 0x2feb9
leaq 0x867a(%rip), %rsi      # 0x3418c
testb $0x10, %cl
cmovneq %rax, %rsi
leaq 0x15fdd(%rip), %rdi     # 0x41afd
xorl %eax, %eax
movb %al, -0x59(%rbp)
callq 0x4050
movb -0x59(%rbp), %al
leaq 0x15ffb(%rip), %rdi     # 0x41b2f
callq 0x4050
movzbl -0x11(%rbp), %eax
andl $0xc, %eax
shrl $0x2, %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x3, %eax
ja 0x2bba0
movq -0x58(%rbp), %rax
leaq 0x1567b(%rip), %rcx     # 0x411d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x15a11(%rip), %rdi     # 0x4157a
movb $0x0, %al
callq 0x4050
jmp 0x2bba0
leaq 0x15fd4(%rip), %rdi     # 0x41b4d
movb $0x0, %al
callq 0x4050
jmp 0x2bba0
leaq 0x15fea(%rip), %rdi     # 0x41b73
movb $0x0, %al
callq 0x4050
jmp 0x2bba0
leaq 0x15ff7(%rip), %rdi     # 0x41b90
movb $0x0, %al
callq 0x4050
movzbl -0x11(%rbp), %ecx
andl $0x2, %ecx
leaq 0x15a96(%rip), %rsi     # 0x41644
leaq 0x4304(%rip), %rax      # 0x2feb9
cmpl $0x0, %ecx
cmovneq %rax, %rsi
leaq 0x15fed(%rip), %rdi     # 0x41bb0
movb $0x0, %al
callq 0x4050
movzbl -0x11(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2bbe6
xorl %edi, %edi
leaq 0x15ffc(%rip), %rsi     # 0x41bdb
movb $0x0, %al
callq 0x47d0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)