2 * Copyright (C) 2015 Intel Corporation.
5 #ifndef __ACTIVITY_EVENT_UTILS_H__
6 #define __ACTIVITY_EVENT_UTILS_H__
8 #include <hardware/activity_recognition.h>
12 #define MAX_ACTIVITIES 6
13 #define MAX_EVENTS_PER_ACTIVITY 2
15 typedef unsigned bool;
19 /* For each activity in activity_recognition.h we can monitor 2 events at most :
21 struct activity_event_info {
22 struct activity_event *event[MAX_EVENTS_PER_ACTIVITY];
24 int sensor_catalog_index;
29 bool monitored[MAX_EVENTS_PER_ACTIVITY];
32 struct control_event_data {
39 * Creates a control event identifier:
40 * [unused] EVENT ACTIVITY ENABLE
41 * 63 ... 24 23 ... 16 15 ... 8 7 ... 0
42 * @enable: Says if the <activity, event> pair needs to be enabled or disabled (0 or 1)
43 * @activity: What activity are we working on - index in the list returned by
44 * get_supported_activities_list()
45 * @event: What type of event to asociate with the given activity (one of
46 * the ACTIVITY_EVENT_* enum)
48 static inline uint64_t get_control_code(uint8_t enable, uint8_t activity, uint8_t event)
50 return ((uint64_t)enable << 56) |
51 ((uint64_t)activity << 48) |
52 ((uint64_t)event << 40);
56 * Parses the given control identifier and retrieves the control data.
57 * @control_code: the unified control data
58 * @control_data: extracted data from the control code
60 static inline void get_control_data(uint64_t control_code,
61 struct control_event_data *control_data)
63 control_data->enable = (uint8_t)(control_code >> 56);
64 control_data->activity = (uint8_t)(control_code >> 48 & 0xFF);
65 control_data->event = (uint8_t)(control_code >> 40 & 0xFF);