Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Add fido constants, and turn hid "raw" mode for fido...
details: https://anonhg.NetBSD.org/src/rev/6f42e86fced9
branches: trunk
changeset: 745456:6f42e86fced9
user: christos <christos%NetBSD.org@localhost>
date: Mon Mar 02 18:15:28 2020 +0000
description:
Add fido constants, and turn hid "raw" mode for fido devices.
diffstat:
sys/dev/hid/hid.h | 6 +++++-
sys/dev/usb/uhid.c | 32 ++++++++++++++++++++++++++------
2 files changed, 31 insertions(+), 7 deletions(-)
diffs (99 lines):
diff -r c3c4455b1cd9 -r 6f42e86fced9 sys/dev/hid/hid.h
--- a/sys/dev/hid/hid.h Mon Mar 02 16:04:49 2020 +0000
+++ b/sys/dev/hid/hid.h Mon Mar 02 18:15:28 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hid.h,v 1.3 2018/11/15 23:01:45 jakllsch Exp $ */
+/* $NetBSD: hid.h,v 1.4 2020/03/02 18:15:28 christos Exp $ */
/* $FreeBSD: src/sys/dev/usb/hid.h,v 1.7 1999/11/17 22:33:40 n_hibma Exp $ */
/*
@@ -123,6 +123,7 @@
#define HUP_CAMERA_CONTROL 0x0090
#define HUP_ARCADE 0x0091
#define HUP_VENDOR 0x00ff
+#define HUP_FIDO 0xf1d0
#define HUP_MICROSOFT 0xff00
/* XXX compat */
#define HUP_APPLE 0x00ff
@@ -396,6 +397,9 @@
/* Usages, Consumer */
#define HUC_AC_PAN 0x0238
+/* Usages, FIDO */
+#define HUF_U2FHID 0x0001
+
#define HID_USAGE2(p, u) (((p) << 16) | u)
#define HID_GET_USAGE(u) ((u) & 0xffff)
#define HID_GET_USAGE_PAGE(u) (((u) >> 16) & 0xffff)
diff -r c3c4455b1cd9 -r 6f42e86fced9 sys/dev/usb/uhid.c
--- a/sys/dev/usb/uhid.c Mon Mar 02 16:04:49 2020 +0000
+++ b/sys/dev/usb/uhid.c Mon Mar 02 18:15:28 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uhid.c,v 1.111 2020/01/01 09:05:03 maxv Exp $ */
+/* $NetBSD: uhid.c,v 1.112 2020/03/02 18:15:28 christos Exp $ */
/*
* Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.111 2020/01/01 09:05:03 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.112 2020/03/02 18:15:28 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -104,6 +104,7 @@
#define UHID_IMMED 0x02 /* return read data immediately */
int sc_refcnt;
+ int sc_raw;
u_char sc_dying;
};
@@ -184,6 +185,8 @@
sc->sc_isize = hid_report_size(desc, size, hid_input, repid);
sc->sc_osize = hid_report_size(desc, size, hid_output, repid);
sc->sc_fsize = hid_report_size(desc, size, hid_feature, repid);
+ sc->sc_raw = hid_is_collection(desc, size, uha->reportid,
+ HID_USAGE2(HUP_FIDO, HUF_U2FHID));
aprint_naive("\n");
aprint_normal(": input=%d, output=%d, feature=%d\n",
@@ -482,15 +485,32 @@
return EIO;
size = sc->sc_osize;
- error = 0;
if (uio->uio_resid != size || size == 0)
return EINVAL;
error = uiomove(sc->sc_obuf, size, uio);
+#ifdef UHID_DEBUG
+ if (uhiddebug > 5) {
+ uint32_t i;
+
+ DPRINTF(("%s: outdata[%d] =", device_xname(sc->sc_hdev.sc_dev),
+ error));
+ for (i = 0; i < size; i++)
+ DPRINTF((" %02x", sc->sc_obuf[i]));
+ DPRINTF(("\n"));
+ }
+#endif
if (!error) {
- err = uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT,
- sc->sc_obuf, size);
- if (err)
+ if (sc->sc_raw)
+ err = uhidev_write(sc->sc_hdev.sc_parent, sc->sc_obuf,
+ size);
+ else
+ err = uhidev_set_report(&sc->sc_hdev,
+ UHID_OUTPUT_REPORT, sc->sc_obuf, size);
+ if (err) {
+ DPRINTF(("%s: err = %d\n",
+ device_xname(sc->sc_hdev.sc_dev), err));
error = EIO;
+ }
}
return error;
Home |
Main Index |
Thread Index |
Old Index