2001-12-29 19:15:42 +03:00
|
|
|
/* $NetBSD: ums.c,v 1.54 2001/12/29 16:15:42 augustss Exp $ */
|
1998-07-12 23:51:55 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
1998-11-26 01:32:04 +03:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2000-04-27 19:26:44 +04:00
|
|
|
* by Lennart Augustsson (lennart@augustsson.net) at
|
1998-11-26 01:32:04 +03:00
|
|
|
* Carlstedt Research & Technology.
|
1998-07-12 23:51:55 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1999-01-10 14:13:36 +03:00
|
|
|
/*
|
2000-12-29 04:24:55 +03:00
|
|
|
* HID spec: http://www.usb.org/developers/data/devclass/hid1_1.pdf
|
1999-01-10 14:13:36 +03:00
|
|
|
*/
|
|
|
|
|
2001-11-13 09:24:53 +03:00
|
|
|
#include <sys/cdefs.h>
|
2001-12-29 19:15:42 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.54 2001/12/29 16:15:42 augustss Exp $");
|
2001-11-13 09:24:53 +03:00
|
|
|
|
1998-07-12 23:51:55 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/poll.h>
|
|
|
|
|
|
|
|
#include <dev/usb/usb.h>
|
|
|
|
#include <dev/usb/usbhid.h>
|
|
|
|
|
|
|
|
#include <dev/usb/usbdi.h>
|
|
|
|
#include <dev/usb/usbdi_util.h>
|
|
|
|
#include <dev/usb/usbdevs.h>
|
|
|
|
#include <dev/usb/usb_quirks.h>
|
2001-12-28 20:32:36 +03:00
|
|
|
#include <dev/usb/uhidev.h>
|
1998-07-12 23:51:55 +04:00
|
|
|
#include <dev/usb/hid.h>
|
|
|
|
|
1998-07-25 05:46:38 +04:00
|
|
|
#include <dev/wscons/wsconsio.h>
|
|
|
|
#include <dev/wscons/wsmousevar.h>
|
|
|
|
|
1998-07-12 23:51:55 +04:00
|
|
|
#ifdef USB_DEBUG
|
1999-08-14 18:49:31 +04:00
|
|
|
#define DPRINTF(x) if (umsdebug) logprintf x
|
|
|
|
#define DPRINTFN(n,x) if (umsdebug>(n)) logprintf x
|
1998-07-12 23:51:55 +04:00
|
|
|
int umsdebug = 0;
|
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#define DPRINTFN(n,x)
|
|
|
|
#endif
|
|
|
|
|
1999-08-17 03:36:25 +04:00
|
|
|
#define UMS_BUT(i) ((i) == 1 || (i) == 2 ? 3 - (i) : i)
|
|
|
|
|
|
|
|
#define UMSUNIT(s) (minor(s))
|
1998-12-26 15:53:00 +03:00
|
|
|
|
|
|
|
#define PS2LBUTMASK x01
|
|
|
|
#define PS2RBUTMASK x02
|
|
|
|
#define PS2MBUTMASK x04
|
1998-07-12 23:51:55 +04:00
|
|
|
#define PS2BUTMASK 0x0f
|
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
#define MAX_BUTTONS 7 /* must not exceed size of sc_buttons */
|
|
|
|
|
1998-07-12 23:51:55 +04:00
|
|
|
struct ums_softc {
|
2001-12-28 20:32:36 +03:00
|
|
|
struct uhidev sc_hdev;
|
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
struct hid_location sc_loc_x, sc_loc_y, sc_loc_z;
|
2001-12-28 20:32:36 +03:00
|
|
|
struct hid_location sc_loc_btn[MAX_BUTTONS];
|
1998-07-12 23:51:55 +04:00
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
int sc_enabled;
|
1998-07-25 05:46:38 +04:00
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
int flags; /* device configuration */
|
|
|
|
#define UMS_Z 0x01 /* z direction available */
|
1999-11-16 01:04:14 +03:00
|
|
|
#define UMS_SPUR_BUT_UP 0x02 /* spurious button up events */
|
|
|
|
#define UMS_REVZ 0x04 /* Z-axis is reversed */
|
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
int nbuttons;
|
|
|
|
|
1999-08-17 03:36:25 +04:00
|
|
|
u_int32_t sc_buttons; /* mouse button status */
|
1998-07-25 05:46:38 +04:00
|
|
|
struct device *sc_wsmousedev;
|
1999-08-24 02:55:14 +04:00
|
|
|
|
|
|
|
char sc_dying;
|
1998-07-12 23:51:55 +04:00
|
|
|
};
|
|
|
|
|
1998-07-25 00:59:57 +04:00
|
|
|
#define MOUSE_FLAGS_MASK (HIO_CONST|HIO_RELATIVE)
|
|
|
|
#define MOUSE_FLAGS (HIO_RELATIVE)
|
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
Static void ums_intr(struct uhidev *addr, void *ibuf, u_int len);
|
1998-07-12 23:51:55 +04:00
|
|
|
|
2000-06-01 18:28:57 +04:00
|
|
|
Static int ums_enable(void *);
|
|
|
|
Static void ums_disable(void *);
|
|
|
|
Static int ums_ioctl(void *, u_long, caddr_t, int, struct proc *);
|
1998-07-25 05:46:38 +04:00
|
|
|
|
|
|
|
const struct wsmouse_accessops ums_accessops = {
|
|
|
|
ums_enable,
|
|
|
|
ums_ioctl,
|
|
|
|
ums_disable,
|
|
|
|
};
|
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
USB_DECLARE_DRIVER(ums);
|
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
int
|
|
|
|
ums_match(struct device *parent, struct cfdata *match, void *aux)
|
1998-07-12 23:51:55 +04:00
|
|
|
{
|
2001-12-28 20:32:36 +03:00
|
|
|
struct uhidev_attach_arg *uha = aux;
|
|
|
|
int size;
|
1998-07-12 23:51:55 +04:00
|
|
|
void *desc;
|
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
uhidev_get_report_desc(uha->parent, &desc, &size);
|
|
|
|
if (!hid_is_collection(desc, size, uha->reportid,
|
|
|
|
HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE)))
|
1998-07-12 23:51:55 +04:00
|
|
|
return (UMATCH_NONE);
|
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
return (UMATCH_IFACECLASS);
|
1998-07-12 23:51:55 +04:00
|
|
|
}
|
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
void
|
|
|
|
ums_attach(struct device *parent, struct device *self, void *aux)
|
1998-07-12 23:51:55 +04:00
|
|
|
{
|
2001-12-28 20:32:36 +03:00
|
|
|
struct ums_softc *sc = (struct ums_softc *)self;
|
|
|
|
struct uhidev_attach_arg *uha = aux;
|
1998-07-25 05:46:38 +04:00
|
|
|
struct wsmousedev_attach_args a;
|
1998-07-12 23:51:55 +04:00
|
|
|
int size;
|
|
|
|
void *desc;
|
1999-11-16 01:04:14 +03:00
|
|
|
u_int32_t flags, quirks;
|
1999-12-24 04:14:01 +03:00
|
|
|
int i, wheel;
|
1998-12-26 15:53:00 +03:00
|
|
|
struct hid_location loc_btn;
|
1998-07-12 23:51:55 +04:00
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
sc->sc_hdev.sc_intr = ums_intr;
|
|
|
|
sc->sc_hdev.sc_parent = uha->parent;
|
|
|
|
sc->sc_hdev.sc_report_id = uha->reportid;
|
1998-07-12 23:51:55 +04:00
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
quirks = usbd_get_quirks(uha->parent->sc_udev)->uq_flags;
|
1999-11-16 01:04:14 +03:00
|
|
|
if (quirks & UQ_MS_REVZ)
|
|
|
|
sc->flags |= UMS_REVZ;
|
|
|
|
if (quirks & UQ_SPUR_BUT_UP)
|
|
|
|
sc->flags |= UMS_SPUR_BUT_UP;
|
1999-06-26 04:09:15 +04:00
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
uhidev_get_report_desc(uha->parent, &desc, &size);
|
1998-12-26 15:53:00 +03:00
|
|
|
|
1998-07-25 00:59:57 +04:00
|
|
|
if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
|
2001-12-28 20:32:36 +03:00
|
|
|
uha->reportid, hid_input, &sc->sc_loc_x, &flags)) {
|
|
|
|
printf("\n%s: mouse has no X report\n",
|
|
|
|
USBDEVNAME(sc->sc_hdev.sc_dev));
|
1998-12-26 15:53:00 +03:00
|
|
|
USB_ATTACH_ERROR_RETURN;
|
|
|
|
}
|
|
|
|
if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) {
|
2001-12-28 20:32:36 +03:00
|
|
|
printf("\n%s: X report 0x%04x not supported\n",
|
|
|
|
USBDEVNAME(sc->sc_hdev.sc_dev), flags);
|
1998-12-26 15:53:00 +03:00
|
|
|
USB_ATTACH_ERROR_RETURN;
|
1998-07-12 23:51:55 +04:00
|
|
|
}
|
1998-11-21 21:57:09 +03:00
|
|
|
|
1998-07-25 00:59:57 +04:00
|
|
|
if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y),
|
2001-12-28 20:32:36 +03:00
|
|
|
uha->reportid, hid_input, &sc->sc_loc_y, &flags)) {
|
|
|
|
printf("\n%s: mouse has no Y report\n",
|
|
|
|
USBDEVNAME(sc->sc_hdev.sc_dev));
|
1998-12-26 15:53:00 +03:00
|
|
|
USB_ATTACH_ERROR_RETURN;
|
|
|
|
}
|
|
|
|
if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) {
|
2001-12-28 20:32:36 +03:00
|
|
|
printf("\n%s: Y report 0x%04x not supported\n",
|
|
|
|
USBDEVNAME(sc->sc_hdev.sc_dev), flags);
|
1998-12-26 15:53:00 +03:00
|
|
|
USB_ATTACH_ERROR_RETURN;
|
1998-07-12 23:51:55 +04:00
|
|
|
}
|
1998-11-21 21:57:09 +03:00
|
|
|
|
1999-01-13 01:06:48 +03:00
|
|
|
/* Try to guess the Z activator: first check Z, then WHEEL. */
|
1999-12-24 04:14:01 +03:00
|
|
|
wheel = 0;
|
1998-07-29 01:21:47 +04:00
|
|
|
if (hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Z),
|
2001-12-28 20:32:36 +03:00
|
|
|
uha->reportid, hid_input, &sc->sc_loc_z, &flags) ||
|
1999-12-24 04:14:01 +03:00
|
|
|
(wheel = hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP,
|
|
|
|
HUG_WHEEL),
|
2001-12-28 20:32:36 +03:00
|
|
|
uha->reportid, hid_input, &sc->sc_loc_z, &flags))) {
|
1998-12-26 15:53:00 +03:00
|
|
|
if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) {
|
|
|
|
sc->sc_loc_z.size = 0; /* Bad Z coord, ignore it */
|
|
|
|
} else {
|
|
|
|
sc->flags |= UMS_Z;
|
1999-12-24 04:14:01 +03:00
|
|
|
/* Wheels need the Z axis reversed. */
|
|
|
|
if (wheel)
|
|
|
|
sc->flags ^= UMS_REVZ;
|
1998-12-26 15:53:00 +03:00
|
|
|
}
|
1998-07-29 01:21:47 +04:00
|
|
|
}
|
|
|
|
|
1999-01-10 22:13:15 +03:00
|
|
|
/* figure out the number of buttons */
|
|
|
|
for (i = 1; i <= MAX_BUTTONS; i++)
|
1998-12-26 15:53:00 +03:00
|
|
|
if (!hid_locate(desc, size, HID_USAGE2(HUP_BUTTON, i),
|
2001-12-28 20:32:36 +03:00
|
|
|
uha->reportid, hid_input, &loc_btn, 0))
|
1998-12-26 15:53:00 +03:00
|
|
|
break;
|
|
|
|
sc->nbuttons = i - 1;
|
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
printf(": %d button%s%s\n",
|
2000-10-09 00:52:18 +04:00
|
|
|
sc->nbuttons, sc->nbuttons == 1 ? "" : "s",
|
|
|
|
sc->flags & UMS_Z ? " and Z dir." : "");
|
1998-12-26 15:53:00 +03:00
|
|
|
|
|
|
|
for (i = 1; i <= sc->nbuttons; i++)
|
|
|
|
hid_locate(desc, size, HID_USAGE2(HUP_BUTTON, i),
|
2001-12-28 20:32:36 +03:00
|
|
|
uha->reportid, hid_input,
|
|
|
|
&sc->sc_loc_btn[i-1], 0);
|
1998-07-25 05:46:38 +04:00
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
#ifdef USB_DEBUG
|
|
|
|
DPRINTF(("ums_attach: sc=%p\n", sc));
|
|
|
|
DPRINTF(("ums_attach: X\t%d/%d\n",
|
|
|
|
sc->sc_loc_x.pos, sc->sc_loc_x.size));
|
|
|
|
DPRINTF(("ums_attach: Y\t%d/%d\n",
|
2001-10-25 17:45:16 +04:00
|
|
|
sc->sc_loc_y.pos, sc->sc_loc_y.size));
|
1998-12-26 15:53:00 +03:00
|
|
|
if (sc->flags & UMS_Z)
|
|
|
|
DPRINTF(("ums_attach: Z\t%d/%d\n",
|
|
|
|
sc->sc_loc_z.pos, sc->sc_loc_z.size));
|
|
|
|
for (i = 1; i <= sc->nbuttons; i++) {
|
|
|
|
DPRINTF(("ums_attach: B%d\t%d/%d\n",
|
|
|
|
i, sc->sc_loc_btn[i-1].pos,sc->sc_loc_btn[i-1].size));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-07-25 05:46:38 +04:00
|
|
|
a.accessops = &ums_accessops;
|
|
|
|
a.accesscookie = sc;
|
|
|
|
|
2001-01-23 17:04:13 +03:00
|
|
|
sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
|
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
USB_ATTACH_SUCCESS_RETURN;
|
1998-07-12 23:51:55 +04:00
|
|
|
}
|
|
|
|
|
1999-06-30 10:44:22 +04:00
|
|
|
int
|
2000-06-01 18:28:57 +04:00
|
|
|
ums_activate(device_ptr_t self, enum devact act)
|
1998-12-26 15:53:00 +03:00
|
|
|
{
|
1999-08-24 02:55:14 +04:00
|
|
|
struct ums_softc *sc = (struct ums_softc *)self;
|
1999-09-12 12:21:49 +04:00
|
|
|
int rv = 0;
|
1999-08-24 02:55:14 +04:00
|
|
|
|
|
|
|
switch (act) {
|
|
|
|
case DVACT_ACTIVATE:
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DVACT_DEACTIVATE:
|
1999-11-12 03:34:57 +03:00
|
|
|
if (sc->sc_wsmousedev != NULL)
|
1999-09-12 12:21:49 +04:00
|
|
|
rv = config_deactivate(sc->sc_wsmousedev);
|
1999-08-24 02:55:14 +04:00
|
|
|
sc->sc_dying = 1;
|
|
|
|
break;
|
|
|
|
}
|
1999-09-12 12:21:49 +04:00
|
|
|
return (rv);
|
1998-12-26 15:53:00 +03:00
|
|
|
}
|
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
int
|
|
|
|
ums_detach(struct device *self, int flags)
|
1998-07-12 23:51:55 +04:00
|
|
|
{
|
2001-12-28 20:32:36 +03:00
|
|
|
struct ums_softc *sc = (struct ums_softc *)self;
|
1999-06-30 10:44:22 +04:00
|
|
|
int rv = 0;
|
|
|
|
|
|
|
|
DPRINTF(("ums_detach: sc=%p flags=%d\n", sc, flags));
|
1999-10-13 12:10:55 +04:00
|
|
|
|
2001-11-07 17:13:35 +03:00
|
|
|
/* No need to do reference counting of ums, wsmouse has all the goo. */
|
|
|
|
if (sc->sc_wsmousedev != NULL)
|
|
|
|
rv = config_detach(sc->sc_wsmousedev, flags);
|
2000-02-02 16:18:45 +03:00
|
|
|
|
1999-06-30 10:44:22 +04:00
|
|
|
return (rv);
|
1998-07-12 23:51:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-12-28 20:32:36 +03:00
|
|
|
ums_intr(struct uhidev *addr, void *ibuf, u_int len)
|
1998-07-12 23:51:55 +04:00
|
|
|
{
|
2001-12-28 20:32:36 +03:00
|
|
|
struct ums_softc *sc = (struct ums_softc *)addr;
|
1998-07-29 01:21:47 +04:00
|
|
|
int dx, dy, dz;
|
1999-08-17 03:36:25 +04:00
|
|
|
u_int32_t buttons = 0;
|
1998-12-26 15:53:00 +03:00
|
|
|
int i;
|
1999-05-09 19:10:30 +04:00
|
|
|
int s;
|
1999-01-10 22:13:15 +03:00
|
|
|
|
2001-12-29 19:15:42 +03:00
|
|
|
DPRINTFN(5,("ums_intr: len=%d\n", len));
|
|
|
|
|
1998-07-12 23:51:55 +04:00
|
|
|
dx = hid_get_data(ibuf, &sc->sc_loc_x);
|
|
|
|
dy = -hid_get_data(ibuf, &sc->sc_loc_y);
|
1998-07-29 01:21:47 +04:00
|
|
|
dz = hid_get_data(ibuf, &sc->sc_loc_z);
|
1999-11-16 01:04:14 +03:00
|
|
|
if (sc->flags & UMS_REVZ)
|
1999-06-26 04:09:15 +04:00
|
|
|
dz = -dz;
|
1998-12-26 15:53:00 +03:00
|
|
|
for (i = 0; i < sc->nbuttons; i++)
|
|
|
|
if (hid_get_data(ibuf, &sc->sc_loc_btn[i]))
|
|
|
|
buttons |= (1 << UMS_BUT(i));
|
|
|
|
|
1999-11-16 01:04:14 +03:00
|
|
|
if (dx != 0 || dy != 0 || dz != 0 || buttons != sc->sc_buttons) {
|
1998-12-26 15:53:00 +03:00
|
|
|
DPRINTFN(10, ("ums_intr: x:%d y:%d z:%d buttons:0x%x\n",
|
|
|
|
dx, dy, dz, buttons));
|
1998-07-27 22:51:32 +04:00
|
|
|
sc->sc_buttons = buttons;
|
1999-11-16 01:04:14 +03:00
|
|
|
if (sc->sc_wsmousedev != NULL) {
|
1999-05-09 19:10:30 +04:00
|
|
|
s = spltty();
|
2000-01-08 05:57:22 +03:00
|
|
|
wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, dz,
|
|
|
|
WSMOUSE_INPUT_DELTA);
|
1999-05-09 19:10:30 +04:00
|
|
|
splx(s);
|
|
|
|
}
|
1998-07-12 23:51:55 +04:00
|
|
|
}
|
|
|
|
}
|
1998-07-25 05:46:38 +04:00
|
|
|
|
2000-03-27 16:33:53 +04:00
|
|
|
Static int
|
2000-06-01 18:28:57 +04:00
|
|
|
ums_enable(void *v)
|
1998-07-25 05:46:38 +04:00
|
|
|
{
|
|
|
|
struct ums_softc *sc = v;
|
1998-12-26 15:53:00 +03:00
|
|
|
|
1999-06-30 10:44:22 +04:00
|
|
|
DPRINTFN(1,("ums_enable: sc=%p\n", sc));
|
1999-08-24 02:55:14 +04:00
|
|
|
|
|
|
|
if (sc->sc_dying)
|
|
|
|
return (EIO);
|
|
|
|
|
1998-07-25 05:46:38 +04:00
|
|
|
if (sc->sc_enabled)
|
1999-08-24 02:55:14 +04:00
|
|
|
return (EBUSY);
|
1998-07-25 05:46:38 +04:00
|
|
|
|
|
|
|
sc->sc_enabled = 1;
|
1998-07-27 22:51:32 +04:00
|
|
|
sc->sc_buttons = 0;
|
1998-07-25 05:46:38 +04:00
|
|
|
|
2001-12-28 20:32:36 +03:00
|
|
|
return (uhidev_open(&sc->sc_hdev));
|
1998-07-25 05:46:38 +04:00
|
|
|
}
|
|
|
|
|
2000-03-27 16:33:53 +04:00
|
|
|
Static void
|
2000-06-01 18:28:57 +04:00
|
|
|
ums_disable(void *v)
|
1998-07-25 05:46:38 +04:00
|
|
|
{
|
|
|
|
struct ums_softc *sc = v;
|
|
|
|
|
1999-06-30 10:44:22 +04:00
|
|
|
DPRINTFN(1,("ums_disable: sc=%p\n", sc));
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (!sc->sc_enabled) {
|
|
|
|
printf("ums_disable: not enabled\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-07-25 05:46:38 +04:00
|
|
|
sc->sc_enabled = 0;
|
2001-12-28 20:32:36 +03:00
|
|
|
return (uhidev_close(&sc->sc_hdev));
|
1998-07-25 05:46:38 +04:00
|
|
|
}
|
|
|
|
|
2000-03-27 16:33:53 +04:00
|
|
|
Static int
|
2000-06-01 18:28:57 +04:00
|
|
|
ums_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
|
1998-07-25 05:46:38 +04:00
|
|
|
|
1998-12-26 15:53:00 +03:00
|
|
|
{
|
1998-07-25 05:46:38 +04:00
|
|
|
switch (cmd) {
|
|
|
|
case WSMOUSEIO_GTYPE:
|
1998-12-30 16:14:21 +03:00
|
|
|
*(u_int *)data = WSMOUSE_TYPE_USB;
|
1998-07-25 05:46:38 +04:00
|
|
|
return (0);
|
|
|
|
}
|
1998-12-26 15:53:00 +03:00
|
|
|
|
1998-07-25 05:46:38 +04:00
|
|
|
return (-1);
|
|
|
|
}
|