// File: goodix[P]gdix_hid_firmware_update/gtx8/gtx8_update.cpp
// Function: GTx8Update::DisableReport()
int GTx8Update::DisableReport()
{
	unsigned char cmdDisable[] = {0x33, 0x00, 0xCD};
	unsigned char cmdConfirm[] = {0x35, 0x00, 0xCB};
	unsigned char buf[3] = {0};
	int ret;

	for (int i = 0; i < 3; i++) {
		ret = dev->Write(CMD_ADDR, cmdDisable, sizeof(cmdDisable));
		if (ret < 0) {
			gdix_err("send close report cmd failed\n");
			return ret;
		}
		usleep(10000);
	}

	ret = dev->Write(CMD_ADDR, cmdConfirm, sizeof(cmdConfirm));
	if (ret < 0) {
		gdix_err("send confirm cmd failed\n");
		return ret;
	}
	usleep(30000);
	ret = dev->Read(CMD_ADDR, buf, sizeof(buf));
	if (ret < 0) {
		gdix_err("read confirm flag failed\n");
		return ret;
	}

	if (buf[1] != 1) {
		gdix_err("close report failed, flag[0x%02X]\n", buf[1]);
		return -EINVAL;
	}

	gdix_info("close report success\n");
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movw 0xd129(%rip), %ax       # 0x1ea44
movw %ax, -0x13(%rbp)
movb 0xd121(%rip), %al       # 0x1ea46
movb %al, -0x11(%rbp)
movw 0xd118(%rip), %ax       # 0x1ea47
movw %ax, -0x16(%rbp)
movb 0xd110(%rip), %al       # 0x1ea49
movb %al, -0x14(%rbp)
leaq -0x19(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x50a0
movl $0x0, -0x24(%rbp)
cmpl $0x3, -0x24(%rbp)
jge 0x119d2
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x13(%rbp), %rdx
movq (%rdi), %rax
movl $0x60cc, %esi           # imm = 0x60CC
movl $0x3, %ecx
callq *0x30(%rax)
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x119bd
jmp 0x11980
leaq 0x14912(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x119b0
movq 0x14645(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0xcf1c(%rip), %rsi      # 0x1e8b9
leaq 0xcf44(%rip), %rdx      # 0x1e8e8
movl $0x85, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x119b2
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x11b2a
movl $0x2710, %edi           # imm = 0x2710
callq 0x5180
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x11953
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x16(%rbp), %rdx
movq (%rdi), %rax
movl $0x60cc, %esi           # imm = 0x60CC
movl $0x3, %ecx
callq *0x30(%rax)
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x11a36
jmp 0x119f9
leaq 0x14899(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x11a29
movq 0x145cc(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0xcee0(%rip), %rsi      # 0x1e8f6
leaq 0xcecb(%rip), %rdx      # 0x1e8e8
movl $0x8d, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x11a2b
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x11b2a
movl $0x7530, %edi           # imm = 0x7530
callq 0x5180
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x19(%rbp), %rdx
movq (%rdi), %rax
movl $0x60cc, %esi           # imm = 0x60CC
movl $0x3, %ecx
callq *0x20(%rax)
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x11aa4
jmp 0x11a67
leaq 0x1482b(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x11a97
movq 0x1455e(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
leaq 0xce9c(%rip), %rsi      # 0x1e920
leaq 0xce5d(%rip), %rdx      # 0x1e8e8
movl $0x93, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x11a99
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x11b2a
movzbl -0x18(%rbp), %eax
cmpl $0x1, %eax
je 0x11aef
jmp 0x11aaf
leaq 0x147e3(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x11ae4
movq 0x14516(%rip), %rax     # 0x25fd8
movq (%rax), %rdi
movzbl -0x18(%rbp), %r8d
leaq 0xce7a(%rip), %rsi      # 0x1e94b
leaq 0xce10(%rip), %rdx      # 0x1e8e8
movl $0x98, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x11ae6
movl $0xffffffea, -0x4(%rbp) # imm = 0xFFFFFFEA
jmp 0x11b2a
jmp 0x11af1
leaq 0x147a1(%rip), %rax     # 0x26299
testb $0x1, (%rax)
je 0x11b21
movq 0x144b4(%rip), %rax     # 0x25fb8
movq (%rax), %rdi
leaq 0xce71(%rip), %rsi      # 0x1e97f
leaq 0xcdd3(%rip), %rdx      # 0x1e8e8
movl $0x9c, %ecx
movb $0x0, %al
callq 0x5190
jmp 0x11b23
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)