Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+17 -36
+9 -14
drivers/video/backlight/gpio_backlight.c
··· 15 15 #include <linux/of_gpio.h> 16 16 #include <linux/platform_data/gpio_backlight.h> 17 17 #include <linux/platform_device.h> 18 + #include <linux/property.h> 18 19 #include <linux/slab.h> 19 20 20 21 struct gpio_backlight { ··· 59 58 struct gpio_backlight *gbl) 60 59 { 61 60 struct device *dev = &pdev->dev; 62 - struct device_node *np = dev->of_node; 63 61 enum gpiod_flags flags; 64 62 int ret; 65 63 66 - gbl->def_value = of_property_read_bool(np, "default-on"); 64 + gbl->def_value = device_property_read_bool(dev, "default-on"); 67 65 flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; 68 66 69 67 gbl->gpiod = devm_gpiod_get(dev, NULL, flags); ··· 86 86 struct backlight_properties props; 87 87 struct backlight_device *bl; 88 88 struct gpio_backlight *gbl; 89 - struct device_node *np = pdev->dev.of_node; 90 89 int ret; 91 - 92 - if (!pdata && !np) { 93 - dev_err(&pdev->dev, 94 - "failed to find platform data or device tree node.\n"); 95 - return -ENODEV; 96 - } 97 90 98 91 gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL); 99 92 if (gbl == NULL) ··· 94 101 95 102 gbl->dev = &pdev->dev; 96 103 97 - if (np) { 104 + if (pdev->dev.fwnode) { 98 105 ret = gpio_backlight_probe_dt(pdev, gbl); 99 106 if (ret) 100 107 return ret; 101 - } else { 108 + } else if (pdata) { 102 109 /* 103 110 * Legacy platform data GPIO retrieveal. Do not expand 104 111 * the use of this code path, currently only used by one ··· 119 126 gbl->gpiod = gpio_to_desc(pdata->gpio); 120 127 if (!gbl->gpiod) 121 128 return -EINVAL; 129 + } else { 130 + dev_err(&pdev->dev, 131 + "failed to find platform data or device tree node.\n"); 132 + return -ENODEV; 122 133 } 123 134 124 135 memset(&props, 0, sizeof(props)); ··· 143 146 return 0; 144 147 } 145 148 146 - #ifdef CONFIG_OF 147 149 static struct of_device_id gpio_backlight_of_match[] = { 148 150 { .compatible = "gpio-backlight" }, 149 151 { /* sentinel */ } 150 152 }; 151 153 152 154 MODULE_DEVICE_TABLE(of, gpio_backlight_of_match); 153 - #endif 154 155 155 156 static struct platform_driver gpio_backlight_driver = { 156 157 .driver = { 157 158 .name = "gpio-backlight", 158 - .of_match_table = of_match_ptr(gpio_backlight_of_match), 159 + .of_match_table = gpio_backlight_of_match, 159 160 }, 160 161 .probe = gpio_backlight_probe, 161 162 };
+8 -22
drivers/video/backlight/pwm_bl.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 - * linux/drivers/video/backlight/pwm_bl.c 4 - * 5 - * simple PWM based backlight control, board code has to setup 3 + * Simple PWM based backlight control, board code has to setup 6 4 * 1) pin configuration so PWM waveforms can output 7 5 * 2) platform_data being correctly configured 8 6 */ ··· 189 191 struct platform_pwm_backlight_data *data, 190 192 unsigned int period) 191 193 { 192 - unsigned int counter = 0; 193 - unsigned int i, n; 194 + unsigned int i; 194 195 u64 retval; 195 196 196 197 /* 197 - * Count the number of bits needed to represent the period number. The 198 - * number of bits is used to calculate the number of levels used for the 199 - * brightness-levels table, the purpose of this calculation is have a 200 - * pre-computed table with enough levels to get linear brightness 201 - * perception. The period is divided by the number of bits so for a 202 - * 8-bit PWM we have 255 / 8 = 32 brightness levels or for a 16-bit PWM 203 - * we have 65535 / 16 = 4096 brightness levels. 204 - * 205 - * Note that this method is based on empirical testing on different 206 - * devices with PWM of 8 and 16 bits of resolution. 198 + * Once we have 4096 levels there's little point going much higher... 199 + * neither interactive sliders nor animation benefits from having 200 + * more values in the table. 207 201 */ 208 - n = period; 209 - while (n) { 210 - counter += n % 2; 211 - n >>= 1; 212 - } 202 + data->max_brightness = 203 + min((int)DIV_ROUND_UP(period, fls(period)), 4096); 213 204 214 - data->max_brightness = DIV_ROUND_UP(period, counter); 215 205 data->levels = devm_kcalloc(dev, data->max_brightness, 216 206 sizeof(*data->levels), GFP_KERNEL); 217 207 if (!data->levels) ··· 691 705 module_platform_driver(pwm_backlight_driver); 692 706 693 707 MODULE_DESCRIPTION("PWM based Backlight Driver"); 694 - MODULE_LICENSE("GPL"); 708 + MODULE_LICENSE("GPL v2"); 695 709 MODULE_ALIAS("platform:pwm-backlight");