1*c1cc27a7Sgkoehler /* $OpenBSD: adb.h,v 1.6 2022/10/21 22:42:36 gkoehler Exp $ */ 2305d9e87Smiod /* $NetBSD: adbsys.h,v 1.4 2000/12/19 02:59:24 tsubai Exp $ */ 3305d9e87Smiod 4305d9e87Smiod /*- 5305d9e87Smiod * Copyright (C) 1993, 1994 Allen K. Briggs, Chris P. Caputo, 6305d9e87Smiod * Michael L. Finch, Bradley A. Grantham, and 7305d9e87Smiod * Lawrence A. Kesteloot 8305d9e87Smiod * All rights reserved. 9305d9e87Smiod * 10305d9e87Smiod * Redistribution and use in source and binary forms, with or without 11305d9e87Smiod * modification, are permitted provided that the following conditions 12305d9e87Smiod * are met: 13305d9e87Smiod * 1. Redistributions of source code must retain the above copyright 14305d9e87Smiod * notice, this list of conditions and the following disclaimer. 15305d9e87Smiod * 2. Redistributions in binary form must reproduce the above copyright 16305d9e87Smiod * notice, this list of conditions and the following disclaimer in the 17305d9e87Smiod * documentation and/or other materials provided with the distribution. 18305d9e87Smiod * 3. All advertising materials mentioning features or use of this software 19305d9e87Smiod * must display the following acknowledgement: 20305d9e87Smiod * This product includes software developed by the Alice Group. 21305d9e87Smiod * 4. The names of the Alice Group or any of its members may not be used 22305d9e87Smiod * to endorse or promote products derived from this software without 23305d9e87Smiod * specific prior written permission. 24305d9e87Smiod * 25305d9e87Smiod * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR 26305d9e87Smiod * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27305d9e87Smiod * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28305d9e87Smiod * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, 29305d9e87Smiod * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 30305d9e87Smiod * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31305d9e87Smiod * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32305d9e87Smiod * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33305d9e87Smiod * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34305d9e87Smiod * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35305d9e87Smiod */ 36305d9e87Smiod 37305d9e87Smiod #ifndef _ADB_H_ 38305d9e87Smiod #define _ADB_H_ 39305d9e87Smiod 40305d9e87Smiod #ifdef _KERNEL 41305d9e87Smiod 42305d9e87Smiod /* 43305d9e87Smiod * Arguments used to attach a device to the Apple Desktop Bus 44305d9e87Smiod */ 45305d9e87Smiod struct adb_attach_args { 464425d974Smiod const char *name; /* adb_device_name if real adb device */ 47305d9e87Smiod int origaddr; 48305d9e87Smiod int adbaddr; 49305d9e87Smiod int handler_id; 50305d9e87Smiod }; 51305d9e87Smiod 524425d974Smiod extern const char adb_device_name[]; 534425d974Smiod 54305d9e87Smiod #define ADB_CMDADDR(cmd) ((u_int8_t)(cmd & 0xf0) >> 4) 55305d9e87Smiod #define ADBFLUSH(dev) ((((u_int8_t)dev & 0x0f) << 4) | 0x01) 56305d9e87Smiod #define ADBLISTEN(dev, reg) ((((u_int8_t)dev & 0x0f) << 4) | 0x08 | reg) 57305d9e87Smiod #define ADBTALK(dev, reg) ((((u_int8_t)dev & 0x0f) << 4) | 0x0c | reg) 58305d9e87Smiod 59305d9e87Smiod /* an ADB event */ 60305d9e87Smiod typedef struct adb_event_s { 61305d9e87Smiod int byte_count; /* number of bytes */ 62305d9e87Smiod unsigned char bytes[8]; /* bytes from register 0 */ 63305d9e87Smiod } adb_event_t; 64305d9e87Smiod 65305d9e87Smiod /* Interesting default addresses */ 66305d9e87Smiod #define ADBADDR_SECURE 1 /* Security dongles */ 67305d9e87Smiod #define ADBADDR_MAP 2 /* Mapped devices (keyboards/pads) */ 68305d9e87Smiod #define ADBADDR_REL 3 /* Relative positioning devices 69305d9e87Smiod (mice, trackballs/pads) */ 70305d9e87Smiod #define ADBADDR_ABS 4 /* Absolute positioning devices 71305d9e87Smiod (graphics tablets) */ 72305d9e87Smiod #define ADBADDR_DATATX 5 73305d9e87Smiod #define ADBADDR_RSRVD 6 /* Reserved by Apple */ 74305d9e87Smiod #define ADBADDR_MISC 7 /* Miscellaneous appliances */ 75305d9e87Smiod #define ADBADDR_DONGLE ADBADDR_SECURE 76305d9e87Smiod #define ADBADDR_KBD ADBADDR_MAP 77305d9e87Smiod #define ADBADDR_MS ADBADDR_REL 78305d9e87Smiod #define ADBADDR_TABLET ADBADDR_ABS 79305d9e87Smiod #define ADBADDR_MODEM ADBADDR_DATATX 80305d9e87Smiod 81305d9e87Smiod /* Interesting keyboard handler IDs */ 82305d9e87Smiod #define ADB_STDKBD 1 83305d9e87Smiod #define ADB_EXTKBD 2 84305d9e87Smiod #define ADB_ISOKBD 4 85305d9e87Smiod #define ADB_EXTISOKBD 5 86305d9e87Smiod #define ADB_KBDII 8 87305d9e87Smiod #define ADB_ISOKBDII 9 88305d9e87Smiod #define ADB_PBKBD 12 89305d9e87Smiod #define ADB_PBISOKBD 13 90305d9e87Smiod #define ADB_ADJKPD 14 91305d9e87Smiod #define ADB_ADJKBD 16 92305d9e87Smiod #define ADB_ADJISOKBD 17 93305d9e87Smiod #define ADB_ADJJAPKBD 18 94305d9e87Smiod #define ADB_PBEXTISOKBD 20 95305d9e87Smiod #define ADB_PBEXTJAPKBD 21 96305d9e87Smiod #define ADB_JPKBDII 22 97305d9e87Smiod #define ADB_PBEXTKBD 24 98305d9e87Smiod #define ADB_DESIGNKBD 27 /* XXX Needs to be verified XXX */ 99305d9e87Smiod #define ADB_PBJPKBD 30 100305d9e87Smiod #define ADB_PBG4KBD 195 101305d9e87Smiod #define ADB_IBITISOKBD 196 102305d9e87Smiod #define ADB_PBG3JPKBD 201 103305d9e87Smiod 104305d9e87Smiod /* Interesting mouse handler IDs */ 105305d9e87Smiod #define ADBMS_100DPI 1 106305d9e87Smiod #define ADBMS_200DPI 2 107305d9e87Smiod #define ADBMS_MSA3 3 /* Mouse Systems A3 Mouse */ 108305d9e87Smiod #define ADBMS_EXTENDED 4 /* Extended mouse protocol */ 109305d9e87Smiod #define ADBMS_USPEED 0x2f /* MicroSpeed mouse */ 110305d9e87Smiod #define ADBMS_UCONTOUR 0x66 /* Contour mouse */ 111305d9e87Smiod #define ADBMS_TURBO 50 /* Kensington Turbo Mouse */ 112305d9e87Smiod 113305d9e87Smiod /* Interesting tablet handler ID */ 114305d9e87Smiod #define ADB_ARTPAD 58 /* WACOM ArtPad II tablet */ 115305d9e87Smiod 116305d9e87Smiod /* Interesting miscellaneous handler ID */ 117305d9e87Smiod #define ADB_POWERKEY 34 /* Sophisticated Circuits PowerKey */ 118305d9e87Smiod /* (intelligent power tap) */ 119305d9e87Smiod 120305d9e87Smiod extern int adb_polling; 121305d9e87Smiod #ifdef ADB_DEBUG 122305d9e87Smiod extern int adb_debug; 123305d9e87Smiod #endif 124305d9e87Smiod 125305d9e87Smiod /* ADB Manager */ 126305d9e87Smiod 127305d9e87Smiod typedef caddr_t Ptr; 128305d9e87Smiod 129305d9e87Smiod typedef struct { 130305d9e87Smiod Ptr siServiceRtPtr; 131305d9e87Smiod Ptr siDataAreaAddr; 132305d9e87Smiod } ADBSetInfoBlock; 133305d9e87Smiod 134305d9e87Smiod typedef struct { 135305d9e87Smiod unsigned char devType; 136305d9e87Smiod unsigned char origADBAddr; 137305d9e87Smiod Ptr dbServiceRtPtr; 138305d9e87Smiod Ptr dbDataAreaAddr; 139305d9e87Smiod } ADBDataBlock; 140305d9e87Smiod 141305d9e87Smiod int adbprint(void *, const char *); 142*c1cc27a7Sgkoehler void adb_lid_closed_intr(void); 143*c1cc27a7Sgkoehler void adb_power_button_intr(void); 14474a0040aSmiod int adb_op_sync(Ptr, short); 145305d9e87Smiod int set_adb_info(ADBSetInfoBlock *, int); 146305d9e87Smiod 147305d9e87Smiod #endif /* _KERNEL */ 148305d9e87Smiod 149305d9e87Smiod #endif /* _ADB_H_ */ 150