8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/module.h>
12 #include <linux/device.h>
15 #include <linux/ctype.h>
18 #include <linux/slab.h>
20 #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
21 defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
49 if (!ld->
ops->check_fb || ld->
ops->check_fb(ld, evdata->
info)) {
51 if (ld->
ops->set_power)
52 ld->
ops->set_power(ld, *(
int *)evdata->
data);
54 if (ld->
ops->early_set_power)
55 ld->
ops->early_set_power(ld,
56 *(
int *)evdata->
data);
58 if (ld->
ops->r_early_set_power)
59 ld->
ops->r_early_set_power(ld,
60 *(
int *)evdata->
data);
62 if (ld->
ops->set_mode)
63 ld->
ops->set_mode(ld, evdata->
data);
73 ld->
fb_notif.notifier_call = fb_notifier_callback;
87 static inline void lcd_unregister_fb(
struct lcd_device *
ld)
99 if (ld->
ops && ld->
ops->get_power)
100 rc =
sprintf(buf,
"%d\n", ld->
ops->get_power(ld));
115 rc = kstrtoul(buf, 0, &power);
120 if (ld->
ops && ld->
ops->set_power) {
121 pr_debug(
"set power to %lu\n", power);
122 ld->
ops->set_power(ld, power);
137 if (ld->
ops && ld->
ops->get_contrast)
138 rc =
sprintf(buf,
"%d\n", ld->
ops->get_contrast(ld));
151 rc = kstrtoul(buf, 0, &contrast);
156 if (ld->
ops && ld->
ops->set_contrast) {
157 pr_debug(
"set contrast to %lu\n", contrast);
158 ld->
ops->set_contrast(ld, contrast);
174 static struct class *lcd_class;
176 static void lcd_device_release(
struct device *dev)
184 __ATTR(contrast, 0644, lcd_show_contrast, lcd_store_contrast),
185 __ATTR(max_contrast, 0444, lcd_show_max_contrast,
NULL),
206 pr_debug(
"lcd_device_register: name=%s\n", name);
215 new_ld->
dev.class = lcd_class;
216 new_ld->
dev.parent = parent;
217 new_ld->
dev.release = lcd_device_release;
227 rc = lcd_register_fb(new_ld);
253 lcd_unregister_fb(ld);
259 static void __exit lcd_class_exit(
void)
264 static int __init lcd_class_init(
void)
267 if (IS_ERR(lcd_class)) {
268 pr_warn(
"Unable to create backlight class; errno = %ld\n",
270 return PTR_ERR(lcd_class);
273 lcd_class->
dev_attrs = lcd_device_attributes;