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