Index: arch/alpha/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/alpha/conf/GENERIC,v retrieving revision 1.230 diff -u -p -r1.230 GENERIC --- arch/alpha/conf/GENERIC 15 Mar 2013 09:10:52 -0000 1.230 +++ arch/alpha/conf/GENERIC 11 May 2013 07:20:59 -0000 @@ -124,6 +124,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.341 diff -u -p -r1.341 GENERIC --- arch/amd64/conf/GENERIC 5 Apr 2013 02:56:17 -0000 1.341 +++ arch/amd64/conf/GENERIC 11 May 2013 07:21:00 -0000 @@ -249,6 +249,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.47 diff -u -p -r1.47 GENERIC --- arch/armish/conf/GENERIC 27 Sep 2012 14:01:35 -0000 1.47 +++ arch/armish/conf/GENERIC 11 May 2013 07:21:00 -0000 @@ -156,6 +156,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.149 diff -u -p -r1.149 GENERIC --- arch/hppa/conf/GENERIC 27 Sep 2012 14:01:35 -0000 1.149 +++ arch/hppa/conf/GENERIC 11 May 2013 07:21:01 -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.746 diff -u -p -r1.746 GENERIC --- arch/i386/conf/GENERIC 5 Apr 2013 02:56:15 -0000 1.746 +++ arch/i386/conf/GENERIC 11 May 2013 07:21:02 -0000 @@ -305,6 +305,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.37 diff -u -p -r1.37 GENERIC --- arch/landisk/conf/GENERIC 27 Sep 2012 14:01:35 -0000 1.37 +++ arch/landisk/conf/GENERIC 11 May 2013 07:21:02 -0000 @@ -156,6 +156,7 @@ zyd* at uhub? # Zydas ZD1211 #ueagle* at uhub? # Analog Devices Eagle ADSL 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.38 diff -u -p -r1.38 GENERIC --- arch/loongson/conf/GENERIC 14 Jan 2013 21:18:47 -0000 1.38 +++ arch/loongson/conf/GENERIC 11 May 2013 07:21:03 -0000 @@ -158,6 +158,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.217 diff -u -p -r1.217 GENERIC --- arch/macppc/conf/GENERIC 15 Mar 2013 09:10:52 -0000 1.217 +++ arch/macppc/conf/GENERIC 11 May 2013 07:21:03 -0000 @@ -290,6 +290,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.44 diff -u -p -r1.44 GENERIC-IP27 --- arch/sgi/conf/GENERIC-IP27 27 Sep 2012 14:01:35 -0000 1.44 +++ arch/sgi/conf/GENERIC-IP27 11 May 2013 07:21:03 -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.38 diff -u -p -r1.38 GENERIC-IP30 --- arch/sgi/conf/GENERIC-IP30 27 Sep 2012 14:01:35 -0000 1.38 +++ arch/sgi/conf/GENERIC-IP30 11 May 2013 07:21:03 -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.29 diff -u -p -r1.29 GENERIC-IP32 --- arch/sgi/conf/GENERIC-IP32 27 Sep 2012 14:01:35 -0000 1.29 +++ arch/sgi/conf/GENERIC-IP32 11 May 2013 07:21:04 -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.23 diff -u -p -r1.23 GENERIC --- arch/socppc/conf/GENERIC 27 Sep 2012 14:01:35 -0000 1.23 +++ arch/socppc/conf/GENERIC 11 May 2013 07:21:04 -0000 @@ -84,6 +84,7 @@ urio* at uhub? # Diamond Multimedia Rio uscanner* at uhub? disable # USB Scanners 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.269 diff -u -p -r1.269 GENERIC --- arch/sparc64/conf/GENERIC 17 Oct 2012 12:12:18 -0000 1.269 +++ arch/sparc64/conf/GENERIC 11 May 2013 07:21:05 -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.104 diff -u -p -r1.104 files.usb --- dev/usb/files.usb 29 Apr 2013 13:38:35 -0000 1.104 +++ dev/usb/files.usb 11 May 2013 07:21:06 -0000 @@ -128,6 +128,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 11 May 2013 07:21:06 -0000 @@ -0,0 +1,452 @@ +/* $OpenBSD: ugold.c,v 1.00 2013/03/27 03:53:10 sasano Exp $ */ + +/* + * Copyright (c) 2013 Takayoshi SASANO + * + * 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 +#include +#include +#include + +#ifdef USB_DEBUG +#define UGOLD_DEBUG +#endif + +#ifdef UGOLD_DEBUG +#define DPRINTF(x) do { printf x; } while (0) +#else +#define DPRINTF(x) +#endif + +/* sensors */ +#define UGOLD_TEMPER_INNER 0 +#define UGOLD_TEMPER_OUTER 1 +#define UGOLD_MAX_SENSORS 2 + +enum ugold_sensor_type { + UGOLD_SENSOR_UNKNOWN, + UGOLD_SENSOR_DS75, + UGOLD_SENSOR_MAXTYPES, +}; + +static const char * const ugold_sensor_type_s[UGOLD_SENSOR_MAXTYPES] = { + "unknown", + "ds75/12bit", +}; + +static uint8_t cmd_led_off[1] = + { 0x00 }; +static uint8_t cmd_get_offset[8] = + { 0x01, 0x82, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00 }; +static uint8_t cmd_init[8] = + { 0x01, 0x86, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00 }; +static uint8_t cmd_get_data[8] = + { 0x01, 0x80, 0x33, 0x01, 0x00, 0x00, 0x00, 0x00 }; + +struct ugold_sensor { + struct ksensor sensor; + int cal_offset; /* 10mC or m%RH */ + int attached; + enum ugold_sensor_type dev_type; +}; + +struct ugold_softc { + struct uhidev sc_hdev; + struct usbd_device *sc_udev; + + int sc_initialized; + int sc_num_sensors; + + uint8_t *sc_command; + int sc_packets; + + /* uhidev parameters */ + size_t sc_flen; /* feature report length */ + size_t sc_ilen; /* input report length */ + size_t sc_olen; /* output report length */ + + /* sensor framework */ + struct ugold_sensor 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 }, +}; +#define ugold_lookup(v, p) usb_lookup(ugold_devs, v, p) + +int ugold_match(struct device *, void *, void *); +void ugold_attach(struct device *, struct device *, void *); +int ugold_detach(struct device *, int); +int ugold_activate(struct device *, int); + +int ugold_issue_cmd(struct ugold_softc *, uint8_t *, int, int, int); +int ugold_read_data(struct ugold_softc *); +int ugold_init_device(struct ugold_softc *); +void ugold_setup_sensors(struct ugold_softc *); +int ugold_setup_device(struct ugold_softc *); + +void ugold_intr(struct uhidev *, void *, u_int); +void ugold_refresh(void *); +void ugold_refresh_temper(struct ugold_softc *); + +int ugold_ds75_temp(uint8_t, uint8_t); +void ugold_print_sensorinfo(struct ugold_softc *, int); + +struct cfdriver ugold_cd = { + NULL, "ugold", DV_DULL +}; + +const struct cfattach ugold_ca = { + sizeof(struct ugold_softc), + ugold_match, + ugold_attach, + ugold_detach, + ugold_activate, +}; + +int +ugold_match(struct device *parent, void *match, void *aux) +{ + struct usb_attach_arg *uaa = aux; + struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa; + + if (ugold_lookup(uha->uaa->vendor, uha->uaa->product) == NULL) + 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 usb_attach_arg *uaa = aux; + struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa; + struct usbd_device *dev = uha->parent->sc_udev; + int i, size, repid, err; + void *desc; + + sc->sc_udev = dev; + sc->sc_hdev.sc_intr = ugold_intr; + sc->sc_hdev.sc_parent = uha->parent; + sc->sc_hdev.sc_report_id = uha->reportid; + sc->sc_initialized = 0; + sc->sc_num_sensors = 0; + + uhidev_get_report_desc(uha->parent, &desc, &size); + repid = uha->reportid; + sc->sc_ilen = hid_report_size(desc, size, hid_input, repid); + sc->sc_olen = hid_report_size(desc, size, hid_output, repid); + sc->sc_flen = hid_report_size(desc, size, hid_feature, repid); + + printf("\n"); + + if (sc->sc_flen < 8) { + /* Keyboard interface is not sensor, but need to LED off */ + ugold_issue_cmd(sc, cmd_led_off, sizeof(cmd_led_off), 0, 0); + return; + } + + /* sensor data comes from interrupt pipe */ + err = uhidev_open(&sc->sc_hdev); + if (err) { + printf("ugold: uhidev_open %d\n", err); + return; + } + + /* + * interrupt pipe is opened but data comes after ugold_attach() + * is finished. simply attach sensors here and the device will be + * initialized at ugold_refresh(). + * + * at this point, the number of sensors is unknown. setup maximum + * sensors here and detach unused sensor later. + */ + + /* setup sensor */ + strlcpy(sc->sc_sensordev.xname, sc->sc_hdev.sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + ugold_setup_sensors(sc); + + /* attach sensors */ + for (i = 0; i < UGOLD_MAX_SENSORS; i++) { + sc->sc_sensor[i].sensor.flags |= SENSOR_FINVALID; + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i].sensor); + sc->sc_sensor[i].attached = 1; + sc->sc_num_sensors++; + } + + /* 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; + } + sensordev_install(&sc->sc_sensordev); + + DPRINTF(("ugold_attach: complete\n")); +} + +int +ugold_detach(struct device *self, int flags) +{ + struct ugold_softc *sc = (struct ugold_softc *)self; + int i, rv = 0; + + if (sc->sc_num_sensors > 0) { + sensordev_deinstall(&sc->sc_sensordev); + for (i = 0; i < UGOLD_MAX_SENSORS; i++) { + if (sc->sc_sensor[i].attached) + sensor_detach(&sc->sc_sensordev, + &sc->sc_sensor[i].sensor); + } + if (sc->sc_sensortask != NULL) + sensor_task_unregister(sc->sc_sensortask); + } + + return (rv); +} + +int +ugold_activate(struct device *self, int act) +{ + return (0); +} + +void +ugold_intr(struct uhidev *addr, void *ibuf, u_int len) +{ + struct ugold_softc *sc = (struct ugold_softc *)addr; + int temp; + uint8_t *buf = ibuf; + + /* receive offset data */ + if (sc->sc_command == cmd_get_offset) { + sc->sc_num_sensors = buf[1]; + if (sc->sc_num_sensors > UGOLD_MAX_SENSORS) + sc->sc_num_sensors = UGOLD_MAX_SENSORS; + sc->sc_sensor[UGOLD_TEMPER_INNER].cal_offset = + ((int8_t)buf[2] * 25) / 4; + sc->sc_sensor[UGOLD_TEMPER_OUTER].cal_offset = + ((int8_t)buf[3] * 25) / 4; + } + + /* receive sensor data */ + if (sc->sc_command == cmd_get_data) { + switch (sc->sc_num_sensors) { + case 2: + temp = ugold_ds75_temp(buf[4], buf[5]); + temp += sc->sc_sensor[UGOLD_TEMPER_OUTER].cal_offset; + sc->sc_sensor[UGOLD_TEMPER_OUTER].sensor.value = + (temp * 10000) + 273150000; + sc->sc_sensor[UGOLD_TEMPER_OUTER].sensor.flags &= + ~SENSOR_FINVALID; + /* FALLTHROUGH */ + case 1: + temp = ugold_ds75_temp(buf[2], buf[3]); + temp += sc->sc_sensor[UGOLD_TEMPER_INNER].cal_offset; + sc->sc_sensor[UGOLD_TEMPER_INNER].sensor.value = + (temp * 10000) + 273150000; + sc->sc_sensor[UGOLD_TEMPER_INNER].sensor.flags &= + ~SENSOR_FINVALID; + break; + } + } + + /* wakeup waiting task */ + if (sc->sc_command != NULL) { + if (sc->sc_packets > 0) { + sc->sc_packets--; + if (sc->sc_packets == 0) { + wakeup(&sc->sc_sensortask); + sc->sc_command = NULL; + } + } + } + + return; +} + +int +ugold_issue_cmd(struct ugold_softc *sc, uint8_t *cmd, int cmdlen, int packets, int timeout) +{ + if (timeout > 0) { + sc->sc_packets = packets; + sc->sc_command = (packets > 0) ? cmd : NULL; + } + + if (uhidev_set_report(&sc->sc_hdev, 2, cmd, cmdlen)) + return EIO; + + /* wait if required */ + if (timeout > 0) { + tsleep(&sc->sc_sensortask, 0, "ugold", + (timeout * hz + 999) / 1000 + 1); + if (sc->sc_packets) + return EIO; + } + + return 0; +} + +int +ugold_read_data(struct ugold_softc *sc) +{ + if (ugold_issue_cmd(sc, cmd_get_data, sizeof(cmd_get_data), 1, 200)) + return EIO; + + return 0; +} + +int +ugold_init_device(struct ugold_softc *sc) +{ + /* init process */ + if (ugold_issue_cmd(sc, cmd_get_offset, + sizeof(cmd_get_offset), 1, 200)) + return EIO; + + if (ugold_issue_cmd(sc, cmd_init, sizeof(cmd_init), 2, 200)) + return EIO; + + return 0; +} + +void +ugold_setup_sensors(struct ugold_softc *sc) +{ + int i; + + for (i = 0; i < UGOLD_MAX_SENSORS; i++) + sc->sc_sensor[i].dev_type = UGOLD_SENSOR_UNKNOWN; + + sc->sc_sensor[UGOLD_TEMPER_OUTER].dev_type = + UGOLD_SENSOR_DS75; + sc->sc_sensor[UGOLD_TEMPER_OUTER].sensor.type = + SENSOR_TEMP; + strlcpy(sc->sc_sensor[UGOLD_TEMPER_OUTER].sensor.desc, + "outer", + sizeof(sc->sc_sensor[UGOLD_TEMPER_OUTER].sensor.desc)); + sc->sc_sensor[UGOLD_TEMPER_INNER].dev_type = + UGOLD_SENSOR_DS75; + sc->sc_sensor[UGOLD_TEMPER_INNER].sensor.type = + SENSOR_TEMP; + strlcpy(sc->sc_sensor[UGOLD_TEMPER_INNER].sensor.desc, + "inner", + sizeof(sc->sc_sensor[UGOLD_TEMPER_INNER].sensor.desc)); +} + +int +ugold_setup_device(struct ugold_softc *sc) +{ + int i; + + if (ugold_init_device(sc)) { + DPRINTF(("ugold: device initialize failed\n")); + return EIO; + } + + /* detach unused sensors */ + for (i = 0; i < UGOLD_MAX_SENSORS; i++) { + if (sc->sc_sensor[i].attached && + i >= sc->sc_num_sensors) { + sensor_detach(&sc->sc_sensordev, + &sc->sc_sensor[i].sensor); + sc->sc_sensor[i].attached = 0; + } + } + + for (i = 0; i < sc->sc_num_sensors; i++) { + if (sc->sc_sensor[i].attached) + ugold_print_sensorinfo(sc, i); + } + + return 0; +} + +void +ugold_refresh(void *arg) +{ + struct ugold_softc *sc = arg; + + /* if device is not initialized, initialize first */ + if (!sc->sc_initialized) { + if (ugold_setup_device(sc)) + return; + sc->sc_initialized = 1; + } + + ugold_refresh_temper(sc); +} + +void +ugold_refresh_temper(struct ugold_softc *sc) +{ + /* issue get data command */ + if (ugold_issue_cmd(sc, cmd_get_data, sizeof(cmd_get_data), 1, 200)) { + DPRINTF(("ugold: data read failed\n")); + sc->sc_sensor[UGOLD_TEMPER_OUTER].sensor.flags + |= SENSOR_FINVALID; + sc->sc_sensor[UGOLD_TEMPER_INNER].sensor.flags + |= SENSOR_FINVALID; + } + + return; +} + +/* return C-degree * 100 value */ +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); +} + +void +ugold_print_sensorinfo(struct ugold_softc *sc, int num) +{ + struct ugold_sensor *s; + s = &sc->sc_sensor[num]; + + printf("%s: ", sc->sc_hdev.sc_dev.dv_xname); + switch (s->sensor.type) { + case SENSOR_TEMP: + printf("type %s (temperature)", + ugold_sensor_type_s[s->dev_type]); + if (s->cal_offset) + printf(", calibration offset %d.%d degC", + s->cal_offset / 100, abs(s->cal_offset % 100)); + break; + default: + printf("unknown"); + } + printf("\n"); +} Index: dev/usb/usbdevs =================================================================== RCS file: /cvs/src/sys/dev/usb/usbdevs,v retrieving revision 1.598 diff -u -p -r1.598 usbdevs --- dev/usb/usbdevs 7 Mar 2013 23:39:14 -0000 1.598 +++ dev/usb/usbdevs 11 May 2013 07:21:08 -0000 @@ -2815,7 +2815,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.608 diff -u -p -r1.608 usbdevs.h --- dev/usb/usbdevs.h 7 Mar 2013 23:39:56 -0000 1.608 +++ dev/usb/usbdevs.h 11 May 2013 07:21:10 -0000 @@ -2823,6 +2823,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.602 diff -u -p -r1.602 usbdevs_data.h --- dev/usb/usbdevs_data.h 7 Mar 2013 23:39:56 -0000 1.602 +++ dev/usb/usbdevs_data.h 11 May 2013 07:21:13 -0000 @@ -6714,6 +6714,10 @@ const struct usb_known_product usb_known "CAM_1", }, { + USB_VENDOR_MICRODIA, USB_PRODUCT_MICRODIA_TEMPER, + "TEMPer sensor", + }, + { USB_VENDOR_MICRONET, USB_PRODUCT_MICRONET_SP128AR, "SP128AR EtherFast", },