~awe/ofono/midori-switch-4g-update

« back to all changes in this revision

Viewing changes to include/wakelock.h

  • Committer: CI Train Bot
  • Author(s): Alfonso Sanchez-Beato
  • Date: 2016-03-14 09:11:23 UTC
  • mfrom: (6911.1.2 ubuntu)
  • Revision ID: ci-train-bot@canonical.com-20160314091123-zolwcf6cjokyqe5f
[ Tony Espy ]
* unit: new rilmodem tests for sms and call barring
* plugins: address upower plugin upstream comments
* unit: fix test-grilreply set_facility_lock test
* style fixes for wakelock support

[ Ratchanan Srirattanamet ]
* qcommsimmodem: fix setting 3G pref when one of the slots is empty

[ Alfonso Sanchez-Beato ]
* ril: set properly gril vendor
* support for system settings
* unit: make unit tests parallelizable

[ Vicamo Yang ]
* ril, gril: support for pro 5
* gril, rilmodem: set RIL version from CONNECTED event
* unit: fix warning

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 *  oFono - Open Source Telephony
 
4
 *
 
5
 *  Copyright (C) 2015 Jolla Ltd. All rights reserved.
 
6
 *  Contact: Hannu Mallat <hannu.mallat@jollamobile.com>
 
7
 *
 
8
 *  This program is free software; you can redistribute it and/or modify
 
9
 *  it under the terms of the GNU General Public License as published by
 
10
 *  the Free Software Foundation; either version 2 of the License, or
 
11
 *  (at your option) any later version.
 
12
 *
 
13
 *  This program is distributed in the hope that it will be useful,
 
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 *  GNU General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU General Public License
 
19
 *  along with this program; if not, write to the Free Software
 
20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
21
 *
 
22
 */
 
23
 
 
24
#ifndef __OFONO_WAKELOCK_H_
 
25
#define __OFONO_WAKELOCK_H_
 
26
 
 
27
#include <ofono/types.h>
 
28
 
 
29
/* Wakelock interface
 
30
 *
 
31
 * Wakelocks ensure system does not suspend/enter power save mode
 
32
 * before an ongoing operation completes. This header declares a
 
33
 * wakelock API that can be implemented by a OS-specific plugin.
 
34
 */
 
35
 
 
36
struct wakelock; /* Opaque */
 
37
 
 
38
struct wakelock_table {
 
39
        int (*create)(const char *name, struct wakelock **);
 
40
        int (*free)(struct wakelock *);
 
41
        int (*acquire)(struct wakelock *);
 
42
        int (*release)(struct wakelock *);
 
43
        ofono_bool_t (*is_locked)(struct wakelock *);
 
44
};
 
45
 
 
46
 
 
47
/*** Functions for wakelock users ***/
 
48
 
 
49
/*
 
50
 * This will create a wakelock which will be held for a short duration
 
51
 * and then automatically freed. If this is called multiple times the
 
52
 * timeout will be restarted on every call.
 
53
 */
 
54
void wakelock_system_lock(void);
 
55
 
 
56
/*
 
57
 * Create a wakelock. Multiple wakelocks can be created; if any one of
 
58
 * them is activated, system will be prevented from going to suspend.
 
59
 * This makes it possible to overlap locks to hand over from subsystem
 
60
 * to subsystem, each with their own wakelock-guarded sections,
 
61
 * without falling to suspend in between.
 
62
 */
 
63
int wakelock_create(const char *name, struct wakelock **wakelock);
 
64
 
 
65
/*
 
66
 * Free a wakelock, releasing all acquisitions at the same time
 
67
 * and deallocating the lock.
 
68
 */
 
69
int wakelock_free(struct wakelock *wakelock);
 
70
 
 
71
/*
 
72
 * Acquire a wakelock. Multiple acquisitions are possible, meaning
 
73
 * that the wakelock needs to be released the same number of times
 
74
 * until it is actually deactivated.
 
75
 */
 
76
int wakelock_acquire(struct wakelock *wakelock);
 
77
 
 
78
/*
 
79
 * Release a wakelock, deactivating it if all acquisitions are
 
80
 * released, letting system suspend.
 
81
 */
 
82
int wakelock_release(struct wakelock *wakelock);
 
83
 
 
84
/*
 
85
 * Check if a wakelock is currently locked or not.
 
86
 */
 
87
ofono_bool_t wakelock_is_locked(struct wakelock *wakelock);
 
88
 
 
89
/*** Functions for wakelock implementors ***/
 
90
 
 
91
/*
 
92
 * Register a wakelock implementation. Only one implementation may be
 
93
 * registered at a time. In the absence of an implementation, all
 
94
 * wakelock functions are no-ops.
 
95
 */
 
96
int wakelock_plugin_register(const char *name, struct wakelock_table *fns);
 
97
 
 
98
int wakelock_plugin_unregister(void);
 
99
 
 
100
#endif