wut  v1.7.0
Wii U Toolchain
camera.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include <coreinit/thread.h>
4 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #define CAMERA_WIDTH 640
16 #define CAMERA_PITCH 768
17 #define CAMERA_HEIGHT 480
18 
19 #define CAMERA_Y_BUFFER_SIZE (CAMERA_PITCH * CAMERA_HEIGHT)
20 #define CAMERA_UV_BUFFER_SIZE (CAMERA_PITCH * CAMERA_HEIGHT / 2)
21 #define CAMERA_YUV_BUFFER_SIZE (CAMERA_Y_BUFFER_SIZE + CAMERA_UV_BUFFER_SIZE)
22 
23 #define CAMERA_YUV_BUFFER_ALIGNMENT 256
24 
25 typedef int CAMHandle;
26 typedef int CAMError;
27 
28 typedef struct CAMEventData CAMEventData;
29 typedef struct CAMMode CAMMode;
30 typedef struct CAMWorkMem CAMWorkMem;
31 typedef struct CAMStreamInfo CAMStreamInfo;
32 typedef struct CAMSetupInfo CAMSetupInfo;
33 typedef struct CAMSurface CAMSurface;
34 
35 typedef enum CamError
36 {
50 
51 typedef enum CamFps
52 {
54  CAMERA_FPS_30 = 1
56 
57 typedef enum CamStreamType
58 {
61 
62 typedef enum CamEventType
63 {
67 
69 {
72  union
73  {
74  struct
75  {
82  } decode;
83  struct
84  {
89  } detach;
91  uint32_t args[3];
92  };
93 };
94 WUT_CHECK_OFFSET(CAMEventData, 0x00, eventType);
95 WUT_CHECK_OFFSET(CAMEventData, 0x04, decode.surfaceBuffer);
96 WUT_CHECK_OFFSET(CAMEventData, 0x08, decode.handle);
97 WUT_CHECK_OFFSET(CAMEventData, 0x0c, decode.failed);
98 WUT_CHECK_OFFSET(CAMEventData, 0x04, detach.connected);
99 WUT_CHECK_OFFSET(CAMEventData, 0x08, detach.handle);
100 WUT_CHECK_OFFSET(CAMEventData, 0x04, args);
101 WUT_CHECK_SIZE(CAMEventData, 0x10);
102 
103 typedef void(*CAMEventHandler)(CAMEventData *camEventData);
104 
105 struct CAMMode
106 {
111 };
112 WUT_CHECK_OFFSET(CAMMode, 0x00, forceDrc);
113 WUT_CHECK_OFFSET(CAMMode, 0x04, fps);
114 WUT_CHECK_SIZE(CAMMode, 0x08);
115 
117 {
119  uint32_t size;
121  void *pMem;
122 };
123 WUT_CHECK_OFFSET(CAMWorkMem, 0x00, size);
124 WUT_CHECK_OFFSET(CAMWorkMem, 0x04, pMem);
125 WUT_CHECK_SIZE(CAMWorkMem, 0x08);
126 
128 {
132  uint32_t height;
134  uint32_t width;
135 };
136 WUT_CHECK_OFFSET(CAMStreamInfo, 0x00, type);
137 WUT_CHECK_OFFSET(CAMStreamInfo, 0x04, height);
138 WUT_CHECK_OFFSET(CAMStreamInfo, 0x08, width);
139 WUT_CHECK_SIZE(CAMStreamInfo, 0x0C);
140 
142 {
152  uint32_t threadAffinity;
153  WUT_PADDING_BYTES(0x10);
154 };
155 WUT_CHECK_OFFSET(CAMSetupInfo, 0x00, streamInfo);
156 WUT_CHECK_OFFSET(CAMSetupInfo, 0x0C, workMem);
157 WUT_CHECK_OFFSET(CAMSetupInfo, 0x14, eventHandler);
158 WUT_CHECK_OFFSET(CAMSetupInfo, 0x18, mode);
159 WUT_CHECK_OFFSET(CAMSetupInfo, 0x20, threadAffinity);
160 WUT_CHECK_SIZE(CAMSetupInfo, 0x34);
161 
163 {
165  int32_t surfaceSize;
169  int32_t height;
171  int32_t width;
173  int32_t pitch;
175  int32_t alignment;
177  int32_t tileMode;
179  int32_t pixelFormat;
180 };
181 WUT_CHECK_OFFSET(CAMSurface, 0x00, surfaceSize);
182 WUT_CHECK_OFFSET(CAMSurface, 0x04, surfaceBuffer);
183 WUT_CHECK_OFFSET(CAMSurface, 0x08, height);
184 WUT_CHECK_OFFSET(CAMSurface, 0x0C, width);
185 WUT_CHECK_OFFSET(CAMSurface, 0x10, pitch);
186 WUT_CHECK_OFFSET(CAMSurface, 0x14, alignment);
187 WUT_CHECK_OFFSET(CAMSurface, 0x18, tileMode);
188 WUT_CHECK_OFFSET(CAMSurface, 0x1C, pixelFormat);
189 WUT_CHECK_SIZE(CAMSurface, 0x20);
190 
195 CAMHandle
196 CAMInit(int instance, CAMSetupInfo *setupInfo, CAMError *err);
197 
201 void
203 
207 CAMError
209 
214 CAMError
216 
222 int32_t
224 
231 CAMError
233 
237 CAMError
238 CAMCheckMemSegmentation(void *pMem, uint32_t size);
239 
240 #ifdef __cplusplus
241 }
242 #endif
void CAMExit(CAMHandle handle)
Deinitialize and clean up.
CAMEventHandler eventHandler
Event handler.
Definition: camera.h:148
uint32_t width
Stream width.
Definition: camera.h:134
BOOL forceDrc
If TRUE, the GamePad will display the camera output regardless of what is being rendered.
Definition: camera.h:108
CamEventType eventType
Event type.
Definition: camera.h:71
int32_t width
Surface width.
Definition: camera.h:171
CAMWorkMem workMem
Memory used by library to record and decode frames.
Definition: camera.h:146
CAMError CAMCheckMemSegmentation(void *pMem, uint32_t size)
Checks whether memory is segmented correctly to be used with the camera library.
CAMStreamInfo streamInfo
Stream info.
Definition: camera.h:144
uint32_t threadAffinity
See OS_THREAD_ATTRIB.
Definition: camera.h:152
CAMError CAMClose(CAMHandle handle)
Stops recording and decoding.
CamFps fps
Framerate setting.
Definition: camera.h:110
CamStreamType
Definition: camera.h:58
CAMHandle CAMInit(int instance, CAMSetupInfo *setupInfo, CAMError *err)
Initialize the camera.
int32_t surfaceSize
Number of bytes allocated to surface buffer.
Definition: camera.h:165
int32_t height
Surface height.
Definition: camera.h:169
CamEventType
Definition: camera.h:63
uint32_t height
Stream height.
Definition: camera.h:132
int32_t alignment
Surface alignment.
Definition: camera.h:175
int32_t tileMode
Tile mode, should be zero.
Definition: camera.h:177
int32_t pitch
Surface pitch.
Definition: camera.h:173
int32_t pixelFormat
Pixel format, Should be zero.
Definition: camera.h:179
CAMError CAMOpen(CAMHandle handle)
Start recording and decoding frames.
void(* CAMEventHandler)(CAMEventData *camEventData)
Definition: camera.h:103
int CAMHandle
Definition: camera.h:25
void * surfaceBuffer
Pointer to the buffer of the decoded image.
Definition: camera.h:77
CamError
Definition: camera.h:36
uint32_t size
Size of the work memory.
Definition: camera.h:119
int32_t CAMGetMemReq(CAMStreamInfo *streamInfo)
Get the number of bytes requied by the work memory.
CAMMode mode
Camera mode.
Definition: camera.h:150
BOOL connected
Will be FALSE.
Definition: camera.h:86
int CAMError
Definition: camera.h:26
CamStreamType type
Stream type, only CAMERA_STREAM_TYPE_1 is valid.
Definition: camera.h:130
CamFps
Definition: camera.h:52
CAMHandle handle
Handle of instance.
Definition: camera.h:79
void * pMem
Pointer to the work memory.
Definition: camera.h:121
CAMError CAMSubmitTargetSurface(CAMHandle handle, CAMSurface *surface)
Submit 1 surface to the working queue.
BOOL failed
TRUE if decode failed.
Definition: camera.h:81
@ CAMERA_STREAM_TYPE_1
Definition: camera.h:59
@ CAMERA_DECODE_DONE
Definition: camera.h:64
@ CAMERA_DRC_DETACH
Definition: camera.h:65
@ CAMERA_ERROR_INVALID_ARG
Definition: camera.h:38
@ CAMERA_ERROR_TOO_MANY_SURFACES
Definition: camera.h:40
@ CAMERA_ERROR_UVD_SESSION
Definition: camera.h:47
@ CAMERA_ERROR_INVALID_HANDLE
Definition: camera.h:39
@ CAMERA_ERROR_UVD_CONTEXT
Definition: camera.h:45
@ CAMERA_ERROR_OK
Definition: camera.h:37
@ CAMERA_ERROR_DEVICE_IN_USE
Definition: camera.h:46
@ CAMERA_ERROR_NOT_READY
Definition: camera.h:42
@ CAMERA_ERROR_UNINITIALIZED
Definition: camera.h:43
@ CAMERA_ERROR_INSUFFICIENT_MEMORY
Definition: camera.h:41
@ CAMERA_ERROR_UVC
Definition: camera.h:44
@ CAMERA_ERROR_SEGMENT_VIOLATION
Definition: camera.h:48
@ CAMERA_FPS_30
Definition: camera.h:54
@ CAMERA_FPS_15
Definition: camera.h:53
int32_t BOOL
Definition: wut_types.h:7