static int nvsd_lut_store(struct tegra_dc_sd_settings *sd_settings, const char *buf) { int ele[3 * DC_DISP_SD_LUT_NUM * NUM_BIN_WIDTHS]; int i = 0; int j = 0; int num = 3 * DC_DISP_SD_LUT_NUM * NUM_BIN_WIDTHS; nvsd_get_multi(ele, num, i, 0, 255); if (i != num) return -EINVAL; for (i = 0; i < NUM_BIN_WIDTHS; i++) { for (j = 0; j < DC_DISP_SD_LUT_NUM; j++) { sd_settings->lut[i][j].r = ele[i * NUM_BIN_WIDTHS + j * 3 + 0]; sd_settings->lut[i][j].g = ele[i * NUM_BIN_WIDTHS + j * 3 + 1]; sd_settings->lut[i][j].b = ele[i * NUM_BIN_WIDTHS + j * 3 + 2]; } } return 0; }
static int nvsd_bltf_store(struct tegra_dc_sd_settings *sd_settings, const char *buf) { int ele[4 * DC_DISP_SD_BL_TF_NUM]; int i = 0, j = 0, num = 4 * DC_DISP_SD_BL_TF_NUM; nvsd_get_multi(ele, num, i, 0, 255); if (i != num) return -EINVAL; for (i = 0; i < NUM_BIN_WIDTHS; i++) { for (j = 0; j < DC_DISP_SD_BL_TF_NUM; j++) { sd_settings->bltf[i][j][0] = ele[i * NUM_BIN_WIDTHS + j * 4 + 0]; sd_settings->bltf[i][j][1] = ele[i * NUM_BIN_WIDTHS + j * 4 + 1]; sd_settings->bltf[i][j][2] = ele[i * NUM_BIN_WIDTHS + j * 4 + 2]; sd_settings->bltf[i][j][3] = ele[i * NUM_BIN_WIDTHS + j * 4 + 3]; } } return 0; }
static int nvsd_bltf_store(struct tegra_dc_sd_settings *sd_settings, const char *buf) { int ele[4 * DC_DISP_SD_BL_TF_NUM * NUM_BIN_WIDTHS]; int i = 0, j = 0, num = ARRAY_SIZE(ele); nvsd_get_multi(ele, num, i, 0, 255); if (i != num) return -EINVAL; for (i = 0; i < NUM_BIN_WIDTHS; i++) { for (j = 0; j < DC_DISP_SD_BL_TF_NUM; j++) { size_t base = (i * NUM_BIN_WIDTHS * DC_DISP_SD_BL_TF_NUM) + (j * 4); sd_settings->bltf[i][j][0] = ele[base + 0]; sd_settings->bltf[i][j][1] = ele[base + 1]; sd_settings->bltf[i][j][2] = ele[base + 2]; sd_settings->bltf[i][j][3] = ele[base + 3]; } } return 0; }
static ssize_t nvsd_settings_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { struct device *dev = container_of((kobj->parent), struct device, kobj); struct nvhost_device *ndev = to_nvhost_device(dev); struct tegra_dc *dc = nvhost_get_drvdata(ndev); struct tegra_dc_sd_settings *sd_settings = dc->out->sd_settings; ssize_t res = count; bool settings_updated = false; long int result; int err; if (sd_settings) { if (IS_NVSD_ATTR(enable)) { if (sd_settings->phase_in_settings) { err = strict_strtol(buf, 10, &result); if (err) return err; if (nvsd_update_enable(sd_settings, result)) nvsd_check_and_update(1, 1, enable); } else { nvsd_check_and_update(0, 1, enable); } } else if (IS_NVSD_ATTR(aggressiveness)) { err = strict_strtol(buf, 10, &result); if (err) return err; if (nvsd_update_agg(sd_settings, result) && !sd_settings->phase_in_settings) settings_updated = true; } else if (IS_NVSD_ATTR(phase_in_settings)) { nvsd_check_and_update(0, 1, phase_in_settings); } else if (IS_NVSD_ATTR(phase_in_adjustments)) { nvsd_check_and_update(0, 1, phase_in_adjustments); } else if (IS_NVSD_ATTR(bin_width)) { nvsd_check_and_update(0, 8, bin_width); } else if (IS_NVSD_ATTR(hw_update_delay)) { nvsd_check_and_update(0, 2, hw_update_delay); } else if (IS_NVSD_ATTR(use_vid_luma)) { nvsd_check_and_update(0, 1, use_vid_luma); } else if (IS_NVSD_ATTR(coeff)) { int ele[3], i = 0, num = 3; nvsd_get_multi(ele, num, i, 0, 15); if (i == num) { sd_settings->coeff.r = ele[0]; sd_settings->coeff.g = ele[1]; sd_settings->coeff.b = ele[2]; settings_updated = true; } else { res = -EINVAL; } } else if (IS_NVSD_ATTR(blp_time_constant)) { nvsd_check_and_update(0, 1024, blp.time_constant); } else if (IS_NVSD_ATTR(blp_step)) { nvsd_check_and_update(0, 255, blp.step); } else if (IS_NVSD_ATTR(fc_time_limit)) { nvsd_check_and_update(0, 255, fc.time_limit); } else if (IS_NVSD_ATTR(fc_threshold)) { nvsd_check_and_update(0, 255, fc.threshold); #ifdef CONFIG_TEGRA_SD_GEN2 } else if (IS_NVSD_ATTR(k_limit_enable)) { nvsd_check_and_update(0, 1, k_limit_enable); } else if (IS_NVSD_ATTR(k_limit)) { nvsd_check_and_update(128, 255, k_limit); } else if (IS_NVSD_ATTR(sd_window_enable)) { nvsd_check_and_update(0, 1, sd_window_enable); } else if (IS_NVSD_ATTR(sd_window)) { int ele[4], i = 0, num = 4; nvsd_get_multi(ele, num, i, 0, LONG_MAX); if (i == num) { sd_settings->sd_window.h_position = ele[0]; sd_settings->sd_window.v_position = ele[1]; sd_settings->sd_window.h_size = ele[2]; sd_settings->sd_window.v_size = ele[3]; settings_updated = true; } else { res = -EINVAL; } } else if (IS_NVSD_ATTR(soft_clipping_enable)) { nvsd_check_and_update(0, 1, soft_clipping_enable); } else if (IS_NVSD_ATTR(soft_clipping_threshold)) { nvsd_check_and_update(0, 255, soft_clipping_threshold); } else if (IS_NVSD_ATTR(smooth_k_enable)) { nvsd_check_and_update(0, 1, smooth_k_enable); } else if (IS_NVSD_ATTR(smooth_k_incr)) { nvsd_check_and_update(0, 16320, smooth_k_incr); } else if (IS_NVSD_ATTR(use_vpulse2)) { nvsd_check_and_update(0, 1, use_vpulse2); #endif } else if (IS_NVSD_ATTR(lut)) { if (nvsd_lut_store(sd_settings, buf)) res = -EINVAL; else settings_updated = true; } else if (IS_NVSD_ATTR(bltf)) { if (nvsd_bltf_store(sd_settings, buf)) res = -EINVAL; else settings_updated = true; } else { res = -EINVAL; } /* Re-init if our settings were updated. */ if (settings_updated) { mutex_lock(&dc->lock); if (!dc->enabled) { mutex_unlock(&dc->lock); return -ENODEV; } tegra_dc_hold_dc_out(dc); nvsd_init(dc, sd_settings); tegra_dc_release_dc_out(dc); mutex_unlock(&dc->lock); /* Update backlight state IFF we're disabling! */ if (!sd_settings->enable && sd_settings->bl_device) { /* Do the actual brightness update outside of * the mutex */ struct platform_device *pdev = sd_settings->bl_device; struct backlight_device *bl = platform_get_drvdata(pdev); if (bl) backlight_update_status(bl); } } } else { /* This shouldn't be reachable. But just in case... */ res = -EINVAL; } return res; }
static ssize_t nvsd_settings_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { struct device *dev = container_of((kobj->parent), struct device, kobj); struct nvhost_device *ndev = to_nvhost_device(dev); struct tegra_dc *dc = nvhost_get_drvdata(ndev); struct tegra_dc_sd_settings *sd_settings = dc->out->sd_settings; ssize_t res = count; bool settings_updated = false; if (sd_settings) { if (IS_NVSD_ATTR(enable)) { nvsd_check_and_update(0, 1, enable); } else if (IS_NVSD_ATTR(aggressiveness)) { nvsd_check_and_update(1, 5, aggressiveness); } else if (IS_NVSD_ATTR(bin_width)) { nvsd_check_and_update(0, 8, bin_width); } else if (IS_NVSD_ATTR(hw_update_delay)) { nvsd_check_and_update(0, 2, hw_update_delay); } else if (IS_NVSD_ATTR(use_vid_luma)) { nvsd_check_and_update(0, 1, use_vid_luma); } else if (IS_NVSD_ATTR(coeff)) { int ele[3], i = 0, num = 3; nvsd_get_multi(ele, num, i, 0, 15); if (i == num) { sd_settings->coeff.r = ele[0]; sd_settings->coeff.g = ele[1]; sd_settings->coeff.b = ele[2]; settings_updated = true; } else { res = -EINVAL; } } else if (IS_NVSD_ATTR(blp_time_constant)) { nvsd_check_and_update(0, 1024, blp.time_constant); } else if (IS_NVSD_ATTR(blp_step)) { nvsd_check_and_update(0, 255, blp.step); } else if (IS_NVSD_ATTR(fc_time_limit)) { nvsd_check_and_update(0, 255, fc.time_limit); } else if (IS_NVSD_ATTR(fc_threshold)) { nvsd_check_and_update(0, 255, fc.threshold); } else if (IS_NVSD_ATTR(lut)) { if (nvsd_lut_store(sd_settings, buf)) res = -EINVAL; else settings_updated = true; } else if (IS_NVSD_ATTR(bltf)) { if (nvsd_bltf_store(sd_settings, buf)) res = -EINVAL; else settings_updated = true; } else { res = -EINVAL; } /* Re-init if our settings were updated. */ if (settings_updated) { nvsd_init(dc, sd_settings); /* Update backlight state IFF we're disabling! */ if (!sd_settings->enable && sd_settings->bl_device) { /* Do the actual brightness update outside of * the mutex */ struct platform_device *pdev = sd_settings->bl_device; struct backlight_device *bl = platform_get_drvdata(pdev); if (bl) backlight_update_status(bl); } } } else { /* This shouldn't be reachable. But just in case... */ res = -EINVAL; } return res; }