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