// SPDX-License-Identifier: GPL-2.0-or-later /* * Driver for DEC VSXXX-AA mouse (hockey-puck mouse, ball or two rollers) * DEC VSXXX-GA mouse (rectangular mouse, with ball) * DEC VSXXX-AB tablet (digitizer with hair cross or stylus) * * Copyright (C) 2003-2004 by Jan-Benedict Glaw <[email protected]> * * The packet format was initially taken from a patch to GPM which is (C) 2001 * by Karsten Merker <[email protected]> * and Maciej W. Rozycki <[email protected]> * Later on, I had access to the device's documentation (referenced below). */ /* * Building an adaptor to DE9 / DB25 RS232 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * DISCLAIMER: Use this description AT YOUR OWN RISK! I'll not pay for * anything if you break your mouse, your computer or whatever! * * In theory, this mouse is a simple RS232 device. In practice, it has got * a quite uncommon plug and the requirement to additionally get a power * supply at +5V and -12V. * * If you look at the socket/jack (_not_ at the plug), we use this pin * numbering: * _______ * / 7 6 5 \ * | 4 --- 3 | * \ 2 1 / * ------- * * DEC socket DE9 DB25 Note * 1 (GND) 5 7 - * 2 (RxD) 2 3 - * 3 (TxD) 3 2 - * 4 (-12V) - - Somewhere from the PSU. At ATX, it's * the thin blue wire at pin 12 of the * ATX power connector. Only required for * VSXXX-AA/-GA mice. * 5 (+5V) - - PSU (red wires of ATX power connector * on pin 4, 6, 19 or 20) or HDD power * connector (also red wire). * 6 (+12V) - - HDD power connector, yellow wire. Only * required for VSXXX-AB digitizer. * 7 (dev. avail.) - - The mouse shorts this one to pin 1. * This way, the host computer can detect * the mouse. To use it with the adaptor, * simply don't connect this pin. * * So to get a working adaptor, you need to connect the mouse with three * wires to a RS232 port and two or three additional wires for +5V, +12V and * -12V to the PSU. * * Flow specification for the link is 4800, 8o1. * * The mice and tablet are described in "VCB02 Video Subsystem - Technical * Manual", DEC EK-104AA-TM-001. You'll find it at MANX, a search engine * specific for DEC documentation. Try * http://www.vt100.net/manx/details?pn=EK-104AA-TM-001;id=21;cp=1 */ #include <linux/delay.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/input.h> #include <linux/serio.h> #define DRIVER_DESC … MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…); MODULE_LICENSE(…) …; #undef VSXXXAA_DEBUG #ifdef VSXXXAA_DEBUG #define DBG … #else #define DBG(x...) … #endif #define VSXXXAA_INTRO_MASK … #define VSXXXAA_INTRO_HEAD … #define IS_HDR_BYTE(x) … #define VSXXXAA_PACKET_MASK … #define VSXXXAA_PACKET_REL … #define VSXXXAA_PACKET_ABS … #define VSXXXAA_PACKET_POR … #define MATCH_PACKET_TYPE(data, type) … struct vsxxxaa { … }; static void vsxxxaa_drop_bytes(struct vsxxxaa *mouse, int num) { … } static void vsxxxaa_queue_byte(struct vsxxxaa *mouse, unsigned char byte) { … } static void vsxxxaa_detection_done(struct vsxxxaa *mouse) { … } /* * Returns number of bytes to be dropped, 0 if packet is okay. */ static int vsxxxaa_check_packet(struct vsxxxaa *mouse, int packet_len) { … } static inline int vsxxxaa_smells_like_packet(struct vsxxxaa *mouse, unsigned char type, size_t len) { … } static void vsxxxaa_handle_REL_packet(struct vsxxxaa *mouse) { … } static void vsxxxaa_handle_ABS_packet(struct vsxxxaa *mouse) { … } static void vsxxxaa_handle_POR_packet(struct vsxxxaa *mouse) { … } static void vsxxxaa_parse_buffer(struct vsxxxaa *mouse) { … } static irqreturn_t vsxxxaa_interrupt(struct serio *serio, unsigned char data, unsigned int flags) { … } static void vsxxxaa_disconnect(struct serio *serio) { … } static int vsxxxaa_connect(struct serio *serio, struct serio_driver *drv) { … } static struct serio_device_id vsxxaa_serio_ids[] = …; MODULE_DEVICE_TABLE(serio, vsxxaa_serio_ids); static struct serio_driver vsxxxaa_drv = …; module_serio_driver(…) …;