2290 lines
72 KiB
C
2290 lines
72 KiB
C
/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
|
|
/*
|
|
* common/ini/model.c
|
|
*
|
|
* Copyright (C) 2020 Amlogic, Inc. All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include "ini_config.h"
|
|
|
|
#define LOG_TAG "model"
|
|
#define LOG_NDEBUG 0
|
|
|
|
#include "ini_log.h"
|
|
|
|
#include "ini_proxy.h"
|
|
#include "ini_handler.h"
|
|
#include "ini_platform.h"
|
|
#include "ini_io.h"
|
|
#include "model.h"
|
|
#include <partition_table.h>
|
|
|
|
#ifndef CONFIG_YOCTO
|
|
#define DEFAULT_MODEL_SUM_PATH1 "/odm/etc/tvconfig/model/model_sum.ini"
|
|
#else
|
|
#define DEFAULT_MODEL_SUM_PATH1 "/vendor/etc/tvconfig/model/model_sum.ini"
|
|
#endif
|
|
#define DEFAULT_MODEL_SUM_PATH2 "/odm_ext/etc/tvconfig/model/model_sum.ini"
|
|
#define AML_START "amlogic_start"
|
|
#define AML_END "amlogic_end"
|
|
|
|
int model_debug_flag;
|
|
|
|
#ifdef CONFIG_AML_LCD
|
|
static int gLcdDataCnt, gLcdExtDataCnt, gBlDataCnt, glcd_optical_dcnt;
|
|
static int g_lcd_pwr_on_seq_cnt, g_lcd_pwr_off_seq_cnt;
|
|
static int gLcdExtInitOnCnt, gLcdExtInitOffCnt, gLcdExtCmdSize;
|
|
static struct lcd_ext_attr_s *lcd_ext_attr;
|
|
static unsigned int g_lcd_if, g_lcd_tcon_valid;
|
|
#endif
|
|
|
|
int transBufferData(const char *data_str, unsigned int data_buf[])
|
|
{
|
|
int item_ind = 0;
|
|
char *token = NULL;
|
|
char *pSave = NULL;
|
|
char *tmp_buf = NULL;
|
|
|
|
if (data_str == NULL)
|
|
return 0;
|
|
|
|
tmp_buf = (char *) malloc(CC_MAX_TEMP_BUF_SIZE);
|
|
if (!tmp_buf) {
|
|
ALOGE("%s, malloc buffer memory error!!!\n", __func__);
|
|
return 0;
|
|
}
|
|
|
|
memset((void *)tmp_buf, 0, CC_MAX_TEMP_BUF_SIZE);
|
|
strncpy(tmp_buf, data_str, CC_MAX_TEMP_BUF_SIZE - 1);
|
|
token = plat_strtok_r(tmp_buf, ",", &pSave);
|
|
while (token != NULL) {
|
|
data_buf[item_ind] = strtoul(token, NULL, 0);
|
|
item_ind++;
|
|
token = plat_strtok_r(NULL, ",", &pSave);
|
|
}
|
|
|
|
free(tmp_buf);
|
|
tmp_buf = NULL;
|
|
|
|
return item_ind;
|
|
}
|
|
|
|
#ifdef CONFIG_AML_LCD
|
|
int check_param_valid(int mode, int parse_len, unsigned char parse_buf[],
|
|
int ori_len, unsigned char ori_buf[])
|
|
{
|
|
unsigned int ori_cal_crc32 = 0, parse_cal_crc32 = 0;
|
|
struct lcd_header_s head, head2;
|
|
unsigned char *p;
|
|
|
|
if (mode == 0) {
|
|
// start check parse data valid
|
|
//ALOGD("%s, start check parse data valid\n", __func__);
|
|
if (check_hex_data_have_header_valid(&parse_cal_crc32, CC_MAX_DATA_SIZE, parse_len, parse_buf) < 0)
|
|
return CC_PARAM_CHECK_ERROR_NOT_NEED_UPDATE_PARAM;
|
|
|
|
// start check flash key data valid
|
|
//ALOGD("%s, start check flash key data valid\n", __func__);
|
|
if (check_hex_data_have_header_valid(&ori_cal_crc32, CC_MAX_DATA_SIZE, ori_len, ori_buf) < 0)
|
|
return CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM;
|
|
|
|
if (parse_cal_crc32 != ori_cal_crc32) {
|
|
//ALOGE("%s, parse data not equal flash data(0x%08X, 0x%08X)\n", __func__, parse_cal_crc32, ori_cal_crc32);
|
|
return CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM;
|
|
}
|
|
// end check parse data valid
|
|
} else if (mode == 1) {
|
|
// start check parse data valid
|
|
//ALOGD("%s, start check parse data valid\n", __func__);
|
|
if (check_hex_data_no_header_valid(&parse_cal_crc32, CC_MAX_DATA_SIZE, parse_len, parse_buf) < 0)
|
|
return CC_PARAM_CHECK_ERROR_NOT_NEED_UPDATE_PARAM;
|
|
|
|
// start check flash key data valid
|
|
//ALOGD("%s, start check flash key data valid\n", __func__);
|
|
if (check_hex_data_no_header_valid(&ori_cal_crc32, CC_MAX_DATA_SIZE, ori_len, ori_buf) < 0)
|
|
return CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM;
|
|
|
|
if (parse_cal_crc32 != ori_cal_crc32) {
|
|
//ALOGE("%s, parse data not equal flash data(0x%08X, 0x%08X)\n", __func__, parse_cal_crc32, ori_cal_crc32);
|
|
return CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM;
|
|
}
|
|
// end check parse data valid
|
|
} else if (mode == 2) {
|
|
// start check parse data valid
|
|
//ALOGD("%s, start check parse data valid\n", __func__);
|
|
memcpy((void *)&head, (void *)parse_buf, sizeof(struct lcd_header_s));
|
|
if (check_hex_data_have_header_valid
|
|
(&parse_cal_crc32, CC_MAX_DATA_SIZE,
|
|
head.data_len, parse_buf) < 0)
|
|
return CC_PARAM_CHECK_ERROR_NOT_NEED_UPDATE_PARAM;
|
|
|
|
// start check flash key data valid
|
|
//ALOGD("%s, start check flash key data valid\n", __func__);
|
|
memcpy((void *)&head2, (void *)ori_buf, sizeof(struct lcd_header_s));
|
|
if (check_hex_data_have_header_valid
|
|
(&ori_cal_crc32, CC_MAX_DATA_SIZE, head2.data_len,
|
|
ori_buf) < 0)
|
|
return CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM;
|
|
|
|
if (parse_cal_crc32 != ori_cal_crc32)
|
|
//ALOGE("%s, parse data not equal flash data(0x%08X, 0x%08X)\n",
|
|
//__func__, parse_cal_crc32, ori_cal_crc32);
|
|
return CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM;
|
|
|
|
p = parse_buf + head.data_len;
|
|
memcpy((void *)&head, (void *)p, sizeof(struct lcd_header_s));
|
|
if (check_hex_data_have_header_valid
|
|
(&parse_cal_crc32, CC_MAX_DATA_SIZE, head.data_len, p) < 0)
|
|
return CC_PARAM_CHECK_ERROR_NOT_NEED_UPDATE_PARAM;
|
|
|
|
p = parse_buf + head2.data_len;
|
|
memcpy((void *)&head2, (void *)ori_buf, sizeof(struct lcd_header_s));
|
|
if (check_hex_data_have_header_valid
|
|
(&ori_cal_crc32, CC_MAX_DATA_SIZE, head2.data_len, p) < 0)
|
|
return CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM;
|
|
|
|
if (parse_cal_crc32 != ori_cal_crc32)
|
|
//ALOGE("%s, parse data not equal flash data(0x%08X, 0x%08X)\n",
|
|
//__func__, parse_cal_crc32, ori_cal_crc32);
|
|
return CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM;
|
|
} else {
|
|
// start check parse data valid
|
|
//ALOGD("%s, start check parse data valid\n", __func__);
|
|
if (check_string_data_have_header_valid(&parse_cal_crc32, (char *)parse_buf, CC_HEAD_CHKSUM_LEN, CC_VERSION_LEN) < 0)
|
|
return CC_PARAM_CHECK_ERROR_NOT_NEED_UPDATE_PARAM;
|
|
|
|
// start check flash key data valid
|
|
//ALOGD("%s, start check flash key data valid\n", __func__);
|
|
if (check_string_data_have_header_valid(&ori_cal_crc32, (char *)ori_buf, CC_HEAD_CHKSUM_LEN, CC_VERSION_LEN) < 0)
|
|
return CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM;
|
|
|
|
if (parse_cal_crc32 != ori_cal_crc32) {
|
|
//ALOGE("%s, parse data not equal flash data(0x%08X, 0x%08X)\n", __func__, parse_cal_crc32, ori_cal_crc32);
|
|
return CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM;
|
|
}
|
|
// end check parse data valid
|
|
}
|
|
|
|
//ALOGD("%s, param check ok!\n", __func__);
|
|
return CC_PARAM_CHECK_OK;
|
|
}
|
|
|
|
static int handle_integrity_flag(void)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("start", "start_tag", "null");
|
|
if (model_debug_flag & DEBUG_NORMAL)
|
|
ALOGD("%s, start_tag is (%s)\n", __func__, ini_value);
|
|
if (strncasecmp(ini_value, AML_START, strlen(AML_START))) {
|
|
ALOGE("%s, start_tag (%s) is error!!!\n", __func__, ini_value);
|
|
return -1;
|
|
}
|
|
|
|
ini_value = IniGetString("end", "end_tag", "null");
|
|
if (model_debug_flag & DEBUG_NORMAL)
|
|
ALOGD("%s, end_tag is (%s)\n", __func__, ini_value);
|
|
if (strncasecmp(ini_value, AML_END, strlen(AML_END))) {
|
|
ALOGE("%s, end_tag (%s) is error!!!\n", __func__, ini_value);
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int read_bin_file(const char *file_name, unsigned long max_buf_len)
|
|
{
|
|
int size;
|
|
|
|
BinFileInit();
|
|
|
|
size = ReadBinFile(file_name);
|
|
if (size < 0) {
|
|
ALOGE("%s, load bin file error!\n", __func__);
|
|
BinFileUninit();
|
|
return 0;
|
|
}
|
|
|
|
if (size > max_buf_len) {
|
|
ALOGE("%s, bin file size out of support!\n", __func__);
|
|
BinFileUninit();
|
|
return 0;
|
|
}
|
|
|
|
return size;
|
|
}
|
|
|
|
static int handle_lcd_basic(struct lcd_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
unsigned int config_chk;
|
|
unsigned int bits, cfmt;
|
|
|
|
ini_value = IniGetString("lcd_Attr", "model_name", "null");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, model_name is (%s)\n", __func__, ini_value);
|
|
strncpy(p_attr->basic.model_name, ini_value, CC_LCD_NAME_LEN_MAX - 1);
|
|
p_attr->basic.model_name[CC_LCD_NAME_LEN_MAX - 1] = '\0';
|
|
|
|
ini_value = IniGetString("lcd_Attr", "interface", "null");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, interface is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "LCD_RGB") == 0)
|
|
g_lcd_if = LCD_RGB;
|
|
else if (strcmp(ini_value, "LCD_LVDS") == 0)
|
|
g_lcd_if = LCD_LVDS;
|
|
else if (strcmp(ini_value, "LCD_VBYONE") == 0)
|
|
g_lcd_if = LCD_VBYONE;
|
|
else if (strcmp(ini_value, "LCD_MIPI") == 0)
|
|
g_lcd_if = LCD_MIPI;
|
|
else if (strcmp(ini_value, "LCD_MLVDS") == 0)
|
|
g_lcd_if = LCD_MLVDS;
|
|
else if (strcmp(ini_value, "LCD_P2P") == 0)
|
|
g_lcd_if = LCD_P2P;
|
|
else if (strcmp(ini_value, "LCD_EDP") == 0)
|
|
g_lcd_if = LCD_EDP;
|
|
else if (strcmp(ini_value, "LCD_BT656") == 0)
|
|
g_lcd_if = LCD_BT656;
|
|
else if (strcmp(ini_value, "LCD_BT1120") == 0)
|
|
g_lcd_if = LCD_BT1120;
|
|
else
|
|
g_lcd_if = LCD_TYPE_MAX;
|
|
|
|
ini_value = IniGetString("lcd_Attr", "config_check", "none");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, config_check is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "none") == 0)
|
|
config_chk = 0;
|
|
else
|
|
config_chk = strtoul(ini_value, NULL, 0) ? 0x3 : 0x2;
|
|
|
|
p_attr->basic.lcd_if_chk = (g_lcd_if & 0x3f) | ((config_chk & 0x3) << 6);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "lcd_bits", "10");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, lcd_bits is (%s)\n", __func__, ini_value);
|
|
bits = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "cmft_in", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, cmft_in is (%s)\n", __func__, ini_value);
|
|
cfmt = strtoul(ini_value, NULL, 0);
|
|
p_attr->basic.lcd_bits_cfmt = ((cfmt & 0x3) << 6) | (bits & 0x3f);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "screen_width", "16");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, screen_width is (%s)\n", __func__, ini_value);
|
|
p_attr->basic.screen_width = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "screen_height", "9");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, screen_height is (%s)\n", __func__, ini_value);
|
|
p_attr->basic.screen_height = strtoul(ini_value, NULL, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_timming(struct lcd_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
unsigned int width, pol;
|
|
|
|
ini_value = IniGetString("lcd_Attr", "h_active", "1920");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, h_active is (%s)\n", __func__, ini_value);
|
|
p_attr->timming.h_active = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "v_active", "1080");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, v_active is (%s)\n", __func__, ini_value);
|
|
p_attr->timming.v_active = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "h_period", "2200");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, h_period is (%s)\n", __func__, ini_value);
|
|
p_attr->timming.h_period = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "v_period", "1125");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, v_period is (%s)\n", __func__, ini_value);
|
|
p_attr->timming.v_period = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "hsync_width", "44");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, hsync_width is (%s)\n", __func__, ini_value);
|
|
width = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "hsync_bp", "148");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, hsync_bp is (%s)\n", __func__, ini_value);
|
|
p_attr->timming.hsync_bp = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "hsync_pol", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, hsync_pol is (%s)\n", __func__, ini_value);
|
|
pol = strtoul(ini_value, NULL, 0);
|
|
p_attr->timming.hsync_width_pol = ((pol & 0xf) << 12) | (width & 0xfff);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "vsync_width", "5");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, vsync_width is (%s)\n", __func__, ini_value);
|
|
width = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "vsync_bp", "30");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, vsync_bp is (%s)\n", __func__, ini_value);
|
|
p_attr->timming.vsync_bp = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "vsync_pol", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, vsync_pol is (%s)\n", __func__, ini_value);
|
|
pol = strtoul(ini_value, NULL, 0);
|
|
p_attr->timming.vsync_width_pol = ((pol & 0xf) << 12) | (width & 0xfff);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "pre_de_h", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, pre_de_h is (%s)\n", __func__, ini_value);
|
|
p_attr->timming.pre_de_h = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "pre_de_v", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, pre_de_v is (%s)\n", __func__, ini_value);
|
|
p_attr->timming.pre_de_v = strtoul(ini_value, NULL, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_customer(struct lcd_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("lcd_Attr", "fr_adjust_type", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, fr_adjust_type is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.fr_adjust_type = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "ss_level", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, ss_level is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.ss_level = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "clk_auto_gen", "1");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, clk_auto_gen is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.clk_auto_gen = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "pixel_clk", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, pixel_clk is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.pixel_clk = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "h_period_min", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, h_period_min is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.h_period_min = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "h_period_max", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, h_period_max is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.h_period_max = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "v_period_min", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, v_period_min is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.v_period_min = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "v_period_max", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, v_period_max is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.v_period_max = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "pixel_clk_min", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, pixel_clk_min is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.pixel_clk_min = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "pixel_clk_max", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, pixel_clk_max is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.pixel_clk_max = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "vlock_val_0", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, vlock_val_0 is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.vlock_val_0 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "vlock_val_1", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, vlock_val_1 is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.vlock_val_1 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "vlock_val_2", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, vlock_val_2 is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.vlock_val_2 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "vlock_val_3", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, vlock_val_3 is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.vlock_val_3 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "custom_pinmux", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, custom_pinmux is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.custom_pinmux = strtoul(ini_value, NULL, 0);
|
|
if (p_attr->customer.custom_pinmux == 0) {
|
|
ini_value = IniGetString("lcd_Attr", "customer_value_9", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, customer_value_9 is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.custom_pinmux = strtoul(ini_value, NULL, 0);
|
|
}
|
|
|
|
ini_value = IniGetString("lcd_Attr", "fr_auto_custom", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, fr_auto_custom is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.fr_auto_cus = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "frame_rate_min", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, frame_rate_min is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.frame_rate_min = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "frame_rate_max", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, frame_rate_max is (%s)\n", __func__, ini_value);
|
|
p_attr->customer.frame_rate_max = strtoul(ini_value, NULL, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_interface(struct lcd_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("lcd_Attr", "if_attr_0", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, if_attr_0 is (%s)\n", __func__, ini_value);
|
|
p_attr->interface.if_attr_0 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "if_attr_1", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, if_attr_1 is (%s)\n", __func__, ini_value);
|
|
p_attr->interface.if_attr_1 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "if_attr_2", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, if_attr_2 is (%s)\n", __func__, ini_value);
|
|
p_attr->interface.if_attr_2 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "if_attr_3", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, if_attr_3 is (%s)\n", __func__, ini_value);
|
|
p_attr->interface.if_attr_3 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "if_attr_4", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, if_attr_4 is (%s)\n", __func__, ini_value);
|
|
p_attr->interface.if_attr_4 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "if_attr_5", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, if_attr_5 is (%s)\n", __func__, ini_value);
|
|
p_attr->interface.if_attr_5 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "if_attr_6", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, if_attr_6 is (%s)\n", __func__, ini_value);
|
|
p_attr->interface.if_attr_6 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "if_attr_7", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, if_attr_7 is (%s)\n", __func__, ini_value);
|
|
p_attr->interface.if_attr_7 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "if_attr_8", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, if_attr_8 is (%s)\n", __func__, ini_value);
|
|
p_attr->interface.if_attr_8 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "if_attr_9", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, if_attr_9 is (%s)\n", __func__, ini_value);
|
|
p_attr->interface.if_attr_9 = strtoul(ini_value, NULL, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_pwr(struct lcd_attr_s *p_attr)
|
|
{
|
|
int i = 0, tmp_cnt = 0, tmp_base_ind = 0;
|
|
const char *ini_value = NULL;
|
|
unsigned int tmp_buf[1024];
|
|
|
|
ini_value = IniGetString("lcd_Attr", "power_on_step", "null");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, power_on_step is (%s)\n", __func__, ini_value);
|
|
tmp_cnt = transBufferData(ini_value, tmp_buf);
|
|
g_lcd_pwr_on_seq_cnt = tmp_cnt / CC_LCD_PWR_ITEM_CNT;
|
|
for (i = 0; i < g_lcd_pwr_on_seq_cnt; i++) {
|
|
tmp_base_ind = i * CC_LCD_PWR_ITEM_CNT;
|
|
p_attr->pwr[i].pwr_step_type = tmp_buf[tmp_base_ind + 0];
|
|
p_attr->pwr[i].pwr_step_index = tmp_buf[tmp_base_ind + 1];
|
|
p_attr->pwr[i].pwr_step_val = tmp_buf[tmp_base_ind + 2];
|
|
p_attr->pwr[i].pwr_step_delay = tmp_buf[tmp_base_ind + 3];
|
|
}
|
|
|
|
ini_value = IniGetString("lcd_Attr", "power_off_step", "null");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, power_off_step is (%s)\n", __func__, ini_value);
|
|
tmp_cnt = transBufferData(ini_value, tmp_buf);
|
|
g_lcd_pwr_off_seq_cnt = tmp_cnt / CC_LCD_PWR_ITEM_CNT;
|
|
for (i = 0; i < g_lcd_pwr_off_seq_cnt; i++) {
|
|
tmp_base_ind = i * CC_LCD_PWR_ITEM_CNT;
|
|
p_attr->pwr[i + g_lcd_pwr_on_seq_cnt].pwr_step_type = tmp_buf[tmp_base_ind + 0];
|
|
p_attr->pwr[i + g_lcd_pwr_on_seq_cnt].pwr_step_index = tmp_buf[tmp_base_ind + 1];
|
|
p_attr->pwr[i + g_lcd_pwr_on_seq_cnt].pwr_step_val = tmp_buf[tmp_base_ind + 2];
|
|
p_attr->pwr[i + g_lcd_pwr_on_seq_cnt].pwr_step_delay = tmp_buf[tmp_base_ind + 3];
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_header(struct lcd_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
unsigned int size = 0;
|
|
|
|
size = 0;
|
|
size += sizeof(struct lcd_header_s);
|
|
size += sizeof(struct lcd_basic_s);
|
|
size += sizeof(struct lcd_timming_s);
|
|
size += sizeof(struct lcd_customer_s);
|
|
size += sizeof(struct lcd_interface_s);
|
|
|
|
size += sizeof(struct lcd_pwr_s) * g_lcd_pwr_on_seq_cnt;
|
|
size += sizeof(struct lcd_pwr_s) * g_lcd_pwr_off_seq_cnt;
|
|
|
|
//p_attr->head.data_len = size; //total data len will handle after all parameters parsed
|
|
p_attr->head.block_cur_size = size;
|
|
|
|
ini_value = IniGetString("lcd_Attr", "version", "null");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, version is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null") == 0)
|
|
p_attr->head.version = 0;
|
|
else
|
|
p_attr->head.version = strtoul(ini_value, NULL, 0);
|
|
|
|
//p_attr->head.rev = 0;
|
|
if (p_attr->head.version >= 2)
|
|
p_attr->head.block_next_flag = 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_phy(unsigned char *p_attr)
|
|
{
|
|
struct lcd_phy_s *phy;
|
|
const char *ini_value = NULL;
|
|
unsigned int temp_buf[72];
|
|
unsigned int offset, lane_cnt = 0;
|
|
int i, j, n;
|
|
|
|
offset = sizeof(struct lcd_header_s);
|
|
phy = (struct lcd_phy_s *)(p_attr + offset);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_flag", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_flag is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_flag = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_0", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_0 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_0 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_1", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_1 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_1 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_2", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_2 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_2 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_3", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_3 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_3 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_4", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_4 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_4 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_5", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_5 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_5 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_6", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_6 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_6 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_7", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_7 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_7 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_8", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_8 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_8 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_9", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_9 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_9 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_10", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_10 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_10 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_attr_11", "0");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_attr_11 is (%s)\n", __func__, ini_value);
|
|
phy->phy_attr_11 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_lane_pn_swap", "null");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_lane_pn_swap is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null")) {
|
|
lane_cnt = transBufferData(ini_value, temp_buf);
|
|
for (i = 0; i < lane_cnt; i++) {
|
|
j = i / 8;
|
|
n = i % 8;
|
|
phy->phy_lane_pn_swap[j] = ((temp_buf[i] ? 1 : 0) << n);
|
|
}
|
|
}
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_lane_ctrl", "null");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_lane_ctrl is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null")) {
|
|
lane_cnt = transBufferData(ini_value, temp_buf);
|
|
for (i = 0; i < lane_cnt; i++) {
|
|
phy->phy_lane_ctrl[i] = temp_buf[i];
|
|
if (model_debug_flag & DEBUG_LCD) {
|
|
ALOGD("%s, phy_lane_ctrl[%d] is (0x%x)\n", __func__,
|
|
i, phy->phy_lane_ctrl[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
ini_value = IniGetString("lcd_Attr", "phy_lane_sel", "null");
|
|
if (model_debug_flag & DEBUG_LCD)
|
|
ALOGD("%s, phy_lane_sel is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null")) {
|
|
lane_cnt = transBufferData(ini_value, temp_buf);
|
|
for (i = 0; i < lane_cnt; i++)
|
|
phy->phy_lane_sel[i] = temp_buf[i];
|
|
}
|
|
|
|
if (model_debug_flag & DEBUG_LCD) {
|
|
ALOGD("%s, phy_attr_flag: 0x%x\n", __func__, phy->phy_attr_flag);
|
|
ALOGD("%s, vswing:0x%x, vcm:0x%x, ref_bias:0x%x, odt:0x%x, cv_mode:0x%x\n",
|
|
__func__, phy->phy_attr_0, phy->phy_attr_1,
|
|
phy->phy_attr_2, phy->phy_attr_3, phy->phy_attr_4);
|
|
for (i = 0; i < lane_cnt; i++) {
|
|
ALOGD("%s, lane[%d]: ctrl:0x%x, sel:0x%x\n",
|
|
__func__, i, phy->phy_lane_ctrl[i], phy->phy_lane_sel[i]);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void handle_lcd_v2_header(struct lcd_header_s *header)
|
|
{
|
|
unsigned int data_cnt;
|
|
|
|
if (!header)
|
|
return;
|
|
|
|
data_cnt = 0;
|
|
data_cnt += sizeof(struct lcd_header_s);
|
|
data_cnt += sizeof(struct lcd_phy_s);
|
|
data_cnt += glcd_cus_ctrl_cnt;
|
|
|
|
header->crc32 = 0xffffffff;
|
|
header->data_len = 0;
|
|
header->version = 2;
|
|
header->block_next_flag = 0;
|
|
header->block_cur_size = data_cnt;
|
|
}
|
|
|
|
static void handle_lcd_v3_header(struct lcd_header_s *header)
|
|
{
|
|
unsigned int data_cnt;
|
|
|
|
if (!header)
|
|
return;
|
|
|
|
data_cnt = 0;
|
|
data_cnt += sizeof(struct lcd_header_s);
|
|
data_cnt += glcd_cus_ctrl_cnt;
|
|
|
|
header->crc32 = 0xffffffff;
|
|
header->data_len = 0;
|
|
header->version = 3;
|
|
header->block_next_flag = 0;
|
|
header->block_cur_size = data_cnt;
|
|
}
|
|
|
|
void *handle_lcd_ext_buf_get(void)
|
|
{
|
|
return (void *)lcd_ext_attr;
|
|
}
|
|
|
|
static int handle_lcd_ext_basic(struct lcd_ext_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "ext_name", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, ext_name is (%s)\n", __func__, ini_value);
|
|
strncpy(p_attr->basic.ext_name, ini_value, CC_LCD_EXT_NAME_LEN_MAX - 1);
|
|
p_attr->basic.ext_name[CC_LCD_EXT_NAME_LEN_MAX - 1] = '\0';
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "ext_index", "0xff");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, ext_index is (%s)\n", __func__, ini_value);
|
|
p_attr->basic.ext_index = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "ext_type", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, ext_type is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "LCD_EXTERN_I2C") == 0)
|
|
p_attr->basic.ext_type = LCD_EXTERN_I2C;
|
|
else if (strcmp(ini_value, "LCD_EXTERN_SPI") == 0)
|
|
p_attr->basic.ext_type = LCD_EXTERN_SPI;
|
|
else if (strcmp(ini_value, "LCD_EXTERN_MIPI") == 0)
|
|
p_attr->basic.ext_type = LCD_EXTERN_MIPI;
|
|
else if (strcmp(ini_value, "LCD_EXTERN_SIMPLE") == 0)
|
|
p_attr->basic.ext_type = LCD_EXTERN_SIMPLE;
|
|
else
|
|
p_attr->basic.ext_type = LCD_EXTERN_MAX;
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "ext_status", "0");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, ext_status is (%s)\n", __func__, ini_value);
|
|
p_attr->basic.ext_status = strtoul(ini_value, NULL, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_ext_type(struct lcd_ext_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "value_0", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, value_0 is (%s)\n", __func__, ini_value);
|
|
p_attr->type.value_0 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "value_1", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, value_1 is (%s)\n", __func__, ini_value);
|
|
p_attr->type.value_1 = strtoul(ini_value, NULL, 0);
|
|
|
|
if (p_attr->basic.ext_type == LCD_EXTERN_I2C)
|
|
p_attr->type.value_2 = LCD_EXTERN_I2C_BUS_INVALID;
|
|
else {
|
|
ini_value = IniGetString("lcd_ext_Attr", "value_2", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, value_2 is (%s)\n", __func__, ini_value);
|
|
p_attr->type.value_2 = strtoul(ini_value, NULL, 0);
|
|
}
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "value_3", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, value_3 is (%s)\n", __func__, ini_value);
|
|
p_attr->type.value_3 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "value_4", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, value_4 is (%s)\n", __func__, ini_value);
|
|
p_attr->type.value_4 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "value_5", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, value_5 is (%s)\n", __func__, ini_value);
|
|
p_attr->type.value_5 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "value_6", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, value_6 is (%s)\n", __func__, ini_value);
|
|
p_attr->type.value_6 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "value_7", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, value_7 is (%s)\n", __func__, ini_value);
|
|
p_attr->type.value_7 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "value_8", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, value_8 is (%s)\n", __func__, ini_value);
|
|
p_attr->type.value_8 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "value_9", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, value_9 is (%s)\n", __func__, ini_value);
|
|
p_attr->type.value_9 = strtoul(ini_value, NULL, 0);
|
|
|
|
if (p_attr->basic.ext_type == LCD_EXTERN_I2C)
|
|
gLcdExtCmdSize = p_attr->type.value_3;
|
|
else if (p_attr->basic.ext_type == LCD_EXTERN_SPI)
|
|
gLcdExtCmdSize = p_attr->type.value_6;
|
|
else
|
|
gLcdExtCmdSize = p_attr->type.value_9;
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_AML_LCD_TCON
|
|
static int handle_tcon_ext_bin_data(int index, int type, unsigned char *buf,
|
|
unsigned int offset, unsigned int data_len,
|
|
int multi_flag, int multi_id)
|
|
{
|
|
char *file_name, str[2][50];
|
|
unsigned int data_size = 0, bin_index, i, file_find = 0;
|
|
unsigned char *bin_buf = NULL;
|
|
|
|
if (!buf) {
|
|
ALOGE("%s, buf is null\n", __func__);
|
|
return -1;
|
|
}
|
|
buf[0] = 0; /* init invalid data */
|
|
i = 0;
|
|
|
|
if (index >= 4) {
|
|
ALOGE("%s, invalid index %d\n", __func__, index);
|
|
return -1;
|
|
}
|
|
|
|
if (multi_flag) {
|
|
sprintf(str[0], "model_tcon_ext_b%d_%d_spi", index, multi_id);
|
|
sprintf(str[1], "model_tcon_ext_b%d_%d", index, multi_id);
|
|
} else {
|
|
sprintf(str[0], "model_tcon_ext_b%d_spi", index);
|
|
sprintf(str[1], "model_tcon_ext_b%d", index);
|
|
}
|
|
|
|
while (i < 2) {
|
|
file_name = getenv(str[i]);
|
|
if (!file_name) {
|
|
if (model_debug_flag & DEBUG_NORMAL)
|
|
ALOGD("%s: no %s path\n", __func__, str[i]);
|
|
} else {
|
|
if (iniIsFileExist(file_name)) {
|
|
if (model_debug_flag & DEBUG_NORMAL)
|
|
ALOGD("%s: %s: %s\n", __func__, str[i], file_name);
|
|
file_find = 1;
|
|
bin_index = i;
|
|
break;
|
|
}
|
|
if (model_debug_flag & DEBUG_NORMAL) {
|
|
ALOGE("%s: %s: \"%s\" not exist.\n",
|
|
__func__, str[i], file_name);
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
if (file_find == 0)
|
|
return -1;
|
|
|
|
data_size = read_bin_file(file_name, LCD_EXTERN_INIT_ON_MAX);
|
|
if (data_size == 0) {
|
|
ALOGE("%s, %s data_size %d error!\n", __func__, str[bin_index], data_size);
|
|
return -1;
|
|
}
|
|
if (data_size > LCD_EXTERN_INIT_ON_MAX) {
|
|
ALOGE("%s, %s data_size %d out of support(max %d)!\n",
|
|
__func__, str[bin_index], data_size, LCD_EXTERN_INIT_ON_MAX);
|
|
BinFileUninit();
|
|
return -1;
|
|
}
|
|
|
|
switch (type) {
|
|
case LCD_EXT_CMD_TYPE_CMD_BIN_DATA: /* all data replace, reg_addr nonexistent */
|
|
buf[0] = data_size;
|
|
GetBinData(&buf[1], data_size);
|
|
break;
|
|
case LCD_EXT_CMD_TYPE_CMD_BIN: /* data with reg_addr auto fill 0x0 */
|
|
buf[0] = (data_size + 1); /* data size include reg_addr */
|
|
buf[1] = 0x00; /* reg_addr */
|
|
GetBinData(&buf[2], data_size);
|
|
break;
|
|
case LCD_EXT_CMD_TYPE_CMD_BIN2: /* data with reg_addr, only replace i2c_data */
|
|
if (data_size < (offset + data_len - 1)) {
|
|
ALOGE("%s, %s suspend size %d out of data_size(%d)!\n",
|
|
__func__, str[bin_index], (offset + data_len - 1), data_size);
|
|
BinFileUninit();
|
|
return -1;
|
|
}
|
|
|
|
bin_buf = (unsigned char *)malloc(data_size);
|
|
if (!bin_buf) {
|
|
ALOGE("%s, malloc buffer memory error!!!\n", __func__);
|
|
BinFileUninit();
|
|
return -1;
|
|
}
|
|
buf[0] = data_len;
|
|
buf[1] = offset;
|
|
GetBinData(bin_buf, data_size);
|
|
memcpy(&buf[2], &bin_buf[offset], data_len - 1);
|
|
free(bin_buf);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN) {
|
|
ALOGD("%s: %s:\n", __func__, str[bin_index]);
|
|
for (i = 0; i < (buf[0] + 1); i++)
|
|
printf(" 0x%02x", buf[i]);
|
|
printf("\n");
|
|
}
|
|
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s %s finish\n", __func__, str[bin_index]);
|
|
|
|
BinFileUninit();
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_ext_cmd_bin_load(unsigned char type,
|
|
unsigned int *raw_buf, int raw_size,
|
|
unsigned char *dest_buf, int dest_size)
|
|
{
|
|
unsigned char next_type, multi_flag;
|
|
unsigned int index, multi_id;
|
|
unsigned int offset = 0, data_len = 0;
|
|
unsigned char *data_buf;
|
|
int ret = -1;
|
|
|
|
if (type == LCD_EXT_CMD_TYPE_MULTI_CMD ||
|
|
type == LCD_EXT_CMD_TYPE_MULTI_DFT_CMD) {
|
|
multi_flag = 1;
|
|
next_type = raw_buf[1];
|
|
} else {
|
|
if (type == LCD_EXT_CMD_TYPE_CMD_MULTI ||
|
|
type == LCD_EXT_CMD_TYPE_CMD2_MULTI ||
|
|
type == LCD_EXT_CMD_TYPE_CMD3_MULTI ||
|
|
type == LCD_EXT_CMD_TYPE_CMD4_MULTI) {
|
|
multi_flag = 1;
|
|
next_type = ((raw_buf[1] << 4) | (type & 0xf));
|
|
} else {
|
|
multi_flag = 0;
|
|
next_type = type;
|
|
}
|
|
}
|
|
|
|
switch (next_type & 0xf0) {
|
|
case LCD_EXT_CMD_TYPE_CMD_BIN2:
|
|
case LCD_EXT_CMD_TYPE_CMD_BIN:
|
|
case LCD_EXT_CMD_TYPE_CMD_BIN_DATA:
|
|
break;
|
|
case LCD_EXT_CMD_TYPE_CMD:
|
|
default:
|
|
return -1;
|
|
}
|
|
|
|
index = next_type & 0xf;
|
|
if (multi_flag) {
|
|
data_len = raw_size - 2; //id,next_cmd
|
|
offset = raw_buf[2];
|
|
multi_id = raw_buf[0];
|
|
} else {
|
|
data_len = raw_size;
|
|
offset = raw_buf[0];
|
|
multi_id = 0xff;
|
|
}
|
|
if (data_len > dest_size) {
|
|
ALOGE("%s, data_len %d over size!\n", __func__, data_len);
|
|
return -1;
|
|
}
|
|
memset(dest_buf, 0, dest_size);
|
|
|
|
//save multi_flag for cmd data different replace method
|
|
dest_buf[0] = multi_flag;
|
|
data_buf = &dest_buf[1];
|
|
|
|
ret = handle_tcon_ext_bin_data(index, next_type, data_buf, offset, data_len,
|
|
multi_flag, multi_id);
|
|
if (ret || data_buf[0] == 0) /* bin data size invalid */
|
|
return -1;
|
|
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
static int handle_lcd_ext_special_parse(unsigned char type,
|
|
unsigned int *raw_buf, int raw_size,
|
|
unsigned char *dest_buf, int dest_size)
|
|
{
|
|
unsigned char *data_buf;
|
|
unsigned int temp_val = 0;
|
|
int i = 0, j = 0;
|
|
int ret = -1;
|
|
|
|
if (!raw_buf || !dest_buf)
|
|
return -1;
|
|
|
|
switch (type) {
|
|
case LCD_EXT_CMD_TYPE_MULTI_LIST_UFR: //2byte frame rate
|
|
if (raw_size < 3)
|
|
return -1;
|
|
memset(dest_buf, 0, dest_size);
|
|
data_buf = &dest_buf[1];
|
|
for (i = 0; i < raw_size; i += 3) {
|
|
if ((j + 5) > dest_size) {
|
|
ALOGE("%s: data over size\n", __func__);
|
|
break;
|
|
}
|
|
data_buf[j] = raw_buf[i]; //index
|
|
//frame rate min
|
|
data_buf[j + 1] = raw_buf[i + 1] & 0xff;
|
|
data_buf[j + 2] = (raw_buf[i + 1] >> 8) & 0xff;
|
|
//frame rate max
|
|
data_buf[j + 3] = raw_buf[i + 2] & 0xff;
|
|
data_buf[j + 4] = (raw_buf[i + 2] >> 8) & 0xff;
|
|
j += 5;
|
|
}
|
|
dest_buf[0] = j; //data_size
|
|
ret = 0;
|
|
break;
|
|
case LCD_EXT_CMD_TYPE_DELAY: //maybe 2byte delay
|
|
memset(dest_buf, 0, dest_size);
|
|
for (i = 0; i < raw_size; i++)
|
|
temp_val += raw_buf[i];
|
|
if (temp_val > 0xff) {
|
|
dest_buf[0] = 2; //data_size
|
|
dest_buf[1] = temp_val & 0xff;
|
|
dest_buf[2] = (temp_val >> 8) & 0xff;
|
|
} else {
|
|
dest_buf[0] = 1; //data_size
|
|
dest_buf[1] = temp_val;
|
|
}
|
|
ret = 0;
|
|
break;
|
|
case LCD_EXT_CMD_TYPE_WAIT_GPIO: //maybe 2byte delay
|
|
case LCD_EXT_CMD_TYPE_GPIO: //maybe 2byte delay
|
|
if (raw_size < 2)
|
|
return -1;
|
|
memset(dest_buf, 0, dest_size);
|
|
dest_buf[1] = raw_buf[0]; //gpio index
|
|
dest_buf[2] = raw_buf[1]; //gpio value
|
|
if (raw_size >= 3) {
|
|
temp_val = raw_buf[2];
|
|
if (temp_val > 0xff) {
|
|
dest_buf[0] = 4; //data_size
|
|
dest_buf[3] = temp_val & 0xff;
|
|
dest_buf[4] = (temp_val >> 8) & 0xff;
|
|
} else {
|
|
dest_buf[0] = 3; //data_size
|
|
dest_buf[3] = temp_val;
|
|
}
|
|
} else {
|
|
dest_buf[0] = 2; //data_size
|
|
}
|
|
ret = 0;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int handle_lcd_ext_cmd_data(struct lcd_ext_attr_s *p_attr)
|
|
{
|
|
int i = 0, j = 0, k, tmp_cnt = 0, tmp_off = 0;
|
|
const char *ini_value = NULL;
|
|
unsigned int tmp_buf[2048];
|
|
unsigned char type, raw_size, data_size;
|
|
unsigned char *data_buf = NULL, data_len;
|
|
#ifdef CONFIG_AML_LCD_TCON
|
|
unsigned char multi_flag;
|
|
#endif
|
|
int ret;
|
|
|
|
/* original data in ini */
|
|
ini_value = IniGetString("lcd_ext_Attr", "init_on", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, init_on is (%s)\n", __func__, ini_value);
|
|
tmp_cnt = transBufferData(ini_value, tmp_buf);
|
|
|
|
data_buf = (unsigned char *)malloc(LCD_EXTERN_INIT_ON_MAX);
|
|
if (!data_buf) {
|
|
ALOGE("%s, malloc buffer memory error!!!\n", __func__);
|
|
return -1;
|
|
}
|
|
memset(data_buf, 0, LCD_EXTERN_INIT_ON_MAX);
|
|
|
|
/* init on */
|
|
if (tmp_cnt > LCD_EXTERN_INIT_ON_MAX) {
|
|
ALOGE("%s: invalid init_on data\n", __func__);
|
|
p_attr->cmd_data[0] = LCD_EXT_CMD_TYPE_END;
|
|
p_attr->cmd_data[1] = 0;
|
|
gLcdExtInitOnCnt = 2;
|
|
goto handle_lcd_ext_cmd_data_init_off;
|
|
}
|
|
|
|
if (gLcdExtCmdSize == 0xff) { //dynamic size
|
|
i = 0;
|
|
j = 0;
|
|
while (i < tmp_cnt) {
|
|
type = tmp_buf[i];
|
|
raw_size = tmp_buf[i + 1];
|
|
data_size = raw_size;
|
|
p_attr->cmd_data[j] = type;
|
|
if (type == LCD_EXT_CMD_TYPE_END) {
|
|
p_attr->cmd_data[j + 1] = 0;
|
|
j += 2;
|
|
break;
|
|
}
|
|
|
|
//special parse
|
|
ret = handle_lcd_ext_special_parse(type, &tmp_buf[i + 2], data_size,
|
|
data_buf, LCD_EXTERN_INIT_ON_MAX);
|
|
if (ret == 0) {
|
|
//buf[0]:data_len
|
|
//buf[1..]:data
|
|
data_len = data_buf[0];
|
|
data_size = data_len;
|
|
p_attr->cmd_data[j + 1] = data_size;
|
|
memcpy(&p_attr->cmd_data[j + 2], &data_buf[1], data_len);
|
|
goto handle_lcd_ext_cmd_data_next;
|
|
}
|
|
|
|
#ifdef CONFIG_AML_LCD_TCON
|
|
ret = handle_lcd_ext_cmd_bin_load(type, &tmp_buf[i + 2], data_size,
|
|
data_buf, LCD_EXTERN_INIT_ON_MAX);
|
|
if (ret == 0) {
|
|
//buf[0]:multi_flag
|
|
//buf[1]:data_len
|
|
//buf[2..]:data
|
|
multi_flag = data_buf[0];
|
|
data_len = data_buf[1];
|
|
if (multi_flag) {
|
|
data_size = data_len + 2;
|
|
p_attr->cmd_data[j + 1] = data_size;
|
|
p_attr->cmd_data[j + 2] = tmp_buf[i + 2];
|
|
p_attr->cmd_data[j + 3] = tmp_buf[i + 3];
|
|
memcpy(&p_attr->cmd_data[j + 4], &data_buf[2], data_len);
|
|
} else {
|
|
data_size = data_len;
|
|
p_attr->cmd_data[j + 1] = data_size;
|
|
memcpy(&p_attr->cmd_data[j + 2], &data_buf[2], data_len);
|
|
}
|
|
goto handle_lcd_ext_cmd_data_next;
|
|
}
|
|
#endif
|
|
|
|
/* original ini data */
|
|
p_attr->cmd_data[j + 1] = data_size;
|
|
for (k = 0; k < data_size; k++)
|
|
p_attr->cmd_data[j + 2 + k] = (unsigned char)tmp_buf[i + 2 + k];
|
|
|
|
handle_lcd_ext_cmd_data_next:
|
|
j += data_size + 2;
|
|
i += raw_size + 2; /* raw data */
|
|
}
|
|
gLcdExtInitOnCnt = j;
|
|
} else {
|
|
for (i = 0; i < tmp_cnt; i++)
|
|
p_attr->cmd_data[i] = tmp_buf[i];
|
|
gLcdExtInitOnCnt = tmp_cnt;
|
|
}
|
|
|
|
handle_lcd_ext_cmd_data_init_off:
|
|
/* init off */
|
|
tmp_off = gLcdExtInitOnCnt;
|
|
ini_value = IniGetString("lcd_ext_Attr", "init_off", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, init_off is (%s)\n", __func__, ini_value);
|
|
tmp_cnt = transBufferData(ini_value, tmp_buf);
|
|
if (tmp_cnt > LCD_EXTERN_INIT_OFF_MAX) {
|
|
ALOGE("%s: invalid init_off data\n", __func__);
|
|
p_attr->cmd_data[tmp_off + 0] = LCD_EXT_CMD_TYPE_END;
|
|
p_attr->cmd_data[tmp_off + 1] = 0;
|
|
gLcdExtInitOnCnt = 2;
|
|
} else {
|
|
for (i = 0; i < tmp_cnt; i++)
|
|
p_attr->cmd_data[tmp_off + i] = tmp_buf[i];
|
|
gLcdExtInitOffCnt = tmp_cnt;
|
|
}
|
|
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN) {
|
|
ALOGD("%s, init_on_data:\n", __func__);
|
|
for (i = 0; i < gLcdExtInitOnCnt; i++)
|
|
printf(" [%d] = 0x%02x\n", i, p_attr->cmd_data[i]);
|
|
|
|
ALOGD("%s, init_off_data:\n", __func__);
|
|
for (i = 0; i < gLcdExtInitOffCnt; i++)
|
|
ALOGD(" [%d] = 0x%02x\n", i, p_attr->cmd_data[tmp_off + i]);
|
|
}
|
|
|
|
memset(data_buf, 0, LCD_EXTERN_INIT_ON_MAX);
|
|
free(data_buf);
|
|
data_buf = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int lcd_ext_data_to_buf(unsigned char tmp_buf[], struct lcd_ext_attr_s *p_attr)
|
|
{
|
|
int i = 0;
|
|
int tmp_len = 0, tmp_off = 0;
|
|
|
|
tmp_off = 0;
|
|
|
|
tmp_len = sizeof(struct lcd_header_s);
|
|
memcpy((void *)(tmp_buf + tmp_off), (void *)(&p_attr->head), tmp_len);
|
|
tmp_off += tmp_len;
|
|
|
|
tmp_len = sizeof(struct lcd_ext_basic_s);
|
|
memcpy((void *)(tmp_buf + tmp_off), (void *)(&p_attr->basic), tmp_len);
|
|
tmp_off += tmp_len;
|
|
|
|
tmp_len = sizeof(struct lcd_ext_type_s);
|
|
memcpy((void *)(tmp_buf + tmp_off), (void *)(&p_attr->type), tmp_len);
|
|
tmp_off += tmp_len;
|
|
|
|
tmp_len = gLcdExtInitOnCnt;
|
|
for (i = 0; i < gLcdExtInitOnCnt; i++)
|
|
tmp_buf[tmp_off + i] = p_attr->cmd_data[i];
|
|
tmp_off += tmp_len;
|
|
|
|
for (i = 0; i < gLcdExtInitOffCnt; i++)
|
|
tmp_buf[tmp_off + i] = p_attr->cmd_data[tmp_len+i];
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_ext_header(struct lcd_ext_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
unsigned char *tmp_buf = NULL;
|
|
|
|
tmp_buf = (unsigned char *) malloc(CC_MAX_TEMP_BUF_SIZE);
|
|
if (!tmp_buf) {
|
|
ALOGE("%s, malloc buffer memory error!!!\n", __func__);
|
|
return -1;
|
|
}
|
|
|
|
gLcdExtDataCnt = 0;
|
|
gLcdExtDataCnt += sizeof(struct lcd_header_s);
|
|
gLcdExtDataCnt += sizeof(struct lcd_ext_basic_s);
|
|
gLcdExtDataCnt += sizeof(struct lcd_ext_type_s);
|
|
|
|
gLcdExtDataCnt += gLcdExtInitOnCnt;
|
|
gLcdExtDataCnt += gLcdExtInitOffCnt;
|
|
|
|
p_attr->head.data_len = gLcdExtDataCnt;
|
|
|
|
ini_value = IniGetString("lcd_ext_Attr", "version", "null");
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, version is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null") == 0)
|
|
p_attr->head.version = 0;
|
|
else
|
|
p_attr->head.version = strtoul(ini_value, NULL, 0);
|
|
|
|
p_attr->head.block_next_flag = 0;
|
|
p_attr->head.block_cur_size = gLcdExtDataCnt;
|
|
|
|
memset((void *)tmp_buf, 0, CC_MAX_TEMP_BUF_SIZE);
|
|
lcd_ext_data_to_buf(tmp_buf, p_attr);
|
|
p_attr->head.crc32 = CalCRC32(0, (tmp_buf + 4), gLcdExtDataCnt - 4);
|
|
|
|
if (model_debug_flag & DEBUG_LCD_EXTERN)
|
|
ALOGD("%s, gLcdExtDataCnt = %d\n", __func__, gLcdExtDataCnt);
|
|
|
|
free(tmp_buf);
|
|
tmp_buf = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_bl_basic(struct bl_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_name", "null");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_name is (%s)\n", __func__, ini_value);
|
|
strncpy(p_attr->basic.bl_name, ini_value, CC_BL_NAME_LEN_MAX - 1);
|
|
p_attr->basic.bl_name[CC_BL_NAME_LEN_MAX - 1] = '\0';
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_bl_level(struct bl_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_level_uboot", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_level_uboot is (%s)\n", __func__, ini_value);
|
|
p_attr->level.bl_level_uboot = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_level_kernel", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_level_kernel is (%s)\n", __func__, ini_value);
|
|
p_attr->level.bl_level_kernel = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_level_max", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_level_max is (%s)\n", __func__, ini_value);
|
|
p_attr->level.bl_level_max = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_level_min", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_level_min is (%s)\n", __func__, ini_value);
|
|
p_attr->level.bl_level_min = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_level_mid", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_level_mid is (%s)\n", __func__, ini_value);
|
|
p_attr->level.bl_level_mid = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_level_mid_mapping", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_level_mid_mapping is (%s)\n", __func__, ini_value);
|
|
p_attr->level.bl_level_mid_mapping = strtoul(ini_value, NULL, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_bl_method(struct bl_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_method", "null");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_method is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "BL_CTRL_GPIO") == 0)
|
|
p_attr->method.bl_method = BL_CTRL_GPIO;
|
|
else if (strcmp(ini_value, "BL_CTRL_PWM") == 0)
|
|
p_attr->method.bl_method = BL_CTRL_PWM;
|
|
else if (strcmp(ini_value, "BL_CTRL_PWM_COMBO") == 0)
|
|
p_attr->method.bl_method = BL_CTRL_PWM_COMBO;
|
|
else if (strcmp(ini_value, "BL_CTRL_LOCAL_DIMING") == 0)
|
|
p_attr->method.bl_method = BL_CTRL_LOCAL_DIMMING;
|
|
else if (strcmp(ini_value, "BL_CTRL_LOCAL_DIMMING") == 0)
|
|
p_attr->method.bl_method = BL_CTRL_LOCAL_DIMMING;
|
|
else if (strcmp(ini_value, "BL_CTRL_EXTERN") == 0)
|
|
p_attr->method.bl_method = BL_CTRL_EXTERN;
|
|
else
|
|
p_attr->method.bl_method = BL_CTRL_MAX;
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_en_gpio", "0xff");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_en_gpio is (%s)\n", __func__, ini_value);
|
|
p_attr->method.bl_en_gpio = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_en_gpio_on", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_en_gpio_on is (%s)\n", __func__, ini_value);
|
|
p_attr->method.bl_en_gpio_on = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_en_gpio_off", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_en_gpio_off is (%s)\n", __func__, ini_value);
|
|
p_attr->method.bl_en_gpio_off = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_on_delay", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_on_delay is (%s)\n", __func__, ini_value);
|
|
p_attr->method.bl_on_delay = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_off_delay", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_off_delay is (%s)\n", __func__, ini_value);
|
|
p_attr->method.bl_off_delay = strtoul(ini_value, NULL, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int getPWMMethod(const char *ini_value, int def_val)
|
|
{
|
|
if (strcmp(ini_value, "BL_PWM_NEGATIVE") == 0)
|
|
return BL_PWM_NEGATIVE;
|
|
else if (strcmp(ini_value, "BL_PWM_POSITIVE") == 0)
|
|
return BL_PWM_POSITIVE;
|
|
else
|
|
return def_val;
|
|
}
|
|
|
|
static char *bl_pwm_name[] = {
|
|
"BL_PWM_A",
|
|
"BL_PWM_B",
|
|
"BL_PWM_C",
|
|
"BL_PWM_D",
|
|
"BL_PWM_E",
|
|
"BL_PWM_F",
|
|
"BL_PWM_G",
|
|
"BL_PWM_H",
|
|
"BL_PWM_I",
|
|
"BL_PWM_J"
|
|
};
|
|
|
|
static char *bl_pwm_ao_name[] = {
|
|
"BL_PWM_AO_A",
|
|
"BL_PWM_AO_B",
|
|
"BL_PWM_AO_C",
|
|
"BL_PWM_AO_D",
|
|
"BL_PWM_AO_E",
|
|
"BL_PWM_AO_F",
|
|
"BL_PWM_AO_G",
|
|
"BL_PWM_AO_H"
|
|
};
|
|
|
|
static char bl_pwm_vs_name[] = {"BL_PWM_VS"};
|
|
|
|
static unsigned int getPWMPortIndVal(const char *str)
|
|
{
|
|
enum bl_pwm_port_e pwm_port = BL_PWM_MAX;
|
|
int i, cnt;
|
|
|
|
cnt = ARRAY_SIZE(bl_pwm_name);
|
|
for (i = 0; i < cnt; i++) {
|
|
if (strcmp(str, bl_pwm_name[i]) == 0) {
|
|
pwm_port = i + BL_PWM_A;
|
|
return pwm_port;
|
|
}
|
|
}
|
|
|
|
cnt = ARRAY_SIZE(bl_pwm_ao_name);
|
|
for (i = 0; i < cnt; i++) {
|
|
if (strcmp(str, bl_pwm_ao_name[i]) == 0) {
|
|
pwm_port = i + BL_PWM_AO_A;
|
|
return pwm_port;
|
|
}
|
|
}
|
|
|
|
if (strcmp(str, bl_pwm_vs_name) == 0) {
|
|
pwm_port = BL_PWM_VS;
|
|
return pwm_port;
|
|
}
|
|
|
|
return BL_PWM_MAX;
|
|
}
|
|
|
|
static int handle_bl_pwm(struct bl_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_method", "BL_PWM_POSITIVE");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_method is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_method = getPWMMethod(ini_value, BL_PWM_POSITIVE);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_port", "null");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_port is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_port = getPWMPortIndVal(ini_value);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_freq", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_freq is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_freq = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_duty_max", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_duty_max is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_duty_max = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_duty_min", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_duty_min is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_duty_min = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_gpio", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_gpio is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_gpio = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_gpio_off", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_gpio_off is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_gpio_off = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm2_method", "BL_PWM_POSITIVE");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm2_method is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm2_method = getPWMMethod(ini_value, BL_PWM_POSITIVE);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm2_port", "null");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm2_port is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm2_port = getPWMPortIndVal(ini_value);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm2_freq", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm2_freq is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm2_freq = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm2_duty_max", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm2_duty_max is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm2_duty_max = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm2_duty_min", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm2_duty_min is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm2_duty_min = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm2_gpio", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm2_gpio is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm2_gpio = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm2_gpio_off", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm2_gpio_off is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm2_gpio_off = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_on_delay", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_on_delay is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_on_delay = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_off_delay", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_off_delay is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_off_delay = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_level_max", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_level_max is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_level_max = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm_level_min", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm_level_min is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm_level_min = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm2_level_max", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm2_level_max is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm2_level_max = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "pwm2_level_min", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, pwm2_level_min is (%s)\n", __func__, ini_value);
|
|
p_attr->pwm.pwm2_level_min = strtoul(ini_value, NULL, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_bl_ldim(struct bl_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_ldim_row", "1");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_ldim_row is (%s)\n", __func__, ini_value);
|
|
p_attr->ldim.ldim_row = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_ldim_col", "1");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_ldim_col is (%s)\n", __func__, ini_value);
|
|
p_attr->ldim.ldim_col = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_ldim_mode", "null");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_ldim_mode is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "LDIM_LR_SIDE") == 0)
|
|
p_attr->ldim.ldim_mode = LDIM_MODE_LR_SIDE;
|
|
else if (strcmp(ini_value, "LDIM_TB_SIDE") == 0)
|
|
p_attr->ldim.ldim_mode = LDIM_MODE_TB_SIDE;
|
|
else if (strcmp(ini_value, "LDIM_DIRECT") == 0)
|
|
p_attr->ldim.ldim_mode = LDIM_MODE_DIRECT;
|
|
else
|
|
p_attr->ldim.ldim_mode = LDIM_MODE_TB_SIDE;
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_ldim_dev_index", "0xff");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_ldim_dev_index is (%s)\n", __func__, ini_value);
|
|
p_attr->ldim.ldim_dev_index = strtoul(ini_value, NULL, 0);
|
|
|
|
p_attr->ldim.ldim_attr_4 = 0;
|
|
p_attr->ldim.ldim_attr_5 = 0;
|
|
p_attr->ldim.ldim_attr_6 = 0;
|
|
p_attr->ldim.ldim_attr_7 = 0;
|
|
p_attr->ldim.ldim_attr_8 = 0;
|
|
p_attr->ldim.ldim_attr_9 = 0;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_bl_custome(struct bl_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_custome_val_0", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_custome_val_0 is (%s)\n", __func__, ini_value);
|
|
p_attr->custome.custome_val_0 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_custome_val_1", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_custome_val_1 is (%s)\n", __func__, ini_value);
|
|
p_attr->custome.custome_val_1 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_custome_val_2", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_custome_val_2 is (%s)\n", __func__, ini_value);
|
|
p_attr->custome.custome_val_2 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_custome_val_3", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_custome_val_3 is (%s)\n", __func__, ini_value);
|
|
p_attr->custome.custome_val_3 = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "bl_custome_val_4", "0");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, bl_custome_val_4 is (%s)\n", __func__, ini_value);
|
|
p_attr->custome.custome_val_4 = strtoul(ini_value, NULL, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_bl_header(struct bl_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("Backlight_Attr", "version", "null");
|
|
if (model_debug_flag & DEBUG_BACKLIGHT)
|
|
ALOGD("%s, version is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null") == 0)
|
|
p_attr->head.version = 0;
|
|
else
|
|
p_attr->head.version = strtoul(ini_value, NULL, 0);
|
|
|
|
gBlDataCnt = 0;
|
|
gBlDataCnt += sizeof(struct lcd_header_s);
|
|
gBlDataCnt += sizeof(struct bl_basic_s);
|
|
gBlDataCnt += sizeof(struct bl_level_s);
|
|
gBlDataCnt += sizeof(struct bl_method_s);
|
|
gBlDataCnt += sizeof(struct bl_pwm_s);
|
|
if (p_attr->head.version == 2) {
|
|
gBlDataCnt += sizeof(struct bl_ldim_s);
|
|
gBlDataCnt += sizeof(struct bl_custome_s);
|
|
}
|
|
p_attr->head.data_len = gBlDataCnt;
|
|
|
|
p_attr->head.block_next_flag = 0;
|
|
p_attr->head.block_cur_size = gBlDataCnt;
|
|
p_attr->head.crc32 = CalCRC32(0, (((unsigned char *)p_attr) + 4), gBlDataCnt - 4);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_panel_misc(struct panel_misc_s *p_misc)
|
|
{
|
|
int tmp_val = 0;
|
|
const char *ini_value = NULL;
|
|
char buf[64] = {0};
|
|
|
|
ini_value = IniGetString("panel_misc", "panel_misc_version", "null");
|
|
if (model_debug_flag & DEBUG_MISC)
|
|
ALOGD("%s, panel_misc_version is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null") == 0) {
|
|
strcpy(p_misc->version, "V001");
|
|
} else {
|
|
tmp_val = strtol(ini_value, NULL, 0);
|
|
if (tmp_val < 1)
|
|
tmp_val = 1;
|
|
|
|
sprintf(p_misc->version, "V%03d", tmp_val);
|
|
}
|
|
|
|
tmp_val = getenv_ulong("model_outputmode_bypass", 10, 0);
|
|
if (tmp_val) {
|
|
ALOGI("model_outputmode_bypass\n");
|
|
goto handle_panel_misc_next;
|
|
}
|
|
ini_value = IniGetString("panel_misc", "outputmode2", "null");
|
|
if (model_debug_flag & DEBUG_MISC)
|
|
ALOGD("%s, outputmode2 is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null") == 0) {
|
|
ini_value = IniGetString("panel_misc", "outputmode", "null");
|
|
if (model_debug_flag & DEBUG_MISC)
|
|
ALOGD("%s, outputmode is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null")) {
|
|
strncpy(p_misc->outputmode, ini_value,
|
|
sizeof(p_misc->outputmode) - 1);
|
|
p_misc->outputmode[sizeof(p_misc->outputmode) - 1]
|
|
= '\0';
|
|
snprintf(buf, 63, "setenv outputmode %s", p_misc->outputmode);
|
|
run_command(buf, 0);
|
|
}
|
|
} else {
|
|
strncpy(p_misc->outputmode, ini_value, 63);
|
|
snprintf(buf, 63, "setenv outputmode2 %s", p_misc->outputmode);
|
|
run_command(buf, 0);
|
|
}
|
|
|
|
handle_panel_misc_next:
|
|
tmp_val = getenv_ulong("model_connector_bypass", 10, 0);
|
|
if (tmp_val) {
|
|
ALOGI("model_connector_bypass\n");
|
|
goto handle_panel_misc_next2;
|
|
}
|
|
ini_value = IniGetString("panel_misc", "connector_type", "null");
|
|
if (model_debug_flag & DEBUG_MISC)
|
|
ALOGD("%s, connector_type is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null")) {
|
|
strncpy(p_misc->connector_type, ini_value,
|
|
sizeof(p_misc->connector_type) - 1);
|
|
p_misc->connector_type[sizeof(p_misc->connector_type) - 1] = '\0';
|
|
snprintf(buf, 63, "setenv connector_type %s", p_misc->connector_type);
|
|
run_command(buf, 0);
|
|
} else {
|
|
run_command("setenv connector_type null", 0);
|
|
}
|
|
|
|
handle_panel_misc_next2:
|
|
ini_value = IniGetString("panel_misc", "panel_reverse", "null");
|
|
if (model_debug_flag & DEBUG_MISC)
|
|
ALOGD("%s, panel_reverse is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null") == 0 || strcmp(ini_value, "0") == 0 ||
|
|
strcmp(ini_value, "false") == 0 || strcmp(ini_value, "no_rev") == 0) {
|
|
p_misc->panel_reverse = 0;
|
|
} else if (strcmp(ini_value, "true") == 0 || strcmp(ini_value, "1") == 0 ||
|
|
strcmp(ini_value, "have_rev") == 0) {
|
|
p_misc->panel_reverse = 1;
|
|
} else if (strcmp(ini_value, "x_rev") == 0 || strcmp(ini_value, "2") == 0) {
|
|
p_misc->panel_reverse = 2;
|
|
} else if (strcmp(ini_value, "y_rev") == 0 || strcmp(ini_value, "3") == 0) {
|
|
p_misc->panel_reverse = 3;
|
|
} else {
|
|
p_misc->panel_reverse = 0;
|
|
}
|
|
|
|
switch (p_misc->panel_reverse) {
|
|
case 1:
|
|
run_command("setenv panel_reverse 1", 0);
|
|
run_command("setenv osd_reverse all,true", 0);
|
|
run_command("setenv video_reverse 1", 0);
|
|
break;
|
|
case 2:
|
|
run_command("setenv panel_reverse 2", 0);
|
|
run_command("setenv osd_reverse all,x_rev", 0);
|
|
run_command("setenv video_reverse 2", 0);
|
|
break;
|
|
case 3:
|
|
run_command("setenv panel_reverse 3", 0);
|
|
run_command("setenv osd_reverse all,y_rev", 0);
|
|
run_command("setenv video_reverse 3", 0);
|
|
break;
|
|
default:
|
|
run_command("setenv panel_reverse 0", 0);
|
|
run_command("setenv osd_reverse n", 0);
|
|
run_command("setenv video_reverse 0", 0);
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_optical_attr(struct lcd_optical_attr_s *p_attr)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "version", "null");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, version is (%s)\n", __func__, ini_value);
|
|
if (strcmp(ini_value, "null") == 0) {
|
|
glcd_optical_dcnt = 0;
|
|
return -1;
|
|
}
|
|
p_attr->head.version = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "hdr_support", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, hdr_support is (%s)\n", __func__, ini_value);
|
|
p_attr->hdr_support = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "features", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, features is (%s)\n", __func__, ini_value);
|
|
p_attr->features = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "primaries_r_x", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, primaries_r_x is (%s)\n", __func__, ini_value);
|
|
p_attr->primaries_r_x = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "primaries_r_y", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, primaries_r_y is (%s)\n", __func__, ini_value);
|
|
p_attr->primaries_r_y = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "primaries_g_x", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, primaries_g_x is (%s)\n", __func__, ini_value);
|
|
p_attr->primaries_g_x = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "primaries_g_y", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, primaries_g_y is (%s)\n", __func__, ini_value);
|
|
p_attr->primaries_g_y = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "primaries_b_x", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, primaries_b_x is (%s)\n", __func__, ini_value);
|
|
p_attr->primaries_b_x = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "primaries_b_y", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, primaries_b_y is (%s)\n", __func__, ini_value);
|
|
p_attr->primaries_b_y = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "white_point_x", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, white_point_x is (%s)\n", __func__, ini_value);
|
|
p_attr->white_point_x = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "white_point_y", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, white_point_y is (%s)\n", __func__, ini_value);
|
|
p_attr->white_point_y = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "luma_max", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, luma_max is (%s)\n", __func__, ini_value);
|
|
p_attr->luma_max = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "luma_min", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, luma_min is (%s)\n", __func__, ini_value);
|
|
p_attr->luma_min = strtoul(ini_value, NULL, 0);
|
|
|
|
ini_value = IniGetString("lcd_optical_Attr", "luma_avg", "0");
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, luma_avg is (%s)\n", __func__, ini_value);
|
|
p_attr->luma_avg = strtoul(ini_value, NULL, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int handle_lcd_optical_header(struct lcd_optical_attr_s *p_attr)
|
|
{
|
|
unsigned char *tmp_buf = NULL;
|
|
|
|
glcd_optical_dcnt = sizeof(struct lcd_optical_attr_s);
|
|
|
|
tmp_buf = (unsigned char *)malloc(glcd_optical_dcnt);
|
|
if (!tmp_buf) {
|
|
ALOGE("%s, malloc buffer memory error!!!\n", __func__);
|
|
return -1;
|
|
}
|
|
memset((void *)tmp_buf, 0, glcd_optical_dcnt);
|
|
|
|
p_attr->head.data_len = glcd_optical_dcnt;
|
|
|
|
p_attr->head.block_next_flag = 0;
|
|
p_attr->head.block_cur_size = glcd_optical_dcnt;
|
|
|
|
memcpy(tmp_buf, p_attr, glcd_optical_dcnt);
|
|
p_attr->head.crc32 = CalCRC32(0, (tmp_buf + 4), glcd_optical_dcnt - 4);
|
|
|
|
if (model_debug_flag & DEBUG_LCD_OPTICAL)
|
|
ALOGD("%s, glcd_optical_dcnt = %d\n", __func__, glcd_optical_dcnt);
|
|
|
|
free(tmp_buf);
|
|
tmp_buf = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int parse_panel_ini(const char *file_name, unsigned char *lcd_buf,
|
|
struct lcd_ext_attr_s *ext_attr,
|
|
struct bl_attr_s *bl_attr,
|
|
struct panel_misc_s *misc_attr,
|
|
struct lcd_optical_attr_s *optical_attr)
|
|
{
|
|
struct lcd_attr_s *lcd_attr;
|
|
unsigned char *lcd_next_attr;
|
|
struct lcd_header_s *header, *next_header = NULL;
|
|
int ret;
|
|
|
|
IniParserInit();
|
|
|
|
if (IniParseFile(file_name) < 0) {
|
|
ALOGE("%s, ini load file error!\n", __func__);
|
|
IniParserUninit();
|
|
return -1;
|
|
}
|
|
|
|
// handle integrity flag
|
|
if (handle_integrity_flag() < 0) {
|
|
ALOGE("%s, handle_integrity_flag error!\n", __func__);
|
|
IniParserUninit();
|
|
return -1;
|
|
}
|
|
|
|
/* handle lcd attr */
|
|
lcd_attr = (struct lcd_attr_s *)lcd_buf;
|
|
handle_lcd_basic(lcd_attr);
|
|
handle_lcd_timming(lcd_attr);
|
|
handle_lcd_customer(lcd_attr);
|
|
handle_lcd_interface(lcd_attr);
|
|
handle_lcd_pwr(lcd_attr);
|
|
handle_lcd_header(lcd_attr);
|
|
|
|
header = &lcd_attr->head;
|
|
lcd_next_attr = lcd_buf + header->block_cur_size;
|
|
next_header = (struct lcd_header_s *)lcd_next_attr;
|
|
if (header->version == 2) {
|
|
handle_lcd_phy(lcd_next_attr);
|
|
handle_lcd_cus_ctrl(lcd_next_attr, header->version);
|
|
handle_lcd_v2_header(next_header);
|
|
} else if (header->version == 3) {
|
|
handle_lcd_cus_ctrl(lcd_next_attr, header->version);
|
|
handle_lcd_v3_header(next_header);
|
|
}
|
|
|
|
gLcdDataCnt = header->block_cur_size + next_header->block_cur_size;
|
|
header->data_len = gLcdDataCnt;
|
|
header->crc32 = CalCRC32(0, (lcd_buf + 4), gLcdDataCnt - 4);
|
|
if (model_debug_flag & DEBUG_LCD) {
|
|
ALOGD("%s: version=%d, data_len=%d, glcd_dcnt=%d, block1_size=%d, block2_size=%d\n",
|
|
__func__, header->version, header->data_len, gLcdDataCnt,
|
|
header->block_cur_size, next_header->block_cur_size);
|
|
}
|
|
|
|
if (g_lcd_if == LCD_MLVDS ||
|
|
g_lcd_if == LCD_P2P)
|
|
g_lcd_tcon_valid = 1;
|
|
else
|
|
g_lcd_tcon_valid = 0;
|
|
|
|
#ifdef CONFIG_AML_LCD_TCON
|
|
/*should ready tcon path here, for lcd_ext usage */
|
|
if (g_lcd_tcon_valid)
|
|
handle_tcon_path();
|
|
#endif
|
|
|
|
// handle lcd extern attr
|
|
handle_lcd_ext_basic(ext_attr);
|
|
handle_lcd_ext_type(ext_attr);
|
|
handle_lcd_ext_cmd_data(ext_attr);
|
|
handle_lcd_ext_header(ext_attr);
|
|
|
|
// handle bl attr
|
|
handle_bl_basic(bl_attr);
|
|
handle_bl_level(bl_attr);
|
|
handle_bl_method(bl_attr);
|
|
handle_bl_pwm(bl_attr);
|
|
handle_bl_ldim(bl_attr);
|
|
handle_bl_custome(bl_attr);
|
|
handle_bl_header(bl_attr);
|
|
|
|
handle_panel_misc(misc_attr);
|
|
|
|
// handle lcd optical attr
|
|
ret = handle_lcd_optical_attr(optical_attr);
|
|
if (ret == 0)
|
|
handle_lcd_optical_header(optical_attr);
|
|
|
|
IniParserUninit();
|
|
|
|
return 0;
|
|
}
|
|
|
|
int handle_panel_ini(void)
|
|
{
|
|
int tmp_len = 0;
|
|
unsigned char *tmp_buf = NULL;
|
|
unsigned char *lcd_buf = NULL;
|
|
struct bl_attr_s *bl_attr = NULL;
|
|
struct panel_misc_s misc_attr;
|
|
struct lcd_optical_attr_s *optical_attr = NULL;
|
|
char *file_name;
|
|
int print_flag;
|
|
|
|
print_flag = getenv_ulong("model_debug_print", 10, 0xffff);
|
|
if (print_flag != 0xffff) {
|
|
model_debug_flag = print_flag;
|
|
ALOGD("model_debug_flag: 0x%x\n", model_debug_flag);
|
|
}
|
|
|
|
file_name = getenv("model_panel");
|
|
if (!file_name) {
|
|
ALOGE("%s, model_panel path error!!!\n", __func__);
|
|
return -1;
|
|
}
|
|
|
|
tmp_buf = (unsigned char *)malloc(CC_MAX_DATA_SIZE);
|
|
if (!tmp_buf) {
|
|
ALOGE("%s, malloc buffer memory error!!!\n", __func__);
|
|
return -1;
|
|
}
|
|
memset((void *)tmp_buf, 0, CC_MAX_DATA_SIZE);
|
|
|
|
lcd_buf = (unsigned char *)malloc(CC_MAX_DATA_SIZE);
|
|
if (!lcd_buf) {
|
|
ALOGE("%s, malloc buffer memory error!!!\n", __func__);
|
|
goto handle_panel_ini_err0;
|
|
}
|
|
memset((void *)lcd_buf, 0, CC_MAX_DATA_SIZE);
|
|
|
|
if (!lcd_ext_attr) {
|
|
lcd_ext_attr = (struct lcd_ext_attr_s *)malloc(sizeof(struct lcd_ext_attr_s));
|
|
if (!lcd_ext_attr) {
|
|
ALOGE("%s, malloc buffer memory error!!!\n", __func__);
|
|
goto handle_panel_ini_err1;
|
|
}
|
|
}
|
|
memset((void *)lcd_ext_attr, 0, sizeof(struct lcd_ext_attr_s));
|
|
|
|
bl_attr = (struct bl_attr_s *)malloc(sizeof(struct bl_attr_s));
|
|
if (!bl_attr) {
|
|
ALOGE("%s, malloc buffer memory error!!!\n", __func__);
|
|
goto handle_panel_ini_err1;
|
|
}
|
|
memset((void *)bl_attr, 0, sizeof(struct bl_attr_s));
|
|
|
|
optical_attr = (struct lcd_optical_attr_s *)malloc(sizeof(struct lcd_optical_attr_s));
|
|
if (!optical_attr) {
|
|
ALOGE("%s, malloc buffer memory error!!!\n", __func__);
|
|
goto handle_panel_ini_err2;
|
|
}
|
|
memset((void *)optical_attr, 0, sizeof(struct lcd_optical_attr_s));
|
|
|
|
//init misc attr as default
|
|
memset((void *)&misc_attr, 0, sizeof(struct panel_misc_s));
|
|
strcpy(misc_attr.version, "V001");
|
|
strcpy(misc_attr.outputmode, "1080p60hz");
|
|
misc_attr.panel_reverse = 0;
|
|
|
|
// start handle panel ini name
|
|
if (model_debug_flag & DEBUG_NORMAL)
|
|
ALOGD("%s: model_panel: %s\n", __func__, file_name);
|
|
if (parse_panel_ini(file_name, lcd_buf, lcd_ext_attr, bl_attr, &misc_attr,
|
|
optical_attr) < 0) {
|
|
ALOGE("%s, parse_panel_ini file name \"%s\" fail.\n",
|
|
__func__, file_name);
|
|
goto handle_panel_ini_err3;
|
|
}
|
|
|
|
// start handle lcd param
|
|
memset((void *)tmp_buf, 0, CC_MAX_DATA_SIZE);
|
|
tmp_len = ReadLCDParam(tmp_buf, CC_MAX_DATA_SIZE);
|
|
//ALOGD("%s, start check lcd param data (0x%x).\n", __func__, tmp_len);
|
|
if (check_param_valid(0, gLcdDataCnt, lcd_buf, tmp_len, tmp_buf) ==
|
|
CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM) {
|
|
ALOGD("%s, check lcd param data diff (0x%x), save new param.\n",
|
|
__func__, tmp_len);
|
|
SaveLCDParam(gLcdDataCnt, lcd_buf);
|
|
}
|
|
// end handle lcd param
|
|
|
|
// start handle lcd extern param
|
|
memset((void *)tmp_buf, 0, CC_MAX_DATA_SIZE);
|
|
tmp_len = ReadLCDExternParam(tmp_buf, CC_MAX_DATA_SIZE);
|
|
//ALOGD("%s, start check lcd extern param data (0x%x).\n", __func__, tmp_len);
|
|
if (check_param_valid(0, gLcdExtDataCnt, (unsigned char *)lcd_ext_attr, tmp_len, tmp_buf) ==
|
|
CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM) {
|
|
ALOGD("%s, check lcd extern param data diff (0x%x), save new param.\n",
|
|
__func__, tmp_len);
|
|
SaveLCDExternParam(gLcdExtDataCnt, (unsigned char*)lcd_ext_attr);
|
|
}
|
|
// end handle lcd extern param
|
|
|
|
// start handle backlight param
|
|
memset((void *)tmp_buf, 0, CC_MAX_DATA_SIZE);
|
|
tmp_len = ReadBackLightParam(tmp_buf, CC_MAX_DATA_SIZE);
|
|
//ALOGD("%s, start check backlight param data (0x%x).\n", __func__, tmp_len);
|
|
if (check_param_valid(0, gBlDataCnt, (unsigned char *)bl_attr, tmp_len, tmp_buf) ==
|
|
CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM) {
|
|
ALOGD("%s, check backlight param data diff (0x%x), save new param.\n",
|
|
__func__, tmp_len);
|
|
SaveBackLightParam(gBlDataCnt, (unsigned char *)bl_attr);
|
|
}
|
|
// end handle backlight param
|
|
|
|
// start handle lcd_optical param
|
|
if (glcd_optical_dcnt) {
|
|
memset((void *)tmp_buf, 0, CC_MAX_DATA_SIZE);
|
|
tmp_len = ReadLcdOpticalParam(tmp_buf, CC_MAX_DATA_SIZE);
|
|
//ALOGD("%s, start check lcd_tcon_spi param data (0x%x).\n", __func__, tmp_len);
|
|
if (check_param_valid(0, glcd_optical_dcnt, (unsigned char *)optical_attr,
|
|
tmp_len, tmp_buf) == CC_PARAM_CHECK_ERROR_NEED_UPDATE_PARAM) {
|
|
ALOGD("%s, check lcd_optical param data diff (0x%x), save new param.\n",
|
|
__func__, tmp_len);
|
|
SaveLcdOpticalParam(glcd_optical_dcnt, (unsigned char *)optical_attr);
|
|
}
|
|
}
|
|
// end handle lcd_optical param
|
|
|
|
memset((void *)optical_attr, 0, sizeof(struct lcd_optical_attr_s));
|
|
free(optical_attr);
|
|
memset((void *)bl_attr, 0, sizeof(struct bl_attr_s));
|
|
free(bl_attr);
|
|
memset((void *)lcd_buf, 0, CC_MAX_DATA_SIZE);
|
|
free(lcd_buf);
|
|
memset((void *)tmp_buf, 0, CC_MAX_DATA_SIZE);
|
|
free(tmp_buf);
|
|
|
|
#ifdef CONFIG_AML_LCD_TCON
|
|
if (g_lcd_tcon_valid)
|
|
handle_tcon_bin();
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
handle_panel_ini_err3:
|
|
memset((void *)optical_attr, 0, sizeof(struct lcd_optical_attr_s));
|
|
free(optical_attr);
|
|
handle_panel_ini_err2:
|
|
memset((void *)bl_attr, 0, sizeof(struct bl_attr_s));
|
|
free(bl_attr);
|
|
handle_panel_ini_err1:
|
|
memset((void *)lcd_buf, 0, CC_MAX_DATA_SIZE);
|
|
free(lcd_buf);
|
|
handle_panel_ini_err0:
|
|
memset((void *)tmp_buf, 0, CC_MAX_DATA_SIZE);
|
|
free(tmp_buf);
|
|
|
|
return -1;
|
|
}
|
|
|
|
static void model_list_panel_path(void)
|
|
{
|
|
char *str;
|
|
|
|
str = getenv("model_panel");
|
|
if (str)
|
|
printf("current model_panel: %s\n", str);
|
|
}
|
|
#endif
|
|
|
|
int parse_model_sum(const char *file_name, char *model_name)
|
|
{
|
|
const char *ini_value = NULL;
|
|
|
|
IniParserInit();
|
|
|
|
if (IniParseFile(file_name) < 0) {
|
|
ALOGE("%s, ini load file error!\n", __func__);
|
|
IniParserUninit();
|
|
return -1;
|
|
}
|
|
|
|
#ifdef CONFIG_AML_LCD
|
|
ini_value = IniGetString(model_name, "PANELINI_PATH", "null");
|
|
if (strcmp(ini_value, "null") != 0)
|
|
setenv("model_panel", ini_value);
|
|
else
|
|
ALOGE("%s, invalid PANELINI_PATH!!!\n", __func__);
|
|
#endif
|
|
|
|
ini_value = IniGetString(model_name, "EDID_14_FILE_PATH", "null");
|
|
if (strcmp(ini_value, "null") != 0)
|
|
setenv("model_edid", ini_value);
|
|
else
|
|
ALOGE("%s, invalid EDID_14_FILE_PATH!!!\n", __func__);
|
|
/*
|
|
ini_value = IniGetString(model_name, "PQINI_PATH", "null");
|
|
if (strcmp(ini_value, "null") != 0)
|
|
setenv("model_pq", ini_value);
|
|
|
|
ini_value = IniGetString(model_name, "AMLOGIC_AUDIO_EFFECT_INI_PATH", "null");
|
|
if (strcmp(ini_value, "null") != 0)
|
|
setenv("model_audio", ini_value);
|
|
*/
|
|
IniParserUninit();
|
|
|
|
return 0;
|
|
}
|
|
|
|
const char *get_model_sum_path(void)
|
|
{
|
|
char *model_path;
|
|
|
|
model_path = getenv("model_path");
|
|
if (model_path == NULL) {
|
|
if (dynamic_partition) {
|
|
return DEFAULT_MODEL_SUM_PATH2;
|
|
} else {
|
|
return DEFAULT_MODEL_SUM_PATH1;
|
|
}
|
|
}
|
|
|
|
printf("%s: %s\n", __func__, model_path);
|
|
return model_path;
|
|
}
|
|
|
|
int handle_model_list(void)
|
|
{
|
|
char *model;
|
|
|
|
model = getenv("model_name");
|
|
if (model == NULL) {
|
|
ALOGE("%s, model_name error!!!\n", __func__);
|
|
return -1;
|
|
}
|
|
printf("current model_name: %s\n", model);
|
|
#ifdef CONFIG_AML_LCD
|
|
model_list_panel_path();
|
|
#endif
|
|
|
|
IniParserInit();
|
|
|
|
if (IniParseFile(get_model_sum_path()) < 0) {
|
|
ALOGE("%s, ini load file error!\n", __func__);
|
|
IniParserUninit();
|
|
return -1;
|
|
}
|
|
|
|
printf("model_name list:\n");
|
|
IniListSection();
|
|
printf("\n");
|
|
|
|
IniParserUninit();
|
|
|
|
return 0;
|
|
}
|
|
|
|
int handle_model_sum(void)
|
|
{
|
|
char *model;
|
|
int ret;
|
|
|
|
model = getenv("model_name");
|
|
if (model == NULL) {
|
|
ALOGE("%s, model_name error!!!\n", __func__);
|
|
return -1;
|
|
}
|
|
ret = parse_model_sum(get_model_sum_path(), model);
|
|
if (ret < 0)
|
|
return -1;
|
|
#ifdef CONFIG_AML_LCD
|
|
ret = handle_panel_ini();
|
|
#endif
|
|
return ret;
|
|
}
|
|
|