static int disp_gamma_set_lut(const DISP_GAMMA_LUT_T __user *user_gamma_lut, void *cmdq) { int ret = 0; disp_gamma_id_t id; DISP_GAMMA_LUT_T *gamma_lut, *old_lut; pr_debug("[GAMMA] disp_gamma_set_lut(cmdq = %d)", (cmdq != NULL ? 1 : 0)); gamma_lut = kmalloc(sizeof(DISP_GAMMA_LUT_T), GFP_KERNEL); if (gamma_lut == NULL) { pr_err("[GAMMA] disp_gamma_set_lut: no memory\n"); return -EFAULT; } if (copy_from_user(gamma_lut, user_gamma_lut, sizeof(DISP_GAMMA_LUT_T)) != 0) { ret = -EFAULT; kfree(gamma_lut); } else { id = gamma_lut->hw_id; if (0 <= id && id < DISP_GAMMA_TOTAL) { mutex_lock(&g_gamma_global_lock); old_lut = g_disp_gamma_lut[id]; g_disp_gamma_lut[id] = gamma_lut; ret = disp_gamma_write_lut_reg(cmdq, id, 0); mutex_unlock(&g_gamma_global_lock); if (old_lut != NULL) kfree(old_lut); disp_gamma_trigger_refresh(id); } else { pr_err("[GAMMA] disp_gamma_set_lut: invalid ID = %d\n", id); ret = -EFAULT; } } return ret; }
static int disp_ccorr_set_coef(const DISP_CCORR_COEF_T __user *user_color_corr, void *cmdq) { int ret = 0; DISP_CCORR_COEF_T *ccorr, *old_ccorr; disp_ccorr_id_t id; ccorr = kmalloc(sizeof(DISP_CCORR_COEF_T), GFP_KERNEL); if (ccorr == NULL) { printk(KERN_ERR "[GAMMA] disp_ccorr_set_coef: no memory\n"); return -EFAULT; } if (copy_from_user(ccorr, user_color_corr, sizeof(DISP_CCORR_COEF_T)) != 0) { ret = -EFAULT; kfree(ccorr); } else { id = ccorr->hw_id; if (0 <= id && id < DISP_CCORR_TOTAL) { spin_lock(&g_gamma_global_lock); old_ccorr = g_disp_ccorr_coef[id]; g_disp_ccorr_coef[id] = ccorr; ret = disp_ccorr_write_coef_reg(cmdq, id, 0); spin_unlock(&g_gamma_global_lock); if (old_ccorr != NULL) kfree(old_ccorr); disp_gamma_trigger_refresh(id); } else { printk(KERN_ERR "[GAMMA] disp_ccorr_set_coef: invalid ID = %d\n", id); ret = -EFAULT; } } return ret; }