1 /*---------------------------------------------------------------------------*
2 Project: Horizon
3 File: cec_Control.h
4
5 Copyright (C)2009 Nintendo Co., Ltd. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Rev: 38552 $
14 *---------------------------------------------------------------------------*/
15
16 #ifndef NN_CEC_CTR_CEC_CONTROL_H_
17 #define NN_CEC_CTR_CEC_CONTROL_H_
18 #include <nn/fnd.h>
19 #include <nn/cec/CTR/cec_Api.h>
20
21 namespace nn {
22 namespace cec {
23 namespace CTR {
24
25 struct CecAllocFunc
26 {
27 void* (*allocFunc)(size_t); //
28 void (*freeFunc)(void*); //
29 };
30
31 //------------------------------------------------------------
32 // For notification
33
34 /* Please see man pages for details
35
36
37
38
39 */
40 struct CecNotificationParam
41 {
42 nn::fnd::DateTimeParameters recvDate; //
43 u32 cecTitleId; //
44 u8 messageId[CEC_SIZEOF_MESSAGEID]; //
45 };
46
47 /* Please see man pages for details
48
49
50
51
52 */
53 struct CecNotificationData
54 {
55 size_t num; //
56 s32 count; //
57 CecNotificationParam param[MESSAGE_BOX_NUM_MAX]; //
58 };
59
60
61 /* Please see man pages for details
62
63
64
65
66
67
68
69
70
71
72
73
74 */
75
76 class CecControl {
77
78 public:
79
80 enum ChangeDaemonState{
81 DAEMON_CHANGE_STATE_READY ,
82 DAEMON_CHANGE_STATE_STARTSCAN ,
83 DAEMON_CHANGE_STATE_STOP,
84 DAEMON_CHANGE_STATE_STOP_DAEMON,
85 DAEMON_CHANGE_STATE_START_DAEMON,
86 DAEMON_CHANGE_STATE_RESET_FILTER,
87
88 DAEMON_CHANGE_STATE_NDM_RESUME,
89 DAEMON_CHANGE_STATE_NDM_SUSPEND
90
91 };
92
93 /* Please see man pages for details
94
95 */
96 enum DaemonState
97 {
98 DAEMON_STATE_STOP, //
99 DAEMON_STATE_IDLE, //
100 DAEMON_STATE_BUSY, //
101 DAEMON_STATE_SCAN, //
102 DAEMON_STATE_READY, //
103 DAEMON_STATE_COMMUNICATING //
104 };
105
106
107 explicit CecControl(size_t bufSize);
108 CecControl();
109 ~CecControl();
110
111 /* Please see man pages for details
112
113
114
115 */
116 static nn::Result Initialize();
117 static nn::Result Initialize(nn::fnd::IAllocator& cecAllocFunc);
118
119 /* Please see man pages for details
120
121
122
123 */
124 static nn::Result Finalize();
125
126 static bool IsInitialized();
127
128 /* Please see man pages for details
129
130
131
132
133 */
134 static nn::Result ReadyDaemon();
135
136 /* Please see man pages for details
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152 */
153 static nn::Result StartScanning(bool reset = false);
154
155 /* Please see man pages for details
156
157
158
159
160
161
162
163 */
164 static nn::Result Suspend();
165
166 /* Please see man pages for details
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186 */
187 static nn::Result StopScanning(bool b_Immediate = false, bool b_Async = false);
188
189 /* Please see man pages for details
190
191
192
193
194
195
196 */
197 static nn::Result StopDaemon();
198
199 /* Please see man pages for details
200
201
202
203
204 */
205 static nn::Result StartDaemon();
206
207 /* Please see man pages for details
208
209
210
211
212
213
214 */
215 static nn::Result GetCecInfoBuffer( u32 cecTitleId, u8 pCecInfoBuffer[], size_t size );
GetCecInfoBuffer(u8 pCecInfoBuffer[],size_t size)216 static nn::Result GetCecInfoBuffer( u8 pCecInfoBuffer[], size_t size )
217 {
218 return GetCecInfoBuffer( 0, pCecInfoBuffer, size );
219 };
220
221 /* Please see man pages for details
222
223
224
225
226 */
227 static nn::Result GetCecState( DaemonState* state );
228 static nn::Result GetCecState( u32* state );
229
230 static bool IsDaemonBusy(void);
231
232 /* Please see man pages for details
233
234
235
236
237 */
238 static nn::Result GetCecRecvEventHandle( nn::os::Event* event );
239
240 static nn::Result GetChangeStateEventHandle( nn::os::Event& event );
241
242 static nn::cec::CTR::TitleId MakeCecTitleId(bit32 id, bit8 variation = 0x0);
243
244 /* */
245 static nn::Result FormatSaveData();
246
247 /* Please see man pages for details
248
249
250
251
252
253
254
255
256 */
257 static nn::Result EnterExclusiveState();
258
259 /* Please see man pages for details
260
261
262 */
263 static nn::Result LeaveExclusiveState();
264
265 private:
266 static bool s_Initialized;
267 static bool s_NdmSuspended;
268 static bool s_EnterExclusiveState;
269 static nn::os::CriticalSection m_Cs;
270
271 };
272
273
274
275
276 //
277 //
278
279
280 /* Please see man pages for details
281
282
283
284
285
286
287
288
289 */
290 nn::Result Initialize(nn::fnd::IAllocator& cecAllocFunc);
291
292 /* Please see man pages for details
293
294
295
296
297
298 */
299 nn::Result Initialize();
300
Initialize()301 inline nn::Result Initialize()
302 {
303 return CecControl::Initialize();
304 }
305
306 nn::Result Initialize(nn::cec::CTR::CecAllocFunc& cecAllocFunc);
307
Initialize(nn::fnd::IAllocator & cecAllocFunc)308 inline nn::Result Initialize(nn::fnd::IAllocator& cecAllocFunc)
309 {
310 return CecControl::Initialize(cecAllocFunc);
311 }
312
313 /* Please see man pages for details
314
315
316
317
318 */
319 nn::Result Finalize();
320
Finalize()321 inline nn::Result Finalize()
322 {
323 return CecControl::Finalize();
324 }
325
326 //
327
328 //
329 //
330
331 /* Please see man pages for details
332
333
334
335
336
337
338
339
340
341
342 */
343 nn::Result GetCecRecvEventHandle( nn::os::Event* event );
GetCecRecvEventHandle(nn::os::Event * event)344 inline nn::Result GetCecRecvEventHandle( nn::os::Event* event )
345 {
346 return CecControl::GetCecRecvEventHandle( event );
347 }
348
349
350 /* Please see man pages for details
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370 */
371 nn::Result GetCecInfoBuffer( u32 cecTitleId, u8 pCecInfoBuffer[], size_t size );
372 nn::Result GetCecInfoBuffer( u8 pCecInfoBuffer[], size_t size );
373
GetCecInfoBuffer(u32 cecTitleId,u8 pCecInfoBuffer[],size_t size)374 inline nn::Result GetCecInfoBuffer( u32 cecTitleId, u8 pCecInfoBuffer[], size_t size )
375 {
376 return CecControl::GetCecInfoBuffer(cecTitleId, pCecInfoBuffer, size );
377 }
378
GetCecInfoBuffer(u8 pCecInfoBuffer[],size_t size)379 inline nn::Result GetCecInfoBuffer( u8 pCecInfoBuffer[], size_t size )
380 {
381 return CecControl::GetCecInfoBuffer(0, pCecInfoBuffer, size );
382 }
383
384 //
385
386
387 /* Please see man pages for details
388
389
390
391
392
393
394
395
396
397
398 */
399 nn::cec::CTR::TitleId MakeCecTitleId(bit32 id, bit8 variation = 0x0);
MakeCecTitleId(bit32 id,bit8 variation)400 inline nn::cec::CTR::TitleId MakeCecTitleId(bit32 id, bit8 variation)
401 {
402 return CecControl::MakeCecTitleId(id, variation);
403 }
404
405 } // end of namespace CTR
406 } // end of namespace cec
407 } // end of namespace nn
408
409
410
411 #endif // ifndef NN_CEC_CTR_CEC_CONTROL_H_
412