.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * fbsysfs.c - framebuffer device class and attributes |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2004 James Simmons <jsimmons@infradead.org> |
---|
5 | | - * |
---|
6 | | - * This program is free software you can redistribute it and/or |
---|
7 | | - * modify it under the terms of the GNU General Public License |
---|
8 | | - * as published by the Free Software Foundation; either version |
---|
9 | | - * 2 of the License, or (at your option) any later version. |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | /* |
---|
.. | .. |
---|
18 | 14 | #include <linux/kernel.h> |
---|
19 | 15 | #include <linux/slab.h> |
---|
20 | 16 | #include <linux/fb.h> |
---|
| 17 | +#include <linux/fbcon.h> |
---|
21 | 18 | #include <linux/console.h> |
---|
22 | 19 | #include <linux/module.h> |
---|
23 | 20 | |
---|
.. | .. |
---|
60 | 57 | info->device = dev; |
---|
61 | 58 | info->fbcon_rotate_hint = -1; |
---|
62 | 59 | |
---|
63 | | -#ifdef CONFIG_FB_BACKLIGHT |
---|
| 60 | +#if IS_ENABLED(CONFIG_FB_BACKLIGHT) |
---|
64 | 61 | mutex_init(&info->bl_curve_mutex); |
---|
65 | 62 | #endif |
---|
66 | 63 | |
---|
.. | .. |
---|
94 | 91 | |
---|
95 | 92 | var->activate |= FB_ACTIVATE_FORCE; |
---|
96 | 93 | console_lock(); |
---|
97 | | - fb_info->flags |= FBINFO_MISC_USEREVENT; |
---|
98 | 94 | err = fb_set_var(fb_info, var); |
---|
99 | | - fb_info->flags &= ~FBINFO_MISC_USEREVENT; |
---|
| 95 | + if (!err) |
---|
| 96 | + fbcon_update_vcs(fb_info, var->activate & FB_ACTIVATE_ALL); |
---|
100 | 97 | console_unlock(); |
---|
101 | 98 | if (err) |
---|
102 | 99 | return err; |
---|
.. | .. |
---|
179 | 176 | return -EINVAL; |
---|
180 | 177 | |
---|
181 | 178 | console_lock(); |
---|
182 | | - if (!lock_fb_info(fb_info)) { |
---|
183 | | - console_unlock(); |
---|
184 | | - return -ENODEV; |
---|
185 | | - } |
---|
| 179 | + lock_fb_info(fb_info); |
---|
186 | 180 | |
---|
187 | 181 | list_splice(&fb_info->modelist, &old_list); |
---|
188 | 182 | fb_videomode_to_modelist((const struct fb_videomode *)buf, i, |
---|
.. | .. |
---|
308 | 302 | { |
---|
309 | 303 | struct fb_info *fb_info = dev_get_drvdata(device); |
---|
310 | 304 | char *last = NULL; |
---|
311 | | - int err; |
---|
| 305 | + int err, arg; |
---|
312 | 306 | |
---|
| 307 | + arg = simple_strtoul(buf, &last, 0); |
---|
313 | 308 | console_lock(); |
---|
314 | | - fb_info->flags |= FBINFO_MISC_USEREVENT; |
---|
315 | | - err = fb_blank(fb_info, simple_strtoul(buf, &last, 0)); |
---|
316 | | - fb_info->flags &= ~FBINFO_MISC_USEREVENT; |
---|
| 309 | + err = fb_blank(fb_info, arg); |
---|
| 310 | + /* might again call into fb_blank */ |
---|
| 311 | + fbcon_fb_blanked(fb_info, arg); |
---|
317 | 312 | console_unlock(); |
---|
318 | 313 | if (err < 0) |
---|
319 | 314 | return err; |
---|
.. | .. |
---|
409 | 404 | state = simple_strtoul(buf, &last, 0); |
---|
410 | 405 | |
---|
411 | 406 | console_lock(); |
---|
412 | | - if (!lock_fb_info(fb_info)) { |
---|
413 | | - console_unlock(); |
---|
414 | | - return -ENODEV; |
---|
415 | | - } |
---|
| 407 | + lock_fb_info(fb_info); |
---|
416 | 408 | |
---|
417 | 409 | fb_set_suspend(fb_info, (int)state); |
---|
418 | 410 | |
---|
.. | .. |
---|
429 | 421 | return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state); |
---|
430 | 422 | } |
---|
431 | 423 | |
---|
432 | | -#ifdef CONFIG_FB_BACKLIGHT |
---|
| 424 | +#if IS_ENABLED(CONFIG_FB_BACKLIGHT) |
---|
433 | 425 | static ssize_t store_bl_curve(struct device *device, |
---|
434 | 426 | struct device_attribute *attr, |
---|
435 | 427 | const char *buf, size_t count) |
---|
.. | .. |
---|
510 | 502 | __ATTR(stride, S_IRUGO, show_stride, NULL), |
---|
511 | 503 | __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate), |
---|
512 | 504 | __ATTR(state, S_IRUGO|S_IWUSR, show_fbstate, store_fbstate), |
---|
513 | | -#ifdef CONFIG_FB_BACKLIGHT |
---|
| 505 | +#if IS_ENABLED(CONFIG_FB_BACKLIGHT) |
---|
514 | 506 | __ATTR(bl_curve, S_IRUGO|S_IWUSR, show_bl_curve, store_bl_curve), |
---|
515 | 507 | #endif |
---|
516 | 508 | }; |
---|
.. | .. |
---|
551 | 543 | } |
---|
552 | 544 | } |
---|
553 | 545 | |
---|
554 | | -#ifdef CONFIG_FB_BACKLIGHT |
---|
| 546 | +#if IS_ENABLED(CONFIG_FB_BACKLIGHT) |
---|
555 | 547 | /* This function generates a linear backlight curve |
---|
556 | 548 | * |
---|
557 | 549 | * 0: off |
---|