14 #include <linux/module.h>
15 #include <linux/input.h>
16 #include <linux/i2c.h>
17 #include <linux/slab.h>
21 #include <asm/unaligned.h>
23 #define WACOM_CMD_QUERY0 0x04
24 #define WACOM_CMD_QUERY1 0x00
25 #define WACOM_CMD_QUERY2 0x33
26 #define WACOM_CMD_QUERY3 0x02
27 #define WACOM_CMD_THROW0 0x05
28 #define WACOM_CMD_THROW1 0x00
29 #define WACOM_QUERY_SIZE 19
30 #define WACOM_RETRY_CNT 100
80 features->
x_max = get_unaligned_le16(&data[3]);
81 features->
y_max = get_unaligned_le16(&data[5]);
83 features->
fw_version = get_unaligned_le16(&data[13]);
86 "x_max:%d, y_max:%d, pressure:%d, fw:%d\n",
98 unsigned int x,
y, pressure;
99 unsigned char tsw,
f1,
f2, ers;
103 wac_i2c->
data,
sizeof(wac_i2c->
data));
107 tsw = data[3] & 0x01;
108 ers = data[3] & 0x04;
115 input_report_key(input,
BTN_TOUCH, tsw || ers);
120 input_report_abs(input,
ABS_X, x);
121 input_report_abs(input,
ABS_Y, y);
129 static int wacom_i2c_open(
struct input_dev *
dev)
131 struct wacom_i2c *wac_i2c = input_get_drvdata(dev);
139 static void wacom_i2c_close(
struct input_dev *
dev)
141 struct wacom_i2c *wac_i2c = input_get_drvdata(dev);
151 struct input_dev *
input;
156 dev_err(&client->
dev,
"i2c_check_functionality error\n");
160 error = wacom_query_device(client, &features);
164 wac_i2c = kzalloc(
sizeof(*wac_i2c),
GFP_KERNEL);
165 input = input_allocate_device();
166 if (!wac_i2c || !input) {
174 input->name =
"Wacom I2C Digitizer";
176 input->id.vendor = 0x56a;
178 input->dev.parent = &client->
dev;
179 input->open = wacom_i2c_open;
180 input->close = wacom_i2c_close;
190 input_set_abs_params(input,
ABS_X, 0, features.
x_max, 0, 0);
191 input_set_abs_params(input,
ABS_Y, 0, features.
y_max, 0, 0);
195 input_set_drvdata(input, wac_i2c);
199 "wacom_i2c", wac_i2c);
202 "Failed to enable IRQ, error: %d\n", error);
209 error = input_register_device(wac_i2c->
input);
212 "Failed to register input device, error: %d\n", error);
216 i2c_set_clientdata(client, wac_i2c);
222 input_free_device(input);
230 struct wacom_i2c *wac_i2c = i2c_get_clientdata(client);
233 input_unregister_device(wac_i2c->
input);
239 #ifdef CONFIG_PM_SLEEP
240 static int wacom_i2c_suspend(
struct device *
dev)
249 static int wacom_i2c_resume(
struct device *
dev)
262 {
"WAC_I2C_EMR", 0 },
274 .probe = wacom_i2c_probe,
276 .id_table = wacom_i2c_id,