}
}
-static inline unsigned int bl_do_div(unsigned long num, unsigned int den)
+static inline unsigned int bl_do_div(unsigned long long num, unsigned int den)
{
unsigned long long ret = num;
do_div(ret, den);
+
return (unsigned int)ret;
}
static void bl_set_duty_pwm(struct bl_pwm_config_s *bl_pwm)
{
- unsigned long temp;
+ unsigned long long temp;
if (bl_pwm_bypass)
return;
unsigned int max = bl_pwm->level_max;
unsigned int pwm_max = bl_pwm->pwm_max;
unsigned int pwm_min = bl_pwm->pwm_min;
- unsigned long temp;
+ unsigned long long temp;
if (bl_pwm_bypass)
return;
static void aml_bl_set_level(unsigned int level)
{
- unsigned int temp;
struct bl_pwm_config_s *pwm0, *pwm1;
if (aml_bl_check_driver())
case BL_CTRL_PWM_COMBO:
pwm0 = bl_drv->bconf->bl_pwm_combo0;
pwm1 = bl_drv->bconf->bl_pwm_combo1;
- if ((level >= pwm0->level_min) &&
- (level <= pwm0->level_max)) {
- temp = (pwm0->level_min > pwm1->level_min) ?
- pwm1->level_max : pwm1->level_min;
- if (bl_debug_print_flag) {
- BLPR("pwm0 region, level=%u, pwm1_level=%u\n",
- level, temp);
- }
+
+ if (level >= pwm0->level_max) {
+ bl_set_level_pwm(pwm0, pwm0->level_max);
+ } else if ((level > pwm0->level_min) &&
+ (level < pwm0->level_max)) {
+ if (bl_debug_print_flag)
+ BLPR("pwm0 region, level=%u\n", level);
bl_set_level_pwm(pwm0, level);
- bl_set_level_pwm(pwm1, temp);
- } else if ((level >= pwm1->level_min) &&
- (level <= pwm1->level_max)) {
- temp = (pwm1->level_min > pwm0->level_min) ?
- pwm0->level_max : pwm0->level_min;
- if (bl_debug_print_flag) {
- BLPR("pwm1 region, level=%u, pwm0_level=%u\n",
- level, temp);
- }
- bl_set_level_pwm(pwm0, temp);
+ } else {
+ bl_set_level_pwm(pwm0, pwm0->level_min);
+ }
+
+ if (level >= pwm1->level_max) {
+ bl_set_level_pwm(pwm1, pwm1->level_max);
+ } else if ((level > pwm1->level_min) &&
+ (level < pwm1->level_max)) {
+ if (bl_debug_print_flag)
+ BLPR("pwm1 region, level=%u,\n", level);
bl_set_level_pwm(pwm1, level);
+ } else {
+ bl_set_level_pwm(pwm1, pwm1->level_min);
}
break;
#ifdef CONFIG_AMLOGIC_LOCAL_DIMMING
void bl_pwm_config_init(struct bl_pwm_config_s *bl_pwm)
{
unsigned int cnt;
- unsigned long temp;
+ unsigned long long temp;
if (bl_debug_print_flag) {
BLPR("%s pwm_port %d: freq = %u\n",
{
struct bl_config_s *bconf = bl_drv->bconf;
struct bl_pwm_config_s *bl_pwm = NULL;
- unsigned long temp;
+ unsigned long long temp;
unsigned int pwm_range, temp_duty;
if (aml_bl_check_driver())