156814Sralph /*- 2*63205Sbostic * Copyright (c) 1992, 1993 3*63205Sbostic * The Regents of the University of California. All rights reserved. 456814Sralph * 556814Sralph * This code is derived from software contributed to Berkeley by 656814Sralph * Ralph Campbell and Rick Macklem. 756814Sralph * 856814Sralph * %sccs.include.redist.c% 956814Sralph * 10*63205Sbostic * @(#)dtopreg.h 8.1 (Berkeley) 06/10/93 1156814Sralph */ 1256814Sralph 1356814Sralph /* 1456814Sralph * Mach Operating System 1556814Sralph * Copyright (c) 1992 Carnegie Mellon University 1656814Sralph * All Rights Reserved. 1756814Sralph * 1856814Sralph * Permission to use, copy, modify and distribute this software and its 1956814Sralph * documentation is hereby granted, provided that both the copyright 2056814Sralph * notice and this permission notice appear in all copies of the 2156814Sralph * software, derivative works or modified versions, and any portions 2256814Sralph * thereof, and that both notices appear in supporting documentation. 2356814Sralph * 2456814Sralph * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 2556814Sralph * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 2656814Sralph * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 2756814Sralph * 2856814Sralph * Carnegie Mellon requests users of this software to return to 2956814Sralph * 3056814Sralph * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 3156814Sralph * School of Computer Science 3256814Sralph * Carnegie Mellon University 3356814Sralph * Pittsburgh PA 15213-3890 3456814Sralph * 3556814Sralph * any improvements or extensions that they make and grant Carnegie Mellon 3656814Sralph * the rights to redistribute these changes. 3756814Sralph */ 3856814Sralph /* 3956814Sralph * HISTORY 4056814Sralph * $Log: dtop.h,v $ 4156814Sralph * Revision 2.3 92/03/05 17:08:17 rpd 4256814Sralph * Define how many buttons and coordinates we can take. 4356814Sralph * [92/03/05 af] 4456814Sralph * 4556814Sralph * Revision 2.2 92/03/02 18:32:17 rpd 4656814Sralph * Created from DEC specs: 4756814Sralph * "DESKTOPinterconnect Description and Protocol Specification" 4856814Sralph * Version 0.9, Jun 17 1991 4956814Sralph * "Open Desktop Bus, Locator Device Protocol Specification" 5056814Sralph * Version 0.4, Dec 13 1990 5156814Sralph * "Open Desktop Bus, Keyboard Device Protocol Specification" 5256814Sralph * Version 0.7, Jan 9 1991 5356814Sralph * [92/01/19 af] 5456814Sralph * 5556814Sralph */ 5656814Sralph /* 5756814Sralph * File: dtop.h 5856814Sralph * Author: Alessandro Forin, Carnegie Mellon University 5956814Sralph * Date: 1/92 6056814Sralph * 6156814Sralph * Definitions for the Desktop serial bus (i2c aka ACCESS). 6256814Sralph */ 6356814Sralph 6456814Sralph #ifndef _DTOP_H_ 6556814Sralph #define _DTOP_H_ 6656814Sralph 6756814Sralph #define DTOP_MAX_DEVICES 14 6856814Sralph #define DTOP_MAX_MSG_SIZE 36 /* 3 hdr + 32 data + 1 checksum */ 6956814Sralph 7056814Sralph typedef struct { 7156814Sralph 7256814Sralph unsigned char dest_address; /* low bit is zero */ 7356814Sralph unsigned char src_address; /* ditto */ 7456814Sralph union { 7556814Sralph struct { 7656814Sralph unsigned char len : 5, /* message byte len */ 7756814Sralph sub : 2, /* sub-address */ 7856814Sralph P : 1; /* Control(1)/Data(0) marker */ 7956814Sralph } val; 8056814Sralph unsigned char bits; /* quick check */ 8156814Sralph } code; 8256814Sralph 8356814Sralph /* varzise, checksum byte at end */ 8456814Sralph unsigned char body[DTOP_MAX_MSG_SIZE-3]; 8556814Sralph 8656814Sralph } dtop_message, *dtop_message_t; 8756814Sralph 8856814Sralph /* 8956814Sralph * Standard addresses 9056814Sralph */ 9156814Sralph 9256814Sralph #define DTOP_ADDR_HOST 0x50 /* address for the (only) host */ 9356814Sralph #define DTOP_ADDR_DEFAULT 0x6e /* power-up default address */ 9456814Sralph #define DTOP_ADDR_FIRST 0x52 /* first assignable address */ 9556814Sralph #define DTOP_ADDR_LAST 0x6c /* last, inclusive */ 9656814Sralph 9756814Sralph /* 9856814Sralph * Standard messages 9956814Sralph */ 10056814Sralph 10156814Sralph /* from host to devices */ 10256814Sralph 10356814Sralph #define DTOP_MSG_RESET 0xf0 /* preceeded by 0x81: P,len 1 */ 10456814Sralph 10556814Sralph #define DTOP_MSG_ID_REQUEST 0xf1 /* preceeded by 0x81: P,len 1 */ 10656814Sralph 10756814Sralph #define DTOP_MSG_ASSIGN_ADDRESS 0xf2 /* preceeded by 0x9e: P,len 30 */ 10856814Sralph /* followed by a dtop_id_reply_t */ 10956814Sralph /* and by the new_IC_address */ 11056814Sralph 11156814Sralph #define DTOP_MSG_CAP_REQUEST 0xf3 /* preceeded by 0x83: P,len 3 */ 11256814Sralph /* followed by a 16 bit u_offset */ 11356814Sralph 11456814Sralph #define DTOP_MSG_APPL_TEST 0xb1 /* preceed by P, sub, len 1 */ 11556814Sralph 11656814Sralph /* from devices to host */ 11756814Sralph 11856814Sralph #define DTOP_MSG_ATTENTION 0xe0 /* preceeded by P, len */ 11956814Sralph # define DTOP_ATN_OK_STATUS 0x00 /* anything else bad */ 12056814Sralph /* followed by 0-30 bytes */ 12156814Sralph 12256814Sralph #define DTOP_MSG_ID_REPLY 0xe1 /* preceeded by P,len (29..32) */ 12356814Sralph 12456814Sralph typedef struct { 12556814Sralph unsigned char module_revision[8]; /* ascii, blank padded */ 12656814Sralph unsigned char vendor_name[8]; 12756814Sralph unsigned char module_name[8]; 12856814Sralph int device_number; /* 32 bits cpl-2 */ 12956814Sralph /* 0-3 optional bytes follow, ignore */ 13056814Sralph } dtop_id_reply_t; 13156814Sralph 13256814Sralph #define DTOP_MSG_CAP_REPLY 0xe3 /* preceeded by P,len (3..32) */ 13356814Sralph /* followed by 16 bit u_offset */ 13456814Sralph /* followed by data */ 13556814Sralph 13656814Sralph #define DTOP_MSG_APPL_SIGNAL 0xa0 /* application level signal */ 13756814Sralph # define DTOP_SIG_ATTENTION 0x00 13856814Sralph # define DTOP_SIG_RESET 0x01 13956814Sralph # define DTOP_SIG_HALT 0x02 14056814Sralph 14156814Sralph #define DTOP_MSG_APPL_TREPLY 0xa1 /* followed by status (0-->ok) */ 14256814Sralph /* and 0..30 bytes of result data */ 14356814Sralph 14456814Sralph /* reserved message codes (testing, manifacturing) */ 14556814Sralph 14656814Sralph #define DTOP_MSG_RES0 0xc0 14756814Sralph #define DTOP_MSG_RES1 0xc1 14856814Sralph #define DTOP_MSG_RES2 0xc2 14956814Sralph #define DTOP_MSG_RES3 0xc3 15056814Sralph 15156814Sralph 15256814Sralph /* 15356814Sralph * Device specific definitions: Keyboard 15456814Sralph */ 15556814Sralph 15656814Sralph /* from host to keyboard */ 15756814Sralph 15856814Sralph #define DTOP_KMSG_CLICK 0x01 /* preceeded by P, sub len 2 */ 15956814Sralph # define DTOP_CLICK_VOLUME_MAX 0x7 /* followed by one byte */ 16056814Sralph 16156814Sralph #define DTOP_KMSG_BELL 0x02 /* preceeded by P, sub len 2 */ 16256814Sralph /* same as above */ 16356814Sralph 16456814Sralph #define DTOP_KMSG_LED 0x03 /* preceeded by P, sub len 2 */ 16556814Sralph /* four lower bits turn leds on */ 16656814Sralph 16756814Sralph #define DTOP_KMSG_POLL 0x04 /* preceeded by P, sub len 1 */ 16856814Sralph 16956814Sralph /* keyboard sends up to 11 codes in a data message, distinguished values: */ 17056814Sralph #define DTOP_KBD_EMPTY 0x00 17156814Sralph #define DTOP_KBD_OUT_ERR 0x01 17256814Sralph #define DTOP_KBD_IN_ERR 0x02 17356814Sralph 17456814Sralph #define DTOP_KBD_KEY_MIN 0x08 17556814Sralph #define DTOP_KBD_KEY_MAX 0xff 17656814Sralph 17756814Sralph /* powerup status values: 0 ok, else.. */ 17856814Sralph #define DTOP_KBD_ROM_FAIL 0x01 17956814Sralph #define DTOP_KBD_RAM_FAIL 0x02 18056814Sralph #define DTOP_KBD_KEY_DOWN 0x03 18156814Sralph 18256814Sralph 18356814Sralph /* 18456814Sralph * Device specific definitions: Locators (mouse) 18556814Sralph */ 18656814Sralph 18756814Sralph /* locator sends this type of report data */ 18856814Sralph 18956814Sralph typedef struct { 19056814Sralph unsigned short buttons; /* 1->pressed */ 19156814Sralph short x; 19256814Sralph short y; 19356814Sralph short z; 19456814Sralph /* possibly 3 more dimensions for gloves */ 19556814Sralph } dtop_locator_msg_t; 19656814Sralph 19756814Sralph #define DTOP_LMSG_SET_RATE 0x01 /* preceeded by P,sub, len 2 */ 19856814Sralph /* followed by sampling interval, 19956814Sralph from 8 to 25 msecs (0->polled */ 20056814Sralph 20156814Sralph #define DTOP_LMSG_POLL 0x02 /* preceeded by P,sub, len 1 */ 20256814Sralph 20356814Sralph /* Powerup codes same as keyboard */ 20456814Sralph 20556814Sralph 20656814Sralph /* 20756814Sralph * Implementation specific definitions 20856814Sralph */ 20956814Sralph 21056814Sralph typedef union { 21156814Sralph 21256814Sralph dtop_message unknown_report; 21356814Sralph 21456814Sralph struct { 21556814Sralph char last_codes_count; 21656814Sralph unsigned char last_codes[11]; /* max as per specs */ 21756814Sralph unsigned int last_msec; /* autorepeat state */ 21856814Sralph unsigned short poll_frequency; 21956814Sralph unsigned char k_ar_state; 22056814Sralph # define K_AR_IDLE 0 /* quiescent, no polling */ 22156814Sralph # define K_AR_OFF 4 /* turn off polling pls */ 22256814Sralph # define K_AR_ACTIVE 2 /* polling, no autos yet */ 22356814Sralph # define K_AR_TRIGGER 1 /* sent one autorepeat */ 22456814Sralph } keyboard; 22556814Sralph 22656814Sralph struct { 22756814Sralph unsigned char type : 7, /* DEV_MOUSE, DEV_TABLET, .. */ 22856814Sralph relative : 1; 22956814Sralph unsigned char n_coords; 23056814Sralph unsigned short prev_buttons; 23156814Sralph # define L_BUTTON_MAX 16 23256814Sralph unsigned char button_code[L_BUTTON_MAX]; 23356814Sralph # define L_COORD_MAX 6 23456814Sralph unsigned int coordinate[L_COORD_MAX]; /* max 6D */ 23556814Sralph } locator; 23656814Sralph 23756814Sralph /* add more as they come along */ 23856814Sralph 23956814Sralph } dtop_device, *dtop_device_t; 24056814Sralph 24156814Sralph 24256814Sralph #define DTOP_EVENT_RECEIVE_PACKET 1 24356814Sralph #define DTOP_EVENT_BAD_PACKET 2 24456814Sralph #define DTOP_EVENT_PUTC 4 24556814Sralph #define DTOP_EVENT_POLL 8 24656814Sralph 24756814Sralph 24856814Sralph /* 24956814Sralph * Device numbers. 25056814Sralph */ 25156814Sralph #define DTOPKBD_PORT 0 25256814Sralph #define DTOPMOUSE_PORT 1 25356814Sralph #endif /* _DTOP_H_ */ 254