xref: /illumos-gate/usr/src/uts/common/sys/consms.h (revision 0ccfe5834c3b867c1b6c273cae02ec8922bc0fd2)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_CONSMS_H
27 #define	_SYS_CONSMS_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * Those default values are taken from lower mice drivers.
35  */
36 #define	CONSMS_SR_DEFAULT_HEIGHT	768
37 #define	CONSMS_SR_DEFAULT_WIDTH		1024
38 
39 #define	CONSMS_PARMS_DEFAULT_JITTER	0
40 #define	CONSMS_PARMS_DEFAULT_SPEED_LAW	0
41 #define	CONSMS_PARMS_DEFAULT_SPEED_LIMIT	48
42 
43 #define	CONSMS_MAX(x, y)	((x) > (y) ? (x) : (y))
44 
45 /*
46  * These states are only used when an underlying mouse
47  * is being linked under the virtual mouse (/dev/mouse),
48  * in order to set some cached state variables. And these
49  * states go in a sequential way.
50  */
51 typedef enum {
52 	LQS_START = 0,				/* begin of initializing */
53 	LQS_BUTTON_COUNT_PENDING = 1,		/* wait for button count ACK */
54 	LQS_WHEEL_COUNT_PENDING = 2,		/* wait for wheel count ACK */
55 	LQS_SET_VUID_FORMAT_PENDING = 3,	/* wait for set format ACK */
56 	LQS_SET_WHEEL_STATE_PENDING = 4,	/* wait for wheel state ACK */
57 	LQS_SET_PARMS_PENDING = 5,		/* wait for parameters ACK */
58 	LQS_SET_RESOLUTION_PENDING = 6,		/* wait for resolution ACK */
59 	LQS_DONE = 7				/* mark end of initialization */
60 } consms_lq_state_t;
61 
62 struct consms_lq;
63 typedef void (*ioc_reply_func_t)(struct consms_lq *, mblk_t *);
64 
65 /*
66  * This structure contains information
67  * for each underlying physical mouse
68  * (lower queue).
69  */
70 typedef struct consms_lq {
71 	struct consms_lq	*lq_next;	/* next lower queue */
72 
73 	consms_lq_state_t	lq_state;	/* used during initializing */
74 	queue_t			*lq_queue;	/* lower write q */
75 
76 	ioc_reply_func_t	lq_ioc_reply_func; /* reply function */
77 	mblk_t			*lq_pending_plink; /* pending msg */
78 	queue_t			*lq_pending_queue; /* upper write q */
79 
80 	int			lq_num_buttons; /* number of buttons */
81 	int			lq_num_wheels;	/* number of wheels */
82 	ushort_t		lq_wheel_state_bf; /* enabled/disabled */
83 } consms_lq_t;
84 
85 /*
86  * This structure is used to remember the
87  * COPYIN and COPYOUT request mp from lower
88  * queue during transparent ioctl.
89  */
90 typedef struct consms_response {
91 	struct consms_response	*rsp_next;
92 	mblk_t  *rsp_mp;	/* response mp (M_COPYIN or M_COPYOUT) */
93 	queue_t	*rsp_queue;	/* lower read q giving this response */
94 } consms_response_t;
95 
96 /*
97  * This structure contains information for
98  * each ioctl message from upper layer
99  * (usually, X server).
100  */
101 typedef struct consms_msg {
102 	struct consms_msg *msg_next;
103 
104 	uint_t	msg_id;			/* taken from request message */
105 	int	msg_num_requests;	/* # of lower queues dispatched */
106 	int	msg_num_responses;	/* # of responses from lower queues */
107 	mblk_t	*msg_request;		/* pending request message from upper */
108 	queue_t *msg_queue;		/* upper write q used for qrely() */
109 
110 	/*
111 	 * ack_mp is just used for IOCACK
112 	 * and rsp_list is only used for COPYIN
113 	 * or COPYOUT responses from lowers
114 	 */
115 	mblk_t			*msg_ack_mp;	/* IOCACK from lower */
116 	consms_response_t	*msg_rsp_list;	/* responses from lower */
117 } consms_msg_t;
118 
119 /*
120  * This structure contains information
121  * about virtual mouse (lower queue list,
122  * and virtual mouse state variables).
123  */
124 typedef struct consms_state {
125 	consms_lq_t	*consms_lqs;		/* lower queues */
126 	int		consms_num_lqs;		/* # of lower queues */
127 
128 	/* virtual mouse state variables */
129 	int		consms_vuid_format;	/* NATIVE or VUID_FIRM */
130 	int		consms_num_buttons;	/* max number of buttons */
131 	int		consms_num_wheels;	/* max number of wheels */
132 	ushort_t	consms_wheel_state_bf;	/* wheel enabled or disabled */
133 	Ms_parms	consms_ms_parms;	/* parameters for usb mouse */
134 	Ms_screen_resolution	consms_ms_sr; 	/* for absolute mouse */
135 } consms_state_t;
136 
137 #ifdef	__cplusplus
138 }
139 #endif
140 
141 #endif	/* _SYS_CONSMS_H */
142