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
86#ifndef WACOM_H
87#define WACOM_H
88#include <linux/kernel.h>
89#include <linux/slab.h>
90#include <linux/module.h>
91#include <linux/mod_devicetable.h>
92#include <linux/hid.h>
93#include <linux/kfifo.h>
94#include <linux/leds.h>
95#include <linux/usb/input.h>
96#include <linux/power_supply.h>
97#include <asm/unaligned.h>
98
99
100
101
102#define DRIVER_VERSION "v2.00"
103#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
104#define DRIVER_DESC "USB Wacom tablet driver"
105
106#define USB_VENDOR_ID_WACOM 0x056a
107#define USB_VENDOR_ID_LENOVO 0x17ef
108
109enum wacom_worker {
110 WACOM_WORKER_WIRELESS,
111 WACOM_WORKER_BATTERY,
112 WACOM_WORKER_REMOTE,
113};
114
115struct wacom;
116
117struct wacom_led {
118 struct led_classdev cdev;
119 struct led_trigger trigger;
120 struct wacom *wacom;
121 unsigned int group;
122 unsigned int id;
123 u8 llv;
124 u8 hlv;
125 bool held;
126};
127
128struct wacom_group_leds {
129 u8 select;
130 struct wacom_led *leds;
131 unsigned int count;
132 struct device *dev;
133};
134
135struct wacom_battery {
136 struct wacom *wacom;
137 struct power_supply_desc bat_desc;
138 struct power_supply *battery;
139 char bat_name[WACOM_NAME_MAX];
140 int battery_capacity;
141 int bat_charging;
142 int bat_connected;
143 int ps_connected;
144};
145
146struct wacom_remote {
147 spinlock_t remote_lock;
148 struct kfifo remote_fifo;
149 struct kobject *remote_dir;
150 struct {
151 struct attribute_group group;
152 u32 serial;
153 struct input_dev *input;
154 bool registered;
155 struct wacom_battery battery;
156 } remotes[WACOM_MAX_REMOTES];
157};
158
159struct wacom {
160 struct usb_device *usbdev;
161 struct usb_interface *intf;
162 struct wacom_wac wacom_wac;
163 struct hid_device *hdev;
164 struct mutex lock;
165 struct work_struct wireless_work;
166 struct work_struct battery_work;
167 struct work_struct remote_work;
168 struct delayed_work init_work;
169 struct wacom_remote *remote;
170 bool generic_has_leds;
171 struct wacom_leds {
172 struct wacom_group_leds *groups;
173 unsigned int count;
174 u8 llv;
175 u8 hlv;
176 u8 img_lum;
177 u8 max_llv;
178 u8 max_hlv;
179 } led;
180 struct wacom_battery battery;
181 bool resources;
182};
183
184static inline void wacom_schedule_work(struct wacom_wac *wacom_wac,
185 enum wacom_worker which)
186{
187 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
188
189 switch (which) {
190 case WACOM_WORKER_WIRELESS:
191 schedule_work(&wacom->wireless_work);
192 break;
193 case WACOM_WORKER_BATTERY:
194 schedule_work(&wacom->battery_work);
195 break;
196 case WACOM_WORKER_REMOTE:
197 schedule_work(&wacom->remote_work);
198 break;
199 }
200}
201
202extern const struct hid_device_id wacom_ids[];
203
204void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
205void wacom_setup_device_quirks(struct wacom *wacom);
206int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
207 struct wacom_wac *wacom_wac);
208int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
209 struct wacom_wac *wacom_wac);
210int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
211 struct wacom_wac *wacom_wac);
212void wacom_wac_usage_mapping(struct hid_device *hdev,
213 struct hid_field *field, struct hid_usage *usage);
214void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
215 struct hid_usage *usage, __s32 value);
216void wacom_wac_report(struct hid_device *hdev, struct hid_report *report);
217void wacom_battery_work(struct work_struct *work);
218enum led_brightness wacom_leds_brightness_get(struct wacom_led *led);
219struct wacom_led *wacom_led_find(struct wacom *wacom, unsigned int group,
220 unsigned int id);
221struct wacom_led *wacom_led_next(struct wacom *wacom, struct wacom_led *cur);
222int wacom_equivalent_usage(int usage);
223int wacom_initialize_leds(struct wacom *wacom);
224#endif
225