static int init_gamma_table(struct lcd_info *lcd) { int i, ret = 0; lcd->gamma_table = kzalloc(GAMMA_MAX * sizeof(u8 *), GFP_KERNEL); if (IS_ERR_OR_NULL(lcd->gamma_table)) { pr_err("failed to allocate gamma table\n"); ret = -ENOMEM; goto err_alloc_gamma_table; } for (i = 0; i < GAMMA_MAX; i++) { lcd->gamma_table[i] = kzalloc(GAMMA_PARAM_SIZE * sizeof(u8), GFP_KERNEL); if (IS_ERR_OR_NULL(lcd->gamma_table[i])) { pr_err("failed to allocate gamma\n"); ret = -ENOMEM; goto err_alloc_gamma; } lcd->gamma_table[i][0] = 0xFA; lcd->gamma_table[i][1] = 0x01; } for (i = 0; i < GAMMA_MAX; i++) { if (candela_table[i] <= 180) calc_gamma_table(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][2], G_21); else if (candela_table[i] > 250) calc_gamma_table(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][2], G_22); else if (candela_table[i] == 190) calc_gamma_table_215_190(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][2]); else calc_gamma_table(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][2], G_215); } #ifdef SMART_DIMMING_DEBUG for (i = 0; i < GAMMA_MAX; i++) { for (j = 0; j < GAMMA_PARAM_SIZE; j++) printk("%d, ", lcd->gamma_table[i][j]); printk("\n"); } #endif return 0; err_alloc_gamma: while (i > 0) { kfree(lcd->gamma_table[i-1]); i--; } kfree(lcd->gamma_table); err_alloc_gamma_table: return ret; }
static int init_gamma_table(struct lcd_info *lcd , const u8 *mtp_data) { int i, j, ret = 0; lcd->gamma_table = kzalloc(GAMMA_MAX * sizeof(u8 *), GFP_KERNEL); if (IS_ERR_OR_NULL(lcd->gamma_table)) { pr_err("failed to allocate gamma table\n"); ret = -ENOMEM; goto err_alloc_gamma_table; } for (i = 0; i < GAMMA_MAX; i++) { lcd->gamma_table[i] = kzalloc(GAMMA_PARAM_SIZE * sizeof(u8), GFP_KERNEL); if (IS_ERR_OR_NULL(lcd->gamma_table[i])) { pr_err("failed to allocate gamma\n"); ret = -ENOMEM; goto err_alloc_gamma; } lcd->gamma_table[i][0] = 0xCA; } if ((lcd->id[2] == 0x00) || (lcd->id[2] == 0x01)) { lcd->aid = aid_setting_table_VT888; for (i = 0; i < ARRAY_SIZE(aid_setting_table_VT888); i++) calc_gamma_table(&lcd->smart, lcd->aid, &lcd->gamma_table[i][1], mtp_data, i); } if (lcd->id[2] == 0x02) { lcd->aid = aid_setting_table_VT232; for (i = 0; i < ARRAY_SIZE(aid_setting_table_VT232); i++) calc_gamma_table(&lcd->smart, lcd->aid, &lcd->gamma_table[i][1], mtp_data, i); } for (i = 0; i < GAMMA_MAX; i++) { for (j = 0; j < GAMMA_PARAM_SIZE; j++) smtd_dbg("%d,", lcd->gamma_table[i][j]); smtd_dbg("\n"); } smtd_dbg("\n"); return 0; err_alloc_gamma: while (i > 0) { kfree(lcd->gamma_table[i-1]); i--; } kfree(lcd->gamma_table); err_alloc_gamma_table: return ret; }
static int ea8061_gamma_ctrl(struct ea8061 *lcd, int brightness) { struct mipi_dsim_master_ops *ops = lcd_to_master_ops(lcd); #ifdef CONFIG_BACKLIGHT_SMART_DIMMING unsigned int gamma; unsigned char gamma_set[GAMMA_TABLE_COUNT] = {0,}; gamma = convert_brightness_to_gamma(brightness); gamma_set[0] = 0xfa; gamma_set[1] = 0x01; calc_gamma_table(&lcd->smart_dim, gamma, gamma_set + 2); ops->cmd_write(lcd_to_master(lcd), MIPI_DSI_DCS_LONG_WRITE, (unsigned int)gamma_set, GAMMA_TABLE_COUNT); #else ops->cmd_write(lcd_to_master(lcd), MIPI_DSI_DCS_LONG_WRITE, (unsigned int)ea8061_gamma22_table[brightness], GAMMA_TABLE_COUNT); #endif /* update gamma table. */ ops->cmd_write(lcd_to_master(lcd), MIPI_DSI_DCS_SHORT_WRITE_PARAM, 0xf7, 0x03); ea8061_acl_on(lcd); return 0; }
static void lcd_gamma_smartDimming_apply( struct msm_fb_data_type *mfd, int srcGamma) { int gamma_lux; char pBuffer[256]; int i; gamma_lux = s6e8aa0_lcd.lcd_brightness_table[srcGamma].lux; if( gamma_lux > SmartDimming_CANDELA_UPPER_LIMIT ) gamma_lux = SmartDimming_CANDELA_UPPER_LIMIT; for( i = SmartDimming_GammaUpdate_Pos; i < sizeof(GAMMA_SmartDimming_COND_SET); i++ ) GAMMA_SmartDimming_COND_SET[i] = 0; calc_gamma_table(&(s6e8aa0_lcd.smart), gamma_lux, GAMMA_SmartDimming_COND_SET +SmartDimming_GammaUpdate_Pos); #ifdef SmartDimming_16bitBugFix if( gamma_lux > SmartDimming_CANDELA_UPPER_LIMIT /2 ) { if( (int)GAMMA_SmartDimming_COND_SET[21] < 0x70 && GAMMA_SmartDimming_COND_SET[20] == 0 ) GAMMA_SmartDimming_COND_SET[20] =1; if( (int)GAMMA_SmartDimming_COND_SET[23] < 0x70 && GAMMA_SmartDimming_COND_SET[22] == 0 ) GAMMA_SmartDimming_COND_SET[22] =1; if( (int)GAMMA_SmartDimming_COND_SET[25] < 0x70 && GAMMA_SmartDimming_COND_SET[24] == 0 ) GAMMA_SmartDimming_COND_SET[24] =1; } #endif pBuffer[0] = 0; for( i =0; i < sizeof(GAMMA_SmartDimming_COND_SET); i++ ) { sprintf( pBuffer+ strlen(pBuffer), " %02x", GAMMA_SmartDimming_COND_SET[i] ); } DPRINT( "SD: %03d %s\n", gamma_lux, pBuffer ); mipi_dsi_cmds_tx(mfd, &s6e8aa0_tx_buf, &DSI_CMD_SmartDimming_GAMMA, 1); DPRINT( "SmartDimming : gamma %d = lux %d\n", srcGamma, gamma_lux ); }
static int s6e8aa0a01_init_gamma_table(struct s6e8aa0a01_data *s6) { int i, ret = 0; s6->gamma_table = kzalloc(GAMMA_MAX * sizeof(u8 *), GFP_KERNEL); if (IS_ERR_OR_NULL(s6->gamma_table)) { pr_err("failed to allocate gamma table\n"); ret = -ENOMEM; goto err_alloc_gamma_table; } for (i = 0; i < GAMMA_MAX; i++) { s6->gamma_table[i] = kzalloc(GAMMA_PARAM_SIZE * sizeof(u8), GFP_KERNEL); if (IS_ERR_OR_NULL(s6->gamma_table[i])) { pr_err("failed to allocate gamma\n"); ret = -ENOMEM; goto err_alloc_gamma; } s6->gamma_table[i][0] = 0xFA; s6->gamma_table[i][1] = 0x01; calc_gamma_table(&s6->smart, candela_table[i] - 1, s6->gamma_table[i] + 2); } return 0; err_alloc_gamma: while (i > 0) kfree(s6->gamma_table[--i]); kfree(s6->gamma_table); err_alloc_gamma_table: return ret; }
static int init_gamma_table(struct lcd_info *lcd , const u8 *mtp_data) { int i, j, ret = 0; lcd->gamma_table = kzalloc(GAMMA_MAX * sizeof(u8 *), GFP_KERNEL); if (IS_ERR_OR_NULL(lcd->gamma_table)) { pr_err("failed to allocate gamma table\n"); ret = -ENOMEM; goto err_alloc_gamma_table; } for (i = 0; i < GAMMA_MAX; i++) { lcd->gamma_table[i] = kzalloc(GAMMA_PARAM_SIZE * sizeof(u8), GFP_KERNEL); if (IS_ERR_OR_NULL(lcd->gamma_table[i])) { pr_err("failed to allocate gamma\n"); ret = -ENOMEM; goto err_alloc_gamma; } lcd->gamma_table[i][0] = 0xCA; } for (i = 0; i < GAMMA_MAX; i++) { if (candela_table[i] <= 108) calc_gamma_table(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][1], G_21, mtp_data); else if ((candela_table[i] > 110) && (candela_table[i] < 182)) calc_gamma_table(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][1], G_207, mtp_data); else if (candela_table[i] == 182) calc_gamma_table(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][1], G_208, mtp_data); else if (candela_table[i] == 184) calc_gamma_table(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][1], G_21, mtp_data); else if (candela_table[i] == 186) calc_gamma_table(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][1], G_212, mtp_data); else if (candela_table[i] == 188) calc_gamma_table(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][1], G_214, mtp_data); else calc_gamma_table(&lcd->smart, aid_candela_table[i], &lcd->gamma_table[i][1], G_215, mtp_data); } #ifdef SMART_DIMMING_DEBUG for (i = 0; i < GAMMA_MAX; i++) { for (j = 0; j < GAMMA_PARAM_SIZE; j++) printk("%d,", lcd->gamma_table[i][j]); printk("\n"); } #endif return 0; err_alloc_gamma: while (i > 0) { kfree(lcd->gamma_table[i-1]); i--; } kfree(lcd->gamma_table); err_alloc_gamma_table: return ret; }
int dynamic_aid(struct dynamic_aid_param_t param, int **gamma) { struct dynamic_aid_info d_aid; int ret; d_aid.param = param; d_aid.iv_tbl = (int *)param.iv_tbl; d_aid.iv_max = param.iv_max; d_aid.iv_top = param.iv_tbl[param.iv_max-1]; /* number of top voltage index: 255 */ d_aid.mtp = param.mtp; d_aid.vreg = MUL_100(param.vreg); d_aid.ibr_tbl = (int *)param.ibr_tbl; d_aid.ibr_max = param.ibr_max; d_aid.ibr_top = param.ibr_tbl[param.ibr_max-1]; /* number of top brightness : 300nt */ d_aid.point_voltages = kzalloc(sizeof(struct rgb64_t)*d_aid.iv_max, GFP_KERNEL); if (!d_aid.point_voltages) { printk(KERN_ERR "failed to allocate point_voltages\n"); ret = -ENOMEM; goto error1; } d_aid.output_voltages = kzalloc(sizeof(struct rgb64_t)*(d_aid.iv_top+1), GFP_KERNEL); if (!d_aid.output_voltages) { printk(KERN_ERR "failed to allocate output_voltages\n"); ret = -ENOMEM; goto error2; } d_aid.l_value = kzalloc(sizeof(int)*d_aid.iv_max, GFP_KERNEL); if (!d_aid.l_value) { printk(KERN_ERR "failed to allocate l_value\n"); ret = -ENOMEM; goto error3; } d_aid.l_lookup_table = kzalloc(sizeof(int)*(d_aid.iv_top+1), GFP_KERNEL); if (!d_aid.l_lookup_table) { printk(KERN_ERR "failed to allocate l_lookup_table\n"); ret = -ENOMEM; goto error4; } d_aid.m_gray = kzalloc(sizeof(int)*d_aid.iv_max, GFP_KERNEL); if (!d_aid.m_gray) { printk(KERN_ERR "failed to allocate m_gray\n"); ret = -ENOMEM; goto error5; } d_aid.m_voltage = kzalloc(sizeof(struct rgb64_t)*d_aid.iv_max, GFP_KERNEL); if (!d_aid.m_voltage) { printk(KERN_ERR "failed to allocate m_voltage\n"); ret = -ENOMEM; goto error6; } ret = calc_voltage_table(d_aid); if (ret) goto error7; ret = calc_gamma_table(d_aid, gamma); if (ret) goto error7; printk(KERN_INFO "Dynamic Aid Finished !\n"); error7: kfree(d_aid.m_voltage); error6: kfree(d_aid.m_gray); error5: kfree(d_aid.l_lookup_table); error4: kfree(d_aid.l_value); error3: kfree(d_aid.output_voltages); error2: kfree(d_aid.point_voltages); error1: return ret; }