- New Functionality

- Provide support for ACPI enumeration; gpio_backlight
 
  - Fix-ups
    - SPDX fixups; pwm_bl
    - Fix linear	brightness levels to include number available; pwm_bl
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAl0sMgQACgkQUa+KL4f8
 d2FTTA//dOz/PwA7lbFEPiOrXkyTsDNkTugyYbR5g1KVTm3IdY8S73Yw7TYLTqw8
 Snfs4afXRxk8hPFe/5JozBUuNz/KQdn2vz4Qq8M3aSf2NBrSQDFTvt/CxclkXIR/
 7RI22llxmibzOWUsPclxe18YbYb7W9PWNtdvcIUlWcHU30R4H7m+mW1JXJjUpKK5
 oGtNegAUZGlG2Q/P2jJNzQK72ltrolwPHdzokxuhmu8SividkFE0X7Bf+hqLX6hq
 RlmmOyTMioFGA46mU5HuDBCHi35vZbdUN4V74ab7igIqnScbUglKifwwa5gDR2Do
 xnFIu960zQWkMAsXxFq1vkgor97b5h0c35l4nkhXtebm+h9R0cEJBv/5ac4wN2vD
 20G+SyIu80rbjNi4h5XQlHECQI70NZc5dmQhHJ8a+uvlrIXA9ppDwWsFsc3FBHzy
 fTJH43Bxw7P4kWTFGiuFOqWXxPUr04J/w84WdcpzVCiX+T7EcCC+bdh5BlNR+in4
 KYiy/AGq9b8YyFV0P83KzHE//tOwrGd6tWlrG6qLaKXpNMA4V5p/C7DM3PImSuH2
 El9Vz2aWUGwmwHe6XHgveFqJp5wZNiZKTRr7bBX4JhITI+R54PZAoZOzubAEt2oD
 9eMIjOdluLdlTRHxhCZwU+/aG5RuLfD6oyi1bwxtPcokAo5xKQo=
 =RKbo
 -----END PGP SIGNATURE-----

Merge tag 'backlight-next-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight

Pull backlight updates from Lee Jones:
 "New Functionality:
   - Provide support for ACPI enumeration; gpio_backlight

  Fix-ups:
   - SPDX fixups; pwm_bl
   - Fix linear	brightness levels to include number available; pwm_bl"

* tag 'backlight-next-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
  backlight: pwm_bl: Fix heuristic to determine number of brightness levels
  backlight: gpio_backlight: Enable ACPI enumeration
  backlight: pwm_bl: Convert to use SPDX identifier
This commit is contained in:
Linus Torvalds 2019-07-16 09:25:04 -07:00
commit 5095062641
2 changed files with 17 additions and 36 deletions

View File

@ -15,6 +15,7 @@
#include <linux/of_gpio.h>
#include <linux/platform_data/gpio_backlight.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/slab.h>
struct gpio_backlight {
@ -58,11 +59,10 @@ static int gpio_backlight_probe_dt(struct platform_device *pdev,
struct gpio_backlight *gbl)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
enum gpiod_flags flags;
int ret;
gbl->def_value = of_property_read_bool(np, "default-on");
gbl->def_value = device_property_read_bool(dev, "default-on");
flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
@ -86,26 +86,19 @@ static int gpio_backlight_probe(struct platform_device *pdev)
struct backlight_properties props;
struct backlight_device *bl;
struct gpio_backlight *gbl;
struct device_node *np = pdev->dev.of_node;
int ret;
if (!pdata && !np) {
dev_err(&pdev->dev,
"failed to find platform data or device tree node.\n");
return -ENODEV;
}
gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
if (gbl == NULL)
return -ENOMEM;
gbl->dev = &pdev->dev;
if (np) {
if (pdev->dev.fwnode) {
ret = gpio_backlight_probe_dt(pdev, gbl);
if (ret)
return ret;
} else {
} else if (pdata) {
/*
* Legacy platform data GPIO retrieveal. Do not expand
* the use of this code path, currently only used by one
@ -126,6 +119,10 @@ static int gpio_backlight_probe(struct platform_device *pdev)
gbl->gpiod = gpio_to_desc(pdata->gpio);
if (!gbl->gpiod)
return -EINVAL;
} else {
dev_err(&pdev->dev,
"failed to find platform data or device tree node.\n");
return -ENODEV;
}
memset(&props, 0, sizeof(props));
@ -146,19 +143,17 @@ static int gpio_backlight_probe(struct platform_device *pdev)
return 0;
}
#ifdef CONFIG_OF
static struct of_device_id gpio_backlight_of_match[] = {
{ .compatible = "gpio-backlight" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, gpio_backlight_of_match);
#endif
static struct platform_driver gpio_backlight_driver = {
.driver = {
.name = "gpio-backlight",
.of_match_table = of_match_ptr(gpio_backlight_of_match),
.of_match_table = gpio_backlight_of_match,
},
.probe = gpio_backlight_probe,
};

View File

@ -1,8 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* linux/drivers/video/backlight/pwm_bl.c
*
* simple PWM based backlight control, board code has to setup
* Simple PWM based backlight control, board code has to setup
* 1) pin configuration so PWM waveforms can output
* 2) platform_data being correctly configured
*/
@ -191,29 +189,17 @@ int pwm_backlight_brightness_default(struct device *dev,
struct platform_pwm_backlight_data *data,
unsigned int period)
{
unsigned int counter = 0;
unsigned int i, n;
unsigned int i;
u64 retval;
/*
* Count the number of bits needed to represent the period number. The
* number of bits is used to calculate the number of levels used for the
* brightness-levels table, the purpose of this calculation is have a
* pre-computed table with enough levels to get linear brightness
* perception. The period is divided by the number of bits so for a
* 8-bit PWM we have 255 / 8 = 32 brightness levels or for a 16-bit PWM
* we have 65535 / 16 = 4096 brightness levels.
*
* Note that this method is based on empirical testing on different
* devices with PWM of 8 and 16 bits of resolution.
* Once we have 4096 levels there's little point going much higher...
* neither interactive sliders nor animation benefits from having
* more values in the table.
*/
n = period;
while (n) {
counter += n % 2;
n >>= 1;
}
data->max_brightness =
min((int)DIV_ROUND_UP(period, fls(period)), 4096);
data->max_brightness = DIV_ROUND_UP(period, counter);
data->levels = devm_kcalloc(dev, data->max_brightness,
sizeof(*data->levels), GFP_KERNEL);
if (!data->levels)
@ -705,5 +691,5 @@ static struct platform_driver pwm_backlight_driver = {
module_platform_driver(pwm_backlight_driver);
MODULE_DESCRIPTION("PWM based Backlight Driver");
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:pwm-backlight");