diff options
| -rw-r--r-- | drivers/video/backlight/pwm_bl.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 678b27063198..f9ef0673a083 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c | |||
| @@ -562,7 +562,30 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
| 562 | goto err_alloc; | 562 | goto err_alloc; |
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | if (!data->levels) { | 565 | if (data->levels) { |
| 566 | /* | ||
| 567 | * For the DT case, only when brightness levels is defined | ||
| 568 | * data->levels is filled. For the non-DT case, data->levels | ||
| 569 | * can come from platform data, however is not usual. | ||
| 570 | */ | ||
| 571 | for (i = 0; i <= data->max_brightness; i++) { | ||
| 572 | if (data->levels[i] > pb->scale) | ||
| 573 | pb->scale = data->levels[i]; | ||
| 574 | |||
| 575 | pb->levels = data->levels; | ||
| 576 | } | ||
| 577 | } else if (!data->max_brightness) { | ||
| 578 | /* | ||
| 579 | * If no brightness levels are provided and max_brightness is | ||
| 580 | * not set, use the default brightness table. For the DT case, | ||
| 581 | * max_brightness is set to 0 when brightness levels is not | ||
| 582 | * specified. For the non-DT case, max_brightness is usually | ||
| 583 | * set to some value. | ||
| 584 | */ | ||
| 585 | |||
| 586 | /* Get the PWM period (in nanoseconds) */ | ||
| 587 | pwm_get_state(pb->pwm, &state); | ||
| 588 | |||
| 566 | ret = pwm_backlight_brightness_default(&pdev->dev, data, | 589 | ret = pwm_backlight_brightness_default(&pdev->dev, data, |
| 567 | state.period); | 590 | state.period); |
| 568 | if (ret < 0) { | 591 | if (ret < 0) { |
| @@ -570,13 +593,19 @@ static int pwm_backlight_probe(struct platform_device *pdev) | |||
| 570 | "failed to setup default brightness table\n"); | 593 | "failed to setup default brightness table\n"); |
| 571 | goto err_alloc; | 594 | goto err_alloc; |
| 572 | } | 595 | } |
| 573 | } | ||
| 574 | 596 | ||
| 575 | for (i = 0; i <= data->max_brightness; i++) { | 597 | for (i = 0; i <= data->max_brightness; i++) { |
| 576 | if (data->levels[i] > pb->scale) | 598 | if (data->levels[i] > pb->scale) |
| 577 | pb->scale = data->levels[i]; | 599 | pb->scale = data->levels[i]; |
| 578 | 600 | ||
| 579 | pb->levels = data->levels; | 601 | pb->levels = data->levels; |
| 602 | } | ||
| 603 | } else { | ||
| 604 | /* | ||
| 605 | * That only happens for the non-DT case, where platform data | ||
| 606 | * sets the max_brightness value. | ||
| 607 | */ | ||
| 608 | pb->scale = data->max_brightness; | ||
| 580 | } | 609 | } |
| 581 | 610 | ||
| 582 | pb->lth_brightness = data->lth_brightness * (state.period / pb->scale); | 611 | pb->lth_brightness = data->lth_brightness * (state.period / pb->scale); |
