blob: 3b0651228aa688ca1a9d3a8cd43149ca0b28ed01 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#ifndef PWRTRAY_API_H_
#define PWRTRAY_API_H_
#include <stdint.h>
#include <netinet/in.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PT_SOCK_DIR "/var/run/pwrtray"
#define PT_SOCKET PT_SOCK_DIR "/socket"
//#define PT_PACKED __attribute__((__packed__))
#define PT_PACKED
enum {
PTREQ_PING = 0x0,
PTREQ_WANT_NOTIFY,
PTREQ_XEVREP,
/* Backlight controls */
PTREQ_BL_GETSTATE = 0x100,
PTREQ_BL_SETBRIGHTNESS,
PTREQ_BL_AUTODIM,
/* Battery controls */
PTREQ_BAT_GETSTATE = 0x200,
/* Notifications */
PTNOTI_SRVDOWN = 0xF00,
PTNOTI_BL_CHANGED,
PTNOTI_BAT_CHANGED,
};
/* (struct pt_message *)->bat_stat.flags */
#define PT_BAT_FLG_ONAC (1 << 0) /* On AC */
#define PT_BAT_FLG_ACUNKNOWN (1 << 1) /* AC status unknown */
#define PT_BAT_FLG_CHARGING (1 << 2) /* Currently charging */
#define PT_BAT_FLG_CHUNKNOWN (1 << 3) /* Charging status unknown */
/* (struct pt_message *)->bl_stat.flags */
#define PT_BL_FLG_AUTODIM (1 << 0) /* Auto dimming enabled */
#define PT_BL_FLG_AUTODIM_AC (1 << 1) /* Auto dimming enabled on AC */
/* (struct pt_message *)->bl_autodim.flags */
#define PT_AUTODIM_FLG_ENABLE (1 << 0) /* Auto dimming enable */
#define PT_AUTODIM_FLG_ENABLE_AC (1 << 1) /* Auto dimming enable on AC */
/* (struct pt_message *)->flags */
#define PT_FLG_REPLY (1 << 0) /* This is a reply to a previous message */
#define PT_FLG_OK (1 << 1) /* There was no error */
#define PT_FLG_ENABLE (1 << 2) /* Generic boolean flag */
struct pt_message {
uint16_t id;
uint16_t flags;
union {
struct { /* Backlight / LCD state */
uint32_t flags;
int32_t min_brightness;
int32_t max_brightness;
int32_t brightness_step;
int32_t brightness;
} PT_PACKED bl_stat;
struct { /* Set backlight */
int32_t brightness;
} PT_PACKED bl_set;
struct { /* Autodim controls */
uint32_t flags;
int32_t max_percent;
} PT_PACKED bl_autodim;
struct { /* Battery state */
uint32_t flags;
int32_t min_level;
int32_t max_level;
int32_t level;
} PT_PACKED bat_stat;
struct { /* Error code (only for PT_FLG_REPLY) */
int32_t code;
} PT_PACKED error;
} PT_PACKED;
} PT_PACKED;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PWRTRAY_API_H_ */
|