1 /* $OpenBSD: wsmuxvar.h,v 1.8 2008/06/26 05:42:19 ray Exp $ */ 2 /* $NetBSD: wsmuxvar.h,v 1.10 2005/04/30 03:47:12 augustss Exp $ */ 3 4 /* 5 * Copyright (c) 1998 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * Author: Lennart Augustsson <augustss@carlstedt.se> 9 * Carlstedt Research & Technology 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 /* 34 * A ws event source, i.e., wskbd, wsmouse, or wsmux. 35 */ 36 struct wsevsrc { 37 struct device me_dv; 38 const struct wssrcops *me_ops; /* method pointers */ 39 struct wseventvar me_evar; /* wseventvar opened directly */ 40 struct wseventvar *me_evp; /* our wseventvar when open */ 41 #if NWSDISPLAY > 0 42 struct device *me_dispdv; /* our display if part of one */ 43 #define sc_displaydv sc_base.me_dispdv 44 #endif 45 #if NWSMUX > 0 46 struct wsmux_softc *me_parent; /* parent mux device */ 47 CIRCLEQ_ENTRY(wsevsrc) me_next; /* sibling pointers */ 48 #endif 49 }; 50 51 /* 52 * Methods that can be performed on an events source. Usually called 53 * from a wsmux. 54 */ 55 struct wssrcops { 56 int type; /* device type: WSMUX_{MOUSE,KBD,MUX} */ 57 int (*dopen)(struct wsevsrc *, struct wseventvar *); 58 int (*dclose)(struct wsevsrc *); 59 int (*dioctl)(struct device *, u_long, caddr_t, int, struct proc *); 60 int (*ddispioctl)(struct device *, u_long, caddr_t, int, struct proc *); 61 int (*dsetdisplay)(struct device *, struct device *); 62 }; 63 64 #define wsevsrc_open(me, evp) \ 65 ((me)->me_ops->dopen((me), evp)) 66 #define wsevsrc_close(me) \ 67 ((me)->me_ops->dclose((me))) 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 u_int32_t sc_kbd_layout; /* current layout of keyboard */ 81 #ifdef WSDISPLAY_COMPAT_RAWKBD 82 int sc_rawkbd; /* A hack to remember the kbd mode */ 83 #endif 84 }; 85 86 /* 87 * configure defines 88 */ 89 #define WSMOUSEDEVCF_MUX 0 90 91 struct wsmux_softc *wsmux_getmux(int); 92 struct wsmux_softc *wsmux_create(const char *, int); 93 int wsmux_attach_sc(struct wsmux_softc *, struct wsevsrc *); 94 void wsmux_detach_sc(struct wsevsrc *); 95 int wsmux_set_display(struct wsmux_softc *, struct device *); 96 97 int wskbd_add_mux(int, struct wsmux_softc *); 98 int wsmouse_add_mux(int, struct wsmux_softc *); 99 100 #endif /* NWSMUX > 0 */ 101