|
@@ -0,0 +1,80 @@
|
|
|
|
|
+#include <linux/module.h>
|
|
|
|
|
+#include <linux/kernel.h>
|
|
|
|
|
+#include <linux/init.h>
|
|
|
|
|
+#include <linux/fs.h>
|
|
|
|
|
+#include <linux/cdev.h>
|
|
|
|
|
+#include <linux/device.h>
|
|
|
|
|
+#include <linux/uaccess.h>
|
|
|
|
|
+#include <linux/slab.h>
|
|
|
|
|
+#include <linux/pci.h>
|
|
|
|
|
+#include <linux/i2c.h>
|
|
|
|
|
+#include <linux/acpi.h>
|
|
|
|
|
+#include <linux/interrupt.h>
|
|
|
|
|
+#include <linux/wait.h>
|
|
|
|
|
+#include <linux/sched.h>
|
|
|
|
|
+#include <linux/poll.h>
|
|
|
|
|
+#include <linux/mutex.h>
|
|
|
|
|
+#include <linux/delay.h>
|
|
|
|
|
+#include "light_ring.h"
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+extern struct kobject *vfiec_kobj;
|
|
|
|
|
+static struct kobject *backlight_kobj = NULL;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== mode ==================== */
|
|
|
|
|
+static ssize_t brightness_show(struct kobject *kobj, struct kobj_attribute *attr,
|
|
|
|
|
+ char *buf)
|
|
|
|
|
+{
|
|
|
|
|
+ static int count = 0;
|
|
|
|
|
+ count++;
|
|
|
|
|
+
|
|
|
|
|
+ return sprintf(buf, "mode_show count=%d\n", count);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static ssize_t brightness_store(struct kobject *kobj, struct kobj_attribute *attr,
|
|
|
|
|
+ const char *buf, size_t count)
|
|
|
|
|
+{
|
|
|
|
|
+ printk("mode_store kernel rev:%s\n", buf);
|
|
|
|
|
+ return count;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static struct kobj_attribute brightness =
|
|
|
|
|
+ __ATTR(brightness, 0644, brightness_show, brightness_store);
|
|
|
|
|
+
|
|
|
|
|
+/* ==================== 属性组 ==================== */
|
|
|
|
|
+static struct attribute *backlight_attrs[] = {
|
|
|
|
|
+ &brightness.attr,
|
|
|
|
|
+ NULL,
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+static struct attribute_group backlight_attr_group = {
|
|
|
|
|
+ .attrs = backlight_attrs,
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+int backlight_init(void)
|
|
|
|
|
+{
|
|
|
|
|
+ int ret;
|
|
|
|
|
+ /* 创建 /sys/kernel/vfiec/lightring */
|
|
|
|
|
+ backlight_kobj = kobject_create_and_add("backlight", vfiec_kobj);
|
|
|
|
|
+ if (!backlight_kobj)
|
|
|
|
|
+ {
|
|
|
|
|
+ ret = -ENOMEM;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 创建属性文件 */
|
|
|
|
|
+ ret = sysfs_create_group(backlight_kobj, &backlight_attr_group);
|
|
|
|
|
+ if (ret)
|
|
|
|
|
+ {
|
|
|
|
|
+ pr_err("Faibacklight to create sysfs group: %d\n", ret);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return ret;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void backlight_exit(void)
|
|
|
|
|
+{
|
|
|
|
|
+ sysfs_remove_group(backlight_kobj, &backlight_attr_group);
|
|
|
|
|
+ kobject_put(backlight_kobj);
|
|
|
|
|
+}
|
|
|
|
|
+
|