logi.c revision 613b28719c10e84c1202c1045df44d77767de21d
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Logitech Mouse Module - Streams
*/
struct mouseconfig mse_config = {
0, 0
};
/*
*
* Local Static Data
*
*/
#define LOGI_MAXUNIT 1
#define M_OPEN 1
static struct driver_minor_data {
char *name;
int minor;
int type;
} logi_minor_data[] = {
{"l", 0, S_IFCHR},
{0}
};
int logidevflag = 1;
/*
* static struct strmseinfo *logiptr = 0;
*/
void **result);
static struct qinit logi_rinit = {
static struct qinit logi_winit = {
static int xmotion, /* current position and .. */
ymotion, /* button status, used .. */
oldbuttons = 1,
status; /* for DOS mode. */
/*
* Local Function Declarations
*/
struct cb_ops logi_cb_ops = {
nodev, /* open */
nodev, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
nodev, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
(&logi_info), /* streamtab */
};
DEVO_REV, /* devo_rev, */
0, /* refcnt */
logiinfo, /* info */
nulldev, /* identify */
logiprobe, /* probe */
logiattach, /* attach */
logidetach, /* detach */
nodev, /* reset */
&logi_cb_ops, /* driver operations */
(struct bus_ops *)0 /* bus operations */
};
#ifndef BUILD_STATIC
/*
* This is the loadable module wrapper.
*/
extern struct mod_ops mod_driverops;
/*
* Module linkage information for the kernel.
*/
&mod_driverops, /* Type of module. This one is a driver */
"Logitech Mouse driver",
&logi_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
&modldrv,
};
/*
* This is the driver initialization routine.
*/
int
_init(void)
{
int rv;
return (rv);
}
#ifdef SUNDEV
int
_fini(void)
{
return (EBUSY);
}
#else
int
_fini(void)
{
return (mod_remove(&modlinkage));
}
#endif
int
{
}
#endif /* !BUILD_STATIC */
static int
{
int unit;
#ifdef LOGI_DEBUG
if (logi_debug) {
PRF("logiprobe: entry\n");
}
#endif
#ifdef LOGI_DEBUG
if (logi_debug)
#endif
return (DDI_PROBE_FAILURE);
}
/*ARGSUSED*/
static int
{
int unit;
struct driver_minor_data *dmdp;
struct strmseinfo *logiptr = 0;
#ifdef LOGI_DEBUG
if (logi_debug) {
PRF("logiattach entry\n");
}
#endif
switch (cmd) {
case DDI_ATTACH:
#ifdef LOGI_DEBUG
if (logi_debug)
PRF("logiattach: "
"ddi_create_minor_node failed\n");
#endif
return (DDI_FAILURE);
}
}
/* allocate and initialize state structure */
(ddi_idevice_cookie_t *)0, logiintr,
#ifdef LOGI_DEBUG
if (logi_debug)
PRF("logiattach: ddi_add_intr failed\n");
#endif
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/*
* logidetach:
*/
/*ARGSUSED*/
static int
{
struct strmseinfo *logiptr;
int instance;
switch (cmd) {
case DDI_DETACH:
/*
* check if every instance can be unloaded before actually
* starting to unload this one; this prevents the needless
*/
continue;
}
/*
* Undo what we did in logiattach & logiprobe, freeing resources
* and removing things we installed. The system
* framework guarantees we are not active with this devinfo
* node in any other entry points at this time.
*/
if ((instance >= LOGI_MAXUNIT) ||
return (DDI_FAILURE);
return (DDI_SUCCESS);
default:
#ifdef LOGI_DEBUG
if (logi_debug) {
}
#endif
return (DDI_FAILURE);
}
}
/* ARGSUSED */
static int
{
int unit;
#ifdef LOGI_DEBUG
if (logi_debug)
PRF("logiinfo: call\n");
#endif
return (DDI_FAILURE);
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
break;
case DDI_INFO_DEVT2INSTANCE:
break;
default:
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static int
{
int i;
int ioaddr;
int len;
int old_probe;
#ifdef LOGI_DEBUG
if (logi_debug)
#endif
"ignore-hardware-nodes", 0);
if (old_probe) {
len = sizeof (int);
/*
* check if ioaddr is set in .conf file, it should be. If it
* isn't then try the default i/o addr
*/
&len) == DDI_PROP_SUCCESS)
} else {
int i;
struct {
int bustype;
int base;
int size;
} *reglist;
/* new probe */
return (DDI_PROBE_FAILURE);
for (i = 0; i < nregs; i++)
break;
}
}
#ifdef LOGI_DEBUG
if (logi_debug)
#endif
mse_config.present = 0;
/* Check if the mouse board exists */
drv_usecwait(10);
drv_usecwait(10);
i = inb(SIGNATURE_PORT);
drv_usecwait(10);
drv_usecwait(10);
#ifdef LOGI_DEBUG
if (logi_debug)
#endif
#ifdef LOGI_DEBUG
if (logi_debug)
PRF("logiinit: succeeded\n");
#endif
return (DDI_SUCCESS);
} else {
#ifdef LOGI_DEBUG
if (logi_debug)
PRF("logiinit: failed\n");
#endif
return (DDI_PROBE_FAILURE);
}
}
/*ARGSUSED2*/
static int
{
struct strmseinfo *logiptr;
int unit;
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logiopen:entered\n");
#endif
return (ENODEV);
if (!mse_config.present)
return (EIO);
return (EIO);
return (EBUSY);
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logiopen:already open\n");
#endif
return (EBUSY); /* already attached */
}
qprocson(q);
#ifdef LOGI_DEBUG
if (logi_debug)
#endif
control_port(0); /* Enable interrupts */
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logiopen:leaving\n");
#endif
oldbuttons = 0;
return (0);
}
/*ARGSUSED1*/
static int
{
struct strmseinfo *logiptr;
qprocsoff(q);
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logiclose:entered\n");
#endif
#ifdef LOGI_DEBUG
if (logi_debug)
#endif
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logiclose:leaving\n");
#endif
return (0);
}
static int
{
struct strmseinfo *logiptr;
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logi_wput:entered\n");
#endif
if (logiptr == 0) {
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logi_wput:logiptr == NULL\n");
#endif
return (0);
}
case M_FLUSH:
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logi_wput:M_FLUSH\n");
#endif
break;
case M_IOCTL:
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logi_wput:M_IOCTL\n");
#endif
break;
case M_IOCDATA:
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logi_wput:M_IOCDATA\n");
#endif
break;
default:
break;
}
#ifdef LOGI_DEBUG
if (logi_debug)
printf("logi_wput:leaving\n");
#endif
return (0);
}
static uint_t
{
int stat = 0;
char x_hi,
x_lo,
y_hi,
y_lo,
x,
y;
#ifdef LOGI_DEBUG
if (logi_debug > 5)
#endif
return (DDI_INTR_UNCLAIMED);
}
/* Get the mouse's status and put it into the appropriate virtual structure */
/*
* Piece the coordinate nibbles together.
*/
/* figure button change values */
/* now convert button status values */
/* Note that the bit is 1 if the button is NOT pressed */
/* did movement occur? */
if (x || y)
/* do we need to deal with PACKETDONE ? */
/* clear old button status, add in new status */
xmotion += x;
ymotion += y;
if (buttons != oldbuttons || x || y) {
char c;
/*
* Emulate a Mouse Systems Corp. mouse.
* push buttons, x, y, x-delta, y-delta onto clist
*/
c = (char)0x80; /* sync byte pattern = 1000 0LMR */
c |= 0x04;
c |= 0x02;
c |= 0x01;
return (DDI_INTR_UNCLAIMED);
}
}
/* Re-enable interrupts on the mouse and return */
#ifdef LOGI_DEBUG
if (logi_debug > 5)
#endif
control_port(0);
return (DDI_INTR_UNCLAIMED);
}