Home | History | Annotate | Line # | Download | only in wscons
wsmuxvar.h revision 1.4
      1 /*	$NetBSD: wsmuxvar.h,v 1.4 2001/10/24 14:07:33 augustss Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * Author: Lennart Augustsson <augustss (at) carlstedt.se>
      8  *         Carlstedt Research & Technology
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * A ws event source, i.e., wskbd, wsmouse, or wsmux.
     41  */
     42 struct wsevsrc {
     43 	struct device me_dv;
     44 	const struct wssrcops *me_ops;	/* method pointers */
     45 	struct wseventvar *me_evp;	/* our wseventvar when open */
     46 #if NWSDISPLAY > 0
     47 	struct device *me_dispdv;       /* our display if part of one */
     48 #endif
     49 #if NWSMUX > 0
     50 	struct wsmux_softc *me_parent;	/* parent mux device */
     51 	CIRCLEQ_ENTRY(wsevsrc) me_next;	/* sibling pointers */
     52 #endif
     53 };
     54 
     55 /*
     56  * Methods that can be performed on an events source.  Usually called
     57  * from a wsmux.
     58  */
     59 struct wssrcops {
     60 	int type;		/* device type: WSMUX_{MOUSE,KBD,MUX} */
     61 	int (*dopen)(struct wsevsrc *, struct wseventvar *);
     62 	int (*dclose)(struct wsevsrc *);
     63 	int (*dioctl)(struct device *, u_long, caddr_t, int, struct proc *);
     64 	int (*ddispioctl)(struct device *, u_long, caddr_t, int, struct proc *);
     65 	int (*dsetdisplay)(struct device *, struct wsevsrc *);
     66 };
     67 
     68 #define wsevsrc_ioctl(me, cmd, data, flag, p) \
     69 	((me)->me_ops->dioctl(&(me)->me_dv, cmd, (caddr_t)data, flag, p))
     70 #define wsevsrc_display_ioctl(me, cmd, data, flag, p) \
     71 	((me)->me_ops->ddispioctl(&(me)->me_dv, cmd, (caddr_t)data, flag, p))
     72 #define wsevsrc_set_display(me, arg) \
     73 	((me)->me_ops->dsetdisplay(&(me)->me_dv, arg))
     74 
     75 #if NWSMUX > 0
     76 struct wsmux_softc {
     77 	struct wsevsrc sc_base;
     78 	struct proc *sc_p;		/* open proc */
     79 	CIRCLEQ_HEAD(, wsevsrc) sc_cld; /* list of children */
     80 #ifdef WSDISPLAY_COMPAT_RAWKBD
     81 	int sc_rawkbd;		        /* A hack to remember the kbd mode */
     82 #endif
     83 };
     84 
     85 struct	wsmux_softc *wsmux_getmux(int);
     86 struct	wsmux_softc *wsmux_create(const char *, int);
     87 int	wsmux_attach_sc(struct wsmux_softc *, struct wsevsrc *);
     88 void	wsmux_detach_sc(struct wsevsrc *);
     89 
     90 int	wskbd_add_mux(int, struct wsmux_softc *);
     91 int	wsmouse_add_mux(int, struct wsmux_softc *);
     92 
     93 #endif /* NWSMUX > 0 */
     94