File: fb_backlight.c

package info (click to toggle)
linux 6.17.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,734,788 kB
  • sloc: ansic: 26,682,992; asm: 271,227; sh: 147,381; python: 75,980; makefile: 57,306; perl: 36,943; xml: 19,562; cpp: 5,899; yacc: 4,909; lex: 2,943; awk: 1,556; sed: 29; ruby: 25
file content (51 lines) | stat: -rw-r--r-- 1,247 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-License-Identifier: GPL-2.0-or-later

#include <linux/backlight.h>
#include <linux/export.h>
#include <linux/fb.h>
#include <linux/mutex.h>

#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
/*
 * This function generates a linear backlight curve
 *
 *     0: off
 *   1-7: min
 * 8-127: linear from min to max
 */
void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max)
{
	unsigned int i, flat, count, range = (max - min);

	mutex_lock(&fb_info->bl_curve_mutex);

	fb_info->bl_curve[0] = off;

	for (flat = 1; flat < (FB_BACKLIGHT_LEVELS / 16); ++flat)
		fb_info->bl_curve[flat] = min;

	count = FB_BACKLIGHT_LEVELS * 15 / 16;
	for (i = 0; i < count; ++i)
		fb_info->bl_curve[flat + i] = min + (range * (i + 1) / count);

	mutex_unlock(&fb_info->bl_curve_mutex);
}
EXPORT_SYMBOL_GPL(fb_bl_default_curve);

struct backlight_device *fb_bl_device(struct fb_info *info)
{
	return info->bl_dev;
}
EXPORT_SYMBOL(fb_bl_device);

void fb_bl_notify_blank(struct fb_info *info, int old_blank)
{
	bool on = info->blank == FB_BLANK_UNBLANK;
	bool prev_on = old_blank == FB_BLANK_UNBLANK;

	if (info->bl_dev)
		backlight_notify_blank(info->bl_dev, info->device, on, prev_on);
	else
		backlight_notify_blank_all(info->device, on, prev_on);
}
#endif