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