1 // SPDX-License-Identifier: GPL-2.0-or-later
3 #include <linux/export.h>
5 #include <linux/mutex.h>
7 #if IS_ENABLED(CONFIG_FB_BACKLIGHT)
9 * This function generates a linear backlight curve
13 * 8-127: linear from min to max
15 void fb_bl_default_curve(struct fb_info
*fb_info
, u8 off
, u8 min
, u8 max
)
17 unsigned int i
, flat
, count
, range
= (max
- min
);
19 mutex_lock(&fb_info
->bl_curve_mutex
);
21 fb_info
->bl_curve
[0] = off
;
23 for (flat
= 1; flat
< (FB_BACKLIGHT_LEVELS
/ 16); ++flat
)
24 fb_info
->bl_curve
[flat
] = min
;
26 count
= FB_BACKLIGHT_LEVELS
* 15 / 16;
27 for (i
= 0; i
< count
; ++i
)
28 fb_info
->bl_curve
[flat
+ i
] = min
+ (range
* (i
+ 1) / count
);
30 mutex_unlock(&fb_info
->bl_curve_mutex
);
32 EXPORT_SYMBOL_GPL(fb_bl_default_curve
);
34 struct backlight_device
*fb_bl_device(struct fb_info
*info
)
38 EXPORT_SYMBOL(fb_bl_device
);