Skip to contentSkip to conversation

leds-da903x (da9030 only) led brightness reversed.

LED bug fix Jonathan Cameron 3 participants 3 messages Oct 30, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The brightness control register calculation (for the pwm) is effectively the reverse of what would be expected. 1 is maximum brightness, 255 minimum.

This patch inverts this.

---

drivers/leds/leds-da903x.c +1 -1
index f1fddb1..ab632e9 100644
@@ -57,7 +57,7 @@ static void da903x_led_work(struct work_struct *work)
 		offset = DA9030_LED_OFFSET(led->id);
 		val = led->flags & ~0x87;
 		val |= (led->new_brightness) ? 0x80 : 0; /* EN bit */
-		val |= (led->new_brightness >> 5) & 0x7; /* PWM<2:0> */
+		val |= (0x7 - (led->new_brightness >> 5)) & 0x7; /* PWM<2:0> */
 		da903x_write(led->master, DA9030_LED1_CONTROL + offset, val);
 		break;
 	case DA9030_ID_VIBRA:
Acked-by
#1 lore raw
Quoted 7 lines · Jonathan Cameron

The brightness control register calculation (for the pwm) is effectively the reverse of what would be expected. 1 is maximum brightness, 255 minimum.

This patch inverts this.

Quoted 15 lines

---

drivers/leds/leds-da903x.c +1 -1
index f1fddb1..ab632e9 100644
@@ -57,7 +57,7 @@ static void da903x_led_work(struct work_struct *work)
 		offset = DA9030_LED_OFFSET(led->id);
 		val = led->flags & ~0x87;
 		val |= (led->new_brightness) ? 0x80 : 0; /* EN bit */
-		val |= (led->new_brightness >> 5) & 0x7; /* PWM<2:0> */
+		val |= (0x7 - (led->new_brightness >> 5)) & 0x7; /* PWM<2:0> */
 		da903x_write(led->master, DA9030_LED1_CONTROL + offset, val);
 		break;
 	case DA9030_ID_VIBRA:
Signature · 2 lines
Sincerely yours,
Mike.
#2 lore raw
Quoted 7 lines · Mike Rapoport
Quoted 4 lines · Jonathan Cameron

The brightness control register calculation (for the pwm) is effectively the reverse of what would be expected. 1 is maximum brightness, 255 minimum.

Quoted 6 lines
Quoted 3 lines

This patch inverts this.

OK, queued.

Richard, I'm taking this patch along with some of my other fixes to be pushed out tonight, thanks.