-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpixel_kb_backlight.c
85 lines (76 loc) · 2.42 KB
/
pixel_kb_backlight.c
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* pixel_kb_backlight.c - Driver to Google Chromebook Pixel keyboard backlight devices.
*
* Author : Benson Leung <bleung@chromium.org>
*
* Copyright (C) 2012 Google, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <linux/dmi.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#ifdef KB_BACKLIGHT
#define DEVICE_NAME "chromeos-keyboard-backlight"
#else
#define DEVICE_NAME "chromeos-keyboard-leds"
#endif
static struct platform_device *kb_backlight_device;
static int __init setup_keyboard_backlight(const struct dmi_system_id *id)
{
kb_backlight_device =
platform_device_register_simple(DEVICE_NAME,
-1, NULL, 0);
if (IS_ERR(kb_backlight_device)) {
pr_warn("Error registering Chromebook Pixel keyboard LEDs.\n");
kb_backlight_device = NULL;
}
return 0;
}
static struct dmi_system_id __initdata pixel_kb_backlight_dmi_table[] = {
{
.ident = "Chromebook Pixel - Keyboard backlight",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"),
DMI_MATCH(DMI_PRODUCT_NAME, "Link"),
},
.callback = setup_keyboard_backlight,
},
{ }
};
MODULE_DEVICE_TABLE(dmi, pixel_kb_backlight_dmi_table);
static int __init pixel_kb_backlight_init(void)
{
if (!dmi_check_system(pixel_kb_backlight_dmi_table)) {
pr_debug("%s unsupported system.\n", __func__);
return -ENODEV;
}
return 0;
}
static void __exit pixel_kb_backlight_exit(void)
{
if (kb_backlight_device)
platform_device_unregister(kb_backlight_device);
}
module_init(pixel_kb_backlight_init);
module_exit(pixel_kb_backlight_exit);
MODULE_DESCRIPTION("Chromebook Pixel Keyboard backlight driver");
MODULE_AUTHOR("Benson Leung <bleung@chromium.org>");
MODULE_LICENSE("GPL");