2005-01-06 01:43:34 +00:00
|
|
|
/*-
|
2017-11-27 14:52:40 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2004-12-12 20:05:50 +00:00
|
|
|
* Copyright (c) 2004 M. Warner Losh
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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
|
2005-01-11 06:24:40 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
2004-12-12 20:05:50 +00:00
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
2005-01-11 06:24:40 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2004-12-12 20:05:50 +00:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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
|
2005-01-11 06:24:40 +00:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
2004-12-12 20:05:50 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
2005-01-11 06:24:40 +00:00
|
|
|
/*-
|
2004-12-12 20:05:50 +00:00
|
|
|
* Copyright 1992 by the University of Guelph
|
|
|
|
*
|
|
|
|
* Permission to use, copy and modify this
|
|
|
|
* software and its documentation for any purpose and without
|
|
|
|
* fee is hereby granted, provided that the above copyright
|
|
|
|
* notice appear in all copies and that both that copyright
|
|
|
|
* notice and this permission notice appear in supporting
|
|
|
|
* documentation.
|
|
|
|
* University of Guelph makes no representations about the suitability of
|
|
|
|
* this software for any purpose. It is provided "as is"
|
|
|
|
* without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* driver configuration flags (config) */
|
|
|
|
#define MSE_CONFIG_ACCEL 0x00f0 /* acceleration factor */
|
|
|
|
#define MSE_CONFIG_FLAGS (MSE_CONFIG_ACCEL)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Software control structure for mouse. The sc_enablemouse(),
|
2014-10-11 19:36:59 +00:00
|
|
|
* sc_disablemouse() and sc_getmouse() routines must be called locked.
|
2004-12-12 20:05:50 +00:00
|
|
|
*/
|
|
|
|
typedef struct mse_softc {
|
|
|
|
int sc_flags;
|
|
|
|
int sc_mousetype;
|
|
|
|
struct selinfo sc_selp;
|
|
|
|
struct resource *sc_port;
|
|
|
|
struct resource *sc_intr;
|
|
|
|
void *sc_ih;
|
2014-10-11 19:36:59 +00:00
|
|
|
void (*sc_enablemouse)(struct resource *port);
|
|
|
|
void (*sc_disablemouse)(struct resource *port);
|
|
|
|
void (*sc_getmouse)(struct resource *port, int *dx, int *dy,
|
|
|
|
int *but);
|
2004-12-12 20:05:50 +00:00
|
|
|
int sc_deltax;
|
|
|
|
int sc_deltay;
|
|
|
|
int sc_obuttons;
|
|
|
|
int sc_buttons;
|
|
|
|
int sc_bytesread;
|
|
|
|
u_char sc_bytes[MOUSE_SYS_PACKETSIZE];
|
2014-10-11 19:36:59 +00:00
|
|
|
struct callout sc_callout;
|
|
|
|
struct mtx sc_lock;
|
2004-12-12 20:05:50 +00:00
|
|
|
int sc_watchdog;
|
|
|
|
struct cdev *sc_dev;
|
|
|
|
struct cdev *sc_ndev;
|
|
|
|
mousehw_t hw;
|
|
|
|
mousemode_t mode;
|
|
|
|
mousestatus_t status;
|
|
|
|
} mse_softc_t;
|
|
|
|
|
2014-10-11 19:36:59 +00:00
|
|
|
#define MSE_LOCK(sc) mtx_lock(&(sc)->sc_lock)
|
|
|
|
#define MSE_UNLOCK(sc) mtx_unlock(&(sc)->sc_lock)
|
|
|
|
#define MSE_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_lock, MA_OWNED)
|
|
|
|
|
2004-12-12 20:05:50 +00:00
|
|
|
/* Flags */
|
|
|
|
#define MSESC_OPEN 0x1
|
|
|
|
#define MSESC_WANT 0x2
|
2014-10-11 19:36:59 +00:00
|
|
|
#define MSESC_READING 0x4
|
2004-12-12 20:05:50 +00:00
|
|
|
|
|
|
|
/* and Mouse Types */
|
|
|
|
#define MSE_NONE 0 /* don't move this! */
|
2005-03-29 09:22:40 +00:00
|
|
|
|
|
|
|
/* isa bus mouse types */
|
2004-12-12 20:05:50 +00:00
|
|
|
#define MSE_LOGITECH 0x1
|
|
|
|
#define MSE_ATIINPORT 0x2
|
2005-03-29 09:22:40 +00:00
|
|
|
|
2004-12-12 20:05:50 +00:00
|
|
|
#define MSE_LOGI_SIG 0xA5
|
|
|
|
|
|
|
|
/* XXX msereg.h? */
|
|
|
|
#define MSE_PORTA 0
|
|
|
|
#define MSE_PORTB 1
|
|
|
|
#define MSE_PORTC 2
|
|
|
|
#define MSE_PORTD 3
|
|
|
|
#define MSE_IOSIZE 4
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Table of mouse types.
|
|
|
|
* Keep the Logitech last, since I haven't figured out how to probe it
|
|
|
|
* properly yet. (Someday I'll have the documentation.)
|
|
|
|
*/
|
|
|
|
struct mse_types {
|
|
|
|
int m_type; /* Type of bus mouse */
|
|
|
|
int (*m_probe)(device_t dev, mse_softc_t *sc);
|
|
|
|
/* Probe routine to test for it */
|
2014-10-11 19:36:59 +00:00
|
|
|
void (*m_enable)(struct resource *port);
|
2004-12-12 20:05:50 +00:00
|
|
|
/* Start routine */
|
2014-10-11 19:36:59 +00:00
|
|
|
void (*m_disable)(struct resource *port);
|
2004-12-12 20:05:50 +00:00
|
|
|
/* Disable interrupts routine */
|
2014-10-11 19:36:59 +00:00
|
|
|
void (*m_get)(struct resource *port, int *dx, int *dy, int *but);
|
2004-12-12 20:05:50 +00:00
|
|
|
/* and get mouse status */
|
|
|
|
mousehw_t m_hw; /* buttons iftype type model hwid */
|
|
|
|
mousemode_t m_mode; /* proto rate res accel level size mask */
|
|
|
|
};
|
|
|
|
|
|
|
|
extern devclass_t mse_devclass;
|
|
|
|
int mse_common_attach(device_t);
|
2014-10-11 19:36:59 +00:00
|
|
|
int mse_detach(device_t);
|