|
6 | 6 |
|
7 | 7 | */
|
8 | 8 |
|
| 9 | +#include <linux/bits.h> |
9 | 10 | #include <linux/module.h>
|
10 | 11 | #include <linux/input.h>
|
11 | 12 | #include <linux/i2c.h>
|
|
14 | 15 | #include <linux/interrupt.h>
|
15 | 16 | #include <asm/unaligned.h>
|
16 | 17 |
|
| 18 | +/* Bitmasks (for data[3]) */ |
| 19 | +#define WACOM_TIP_SWITCH BIT(0) |
| 20 | +#define WACOM_BARREL_SWITCH BIT(1) |
| 21 | +#define WACOM_ERASER BIT(2) |
| 22 | +#define WACOM_INVERT BIT(3) |
| 23 | +#define WACOM_BARREL_SWITCH_2 BIT(4) |
| 24 | +#define WACOM_IN_PROXIMITY BIT(5) |
| 25 | + |
| 26 | +/* Registers */ |
17 | 27 | #define WACOM_CMD_QUERY0 0x04
|
18 | 28 | #define WACOM_CMD_QUERY1 0x00
|
19 | 29 | #define WACOM_CMD_QUERY2 0x33
|
@@ -99,19 +109,19 @@ static irqreturn_t wacom_i2c_irq(int irq, void *dev_id)
|
99 | 109 | if (error < 0)
|
100 | 110 | goto out;
|
101 | 111 |
|
102 |
| - tsw = data[3] & 0x01; |
103 |
| - ers = data[3] & 0x04; |
104 |
| - f1 = data[3] & 0x02; |
105 |
| - f2 = data[3] & 0x10; |
| 112 | + tsw = data[3] & WACOM_TIP_SWITCH; |
| 113 | + ers = data[3] & WACOM_ERASER; |
| 114 | + f1 = data[3] & WACOM_BARREL_SWITCH; |
| 115 | + f2 = data[3] & WACOM_BARREL_SWITCH_2; |
106 | 116 | x = le16_to_cpup((__le16 *)&data[4]);
|
107 | 117 | y = le16_to_cpup((__le16 *)&data[6]);
|
108 | 118 | pressure = le16_to_cpup((__le16 *)&data[8]);
|
109 | 119 |
|
110 | 120 | if (!wac_i2c->prox)
|
111 |
| - wac_i2c->tool = (data[3] & 0x0c) ? |
| 121 | + wac_i2c->tool = (data[3] & (WACOM_ERASER | WACOM_INVERT)) ? |
112 | 122 | BTN_TOOL_RUBBER : BTN_TOOL_PEN;
|
113 | 123 |
|
114 |
| - wac_i2c->prox = data[3] & 0x20; |
| 124 | + wac_i2c->prox = data[3] & WACOM_IN_PROXIMITY; |
115 | 125 |
|
116 | 126 | input_report_key(input, BTN_TOUCH, tsw || ers);
|
117 | 127 | input_report_key(input, wac_i2c->tool, wac_i2c->prox);
|
|
0 commit comments