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