mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 06:02:05 +00:00
auxdisplay: ht16k33: Connect backlight to fbdev
Currently /sys/class/graphics/fb0/bl_curve is not accessible (-ENODEV),
as the driver does not connect the backlight to the frame buffer device.
Fix this moving backlight initialization up, and filling in
fb_info.bl_dev.
Fixes: 8992da44c6
("auxdisplay: ht16k33: Driver for LED controller")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Robin van der Gracht <robin@protonic.nl>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
d79141c39f
commit
80f9eb70fd
@ -413,6 +413,33 @@ static int ht16k33_probe(struct i2c_client *client,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Backlight */
|
||||
memset(&bl_props, 0, sizeof(struct backlight_properties));
|
||||
bl_props.type = BACKLIGHT_RAW;
|
||||
bl_props.max_brightness = MAX_BRIGHTNESS;
|
||||
|
||||
bl = devm_backlight_device_register(&client->dev, DRIVER_NAME"-bl",
|
||||
&client->dev, priv,
|
||||
&ht16k33_bl_ops, &bl_props);
|
||||
if (IS_ERR(bl)) {
|
||||
dev_err(&client->dev, "failed to register backlight\n");
|
||||
return PTR_ERR(bl);
|
||||
}
|
||||
|
||||
err = of_property_read_u32(node, "default-brightness-level",
|
||||
&dft_brightness);
|
||||
if (err) {
|
||||
dft_brightness = MAX_BRIGHTNESS;
|
||||
} else if (dft_brightness > MAX_BRIGHTNESS) {
|
||||
dev_warn(&client->dev,
|
||||
"invalid default brightness level: %u, using %u\n",
|
||||
dft_brightness, MAX_BRIGHTNESS);
|
||||
dft_brightness = MAX_BRIGHTNESS;
|
||||
}
|
||||
|
||||
bl->props.brightness = dft_brightness;
|
||||
ht16k33_bl_update_status(bl);
|
||||
|
||||
/* Framebuffer (2 bytes per column) */
|
||||
BUILD_BUG_ON(PAGE_SIZE < HT16K33_FB_SIZE);
|
||||
fbdev->buffer = (unsigned char *) get_zeroed_page(GFP_KERNEL);
|
||||
@ -445,6 +472,7 @@ static int ht16k33_probe(struct i2c_client *client,
|
||||
fbdev->info->screen_size = HT16K33_FB_SIZE;
|
||||
fbdev->info->fix = ht16k33_fb_fix;
|
||||
fbdev->info->var = ht16k33_fb_var;
|
||||
fbdev->info->bl_dev = bl;
|
||||
fbdev->info->pseudo_palette = NULL;
|
||||
fbdev->info->flags = FBINFO_FLAG_DEFAULT;
|
||||
fbdev->info->par = priv;
|
||||
@ -460,34 +488,6 @@ static int ht16k33_probe(struct i2c_client *client,
|
||||
goto err_fbdev_unregister;
|
||||
}
|
||||
|
||||
/* Backlight */
|
||||
memset(&bl_props, 0, sizeof(struct backlight_properties));
|
||||
bl_props.type = BACKLIGHT_RAW;
|
||||
bl_props.max_brightness = MAX_BRIGHTNESS;
|
||||
|
||||
bl = devm_backlight_device_register(&client->dev, DRIVER_NAME"-bl",
|
||||
&client->dev, priv,
|
||||
&ht16k33_bl_ops, &bl_props);
|
||||
if (IS_ERR(bl)) {
|
||||
dev_err(&client->dev, "failed to register backlight\n");
|
||||
err = PTR_ERR(bl);
|
||||
goto err_fbdev_unregister;
|
||||
}
|
||||
|
||||
err = of_property_read_u32(node, "default-brightness-level",
|
||||
&dft_brightness);
|
||||
if (err) {
|
||||
dft_brightness = MAX_BRIGHTNESS;
|
||||
} else if (dft_brightness > MAX_BRIGHTNESS) {
|
||||
dev_warn(&client->dev,
|
||||
"invalid default brightness level: %u, using %u\n",
|
||||
dft_brightness, MAX_BRIGHTNESS);
|
||||
dft_brightness = MAX_BRIGHTNESS;
|
||||
}
|
||||
|
||||
bl->props.brightness = dft_brightness;
|
||||
ht16k33_bl_update_status(bl);
|
||||
|
||||
ht16k33_fb_queue(priv);
|
||||
return 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user