wsmuxvar.h revision 1.8
1/* $NetBSD: wsmuxvar.h,v 1.8 2003/06/28 14:21:48 darrenr Exp $ */ 2 3/* 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * Author: Lennart Augustsson <augustss@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 */ 42struct wsevsrc { 43 struct device me_dv; 44 const struct wssrcops *me_ops; /* method pointers */ 45 struct wseventvar me_evar; /* wseventvar opened directly */ 46 struct wseventvar *me_evp; /* our wseventvar when open */ 47#if NWSDISPLAY > 0 48 struct device *me_dispdv; /* our display if part of one */ 49#endif 50#if NWSMUX > 0 51 struct wsmux_softc *me_parent; /* parent mux device */ 52 CIRCLEQ_ENTRY(wsevsrc) me_next; /* sibling pointers */ 53#endif 54}; 55 56/* 57 * Methods that can be performed on an events source. Usually called 58 * from a wsmux. 59 */ 60struct wssrcops { 61 int type; /* device type: WSMUX_{MOUSE,KBD,MUX} */ 62 int (*dopen)(struct wsevsrc *, struct wseventvar *); 63 int (*dclose)(struct wsevsrc *); 64 int (*dioctl)(struct device *, u_long, caddr_t, int, struct lwp *); 65 int (*ddispioctl)(struct device *, u_long, caddr_t, int, struct lwp *); 66 int (*dsetdisplay)(struct device *, struct wsevsrc *); 67}; 68 69#define wsevsrc_open(me, evp) \ 70 ((me)->me_ops->dopen((me), evp)) 71#define wsevsrc_close(me) \ 72 ((me)->me_ops->dclose((me))) 73#define wsevsrc_ioctl(me, cmd, data, flag, l) \ 74 ((me)->me_ops->dioctl(&(me)->me_dv, cmd, (caddr_t)data, flag, l)) 75#define wsevsrc_display_ioctl(me, cmd, data, flag, l) \ 76 ((me)->me_ops->ddispioctl(&(me)->me_dv, cmd, (caddr_t)data, flag, l)) 77#define wsevsrc_set_display(me, arg) \ 78 ((me)->me_ops->dsetdisplay(&(me)->me_dv, arg)) 79 80#if NWSMUX > 0 81struct wsmux_softc { 82 struct wsevsrc sc_base; 83 struct proc *sc_p; /* open proc */ 84 CIRCLEQ_HEAD(, wsevsrc) sc_cld; /* list of children */ 85#ifdef WSDISPLAY_COMPAT_RAWKBD 86 int sc_rawkbd; /* A hack to remember the kbd mode */ 87#endif 88}; 89 90struct wsmux_softc *wsmux_getmux(int); 91struct wsmux_softc *wsmux_create(const char *, int); 92int wsmux_attach_sc(struct wsmux_softc *, struct wsevsrc *); 93void wsmux_detach_sc(struct wsevsrc *); 94int wsmux_set_display(struct wsmux_softc *, struct device *); 95 96int wskbd_add_mux(int, struct wsmux_softc *); 97int wsmouse_add_mux(int, struct wsmux_softc *); 98 99#endif /* NWSMUX > 0 */ 100