// File: chenhn123[P]wdt_util_src/wdt_ct/w8790_funcs.cpp
// Function: wh_w8790_prepare_data(WdtDevice*, BoardInfo*)
int wh_w8790_prepare_data(WDT_DEV* pdev, BOARD_INFO* p_out_board_info)
{
	if (!pdev || !p_out_board_info)
		return 0;
	wh_w8790_dev_set_basic_op(pdev);



	if (!wh_w8790_dev_identify_platform(pdev)) {
		wh_printf("can't get platform identify!\n");
		return 0;
	}
	//I:0x49 S:0x53 P:0x50 
	if (pdev->board_info.dev_info.w8790_feature_devinfo.program_name_fourcc[0] == 'I' &&
		pdev->board_info.dev_info.w8790_feature_devinfo.program_name_fourcc[1] == 'S' &&
		pdev->board_info.dev_info.w8790_feature_devinfo.program_name_fourcc[2] == 'P')
	{
		p_out_board_info->dev_type = FW_WDT8790_ISP;
		wh_printf("It is ISP mode!\n");


		return 1;

	}


	W8790_PCT pct_data;


	if (wh_w8790_dev_get_context(pdev, &pct_data)) {
		// set the default values
		p_out_board_info->sys_param.Phy_Frmbuf_W = pct_data.n_cs;
		p_out_board_info->sys_param.Phy_X0 = pct_data.x1;
		p_out_board_info->sys_param.Phy_X1 = pct_data.xn;

		p_out_board_info->sys_param.Phy_Frmbuf_H = pct_data.n_cd;
		p_out_board_info->sys_param.Phy_Y0 = pct_data.y1;
		p_out_board_info->sys_param.Phy_Y1 = pct_data.yn;

		p_out_board_info->sys_param.xmls_id2 = 0;

		W8790_PARAMETER_INFO parameter_info;
		wh_w8790_dev_read_parameter_table_info(pdev, &parameter_info);
		UINT32 cksum;
		wh_w8790_dev_read_parameters_get_checksum(pdev, parameter_info, &cksum);
		p_out_board_info->sys_param.xmls_id1 = cksum;

		return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x8b5e
cmpq $0x0, -0x18(%rbp)
jne 0x8b6a
movl $0x0, -0x4(%rbp)
jmp 0x8cc9
movq -0x10(%rbp), %rdi
callq 0x6850
movq -0x10(%rbp), %rdi
callq 0x6a00
cmpl $0x0, %eax
jne 0x8b9b
leaq 0x7226(%rip), %rdi      # 0xfdae
movb $0x0, %al
callq 0x24e0
movl $0x0, -0x4(%rbp)
jmp 0x8cc9
movq -0x10(%rbp), %rax
movzbl 0x220(%rax), %eax
cmpl $0x49, %eax
jne 0x8bef
movq -0x10(%rbp), %rax
movzbl 0x221(%rax), %eax
cmpl $0x53, %eax
jne 0x8bef
movq -0x10(%rbp), %rax
movzbl 0x222(%rax), %eax
cmpl $0x50, %eax
jne 0x8bef
movq -0x18(%rbp), %rax
movl $0x201, (%rax)          # imm = 0x201
leaq 0x71f0(%rip), %rdi      # 0xfdcc
movb $0x0, %al
callq 0x24e0
movl $0x1, -0x4(%rbp)
jmp 0x8cc9
movq -0x10(%rbp), %rdi
leaq -0x22(%rbp), %rsi
callq 0x6ae0
cmpl $0x0, %eax
je 0x8cc2
movzbl -0x20(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x24(%rax)
movzbl -0x1e(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x28(%rax)
movzbl -0x1d(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x2a(%rax)
movzbl -0x21(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x26(%rax)
movzbl -0x1c(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x2c(%rax)
movzbl -0x1b(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x2e(%rax)
movq -0x18(%rbp), %rax
movw $0x0, 0x22(%rax)
movq -0x10(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x7260
movq -0x10(%rbp), %rdi
movq -0x2c(%rbp), %rax
movq %rax, -0x3a(%rbp)
movw -0x24(%rbp), %ax
movw %ax, -0x32(%rbp)
movq -0x3a(%rbp), %rax
movq %rax, -0x4a(%rbp)
movw -0x32(%rbp), %ax
movw %ax, -0x42(%rbp)
movq -0x4a(%rbp), %rsi
leaq -0x30(%rbp), %rcx
movzwl -0x42(%rbp), %edx
callq 0x8740
movl -0x30(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x20(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x8cc9
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)