summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2020-06-29 12:15:17 +0000
committerDaniel Lezcano <daniel.lezcano@linaro.org>2020-06-29 12:15:17 +0000
commit09ce22363600679e017d67743835209a5d280c23 (patch)
tree6d3fee087c4d8240455d2f8ff861d407f5add598
parente725788049fe791c2e55e9efd31d8ff3a2927ac3 (diff)
Add more notification and align with the uapi changes
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--thermal-event.c56
-rw-r--r--thermal.h48
2 files changed, 76 insertions, 28 deletions
diff --git a/thermal-event.c b/thermal-event.c
index 98d645e..b7c208e 100644
--- a/thermal-event.c
+++ b/thermal-event.c
@@ -72,8 +72,8 @@ static int handle_event(struct nl_msg *n, void *arg)
genlmsg_parse(nlh, 0, attrs, THERMAL_GENL_ATTR_MAX, NULL);
- if (genlhdr->cmd == THERMAL_GENL_EVENT_TZ_TRIP_HIGH) {
- printf("THERMAL_GENL_EVENT_TZ_TRIP_HIGH\n");
+ if (genlhdr->cmd == THERMAL_GENL_EVENT_TZ_TRIP_UP) {
+ printf("THERMAL_GENL_EVENT_TZ_TRIP_UP\n");
if (attrs[THERMAL_GENL_ATTR_TZ_ID])
printf("Thermal zone %d\n",
@@ -84,8 +84,8 @@ static int handle_event(struct nl_msg *n, void *arg)
nla_get_u32(attrs[THERMAL_GENL_ATTR_TZ_TRIP_ID]));
}
- if (genlhdr->cmd == THERMAL_GENL_EVENT_TZ_TRIP_LOW) {
- printf("THERMAL_GENL_EVENT_TZ_TRIP_LOW\n");
+ if (genlhdr->cmd == THERMAL_GENL_EVENT_TZ_TRIP_DOWN) {
+ printf("THERMAL_GENL_EVENT_TZ_TRIP_DOWN\n");
if (attrs[THERMAL_GENL_ATTR_TZ_ID])
printf("Thermal zone %d\n",
@@ -96,6 +96,54 @@ static int handle_event(struct nl_msg *n, void *arg)
nla_get_u32(attrs[THERMAL_GENL_ATTR_TZ_TRIP_ID]));
}
+ if (genlhdr->cmd == THERMAL_GENL_EVENT_CDEV_UPDATE) {
+ printf("THERMAL_GENL_EVENT_CDEV_UPDATE\n");
+
+ if (attrs[THERMAL_GENL_ATTR_CDEV_ID])
+ printf("Cooling device id %d\n",
+ nla_get_u32(attrs[THERMAL_GENL_ATTR_CDEV_ID]));
+
+ if (attrs[THERMAL_GENL_ATTR_CDEV_CUR_STATE])
+ printf("Cooling device current state %d\n",
+ nla_get_u32(attrs[THERMAL_GENL_ATTR_CDEV_CUR_STATE]));
+ }
+
+ if (genlhdr->cmd == THERMAL_GENL_EVENT_TZ_GOV_CHANGE) {
+ printf("THERMAL_GENL_EVENT_TZ_GOV_CHANGE\n");
+
+ if (attrs[THERMAL_GENL_ATTR_TZ_ID])
+ printf("Thermal zone id %d\n",
+ nla_get_u32(attrs[THERMAL_GENL_ATTR_TZ_ID]));
+
+ if (attrs[THERMAL_GENL_ATTR_GOV_NAME])
+ printf("Governor name %s\n",
+ nla_get_string(attrs[THERMAL_GENL_ATTR_GOV_NAME]));
+ }
+
+ if (genlhdr->cmd == THERMAL_GENL_EVENT_TZ_TRIP_CHANGE) {
+ printf("THERMAL_GENL_EVENT_TZ_TRIP_CHANGE\n");
+
+ if (attrs[THERMAL_GENL_ATTR_TZ_ID])
+ printf("Thermal zone id %d\n",
+ nla_get_u32(attrs[THERMAL_GENL_ATTR_TZ_ID]));
+
+ if (attrs[THERMAL_GENL_ATTR_TZ_TRIP_ID])
+ printf("Trip id %d\n",
+ nla_get_u32(attrs[THERMAL_GENL_ATTR_TZ_TRIP_ID]));
+
+ if (attrs[THERMAL_GENL_ATTR_TZ_TRIP_TYPE])
+ printf("Trip type %d\n",
+ nla_get_u32(attrs[THERMAL_GENL_ATTR_TZ_TRIP_TYPE]));
+
+ if (attrs[THERMAL_GENL_ATTR_TZ_TRIP_TEMP])
+ printf("Trip temp %d\n",
+ nla_get_u32(attrs[THERMAL_GENL_ATTR_TZ_TRIP_TEMP]));
+
+ if (attrs[THERMAL_GENL_ATTR_TZ_TRIP_HYST])
+ printf("Trip hyst %d\n",
+ nla_get_u32(attrs[THERMAL_GENL_ATTR_TZ_TRIP_HYST]));
+ }
+
return 0;
}
diff --git a/thermal.h b/thermal.h
index 51db54d..49289f9 100644
--- a/thermal.h
+++ b/thermal.h
@@ -2,7 +2,7 @@
#ifndef _UAPI_LINUX_THERMAL_H
#define _UAPI_LINUX_THERMAL_H
-#define THERMAL_NAME_LENGTH20
+#define THERMAL_NAME_LENGTH 20
enum thermal_device_mode {
THERMAL_DEVICE_DISABLED = 0,
@@ -17,10 +17,10 @@ enum thermal_trip_type {
};
/* Adding event notification support elements */
-#define THERMAL_GENL_FAMILY_NAME "thermal"
-#define THERMAL_GENL_VERSION 0x01
-#define THERMAL_GENL_SAMPLING_GROUP_NAME "sampling"
-#define THERMAL_GENL_EVENT_GROUP_NAME "event"
+#define THERMAL_GENL_FAMILY_NAME "thermal"
+#define THERMAL_GENL_VERSION 0x01
+#define THERMAL_GENL_SAMPLING_GROUP_NAME "sampling"
+#define THERMAL_GENL_EVENT_GROUP_NAME "event"
/* Attributes of thermal_genl_family */
enum thermal_genl_attr {
@@ -59,19 +59,19 @@ enum thermal_genl_sampling {
/* Events of thermal_genl_family */
enum thermal_genl_event {
THERMAL_GENL_EVENT_UNSPEC,
- THERMAL_GENL_EVENT_TZ_CREATE,/* Thermal zone creation */
- THERMAL_GENL_EVENT_TZ_DELETE,/* Thermal zone deletion */
- THERMAL_GENL_EVENT_TZ_DISABLE,/* Thermal zone disabed */
- THERMAL_GENL_EVENT_TZ_ENABLE,/* Thermal zone enabled */
- THERMAL_GENL_EVENT_TZ_TRIP_HIGH,/* Trip point crossed the way up */
- THERMAL_GENL_EVENT_TZ_TRIP_LOW,/* Trip point crossed the way down */
- THERMAL_GENL_EVENT_TZ_TRIP_CHANGE,/* Trip point changed */
- THERMAL_GENL_EVENT_TZ_TRIP_ADD,/* Trip point added */
- THERMAL_GENL_EVENT_TZ_TRIP_DELETE,/* Trip point deleted */
- THERMAL_GENL_EVENT_TZ_CDEV_ADD,/* Cdev bound to the thermal zone */
- THERMAL_GENL_EVENT_TZ_CDEV_DELETE,/* Cdev unbound */
- THERMAL_GENL_EVENT_TZ_CDEV_UPDATE,/* Cdev state updated */
- THERMAL_GENL_EVENT_TZ_GOV_CHANGE,/* Governor policy changed */
+ THERMAL_GENL_EVENT_TZ_CREATE, /* Thermal zone creation */
+ THERMAL_GENL_EVENT_TZ_DELETE, /* Thermal zone deletion */
+ THERMAL_GENL_EVENT_TZ_DISABLE, /* Thermal zone disabed */
+ THERMAL_GENL_EVENT_TZ_ENABLE, /* Thermal zone enabled */
+ THERMAL_GENL_EVENT_TZ_TRIP_UP, /* Trip point crossed the way up */
+ THERMAL_GENL_EVENT_TZ_TRIP_DOWN, /* Trip point crossed the way down */
+ THERMAL_GENL_EVENT_TZ_TRIP_CHANGE, /* Trip point changed */
+ THERMAL_GENL_EVENT_TZ_TRIP_ADD, /* Trip point added */
+ THERMAL_GENL_EVENT_TZ_TRIP_DELETE, /* Trip point deleted */
+ THERMAL_GENL_EVENT_CDEV_ADD, /* Cdev bound to the thermal zone */
+ THERMAL_GENL_EVENT_CDEV_DELETE, /* Cdev unbound */
+ THERMAL_GENL_EVENT_CDEV_UPDATE, /* Cdev state updated */
+ THERMAL_GENL_EVENT_TZ_GOV_CHANGE, /* Governor policy changed */
__THERMAL_GENL_EVENT_MAX,
};
#define THERMAL_GENL_EVENT_MAX (__THERMAL_GENL_EVENT_MAX - 1)
@@ -79,12 +79,12 @@ enum thermal_genl_event {
/* Commands supported by the thermal_genl_family */
enum thermal_genl_cmd {
THERMAL_GENL_CMD_UNSPEC,
- THERMAL_GENL_CMD_TZ_GET,/* List thermal zones id */
- THERMAL_GENL_CMD_TZ_GET_TRIP,/* List of thermal trips */
- THERMAL_GENL_CMD_TZ_GET_TEMP,/* Get the thermal zone temperature */
- THERMAL_GENL_CMD_TZ_GET_GOV,/* Get the thermal zone governor */
- THERMAL_GENL_CMD_TZ_GET_MODE,/* Get the thermal zone mode */
- THERMAL_GENL_CMD_CDEV_GET,/* List of cdev id */
+ THERMAL_GENL_CMD_TZ_GET, /* List thermal zones id */
+ THERMAL_GENL_CMD_TZ_GET_TRIP, /* List of thermal trips */
+ THERMAL_GENL_CMD_TZ_GET_TEMP, /* Get the thermal zone temperature */
+ THERMAL_GENL_CMD_TZ_GET_GOV, /* Get the thermal zone governor */
+ THERMAL_GENL_CMD_TZ_GET_MODE, /* Get the thermal zone mode */
+ THERMAL_GENL_CMD_CDEV_GET, /* List of cdev id */
__THERMAL_GENL_CMD_MAX,
};
#define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1)