int disp_aal_write_init_regs(void *cmdq) { int ret = -EFAULT; if (g_aal_is_init_regs_valid) { DISP_AAL_INITREG *init_regs = &g_aal_init_regs; int i, j; int *gain; DISP_REG_MASK(cmdq, DISP_AAL_DRE_MAPPING_00, (init_regs->dre_map_bypass << 4), 1 << 4); gain = init_regs->cabc_gainlmt; j = 0; for (i = 0; i <= 10; i++) { DISP_REG_SET(cmdq, DISP_AAL_CABC_GAINLMT_TBL(i), CABC_GAINLMT(gain[j], gain[j + 1], gain[j + 2])); j += 3; } AAL_DBG("disp_aal_write_init_regs: done"); ret = 0; } return ret; }
static int disp_aal_write_param_to_reg(cmdqRecHandle cmdq, const DISP_AAL_PARAM *param) { int i; const int *gain; gain = param->DREGainFltStatus; DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(0), DRE_REG_2(gain[0], 0, gain[1], 12), ~0); DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(1), DRE_REG_2(gain[2], 0, gain[3], 12), ~0); DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(2), DRE_REG_2(gain[4], 0, gain[5], 11), ~0); DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(3), DRE_REG_3(gain[6], 0, gain[7], 11, gain[8], 21), ~0); DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(4), DRE_REG_3(gain[9], 0, gain[10], 10, gain[11], 20), ~0); DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(5), DRE_REG_3(gain[12], 0, gain[13], 10, gain[14], 20), ~0); DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(6), DRE_REG_3(gain[15], 0, gain[16], 10, gain[17], 20), ~0); DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(7), DRE_REG_3(gain[18], 0, gain[19], 9, gain[20], 18), ~0); DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(8), DRE_REG_3(gain[21], 0, gain[22], 9, gain[23], 18), ~0); DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(9), DRE_REG_3(gain[24], 0, gain[25], 9, gain[26], 18), ~0); DISP_REG_MASK(cmdq, DISP_AAL_DRE_FLT_FORCE(10), DRE_REG_2(gain[27], 0, gain[28], 9), ~0); DISP_REG_MASK(cmdq, DISP_AAL_CABC_00, 1 << 31, 1 << 31); DISP_REG_MASK(cmdq, DISP_AAL_CABC_02, ((1 << 26) | param->cabc_fltgain_force), ((1 << 26) | 0x3ff)); gain = param->cabc_gainlmt; for (i = 0; i <= 10; i++) { DISP_REG_MASK(cmdq, DISP_AAL_CABC_GAINLMT_TBL(i), CABC_GAINLMT(gain[0], gain[1], gain[2]), ~0); gain += 3; } return 0; }
static int disp_aal_set_init_reg(DISP_AAL_INITREG __user *user_regs, void *cmdq) { int ret = -EFAULT; DISP_AAL_INITREG *init_regs; init_regs = (DISP_AAL_INITREG*)kmalloc(sizeof(DISP_AAL_INITREG), GFP_KERNEL); if (init_regs == NULL) { AAL_ERR("disp_aal_set_init_reg: insufficient memory"); return -EFAULT; } ret = copy_from_user(init_regs, user_regs, sizeof(DISP_AAL_INITREG)); if (ret == 0) { int i, j; int *gain; DISP_REG_MASK(cmdq, DISP_AAL_DRE_MAPPING_00, (init_regs->dre_map_bypass << 4), 1 << 4); gain = init_regs->cabc_gainlmt; j = 0; for (i = 0; i <= 10; i++) { DISP_REG_SET(cmdq, DISP_AAL_CABC_GAINLMT_TBL(i), CABC_GAINLMT(gain[j], gain[j + 1], gain[j + 2])); j += 3; } } else { AAL_ERR("disp_aal_set_init_reg: copy_from_user() failed"); } AAL_DBG("disp_aal_set_init_reg: %d", ret); kfree(init_regs); return ret; }