w8001             138 drivers/input/touchscreen/wacom_w8001.c static void scale_touch_coordinates(struct w8001 *w8001,
w8001             141 drivers/input/touchscreen/wacom_w8001.c 	if (w8001->max_pen_x && w8001->max_touch_x)
w8001             142 drivers/input/touchscreen/wacom_w8001.c 		*x = *x * w8001->max_pen_x / w8001->max_touch_x;
w8001             144 drivers/input/touchscreen/wacom_w8001.c 	if (w8001->max_pen_y && w8001->max_touch_y)
w8001             145 drivers/input/touchscreen/wacom_w8001.c 		*y = *y * w8001->max_pen_y / w8001->max_touch_y;
w8001             148 drivers/input/touchscreen/wacom_w8001.c static void parse_multi_touch(struct w8001 *w8001)
w8001             150 drivers/input/touchscreen/wacom_w8001.c 	struct input_dev *dev = w8001->touch_dev;
w8001             151 drivers/input/touchscreen/wacom_w8001.c 	unsigned char *data = w8001->data;
w8001             167 drivers/input/touchscreen/wacom_w8001.c 			scale_touch_coordinates(w8001, &x, &y);
w8001             179 drivers/input/touchscreen/wacom_w8001.c 	if (w8001->type != BTN_TOOL_PEN &&
w8001             180 drivers/input/touchscreen/wacom_w8001.c 			    w8001->type != BTN_TOOL_RUBBER) {
w8001             181 drivers/input/touchscreen/wacom_w8001.c 		w8001->type = count == 1 ? BTN_TOOL_FINGER : KEY_RESERVED;
w8001             214 drivers/input/touchscreen/wacom_w8001.c static void report_pen_events(struct w8001 *w8001, struct w8001_coord *coord)
w8001             216 drivers/input/touchscreen/wacom_w8001.c 	struct input_dev *dev = w8001->pen_dev;
w8001             228 drivers/input/touchscreen/wacom_w8001.c 	switch (w8001->type) {
w8001             237 drivers/input/touchscreen/wacom_w8001.c 			w8001->type = BTN_TOOL_PEN;
w8001             243 drivers/input/touchscreen/wacom_w8001.c 		w8001->type = coord->f2 ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
w8001             256 drivers/input/touchscreen/wacom_w8001.c 	input_report_key(dev, w8001->type, coord->rdy);
w8001             260 drivers/input/touchscreen/wacom_w8001.c 		w8001->type = KEY_RESERVED;
w8001             263 drivers/input/touchscreen/wacom_w8001.c static void report_single_touch(struct w8001 *w8001, struct w8001_coord *coord)
w8001             265 drivers/input/touchscreen/wacom_w8001.c 	struct input_dev *dev = w8001->touch_dev;
w8001             270 drivers/input/touchscreen/wacom_w8001.c 	scale_touch_coordinates(w8001, &x, &y);
w8001             278 drivers/input/touchscreen/wacom_w8001.c 	w8001->type = coord->tsw ? BTN_TOOL_FINGER : KEY_RESERVED;
w8001             284 drivers/input/touchscreen/wacom_w8001.c 	struct w8001 *w8001 = serio_get_drvdata(serio);
w8001             288 drivers/input/touchscreen/wacom_w8001.c 	w8001->data[w8001->idx] = data;
w8001             289 drivers/input/touchscreen/wacom_w8001.c 	switch (w8001->idx++) {
w8001             293 drivers/input/touchscreen/wacom_w8001.c 			w8001->idx = 0;
w8001             299 drivers/input/touchscreen/wacom_w8001.c 		tmp = w8001->data[0] & W8001_TOUCH_BYTE;
w8001             303 drivers/input/touchscreen/wacom_w8001.c 		if (w8001->pktlen == w8001->idx) {
w8001             304 drivers/input/touchscreen/wacom_w8001.c 			w8001->idx = 0;
w8001             305 drivers/input/touchscreen/wacom_w8001.c 			if (w8001->type != BTN_TOOL_PEN &&
w8001             306 drivers/input/touchscreen/wacom_w8001.c 			    w8001->type != BTN_TOOL_RUBBER) {
w8001             307 drivers/input/touchscreen/wacom_w8001.c 				parse_single_touch(w8001->data, &coord);
w8001             308 drivers/input/touchscreen/wacom_w8001.c 				report_single_touch(w8001, &coord);
w8001             315 drivers/input/touchscreen/wacom_w8001.c 		tmp = w8001->data[0] & W8001_TAB_MASK;
w8001             319 drivers/input/touchscreen/wacom_w8001.c 		tmp = w8001->data[0] & W8001_TOUCH_BYTE;
w8001             323 drivers/input/touchscreen/wacom_w8001.c 		w8001->idx = 0;
w8001             324 drivers/input/touchscreen/wacom_w8001.c 		parse_pen_data(w8001->data, &coord);
w8001             325 drivers/input/touchscreen/wacom_w8001.c 		report_pen_events(w8001, &coord);
w8001             330 drivers/input/touchscreen/wacom_w8001.c 		tmp = w8001->data[0] & W8001_TOUCH_MASK;
w8001             334 drivers/input/touchscreen/wacom_w8001.c 		w8001->idx = 0;
w8001             335 drivers/input/touchscreen/wacom_w8001.c 		memcpy(w8001->response, w8001->data, W8001_MAX_LENGTH);
w8001             336 drivers/input/touchscreen/wacom_w8001.c 		w8001->response_type = W8001_QUERY_PACKET;
w8001             337 drivers/input/touchscreen/wacom_w8001.c 		complete(&w8001->cmd_done);
w8001             342 drivers/input/touchscreen/wacom_w8001.c 		w8001->idx = 0;
w8001             343 drivers/input/touchscreen/wacom_w8001.c 		parse_multi_touch(w8001);
w8001             352 drivers/input/touchscreen/wacom_w8001.c 		if (!w8001->touch_dev && w8001->idx > W8001_PKTLEN_TPCPEN - 1)
w8001             353 drivers/input/touchscreen/wacom_w8001.c 			w8001->idx = 0;
w8001             359 drivers/input/touchscreen/wacom_w8001.c static int w8001_command(struct w8001 *w8001, unsigned char command,
w8001             364 drivers/input/touchscreen/wacom_w8001.c 	w8001->response_type = 0;
w8001             365 drivers/input/touchscreen/wacom_w8001.c 	init_completion(&w8001->cmd_done);
w8001             367 drivers/input/touchscreen/wacom_w8001.c 	rc = serio_write(w8001->serio, command);
w8001             370 drivers/input/touchscreen/wacom_w8001.c 		wait_for_completion_timeout(&w8001->cmd_done, HZ);
w8001             371 drivers/input/touchscreen/wacom_w8001.c 		if (w8001->response_type != W8001_QUERY_PACKET)
w8001             380 drivers/input/touchscreen/wacom_w8001.c 	struct w8001 *w8001 = input_get_drvdata(dev);
w8001             383 drivers/input/touchscreen/wacom_w8001.c 	err = mutex_lock_interruptible(&w8001->mutex);
w8001             387 drivers/input/touchscreen/wacom_w8001.c 	if (w8001->open_count++ == 0) {
w8001             388 drivers/input/touchscreen/wacom_w8001.c 		err = w8001_command(w8001, W8001_CMD_START, false);
w8001             390 drivers/input/touchscreen/wacom_w8001.c 			w8001->open_count--;
w8001             393 drivers/input/touchscreen/wacom_w8001.c 	mutex_unlock(&w8001->mutex);
w8001             399 drivers/input/touchscreen/wacom_w8001.c 	struct w8001 *w8001 = input_get_drvdata(dev);
w8001             401 drivers/input/touchscreen/wacom_w8001.c 	mutex_lock(&w8001->mutex);
w8001             403 drivers/input/touchscreen/wacom_w8001.c 	if (--w8001->open_count == 0)
w8001             404 drivers/input/touchscreen/wacom_w8001.c 		w8001_command(w8001, W8001_CMD_STOP, false);
w8001             406 drivers/input/touchscreen/wacom_w8001.c 	mutex_unlock(&w8001->mutex);
w8001             409 drivers/input/touchscreen/wacom_w8001.c static int w8001_detect(struct w8001 *w8001)
w8001             413 drivers/input/touchscreen/wacom_w8001.c 	error = w8001_command(w8001, W8001_CMD_STOP, false);
w8001             422 drivers/input/touchscreen/wacom_w8001.c static int w8001_setup_pen(struct w8001 *w8001, char *basename,
w8001             425 drivers/input/touchscreen/wacom_w8001.c 	struct input_dev *dev = w8001->pen_dev;
w8001             430 drivers/input/touchscreen/wacom_w8001.c 	error = w8001_command(w8001, W8001_CMD_QUERY, true);
w8001             443 drivers/input/touchscreen/wacom_w8001.c 	parse_pen_data(w8001->response, &coord);
w8001             444 drivers/input/touchscreen/wacom_w8001.c 	w8001->max_pen_x = coord.x;
w8001             445 drivers/input/touchscreen/wacom_w8001.c 	w8001->max_pen_y = coord.y;
w8001             457 drivers/input/touchscreen/wacom_w8001.c 	w8001->id = 0x90;
w8001             463 drivers/input/touchscreen/wacom_w8001.c static int w8001_setup_touch(struct w8001 *w8001, char *basename,
w8001             466 drivers/input/touchscreen/wacom_w8001.c 	struct input_dev *dev = w8001->touch_dev;
w8001             472 drivers/input/touchscreen/wacom_w8001.c 	error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true);
w8001             479 drivers/input/touchscreen/wacom_w8001.c 	if (!w8001->response[1])
w8001             487 drivers/input/touchscreen/wacom_w8001.c 	parse_touchquery(w8001->response, &touch);
w8001             488 drivers/input/touchscreen/wacom_w8001.c 	w8001->max_touch_x = touch.x;
w8001             489 drivers/input/touchscreen/wacom_w8001.c 	w8001->max_touch_y = touch.y;
w8001             491 drivers/input/touchscreen/wacom_w8001.c 	if (w8001->max_pen_x && w8001->max_pen_y) {
w8001             493 drivers/input/touchscreen/wacom_w8001.c 		touch.x = w8001->max_pen_x;
w8001             494 drivers/input/touchscreen/wacom_w8001.c 		touch.y = w8001->max_pen_y;
w8001             506 drivers/input/touchscreen/wacom_w8001.c 		w8001->pktlen = W8001_PKTLEN_TOUCH93;
w8001             507 drivers/input/touchscreen/wacom_w8001.c 		w8001->id = 0x93;
w8001             514 drivers/input/touchscreen/wacom_w8001.c 		w8001->pktlen = W8001_PKTLEN_TOUCH9A;
w8001             516 drivers/input/touchscreen/wacom_w8001.c 		w8001->id = 0x9a;
w8001             520 drivers/input/touchscreen/wacom_w8001.c 		w8001->pktlen = W8001_PKTLEN_TOUCH2FG;
w8001             525 drivers/input/touchscreen/wacom_w8001.c 			dev_err(&w8001->serio->dev,
w8001             540 drivers/input/touchscreen/wacom_w8001.c 		if (w8001->max_pen_x && w8001->max_pen_y)
w8001             541 drivers/input/touchscreen/wacom_w8001.c 			w8001->id = 0xE3;
w8001             543 drivers/input/touchscreen/wacom_w8001.c 			w8001->id = 0xE2;
w8001             552 drivers/input/touchscreen/wacom_w8001.c static void w8001_set_devdata(struct input_dev *dev, struct w8001 *w8001,
w8001             555 drivers/input/touchscreen/wacom_w8001.c 	dev->phys = w8001->phys;
w8001             557 drivers/input/touchscreen/wacom_w8001.c 	dev->id.product = w8001->id;
w8001             565 drivers/input/touchscreen/wacom_w8001.c 	input_set_drvdata(dev, w8001);
w8001             574 drivers/input/touchscreen/wacom_w8001.c 	struct w8001 *w8001 = serio_get_drvdata(serio);
w8001             578 drivers/input/touchscreen/wacom_w8001.c 	if (w8001->pen_dev)
w8001             579 drivers/input/touchscreen/wacom_w8001.c 		input_unregister_device(w8001->pen_dev);
w8001             580 drivers/input/touchscreen/wacom_w8001.c 	if (w8001->touch_dev)
w8001             581 drivers/input/touchscreen/wacom_w8001.c 		input_unregister_device(w8001->touch_dev);
w8001             582 drivers/input/touchscreen/wacom_w8001.c 	kfree(w8001);
w8001             595 drivers/input/touchscreen/wacom_w8001.c 	struct w8001 *w8001;
w8001             601 drivers/input/touchscreen/wacom_w8001.c 	w8001 = kzalloc(sizeof(struct w8001), GFP_KERNEL);
w8001             604 drivers/input/touchscreen/wacom_w8001.c 	if (!w8001 || !input_dev_pen || !input_dev_touch) {
w8001             609 drivers/input/touchscreen/wacom_w8001.c 	w8001->serio = serio;
w8001             610 drivers/input/touchscreen/wacom_w8001.c 	w8001->pen_dev = input_dev_pen;
w8001             611 drivers/input/touchscreen/wacom_w8001.c 	w8001->touch_dev = input_dev_touch;
w8001             612 drivers/input/touchscreen/wacom_w8001.c 	mutex_init(&w8001->mutex);
w8001             613 drivers/input/touchscreen/wacom_w8001.c 	init_completion(&w8001->cmd_done);
w8001             614 drivers/input/touchscreen/wacom_w8001.c 	snprintf(w8001->phys, sizeof(w8001->phys), "%s/input0", serio->phys);
w8001             616 drivers/input/touchscreen/wacom_w8001.c 	serio_set_drvdata(serio, w8001);
w8001             621 drivers/input/touchscreen/wacom_w8001.c 	err = w8001_detect(w8001);
w8001             630 drivers/input/touchscreen/wacom_w8001.c 	err_pen = w8001_setup_pen(w8001, basename, sizeof(basename));
w8001             631 drivers/input/touchscreen/wacom_w8001.c 	err_touch = w8001_setup_touch(w8001, basename, sizeof(basename));
w8001             638 drivers/input/touchscreen/wacom_w8001.c 		strlcpy(w8001->pen_name, basename, sizeof(w8001->pen_name));
w8001             639 drivers/input/touchscreen/wacom_w8001.c 		strlcat(w8001->pen_name, " Pen", sizeof(w8001->pen_name));
w8001             640 drivers/input/touchscreen/wacom_w8001.c 		input_dev_pen->name = w8001->pen_name;
w8001             642 drivers/input/touchscreen/wacom_w8001.c 		w8001_set_devdata(input_dev_pen, w8001, serio);
w8001             644 drivers/input/touchscreen/wacom_w8001.c 		err = input_register_device(w8001->pen_dev);
w8001             650 drivers/input/touchscreen/wacom_w8001.c 		w8001->pen_dev = NULL;
w8001             654 drivers/input/touchscreen/wacom_w8001.c 		strlcpy(w8001->touch_name, basename, sizeof(w8001->touch_name));
w8001             655 drivers/input/touchscreen/wacom_w8001.c 		strlcat(w8001->touch_name, " Finger",
w8001             656 drivers/input/touchscreen/wacom_w8001.c 			sizeof(w8001->touch_name));
w8001             657 drivers/input/touchscreen/wacom_w8001.c 		input_dev_touch->name = w8001->touch_name;
w8001             659 drivers/input/touchscreen/wacom_w8001.c 		w8001_set_devdata(input_dev_touch, w8001, serio);
w8001             661 drivers/input/touchscreen/wacom_w8001.c 		err = input_register_device(w8001->touch_dev);
w8001             667 drivers/input/touchscreen/wacom_w8001.c 		w8001->touch_dev = NULL;
w8001             673 drivers/input/touchscreen/wacom_w8001.c 	if (w8001->pen_dev)
w8001             674 drivers/input/touchscreen/wacom_w8001.c 		input_unregister_device(w8001->pen_dev);
w8001             682 drivers/input/touchscreen/wacom_w8001.c 	kfree(w8001);