Commit 80f9eb70 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Miguel Ojeda

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: 8992da44 ("auxdisplay: ht16k33: Driver for LED controller")
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: default avatarRobin van der Gracht <robin@protonic.nl>
Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent d79141c3
...@@ -413,6 +413,33 @@ static int ht16k33_probe(struct i2c_client *client, ...@@ -413,6 +413,33 @@ static int ht16k33_probe(struct i2c_client *client,
if (err) if (err)
return 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) */ /* Framebuffer (2 bytes per column) */
BUILD_BUG_ON(PAGE_SIZE < HT16K33_FB_SIZE); BUILD_BUG_ON(PAGE_SIZE < HT16K33_FB_SIZE);
fbdev->buffer = (unsigned char *) get_zeroed_page(GFP_KERNEL); fbdev->buffer = (unsigned char *) get_zeroed_page(GFP_KERNEL);
...@@ -445,6 +472,7 @@ static int ht16k33_probe(struct i2c_client *client, ...@@ -445,6 +472,7 @@ static int ht16k33_probe(struct i2c_client *client,
fbdev->info->screen_size = HT16K33_FB_SIZE; fbdev->info->screen_size = HT16K33_FB_SIZE;
fbdev->info->fix = ht16k33_fb_fix; fbdev->info->fix = ht16k33_fb_fix;
fbdev->info->var = ht16k33_fb_var; fbdev->info->var = ht16k33_fb_var;
fbdev->info->bl_dev = bl;
fbdev->info->pseudo_palette = NULL; fbdev->info->pseudo_palette = NULL;
fbdev->info->flags = FBINFO_FLAG_DEFAULT; fbdev->info->flags = FBINFO_FLAG_DEFAULT;
fbdev->info->par = priv; fbdev->info->par = priv;
...@@ -460,34 +488,6 @@ static int ht16k33_probe(struct i2c_client *client, ...@@ -460,34 +488,6 @@ static int ht16k33_probe(struct i2c_client *client,
goto err_fbdev_unregister; 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); ht16k33_fb_queue(priv);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment