summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/hid/hidmt.c16
-rw-r--r--sys/dev/hid/hidmtvar.h3
-rw-r--r--sys/dev/i2c/ihidev.c15
-rw-r--r--sys/dev/i2c/ihidev.h3
-rw-r--r--sys/dev/i2c/imt.c3
-rw-r--r--sys/dev/usb/uhidev.c17
-rw-r--r--sys/dev/usb/uhidev.h3
7 files changed, 39 insertions, 21 deletions
diff --git a/sys/dev/hid/hidmt.c b/sys/dev/hid/hidmt.c
index 7a9b91674cf..6638d395d5d 100644
--- a/sys/dev/hid/hidmt.c
+++ b/sys/dev/hid/hidmt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hidmt.c,v 1.7 2018/07/30 15:56:30 jcs Exp $ */
+/* $OpenBSD: hidmt.c,v 1.8 2018/08/25 18:32:05 jcs Exp $ */
/*
* HID multitouch driver for devices conforming to Windows Precision Touchpad
* standard
@@ -126,7 +126,11 @@ hidmt_setup(struct device *self, struct hidmt *mt, void *desc, int dlen)
capsize = hid_report_size(desc, dlen, hid_feature, mt->sc_rep_cap);
rep = malloc(capsize, M_DEVBUF, M_NOWAIT | M_ZERO);
- if (mt->hidev_get_report(mt->sc_device, hid_feature, mt->sc_rep_cap,
+ if (mt->hidev_report_type_conv == NULL)
+ panic("no report type conversion function");
+
+ if (mt->hidev_get_report(mt->sc_device,
+ mt->hidev_report_type_conv(hid_feature), mt->sc_rep_cap,
rep, capsize)) {
printf("\n%s: failed getting capability report\n",
self->dv_xname);
@@ -278,8 +282,12 @@ hidmt_detach(struct hidmt *mt, int flags)
int
hidmt_set_input_mode(struct hidmt *mt, uint16_t mode)
{
- return mt->hidev_set_report(mt->sc_device, hid_feature,
- mt->sc_rep_config, &mode, 2);
+ if (mt->hidev_report_type_conv == NULL)
+ panic("no report type conversion function");
+
+ return mt->hidev_set_report(mt->sc_device,
+ mt->hidev_report_type_conv(hid_feature),
+ mt->sc_rep_config, &mode, sizeof(mode));
}
void
diff --git a/sys/dev/hid/hidmtvar.h b/sys/dev/hid/hidmtvar.h
index 615efe56d73..66d95eda2a2 100644
--- a/sys/dev/hid/hidmtvar.h
+++ b/sys/dev/hid/hidmtvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hidmtvar.h,v 1.5 2017/10/10 20:31:50 jcs Exp $ */
+/* $OpenBSD: hidmtvar.h,v 1.6 2018/08/25 18:32:05 jcs Exp $ */
/*
* Copyright (c) 2016 joshua stein <jcs@openbsd.org>
*
@@ -39,6 +39,7 @@ struct hidmt {
#define HIDMT_REVY 0x0001 /* Y-axis is reversed ("natural" scrolling) */
struct device *sc_device;
+ int (*hidev_report_type_conv)(int);
int (*hidev_get_report)(struct device *, int, int, void *,
int);
int (*hidev_set_report)(struct device *, int, int, void *,
diff --git a/sys/dev/i2c/ihidev.c b/sys/dev/i2c/ihidev.c
index b1c6b8db348..cf183afac9e 100644
--- a/sys/dev/i2c/ihidev.c
+++ b/sys/dev/i2c/ihidev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ihidev.c,v 1.16 2018/01/12 08:11:47 mlarkin Exp $ */
+/* $OpenBSD: ihidev.c,v 1.17 2018/08/25 18:32:05 jcs Exp $ */
/*
* HID-over-i2c driver
*
@@ -787,7 +787,6 @@ ihidev_get_report_desc(struct ihidev_softc *sc, void **desc, int *size)
*size = sc->sc_reportlen;
}
-/* convert hid_* constants used throughout HID code to i2c HID equivalents */
int
ihidev_report_type_conv(int hid_type_id)
{
@@ -808,12 +807,8 @@ ihidev_get_report(struct device *dev, int type, int id, void *data, int len)
{
struct ihidev_softc *sc = (struct ihidev_softc *)dev;
struct i2c_hid_report_request rreq;
- int ctype;
- if ((ctype = ihidev_report_type_conv(type)) < 0)
- return (1);
-
- rreq.type = ctype;
+ rreq.type = type;
rreq.id = id;
rreq.data = data;
rreq.len = len;
@@ -831,12 +826,8 @@ ihidev_set_report(struct device *dev, int type, int id, void *data, int len)
{
struct ihidev_softc *sc = (struct ihidev_softc *)dev;
struct i2c_hid_report_request rreq;
- int ctype;
-
- if ((ctype = ihidev_report_type_conv(type)) < 0)
- return (1);
- rreq.type = ctype;
+ rreq.type = type;
rreq.id = id;
rreq.data = data;
rreq.len = len;
diff --git a/sys/dev/i2c/ihidev.h b/sys/dev/i2c/ihidev.h
index 7cd6dbc1cf5..a9ff60f182d 100644
--- a/sys/dev/i2c/ihidev.h
+++ b/sys/dev/i2c/ihidev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ihidev.h,v 1.5 2017/11/29 02:48:16 jcs Exp $ */
+/* $OpenBSD: ihidev.h,v 1.6 2018/08/25 18:32:05 jcs Exp $ */
/*
* HID-over-i2c driver
*
@@ -128,5 +128,6 @@ int ihidev_open(struct ihidev *);
void ihidev_close(struct ihidev *);
int ihidev_ioctl(struct ihidev *, u_long, caddr_t, int, struct proc *);
+int ihidev_report_type_conv(int);
int ihidev_set_report(struct device *, int, int, void *, int);
int ihidev_get_report(struct device *, int, int, void *, int);
diff --git a/sys/dev/i2c/imt.c b/sys/dev/i2c/imt.c
index 0443bd765d3..debcffc60c5 100644
--- a/sys/dev/i2c/imt.c
+++ b/sys/dev/i2c/imt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imt.c,v 1.2 2017/07/23 22:39:11 jcs Exp $ */
+/* $OpenBSD: imt.c,v 1.3 2018/08/25 18:32:05 jcs Exp $ */
/*
* HID-over-i2c multitouch trackpad driver for devices conforming to
* Windows Precision Touchpad standard
@@ -154,6 +154,7 @@ imt_attach(struct device *parent, struct device *self, void *aux)
/* assume everything has "natural scrolling" where Y axis is reversed */
mt->sc_flags = HIDMT_REVY;
+ mt->hidev_report_type_conv = ihidev_report_type_conv;
mt->hidev_get_report = imt_hidev_get_report;
mt->hidev_set_report = imt_hidev_set_report;
mt->sc_rep_input = sc->sc_rep_input;
diff --git a/sys/dev/usb/uhidev.c b/sys/dev/usb/uhidev.c
index a61625e64c1..7c02c82f7d5 100644
--- a/sys/dev/usb/uhidev.c
+++ b/sys/dev/usb/uhidev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhidev.c,v 1.75 2017/04/08 02:57:25 deraadt Exp $ */
+/* $OpenBSD: uhidev.c,v 1.76 2018/08/25 18:32:05 jcs Exp $ */
/* $NetBSD: uhidev.c,v 1.14 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -640,6 +640,21 @@ uhidev_close(struct uhidev *scd)
}
int
+uhidev_report_type_conv(int hid_type_id)
+{
+ switch (hid_type_id) {
+ case hid_input:
+ return UHID_INPUT_REPORT;
+ case hid_output:
+ return UHID_OUTPUT_REPORT;
+ case hid_feature:
+ return UHID_FEATURE_REPORT;
+ default:
+ return -1;
+ }
+}
+
+int
uhidev_set_report(struct uhidev_softc *sc, int type, int id, void *data,
int len)
{
diff --git a/sys/dev/usb/uhidev.h b/sys/dev/usb/uhidev.h
index 43020fb9803..16657f1e712 100644
--- a/sys/dev/usb/uhidev.h
+++ b/sys/dev/usb/uhidev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhidev.h,v 1.24 2016/01/09 02:01:06 jcs Exp $ */
+/* $OpenBSD: uhidev.h,v 1.25 2018/08/25 18:32:05 jcs Exp $ */
/* $NetBSD: uhidev.h,v 1.3 2002/10/08 09:56:17 dan Exp $ */
/*
@@ -84,6 +84,7 @@ struct uhidev_attach_arg {
#define UHIDEV_CLAIM_ALLREPORTID 255
};
+int uhidev_report_type_conv(int);
void uhidev_get_report_desc(struct uhidev_softc *, void **, int *);
int uhidev_open(struct uhidev *);
void uhidev_close(struct uhidev *);