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