2 * ideapad-laptop.c - Lenovo IdeaPad ACPI Extras
4 * Copyright © 2010 Intel Corporation
5 * Copyright © 2010 David Woodhouse <dwmw2@infradead.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/init.h>
28 #include <linux/types.h>
29 #include <acpi/acpi_bus.h>
30 #include <acpi/acpi_drivers.h>
31 #include <linux/rfkill.h>
32 #include <linux/platform_device.h>
33 #include <linux/input.h>
34 #include <linux/input/sparse-keymap.h>
35 #include <linux/backlight.h>
37 #include <linux/debugfs.h>
38 #include <linux/seq_file.h>
39 #include <linux/i8042.h>
41 #define IDEAPAD_RFKILL_DEV_NUM (3)
43 #define CFG_BT_BIT (16)
44 #define CFG_3G_BIT (17)
45 #define CFG_WIFI_BIT (18)
46 #define CFG_CAMERA_BIT (19)
66 VPCCMD_R_ODD
, /* 0x21 */
71 VPCCMD_R_SPECIAL_BUTTONS
= 0x31,
72 VPCCMD_W_BL_POWER
= 0x33,
75 struct ideapad_private
{
76 struct rfkill
*rfk
[IDEAPAD_RFKILL_DEV_NUM
];
77 struct platform_device
*platform_device
;
78 struct input_dev
*inputdev
;
79 struct backlight_device
*blightdev
;
84 static acpi_handle ideapad_handle
;
85 static struct ideapad_private
*ideapad_priv
;
86 static bool no_bt_rfkill
;
87 module_param(no_bt_rfkill
, bool, 0444);
88 MODULE_PARM_DESC(no_bt_rfkill
, "No rfkill for bluetooth.");
93 #define IDEAPAD_EC_TIMEOUT (100) /* in ms */
95 static int read_method_int(acpi_handle handle
, const char *method
, int *val
)
98 unsigned long long result
;
100 status
= acpi_evaluate_integer(handle
, (char *)method
, NULL
, &result
);
101 if (ACPI_FAILURE(status
)) {
110 static int method_vpcr(acpi_handle handle
, int cmd
, int *ret
)
113 unsigned long long result
;
114 struct acpi_object_list params
;
115 union acpi_object in_obj
;
118 params
.pointer
= &in_obj
;
119 in_obj
.type
= ACPI_TYPE_INTEGER
;
120 in_obj
.integer
.value
= cmd
;
122 status
= acpi_evaluate_integer(handle
, "VPCR", ¶ms
, &result
);
124 if (ACPI_FAILURE(status
)) {
133 static int method_vpcw(acpi_handle handle
, int cmd
, int data
)
135 struct acpi_object_list params
;
136 union acpi_object in_obj
[2];
140 params
.pointer
= in_obj
;
141 in_obj
[0].type
= ACPI_TYPE_INTEGER
;
142 in_obj
[0].integer
.value
= cmd
;
143 in_obj
[1].type
= ACPI_TYPE_INTEGER
;
144 in_obj
[1].integer
.value
= data
;
146 status
= acpi_evaluate_object(handle
, "VPCW", ¶ms
, NULL
);
152 static int read_ec_data(acpi_handle handle
, int cmd
, unsigned long *data
)
155 unsigned long int end_jiffies
;
157 if (method_vpcw(handle
, 1, cmd
))
160 for (end_jiffies
= jiffies
+(HZ
)*IDEAPAD_EC_TIMEOUT
/1000+1;
161 time_before(jiffies
, end_jiffies
);) {
163 if (method_vpcr(handle
, 1, &val
))
166 if (method_vpcr(handle
, 0, &val
))
172 pr_err("timeout in read_ec_cmd\n");
176 static int write_ec_cmd(acpi_handle handle
, int cmd
, unsigned long data
)
179 unsigned long int end_jiffies
;
181 if (method_vpcw(handle
, 0, data
))
183 if (method_vpcw(handle
, 1, cmd
))
186 for (end_jiffies
= jiffies
+(HZ
)*IDEAPAD_EC_TIMEOUT
/1000+1;
187 time_before(jiffies
, end_jiffies
);) {
189 if (method_vpcr(handle
, 1, &val
))
194 pr_err("timeout in write_ec_cmd\n");
201 static int debugfs_status_show(struct seq_file
*s
, void *data
)
205 if (!read_ec_data(ideapad_handle
, VPCCMD_R_BL_MAX
, &value
))
206 seq_printf(s
, "Backlight max:\t%lu\n", value
);
207 if (!read_ec_data(ideapad_handle
, VPCCMD_R_BL
, &value
))
208 seq_printf(s
, "Backlight now:\t%lu\n", value
);
209 if (!read_ec_data(ideapad_handle
, VPCCMD_R_BL_POWER
, &value
))
210 seq_printf(s
, "BL power value:\t%s\n", value
? "On" : "Off");
211 seq_printf(s
, "=====================\n");
213 if (!read_ec_data(ideapad_handle
, VPCCMD_R_RF
, &value
))
214 seq_printf(s
, "Radio status:\t%s(%lu)\n",
215 value
? "On" : "Off", value
);
216 if (!read_ec_data(ideapad_handle
, VPCCMD_R_WIFI
, &value
))
217 seq_printf(s
, "Wifi status:\t%s(%lu)\n",
218 value
? "On" : "Off", value
);
219 if (!read_ec_data(ideapad_handle
, VPCCMD_R_BT
, &value
))
220 seq_printf(s
, "BT status:\t%s(%lu)\n",
221 value
? "On" : "Off", value
);
222 if (!read_ec_data(ideapad_handle
, VPCCMD_R_3G
, &value
))
223 seq_printf(s
, "3G status:\t%s(%lu)\n",
224 value
? "On" : "Off", value
);
225 seq_printf(s
, "=====================\n");
227 if (!read_ec_data(ideapad_handle
, VPCCMD_R_TOUCHPAD
, &value
))
228 seq_printf(s
, "Touchpad status:%s(%lu)\n",
229 value
? "On" : "Off", value
);
230 if (!read_ec_data(ideapad_handle
, VPCCMD_R_CAMERA
, &value
))
231 seq_printf(s
, "Camera status:\t%s(%lu)\n",
232 value
? "On" : "Off", value
);
237 static int debugfs_status_open(struct inode
*inode
, struct file
*file
)
239 return single_open(file
, debugfs_status_show
, NULL
);
242 static const struct file_operations debugfs_status_fops
= {
243 .owner
= THIS_MODULE
,
244 .open
= debugfs_status_open
,
247 .release
= single_release
,
250 static int debugfs_cfg_show(struct seq_file
*s
, void *data
)
253 seq_printf(s
, "cfg: N/A\n");
255 seq_printf(s
, "cfg: 0x%.8lX\n\nCapability: ",
257 if (test_bit(CFG_BT_BIT
, &ideapad_priv
->cfg
))
258 seq_printf(s
, "Bluetooth ");
259 if (test_bit(CFG_3G_BIT
, &ideapad_priv
->cfg
))
260 seq_printf(s
, "3G ");
261 if (test_bit(CFG_WIFI_BIT
, &ideapad_priv
->cfg
))
262 seq_printf(s
, "Wireless ");
263 if (test_bit(CFG_CAMERA_BIT
, &ideapad_priv
->cfg
))
264 seq_printf(s
, "Camera ");
265 seq_printf(s
, "\nGraphic: ");
266 switch ((ideapad_priv
->cfg
)&0x700) {
268 seq_printf(s
, "Intel");
271 seq_printf(s
, "ATI");
274 seq_printf(s
, "Nvidia");
277 seq_printf(s
, "Intel and ATI");
280 seq_printf(s
, "Intel and Nvidia");
288 static int debugfs_cfg_open(struct inode
*inode
, struct file
*file
)
290 return single_open(file
, debugfs_cfg_show
, NULL
);
293 static const struct file_operations debugfs_cfg_fops
= {
294 .owner
= THIS_MODULE
,
295 .open
= debugfs_cfg_open
,
298 .release
= single_release
,
301 static int __devinit
ideapad_debugfs_init(struct ideapad_private
*priv
)
305 priv
->debug
= debugfs_create_dir("ideapad", NULL
);
306 if (priv
->debug
== NULL
) {
307 pr_err("failed to create debugfs directory");
311 node
= debugfs_create_file("cfg", S_IRUGO
, priv
->debug
, NULL
,
314 pr_err("failed to create cfg in debugfs");
318 node
= debugfs_create_file("status", S_IRUGO
, priv
->debug
, NULL
,
319 &debugfs_status_fops
);
321 pr_err("failed to create status in debugfs");
331 static void ideapad_debugfs_exit(struct ideapad_private
*priv
)
333 debugfs_remove_recursive(priv
->debug
);
340 static ssize_t
show_ideapad_cam(struct device
*dev
,
341 struct device_attribute
*attr
,
344 unsigned long result
;
346 if (read_ec_data(ideapad_handle
, VPCCMD_R_CAMERA
, &result
))
347 return sprintf(buf
, "-1\n");
348 return sprintf(buf
, "%lu\n", result
);
351 static ssize_t
store_ideapad_cam(struct device
*dev
,
352 struct device_attribute
*attr
,
353 const char *buf
, size_t count
)
359 if (sscanf(buf
, "%i", &state
) != 1)
361 ret
= write_ec_cmd(ideapad_handle
, VPCCMD_W_CAMERA
, state
);
367 static DEVICE_ATTR(camera_power
, 0644, show_ideapad_cam
, store_ideapad_cam
);
369 static ssize_t
show_ideapad_fan(struct device
*dev
,
370 struct device_attribute
*attr
,
373 unsigned long result
;
375 if (read_ec_data(ideapad_handle
, VPCCMD_R_FAN
, &result
))
376 return sprintf(buf
, "-1\n");
377 return sprintf(buf
, "%lu\n", result
);
380 static ssize_t
store_ideapad_fan(struct device
*dev
,
381 struct device_attribute
*attr
,
382 const char *buf
, size_t count
)
388 if (sscanf(buf
, "%i", &state
) != 1)
390 if (state
< 0 || state
> 4 || state
== 3)
392 ret
= write_ec_cmd(ideapad_handle
, VPCCMD_W_FAN
, state
);
398 static DEVICE_ATTR(fan_mode
, 0644, show_ideapad_fan
, store_ideapad_fan
);
400 static struct attribute
*ideapad_attributes
[] = {
401 &dev_attr_camera_power
.attr
,
402 &dev_attr_fan_mode
.attr
,
406 static umode_t
ideapad_is_visible(struct kobject
*kobj
,
407 struct attribute
*attr
,
410 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
411 struct ideapad_private
*priv
= dev_get_drvdata(dev
);
414 if (attr
== &dev_attr_camera_power
.attr
)
415 supported
= test_bit(CFG_CAMERA_BIT
, &(priv
->cfg
));
416 else if (attr
== &dev_attr_fan_mode
.attr
) {
418 supported
= !read_ec_data(ideapad_handle
, VPCCMD_R_FAN
, &value
);
422 return supported
? attr
->mode
: 0;
425 static struct attribute_group ideapad_attribute_group
= {
426 .is_visible
= ideapad_is_visible
,
427 .attrs
= ideapad_attributes
433 struct ideapad_rfk_data
{
440 const struct ideapad_rfk_data ideapad_rfk_data
[] = {
441 { "ideapad_wlan", CFG_WIFI_BIT
, VPCCMD_W_WIFI
, RFKILL_TYPE_WLAN
},
442 { "ideapad_bluetooth", CFG_BT_BIT
, VPCCMD_W_BT
, RFKILL_TYPE_BLUETOOTH
},
443 { "ideapad_3g", CFG_3G_BIT
, VPCCMD_W_3G
, RFKILL_TYPE_WWAN
},
446 static int ideapad_rfk_set(void *data
, bool blocked
)
448 unsigned long opcode
= (unsigned long)data
;
450 return write_ec_cmd(ideapad_handle
, opcode
, !blocked
);
453 static struct rfkill_ops ideapad_rfk_ops
= {
454 .set_block
= ideapad_rfk_set
,
457 static void ideapad_sync_rfk_state(struct ideapad_private
*priv
)
459 unsigned long hw_blocked
;
462 if (read_ec_data(ideapad_handle
, VPCCMD_R_RF
, &hw_blocked
))
464 hw_blocked
= !hw_blocked
;
466 for (i
= 0; i
< IDEAPAD_RFKILL_DEV_NUM
; i
++)
468 rfkill_set_hw_state(priv
->rfk
[i
], hw_blocked
);
471 static int __devinit
ideapad_register_rfkill(struct acpi_device
*adevice
,
474 struct ideapad_private
*priv
= dev_get_drvdata(&adevice
->dev
);
476 unsigned long sw_blocked
;
479 (ideapad_rfk_data
[dev
].type
== RFKILL_TYPE_BLUETOOTH
)) {
480 /* Force to enable bluetooth when no_bt_rfkill=1 */
481 write_ec_cmd(ideapad_handle
,
482 ideapad_rfk_data
[dev
].opcode
, 1);
486 priv
->rfk
[dev
] = rfkill_alloc(ideapad_rfk_data
[dev
].name
, &adevice
->dev
,
487 ideapad_rfk_data
[dev
].type
, &ideapad_rfk_ops
,
492 if (read_ec_data(ideapad_handle
, ideapad_rfk_data
[dev
].opcode
-1,
494 rfkill_init_sw_state(priv
->rfk
[dev
], 0);
496 sw_blocked
= !sw_blocked
;
497 rfkill_init_sw_state(priv
->rfk
[dev
], sw_blocked
);
500 ret
= rfkill_register(priv
->rfk
[dev
]);
502 rfkill_destroy(priv
->rfk
[dev
]);
508 static void ideapad_unregister_rfkill(struct acpi_device
*adevice
, int dev
)
510 struct ideapad_private
*priv
= dev_get_drvdata(&adevice
->dev
);
515 rfkill_unregister(priv
->rfk
[dev
]);
516 rfkill_destroy(priv
->rfk
[dev
]);
522 static int __devinit
ideapad_platform_init(struct ideapad_private
*priv
)
526 priv
->platform_device
= platform_device_alloc("ideapad", -1);
527 if (!priv
->platform_device
)
529 platform_set_drvdata(priv
->platform_device
, priv
);
531 result
= platform_device_add(priv
->platform_device
);
533 goto fail_platform_device
;
535 result
= sysfs_create_group(&priv
->platform_device
->dev
.kobj
,
536 &ideapad_attribute_group
);
542 platform_device_del(priv
->platform_device
);
543 fail_platform_device
:
544 platform_device_put(priv
->platform_device
);
548 static void ideapad_platform_exit(struct ideapad_private
*priv
)
550 sysfs_remove_group(&priv
->platform_device
->dev
.kobj
,
551 &ideapad_attribute_group
);
552 platform_device_unregister(priv
->platform_device
);
558 static const struct key_entry ideapad_keymap
[] = {
559 { KE_KEY
, 6, { KEY_SWITCHVIDEOMODE
} },
560 { KE_KEY
, 7, { KEY_CAMERA
} },
561 { KE_KEY
, 11, { KEY_F16
} },
562 { KE_KEY
, 13, { KEY_WLAN
} },
563 { KE_KEY
, 16, { KEY_PROG1
} },
564 { KE_KEY
, 17, { KEY_PROG2
} },
565 { KE_KEY
, 64, { KEY_PROG3
} },
566 { KE_KEY
, 65, { KEY_PROG4
} },
567 { KE_KEY
, 66, { KEY_TOUCHPAD_OFF
} },
568 { KE_KEY
, 67, { KEY_TOUCHPAD_ON
} },
572 static int __devinit
ideapad_input_init(struct ideapad_private
*priv
)
574 struct input_dev
*inputdev
;
577 inputdev
= input_allocate_device();
579 pr_info("Unable to allocate input device\n");
583 inputdev
->name
= "Ideapad extra buttons";
584 inputdev
->phys
= "ideapad/input0";
585 inputdev
->id
.bustype
= BUS_HOST
;
586 inputdev
->dev
.parent
= &priv
->platform_device
->dev
;
588 error
= sparse_keymap_setup(inputdev
, ideapad_keymap
, NULL
);
590 pr_err("Unable to setup input device keymap\n");
594 error
= input_register_device(inputdev
);
596 pr_err("Unable to register input device\n");
597 goto err_free_keymap
;
600 priv
->inputdev
= inputdev
;
604 sparse_keymap_free(inputdev
);
606 input_free_device(inputdev
);
610 static void ideapad_input_exit(struct ideapad_private
*priv
)
612 sparse_keymap_free(priv
->inputdev
);
613 input_unregister_device(priv
->inputdev
);
614 priv
->inputdev
= NULL
;
617 static void ideapad_input_report(struct ideapad_private
*priv
,
618 unsigned long scancode
)
620 sparse_keymap_report_event(priv
->inputdev
, scancode
, 1, true);
623 static void ideapad_input_novokey(struct ideapad_private
*priv
)
625 unsigned long long_pressed
;
627 if (read_ec_data(ideapad_handle
, VPCCMD_R_NOVO
, &long_pressed
))
630 ideapad_input_report(priv
, 17);
632 ideapad_input_report(priv
, 16);
635 static void ideapad_check_special_buttons(struct ideapad_private
*priv
)
637 unsigned long bit
, value
;
639 read_ec_data(ideapad_handle
, VPCCMD_R_SPECIAL_BUTTONS
, &value
);
641 for (bit
= 0; bit
< 16; bit
++) {
642 if (test_bit(bit
, &value
)) {
645 /* Thermal Management button */
646 ideapad_input_report(priv
, 65);
649 /* OneKey Theater button */
650 ideapad_input_report(priv
, 64);
660 static int ideapad_backlight_get_brightness(struct backlight_device
*blightdev
)
664 if (read_ec_data(ideapad_handle
, VPCCMD_R_BL
, &now
))
669 static int ideapad_backlight_update_status(struct backlight_device
*blightdev
)
671 if (write_ec_cmd(ideapad_handle
, VPCCMD_W_BL
,
672 blightdev
->props
.brightness
))
674 if (write_ec_cmd(ideapad_handle
, VPCCMD_W_BL_POWER
,
675 blightdev
->props
.power
== FB_BLANK_POWERDOWN
? 0 : 1))
681 static const struct backlight_ops ideapad_backlight_ops
= {
682 .get_brightness
= ideapad_backlight_get_brightness
,
683 .update_status
= ideapad_backlight_update_status
,
686 static int ideapad_backlight_init(struct ideapad_private
*priv
)
688 struct backlight_device
*blightdev
;
689 struct backlight_properties props
;
690 unsigned long max
, now
, power
;
692 if (read_ec_data(ideapad_handle
, VPCCMD_R_BL_MAX
, &max
))
694 if (read_ec_data(ideapad_handle
, VPCCMD_R_BL
, &now
))
696 if (read_ec_data(ideapad_handle
, VPCCMD_R_BL_POWER
, &power
))
699 memset(&props
, 0, sizeof(struct backlight_properties
));
700 props
.max_brightness
= max
;
701 props
.type
= BACKLIGHT_PLATFORM
;
702 blightdev
= backlight_device_register("ideapad",
703 &priv
->platform_device
->dev
,
705 &ideapad_backlight_ops
,
707 if (IS_ERR(blightdev
)) {
708 pr_err("Could not register backlight device\n");
709 return PTR_ERR(blightdev
);
712 priv
->blightdev
= blightdev
;
713 blightdev
->props
.brightness
= now
;
714 blightdev
->props
.power
= power
? FB_BLANK_UNBLANK
: FB_BLANK_POWERDOWN
;
715 backlight_update_status(blightdev
);
720 static void ideapad_backlight_exit(struct ideapad_private
*priv
)
723 backlight_device_unregister(priv
->blightdev
);
724 priv
->blightdev
= NULL
;
727 static void ideapad_backlight_notify_power(struct ideapad_private
*priv
)
730 struct backlight_device
*blightdev
= priv
->blightdev
;
734 if (read_ec_data(ideapad_handle
, VPCCMD_R_BL_POWER
, &power
))
736 blightdev
->props
.power
= power
? FB_BLANK_UNBLANK
: FB_BLANK_POWERDOWN
;
739 static void ideapad_backlight_notify_brightness(struct ideapad_private
*priv
)
743 /* if we control brightness via acpi video driver */
744 if (priv
->blightdev
== NULL
) {
745 read_ec_data(ideapad_handle
, VPCCMD_R_BL
, &now
);
749 backlight_force_update(priv
->blightdev
, BACKLIGHT_UPDATE_HOTKEY
);
755 static const struct acpi_device_id ideapad_device_ids
[] = {
759 MODULE_DEVICE_TABLE(acpi
, ideapad_device_ids
);
761 static void ideapad_sync_touchpad_state(struct acpi_device
*adevice
)
763 struct ideapad_private
*priv
= dev_get_drvdata(&adevice
->dev
);
766 /* Without reading from EC touchpad LED doesn't switch state */
767 if (!read_ec_data(adevice
->handle
, VPCCMD_R_TOUCHPAD
, &value
)) {
768 /* Some IdeaPads don't really turn off touchpad - they only
769 * switch the LED state. We (de)activate KBC AUX port to turn
770 * touchpad off and on. We send KEY_TOUCHPAD_OFF and
771 * KEY_TOUCHPAD_ON to not to get out of sync with LED */
773 i8042_command(¶m
, value
? I8042_CMD_AUX_ENABLE
:
774 I8042_CMD_AUX_DISABLE
);
775 ideapad_input_report(priv
, value
? 67 : 66);
779 static int __devinit
ideapad_acpi_add(struct acpi_device
*adevice
)
783 struct ideapad_private
*priv
;
785 if (read_method_int(adevice
->handle
, "_CFG", &cfg
))
788 priv
= kzalloc(sizeof(*priv
), GFP_KERNEL
);
791 dev_set_drvdata(&adevice
->dev
, priv
);
793 ideapad_handle
= adevice
->handle
;
796 ret
= ideapad_platform_init(priv
);
798 goto platform_failed
;
800 ret
= ideapad_debugfs_init(priv
);
804 ret
= ideapad_input_init(priv
);
808 for (i
= 0; i
< IDEAPAD_RFKILL_DEV_NUM
; i
++) {
809 if (test_bit(ideapad_rfk_data
[i
].cfgbit
, &priv
->cfg
))
810 ideapad_register_rfkill(adevice
, i
);
814 ideapad_sync_rfk_state(priv
);
815 ideapad_sync_touchpad_state(adevice
);
817 if (!acpi_video_backlight_support()) {
818 ret
= ideapad_backlight_init(priv
);
819 if (ret
&& ret
!= -ENODEV
)
820 goto backlight_failed
;
826 for (i
= 0; i
< IDEAPAD_RFKILL_DEV_NUM
; i
++)
827 ideapad_unregister_rfkill(adevice
, i
);
828 ideapad_input_exit(priv
);
830 ideapad_debugfs_exit(priv
);
832 ideapad_platform_exit(priv
);
838 static int __devexit
ideapad_acpi_remove(struct acpi_device
*adevice
, int type
)
840 struct ideapad_private
*priv
= dev_get_drvdata(&adevice
->dev
);
843 ideapad_backlight_exit(priv
);
844 for (i
= 0; i
< IDEAPAD_RFKILL_DEV_NUM
; i
++)
845 ideapad_unregister_rfkill(adevice
, i
);
846 ideapad_input_exit(priv
);
847 ideapad_debugfs_exit(priv
);
848 ideapad_platform_exit(priv
);
849 dev_set_drvdata(&adevice
->dev
, NULL
);
855 static void ideapad_acpi_notify(struct acpi_device
*adevice
, u32 event
)
857 struct ideapad_private
*priv
= dev_get_drvdata(&adevice
->dev
);
858 acpi_handle handle
= adevice
->handle
;
859 unsigned long vpc1
, vpc2
, vpc_bit
;
861 if (read_ec_data(handle
, VPCCMD_R_VPC1
, &vpc1
))
863 if (read_ec_data(handle
, VPCCMD_R_VPC2
, &vpc2
))
866 vpc1
= (vpc2
<< 8) | vpc1
;
867 for (vpc_bit
= 0; vpc_bit
< 16; vpc_bit
++) {
868 if (test_bit(vpc_bit
, &vpc1
)) {
871 ideapad_sync_rfk_state(priv
);
877 ideapad_input_report(priv
, vpc_bit
);
880 ideapad_sync_touchpad_state(adevice
);
883 ideapad_backlight_notify_brightness(priv
);
886 ideapad_input_novokey(priv
);
889 ideapad_backlight_notify_power(priv
);
892 ideapad_check_special_buttons(priv
);
895 pr_info("Unknown event: %lu\n", vpc_bit
);
901 static int ideapad_acpi_resume(struct device
*device
)
903 ideapad_sync_rfk_state(ideapad_priv
);
904 ideapad_sync_touchpad_state(to_acpi_device(device
));
908 static SIMPLE_DEV_PM_OPS(ideapad_pm
, NULL
, ideapad_acpi_resume
);
910 static struct acpi_driver ideapad_acpi_driver
= {
911 .name
= "ideapad_acpi",
913 .ids
= ideapad_device_ids
,
914 .ops
.add
= ideapad_acpi_add
,
915 .ops
.remove
= ideapad_acpi_remove
,
916 .ops
.notify
= ideapad_acpi_notify
,
917 .drv
.pm
= &ideapad_pm
,
918 .owner
= THIS_MODULE
,
921 static int __init
ideapad_acpi_module_init(void)
923 return acpi_bus_register_driver(&ideapad_acpi_driver
);
926 static void __exit
ideapad_acpi_module_exit(void)
928 acpi_bus_unregister_driver(&ideapad_acpi_driver
);
931 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
932 MODULE_DESCRIPTION("IdeaPad ACPI Extras");
933 MODULE_LICENSE("GPL");
935 module_init(ideapad_acpi_module_init
);
936 module_exit(ideapad_acpi_module_exit
);