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 WACOM_WORKER_MODE_CHANGE,
114};
115
116struct wacom;
117
118struct wacom_led {
119 struct led_classdev cdev;
120 struct led_trigger trigger;
121 struct wacom *wacom;
122 unsigned int group;
123 unsigned int id;
124 u8 llv;
125 u8 hlv;
126 bool held;
127};
128
129struct wacom_group_leds {
130 u8 select;
131 struct wacom_led *leds;
132 unsigned int count;
133 struct device *dev;
134};
135
136struct wacom_battery {
137 struct wacom *wacom;
138 struct power_supply_desc bat_desc;
139 struct power_supply *battery;
140 char bat_name[WACOM_NAME_MAX];
141 int battery_capacity;
142 int bat_charging;
143 int bat_connected;
144 int ps_connected;
145};
146
147struct wacom_remote {
148 spinlock_t remote_lock;
149 struct kfifo remote_fifo;
150 struct kobject *remote_dir;
151 struct {
152 struct attribute_group group;
153 u32 serial;
154 struct input_dev *input;
155 bool registered;
156 struct wacom_battery battery;
157 } remotes[WACOM_MAX_REMOTES];
158};
159
160struct wacom {
161 struct usb_device *usbdev;
162 struct usb_interface *intf;
163 struct wacom_wac wacom_wac;
164 struct hid_device *hdev;
165 struct mutex lock;
166 struct work_struct wireless_work;
167 struct work_struct battery_work;
168 struct work_struct remote_work;
169 struct delayed_work init_work;
170 struct wacom_remote *remote;
171 struct work_struct mode_change_work;
172 bool generic_has_leds;
173 struct wacom_leds {
174 struct wacom_group_leds *groups;
175 unsigned int count;
176 u8 llv;
177 u8 hlv;
178 u8 img_lum;
179 u8 max_llv;
180 u8 max_hlv;
181 } led;
182 struct wacom_battery battery;
183 bool resources;
184};
185
186static inline void wacom_schedule_work(struct wacom_wac *wacom_wac,
187 enum wacom_worker which)
188{
189 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
190
191 switch (which) {
192 case WACOM_WORKER_WIRELESS:
193 schedule_work(&wacom->wireless_work);
194 break;
195 case WACOM_WORKER_BATTERY:
196 schedule_work(&wacom->battery_work);
197 break;
198 case WACOM_WORKER_REMOTE:
199 schedule_work(&wacom->remote_work);
200 break;
201 case WACOM_WORKER_MODE_CHANGE:
202 schedule_work(&wacom->mode_change_work);
203 break;
204 }
205}
206
207extern const struct hid_device_id wacom_ids[];
208
209void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
210void wacom_setup_device_quirks(struct wacom *wacom);
211int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
212 struct wacom_wac *wacom_wac);
213int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
214 struct wacom_wac *wacom_wac);
215int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
216 struct wacom_wac *wacom_wac);
217void wacom_wac_usage_mapping(struct hid_device *hdev,
218 struct hid_field *field, struct hid_usage *usage);
219void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
220 struct hid_usage *usage, __s32 value);
221void wacom_wac_report(struct hid_device *hdev, struct hid_report *report);
222void wacom_battery_work(struct work_struct *work);
223enum led_brightness wacom_leds_brightness_get(struct wacom_led *led);
224struct wacom_led *wacom_led_find(struct wacom *wacom, unsigned int group,
225 unsigned int id);
226struct wacom_led *wacom_led_next(struct wacom *wacom, struct wacom_led *cur);
227int wacom_equivalent_usage(int usage);
228int wacom_initialize_leds(struct wacom *wacom);
229#endif
230