Index: arch/alpha/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/alpha/conf/GENERIC,v retrieving revision 1.231 diff -u -p -r1.231 GENERIC --- arch/alpha/conf/GENERIC 20 Aug 2013 14:27:24 -0000 1.231 +++ arch/alpha/conf/GENERIC 4 Sep 2013 19:47:26 -0000 @@ -123,6 +123,7 @@ run* at uhub? # Ralink RT2700U/RT2800U uow* at uhub? # Maxim/Dallas DS2490 1-Wire adapter onewire* at uow? uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utwitch* at uhidev? # yurex BBU sensor # USB Video Index: arch/amd64/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/amd64/conf/GENERIC,v retrieving revision 1.347 diff -u -p -r1.347 GENERIC --- arch/amd64/conf/GENERIC 21 Aug 2013 18:29:25 -0000 1.347 +++ arch/amd64/conf/GENERIC 4 Sep 2013 19:47:28 -0000 @@ -246,6 +246,7 @@ rsu* at uhub? # RealTek RTL8188SU/RTL81 urtwn* at uhub? # RealTek RTL8188CU/RTL8192CU udcf* at uhub? # Gude Expert mouseCLOCK uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utrh* at uhidev? # USBRH sensor utwitch* at uhidev? # YUREX BBU sensor uow* at uhub? # Maxim/Dallas DS2490 1-Wire adapter Index: arch/armish/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/armish/conf/GENERIC,v retrieving revision 1.48 diff -u -p -r1.48 GENERIC --- arch/armish/conf/GENERIC 20 Aug 2013 14:27:26 -0000 1.48 +++ arch/armish/conf/GENERIC 4 Sep 2013 19:47:29 -0000 @@ -155,6 +155,7 @@ urtwn* at uhub? # Realtek RTL8188CU/RTL athn* at uhub? # Atheros AR9002U #udcf* at uhub? # Gude Expert mouseCLOCK uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utwitch* at uhidev? # YUREX BBU sensor uow* at uhub? # Maxim/Dallas DS2490 1-Wire adapter onewire* at uow? Index: arch/hppa/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/hppa/conf/GENERIC,v retrieving revision 1.151 diff -u -p -r1.151 GENERIC --- arch/hppa/conf/GENERIC 20 Aug 2013 14:27:26 -0000 1.151 +++ arch/hppa/conf/GENERIC 4 Sep 2013 19:47:33 -0000 @@ -163,6 +163,7 @@ rum* at uhub? # Ralink RT2501USB/RT2601 run* at uhub? # Ralink RT2700U/RT2800U/RT3000U zyd* at uhub? # Zydas ZD1211 uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utwitch* at uhidev? # YUREX BBU sensor uow* at uhub? # Maxim/Dallas DS2490 1-Wire adapter onewire* at uow? Index: arch/i386/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/i386/conf/GENERIC,v retrieving revision 1.753 diff -u -p -r1.753 GENERIC --- arch/i386/conf/GENERIC 21 Aug 2013 18:29:25 -0000 1.753 +++ arch/i386/conf/GENERIC 4 Sep 2013 19:47:34 -0000 @@ -300,6 +300,7 @@ urtwn* at uhub? # RealTek RTL8188CU/RTL udcf* at uhub? # Gude Expert mouseCLOCK umbg* at uhub? # Meinberg Funkuhren USB5131 uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utrh* at uhidev? # USBRH sensor utwitch* at uhidev? # YUREX BBU sensor uow* at uhub? # Maxim/Dallas DS2490 1-Wire adapter Index: arch/landisk/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/landisk/conf/GENERIC,v retrieving revision 1.39 diff -u -p -r1.39 GENERIC --- arch/landisk/conf/GENERIC 20 Aug 2013 14:27:28 -0000 1.39 +++ arch/landisk/conf/GENERIC 4 Sep 2013 19:47:35 -0000 @@ -153,6 +153,7 @@ urtwn* at uhub? # Realtek RTL8188CU/RTL zyd* at uhub? # Zydas ZD1211 udcf* at uhub? # Gude Expert mouseCLOCK uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utwitch* at uhidev? # YUREX BBU sensor #uow* at uhub? # Maxim/Dallas DS2490 1-Wire adapter #onewire* at uow? Index: arch/loongson/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/loongson/conf/GENERIC,v retrieving revision 1.39 diff -u -p -r1.39 GENERIC --- arch/loongson/conf/GENERIC 20 Aug 2013 14:27:29 -0000 1.39 +++ arch/loongson/conf/GENERIC 4 Sep 2013 19:47:36 -0000 @@ -157,6 +157,7 @@ zyd* at uhub? # Zydas ZD1211 uberry* at uhub? # Research In Motion Blackberry udcf* at uhub? # Gude Expert mouseCLOCK uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utwitch* at uhidev? # YUREX BBU sensor ugen* at uhub? # USB Generic driver Index: arch/macppc/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/macppc/conf/GENERIC,v retrieving revision 1.225 diff -u -p -r1.225 GENERIC --- arch/macppc/conf/GENERIC 20 Aug 2013 14:27:29 -0000 1.225 +++ arch/macppc/conf/GENERIC 4 Sep 2013 19:47:38 -0000 @@ -288,6 +288,7 @@ urtw* at uhub? # RealTek 8187 udcf* at uhub? # Gude Expert mouseCLOCK umbg* at uhub? # Meinberg Funkuhren USB5131 uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utrh* at uhidev? # USBRH sensor utwitch* at uhidev? # YUREX BBU sensor uow* at uhub? # Maxim/Dallas DS2490 1-Wire adapter Index: arch/sgi/conf/GENERIC-IP27 =================================================================== RCS file: /cvs/src/sys/arch/sgi/conf/GENERIC-IP27,v retrieving revision 1.46 diff -u -p -r1.46 GENERIC-IP27 --- arch/sgi/conf/GENERIC-IP27 20 Aug 2013 22:21:13 -0000 1.46 +++ arch/sgi/conf/GENERIC-IP27 4 Sep 2013 19:47:42 -0000 @@ -144,6 +144,7 @@ wi* at uhub? # WaveLAN IEEE 802.11DS zyd* at uhub? # Zydas ZD1211 ugen* at uhub? # USB Generic driver uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utwitch* at uhidev? # YUREX BBU sensor # USB Video Index: arch/sgi/conf/GENERIC-IP30 =================================================================== RCS file: /cvs/src/sys/arch/sgi/conf/GENERIC-IP30,v retrieving revision 1.40 diff -u -p -r1.40 GENERIC-IP30 --- arch/sgi/conf/GENERIC-IP30 20 Aug 2013 22:21:13 -0000 1.40 +++ arch/sgi/conf/GENERIC-IP30 4 Sep 2013 19:47:42 -0000 @@ -136,6 +136,7 @@ wi* at uhub? # WaveLAN IEEE 802.11DS zyd* at uhub? # Zydas ZD1211 ugen* at uhub? # USB Generic driver uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utwitch* at uhidev? # YUREX BBU sensor # USB Video Index: arch/sgi/conf/GENERIC-IP32 =================================================================== RCS file: /cvs/src/sys/arch/sgi/conf/GENERIC-IP32,v retrieving revision 1.31 diff -u -p -r1.31 GENERIC-IP32 --- arch/sgi/conf/GENERIC-IP32 20 Aug 2013 22:21:13 -0000 1.31 +++ arch/sgi/conf/GENERIC-IP32 4 Sep 2013 19:47:42 -0000 @@ -128,6 +128,7 @@ wi* at uhub? # WaveLAN IEEE 802.11DS zyd* at uhub? # Zydas ZD1211 ugen* at uhub? # USB Generic driver uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utwitch* at uhidev? # YUREX BBU sensor # USB Video Index: arch/socppc/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/socppc/conf/GENERIC,v retrieving revision 1.24 diff -u -p -r1.24 GENERIC --- arch/socppc/conf/GENERIC 20 Aug 2013 14:27:30 -0000 1.24 +++ arch/socppc/conf/GENERIC 4 Sep 2013 19:47:44 -0000 @@ -83,6 +83,7 @@ zyd* at uhub? # Zydas ZD1211 urio* at uhub? # Diamond Multimedia Rio 500 ugen* at uhub? # USB Generic driver uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utwitch* at uhidev? # YUREX BBU sensor udl* at uhub? Index: arch/sparc64/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/sparc64/conf/GENERIC,v retrieving revision 1.272 diff -u -p -r1.272 GENERIC --- arch/sparc64/conf/GENERIC 20 Aug 2013 14:27:31 -0000 1.272 +++ arch/sparc64/conf/GENERIC 4 Sep 2013 19:47:46 -0000 @@ -236,6 +236,7 @@ ugen* at uhub? # USB Generic driver udcf* at uhub? # Gude Expert mouseCLOCK umbg* at uhub? # Meinberg Funkuhren USB5131 uthum* at uhidev? # TEMPerHUM sensor +ugold* at uhidev? # gold TEMPer sensor utwitch* at uhidev? # UYUREX BBU sensor uow* at uhub? # Maxim/Dallas DS2490 1-Wire adapter onewire* at uow? Index: dev/usb/files.usb =================================================================== RCS file: /cvs/src/sys/dev/usb/files.usb,v retrieving revision 1.108 diff -u -p -r1.108 files.usb --- dev/usb/files.usb 20 Aug 2013 14:27:33 -0000 1.108 +++ dev/usb/files.usb 4 Sep 2013 19:47:52 -0000 @@ -129,6 +129,11 @@ device uthum: hid attach uthum at uhidbus file dev/usb/uthum.c uthum +# gold TEMPer +device ugold: hid +attach ugold at uhidbus +file dev/usb/ugold.c ugold + # Strawberry Linux USBRH device utrh: hid attach utrh at uhidbus Index: dev/usb/ugold.c =================================================================== RCS file: dev/usb/ugold.c diff -N dev/usb/ugold.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ dev/usb/ugold.c 4 Sep 2013 19:47:52 -0000 @@ -0,0 +1,257 @@ +/* $OpenBSD$ */ + +/* + * Copyright (c) 2013 Takayoshi SASANO + * Copyright (c) 2013 Martin Pieuchot + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* Driver for Microdia's HID base TEMPer Temperature sensor */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#define UGOLD_INNER 0 +#define UGOLD_OUTER 1 +#define UGOLD_MAX_SENSORS 2 + +#define UGOLD_CMD_DATA 0x80 +#define UGOLD_CMD_INIT 0x82 + +/* + * This driver only uses two of the three known commands for the + * TEMPerV1.2 device. + * + * The first byte of the answer corresponds to the command and the + * second one seems to be the size (in bytes) of the answer. + * + * The device always sends 8 bytes and if the length of the answer + * is less than that, it just leaves the last bytes untouched. That + * is why most of the time the last n bytes of the answers are the + * same. + * + * The third command below seems to generate two answers with a + * string corresponding to the device, for example: + * 'TEMPer1F' and '1.1Per1F' (here Per1F is repeated). + */ +static uint8_t cmd_data[8] = { 0x01, 0x80, 0x33, 0x01, 0x00, 0x00, 0x00, 0x00 }; +static uint8_t cmd_init[8] = { 0x01, 0x82, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00 }; +#if 0 +static uint8_t cmd_type[8] = { 0x01, 0x86, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00 }; +#endif + +struct ugold_softc { + struct uhidev sc_hdev; + struct usbd_device *sc_udev; + + int sc_num_sensors; + + struct ksensor sc_sensor[UGOLD_MAX_SENSORS]; + struct ksensordev sc_sensordev; + struct sensor_task *sc_sensortask; +}; + +const struct usb_devno ugold_devs[] = { + { USB_VENDOR_MICRODIA, USB_PRODUCT_MICRODIA_TEMPER }, +}; + +int ugold_match(struct device *, void *, void *); +void ugold_attach(struct device *, struct device *, void *); +int ugold_detach(struct device *, int); + +void ugold_intr(struct uhidev *, void *, u_int); +void ugold_refresh(void *); + +int ugold_issue_cmd(struct ugold_softc *, uint8_t *, int); + +struct cfdriver ugold_cd = { + NULL, "ugold", DV_DULL +}; + +const struct cfattach ugold_ca = { + sizeof(struct ugold_softc), ugold_match, ugold_attach, ugold_detach, +}; + +int +ugold_match(struct device *parent, void *match, void *aux) +{ + struct uhidev_attach_arg *uha = aux; + int size; + void *desc; + + if (usb_lookup(ugold_devs, uha->uaa->vendor, uha->uaa->product) == NULL) + return (UMATCH_NONE); + + /* + * XXX Only match the sensor interface. + * + * Does it makes sense to attach various uhidev(4) to these + * non-standard HID devices? + */ + uhidev_get_report_desc(uha->parent, &desc, &size); + if (hid_is_collection(desc, size, uha->reportid, + HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_KEYBOARD))) + return (UMATCH_NONE); + + return (UMATCH_VENDOR_PRODUCT); + +} + +void +ugold_attach(struct device *parent, struct device *self, void *aux) +{ + struct ugold_softc *sc = (struct ugold_softc *)self; + struct uhidev_attach_arg *uha = aux; + int size, repid; + void *desc; + + sc->sc_udev = uha->parent->sc_udev; + sc->sc_hdev.sc_intr = ugold_intr; + sc->sc_hdev.sc_parent = uha->parent; + sc->sc_hdev.sc_report_id = uha->reportid; + + uhidev_get_report_desc(uha->parent, &desc, &size); + repid = uha->reportid; + sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid); + sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid); + sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid); + + if (uhidev_open(&sc->sc_hdev)) { + printf(", unable to open interrupt pipe\n"); + return; + } + + strlcpy(sc->sc_sensordev.xname, sc->sc_hdev.sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + + sc->sc_sensor[UGOLD_OUTER].type = SENSOR_TEMP; + strlcpy(sc->sc_sensor[UGOLD_OUTER].desc, "outer", + sizeof(sc->sc_sensor[UGOLD_OUTER].desc)); + + sc->sc_sensor[UGOLD_INNER].type = SENSOR_TEMP; + strlcpy(sc->sc_sensor[UGOLD_INNER].desc, "inner", + sizeof(sc->sc_sensor[UGOLD_INNER].desc)); + + /* 0.1Hz */ + sc->sc_sensortask = sensor_task_register(sc, ugold_refresh, 6); + if (sc->sc_sensortask == NULL) { + printf(", unable to register update task\n"); + return; + } + printf("\n"); + + sensordev_install(&sc->sc_sensordev); +} + +int +ugold_detach(struct device *self, int flags) +{ + struct ugold_softc *sc = (struct ugold_softc *)self; + int i; + + if (sc->sc_sensortask != NULL) { + sensor_task_unregister(sc->sc_sensortask); + sensordev_deinstall(&sc->sc_sensordev); + } + + for (i = 0; i < sc->sc_num_sensors; i++) + sensor_detach(&sc->sc_sensordev, &sc->sc_sensor[i]); + + return (0); +} + +static int +ugold_ds75_temp(uint8_t msb, uint8_t lsb) +{ + /* DS75: 12bit precision mode : 0.0625 degrees Celsius ticks */ + return (((msb * 100) + ((lsb >> 4) * 25 / 4)) * 10000) + 273150000; +} + +void +ugold_intr(struct uhidev *addr, void *ibuf, u_int len) +{ + struct ugold_softc *sc = (struct ugold_softc *)addr; + uint8_t *buf = ibuf; + int i, temp; + + switch (buf[0]) { + case UGOLD_CMD_INIT: + if (sc->sc_num_sensors) + break; + + sc->sc_num_sensors = min(buf[1], UGOLD_MAX_SENSORS) /* XXX */; + + for (i = 0; i < sc->sc_num_sensors; i++) { + sc->sc_sensor[i].flags |= SENSOR_FINVALID; + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + } + + printf("%s: %d sensor%s type ds75/12bit (temperature)\n", + sc->sc_hdev.sc_dev.dv_xname, sc->sc_num_sensors, + (sc->sc_num_sensors == 1) ? "" : "s"); + break; + case UGOLD_CMD_DATA: + switch (buf[1]) { + case 4: + temp = ugold_ds75_temp(buf[4], buf[5]); + sc->sc_sensor[UGOLD_OUTER].value = temp; + sc->sc_sensor[UGOLD_OUTER].flags &= ~SENSOR_FINVALID; + /* FALLTHROUGH */ + case 2: + temp = ugold_ds75_temp(buf[2], buf[3]); + sc->sc_sensor[UGOLD_INNER].value = temp; + sc->sc_sensor[UGOLD_INNER].flags &= ~SENSOR_FINVALID; + break; + default: + printf("%s: invalid data length (%d bytes)\n", + sc->sc_hdev.sc_dev.dv_xname, buf[1]); + } + break; + default: + printf("%s: unknown command 0x%02x\n", + sc->sc_hdev.sc_dev.dv_xname, buf[0]); + } +} + +void +ugold_refresh(void *arg) +{ + struct ugold_softc *sc = arg; + int i; + + if (sc->sc_num_sensors == 0) + ugold_issue_cmd(sc, cmd_init, sizeof(cmd_init)); + + if (ugold_issue_cmd(sc, cmd_data, sizeof(cmd_data))) { + for (i = 0; i < sc->sc_num_sensors; i++) + sc->sc_sensor[i].flags |= SENSOR_FINVALID; + } +} + +int +ugold_issue_cmd(struct ugold_softc *sc, uint8_t *cmd, int len) +{ + return (uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT , cmd, len)); +} Index: dev/usb/usbdevs =================================================================== RCS file: /cvs/src/sys/dev/usb/usbdevs,v retrieving revision 1.604 diff -u -p -r1.604 usbdevs --- dev/usb/usbdevs 20 Aug 2013 04:49:44 -0000 1.604 +++ dev/usb/usbdevs 4 Sep 2013 19:47:52 -0000 @@ -2832,7 +2832,8 @@ product MSI BLUETOOTH_3 0xa97a Bluetoot /* Microdia / Sonix Techonology Co., Ltd. products */ product MICRODIA YUREX 0x1010 YUREX -product MICRODIA CAM_1 0x62c0 CAM_1 +product MICRODIA CAM_1 0x62c0 CAM_1 +product MICRODIA TEMPER 0x7401 TEMPer sensor /* Micronet Communications products */ product MICRONET SP128AR 0x0003 SP128AR EtherFast Index: dev/usb/usbdevs.h =================================================================== RCS file: /cvs/src/sys/dev/usb/usbdevs.h,v retrieving revision 1.614 diff -u -p -r1.614 usbdevs.h --- dev/usb/usbdevs.h 20 Aug 2013 04:50:35 -0000 1.614 +++ dev/usb/usbdevs.h 4 Sep 2013 19:47:52 -0000 @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdevs.h,v 1.614 2013/08/20 04:50:35 jsg Exp $ */ +/* $OpenBSD$ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. @@ -2840,6 +2840,7 @@ /* Microdia / Sonix Techonology Co., Ltd. products */ #define USB_PRODUCT_MICRODIA_YUREX 0x1010 /* YUREX */ #define USB_PRODUCT_MICRODIA_CAM_1 0x62c0 /* CAM_1 */ +#define USB_PRODUCT_MICRODIA_TEMPER 0x7401 /* TEMPer sensor */ /* Micronet Communications products */ #define USB_PRODUCT_MICRONET_SP128AR 0x0003 /* SP128AR EtherFast */ Index: dev/usb/usbdevs_data.h =================================================================== RCS file: /cvs/src/sys/dev/usb/usbdevs_data.h,v retrieving revision 1.608 diff -u -p -r1.608 usbdevs_data.h --- dev/usb/usbdevs_data.h 20 Aug 2013 04:50:36 -0000 1.608 +++ dev/usb/usbdevs_data.h 4 Sep 2013 19:47:52 -0000 @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdevs_data.h,v 1.608 2013/08/20 04:50:36 jsg Exp $ */ +/* $OpenBSD$ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. @@ -6760,6 +6760,10 @@ const struct usb_known_product usb_known { USB_VENDOR_MICRODIA, USB_PRODUCT_MICRODIA_CAM_1, "CAM_1", + }, + { + USB_VENDOR_MICRODIA, USB_PRODUCT_MICRODIA_TEMPER, + "TEMPer sensor", }, { USB_VENDOR_MICRONET, USB_PRODUCT_MICRONET_SP128AR,