Home | History | Annotate | Line # | Download | only in hpc
hpctpanel.c revision 1.3.2.1
      1  1.3.2.1    yamt /*	$NetBSD: hpctpanel.c,v 1.3.2.1 2006/06/21 15:02:46 yamt Exp $	*/
      2      1.1  tsarna 
      3      1.1  tsarna /*
      4      1.1  tsarna  * Copyright (c) 1999-2003 TAKEMURA Shin All rights reserved.
      5      1.1  tsarna  * Copyright (c) 1999 PocketBSD Project. All rights reserved.
      6      1.1  tsarna  *
      7      1.1  tsarna  * Redistribution and use in source and binary forms, with or without
      8      1.1  tsarna  * modification, are permitted provided that the following conditions
      9      1.1  tsarna  * are met:
     10      1.1  tsarna  * 1. Redistributions of source code must retain the above copyright
     11      1.1  tsarna  *    notice, this list of conditions and the following disclaimer.
     12      1.1  tsarna  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1  tsarna  *    notice, this list of conditions and the following disclaimer in the
     14      1.1  tsarna  *    documentation and/or other materials provided with the distribution.
     15      1.1  tsarna  *
     16      1.1  tsarna  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     17      1.1  tsarna  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18      1.1  tsarna  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19      1.1  tsarna  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     20      1.1  tsarna  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21      1.1  tsarna  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22      1.1  tsarna  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23      1.1  tsarna  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24      1.1  tsarna  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25      1.1  tsarna  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26      1.1  tsarna  * SUCH DAMAGE.
     27      1.1  tsarna  *
     28      1.1  tsarna  */
     29      1.1  tsarna 
     30      1.1  tsarna #include <sys/cdefs.h>
     31  1.3.2.1    yamt __KERNEL_RCSID(0, "$NetBSD: hpctpanel.c,v 1.3.2.1 2006/06/21 15:02:46 yamt Exp $");
     32      1.1  tsarna 
     33      1.1  tsarna #include <sys/param.h>
     34      1.1  tsarna #include <sys/systm.h>
     35      1.1  tsarna #include <sys/device.h>
     36      1.1  tsarna #include <sys/kernel.h>
     37      1.1  tsarna #include <dev/wscons/wsconsio.h>
     38      1.1  tsarna #include <dev/hpc/hpctpanelvar.h>
     39      1.1  tsarna 
     40      1.1  tsarna #include <machine/platid.h>
     41      1.1  tsarna #include <machine/platid_mask.h>
     42      1.1  tsarna 
     43      1.1  tsarna int
     44      1.1  tsarna hpc_tpanel_ioctl(struct tpcalib_softc *sc, u_long cmd, caddr_t data, int flag,
     45  1.3.2.1    yamt     struct lwp *l)
     46      1.1  tsarna {
     47      1.1  tsarna 	struct wsmouse_id *id;
     48      1.3     uwe 	const char *idstr;
     49      1.1  tsarna 	int s;
     50      1.1  tsarna 
     51      1.1  tsarna 	switch (cmd) {
     52      1.1  tsarna         case WSMOUSEIO_GTYPE:
     53      1.1  tsarna 		*(u_int *)data = WSMOUSE_TYPE_TPANEL;
     54      1.1  tsarna 		return (0);
     55      1.1  tsarna 
     56      1.1  tsarna 	case WSMOUSEIO_GETID:
     57      1.1  tsarna 		/*
     58      1.1  tsarna 		 * return unique ID string,
     59      1.1  tsarna 		 * "<vendor> <model> <serial number>"
     60      1.1  tsarna 		 */
     61      1.1  tsarna 		id = (struct wsmouse_id *)data;
     62      1.1  tsarna 		if (id->type != WSMOUSE_ID_TYPE_UIDSTR)
     63      1.1  tsarna 			return (EINVAL);
     64      1.1  tsarna 		idstr = platid_name(&platid);
     65      1.1  tsarna 		s = strlen(idstr);
     66      1.1  tsarna 		if (WSMOUSE_ID_MAXLEN - 10 < s)
     67      1.1  tsarna 			s = WSMOUSE_ID_MAXLEN - 10;
     68      1.1  tsarna 		memcpy(id->data, idstr, s);
     69      1.1  tsarna 		strcpy(&id->data[s], " SN000000");
     70      1.1  tsarna 		id->length = s + 9;
     71      1.1  tsarna 		break;
     72      1.1  tsarna 
     73      1.1  tsarna         case WSMOUSEIO_SCALIBCOORDS:
     74      1.1  tsarna         case WSMOUSEIO_GCALIBCOORDS:
     75  1.3.2.1    yamt                 return tpcalib_ioctl(sc, cmd, data, flag, l);
     76      1.2   perry 
     77      1.1  tsarna 	default:
     78      1.1  tsarna 		return EPASSTHROUGH;
     79      1.1  tsarna 	}
     80      1.2   perry 
     81      1.1  tsarna 	return 0;
     82      1.1  tsarna }
     83