2 * atlas_btns.c - Atlas Wallmount Touchscreen ACPI Extras
4 * Copyright (C) 2006 Jaya Kumar
5 * Based on Toshiba ACPI by John Belmonte and ASUS ACPI
6 * This work was sponsored by CIS(M) Sdn Bhd.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/init.h>
27 #include <linux/input.h>
28 #include <linux/types.h>
29 #include <asm/uaccess.h>
30 #include <acpi/acpi_drivers.h>
32 #define ACPI_ATLAS_NAME "Atlas ACPI"
33 #define ACPI_ATLAS_CLASS "Atlas"
35 static struct input_dev
*input_dev
;
37 /* button handling code */
38 static acpi_status
acpi_atlas_button_setup(acpi_handle region_handle
,
39 u32 function
, void *handler_context
, void **return_context
)
42 (function
!= ACPI_REGION_DEACTIVATE
) ? handler_context
: NULL
;
47 static acpi_status
acpi_atlas_button_handler(u32 function
,
48 acpi_physical_address address
,
49 u32 bit_width
, acpi_integer
*value
,
50 void *handler_context
, void *region_context
)
55 if (function
== ACPI_WRITE
) {
56 keycode
= KEY_F1
+ (address
& 0x0F);
57 input_report_key(input_dev
, keycode
, !(address
& 0x10));
58 input_sync(input_dev
);
61 printk(KERN_WARNING
"atlas: shrugged on unexpected function"
62 ":function=%x,address=%lx,value=%x\n",
63 function
, (unsigned long)address
, (u32
)*value
);
70 static int atlas_acpi_button_add(struct acpi_device
*device
)
75 input_dev
= input_allocate_device();
77 printk(KERN_ERR
"atlas: unable to allocate input device\n");
81 input_dev
->name
= "Atlas ACPI button driver";
82 input_dev
->phys
= "ASIM0000/atlas/input0";
83 input_dev
->id
.bustype
= BUS_HOST
;
84 input_dev
->evbit
[BIT_WORD(EV_KEY
)] = BIT_MASK(EV_KEY
);
86 set_bit(KEY_F1
, input_dev
->keybit
);
87 set_bit(KEY_F2
, input_dev
->keybit
);
88 set_bit(KEY_F3
, input_dev
->keybit
);
89 set_bit(KEY_F4
, input_dev
->keybit
);
90 set_bit(KEY_F5
, input_dev
->keybit
);
91 set_bit(KEY_F6
, input_dev
->keybit
);
92 set_bit(KEY_F7
, input_dev
->keybit
);
93 set_bit(KEY_F8
, input_dev
->keybit
);
94 set_bit(KEY_F9
, input_dev
->keybit
);
96 err
= input_register_device(input_dev
);
98 printk(KERN_ERR
"atlas: couldn't register input device\n");
99 input_free_device(input_dev
);
103 /* hookup button handler */
104 status
= acpi_install_address_space_handler(device
->handle
,
105 0x81, &acpi_atlas_button_handler
,
106 &acpi_atlas_button_setup
, device
);
107 if (ACPI_FAILURE(status
)) {
108 printk(KERN_ERR
"Atlas: Error installing addr spc handler\n");
109 input_unregister_device(input_dev
);
116 static int atlas_acpi_button_remove(struct acpi_device
*device
, int type
)
120 status
= acpi_remove_address_space_handler(device
->handle
,
121 0x81, &acpi_atlas_button_handler
);
122 if (ACPI_FAILURE(status
)) {
123 printk(KERN_ERR
"Atlas: Error removing addr spc handler\n");
127 input_unregister_device(input_dev
);
132 static const struct acpi_device_id atlas_device_ids
[] = {
136 MODULE_DEVICE_TABLE(acpi
, atlas_device_ids
);
138 static struct acpi_driver atlas_acpi_driver
= {
139 .name
= ACPI_ATLAS_NAME
,
140 .class = ACPI_ATLAS_CLASS
,
141 .ids
= atlas_device_ids
,
143 .add
= atlas_acpi_button_add
,
144 .remove
= atlas_acpi_button_remove
,
148 static int __init
atlas_acpi_init(void)
155 result
= acpi_bus_register_driver(&atlas_acpi_driver
);
157 printk(KERN_ERR
"Atlas ACPI: Unable to register driver\n");
164 static void __exit
atlas_acpi_exit(void)
166 acpi_bus_unregister_driver(&atlas_acpi_driver
);
169 module_init(atlas_acpi_init
);
170 module_exit(atlas_acpi_exit
);
172 MODULE_AUTHOR("Jaya Kumar");
173 MODULE_LICENSE("GPL");
174 MODULE_DESCRIPTION("Atlas button driver");