| #ifndef __MMP_ALARM__ |
| #define __MMP_ALARM__ |
| |
| #ifndef TIMESPEC_TO_TIMEVAL |
| #define TIMESPEC_TO_TIMEVAL(tv, ts) {\ |
| (tv)->tv_sec = (ts)->tv_sec;\ |
| (tv)->tv_usec = (ts)->tv_nsec / 1000;\ |
| } |
| #endif |
| |
| #ifndef TIMEVAL_TO_TIMESPEC |
| #define TIMEVAL_TO_TIMESPEC(tv, ts) {\ |
| (ts)->tv_sec = (tv)->tv_sec;\ |
| (ts)->tv_nsec = (tv)->tv_usec * 1000;\ |
| } |
| #endif |
| |
| enum { |
| ALARM_TIME, |
| ALARM_NAME, |
| __ALARM_MAX |
| }; |
| |
| enum android_alarm_type { |
| /* return code bit numbers or set alarm arg */ |
| ANDROID_ALARM_RTC_WAKEUP, |
| ANDROID_ALARM_RTC, |
| ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, |
| ANDROID_ALARM_ELAPSED_REALTIME, |
| ANDROID_ALARM_SYSTEMTIME, |
| ANDROID_ALARM_POWER_UP, |
| |
| ANDROID_ALARM_TYPE_COUNT, |
| |
| /* return code bit numbers */ |
| /* ANDROID_ALARM_TIME_CHANGE = 16 */ |
| }; |
| |
| enum android_alarm_return_flags { |
| ANDROID_ALARM_RTC_WAKEUP_MASK = 1U << ANDROID_ALARM_RTC_WAKEUP, |
| ANDROID_ALARM_RTC_MASK = 1U << ANDROID_ALARM_RTC, |
| ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK = |
| 1U << ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, |
| ANDROID_ALARM_ELAPSED_REALTIME_MASK = |
| 1U << ANDROID_ALARM_ELAPSED_REALTIME, |
| ANDROID_ALARM_SYSTEMTIME_MASK = 1U << ANDROID_ALARM_SYSTEMTIME, |
| ANDROID_ALARM_TIME_CHANGE_MASK = 1U << 16 |
| }; |
| |
| /* Disable alarm */ |
| #define ANDROID_ALARM_CLEAR(type) _IO('a', 0 | ((type) << 4)) |
| |
| /* Ack last alarm and wait for next */ |
| #define ANDROID_ALARM_WAIT _IO('a', 1) |
| |
| #define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size) |
| /* Set alarm */ |
| #define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec) |
| #define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec) |
| #define ANDROID_ALARM_GET_TIME(type) ALARM_IOW(4, type, struct timespec) |
| #define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) |
| #define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) |
| #define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) |
| |
| |
| #define MAX_EVENT 16 |
| |
| #define TFLAG_NONE 0 |
| #define TFLAG_CANCELLED (1<<0) |
| #define TFLAG_DELETED (1<<1) |
| |
| |
| static const struct blobmsg_policy alarm_policy[] = { |
| [ALARM_TIME] = { .name = "time", .type = BLOBMSG_TYPE_INT32 }, |
| [ALARM_NAME] = { .name = "alarm_name", .type = BLOBMSG_TYPE_STRING }, |
| }; |
| |
| int alarm_set(struct ubus_context *ctx, struct ubus_object *obj, |
| struct ubus_request_data *req, const char *method, |
| struct blob_attr *msg); |
| int alarm_cancel(struct ubus_context *ctx, struct ubus_object *obj, |
| struct ubus_request_data *req, const char *method, |
| struct blob_attr *msg); |
| void alarm_init(struct ubus_context *ctx); |
| |
| #endif |