Lines Matching defs:wacom

15  *  - the USB wacom input driver, credited to many people
16 * (see drivers/input/tablet/wacom.h);
17 * - new and old versions of linuxwacom / xf86-input-wacom credited to
19 * Ping Cheng, Wacom. <pingc@wacom.com>;
163 struct wacom {
188 static void wacom_handle_model_response(struct wacom *wacom)
193 p = strrchr(wacom->data, 'V');
199 switch (wacom->data[2] << 8 | wacom->data[3]) {
202 if ((wacom->data[2] << 8 | wacom->data[3]) == MODEL_CINTIQ) {
203 wacom->dev->name = "Wacom Cintiq";
204 wacom->dev->id.version = MODEL_CINTIQ;
206 wacom->dev->name = "Wacom Cintiq II";
207 wacom->dev->id.version = MODEL_CINTIQ2;
209 wacom->res_x = 508;
210 wacom->res_y = 508;
212 switch (wacom->data[5] << 8 | wacom->data[6]) {
214 wacom->res_x = 2540;
215 wacom->res_y = 2540;
219 wacom->extra_z_bits = 2;
222 wacom->flags = F_COVERS_SCREEN;
226 wacom->dev->name = "Wacom Penpartner";
227 wacom->dev->id.version = MODEL_PENPARTNER;
228 wacom->res_x = 1000;
229 wacom->res_y = 1000;
233 wacom->dev->name = "Wacom Graphire";
234 wacom->dev->id.version = MODEL_GRAPHIRE;
235 wacom->res_x = 1016;
236 wacom->res_y = 1016;
237 wacom->max_x = 5103;
238 wacom->max_y = 3711;
239 wacom->extra_z_bits = 2;
240 wacom->eraser_mask = 0x08;
241 wacom->flags = F_HAS_STYLUS2 | F_HAS_SCROLLWHEEL;
246 wacom->dev->name = "Wacom Digitizer II";
247 wacom->dev->id.version = MODEL_DIGITIZER_II;
249 wacom->extra_z_bits = 0; /* UNTESTED */
253 dev_err(&wacom->dev->dev, "Unsupported Wacom model %s\n",
254 wacom->data);
255 wacom->result = -ENODEV;
259 dev_info(&wacom->dev->dev, "%s tablet, version %u.%u\n",
260 wacom->dev->name, major_v, minor_v);
263 static void wacom_handle_configuration_response(struct wacom *wacom)
267 dev_dbg(&wacom->dev->dev, "Configuration string: %s\n", wacom->data);
268 r = sscanf(wacom->data, "~R%x,%u,%u,%u,%u", &skip, &skip, &skip,
269 &wacom->res_x, &wacom->res_y);
271 dev_warn(&wacom->dev->dev, "could not get resolution\n");
274 static void wacom_handle_coordinates_response(struct wacom *wacom)
278 dev_dbg(&wacom->dev->dev, "Coordinates string: %s\n", wacom->data);
279 r = sscanf(wacom->data, "~C%u,%u", &wacom->max_x, &wacom->max_y);
281 dev_warn(&wacom->dev->dev, "could not get max coordinates\n");
284 static void wacom_handle_response(struct wacom *wacom)
286 if (wacom->data[0] != '~' || wacom->data[1] != wacom->expect) {
287 dev_err(&wacom->dev->dev,
288 "Wacom got an unexpected response: %s\n", wacom->data);
289 wacom->result = -EIO;
291 wacom->result = 0;
293 switch (wacom->data[1]) {
295 wacom_handle_model_response(wacom);
298 wacom_handle_configuration_response(wacom);
301 wacom_handle_coordinates_response(wacom);
306 complete(&wacom->cmd_done);
309 static void wacom_handle_packet(struct wacom *wacom)
315 in_proximity_p = wacom->data[0] & 0x40;
316 stylus_p = wacom->data[0] & 0x20;
317 button = (wacom->data[3] & 0x78) >> 3;
318 x = (wacom->data[0] & 3) << 14 | wacom->data[1]<<7 | wacom->data[2];
319 y = (wacom->data[3] & 3) << 14 | wacom->data[4]<<7 | wacom->data[5];
322 z = wacom->data[6] & 0x7f;
323 if (wacom->extra_z_bits >= 1)
324 z = z << 1 | (wacom->data[3] & 0x4) >> 2;
325 if (wacom->extra_z_bits > 1)
326 z = z << 1 | (wacom->data[0] & 0x4) >> 2;
327 z = z ^ (0x40 << wacom->extra_z_bits);
333 tool = (button & wacom->eraser_mask) ? ERASER : STYLUS;
337 if (tool != wacom->tool && wacom->tool != 0) {
338 input_report_key(wacom->dev, tools[wacom->tool].input_id, 0);
339 input_sync(wacom->dev);
341 wacom->tool = tool;
343 input_report_key(wacom->dev, tools[tool].input_id, in_proximity_p);
344 input_report_abs(wacom->dev, ABS_MISC,
346 input_report_abs(wacom->dev, ABS_X, x);
347 input_report_abs(wacom->dev, ABS_Y, y);
348 input_report_abs(wacom->dev, ABS_PRESSURE, z);
350 input_report_key(wacom->dev, BTN_TOUCH, button & 1);
351 input_report_key(wacom->dev, BTN_STYLUS, button & 2);
352 input_report_key(wacom->dev, BTN_STYLUS2, button & 4);
354 input_report_key(wacom->dev, BTN_LEFT, button & 1);
355 input_report_key(wacom->dev, BTN_RIGHT, button & 2);
356 input_report_key(wacom->dev, BTN_MIDDLE, button & 4);
358 z = (wacom->data[6] & 0x30) >> 4;
359 if (wacom->data[6] & 0x40)
361 input_report_rel(wacom->dev, REL_WHEEL, z);
363 input_sync(wacom->dev);
366 static void wacom_clear_data_buf(struct wacom *wacom)
368 memset(wacom->data, 0, DATA_SIZE);
369 wacom->idx = 0;
375 struct wacom *wacom = serio_get_drvdata(serio);
378 wacom->idx = 0;
389 if (data == '\r' && !(wacom->data[0] & 0x80)) {
390 wacom_handle_response(wacom);
391 wacom_clear_data_buf(wacom);
396 if (wacom->idx > (DATA_SIZE - 2)) {
397 dev_dbg(&wacom->dev->dev,
398 "throwing away %d bytes of garbage\n", wacom->idx);
399 wacom_clear_data_buf(wacom);
401 wacom->data[wacom->idx++] = data;
403 if (wacom->idx == PACKET_LENGTH && (wacom->data[0] & 0x80)) {
404 wacom_handle_packet(wacom);
405 wacom_clear_data_buf(wacom);
413 struct wacom *wacom = serio_get_drvdata(serio);
417 input_unregister_device(wacom->dev);
418 kfree(wacom);
431 static int wacom_send_setup_string(struct wacom *wacom, struct serio *serio)
435 switch (wacom->dev->id.version) {
464 static int wacom_send_and_wait(struct wacom *wacom, struct serio *serio,
470 wacom->expect = cmd[1];
471 init_completion(&wacom->cmd_done);
477 u = wait_for_completion_timeout(&wacom->cmd_done, HZ);
480 wacom_handle_response(wacom);
483 wacom->expect = 0;
484 return wacom->result;
487 static int wacom_setup(struct wacom *wacom, struct serio *serio)
494 err = wacom_send_and_wait(wacom, serio, REQUEST_MODEL_AND_ROM_VERSION,
499 if (!(wacom->res_x && wacom->res_y)) {
500 err = wacom_send_and_wait(wacom, serio,
507 if (!(wacom->max_x && wacom->max_y)) {
508 err = wacom_send_and_wait(wacom, serio,
515 return wacom_send_setup_string(wacom, serio);
520 struct wacom *wacom;
524 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
526 if (!wacom || !input_dev)
529 wacom->dev = input_dev;
530 wacom->extra_z_bits = 1;
531 wacom->eraser_mask = 0x04;
532 wacom->tool = wacom->idx = 0;
533 snprintf(wacom->phys, sizeof(wacom->phys), "%s/input0", serio->phys);
534 input_dev->phys = wacom->phys;
552 serio_set_drvdata(serio, wacom);
558 err = wacom_setup(wacom, serio);
563 if (!(wacom->flags & F_COVERS_SCREEN))
566 if (wacom->flags & F_HAS_STYLUS2)
569 if (wacom->flags & F_HAS_SCROLLWHEEL)
572 input_abs_set_res(wacom->dev, ABS_X, wacom->res_x);
573 input_abs_set_res(wacom->dev, ABS_Y, wacom->res_y);
574 input_set_abs_params(wacom->dev, ABS_X, 0, wacom->max_x, 0, 0);
575 input_set_abs_params(wacom->dev, ABS_Y, 0, wacom->max_y, 0, 0);
576 input_set_abs_params(wacom->dev, ABS_PRESSURE, -1,
577 (1 << (7 + wacom->extra_z_bits)) - 1, 0, 0);
579 err = input_register_device(wacom->dev);
590 kfree(wacom);