]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/mse/msevar.h
MFV r322227: 8377 Panic in bookmark deletion
[FreeBSD/FreeBSD.git] / sys / dev / mse / msevar.h
1 /*-
2  * Copyright (c) 2004 M. Warner Losh
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 /*-
30  * Copyright 1992 by the University of Guelph
31  *
32  * Permission to use, copy and modify this
33  * software and its documentation for any purpose and without
34  * fee is hereby granted, provided that the above copyright
35  * notice appear in all copies and that both that copyright
36  * notice and this permission notice appear in supporting
37  * documentation.
38  * University of Guelph makes no representations about the suitability of
39  * this software for any purpose.  It is provided "as is"
40  * without express or implied warranty.
41  */
42
43 /* driver configuration flags (config) */
44 #define MSE_CONFIG_ACCEL        0x00f0  /* acceleration factor */
45 #define MSE_CONFIG_FLAGS        (MSE_CONFIG_ACCEL)
46
47 /*
48  * Software control structure for mouse. The sc_enablemouse(),
49  * sc_disablemouse() and sc_getmouse() routines must be called locked.
50  */
51 typedef struct mse_softc {
52         int             sc_flags;
53         int             sc_mousetype;
54         struct selinfo  sc_selp;
55         struct resource *sc_port;
56         struct resource *sc_intr;
57         void            *sc_ih;
58         void            (*sc_enablemouse)(struct resource *port);
59         void            (*sc_disablemouse)(struct resource *port);
60         void            (*sc_getmouse)(struct resource *port, int *dx, int *dy,
61                             int *but);
62         int             sc_deltax;
63         int             sc_deltay;
64         int             sc_obuttons;
65         int             sc_buttons;
66         int             sc_bytesread;
67         u_char          sc_bytes[MOUSE_SYS_PACKETSIZE];
68         struct callout  sc_callout;
69         struct mtx      sc_lock;
70         int             sc_watchdog;
71         struct cdev *sc_dev;
72         struct cdev *sc_ndev;
73         mousehw_t       hw;
74         mousemode_t     mode;
75         mousestatus_t   status;
76 } mse_softc_t;
77
78 #define MSE_LOCK(sc)            mtx_lock(&(sc)->sc_lock)
79 #define MSE_UNLOCK(sc)          mtx_unlock(&(sc)->sc_lock)
80 #define MSE_ASSERT_LOCKED(sc)   mtx_assert(&(sc)->sc_lock, MA_OWNED)
81
82 /* Flags */
83 #define MSESC_OPEN      0x1
84 #define MSESC_WANT      0x2
85 #define MSESC_READING   0x4
86
87 /* and Mouse Types */
88 #define MSE_NONE        0       /* don't move this! */
89
90 /* isa bus mouse types */
91 #define MSE_LOGITECH    0x1
92 #define MSE_ATIINPORT   0x2
93
94 #define MSE_LOGI_SIG    0xA5
95
96 /* XXX msereg.h? */
97 #define MSE_PORTA       0
98 #define MSE_PORTB       1
99 #define MSE_PORTC       2
100 #define MSE_PORTD       3
101 #define MSE_IOSIZE      4
102
103 /*
104  * Table of mouse types.
105  * Keep the Logitech last, since I haven't figured out how to probe it
106  * properly yet. (Someday I'll have the documentation.)
107  */
108 struct mse_types {
109         int     m_type;         /* Type of bus mouse */
110         int     (*m_probe)(device_t dev, mse_softc_t *sc);
111                                 /* Probe routine to test for it */
112         void    (*m_enable)(struct resource *port);
113                                 /* Start routine */
114         void    (*m_disable)(struct resource *port);
115                                 /* Disable interrupts routine */
116         void    (*m_get)(struct resource *port, int *dx, int *dy, int *but);
117                                 /* and get mouse status */
118         mousehw_t   m_hw;       /* buttons iftype type model hwid */
119         mousemode_t m_mode;     /* proto rate res accel level size mask */
120 };
121
122 extern devclass_t       mse_devclass;
123 int mse_common_attach(device_t);
124 int mse_detach(device_t);