summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/consms.h
blob: 87594aedfbb5f5978565fe666be64c7a48ba8dd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_CONSMS_H
#define	_SYS_CONSMS_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Those default values are taken from lower mice drivers.
 */
#define	CONSMS_SR_DEFAULT_HEIGHT	768
#define	CONSMS_SR_DEFAULT_WIDTH		1024

#define	CONSMS_PARMS_DEFAULT_JITTER	0
#define	CONSMS_PARMS_DEFAULT_SPEED_LAW	0
#define	CONSMS_PARMS_DEFAULT_SPEED_LIMIT	48

#define	CONSMS_MAX(x, y)	((x) > (y) ? (x) : (y))

/*
 * These states are only used when an underlying mouse
 * is being linked under the virtual mouse (/dev/mouse),
 * in order to set some cached state variables. And these
 * states go in a sequential way.
 */
typedef enum {
	LQS_START = 0,				/* begin of initializing */
	LQS_BUTTON_COUNT_PENDING = 1,		/* wait for button count ACK */
	LQS_WHEEL_COUNT_PENDING = 2,		/* wait for wheel count ACK */
	LQS_SET_VUID_FORMAT_PENDING = 3,	/* wait for set format ACK */
	LQS_SET_WHEEL_STATE_PENDING = 4,	/* wait for wheel state ACK */
	LQS_SET_RESOLUTION_PENDING = 5,		/* wait for resolution ACK */
	LQS_SET_PARMS_PENDING = 6,		/* wait for parameters ACK */
	LQS_DONE = 7				/* mark end of initialization */
} consms_lq_state_t;

struct consms_lq;
typedef void (*ioc_reply_func_t)(struct consms_lq *, mblk_t *);

/*
 * This structure contains information
 * for each underlying physical mouse
 * (lower queue).
 */
typedef struct consms_lq {
	struct consms_lq	*lq_next;	/* next lower queue */

	consms_lq_state_t	lq_state;	/* used during initializing */
	queue_t			*lq_queue;	/* lower write q */

	ioc_reply_func_t	lq_ioc_reply_func; /* reply function */
	mblk_t			*lq_pending_plink; /* pending msg */
	queue_t			*lq_pending_queue; /* upper write q */

	int			lq_num_buttons; /* number of buttons */
	int			lq_num_wheels;	/* number of wheels */
	ushort_t		lq_wheel_state_bf; /* enabled/disabled */
} consms_lq_t;

/*
 * This structure is used to remember the
 * COPYIN and COPYOUT request mp from lower
 * queue during transparent ioctl.
 */
typedef struct consms_response {
	struct consms_response	*rsp_next;
	mblk_t  *rsp_mp;	/* response mp (M_COPYIN or M_COPYOUT) */
	queue_t	*rsp_queue;	/* lower read q giving this response */
} consms_response_t;

/*
 * This structure contains information for
 * each ioctl message from upper layer
 * (usually, X server).
 */
typedef struct consms_msg {
	struct consms_msg *msg_next;

	uint_t	msg_id;			/* taken from request message */
	int	msg_num_requests;	/* # of lower queues dispatched */
	int	msg_num_responses;	/* # of responses from lower queues */
	mblk_t	*msg_request;		/* pending request message from upper */
	queue_t *msg_queue;		/* upper write q used for qrely() */

	/*
	 * ack_mp is just used for IOCACK
	 * and rsp_list is only used for COPYIN
	 * or COPYOUT responses from lowers
	 */
	mblk_t			*msg_ack_mp;	/* IOCACK from lower */
	consms_response_t	*msg_rsp_list;	/* responses from lower */
} consms_msg_t;

/*
 * This structure contains information
 * about virtual mouse (lower queue list,
 * and virtual mouse state variables).
 */
typedef struct consms_state {
	consms_lq_t	*consms_lqs;		/* lower queues */
	int		consms_num_lqs;		/* # of lower queues */

	/* virtual mouse state variables */
	int		consms_vuid_format;	/* NATIVE or VUID_FIRM */
	int		consms_num_buttons;	/* max number of buttons */
	int		consms_num_wheels;	/* max number of wheels */
	ushort_t	consms_wheel_state_bf;	/* wheel enabled or disabled */
	Ms_parms	consms_ms_parms;	/* parameters for usb mouse */
	Ms_screen_resolution	consms_ms_sr; 	/* for absolute mouse */
} consms_state_t;

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_CONSMS_H */