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#define DRIVER_LICENSE "GPL"
106
107#define USB_VENDOR_ID_WACOM 0x056a
108#define USB_VENDOR_ID_LENOVO 0x17ef
109
110enum wacom_worker {
111 WACOM_WORKER_WIRELESS,
112 WACOM_WORKER_BATTERY,
113 WACOM_WORKER_REMOTE,
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 wacom_remote *remote;
170 struct wacom_leds {
171 struct wacom_group_leds *groups;
172 unsigned int count;
173 u8 llv;
174 u8 hlv;
175 u8 img_lum;
176 u8 max_llv;
177 u8 max_hlv;
178 } led;
179 struct wacom_battery battery;
180 bool resources;
181};
182
183static inline void wacom_schedule_work(struct wacom_wac *wacom_wac,
184 enum wacom_worker which)
185{
186 struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
187
188 switch (which) {
189 case WACOM_WORKER_WIRELESS:
190 schedule_work(&wacom->wireless_work);
191 break;
192 case WACOM_WORKER_BATTERY:
193 schedule_work(&wacom->battery_work);
194 break;
195 case WACOM_WORKER_REMOTE:
196 schedule_work(&wacom->remote_work);
197 break;
198 }
199}
200
201extern const struct hid_device_id wacom_ids[];
202
203void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
204void wacom_setup_device_quirks(struct wacom *wacom);
205int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
206 struct wacom_wac *wacom_wac);
207int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
208 struct wacom_wac *wacom_wac);
209int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
210 struct wacom_wac *wacom_wac);
211void wacom_wac_usage_mapping(struct hid_device *hdev,
212 struct hid_field *field, struct hid_usage *usage);
213int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
214 struct hid_usage *usage, __s32 value);
215void wacom_wac_report(struct hid_device *hdev, struct hid_report *report);
216void wacom_battery_work(struct work_struct *work);
217enum led_brightness wacom_leds_brightness_get(struct wacom_led *led);
218struct wacom_led *wacom_led_find(struct wacom *wacom, unsigned int group,
219 unsigned int id);
220struct wacom_led *wacom_led_next(struct wacom *wacom, struct wacom_led *cur);
221#endif
222