From owner-svn-src-head@FreeBSD.ORG Thu Oct 22 20:54:02 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E9DE5106566C; Thu, 22 Oct 2009 20:54:01 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D8B498FC15; Thu, 22 Oct 2009 20:54:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9MKs1Xk039780; Thu, 22 Oct 2009 20:54:01 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9MKs1kX039778; Thu, 22 Oct 2009 20:54:01 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200910222054.n9MKs1kX039778@svn.freebsd.org> From: Andrew Thompson Date: Thu, 22 Oct 2009 20:54:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198373 - head/sys/dev/usb/input X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2009 20:54:02 -0000 Author: thompsa Date: Thu Oct 22 20:54:01 2009 New Revision: 198373 URL: http://svn.freebsd.org/changeset/base/198373 Log: Allow dumping the USB mouse reports via 'sysctl -b dev.ums.N.parseinfo', previously only available via bootverbose. PR: usb/137191 Submitted by: Eygene Ryabinkin Modified: head/sys/dev/usb/input/ums.c Modified: head/sys/dev/usb/input/ums.c ============================================================================== --- head/sys/dev/usb/input/ums.c Thu Oct 22 20:44:55 2009 (r198372) +++ head/sys/dev/usb/input/ums.c Thu Oct 22 20:54:01 2009 (r198373) @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -161,7 +162,9 @@ static usb_fifo_open_t ums_open; static usb_fifo_close_t ums_close; static usb_fifo_ioctl_t ums_ioctl; -static void ums_put_queue(struct ums_softc *sc, int32_t dx, int32_t dy, int32_t dz, int32_t dt, int32_t buttons); +static void ums_put_queue(struct ums_softc *, int32_t, int32_t, + int32_t, int32_t, int32_t); +static int ums_sysctl_handler_parseinfo(SYSCTL_HANDLER_ARGS); static struct usb_fifo_methods ums_fifo_methods = { .f_open = &ums_open, @@ -643,6 +646,12 @@ ums_attach(device_t dev) if (err) { goto detach; } + SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "parseinfo", CTLTYPE_STRING|CTLFLAG_RD, + sc, 0, ums_sysctl_handler_parseinfo, + "", "Dump UMS report parsing information"); + return (0); detach: @@ -916,6 +925,67 @@ done: return (error); } +static int +ums_sysctl_handler_parseinfo(SYSCTL_HANDLER_ARGS) +{ + struct ums_softc *sc = arg1; + struct ums_info *info; + struct sbuf *sb; + int i, j, err; + + sb = sbuf_new_auto(); + for (i = 0; i < UMS_INFO_MAX; i++) { + info = &sc->sc_info[i]; + + /* Don't emit empty info */ + if ((info->sc_flags & + (UMS_FLAG_X_AXIS | UMS_FLAG_Y_AXIS | UMS_FLAG_Z_AXIS | + UMS_FLAG_T_AXIS | UMS_FLAG_W_AXIS)) == 0 && + info->sc_buttons == 0) + continue; + + sbuf_printf(sb, "i%d:", i + 1); + if (info->sc_flags & UMS_FLAG_X_AXIS) + sbuf_printf(sb, " X:r%d, p%d, s%d;", + (int)info->sc_iid_x, + (int)info->sc_loc_x.pos, + (int)info->sc_loc_x.size); + if (info->sc_flags & UMS_FLAG_Y_AXIS) + sbuf_printf(sb, " Y:r%d, p%d, s%d;", + (int)info->sc_iid_y, + (int)info->sc_loc_y.pos, + (int)info->sc_loc_y.size); + if (info->sc_flags & UMS_FLAG_Z_AXIS) + sbuf_printf(sb, " Z:r%d, p%d, s%d;", + (int)info->sc_iid_z, + (int)info->sc_loc_z.pos, + (int)info->sc_loc_z.size); + if (info->sc_flags & UMS_FLAG_T_AXIS) + sbuf_printf(sb, " T:r%d, p%d, s%d;", + (int)info->sc_iid_t, + (int)info->sc_loc_t.pos, + (int)info->sc_loc_t.size); + if (info->sc_flags & UMS_FLAG_W_AXIS) + sbuf_printf(sb, " W:r%d, p%d, s%d;", + (int)info->sc_iid_w, + (int)info->sc_loc_w.pos, + (int)info->sc_loc_w.size); + + for (j = 0; j < info->sc_buttons; j++) { + sbuf_printf(sb, " B%d:r%d, p%d, s%d;", j + 1, + (int)info->sc_iid_btn[j], + (int)info->sc_loc_btn[j].pos, + (int)info->sc_loc_btn[j].size); + } + sbuf_printf(sb, "\n"); + } + sbuf_finish(sb); + err = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1); + sbuf_delete(sb); + + return (err); +} + static devclass_t ums_devclass; static device_method_t ums_methods[] = {