1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - camera - include
3   File:     camera_api.h
4 
5   Copyright 2007-2008 Nintendo. 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   $Date:: 2008-11-20#$
14   $Rev: 9373 $
15   $Author: okajima_manabu $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef TWL_CAMERA_CAMERA_API_H_
19 #define TWL_CAMERA_CAMERA_API_H_
20 
21 #include <twl/types.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /*===========================================================================*/
28 
29 // Processing Result Definitions
30 typedef enum CAMERAResult
31 {
32     CAMERA_RESULT_SUCCESS = 0,
33     CAMERA_RESULT_SUCCESS_TRUE = 0,
34     CAMERA_RESULT_SUCCESS_FALSE,
35     CAMERA_RESULT_BUSY,
36     CAMERA_RESULT_ILLEGAL_PARAMETER,
37     CAMERA_RESULT_SEND_ERROR,
38     CAMERA_RESULT_INVALID_COMMAND,
39     CAMERA_RESULT_ILLEGAL_STATUS,
40     CAMERA_RESULT_FATAL_ERROR,
41     CAMERA_RESULT_MAX
42 }
43 CAMERAResult;
44 
45 // Callbacks
46 typedef void (*CAMERACallback)(CAMERAResult result, void *arg);
47 typedef void (*CAMERAIntrCallback)(CAMERAResult result);
48 
49 // Core APIs
50 CAMERAResult CAMERA_InitCore(void);
51 void CAMERA_EndCore(void);
52 CAMERAResult CAMERA_StartCore(CAMERASelect camera);
53 CAMERAResult CAMERA_StopCore(void);
54 CAMERAResult CAMERA_I2CInitAsyncCore(CAMERASelect camera, CAMERACallback callback, void *arg);
55 CAMERAResult CAMERA_I2CInitCore(CAMERASelect camera);
56 CAMERAResult CAMERA_I2CActivateAsyncCore(CAMERASelect camera, CAMERACallback callback, void *arg);
57 CAMERAResult CAMERA_I2CActivateCore(CAMERASelect camera);
58 CAMERAResult CAMERA_I2CContextSwitchAsyncCore(CAMERASelect camera, CAMERAContext context, CAMERACallback callback, void *arg);
59 CAMERAResult CAMERA_I2CContextSwitchCore(CAMERASelect camera, CAMERAContext context);
60 CAMERAResult CAMERA_I2CSizeExAsyncCore(CAMERASelect camera, CAMERAContext context, CAMERASize size, CAMERACallback callback, void *arg);
61 CAMERAResult CAMERA_I2CSizeExCore(CAMERASelect camera, CAMERAContext context, CAMERASize size);
62 CAMERAResult CAMERA_I2CFrameRateAsyncCore(CAMERASelect camera, CAMERAFrameRate rate, CAMERACallback callback, void *arg);
63 CAMERAResult CAMERA_I2CFrameRateCore(CAMERASelect camera, CAMERAFrameRate rate);
64 CAMERAResult CAMERA_I2CEffectExAsyncCore(CAMERASelect camera, CAMERAContext context, CAMERAEffect effect, CAMERACallback callback, void *arg);
65 CAMERAResult CAMERA_I2CEffectExCore(CAMERASelect camera, CAMERAContext context, CAMERAEffect effect);
66 CAMERAResult CAMERA_I2CFlipExAsyncCore(CAMERASelect camera, CAMERAContext context, CAMERAFlip flip, CAMERACallback callback, void *arg);
67 CAMERAResult CAMERA_I2CFlipExCore(CAMERASelect camera, CAMERAContext context, CAMERAFlip flip);
68 CAMERAResult CAMERA_I2CPhotoModeAsyncCore(CAMERASelect camera, CAMERAPhotoMode mode, CAMERACallback callback, void *arg);
69 CAMERAResult CAMERA_I2CPhotoModeCore(CAMERASelect camera, CAMERAPhotoMode mode);
70 CAMERAResult CAMERA_I2CWhiteBalanceAsyncCore(CAMERASelect camera, CAMERAWhiteBalance wb, CAMERACallback callback, void *arg);
71 CAMERAResult CAMERA_I2CWhiteBalanceCore(CAMERASelect camera, CAMERAWhiteBalance wb);
72 CAMERAResult CAMERA_I2CExposureAsyncCore(CAMERASelect camera, int exposure, CAMERACallback callback, void *arg);
73 CAMERAResult CAMERA_I2CExposureCore(CAMERASelect camera, int exposure);
74 CAMERAResult CAMERA_I2CSharpnessAsyncCore(CAMERASelect camera, int sharpness, CAMERACallback callback, void *arg);
75 CAMERAResult CAMERA_I2CSharpnessCore(CAMERASelect camera, int sharpness);
76 CAMERAResult CAMERAi_I2CTestPatternAsyncCore(CAMERASelect camera, CAMERATestPattern pattern, CAMERACallback callback, void *arg);
77 CAMERAResult CAMERAi_I2CTestPatternCore(CAMERASelect camera, CAMERATestPattern pattern);
78 CAMERAResult CAMERA_I2CAutoExposureAsyncCore(CAMERASelect camera, BOOL on, CAMERACallback callback, void *arg);
79 CAMERAResult CAMERA_I2CAutoExposureCore(CAMERASelect camera, BOOL on);
80 CAMERAResult CAMERA_I2CAutoWhiteBalanceAsyncCore(CAMERASelect camera, BOOL on, CAMERACallback callback, void *arg);
81 CAMERAResult CAMERA_I2CAutoWhiteBalanceCore(CAMERASelect camera, BOOL on);
82 CAMERAResult CAMERA_SetLEDAsyncCore(BOOL isBlink, CAMERACallback callback, void *arg);
83 CAMERAResult CAMERA_SetLEDCore(BOOL isBlink);
84 CAMERAResult CAMERA_SwitchOffLEDAsyncCore(CAMERACallback callback, void *arg);
85 CAMERAResult CAMERA_SwitchOffLEDCore(void);
86 
87 void CAMERA_SetVsyncCallbackCore(CAMERAIntrCallback callback);
88 void CAMERA_SetBufferErrorCallbackCore(CAMERAIntrCallback callback);
89 void CAMERA_SetRebootCallbackCore(CAMERAIntrCallback callback);
90 
91 /*---------------------------------------------------------------------------*
92   Name:         CAMERA_Init
93 
94   Description:  Initializes the CAMERA library.
95 
96   Arguments:    None.
97 
98   Returns:      None.
99  *---------------------------------------------------------------------------*/
CAMERA_Init(void)100 SDK_INLINE CAMERAResult CAMERA_Init(void)
101 {
102     if (OS_IsRunOnTwl() == TRUE)
103     {
104         CAMERAResult result;
105         result = CAMERA_InitCore();
106         if (result == CAMERA_RESULT_SUCCESS)
107         {
108             return CAMERA_I2CInitCore(CAMERA_SELECT_BOTH);
109         }
110         else
111         {
112             return result;
113         }
114     }
115     return CAMERA_RESULT_FATAL_ERROR;
116 }
117 
118 /*---------------------------------------------------------------------------*
119   Name:         CAMERA_End
120 
121   Description:  Shuts down the CAMERA library.
122 
123   Arguments:    None.
124 
125   Returns:      None.
126  *---------------------------------------------------------------------------*/
CAMERA_End(void)127 SDK_INLINE void CAMERA_End(void)
128 {
129     if (OS_IsRunOnTwl() == TRUE)
130     {
131         CAMERA_EndCore();
132     }
133 }
134 
135 /*---------------------------------------------------------------------------*
136   Name:         CAMERA_Start
137 
138   Description:  This high-level function starts capturing. This can also be used for switching.
139                 Synchronous version only.
140 
141   Arguments:    camera: One of the CAMERASelect values
142 
143   Returns:      CAMERAResult
144  *---------------------------------------------------------------------------*/
CAMERA_Start(CAMERASelect camera)145 SDK_INLINE CAMERAResult CAMERA_Start(CAMERASelect camera)
146 {
147     if (OS_IsRunOnTwl() == TRUE)
148     {
149         return CAMERA_StartCore(camera);
150     }
151     return CAMERA_RESULT_FATAL_ERROR;
152 }
153 
154 /*---------------------------------------------------------------------------*
155   Name:         CAMERA_Stop
156 
157   Description:  This high-level function stops capturing.
158                 Synchronous version only.
159 
160   Arguments:    None.
161 
162   Returns:      CAMERAResult
163  *---------------------------------------------------------------------------*/
CAMERA_Stop(void)164 SDK_INLINE CAMERAResult CAMERA_Stop(void)
165 {
166     if (OS_IsRunOnTwl() == TRUE)
167     {
168         return CAMERA_StopCore();
169     }
170     return CAMERA_RESULT_FATAL_ERROR;
171 }
172 
173 /*---------------------------------------------------------------------------*
174   Name:         CAMERA_I2CInitAsync
175 
176   Description:  Initializes camera registers via I2C.
177                 async version.
178 
179   Arguments:    camera: One of the CAMERASelect values
180                 callback: Specifies the function to be called when the asynchronous process has completed.
181                 arg: Specifies the arguments to the callback function when it is invoked.
182 
183   Returns:      CAMERAResult
184  *---------------------------------------------------------------------------*/
CAMERA_I2CInitAsync(CAMERASelect camera,CAMERACallback callback,void * arg)185 SDK_INLINE CAMERAResult CAMERA_I2CInitAsync(CAMERASelect camera, CAMERACallback callback, void *arg)
186 {
187     if (OS_IsRunOnTwl() == TRUE)
188     {
189         return CAMERA_I2CInitAsyncCore(camera, callback, arg);
190     }
191     return CAMERA_RESULT_FATAL_ERROR;
192 }
193 
194 /*---------------------------------------------------------------------------*
195   Name:         CAMERA_I2CInit
196 
197   Description:  Initializes camera registers via I2C.
198                 sync version.
199 
200   Arguments:    camera: One of the CAMERASelect values
201 
202   Returns:      CAMERAResult
203  *---------------------------------------------------------------------------*/
CAMERA_I2CInit(CAMERASelect camera)204 SDK_INLINE CAMERAResult CAMERA_I2CInit(CAMERASelect camera)
205 {
206     if (OS_IsRunOnTwl() == TRUE)
207     {
208         return CAMERA_I2CInitCore(camera);
209     }
210     return CAMERA_RESULT_FATAL_ERROR;
211 }
212 
213 /*---------------------------------------------------------------------------*
214   Name:         CAMERA_I2CActivateAsync
215 
216   Description:  Activates the specified camera (go to standby mode if NONE is specified).
217                 Asynchronous version.
218 
219   Arguments:    camera: One of the CAMERASelect values (BOTH is not valid)
220                 callback: Specifies the function to be called when the asynchronous process has completed.
221                 arg: Specifies the arguments to the callback function when it is invoked.
222 
223   Returns:      CAMERAResult
224  *---------------------------------------------------------------------------*/
CAMERA_I2CActivateAsync(CAMERASelect camera,CAMERACallback callback,void * arg)225 SDK_INLINE CAMERAResult CAMERA_I2CActivateAsync(CAMERASelect camera, CAMERACallback callback, void *arg)
226 {
227     if (OS_IsRunOnTwl() == TRUE)
228     {
229         return CAMERA_I2CActivateAsyncCore(camera, callback, arg);
230     }
231     return CAMERA_RESULT_FATAL_ERROR;
232 }
233 
234 /*---------------------------------------------------------------------------*
235   Name:         CAMERA_I2CActivate
236 
237   Description:  Activates the specified camera (go to standby mode if NONE is specified).
238                 sync version.
239 
240   Arguments:    camera: One of the CAMERASelect values (BOTH is not valid)
241 
242   Returns:      CAMERAResult
243  *---------------------------------------------------------------------------*/
CAMERA_I2CActivate(CAMERASelect camera)244 SDK_INLINE CAMERAResult CAMERA_I2CActivate(CAMERASelect camera)
245 {
246     if (OS_IsRunOnTwl() == TRUE)
247     {
248         return CAMERA_I2CActivateCore(camera);
249     }
250     return CAMERA_RESULT_FATAL_ERROR;
251 }
252 
253 /*---------------------------------------------------------------------------*
254   Name:         CAMERA_I2CContextSwitchAsync
255 
256   Description:  Resizes the camera output image.
257                 Asynchronous version.
258 
259   Arguments:    camera: One of the CAMERASelect values
260                 context: One of the CAMERAContext values (A or B)
261                 callback: Specifies the function to be called when the asynchronous process has completed.
262                 arg: Specifies the arguments to the callback function when it is invoked.
263 
264   Returns:      CAMERAResult
265  *---------------------------------------------------------------------------*/
CAMERA_I2CContextSwitchAsync(CAMERASelect camera,CAMERAContext context,CAMERACallback callback,void * arg)266 SDK_INLINE CAMERAResult CAMERA_I2CContextSwitchAsync(CAMERASelect camera, CAMERAContext context, CAMERACallback callback, void *arg)
267 {
268     if (OS_IsRunOnTwl() == TRUE)
269     {
270         return CAMERA_I2CContextSwitchAsyncCore(camera, context, callback, arg);
271     }
272     return CAMERA_RESULT_FATAL_ERROR;
273 }
274 
275 /*---------------------------------------------------------------------------*
276   Name:         CAMERA_I2CContextSwitch
277 
278   Description:  Resizes the camera output image.
279                 sync version.
280 
281   Arguments:    camera: One of the CAMERASelect values
282                 context: One of the CAMERAContext values (A or B)
283 
284   Returns:      CAMERAResult
285  *---------------------------------------------------------------------------*/
CAMERA_I2CContextSwitch(CAMERASelect camera,CAMERAContext context)286 SDK_INLINE CAMERAResult CAMERA_I2CContextSwitch(CAMERASelect camera, CAMERAContext context)
287 {
288     if (OS_IsRunOnTwl() == TRUE)
289     {
290         return CAMERA_I2CContextSwitchCore(camera, context);
291     }
292     return CAMERA_RESULT_FATAL_ERROR;
293 }
294 
295 /*---------------------------------------------------------------------------*
296   Name:         CAMERA_I2CSizeExAsync
297 
298   Description:  Sets the camera frame size.
299                 Asynchronous version.
300 
301   Arguments:    camera: One of the CAMERASelect values
302                 context: One of the CAMERAContext values (A or B)
303                 size: One of the CAMERASize values
304                 callback: Specifies the function to be called when the asynchronous process has completed.
305                 arg: Specifies the arguments to the callback function when it is invoked.
306 
307   Returns:      CAMERAResult
308  *---------------------------------------------------------------------------*/
CAMERA_I2CSizeExAsync(CAMERASelect camera,CAMERAContext context,CAMERASize size,CAMERACallback callback,void * arg)309 SDK_INLINE CAMERAResult CAMERA_I2CSizeExAsync(CAMERASelect camera, CAMERAContext context, CAMERASize size, CAMERACallback callback, void *arg)
310 {
311     if (OS_IsRunOnTwl() == TRUE)
312     {
313         return CAMERA_I2CSizeExAsyncCore(camera, context, size, callback, arg);
314     }
315     return CAMERA_RESULT_FATAL_ERROR;
316 }
317 /*---------------------------------------------------------------------------*
318   Name:         CAMERA_I2CSizeAsync
319 
320   Description:  Sets the camera frame size for all contexts.
321                 Asynchronous version.
322 
323   Arguments:    camera: One of the CAMERASelect values
324                 size: One of the CAMERASize values
325                 callback: Specifies the function to be called when the asynchronous process has completed.
326                 arg: Specifies the arguments to the callback function when it is invoked.
327 
328   Returns:      CAMERAResult
329  *---------------------------------------------------------------------------*/
CAMERA_I2CSizeAsync(CAMERASelect camera,CAMERASize size,CAMERACallback callback,void * arg)330 SDK_INLINE CAMERAResult CAMERA_I2CSizeAsync(CAMERASelect camera, CAMERASize size, CAMERACallback callback, void *arg)
331 {
332     if (OS_IsRunOnTwl() == TRUE)
333     {
334         return CAMERA_I2CSizeExAsyncCore(camera, CAMERA_CONTEXT_BOTH, size, callback, arg);
335     }
336     return CAMERA_RESULT_FATAL_ERROR;
337 }
338 
339 /*---------------------------------------------------------------------------*
340   Name:         CAMERA_I2CSizeEx
341 
342   Description:  Sets the camera frame size.
343                 sync version.
344 
345   Arguments:    camera: One of the CAMERASelect values
346                 context: One of the CAMERAContext values (A or B)
347                 size: One of the CAMERASize values
348 
349   Returns:      CAMERAResult
350  *---------------------------------------------------------------------------*/
CAMERA_I2CSizeEx(CAMERASelect camera,CAMERAContext context,CAMERASize size)351 SDK_INLINE CAMERAResult CAMERA_I2CSizeEx(CAMERASelect camera, CAMERAContext context, CAMERASize size)
352 {
353     if (OS_IsRunOnTwl() == TRUE)
354     {
355         return CAMERA_I2CSizeExCore(camera, context, size);
356     }
357     return CAMERA_RESULT_FATAL_ERROR;
358 }
359 /*---------------------------------------------------------------------------*
360   Name:         CAMERA_I2CSize
361 
362   Description:  Sets the camera frame size for all contexts.
363                 sync version.
364 
365   Arguments:    camera: One of the CAMERASelect values
366                 size: One of the CAMERASize values
367 
368   Returns:      CAMERAResult
369  *---------------------------------------------------------------------------*/
CAMERA_I2CSize(CAMERASelect camera,CAMERASize size)370 SDK_INLINE CAMERAResult CAMERA_I2CSize(CAMERASelect camera, CAMERASize size)
371 {
372     if (OS_IsRunOnTwl() == TRUE)
373     {
374         return CAMERA_I2CSizeExCore(camera, CAMERA_CONTEXT_BOTH, size);
375     }
376     return CAMERA_RESULT_FATAL_ERROR;
377 }
378 
379 /*---------------------------------------------------------------------------*
380   Name:         CAMERA_I2CFrameRateAsync
381 
382   Description:  Sets the camera frame rate.
383                 Asynchronous version.
384 
385   Arguments:    camera: One of the CAMERASelect values
386                 rate: One of the CAMERAFrameRate values
387                 callback: Specifies the function to be called when the asynchronous process has completed.
388                 arg: Specifies the arguments to the callback function when it is invoked.
389 
390   Returns:      CAMERAResult
391  *---------------------------------------------------------------------------*/
CAMERA_I2CFrameRateAsync(CAMERASelect camera,CAMERAFrameRate rate,CAMERACallback callback,void * arg)392 SDK_INLINE CAMERAResult CAMERA_I2CFrameRateAsync(CAMERASelect camera, CAMERAFrameRate rate, CAMERACallback callback, void *arg)
393 {
394     if (OS_IsRunOnTwl() == TRUE)
395     {
396         return CAMERA_I2CFrameRateAsyncCore(camera, rate, callback, arg);
397     }
398     return CAMERA_RESULT_FATAL_ERROR;
399 }
400 
401 /*---------------------------------------------------------------------------*
402   Name:         CAMERA_I2CFrameRate
403 
404   Description:  Sets the camera frame rate.
405                 sync version.
406 
407   Arguments:    camera: One of the CAMERASelect values
408                 rate: One of the CAMERAFrameRate values
409 
410   Returns:      CAMERAResult
411  *---------------------------------------------------------------------------*/
CAMERA_I2CFrameRate(CAMERASelect camera,CAMERAFrameRate rate)412 SDK_INLINE CAMERAResult CAMERA_I2CFrameRate(CAMERASelect camera, CAMERAFrameRate rate)
413 {
414     if (OS_IsRunOnTwl() == TRUE)
415     {
416         return CAMERA_I2CFrameRateCore(camera, rate);
417     }
418     return CAMERA_RESULT_FATAL_ERROR;
419 }
420 
421 /*---------------------------------------------------------------------------*
422   Name:         CAMERA_I2CEffectExAsync
423 
424   Description:  Sets camera effects.
425                 Asynchronous version.
426 
427   Arguments:    camera: One of the CAMERASelect values
428                 context: One of the CAMERAContext values (A or B)
429                 effect: One of the CAMERAEffect values
430                 callback: Specifies the function to be called when the asynchronous process has completed.
431                 arg: Specifies the arguments to the callback function when it is invoked.
432 
433   Returns:      CAMERAResult
434  *---------------------------------------------------------------------------*/
CAMERA_I2CEffectExAsync(CAMERASelect camera,CAMERAContext context,CAMERAEffect effect,CAMERACallback callback,void * arg)435 SDK_INLINE CAMERAResult CAMERA_I2CEffectExAsync(CAMERASelect camera, CAMERAContext context, CAMERAEffect effect, CAMERACallback callback, void *arg)
436 {
437     if (OS_IsRunOnTwl() == TRUE)
438     {
439         return CAMERA_I2CEffectExAsyncCore(camera, context, effect, callback, arg);
440     }
441     return CAMERA_RESULT_FATAL_ERROR;
442 }
443 
444 /*---------------------------------------------------------------------------*
445   Name:         CAMERA_I2CEffectAsync
446 
447   Description:  Sets the camera effect for all contexts.
448                 Asynchronous version.
449 
450   Arguments:    camera: One of the CAMERASelect values
451                 effect: One of the CAMERAEffect values
452                 callback: Specifies the function to be called when the asynchronous process has completed.
453                 arg: Specifies the arguments to the callback function when it is invoked.
454 
455   Returns:      CAMERAResult
456  *---------------------------------------------------------------------------*/
CAMERA_I2CEffectAsync(CAMERASelect camera,CAMERAEffect effect,CAMERACallback callback,void * arg)457 SDK_INLINE CAMERAResult CAMERA_I2CEffectAsync(CAMERASelect camera, CAMERAEffect effect, CAMERACallback callback, void *arg)
458 {
459     if (OS_IsRunOnTwl() == TRUE)
460     {
461         return CAMERA_I2CEffectExAsyncCore(camera, CAMERA_CONTEXT_BOTH, effect, callback, arg);
462     }
463     return CAMERA_RESULT_FATAL_ERROR;
464 }
465 
466 /*---------------------------------------------------------------------------*
467   Name:         CAMERA_I2CEffect
468 
469   Description:  Sets camera effects.
470                 sync version.
471 
472   Arguments:    camera: One of the CAMERASelect values
473                 context: One of the CAMERAContext values (A or B)
474                 effect: One of the CAMERAEffect values
475 
476   Returns:      CAMERAResult
477  *---------------------------------------------------------------------------*/
CAMERA_I2CEffectEx(CAMERASelect camera,CAMERAContext context,CAMERAEffect effect)478 SDK_INLINE CAMERAResult CAMERA_I2CEffectEx(CAMERASelect camera, CAMERAContext context, CAMERAEffect effect)
479 {
480     if (OS_IsRunOnTwl() == TRUE)
481     {
482         return CAMERA_I2CEffectExCore(camera, context, effect);
483     }
484     return CAMERA_RESULT_FATAL_ERROR;
485 }
486 /*---------------------------------------------------------------------------*
487   Name:         CAMERA_I2CEffect
488 
489   Description:  Sets the camera effect for all contexts.
490                 sync version.
491 
492   Arguments:    camera: One of the CAMERASelect values
493                 effect: One of the CAMERAEffect values
494 
495   Returns:      CAMERAResult
496  *---------------------------------------------------------------------------*/
CAMERA_I2CEffect(CAMERASelect camera,CAMERAEffect effect)497 SDK_INLINE CAMERAResult CAMERA_I2CEffect(CAMERASelect camera, CAMERAEffect effect)
498 {
499     if (OS_IsRunOnTwl() == TRUE)
500     {
501         return CAMERA_I2CEffectExCore(camera, CAMERA_CONTEXT_BOTH, effect);
502     }
503     return CAMERA_RESULT_FATAL_ERROR;
504 }
505 
506 /*---------------------------------------------------------------------------*
507   Name:         CAMERA_I2CFlipExAsync
508 
509   Description:  Sets the camera's flip/mirror.
510                 Asynchronous version.
511 
512   Arguments:    camera: One of the CAMERASelect values
513                 context: One of the CAMERAContext values (A or B)
514                 flip: One of the CAMERAFlip values
515                 callback: Specifies the function to be called when the asynchronous process has completed.
516                 arg: Specifies the arguments to the callback function when it is invoked.
517 
518   Returns:      CAMERAResult
519  *---------------------------------------------------------------------------*/
CAMERA_I2CFlipExAsync(CAMERASelect camera,CAMERAContext context,CAMERAFlip flip,CAMERACallback callback,void * arg)520 SDK_INLINE CAMERAResult CAMERA_I2CFlipExAsync(CAMERASelect camera, CAMERAContext context, CAMERAFlip flip, CAMERACallback callback, void *arg)
521 {
522     if (OS_IsRunOnTwl() == TRUE)
523     {
524         return CAMERA_I2CFlipExAsyncCore(camera, context, flip, callback, arg);
525     }
526     return CAMERA_RESULT_FATAL_ERROR;
527 }
528 /*---------------------------------------------------------------------------*
529   Name:         CAMERA_I2CFlipAsync
530 
531   Description:  Sets the camera flip/mirror for all contexts.
532                 Asynchronous version.
533 
534   Arguments:    camera: One of the CAMERASelect values
535                 flip: One of the CAMERAFlip values
536                 callback: Specifies the function to be called when the asynchronous process has completed.
537                 arg: Specifies the arguments to the callback function when it is invoked.
538 
539   Returns:      CAMERAResult
540  *---------------------------------------------------------------------------*/
CAMERA_I2CFlipAsync(CAMERASelect camera,CAMERAFlip flip,CAMERACallback callback,void * arg)541 SDK_INLINE CAMERAResult CAMERA_I2CFlipAsync(CAMERASelect camera, CAMERAFlip flip, CAMERACallback callback, void *arg)
542 {
543     if (OS_IsRunOnTwl() == TRUE)
544     {
545         return CAMERA_I2CFlipExAsyncCore(camera, CAMERA_CONTEXT_BOTH, flip, callback, arg);
546     }
547     return CAMERA_RESULT_FATAL_ERROR;
548 }
549 
550 /*---------------------------------------------------------------------------*
551   Name:         CAMERA_I2CFlipEx
552 
553   Description:  Sets the camera's flip/mirror.
554                 sync version.
555 
556   Arguments:    camera: One of the CAMERASelect values
557                 context: One of the CAMERAContext values (A or B)
558                 flip: One of the CAMERAFlip values
559 
560   Returns:      CAMERAResult
561  *---------------------------------------------------------------------------*/
CAMERA_I2CFlipEx(CAMERASelect camera,CAMERAContext context,CAMERAFlip flip)562 SDK_INLINE CAMERAResult CAMERA_I2CFlipEx(CAMERASelect camera, CAMERAContext context, CAMERAFlip flip)
563 {
564     if (OS_IsRunOnTwl() == TRUE)
565     {
566         return CAMERA_I2CFlipExCore(camera, context, flip);
567     }
568     return CAMERA_RESULT_FATAL_ERROR;
569 }
570 /*---------------------------------------------------------------------------*
571   Name:         CAMERA_I2CFlip
572 
573   Description:  Sets the camera flip/mirror for all contexts.
574                 sync version.
575 
576   Arguments:    camera: One of the CAMERASelect values
577                 flip: One of the CAMERAFlip values
578 
579   Returns:      CAMERAResult
580  *---------------------------------------------------------------------------*/
CAMERA_I2CFlip(CAMERASelect camera,CAMERAFlip flip)581 SDK_INLINE CAMERAResult CAMERA_I2CFlip(CAMERASelect camera, CAMERAFlip flip)
582 {
583     if (OS_IsRunOnTwl() == TRUE)
584     {
585         return CAMERA_I2CFlipExCore(camera, CAMERA_CONTEXT_BOTH, flip);
586     }
587     return CAMERA_RESULT_FATAL_ERROR;
588 }
589 
590 /*---------------------------------------------------------------------------*
591   Name:         CAMERA_I2CPhotoModeAsync
592 
593   Description:  Sets the camera's photo mode.
594                 Asynchronous version.
595 
596   Arguments:    camera: One of the CAMERASelect values
597                 mode: One of the CAMERAPhotoMode values
598                 callback: Specifies the function to be called when the asynchronous process has completed.
599                 arg: Specifies the arguments to the callback function when it is invoked.
600 
601   Returns:      CAMERAResult
602  *---------------------------------------------------------------------------*/
CAMERA_I2CPhotoModeAsync(CAMERASelect camera,CAMERAPhotoMode mode,CAMERACallback callback,void * arg)603 SDK_INLINE CAMERAResult CAMERA_I2CPhotoModeAsync(CAMERASelect camera, CAMERAPhotoMode mode, CAMERACallback callback, void *arg)
604 {
605     if (OS_IsRunOnTwl() == TRUE)
606     {
607         return CAMERA_I2CPhotoModeAsyncCore(camera, mode, callback, arg);
608     }
609     return CAMERA_RESULT_FATAL_ERROR;
610 }
611 
612 /*---------------------------------------------------------------------------*
613   Name:         CAMERA_I2CPhotoMode
614 
615   Description:  Sets the camera's photo mode.
616                 sync version.
617 
618   Arguments:    camera: One of the CAMERASelect values
619                 mode: One of the CAMERAPhotoMode values
620 
621   Returns:      CAMERAResult
622  *---------------------------------------------------------------------------*/
CAMERA_I2CPhotoMode(CAMERASelect camera,CAMERAPhotoMode mode)623 SDK_INLINE CAMERAResult CAMERA_I2CPhotoMode(CAMERASelect camera, CAMERAPhotoMode mode)
624 {
625     if (OS_IsRunOnTwl() == TRUE)
626     {
627         return CAMERA_I2CPhotoModeCore(camera, mode);
628     }
629     return CAMERA_RESULT_FATAL_ERROR;
630 }
631 
632 /*---------------------------------------------------------------------------*
633   Name:         CAMERA_I2CWhiteBalanceAsync
634 
635   Description:  Sets the camera's white balance.
636                 Asynchronous version.
637 
638   Arguments:    camera: One of the CAMERASelect values
639                 wb: One of the CAMERAWhiteBalance values
640                 callback: Specifies the function to be called when the asynchronous process has completed.
641                 arg: Specifies the arguments to the callback function when it is invoked.
642 
643   Returns:      CAMERAResult
644  *---------------------------------------------------------------------------*/
CAMERA_I2CWhiteBalanceAsync(CAMERASelect camera,CAMERAWhiteBalance wb,CAMERACallback callback,void * arg)645 SDK_INLINE CAMERAResult CAMERA_I2CWhiteBalanceAsync(CAMERASelect camera, CAMERAWhiteBalance wb, CAMERACallback callback, void *arg)
646 {
647     if (OS_IsRunOnTwl() == TRUE)
648     {
649         return CAMERA_I2CWhiteBalanceAsyncCore(camera, wb, callback, arg);
650     }
651     return CAMERA_RESULT_FATAL_ERROR;
652 }
653 
654 /*---------------------------------------------------------------------------*
655   Name:         CAMERA_I2CWhiteBalance
656 
657   Description:  Sets the camera's white balance.
658                 sync version.
659 
660   Arguments:    camera: One of the CAMERASelect values
661                 wb: One of the CAMERAWhiteBalance values
662 
663   Returns:      CAMERAResult
664  *---------------------------------------------------------------------------*/
CAMERA_I2CWhiteBalance(CAMERASelect camera,CAMERAWhiteBalance wb)665 SDK_INLINE CAMERAResult CAMERA_I2CWhiteBalance(CAMERASelect camera, CAMERAWhiteBalance wb)
666 {
667     if (OS_IsRunOnTwl() == TRUE)
668     {
669         return CAMERA_I2CWhiteBalanceCore(camera, wb);
670     }
671     return CAMERA_RESULT_FATAL_ERROR;
672 }
673 
674 /*---------------------------------------------------------------------------*
675   Name:         CAMERA_I2CExposureAsync
676 
677   Description:  Sets the camera's exposure.
678                 Asynchronous version.
679 
680   Arguments:    camera: One of the CAMERASelect values
681                 exposure: -5 to +5
682                 callback: Specifies the function to be called when the asynchronous process has completed.
683                 arg: Specifies the arguments to the callback function when it is invoked.
684 
685   Returns:      CAMERAResult
686  *---------------------------------------------------------------------------*/
CAMERA_I2CExposureAsync(CAMERASelect camera,int exposure,CAMERACallback callback,void * arg)687 SDK_INLINE CAMERAResult CAMERA_I2CExposureAsync(CAMERASelect camera, int exposure, CAMERACallback callback, void *arg)
688 {
689     if (OS_IsRunOnTwl() == TRUE)
690     {
691         return CAMERA_I2CExposureAsyncCore(camera, exposure, callback, arg);
692     }
693     return CAMERA_RESULT_FATAL_ERROR;
694 }
695 
696 /*---------------------------------------------------------------------------*
697   Name:         CAMERA_I2CExposure
698 
699   Description:  Sets the camera's exposure.
700                 sync version.
701 
702   Arguments:    camera: One of the CAMERASelect values
703                 exposure: -5 to +5
704   Returns:      CAMERAResult
705  *---------------------------------------------------------------------------*/
CAMERA_I2CExposure(CAMERASelect camera,int exposure)706 SDK_INLINE CAMERAResult CAMERA_I2CExposure(CAMERASelect camera, int exposure)
707 {
708     if (OS_IsRunOnTwl() == TRUE)
709     {
710         return CAMERA_I2CExposureCore(camera, exposure);
711     }
712     return CAMERA_RESULT_FATAL_ERROR;
713 }
714 
715 /*---------------------------------------------------------------------------*
716   Name:         CAMERA_I2CSharpnessAsync
717 
718   Description:  Sets the camera's sharpness.
719                 Asynchronous version.
720 
721   Arguments:    camera: One of the CAMERASelect values
722                 sharpness: -3 to +5
723                 callback: Specifies the function to be called when the asynchronous process has completed.
724                 arg: Specifies the arguments to the callback function when it is invoked.
725 
726   Returns:      CAMERAResult
727  *---------------------------------------------------------------------------*/
CAMERA_I2CSharpnessAsync(CAMERASelect camera,int sharpness,CAMERACallback callback,void * arg)728 SDK_INLINE CAMERAResult CAMERA_I2CSharpnessAsync(CAMERASelect camera, int sharpness, CAMERACallback callback, void *arg)
729 {
730     if (OS_IsRunOnTwl() == TRUE)
731     {
732         return CAMERA_I2CSharpnessAsyncCore(camera, sharpness, callback, arg);
733     }
734     return CAMERA_RESULT_FATAL_ERROR;
735 }
736 
737 /*---------------------------------------------------------------------------*
738   Name:         CAMERA_I2CSharpness
739 
740   Description:  Sets the camera's sharpness.
741                 sync version.
742 
743   Arguments:    camera: One of the CAMERASelect values
744                 sharpness: -3 to +5
745   Returns:      CAMERAResult
746  *---------------------------------------------------------------------------*/
CAMERA_I2CSharpness(CAMERASelect camera,int sharpness)747 SDK_INLINE CAMERAResult CAMERA_I2CSharpness(CAMERASelect camera, int sharpness)
748 {
749     if (OS_IsRunOnTwl() == TRUE)
750     {
751         return CAMERA_I2CSharpnessCore(camera, sharpness);
752     }
753     return CAMERA_RESULT_FATAL_ERROR;
754 }
755 
756 /*---------------------------------------------------------------------------*
757   Name:         CAMERAi_I2CTestPatternAsync
758 
759   Description:  Sets the camera's test pattern.
760                 Asynchronous version.
761 
762   Arguments:    camera: One of the CAMERASelect values
763                 pattern: One of the CAMERATestPattern values
764                 callback: Specifies the function to be called when the asynchronous process has completed.
765                 arg: Specifies the arguments to the callback function when it is invoked.
766 
767   Returns:      CAMERAResult
768  *---------------------------------------------------------------------------*/
CAMERAi_I2CTestPatternAsync(CAMERASelect camera,CAMERATestPattern pattern,CAMERACallback callback,void * arg)769 SDK_INLINE CAMERAResult CAMERAi_I2CTestPatternAsync(CAMERASelect camera, CAMERATestPattern pattern, CAMERACallback callback, void *arg)
770 {
771     if (OS_IsRunOnTwl() == TRUE)
772     {
773         return CAMERAi_I2CTestPatternAsyncCore(camera, pattern, callback, arg);
774     }
775     return CAMERA_RESULT_FATAL_ERROR;
776 }
777 
778 /*---------------------------------------------------------------------------*
779   Name:         CAMERAi_I2CTestPattern
780 
781   Description:  Sets the camera's test pattern.
782                 sync version.
783 
784   Arguments:    camera: One of the CAMERASelect values
785                 pattern: One of the CAMERATestPattern values
786 
787   Returns:      CAMERAResult
788  *---------------------------------------------------------------------------*/
CAMERAi_I2CTestPattern(CAMERASelect camera,CAMERATestPattern pattern)789 SDK_INLINE CAMERAResult CAMERAi_I2CTestPattern(CAMERASelect camera, CAMERATestPattern pattern)
790 {
791     if (OS_IsRunOnTwl() == TRUE)
792     {
793         return CAMERAi_I2CTestPatternCore(camera, pattern);
794     }
795     return CAMERA_RESULT_FATAL_ERROR;
796 }
797 
798 /*---------------------------------------------------------------------------*
799   Name:         CAMERA_I2CAutoExposureAsync
800 
801   Description:  Enables and disables camera auto-exposure.
802                 Asynchronous version.
803 
804   Arguments:    camera: One of the CAMERASelect values
805                 on: TRUE if AE will be enabled
806                 callback: Specifies the function to be called when the asynchronous process has completed.
807                 arg: Specifies the arguments to the callback function when it is invoked.
808 
809   Returns:      CAMERAResult
810  *---------------------------------------------------------------------------*/
CAMERA_I2CAutoExposureAsync(CAMERASelect camera,BOOL on,CAMERACallback callback,void * arg)811 SDK_INLINE CAMERAResult CAMERA_I2CAutoExposureAsync(CAMERASelect camera, BOOL on, CAMERACallback callback, void *arg)
812 {
813     if (OS_IsRunOnTwl() == TRUE)
814     {
815         return CAMERA_I2CAutoExposureAsyncCore(camera, on, callback, arg);
816     }
817     return CAMERA_RESULT_FATAL_ERROR;
818 }
819 
820 /*---------------------------------------------------------------------------*
821   Name:         CAMERA_I2CAutoExposure
822 
823   Description:  Enables and disables camera auto-exposure.
824                 sync version.
825 
826   Arguments:    camera: One of the CAMERASelect values
827                 on: TRUE if AE will be enabled
828   Returns:      CAMERAResult
829  *---------------------------------------------------------------------------*/
CAMERA_I2CAutoExposure(CAMERASelect camera,BOOL on)830 SDK_INLINE CAMERAResult CAMERA_I2CAutoExposure(CAMERASelect camera, BOOL on)
831 {
832     if (OS_IsRunOnTwl() == TRUE)
833     {
834         return CAMERA_I2CAutoExposureCore(camera, on);
835     }
836     return CAMERA_RESULT_FATAL_ERROR;
837 }
838 
839 /*---------------------------------------------------------------------------*
840   Name:         CAMERA_I2CAutoWhiteBalanceAsync
841 
842   Description:  Enables and disables camera auto-white balance.
843                 Asynchronous version.
844 
845   Arguments:    camera: One of the CAMERASelect values
846                 on: TRUE if AWB will be enabled
847                 callback: Specifies the function to be called when the asynchronous process has completed.
848                 arg: Specifies the arguments to the callback function when it is invoked.
849 
850   Returns:      CAMERAResult
851  *---------------------------------------------------------------------------*/
CAMERA_I2CAutoWhiteBalanceAsync(CAMERASelect camera,BOOL on,CAMERACallback callback,void * arg)852 SDK_INLINE CAMERAResult CAMERA_I2CAutoWhiteBalanceAsync(CAMERASelect camera, BOOL on, CAMERACallback callback, void *arg)
853 {
854     if (OS_IsRunOnTwl() == TRUE)
855     {
856         return CAMERA_I2CAutoWhiteBalanceAsyncCore(camera, on, callback, arg);
857     }
858     return CAMERA_RESULT_FATAL_ERROR;
859 }
860 
861 /*---------------------------------------------------------------------------*
862   Name:         CAMERA_I2CAutoWhiteBalance
863 
864   Description:  Enables and disables camera auto-white balance.
865                 sync version.
866 
867   Arguments:    camera: One of the CAMERASelect values
868                 on: TRUE if AWB will be enabled
869   Returns:      CAMERAResult
870  *---------------------------------------------------------------------------*/
CAMERA_I2CAutoWhiteBalance(CAMERASelect camera,BOOL on)871 SDK_INLINE CAMERAResult CAMERA_I2CAutoWhiteBalance(CAMERASelect camera, BOOL on)
872 {
873     if (OS_IsRunOnTwl() == TRUE)
874     {
875         return CAMERA_I2CAutoWhiteBalanceCore(camera, on);
876     }
877     return CAMERA_RESULT_FATAL_ERROR;
878 }
879 
880 /*---------------------------------------------------------------------------*
881   Name:         CAMERA_SetLEDAsync
882 
883   Description:  Configures whether the camera indicator LED (outside) will blink.
884                 This only works when the outer camera is active.
885                 By default, it will not blink when I2CActivate(OUT/BOTH) is called.
886                 Asynchronous version.
887 
888   Arguments:    isBlink: TRUE to cause it to blink and FALSE to leave it lit
889                 callback: Specifies the function to be called when the asynchronous process has completed.
890                 arg: Specifies the arguments to the callback function when it is invoked.
891 
892   Returns:      CAMERAResult
893  *---------------------------------------------------------------------------*/
CAMERA_SetLEDAsync(BOOL isBlink,CAMERACallback callback,void * arg)894 SDK_INLINE CAMERAResult CAMERA_SetLEDAsync(BOOL isBlink, CAMERACallback callback, void *arg)
895 {
896     if (OS_IsRunOnTwl() == TRUE)
897     {
898         return CAMERA_SetLEDAsyncCore(isBlink, callback, arg);
899     }
900     return CAMERA_RESULT_FATAL_ERROR;
901 }
902 
903 /*---------------------------------------------------------------------------*
904   Name:         CAMERA_SetLED
905 
906   Description:  Configures whether the camera indicator LED (outside) will blink.
907                 This only works when the outer camera is active.
908                 By default, it will not blink when I2CActivate(OUT/BOTH) is called.
909                 sync version.
910 
911   Arguments:    isBlink: TRUE to cause it to blink and FALSE to leave it lit
912 
913   Returns:      CAMERAResult
914  *---------------------------------------------------------------------------*/
CAMERA_SetLED(BOOL isBlink)915 SDK_INLINE CAMERAResult CAMERA_SetLED(BOOL isBlink)
916 {
917     if (OS_IsRunOnTwl() == TRUE)
918     {
919         return CAMERA_SetLEDCore(isBlink);
920     }
921     return CAMERA_RESULT_FATAL_ERROR;
922 }
923 
924 /*---------------------------------------------------------------------------*
925   Name:         CAMERA_SwitchOffLEDAsync
926 
927   Description:  Turns off the camera indicator LED once.
928                 This results in the same behavior as calling CAMERA_SetLED(TRUE) and CAMERA_SetLED(FALSE) in succession.
929 
930 
931   Arguments:    callback: Specifies the function to be called when the asynchronous process has completed.
932                 arg: Specifies the arguments to the callback function when it is invoked.
933 
934   Returns:      CAMERAResult
935  *---------------------------------------------------------------------------*/
CAMERA_SwitchOffLEDAsync(CAMERACallback callback,void * arg)936 SDK_INLINE CAMERAResult CAMERA_SwitchOffLEDAsync(CAMERACallback callback, void *arg)
937 {
938     if (OS_IsRunOnTwl() == TRUE)
939     {
940         return CAMERA_SwitchOffLEDAsyncCore(callback, arg);
941     }
942     return CAMERA_RESULT_FATAL_ERROR;
943 }
944 
945 /*---------------------------------------------------------------------------*
946   Name:         CAMERA_SwitchOffLED
947 
948   Description:  Turns off the camera indicator LED once.
949                 This results in the same behavior as calling CAMERA_SetLED(TRUE) and CAMERA_SetLED(FALSE) in succession.
950 
951 
952   Arguments:    None.
953 
954   Returns:      CAMERAResult
955  *---------------------------------------------------------------------------*/
CAMERA_SwitchOffLED()956 SDK_INLINE CAMERAResult CAMERA_SwitchOffLED()
957 {
958     if (OS_IsRunOnTwl() == TRUE)
959     {
960         return CAMERA_SwitchOffLEDCore();
961     }
962     return CAMERA_RESULT_FATAL_ERROR;
963 }
964 
965 /*---------------------------------------------------------------------------*
966   Name:         CAMERA_SetVsynCallback
967 
968   Description:  Registers a callback function to invoke when a camera VSync interrupt occurs.
969 
970   Arguments:    callback: The callback function to register
971 
972   Returns:      None.
973  *---------------------------------------------------------------------------*/
CAMERA_SetVsyncCallback(CAMERAIntrCallback callback)974 SDK_INLINE void CAMERA_SetVsyncCallback(CAMERAIntrCallback callback)
975 {
976     if (OS_IsRunOnTwl() == TRUE)
977     {
978         CAMERA_SetVsyncCallbackCore(callback);
979     }
980 }
981 
982 /*---------------------------------------------------------------------------*
983   Name:         CAMERA_SetBufferErrorCallback
984 
985   Description:  Registers a callback function to invoke when a camera buffer error interrupt occurs.
986 
987   Arguments:    callback: The callback function to register
988 
989   Returns:      None.
990  *---------------------------------------------------------------------------*/
CAMERA_SetBufferErrorCallback(CAMERAIntrCallback callback)991 SDK_INLINE void CAMERA_SetBufferErrorCallback(CAMERAIntrCallback callback)
992 {
993     if (OS_IsRunOnTwl() == TRUE)
994     {
995         CAMERA_SetBufferErrorCallbackCore(callback);
996     }
997 }
998 
999 /*---------------------------------------------------------------------------*
1000   Name:         CAMERA_SetRebootCallback
1001 
1002   Description:  Registers a callback function to invoke when the process of recovering from a camera malfunction is complete.
1003 
1004   Arguments:    callback: The callback function to register
1005 
1006   Returns:      None.
1007  *---------------------------------------------------------------------------*/
CAMERA_SetRebootCallback(CAMERAIntrCallback callback)1008 SDK_INLINE void CAMERA_SetRebootCallback(CAMERAIntrCallback callback)
1009 {
1010     if (OS_IsRunOnTwl() == TRUE)
1011     {
1012         CAMERA_SetRebootCallbackCore(callback);
1013     }
1014 }
1015 
1016 /*===========================================================================*/
1017 
1018 #ifdef __cplusplus
1019 } /* extern "C" */
1020 #endif
1021 
1022 #endif /* TWL_CAMERA_CAMERA_API_H_ */
1023