summaryrefslogtreecommitdiff
path: root/chip_interface/lid.h
blob: cffa35c4f4ac595609641bbe17ae00bf5bc23451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* lid.h - handle lid open/close
 *
 * (Chromium license) */

#ifndef __CHIP_INTERFACE_LID_H
#define __CHIP_INTERFACE_LID_H

/* Initialize the GPIO pin */
EcError CrLidSwitchInit(void);

/* Calls GPIOPinRead() to read the GPIO state. */
/* TODO: has the state been debounced? */
EcError CrLidSwitchState(void);

/* Register a calback function. It is called while lid state is changed.
 */
EcError CrLidSwitchRegister(void (*callback)(void));

/* Below is the example code to register this function. */
#if 0
/* This callback function is implemented in Chrome OS features layer. */
void LidSwitchChanged(void) {
  int lid_open = CrLidSwitchState();
  if (lid_open) {
    if (system is in S3) {
      // resume system
    }
  } else {
    if (system is in S0) {
      // suspend system
    }
  }
}
  ... somewhere in init code ...
  CrLidSwitchRegister(LidSwitchChanged);
#endif

#endif  /* __CHIP_INTERFACE_LID_H */