// File: rpavlik[P]edid-decode/parse-displayid-block.cpp
// Function: edid_state::parse_displayid_vesa(unsigned char const*)
void edid_state::parse_displayid_vesa(const unsigned char *x)
{
	check_displayid_datablock_revision(x[1]);

	if (!check_displayid_datablock_length(x, 5, 7))
		return;

	unsigned len = x[2];
	x += 6;
	printf("    Data Structure Type: ");
	switch (x[0] & 0x07) {
	case 0x00: printf("eDP\n"); break;
	case 0x01: printf("DP\n"); break;
	default: printf("Reserved\n"); break;
	}
	printf("    Default Colorspace and EOTF Handling: %s\n",
	       (x[0] & 0x80) ? "Native as specified in the Display Parameters DB" : "sRGB");
	printf("    Number of Pixels in Hor Pix Cnt Overlapping an Adjacent Panel: %u\n",
	       x[1] & 0xf);
	printf("    Multi-SST Operation: ");
	switch ((x[1] >> 5) & 0x03) {
	case 0x00: printf("Not Supported\n"); break;
	case 0x01: printf("Two Streams (number of links shall be 2 or 4)\n"); break;
	case 0x02: printf("Four Streams (number of links shall be 4)\n"); break;
	case 0x03: printf("Reserved\n"); break;
	}
	if (len >= 7) {
		double bpp = (x[2] & 0x3f) + (x[3] & 0x0f) / 16.0;
		printf("    Pass through timing's target DSC bits per pixel: %.4f\n", bpp);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
movzbl 0x1(%rax), %esi
movl %ecx, %edx
callq 0x21b00
movq -0x10(%rbp), %rdi
movl $0x5, %esi
movl $0x7, %edx
xorl %ecx, %ecx
callq 0x21f90
testb $0x1, %al
jne 0x27b53
jmp 0x27ccc
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x10(%rbp)
leaq 0x185d3(%rip), %rdi     # 0x40144
xorl %eax, %eax
callq 0x4050
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x7, %eax
movl %eax, -0x24(%rbp)
je 0x27b93
jmp 0x27b89
movl -0x24(%rbp), %eax
subl $0x1, %eax
je 0x27ba3
jmp 0x27bb3
leaq 0x185c4(%rip), %rdi     # 0x4015e
movb $0x0, %al
callq 0x4050
jmp 0x27bc1
leaq 0x185b5(%rip), %rdi     # 0x4015f
movb $0x0, %al
callq 0x4050
jmp 0x27bc1
leaq 0x17a6a(%rip), %rdi     # 0x3f624
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movb (%rax), %al
testb %al, %al
leaq 0x185c1(%rip), %rax     # 0x40191
leaq 0x185eb(%rip), %rsi     # 0x401c2
cmovsq %rax, %rsi
leaq 0x18581(%rip), %rdi     # 0x40163
xorl %eax, %eax
movb %al, -0x31(%rbp)
callq 0x4050
movb -0x31(%rbp), %al
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %esi
andl $0xf, %esi
leaq 0x185c6(%rip), %rdi     # 0x401c7
callq 0x4050
movb -0x31(%rbp), %al
leaq 0x185fe(%rip), %rdi     # 0x4020e
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
shrl $0x5, %eax
andl $0x3, %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x3, %eax
ja 0x27c80
movq -0x30(%rbp), %rax
leaq 0x161c3(%rip), %rcx     # 0x3ddfc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x185df(%rip), %rdi     # 0x40228
movb $0x0, %al
callq 0x4050
jmp 0x27c80
leaq 0x185de(%rip), %rdi     # 0x40237
movb $0x0, %al
callq 0x4050
jmp 0x27c80
leaq 0x185fd(%rip), %rdi     # 0x40266
movb $0x0, %al
callq 0x4050
jmp 0x27c80
leaq 0x179ab(%rip), %rdi     # 0x3f624
movb $0x0, %al
callq 0x4050
cmpl $0x7, -0x14(%rbp)
jb 0x27ccc
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
andl $0x3f, %eax
cvtsi2sd %eax, %xmm0
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
andl $0xf, %eax
cvtsi2sd %eax, %xmm1
movsd 0x15ed4(%rip), %xmm2    # 0x3db80
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
leaq 0x185cc(%rip), %rdi     # 0x40291
movb $0x1, %al
callq 0x4050
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)