static int cabc_pwm_thread(void *p) { while(!kthread_should_stop()) { if(g_bl_info.index_cabc_dimming > CABC_DIMMING_STEP_TOTAL_NUM) { set_current_state(TASK_INTERRUPTIBLE); schedule(); g_bl_info.index_cabc_dimming =1 ; } else { if(g_bl_info.cabc_pwm_in != 0) { g_bl_info.cabc_pwm = g_bl_info.cabc_pwm_in; g_bl_info.cabc_pwm_in = 0; g_bl_info.index_cabc_dimming = 1; g_bl_info.prev_cabc_pwm = g_bl_info.current_cabc_pwm; } int32_t delta_cabc_pwm = g_bl_info.cabc_pwm - g_bl_info.prev_cabc_pwm; int32_t pwm_duty=delta_cabc_pwm*g_bl_info.index_cabc_dimming/32 + delta_cabc_pwm *g_bl_info.index_cabc_dimming % 32 /16; g_bl_info.current_cabc_pwm = g_bl_info.prev_cabc_pwm + pwm_duty; HISI_FB_INFO("g_bl_info.current_cabc_pwm = %d,g_bl_info.index_cabc_dimming= %d,pwm_duty= %d,g_bl_info.index_cabc_dimming= %d!\n",g_bl_info.current_cabc_pwm ,g_bl_info.index_cabc_dimming,pwm_duty,g_bl_info.index_cabc_dimming); int32_t backlight = g_bl_info.current_cabc_pwm * g_bl_info.ap_brightness / CABC_PWM_DUTY_MAX_LEVEL; if (backlight > 0 && backlight < PWM_BL_LEVEL_MIN) { backlight = PWM_BL_LEVEL_MIN; } update_backlight(backlight); g_bl_info.index_cabc_dimming++; msleep(16); } } return 0; }
/** * Initialize backlight module. */ static void backlight_init(void) { update_backlight(); #ifdef CONFIG_BACKLIGHT_REQ_GPIO gpio_enable_interrupt(CONFIG_BACKLIGHT_REQ_GPIO); #endif }
void update_lights(double value) { // update value for all known contols char backlight_dirs[][50] = { "backlight/acpi_video0", "leds/lcd-backlight" }; int i, changed = 0; // update by virtual values like acpi for (i = 0; i < 2; i++) { if (update_backlight(backlight_dirs[i], value, 0)) changed = 1; } // we can't change virtual control, try update by direct contol if (!changed) { char backlight_direct_dirs[][50] = { "backlight/radeon_bl0", }; for (i = 0; i < 1; i++) { update_backlight(backlight_direct_dirs[i], value, 1); } } }
/** * Initialize panel module. */ static void panel_init(void) { /* Set initial deferred value and signal to the current PCH signal. */ backlight_deferred_value = gpio_get_level(GPIO_PCH_BKLTEN); set_backlight_value(); update_backlight(); gpio_enable_interrupt(GPIO_PCH_BKLTEN); /* The interrupt is enabled for the GPIO_PCH_EDP_VDD_EN in the * chipset_haswell.c compilation unit. Initially set the value * to whatever it current is reading. */ lcdvcc_en_deferred_value = gpio_get_level(GPIO_PCH_EDP_VDD_EN); set_lcdvcc_en_value(); }
void backlight_interrupt(enum gpio_signal signal) { update_backlight(); }
void update_status() { #ifdef DEBUG char buffer[256]; sprintf(buffer, "Update Status: draw Memory %s", sbar_status_symbols[DrawMemory].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); sprintf(buffer, "Update Status: draw Battery %s", sbar_status_symbols[DrawBattery].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); sprintf(buffer, "Update Status: draw Uptime %s", sbar_status_symbols[DrawUptime].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); sprintf(buffer, "Update Status: draw Termal %s", sbar_status_symbols[DrawTermal].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); #ifdef NF310_A01 sprintf(buffer, "Update Status: draw Backlight %s", sbar_status_symbols[DrawBacklight].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); #endif sprintf(buffer, "Update Status: draw Net %s", sbar_status_symbols[DrawNet].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); #endif if(sbar_status_symbols[DrawMemory].active) { get_memory(); #ifdef DEBUG log_str("Sucessfully Updated Memory", LOG_DEBUG); #endif } if(sbar_status_symbols[DrawBattery].active) { check_battery(); #ifdef DEBUG log_str("Sucessfully Updated Battery", LOG_DEBUG); #endif } cpu_usage(); #ifdef DEBUG log_str("Sucessfully Updated CPU", LOG_DEBUG); #endif update_date(); #ifdef DEBUG log_str("Sucessfully Updated Date", LOG_DEBUG); #endif if(sbar_status_symbols[DrawUptime].active) { update_uptime(); #ifdef DEBUG log_str("Sucessfully Updated Uptime", LOG_DEBUG); #endif } if(sbar_status_symbols[DrawTermal].active) { get_thermal(); #ifdef DEBUG log_str("Sucessfully Updated Termal", LOG_DEBUG); #endif } #ifdef NF310_A01 if(sbar_status_symbols[DrawBacklight].active) { update_backlight(); #ifdef DEBUG log_str("Sucessfully Updated Backlight", LOG_DEBUG); #endif } #endif if(sbar_status_symbols[DrawNet].active) { update_net(); #ifdef DEBUG log_str("Sucessfully Updated Net", LOG_DEBUG); #endif } update_disk(); #ifdef DEBUG log_str("Sucessfully Updated Disk", LOG_DEBUG); #endif }