| // Copyright 2021 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| // Definitions for the event API exposed by the cros_healthd daemon. This API is |
| // normally consumed by the browser. |
| |
| // NOTE: This mojom should be kept in sync with the copy in Chromium OS's repo |
| // in src/platform2/diagnostics/mojo/wilco_ec.mojom. |
| |
| module chromeos.cros_healthd.mojom; |
| |
| // A packet of data sent by the EC when it notices certain events have |
| // occurred, such as the battery, AC adapter, or USB-C state changing. |
| // The format of this packet is a variable length sequence of 16-bit words. |
| // Word 0 is the |size| word, representing the number of following |
| // words in the struct. Word 1 is the |type| word. The following |size|-1 |
| // words are the |payload|. Depending on the value of |type|, the |payload| |
| // is interpreted in different ways. There are other possible values of |type| |
| // and other interpretations of |payload| than those listed here. There will |
| // be, at most, 6 words in the |payload|. See section 2.3 "ACPI EC Event |
| // notification" of the Wilco EC specification at go/wilco-ec-spec for more |
| // information. |
| struct EcEvent { |
| // Derived value representing the reason/cause of the EC event. |
| // |
| // NOTE: This is a computed value and not sent by the EC. |
| enum Reason { |
| // |kSystemNotify| EC event types: |
| // |
| // An AC adapter event indicating a non-Wilco charger. |
| kNonWilcoCharger, |
| // An AC adapter event indicating a low power charger. |
| kLowPowerCharger, |
| // A battery event indicating an incompatible battery. |
| kBatteryAuth, |
| // A USB-C event indicating an HDMI conflict. |
| kDockDisplay, |
| // A USB-C event indicating a lack of thunderbolt support. |
| kDockThunderbolt, |
| // A USB-C event indicating an incompatible dock. |
| kIncompatibleDock, |
| // A USB-C event indicating the attached dock has overheated. |
| kDockError, |
| |
| // |kSystemNotify| EC event type with no appropriate subtype. |
| kSysNotification, |
| // Non |kSystemNotify| EC event type. |
| kNonSysNotification, |
| }; |
| |
| // The |type| member will be one of these. |
| enum Type { |
| // Interpret |payload| as a system notify payload. |
| kSystemNotify = 0x0012, |
| }; |
| |
| Type type; |
| array<uint16> payload; |
| Reason reason; |
| }; |
| |
| struct GetEcTelemetryResponse { |
| enum Status { |
| // The EC telemetry command was successfully completed. |
| kStatusOk, |
| // The EC telemetry command was rejected due to the empty request payload. |
| kStatusErrorInputPayloadEmpty, |
| // The EC telemetry command was rejected due to the request payload being |
| // too large. |
| kStatusErrorInputPayloadMaxSizeExceeded, |
| // The EC telemetry command was failed due to EC driver error. |
| kStatusErrorAccessingDriver, |
| }; |
| Status status; |
| string payload; |
| }; |
| |
| // Implemented by clients who desire EC notifications. |
| interface WilcoEcObserver { |
| // Fired when an EC event occurs. |
| OnEcEvent(EcEvent ec_event); |
| }; |