Four new sensors, from David Higgs.
authormpi <mpi@openbsd.org>
Wed, 17 Jun 2015 08:31:55 +0000 (08:31 +0000)
committermpi <mpi@openbsd.org>
Wed, 17 Jun 2015 08:31:55 +0000 (08:31 +0000)
sys/dev/usb/upd.c
sys/dev/usb/usbhid.h

index 6b3b266..1b0e065 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: upd.c,v 1.21 2015/05/14 13:50:34 mpi Exp $ */
+/*     $OpenBSD: upd.c,v 1.22 2015/06/17 08:31:55 mpi Exp $ */
 
 /*
  * Copyright (c) 2015 David Higgs <higgsd@gmail.com>
@@ -66,7 +66,13 @@ static struct upd_usage_entry upd_usage_batdep[] = {
        { HUP_BATTERY,  HUB_DISCHARGING,
            SENSOR_INDICATOR,    "Discharging" },
        { HUP_BATTERY,  HUB_ATRATE_TIMETOFULL,
-           SENSOR_TIMEDELTA,    "AtRateTimeToFull" }
+           SENSOR_TIMEDELTA,    "AtRateTimeToFull" },
+       { HUP_BATTERY,  HUB_ATRATE_TIMETOEMPTY,
+           SENSOR_TIMEDELTA,    "AtRateTimeToEmpty" },
+       { HUP_BATTERY,  HUB_RUNTIMETO_EMPTY,
+           SENSOR_TIMEDELTA,    "RunTimeToEmpty" },
+       { HUP_BATTERY,  HUB_NEED_REPLACEMENT,
+           SENSOR_INDICATOR,    "NeedReplacement" },
 };
 static struct upd_usage_entry upd_usage_roots[] = {
        { HUP_BATTERY,  HUB_BATTERY_PRESENT,
@@ -75,7 +81,9 @@ static struct upd_usage_entry upd_usage_roots[] = {
        { HUP_POWER,    HUP_SHUTDOWN_IMMINENT,
            SENSOR_INDICATOR,    "ShutdownImminent" },
        { HUP_BATTERY,  HUB_AC_PRESENT,
-           SENSOR_INDICATOR,    "ACPresent" }
+           SENSOR_INDICATOR,    "ACPresent" },
+       { HUP_POWER,    HUP_OVERLOAD,
+           SENSOR_INDICATOR,    "Overload" },
 };
 #define UPD_MAX_SENSORS        (nitems(upd_usage_batdep) + nitems(upd_usage_roots))
 
@@ -410,6 +418,12 @@ upd_sensor_update(struct upd_softc *sc, struct upd_sensor *sensor,
        case HUB_FULLCHARGE_CAPACITY:
                adjust = 1000; /* scale adjust */
                break;
+       case HUB_ATRATE_TIMETOFULL:
+       case HUB_ATRATE_TIMETOEMPTY:
+       case HUB_RUNTIMETO_EMPTY:
+               /* spec says minutes, not seconds */
+               adjust = 1000000000LL;
+               break;
        default:
                adjust = 1; /* no scale adjust */
                break;
index 74ca55a..5f5422f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: usbhid.h,v 1.17 2014/03/16 10:53:09 mpi Exp $ */
+/*     $OpenBSD: usbhid.h,v 1.18 2015/06/17 08:31:55 mpi Exp $ */
 /*     $NetBSD: usbhid.h,v 1.11 2001/12/28 00:20:24 augustss Exp $     */
 /*     $FreeBSD: src/sys/dev/usb/usbhid.h,v 1.7 1999/11/17 22:33:51 n_hibma Exp $ */
 
@@ -213,7 +213,7 @@ struct usb_hid_descriptor {
 #define HUB_CONDITIONING_FLAG  0x0048
 #define HUB_ATRATE_OK          0x0049
 #define HUB_SMB_ERROR_CODE     0x004a
-#define HUB_SMB_NEED_REPLACE   0x004b
+#define HUB_NEED_REPLACEMENT   0x004b
 #define HUB_ATRATE_TIMETOFULL  0x0060
 #define HUB_ATRATE_TIMETOEMPTY 0x0061
 #define HUB_AVERAGE_CURRENT    0x0062