Lines Matching refs:mouse
126 static void vsxxxaa_drop_bytes(struct vsxxxaa *mouse, int num) in vsxxxaa_drop_bytes() argument
128 if (num >= mouse->count) { in vsxxxaa_drop_bytes()
129 mouse->count = 0; in vsxxxaa_drop_bytes()
131 memmove(mouse->buf, mouse->buf + num, BUFLEN - num); in vsxxxaa_drop_bytes()
132 mouse->count -= num; in vsxxxaa_drop_bytes()
136 static void vsxxxaa_queue_byte(struct vsxxxaa *mouse, unsigned char byte) in vsxxxaa_queue_byte() argument
138 if (mouse->count == BUFLEN) { in vsxxxaa_queue_byte()
140 mouse->name, mouse->phys); in vsxxxaa_queue_byte()
141 vsxxxaa_drop_bytes(mouse, 1); in vsxxxaa_queue_byte()
146 mouse->buf[mouse->count++] = byte; in vsxxxaa_queue_byte()
149 static void vsxxxaa_detection_done(struct vsxxxaa *mouse) in vsxxxaa_detection_done() argument
151 switch (mouse->type) { in vsxxxaa_detection_done()
153 strlcpy(mouse->name, "DEC VSXXX-AA/-GA mouse", in vsxxxaa_detection_done()
154 sizeof(mouse->name)); in vsxxxaa_detection_done()
158 strlcpy(mouse->name, "DEC VSXXX-AB digitizer", in vsxxxaa_detection_done()
159 sizeof(mouse->name)); in vsxxxaa_detection_done()
163 snprintf(mouse->name, sizeof(mouse->name), in vsxxxaa_detection_done()
165 mouse->type); in vsxxxaa_detection_done()
171 mouse->name, mouse->version, mouse->country, mouse->phys); in vsxxxaa_detection_done()
177 static int vsxxxaa_check_packet(struct vsxxxaa *mouse, int packet_len) in vsxxxaa_check_packet() argument
182 if (!IS_HDR_BYTE(mouse->buf[0])) { in vsxxxaa_check_packet()
183 DBG("vsck: len=%d, 1st=0x%02x\n", packet_len, mouse->buf[0]); in vsxxxaa_check_packet()
189 if (IS_HDR_BYTE(mouse->buf[i])) { in vsxxxaa_check_packet()
194 packet_len, i, mouse->buf[i]); in vsxxxaa_check_packet()
202 static inline int vsxxxaa_smells_like_packet(struct vsxxxaa *mouse, in vsxxxaa_smells_like_packet() argument
205 return mouse->count >= len && MATCH_PACKET_TYPE(mouse->buf[0], type); in vsxxxaa_smells_like_packet()
208 static void vsxxxaa_handle_REL_packet(struct vsxxxaa *mouse) in vsxxxaa_handle_REL_packet() argument
210 struct input_dev *dev = mouse->dev; in vsxxxaa_handle_REL_packet()
211 unsigned char *buf = mouse->buf; in vsxxxaa_handle_REL_packet()
246 vsxxxaa_drop_bytes(mouse, 3); in vsxxxaa_handle_REL_packet()
249 mouse->name, mouse->phys, dx, dy, in vsxxxaa_handle_REL_packet()
264 static void vsxxxaa_handle_ABS_packet(struct vsxxxaa *mouse) in vsxxxaa_handle_ABS_packet() argument
266 struct input_dev *dev = mouse->dev; in vsxxxaa_handle_ABS_packet()
267 unsigned char *buf = mouse->buf; in vsxxxaa_handle_ABS_packet()
297 vsxxxaa_drop_bytes(mouse, 5); in vsxxxaa_handle_ABS_packet()
300 mouse->name, mouse->phys, x, y, in vsxxxaa_handle_ABS_packet()
316 static void vsxxxaa_handle_POR_packet(struct vsxxxaa *mouse) in vsxxxaa_handle_POR_packet() argument
318 struct input_dev *dev = mouse->dev; in vsxxxaa_handle_POR_packet()
319 unsigned char *buf = mouse->buf; in vsxxxaa_handle_POR_packet()
341 mouse->version = buf[0] & 0x0f; in vsxxxaa_handle_POR_packet()
342 mouse->country = (buf[1] >> 4) & 0x07; in vsxxxaa_handle_POR_packet()
343 mouse->type = buf[1] & 0x0f; in vsxxxaa_handle_POR_packet()
355 vsxxxaa_drop_bytes(mouse, 4); in vsxxxaa_handle_POR_packet()
356 vsxxxaa_detection_done(mouse); in vsxxxaa_handle_POR_packet()
368 mouse->name, mouse->phys, error); in vsxxxaa_handle_POR_packet()
379 mouse->name, mouse->phys); in vsxxxaa_handle_POR_packet()
380 serio_write(mouse->serio, 'S'); /* Standard format */ in vsxxxaa_handle_POR_packet()
382 serio_write(mouse->serio, 'R'); /* Incremental */ in vsxxxaa_handle_POR_packet()
384 serio_write(mouse->serio, 'L'); /* 72 samples/sec */ in vsxxxaa_handle_POR_packet()
387 static void vsxxxaa_parse_buffer(struct vsxxxaa *mouse) in vsxxxaa_parse_buffer() argument
389 unsigned char *buf = mouse->buf; in vsxxxaa_parse_buffer()
403 while (mouse->count > 0 && !IS_HDR_BYTE(buf[0])) { in vsxxxaa_parse_buffer()
406 mouse->name, mouse->phys); in vsxxxaa_parse_buffer()
407 vsxxxaa_drop_bytes(mouse, 1); in vsxxxaa_parse_buffer()
414 if (vsxxxaa_smells_like_packet(mouse, VSXXXAA_PACKET_REL, 3)) { in vsxxxaa_parse_buffer()
416 stray_bytes = vsxxxaa_check_packet(mouse, 3); in vsxxxaa_parse_buffer()
418 vsxxxaa_handle_REL_packet(mouse); in vsxxxaa_parse_buffer()
420 } else if (vsxxxaa_smells_like_packet(mouse, in vsxxxaa_parse_buffer()
423 stray_bytes = vsxxxaa_check_packet(mouse, 5); in vsxxxaa_parse_buffer()
425 vsxxxaa_handle_ABS_packet(mouse); in vsxxxaa_parse_buffer()
427 } else if (vsxxxaa_smells_like_packet(mouse, in vsxxxaa_parse_buffer()
430 stray_bytes = vsxxxaa_check_packet(mouse, 4); in vsxxxaa_parse_buffer()
432 vsxxxaa_handle_POR_packet(mouse); in vsxxxaa_parse_buffer()
441 vsxxxaa_drop_bytes(mouse, stray_bytes); in vsxxxaa_parse_buffer()
450 struct vsxxxaa *mouse = serio_get_drvdata(serio); in vsxxxaa_interrupt() local
452 vsxxxaa_queue_byte(mouse, data); in vsxxxaa_interrupt()
453 vsxxxaa_parse_buffer(mouse); in vsxxxaa_interrupt()
460 struct vsxxxaa *mouse = serio_get_drvdata(serio); in vsxxxaa_disconnect() local
464 input_unregister_device(mouse->dev); in vsxxxaa_disconnect()
465 kfree(mouse); in vsxxxaa_disconnect()
470 struct vsxxxaa *mouse; in vsxxxaa_connect() local
474 mouse = kzalloc(sizeof(struct vsxxxaa), GFP_KERNEL); in vsxxxaa_connect()
476 if (!mouse || !input_dev) in vsxxxaa_connect()
479 mouse->dev = input_dev; in vsxxxaa_connect()
480 mouse->serio = serio; in vsxxxaa_connect()
481 strlcat(mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer", in vsxxxaa_connect()
482 sizeof(mouse->name)); in vsxxxaa_connect()
483 snprintf(mouse->phys, sizeof(mouse->phys), "%s/input0", serio->phys); in vsxxxaa_connect()
485 input_dev->name = mouse->name; in vsxxxaa_connect()
486 input_dev->phys = mouse->phys; in vsxxxaa_connect()
502 serio_set_drvdata(serio, mouse); in vsxxxaa_connect()
523 kfree(mouse); in vsxxxaa_connect()