Skip to content

Commit d1a84d6

Browse files
ashinlinjamess-huang
authored andcommitted
DSI : Add the backlight control node in /sys/class/backlight/rpi_backlight/brightness
Change-Id: I8d75ec76b81cb1d82e9dab999f704549b25e9ef8 Reviewed-on: https://tp-biosrd-v02/gerrit/83005 Reviewed-by: Jamess Huang(黃以民) <Jamess_Huang@asus.com> Tested-by: Jamess Huang(黃以民) <Jamess_Huang@asus.com>
1 parent 6366730 commit d1a84d6

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

drivers/misc/tinker_mcu.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
#include <linux/i2c.h>
2323
#include <linux/module.h>
2424
#include <linux/workqueue.h>
25+
#include <linux/backlight.h>
2526
#include "tinker_mcu.h"
2627

2728
#define BL_DEBUG 0
2829
static struct tinker_mcu_data *g_mcu_data;
2930
static int connected = 0;
3031
static int lcd_bright_level = 0;
32+
static struct device *rpi_backlight_device;
3133

3234
static int is_hex(char num)
3335
{
@@ -187,6 +189,7 @@ static ssize_t tinker_mcu_bl_store(struct device *dev, struct device_attribute *
187189
return strnlen(buf, count);
188190
}
189191
static DEVICE_ATTR(tinker_mcu_bl, S_IRUGO | S_IWUSR, tinker_mcu_bl_show, tinker_mcu_bl_store);
192+
static DEVICE_ATTR(brightness, S_IRUGO | S_IWUSR, tinker_mcu_bl_show, tinker_mcu_bl_store);
190193

191194
int tinker_mcu_is_connected(void)
192195
{
@@ -230,6 +233,22 @@ static int tinker_mcu_probe(struct i2c_client *client,
230233
return ret;
231234
}
232235

236+
rpi_backlight_device = device_create(backlight_class, NULL, MKDEV(0, 0), NULL,
237+
"rpi_backlight");
238+
if (IS_ERR(rpi_backlight_device)) {
239+
printk(KERN_WARNING "Unable to create device "
240+
"for rpi_backlight; errno = %ld\n",
241+
PTR_ERR(rpi_backlight_device));
242+
rpi_backlight_device = NULL;
243+
} else {
244+
//init_device
245+
ret = device_create_file(rpi_backlight_device, &dev_attr_brightness);
246+
if (ret != 0) {
247+
dev_err(&client->dev, "Failed to create brightness sysfs files %d\n", ret);
248+
return ret;
249+
}
250+
}
251+
233252
return 0;
234253

235254
error:

drivers/video/backlight/backlight.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static void backlight_generate_event(struct backlight_device *bd,
124124
sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness");
125125
}
126126

127+
#ifndef CONFIG_TINKER_MCU
127128
static ssize_t bl_power_show(struct device *dev, struct device_attribute *attr,
128129
char *buf)
129130
{
@@ -242,8 +243,10 @@ static ssize_t actual_brightness_show(struct device *dev,
242243
return rc;
243244
}
244245
static DEVICE_ATTR_RO(actual_brightness);
246+
#endif
245247

246-
static struct class *backlight_class;
248+
struct class *backlight_class;
249+
EXPORT_SYMBOL(backlight_class);
247250

248251
#ifdef CONFIG_PM_SLEEP
249252
static int backlight_suspend(struct device *dev)
@@ -285,11 +288,13 @@ static void bl_device_release(struct device *dev)
285288
}
286289

287290
static struct attribute *bl_device_attrs[] = {
291+
#ifndef CONFIG_TINKER_MCU
288292
&dev_attr_bl_power.attr,
289293
&dev_attr_brightness.attr,
290294
&dev_attr_actual_brightness.attr,
291295
&dev_attr_max_brightness.attr,
292296
&dev_attr_type.attr,
297+
#endif
293298
NULL,
294299
};
295300
ATTRIBUTE_GROUPS(bl_device);
@@ -594,6 +599,7 @@ static int __init backlight_class_init(void)
594599

595600
backlight_class->dev_groups = bl_device_groups;
596601
backlight_class->pm = &backlight_class_dev_pm_ops;
602+
597603
INIT_LIST_HEAD(&backlight_dev_list);
598604
mutex_init(&backlight_dev_list_mutex);
599605
BLOCKING_INIT_NOTIFIER_HEAD(&backlight_notifier);

include/linux/backlight.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ enum backlight_notification {
4747

4848
struct backlight_device;
4949
struct fb_info;
50+
extern struct class *backlight_class;
5051

5152
struct backlight_ops {
5253
unsigned int options;

0 commit comments

Comments
 (0)