1139749Simp/*-
2138755Simp * Copyright (c) 2004 M. Warner Losh
3138755Simp * All rights reserved.
4138755Simp *
5138755Simp * Redistribution and use in source and binary forms, with or without
6138755Simp * modification, are permitted provided that the following conditions
7138755Simp * are met:
8138755Simp * 1. Redistributions of source code must retain the above copyright
9140040Simp *    notice, this list of conditions and the following disclaimer.
10138755Simp * 2. Redistributions in binary form must reproduce the above copyright
11140040Simp *    notice, this list of conditions and the following disclaimer in the
12140040Simp *    documentation and/or other materials provided with the distribution.
13138755Simp *
14138755Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15138755Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16138755Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17140040Simp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18140040Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19138755Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20138755Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21138755Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22138755Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23138755Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24138755Simp * SUCH DAMAGE.
25138755Simp *
26138755Simp * $FreeBSD: releng/10.2/sys/dev/mse/msevar.h 144280 2005-03-29 09:22:40Z imp $
27138755Simp */
28138755Simp
29140040Simp/*-
30138755Simp * Copyright 1992 by the University of Guelph
31138755Simp *
32138755Simp * Permission to use, copy and modify this
33138755Simp * software and its documentation for any purpose and without
34138755Simp * fee is hereby granted, provided that the above copyright
35138755Simp * notice appear in all copies and that both that copyright
36138755Simp * notice and this permission notice appear in supporting
37138755Simp * documentation.
38138755Simp * University of Guelph makes no representations about the suitability of
39138755Simp * this software for any purpose.  It is provided "as is"
40138755Simp * without express or implied warranty.
41138755Simp */
42138755Simp
43138755Simp/* driver configuration flags (config) */
44138755Simp#define MSE_CONFIG_ACCEL	0x00f0  /* acceleration factor */
45138755Simp#define MSE_CONFIG_FLAGS	(MSE_CONFIG_ACCEL)
46138755Simp
47138755Simp/*
48138755Simp * Software control structure for mouse. The sc_enablemouse(),
49138755Simp * sc_disablemouse() and sc_getmouse() routines must be called spl'd().
50138755Simp */
51138755Simptypedef struct mse_softc {
52138755Simp	int		sc_flags;
53138755Simp	int		sc_mousetype;
54138755Simp	struct selinfo	sc_selp;
55138755Simp	struct resource	*sc_port;
56138755Simp	struct resource	*sc_intr;
57138755Simp	bus_space_tag_t	sc_iot;
58138755Simp	bus_space_handle_t sc_ioh;
59138755Simp	void		*sc_ih;
60138755Simp	void		(*sc_enablemouse)(bus_space_tag_t t,
61138755Simp			    bus_space_handle_t h);
62138755Simp	void		(*sc_disablemouse)(bus_space_tag_t t,
63138755Simp			    bus_space_handle_t h);
64138755Simp	void		(*sc_getmouse)(bus_space_tag_t t, bus_space_handle_t h,
65138755Simp			    int *dx, int *dy, int *but);
66138755Simp	int		sc_deltax;
67138755Simp	int		sc_deltay;
68138755Simp	int		sc_obuttons;
69138755Simp	int		sc_buttons;
70138755Simp	int		sc_bytesread;
71138755Simp	u_char		sc_bytes[MOUSE_SYS_PACKETSIZE];
72138755Simp	struct		callout_handle sc_callout;
73138755Simp	int		sc_watchdog;
74138755Simp	struct cdev *sc_dev;
75138755Simp	struct cdev *sc_ndev;
76138755Simp	mousehw_t	hw;
77138755Simp	mousemode_t	mode;
78138755Simp	mousestatus_t	status;
79138755Simp} mse_softc_t;
80138755Simp
81138755Simp/* Flags */
82138755Simp#define	MSESC_OPEN	0x1
83138755Simp#define	MSESC_WANT	0x2
84138755Simp
85138755Simp/* and Mouse Types */
86138755Simp#define	MSE_NONE	0	/* don't move this! */
87144280Simp
88144280Simp/* pc98 bus mouse types */
89138755Simp#define	MSE_98BUSMOUSE	0x1
90144280Simp
91144280Simp/* isa bus mouse types */
92138755Simp#define	MSE_LOGITECH	0x1
93138755Simp#define	MSE_ATIINPORT	0x2
94144280Simp
95138755Simp#define	MSE_LOGI_SIG	0xA5
96138755Simp
97138755Simp/* XXX msereg.h? */
98138755Simp#define	MSE_PORTA	0
99138755Simp#define	MSE_PORTB	1
100138755Simp#define	MSE_PORTC	2
101138755Simp#define	MSE_PORTD	3
102138755Simp#define MSE_IOSIZE	4
103138755Simp
104138755Simp/*
105138755Simp * Table of mouse types.
106138755Simp * Keep the Logitech last, since I haven't figured out how to probe it
107138755Simp * properly yet. (Someday I'll have the documentation.)
108138755Simp */
109138755Simpstruct mse_types {
110138755Simp	int	m_type;		/* Type of bus mouse */
111138755Simp	int	(*m_probe)(device_t dev, mse_softc_t *sc);
112138755Simp				/* Probe routine to test for it */
113138755Simp	void	(*m_enable)(bus_space_tag_t t, bus_space_handle_t h);
114138755Simp				/* Start routine */
115138755Simp	void	(*m_disable)(bus_space_tag_t t, bus_space_handle_t h);
116138755Simp				/* Disable interrupts routine */
117138755Simp	void	(*m_get)(bus_space_tag_t t, bus_space_handle_t h, int *dx,
118138755Simp		    int *dy, int *but);
119138755Simp				/* and get mouse status */
120138755Simp	mousehw_t   m_hw;	/* buttons iftype type model hwid */
121138755Simp	mousemode_t m_mode;	/* proto rate res accel level size mask */
122138755Simp};
123138755Simp
124138755Simpextern devclass_t	mse_devclass;
125138755Simpint mse_common_attach(device_t);
126