1 /* $NetBSD: dtms.c,v 1.8 2007/03/04 06:00:34 christos Exp $ */
4 * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: dtms.c,v 1.8 2007/03/04 06:00:34 christos Exp $");
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/device.h>
40 #include <sys/ioctl.h>
41 #include <sys/syslog.h>
43 #include <machine/bus.h>
45 #include <arch/pmax/tc/dtreg.h>
46 #include <arch/pmax/tc/dtvar.h>
48 #include <dev/wscons/wsconsio.h>
49 #include <dev/wscons/wsmousevar.h>
53 struct device
*sc_wsmousedev
;
57 int dtms_match(struct device
*, struct cfdata
*, void *);
58 void dtms_attach(struct device
*, struct device
*, void *);
59 int dtms_input(void *, int);
60 int dtms_enable(void *);
61 int dtms_ioctl(void *, u_long
, void *, int, struct lwp
*);
62 void dtms_disable(void *);
63 void dtms_handler(void *, struct dt_msg
*);
65 CFATTACH_DECL(dtms
, sizeof(struct dtms_softc
),
66 dtms_match
, dtms_attach
, NULL
, NULL
);
68 const struct wsmouse_accessops dtms_accessops
= {
75 dtms_match(struct device
*parent
, struct cfdata
*cf
, void *aux
)
77 struct dt_attach_args
*dta
;
80 return (dta
->dta_addr
== DT_ADDR_MOUSE
);
84 dtms_attach(struct device
*parent
, struct device
*self
, void *aux
)
86 struct wsmousedev_attach_args a
;
87 struct dtms_softc
*sc
;
90 dt
= (struct dt_softc
*)parent
;
91 sc
= (struct dtms_softc
*)self
;
95 if (dt_establish_handler(dt
, &dt_ms_dv
, self
, dtms_handler
)) {
96 printf("%s: unable to establish handler\n", self
->dv_xname
);
100 a
.accessops
= &dtms_accessops
;
102 sc
->sc_wsmousedev
= config_found(self
, &a
, wsmousedevprint
);
106 dtms_enable(void *cookie
)
108 struct dtms_softc
*sc
;
119 dtms_disable(void *cookie
)
121 struct dtms_softc
*sc
;
128 dtms_ioctl(void *v
, u_long cmd
, void *data
, int flag
, struct lwp
*l
)
131 if (cmd
== WSMOUSEIO_GTYPE
) {
132 *(u_int
*)data
= WSMOUSE_TYPE_VSXXX
;
136 return (EPASSTHROUGH
);
140 dtms_handler(void *cookie
, struct dt_msg
*msg
)
142 struct dtms_softc
*sc
;
151 tmp
= DT_GET_SHORT(msg
->body
[0], msg
->body
[1]);
158 tmp
= DT_GET_SHORT(msg
->body
[2], msg
->body
[3]);
164 tmp
= DT_GET_SHORT(msg
->body
[4], msg
->body
[5]);
170 wsmouse_input(sc
->sc_wsmousedev
,
173 WSMOUSE_INPUT_DELTA
);