Add fido constants, and turn hid "raw" mode for fido devices.
This commit is contained in:
parent
00fb306ae0
commit
141531ce86
@ -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 @@ int hid_is_collection(const void *, int, uint8_t, uint32_t);
|
||||
#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 @@ int hid_is_collection(const void *, int, uint8_t, uint32_t);
|
||||
/* 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)
|
||||
|
@ -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 @@ struct uhid_softc {
|
||||
#define UHID_IMMED 0x02 /* return read data immediately */
|
||||
|
||||
int sc_refcnt;
|
||||
int sc_raw;
|
||||
u_char sc_dying;
|
||||
};
|
||||
|
||||
@ -184,6 +185,8 @@ uhid_attach(device_t parent, device_t self, void *aux)
|
||||
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 @@ uhid_do_write(struct uhid_softc *sc, struct uio *uio, int flag)
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user