Merge commit 'cb41b9c565d4eec9e1f06e24d429696f59f2f07d'
[unleashed.git] / usr / src / uts / common / io / kbtrans / kbtrans_streams.h
blob36303529d37dd53ac353d6e44a8363e7cc081671
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _KBTRANS_STREAMS_H
28 #define _KBTRANS_STREAMS_H
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 #include <sys/stream.h>
36 #define KBTRANS_POLLED_BUF_SIZE 30
38 /* definitions for various state machines */
39 #define KBTRANS_STREAMS_OPEN 0x00000001 /* keyboard is open for business */
41 #define NO_HARD_RESET 0 /* resets only state struct */
42 #define HARD_RESET 1 /* resets keyboard and state structure */
45 * structure to keep track of currently pressed keys when in
46 * TR_UNTRANS_EVENT mode
48 typedef struct key_event {
49 uchar_t key_station; /* Physical key station associated with event */
50 Firm_event event; /* Event that sent out on down */
51 } Key_event;
54 /* state structure for kbtrans_streams */
55 struct kbtrans {
56 struct kbtrans_lower kbtrans_lower; /* actual translation state */
58 /* Read and write queues */
59 queue_t *kbtrans_streams_readq;
60 queue_t *kbtrans_streams_writeq;
62 /* Pending "ioctl" awaiting buffer */
63 mblk_t *kbtrans_streams_iocpending;
65 /* Number of times the keyboard overflowed input */
66 int kbtrans_overflow_cnt;
68 /* random flags */
69 int kbtrans_streams_flags;
71 /* id from qbufcall on allocb failure */
72 bufcall_id_t kbtrans_streams_bufcallid;
74 timeout_id_t kbtrans_streams_rptid; /* timeout id for repeat */
76 int kbtrans_streams_iocerror; /* error return from "ioctl" */
77 int kbtrans_streams_translate_mode; /* Translate keycodes? */
78 int kbtrans_streams_translatable; /* Keyboard is translatable? */
80 /* Vuid_id_addrs for various events */
81 struct {
82 short ascii;
83 short top;
84 short vkey;
85 } kbtrans_streams_vuid_addr;
88 * Table of key stations currently down that have
89 * have firm events that need to be matched with up transitions
90 * when translation mode is TR_*EVENT
92 struct key_event *kbtrans_streams_downs;
94 /* Number of down entries */
95 int kbtrans_streams_num_downs_entries; /* entries in downs */
97 /* Bytes allocated for downs */
98 uint_t kbtrans_streams_downs_bytes;
100 /* Abort state */
101 enum {
102 ABORT_NORMAL,
103 ABORT_ABORT1_RECEIVED,
104 NEW_ABORT_ABORT1_RECEIVED /* for new abort key */
105 } kbtrans_streams_abort_state;
107 /* Indicated whether or not abort may be honored */
108 boolean_t kbtrans_streams_abortable;
111 * During an abort sequence, says which key started the sequence.
112 * This is used to support both L1+A and F1+A.
114 kbtrans_key_t kbtrans_streams_abort1_key;
116 /* It is used to support new abort sequence Shift+Pause */
117 kbtrans_key_t kbtrans_streams_new_abort1_key;
119 /* Functions to be called based on the translation type */
120 struct keyboard_callback *kbtrans_streams_callback;
122 /* Private structure for the keyboard specific module/driver */
123 struct kbtrans_hardware *kbtrans_streams_hw;
125 /* Callbacks into the keyboard specific module/driver */
126 struct kbtrans_callbacks *kbtrans_streams_hw_callbacks;
128 /* Keyboard type */
129 int kbtrans_streams_id;
131 /* Buffers to hold characters during the polled mode */
132 char *kbtrans_polled_pending_chars;
133 char kbtrans_polled_buf[KBTRANS_POLLED_BUF_SIZE+1];
135 /* vt switch key sequence state */
136 enum {
137 VT_SWITCH_KEY_NONE = 0,
138 VT_SWITCH_KEY_ALT, /* left Alt key is pressed */
139 VT_SWITCH_KEY_ALTGR /* right Alt key is pressed */
140 } vt_switch_keystate;
142 kcondvar_t progressbar_key_abort_cv;
143 kmutex_t progressbar_key_abort_lock;
144 int progressbar_key_abort_flag;
145 kt_did_t progressbar_key_abort_t_did;
148 #ifdef __cplusplus
150 #endif
152 #endif /* _KBTRANS_STREAMS_H */