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#ifndef VCHIQ_ARM_H
36#define VCHIQ_ARM_H
37
38#include <linux/mutex.h>
39#include <linux/platform_device.h>
40#include <linux/semaphore.h>
41#include <linux/atomic.h>
42#include "vchiq_core.h"
43#include "vchiq_debugfs.h"
44
45
46enum vc_suspend_status {
47 VC_SUSPEND_FORCE_CANCELED = -3,
48 VC_SUSPEND_REJECTED = -2,
49 VC_SUSPEND_FAILED = -1,
50 VC_SUSPEND_IDLE = 0,
51 VC_SUSPEND_REQUESTED,
52 VC_SUSPEND_IN_PROGRESS,
53 VC_SUSPEND_SUSPENDED
54};
55
56enum vc_resume_status {
57 VC_RESUME_FAILED = -1,
58 VC_RESUME_IDLE = 0,
59 VC_RESUME_REQUESTED,
60 VC_RESUME_IN_PROGRESS,
61 VC_RESUME_RESUMED
62};
63
64
65enum USE_TYPE_E {
66 USE_TYPE_SERVICE,
67 USE_TYPE_SERVICE_NO_RESUME,
68 USE_TYPE_VCHIQ
69};
70
71
72
73typedef struct vchiq_arm_state_struct {
74
75 struct task_struct *ka_thread;
76 struct completion ka_evt;
77 atomic_t ka_use_count;
78 atomic_t ka_use_ack_count;
79 atomic_t ka_release_count;
80
81 struct completion vc_suspend_complete;
82 struct completion vc_resume_complete;
83
84 rwlock_t susp_res_lock;
85 enum vc_suspend_status vc_suspend_state;
86 enum vc_resume_status vc_resume_state;
87
88 unsigned int wake_address;
89
90 struct timer_list suspend_timer;
91 int suspend_timer_timeout;
92 int suspend_timer_running;
93
94
95
96
97
98 int videocore_use_count;
99
100
101
102
103
104 int peer_use_count;
105
106
107
108
109 struct completion resume_blocker;
110 int resume_blocked;
111 struct completion blocked_blocker;
112 int blocked_count;
113
114 int autosuspend_override;
115
116
117
118
119
120 int first_connect;
121
122 unsigned long long suspend_start_time;
123 unsigned long long sleep_start_time;
124 unsigned long long resume_start_time;
125 unsigned long long last_wake_time;
126
127} VCHIQ_ARM_STATE_T;
128
129extern int vchiq_arm_log_level;
130extern int vchiq_susp_log_level;
131
132int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state);
133
134extern VCHIQ_STATE_T *
135vchiq_get_state(void);
136
137extern VCHIQ_STATUS_T
138vchiq_arm_vcsuspend(VCHIQ_STATE_T *state);
139
140extern VCHIQ_STATUS_T
141vchiq_arm_force_suspend(VCHIQ_STATE_T *state);
142
143extern int
144vchiq_arm_allow_resume(VCHIQ_STATE_T *state);
145
146extern VCHIQ_STATUS_T
147vchiq_arm_vcresume(VCHIQ_STATE_T *state);
148
149extern VCHIQ_STATUS_T
150vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state);
151
152extern int
153vchiq_check_resume(VCHIQ_STATE_T *state);
154
155extern void
156vchiq_check_suspend(VCHIQ_STATE_T *state);
157VCHIQ_STATUS_T
158vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle);
159
160extern VCHIQ_STATUS_T
161vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle);
162
163extern VCHIQ_STATUS_T
164vchiq_check_service(VCHIQ_SERVICE_T *service);
165
166extern VCHIQ_STATUS_T
167vchiq_platform_suspend(VCHIQ_STATE_T *state);
168
169extern int
170vchiq_platform_videocore_wanted(VCHIQ_STATE_T *state);
171
172extern int
173vchiq_platform_use_suspend_timer(void);
174
175extern void
176vchiq_dump_platform_use_state(VCHIQ_STATE_T *state);
177
178extern void
179vchiq_dump_service_use_state(VCHIQ_STATE_T *state);
180
181extern VCHIQ_ARM_STATE_T*
182vchiq_platform_get_arm_state(VCHIQ_STATE_T *state);
183
184extern int
185vchiq_videocore_wanted(VCHIQ_STATE_T *state);
186
187extern VCHIQ_STATUS_T
188vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service,
189 enum USE_TYPE_E use_type);
190extern VCHIQ_STATUS_T
191vchiq_release_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service);
192
193extern VCHIQ_DEBUGFS_NODE_T *
194vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance);
195
196extern int
197vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance);
198
199extern int
200vchiq_instance_get_pid(VCHIQ_INSTANCE_T instance);
201
202extern int
203vchiq_instance_get_trace(VCHIQ_INSTANCE_T instance);
204
205extern void
206vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace);
207
208extern void
209set_suspend_state(VCHIQ_ARM_STATE_T *arm_state,
210 enum vc_suspend_status new_state);
211
212extern void
213set_resume_state(VCHIQ_ARM_STATE_T *arm_state,
214 enum vc_resume_status new_state);
215
216extern void
217start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state);
218
219
220#endif
221