1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     cec_Control.h
4 
5   Copyright (C)2009-2012 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: 47112 $
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_MessageBox.h>
20 
21 namespace nn {
22 namespace cec {
23 namespace CTR {
24 
25 //------------------------------------------------------------
26 // For notification
27 
28 /* Please see man pages for details
29 
30 
31 
32 
33 */
34 struct CecNotificationParam
35 {
36     nn::fnd::DateTimeParameters     recvDate;       //
37     u32                             cecTitleId;     //
38     u8                              messageId[CEC_SIZEOF_MESSAGEID];    //
39 };
40 
41 /* Please see man pages for details
42 
43 
44 
45 
46 */
47 struct CecNotificationData
48 {
49     size_t  num;                //
50     s32     count;              //
51     CecNotificationParam param[MESSAGE_BOX_NUM_MAX];    //
52 };
53 
54 
55 /* Please see man pages for details
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 */
69 
70 class CecControl {
71 
72 public:
73 
74     enum ChangeDaemonState
75     {
76         DAEMON_CHANGE_STATE_READY ,
77         DAEMON_CHANGE_STATE_STARTSCAN ,
78         DAEMON_CHANGE_STATE_STOP,
79         DAEMON_CHANGE_STATE_STOP_DAEMON,
80         DAEMON_CHANGE_STATE_START_DAEMON,
81         DAEMON_CHANGE_STATE_RESET_FILTER,
82 
83         DAEMON_CHANGE_STATE_NDM_RESUME,
84         DAEMON_CHANGE_STATE_NDM_SUSPEND
85 
86     };
87 
88     /* Please see man pages for details
89 
90     */
91     enum DaemonState
92     {
93         DAEMON_STATE_STOP,          //
94         DAEMON_STATE_IDLE,          //
95         DAEMON_STATE_BUSY,          //
96         DAEMON_STATE_SCAN,          //
97         DAEMON_STATE_READY,         //
98         DAEMON_STATE_COMMUNICATING  //
99     };
100 
101 
102     explicit  CecControl(size_t bufSize);
103     CecControl();
104     ~CecControl();
105 
106     /* Please see man pages for details
107 
108 
109 
110      */
111     static nn::Result  Initialize();
112     static nn::Result  Initialize(nn::fnd::IAllocator& cecAllocFunc);
113     static nn::Result  Initialize(uptr bufferAddress, size_t bufferSize);
114     static nn::Result  InitializeWithoutNdm();
115 
116     /* Please see man pages for details
117 
118 
119 
120      */
121     static nn::Result  Finalize();
122 
123     static bool IsInitialized();
124 
125     /* Please see man pages for details
126 
127 
128 
129 
130      */
131     static nn::Result  ReadyDaemon();
132 
133     /* Please see man pages for details
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149      */
150     static nn::Result  StartScanning(bool reset = false);
151 
152     /* Please see man pages for details
153 
154 
155 
156 
157 
158 
159 
160      */
161     static nn::Result  Suspend();
162 
163     /* Please see man pages for details
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183      */
184     static nn::Result  StopScanning(bool b_Immediate = false, bool b_Async = false);
185 
186     /* Please see man pages for details
187 
188 
189 
190 
191 
192 
193      */
194     static nn::Result  StopDaemon();
195 
196     /* Please see man pages for details
197 
198 
199 
200 
201      */
202     static nn::Result  StartDaemon();
203 
204     /* Please see man pages for details
205 
206 
207 
208 
209 
210 
211      */
212     static nn::Result GetCecInfoBuffer(  u32 cecTitleId, u8 pCecInfoBuffer[], size_t size );
GetCecInfoBuffer(u8 pCecInfoBuffer[],size_t size)213     static nn::Result GetCecInfoBuffer(  u8 pCecInfoBuffer[], size_t size )
214     {
215         return GetCecInfoBuffer(  0, pCecInfoBuffer, size );
216     };
217 
218     /* Please see man pages for details
219 
220 
221 
222 
223      */
224     static nn::Result GetCecState( DaemonState* state );
225     static nn::Result GetCecState( u32* state );
226 
227     static bool IsDaemonBusy(void);
228 
229     /* Please see man pages for details
230 
231 
232 
233 
234      */
235     static nn::Result GetCecRecvEventHandle( nn::os::Event* event );
236 
237     /* Please see man pages for details
238 
239 
240 
241 
242 
243 
244      */
245     static nn::Result GetExchangeCount( s32* count );
246 
247 
248     static nn::Result GetChangeStateEventHandle( nn::os::Event& event );
249 
250     static nn::cec::CTR::TitleId MakeCecTitleId(bit32 id, bit8 variation = 0x0);
251 
252     /* */
253     static nn::Result FormatSaveData();
254 
255     /* Please see man pages for details
256 
257 
258 
259 
260 
261 
262 
263 
264 
265      */
266     static nn::Result   EnterExclusiveState();
267 
268     /* Please see man pages for details
269 
270 
271      */
272     static nn::Result   LeaveExclusiveState();
273 
274     static bool                s_Initialized;
275     static bool                s_NdmInitialized;
276     static bool                s_NdmSuspended;
277     static bool                s_EnterExclusiveState;
278 private:
279     static nn::os::CriticalSection    m_Cs;
280 
281 };
282 
283 
284 
285 
286 //
287 //
288 
289 
290 /* Please see man pages for details
291 
292 
293 
294 
295 
296 
297 
298 
299 
300 
301  */
302 nn::Result  Initialize(nn::fnd::IAllocator& cecAllocFunc);
303 
304 /* Please see man pages for details
305 
306 
307 
308 
309 
310 
311 
312 
313 
314 
315  */
316 nn::Result  Initialize() NN_ATTRIBUTE_DEPRECATED;
317 
318 /* Please see man pages for details
319 
320 
321 
322 
323 
324 
325 
326 
327 
328 
329  */
330 nn::Result  Initialize(uptr bufferAddress, size_t bufferSize);
331 
Initialize()332 inline nn::Result  Initialize()
333 {
334     return CecControl::Initialize();
335 }
336 
337 nn::Result  Initialize(nn::fnd::IAllocator& cecAllocFunc);
338 
Initialize(nn::fnd::IAllocator & cecAllocFunc)339 inline nn::Result  Initialize(nn::fnd::IAllocator& cecAllocFunc)
340 {
341     return CecControl::Initialize(cecAllocFunc);
342 }
343 
Initialize(uptr bufferAddress,size_t bufferSize)344 inline nn::Result  Initialize(uptr bufferAddress, size_t bufferSize)
345 {
346     return CecControl::Initialize(bufferAddress, bufferSize);
347 }
348 
349 /* Please see man pages for details
350 
351 
352 
353 
354 
355 
356 
357 
358 
359 
360  */
361 nn::Result  InitializeForGetState();
362 
InitializeForGetState()363 inline nn::Result  InitializeForGetState()
364 {
365     return CecControl::InitializeWithoutNdm();
366 }
367 
368 /* Please see man pages for details
369 
370 
371 
372 
373 
374 
375 
376 
377 
378 
379  */
380 nn::Result  InitializeWithoutNdm();
381 
InitializeWithoutNdm()382 inline nn::Result  InitializeWithoutNdm()
383 {
384     return CecControl::InitializeWithoutNdm();
385 }
386 
387 /* Please see man pages for details
388 
389 
390 
391 
392  */
393 nn::Result  Finalize();
394 
Finalize()395 inline nn::Result  Finalize()
396 {
397     return CecControl::Finalize();
398 }
399 
400 //
401 
402 //
403 //
404 
405 /* Please see man pages for details
406 
407 
408 
409 
410 
411 
412 
413 
414 
415 
416 
417 
418  */
419 nn::Result GetCecRecvEventHandle( nn::os::Event* event );
GetCecRecvEventHandle(nn::os::Event * event)420 inline nn::Result GetCecRecvEventHandle( nn::os::Event* event )
421 {
422     return CecControl::GetCecRecvEventHandle( event );
423 }
424 
425 /* Please see man pages for details
426 
427 
428 
429 
430 
431 
432 
433 
434 
435 
436 
437 
438  */
439 nn::Result GetCecEvent( nn::os::Event* event );
GetCecEvent(nn::os::Event * event)440 inline nn::Result GetCecEvent( nn::os::Event* event )
441 {
442     return CecControl::GetCecRecvEventHandle( event );
443 }
444 
445 
446 /* Please see man pages for details
447 
448 
449 
450 
451 
452 
453 
454 
455 
456 
457 
458 
459 
460 
461 
462 
463 
464 
465 
466  */
467 nn::Result GetCecInfoBuffer( u32 cecTitleId, u8 pCecInfoBuffer[], size_t size );
468 nn::Result GetCecInfoBuffer( u8 pCecInfoBuffer[], size_t size );
469 
GetCecInfoBuffer(u32 cecTitleId,u8 pCecInfoBuffer[],size_t size)470 inline nn::Result GetCecInfoBuffer( u32 cecTitleId, u8 pCecInfoBuffer[], size_t size )
471 {
472     return CecControl::GetCecInfoBuffer(cecTitleId, pCecInfoBuffer, size );
473 }
474 
GetCecInfoBuffer(u8 pCecInfoBuffer[],size_t size)475 inline nn::Result GetCecInfoBuffer( u8 pCecInfoBuffer[], size_t size )
476 {
477     return CecControl::GetCecInfoBuffer(0, pCecInfoBuffer, size );
478 }
479 
480 //
481 
482 /* Please see man pages for details
483 
484 
485 
486 
487 
488 
489  */
490 nn::Result GetExchangeCount( s32* count );
GetExchangeCount(s32 * count)491 inline nn::Result GetExchangeCount( s32* count )
492 {
493     return CecControl::GetExchangeCount( count );
494 }
495 
496 
497 /* Please see man pages for details
498 
499 
500 
501 
502 
503 
504 
505 
506 
507 
508 
509 
510 */
511 nn::cec::CTR::TitleId MakeCecTitleId(bit32 id, bit8 variation = 0x0);
MakeCecTitleId(bit32 id,bit8 variation)512 inline nn::cec::CTR::TitleId MakeCecTitleId(bit32 id, bit8 variation)
513 {
514     return CecControl::MakeCecTitleId(id, variation);
515 }
516 
517 } // end of namespace CTR
518 } // end of namespace cec
519 } // end of namespace nn
520 
521 
522 
523 #endif  // ifndef NN_CEC_CTR_CEC_CONTROL_H_
524