libctru  v1.6.0
cam.h
Go to the documentation of this file.
1 /**
2  * @file cam.h
3  * @brief CAM service for using the 3DS's front and back cameras.
4  */
5 #pragma once
6 
7 #include <3ds/services/y2r.h>
8 #include <3ds/types.h>
9 
10 /// Camera connection target ports.
11 enum {
12  PORT_NONE = 0x0, ///< No port.
13  PORT_CAM1 = BIT(0), ///< CAM1 port.
14  PORT_CAM2 = BIT(1), ///< CAM2 port.
15 
16  // Port combinations.
17  PORT_BOTH = PORT_CAM1 | PORT_CAM2, ///< Both ports.
18 };
19 
20 /// Camera combinations.
21 enum {
22  SELECT_NONE = 0x0, ///< No camera.
23  SELECT_OUT1 = BIT(0), ///< Outer camera 1.
24  SELECT_IN1 = BIT(1), ///< Inner camera 1.
25  SELECT_OUT2 = BIT(2), ///< Outer camera 2.
26 
27  // Camera combinations.
28  SELECT_IN1_OUT1 = SELECT_OUT1 | SELECT_IN1, ///< Outer camera 1 and inner camera 1.
29  SELECT_OUT1_OUT2 = SELECT_OUT1 | SELECT_OUT2, ///< Both outer cameras.
30  SELECT_IN1_OUT2 = SELECT_IN1 | SELECT_OUT2, ///< Inner camera 1 and outer camera 2.
31  SELECT_ALL = SELECT_OUT1 | SELECT_IN1 | SELECT_OUT2, ///< All cameras.
32 };
33 
34 /// Camera contexts.
35 typedef enum {
36  CONTEXT_NONE = 0x0, ///< No context.
37  CONTEXT_A = BIT(0), ///< Context A.
38  CONTEXT_B = BIT(1), ///< Context B.
39 
40  // Context combinations.
41  CONTEXT_BOTH = CONTEXT_A | CONTEXT_B, ///< Both contexts.
42 } CAMU_Context;
43 
44 /// Ways to flip the camera image.
45 typedef enum {
46  FLIP_NONE = 0x0, ///< No flip.
47  FLIP_HORIZONTAL = 0x1, ///< Horizontal flip.
48  FLIP_VERTICAL = 0x2, ///< Vertical flip.
49  FLIP_REVERSE = 0x3, ///< Reverse flip.
50 } CAMU_Flip;
51 
52 /// Camera image resolutions.
53 typedef enum {
54  SIZE_VGA = 0x0, ///< VGA size. (640x480)
55  SIZE_QVGA = 0x1, ///< QVGA size. (320x240)
56  SIZE_QQVGA = 0x2, ///< QQVGA size. (160x120)
57  SIZE_CIF = 0x3, ///< CIF size. (352x288)
58  SIZE_QCIF = 0x4, ///< QCIF size. (176x144)
59  SIZE_DS_LCD = 0x5, ///< DS LCD size. (256x192)
60  SIZE_DS_LCDx4 = 0x6, ///< DS LCD x4 size. (512x384)
61  SIZE_CTR_TOP_LCD = 0x7, ///< CTR Top LCD size. (400x240)
62 
63  // Alias for bottom screen to match top screen naming.
64  SIZE_CTR_BOTTOM_LCD = SIZE_QVGA, ///< CTR Bottom LCD size. (320x240)
65 } CAMU_Size;
66 
67 /// Camera capture frame rates.
68 typedef enum {
69  FRAME_RATE_15 = 0x0, ///< 15 FPS.
70  FRAME_RATE_15_TO_5 = 0x1, ///< 15-5 FPS.
71  FRAME_RATE_15_TO_2 = 0x2, ///< 15-2 FPS.
72  FRAME_RATE_10 = 0x3, ///< 10 FPS.
73  FRAME_RATE_8_5 = 0x4, ///< 8.5 FPS.
74  FRAME_RATE_5 = 0x5, ///< 5 FPS.
75  FRAME_RATE_20 = 0x6, ///< 20 FPS.
76  FRAME_RATE_20_TO_5 = 0x7, ///< 20-5 FPS.
77  FRAME_RATE_30 = 0x8, ///< 30 FPS.
78  FRAME_RATE_30_TO_5 = 0x9, ///< 30-5 FPS.
79  FRAME_RATE_15_TO_10 = 0xA, ///< 15-10 FPS.
80  FRAME_RATE_20_TO_10 = 0xB, ///< 20-10 FPS.
81  FRAME_RATE_30_TO_10 = 0xC, ///< 30-10 FPS.
83 
84 /// Camera white balance modes.
85 typedef enum {
86  WHITE_BALANCE_AUTO = 0x0, ///< Auto white balance.
87  WHITE_BALANCE_3200K = 0x1, ///< 3200K white balance.
88  WHITE_BALANCE_4150K = 0x2, ///< 4150K white balance.
89  WHITE_BALANCE_5200K = 0x3, ///< 5200K white balance.
90  WHITE_BALANCE_6000K = 0x4, ///< 6000K white balance.
91  WHITE_BALANCE_7000K = 0x5, ///< 7000K white balance.
92 
93  // White balance aliases.
94  WHITE_BALANCE_NORMAL = WHITE_BALANCE_AUTO, // Normal white balance. (AUTO)
95  WHITE_BALANCE_TUNGSTEN = WHITE_BALANCE_3200K, // Tungsten white balance. (3200K)
96  WHITE_BALANCE_WHITE_FLUORESCENT_LIGHT = WHITE_BALANCE_4150K, // Fluorescent white balance. (4150K)
97  WHITE_BALANCE_DAYLIGHT = WHITE_BALANCE_5200K, // Daylight white balance. (5200K)
98  WHITE_BALANCE_CLOUDY = WHITE_BALANCE_6000K, // Cloudy white balance. (6000K)
99  WHITE_BALANCE_HORIZON = WHITE_BALANCE_6000K, // Horizon white balance. (6000K)
100  WHITE_BALANCE_SHADE = WHITE_BALANCE_7000K, // Shade white balance. (7000K)
102 
103 /// Camera photo modes.
104 typedef enum {
105  PHOTO_MODE_NORMAL = 0x0, ///< Normal mode.
106  PHOTO_MODE_PORTRAIT = 0x1, ///< Portrait mode.
107  PHOTO_MODE_LANDSCAPE = 0x2, ///< Landscape mode.
108  PHOTO_MODE_NIGHTVIEW = 0x3, ///< Night mode.
109  PHOTO_MODE_LETTER = 0x4, ///< Letter mode.
111 
112 /// Camera special effects.
113 typedef enum {
114  EFFECT_NONE = 0x0, ///< No effects.
115  EFFECT_MONO = 0x1, ///< Mono effect.
116  EFFECT_SEPIA = 0x2, ///< Sepia effect.
117  EFFECT_NEGATIVE = 0x3, ///< Negative effect.
118  EFFECT_NEGAFILM = 0x4, ///< Negative film effect.
119  EFFECT_SEPIA01 = 0x5, ///< Sepia effect.
120 } CAMU_Effect;
121 
122 /// Camera contrast patterns.
123 typedef enum {
124  CONTRAST_PATTERN_01 = 0x0, ///< Pattern 1.
125  CONTRAST_PATTERN_02 = 0x1, ///< Pattern 2.
126  CONTRAST_PATTERN_03 = 0x2, ///< Pattern 3.
127  CONTRAST_PATTERN_04 = 0x3, ///< Pattern 4.
128  CONTRAST_PATTERN_05 = 0x4, ///< Pattern 5.
129  CONTRAST_PATTERN_06 = 0x5, ///< Pattern 6.
130  CONTRAST_PATTERN_07 = 0x6, ///< Pattern 7.
131  CONTRAST_PATTERN_08 = 0x7, ///< Pattern 8.
132  CONTRAST_PATTERN_09 = 0x8, ///< Pattern 9.
133  CONTRAST_PATTERN_10 = 0x9, ///< Pattern 10.
134  CONTRAST_PATTERN_11 = 0xA, ///< Pattern 11.
135 
136  // Contrast aliases.
137  CONTRAST_LOW = CONTRAST_PATTERN_05, ///< Low contrast. (5)
138  CONTRAST_NORMAL = CONTRAST_PATTERN_06, ///< Normal contrast. (6)
139  CONTRAST_HIGH = CONTRAST_PATTERN_07, ///< High contrast. (7)
140 } CAMU_Contrast;
141 
142 /// Camera lens correction modes.
143 typedef enum {
144  LENS_CORRECTION_OFF = 0x0, ///< No lens correction.
145  LENS_CORRECTION_ON_70 = 0x1, ///< Edge-to-center brightness ratio of 70.
146  LENS_CORRECTION_ON_90 = 0x2, ///< Edge-to-center brightness ratio of 90.
147 
148  // Lens correction aliases.
149  LENS_CORRECTION_DARK = LENS_CORRECTION_OFF, ///< Dark lens correction. (OFF)
150  LENS_CORRECTION_NORMAL = LENS_CORRECTION_ON_70, ///< Normal lens correction. (70)
151  LENS_CORRECTION_BRIGHT = LENS_CORRECTION_ON_90, ///< Bright lens correction. (90)
153 
154 /// Camera image output formats.
155 typedef enum {
156  OUTPUT_YUV_422 = 0x0, ///< YUV422
157  OUTPUT_RGB_565 = 0x1, ///< RGB565
159 
160 /// Camera shutter sounds.
161 typedef enum {
162  SHUTTER_SOUND_TYPE_NORMAL = 0x0, ///< Normal shutter sound.
163  SHUTTER_SOUND_TYPE_MOVIE = 0x1, ///< Shutter sound to begin a movie.
164  SHUTTER_SOUND_TYPE_MOVIE_END = 0x2, ///< Shutter sound to end a movie.
166 
167 /// Image quality calibration data.
168 typedef struct {
169  s16 aeBaseTarget; ///< Auto exposure base target brightness.
170  s16 kRL; ///< Left color correction matrix red normalization coefficient.
171  s16 kGL; ///< Left color correction matrix green normalization coefficient.
172  s16 kBL; ///< Left color correction matrix blue normalization coefficient.
173  s16 ccmPosition; ///< Color correction matrix position.
174  u16 awbCcmL9Right; ///< Right camera, left color correction matrix red/green gain.
175  u16 awbCcmL9Left; ///< Left camera, left color correction matrix red/green gain.
176  u16 awbCcmL10Right; ///< Right camera, left color correction matrix blue/green gain.
177  u16 awbCcmL10Left; ///< Left camera, left color correction matrix blue/green gain.
178  u16 awbX0Right; ///< Right camera, color correction matrix position threshold.
179  u16 awbX0Left; ///< Left camera, color correction matrix position threshold.
181 
182 /// Stereo camera calibration data.
183 typedef struct {
184  u8 isValidRotationXY; ///< #bool Whether the X and Y rotation data is valid.
185  u8 padding[3]; ///< Padding. (Aligns isValidRotationXY to 4 bytes)
186  float scale; ///< Scale to match the left camera image with the right.
187  float rotationZ; ///< Z axis rotation to match the left camera image with the right.
188  float translationX; ///< X axis translation to match the left camera image with the right.
189  float translationY; ///< Y axis translation to match the left camera image with the right.
190  float rotationX; ///< X axis rotation to match the left camera image with the right.
191  float rotationY; ///< Y axis rotation to match the left camera image with the right.
192  float angleOfViewRight; ///< Right camera angle of view.
193  float angleOfViewLeft; ///< Left camera angle of view.
194  float distanceToChart; ///< Distance between cameras and measurement chart.
195  float distanceCameras; ///< Distance between left and right cameras.
196  s16 imageWidth; ///< Image width.
197  s16 imageHeight; ///< Image height.
198  u8 reserved[16]; ///< Reserved for future use. (unused)
200 
201 /// Batch camera configuration for use without a context.
202 typedef struct {
203  u8 camera; ///< Selected camera.
204  s8 exposure; ///< Camera exposure.
205  u8 whiteBalance; ///< #CAMU_WhiteBalance Camera white balance.
206  s8 sharpness; ///< Camera sharpness.
207  u8 autoExposureOn; ///< #bool Whether to automatically determine the proper exposure.
208  u8 autoWhiteBalanceOn; ///< #bool Whether to automatically determine the white balance mode.
209  u8 frameRate; ///< #CAMU_FrameRate Camera frame rate.
210  u8 photoMode; ///< #CAMU_PhotoMode Camera photo mode.
211  u8 contrast; ///< #CAMU_Contrast Camera contrast.
212  u8 lensCorrection; ///< #CAMU_LensCorrection Camera lens correction.
213  u8 noiseFilterOn; ///< #bool Whether to enable the camera's noise filter.
214  u8 padding; ///< Padding. (Aligns last 3 fields to 4 bytes)
215  s16 autoExposureWindowX; ///< X of the region to use for auto exposure.
216  s16 autoExposureWindowY; ///< Y of the region to use for auto exposure.
217  s16 autoExposureWindowWidth; ///< Width of the region to use for auto exposure.
218  s16 autoExposureWindowHeight; ///< Height of the region to use for auto exposure.
219  s16 autoWhiteBalanceWindowX; ///< X of the region to use for auto white balance.
220  s16 autoWhiteBalanceWindowY; ///< Y of the region to use for auto white balance.
221  s16 autoWhiteBalanceWindowWidth; ///< Width of the region to use for auto white balance.
222  s16 autoWhiteBalanceWindowHeight; ///< Height of the region to use for auto white balance.
224 
225 /// Batch camera configuration for use with a context.
226 typedef struct {
227  u8 camera; ///< Selected camera.
228  u8 context; ///< #CAMU_Context Selected context.
229  u8 flip; ///< #CAMU_Flip Camera image flip mode.
230  u8 effect; ///< #CAMU_Effect Camera image special effects.
231  u8 size; ///< #CAMU_Size Camera image resolution.
233 
234 /// Batch camera configuration for use with a context and with detailed size information.
235 typedef struct {
236  u8 camera; ///< Selected camera.
237  u8 context; ///< #CAMU_Context Selected context.
238  u8 flip; ///< #CAMU_Flip Camera image flip mode.
239  u8 effect; ///< #CAMU_Effect Camera image special effects.
240  s16 width; ///< Image width.
241  s16 height; ///< Image height.
242  s16 cropX0; ///< First crop point X.
243  s16 cropY0; ///< First crop point Y.
244  s16 cropX1; ///< Second crop point X.
245  s16 cropY1; ///< Second crop point Y.
247 
248 /**
249  * @brief Initializes the cam service.
250  *
251  * This will internally get the handle of the service, and on success call CAMU_DriverInitialize.
252  */
253 Result camInit(void);
254 
255 /**
256  * @brief Closes the cam service.
257  *
258  * This will internally call CAMU_DriverFinalize and close the handle of the service.
259  */
260 void camExit(void);
261 
262 /**
263  * Begins capture on the specified camera port.
264  * @param port Port to begin capture on.
265  */
267 
268 /**
269  * Terminates capture on the specified camera port.
270  * @param port Port to terminate capture on.
271  */
273 
274 /**
275  * @brief Gets whether the specified camera port is busy.
276  * @param busy Pointer to output the busy state to.
277  * @param port Port to check.
278  */
279 Result CAMU_IsBusy(bool* busy, u32 port);
280 
281 /**
282  * @brief Clears the buffer and error flags of the specified camera port.
283  * @param port Port to clear.
284  */
286 
287 /**
288  * @brief Gets a handle to the event signaled on vsync interrupts.
289  * @param event Pointer to output the event handle to.
290  * @param port Port to use.
291  */
293 
294 /**
295  * @brief Gets a handle to the event signaled on camera buffer errors.
296  * @param event Pointer to output the event handle to.
297  * @param port Port to use.
298  */
300 
301 /**
302  * @brief Initiates the process of receiving a camera frame.
303  * @param event Pointer to output the completion event handle to.
304  * @param dst Buffer to write data to.
305  * @param port Port to receive from.
306  * @param imageSize Size of the image to receive.
307  * @param transferUnit Transfer unit to use when receiving.
308  */
309 Result CAMU_SetReceiving(Handle* event, void* dst, u32 port, u32 imageSize, s16 transferUnit);
310 
311 /**
312  * @brief Gets whether the specified camera port has finished receiving image data.
313  * @param finishedReceiving Pointer to output the receiving status to.
314  * @param port Port to check.
315  */
316 Result CAMU_IsFinishedReceiving(bool* finishedReceiving, u32 port);
317 
318 /**
319  * @brief Sets the number of lines to transfer into an image buffer.
320  * @param port Port to use.
321  * @param lines Lines to transfer.
322  * @param width Width of the image.
323  * @param height Height of the image.
324  */
325 Result CAMU_SetTransferLines(u32 port, s16 lines, s16 width, s16 height);
326 
327 /**
328  * @brief Gets the maximum number of lines that can be saved to an image buffer.
329  * @param maxLines Pointer to write the maximum number of lines to.
330  * @param width Width of the image.
331  * @param height Height of the image.
332  */
333 Result CAMU_GetMaxLines(s16* maxLines, s16 width, s16 height);
334 
335 /**
336  * @brief Sets the number of bytes to transfer into an image buffer.
337  * @param port Port to use.
338  * @param bytes Bytes to transfer.
339  * @param width Width of the image.
340  * @param height Height of the image.
341  */
342 Result CAMU_SetTransferBytes(u32 port, u32 bytes, s16 width, s16 height);
343 
344 /**
345  * @brief Gets the number of bytes to transfer into an image buffer.
346  * @param transferBytes Pointer to write the number of bytes to.
347  * @param port Port to use.
348  */
349 Result CAMU_GetTransferBytes(u32* transferBytes, u32 port);
350 
351 /**
352  * @brief Gets the maximum number of bytes that can be saved to an image buffer.
353  * @param maxBytes Pointer to write the maximum number of bytes to.
354  * @param width Width of the image.
355  * @param height Height of the image.
356  */
357 Result CAMU_GetMaxBytes(u32* maxBytes, s16 width, s16 height);
358 
359 /**
360  * @brief Sets whether image trimming is enabled.
361  * @param port Port to use.
362  * @param trimming Whether image trimming is enabled.
363  */
364 Result CAMU_SetTrimming(u32 port, bool trimming);
365 
366 /**
367  * @brief Gets whether image trimming is enabled.
368  * @param trimming Pointer to output the trim state to.
369  * @param port Port to use.
370  */
371 Result CAMU_IsTrimming(bool* trimming, u32 port);
372 
373 /**
374  * @brief Sets the parameters used for trimming images.
375  * @param port Port to use.
376  * @param xStart Start X coordinate.
377  * @param yStart Start Y coordinate.
378  * @param xEnd End X coordinate.
379  * @param yEnd End Y coordinate.
380  */
381 Result CAMU_SetTrimmingParams(u32 port, s16 xStart, s16 yStart, s16 xEnd, s16 yEnd);
382 
383 /**
384  * @brief Gets the parameters used for trimming images.
385  * @param xStart Pointer to write the start X coordinate to.
386  * @param yStart Pointer to write the start Y coordinate to.
387  * @param xEnd Pointer to write the end X coordinate to.
388  * @param yEnd Pointer to write the end Y coordinate to.
389  * @param port Port to use.
390  */
391 Result CAMU_GetTrimmingParams(s16* xStart, s16* yStart, s16* xEnd, s16* yEnd, u32 port);
392 
393 /**
394  * @brief Sets the parameters used for trimming images, relative to the center of the image.
395  * @param port Port to use.
396  * @param trimWidth Trim width.
397  * @param trimHeight Trim height.
398  * @param camWidth Camera width.
399  * @param camHeight Camera height.
400  */
401 Result CAMU_SetTrimmingParamsCenter(u32 port, s16 trimWidth, s16 trimHeight, s16 camWidth, s16 camHeight);
402 
403 /**
404  * @brief Activates the specified camera.
405  * @param select Camera to use.
406  */
407 Result CAMU_Activate(u32 select);
408 
409 /**
410  * @brief Switches the specified camera's active context.
411  * @param select Camera to use.
412  * @param context Context to use.
413  */
414 Result CAMU_SwitchContext(u32 select, CAMU_Context context);
415 
416 /**
417  * @brief Sets the exposure value of the specified camera.
418  * @param select Camera to use.
419  * @param exposure Exposure value to use.
420  */
421 Result CAMU_SetExposure(u32 select, s8 exposure);
422 
423 /**
424  * @brief Sets the white balance mode of the specified camera.
425  * @param select Camera to use.
426  * @param whiteBalance White balance mode to use.
427  */
428 Result CAMU_SetWhiteBalance(u32 select, CAMU_WhiteBalance whiteBalance);
429 
430 /**
431  * @brief Sets the white balance mode of the specified camera.
432  * TODO: Explain "without base up"?
433  * @param select Camera to use.
434  * @param whiteBalance White balance mode to use.
435  */
437 
438 /**
439  * @brief Sets the sharpness of the specified camera.
440  * @param select Camera to use.
441  * @param sharpness Sharpness to use.
442  */
443 Result CAMU_SetSharpness(u32 select, s8 sharpness);
444 
445 /**
446  * @brief Sets whether auto exposure is enabled on the specified camera.
447  * @param select Camera to use.
448  * @param autoWhiteBalance Whether auto exposure is enabled.
449  */
450 Result CAMU_SetAutoExposure(u32 select, bool autoExposure);
451 
452 /**
453  * @brief Gets whether auto exposure is enabled on the specified camera.
454  * @param autoExposure Pointer to output the auto exposure state to.
455  * @param select Camera to use.
456  */
457 Result CAMU_IsAutoExposure(bool* autoExposure, u32 select);
458 
459 /**
460  * @brief Sets whether auto white balance is enabled on the specified camera.
461  * @param select Camera to use.
462  * @param autoWhiteBalance Whether auto white balance is enabled.
463  */
464 Result CAMU_SetAutoWhiteBalance(u32 select, bool autoWhiteBalance);
465 
466 /**
467  * @brief Gets whether auto white balance is enabled on the specified camera.
468  * @param autoWhiteBalance Pointer to output the auto white balance state to.
469  * @param select Camera to use.
470  */
471 Result CAMU_IsAutoWhiteBalance(bool* autoWhiteBalance, u32 select);
472 
473 /**
474  * @brief Flips the image of the specified camera in the specified context.
475  * @param select Camera to use.
476  * @param flip Flip mode to use.
477  * @param context Context to use.
478  */
479 Result CAMU_FlipImage(u32 select, CAMU_Flip flip, CAMU_Context context);
480 
481 /**
482  * @brief Sets the image resolution of the given camera in the given context, in detail.
483  * @param select Camera to use.
484  * @param width Width to use.
485  * @param height Height to use.
486  * @param cropX0 First crop point X.
487  * @param cropY0 First crop point Y.
488  * @param cropX1 Second crop point X.
489  * @param cropY1 Second crop point Y.
490  * @param context Context to use.
491  */
492 Result CAMU_SetDetailSize(u32 select, s16 width, s16 height, s16 cropX0, s16 cropY0, s16 cropX1, s16 cropY1, CAMU_Context context);
493 
494 /**
495  * @brief Sets the image resolution of the given camera in the given context.
496  * @param select Camera to use.
497  * @param size Size to use.
498  * @param context Context to use.
499  */
500 Result CAMU_SetSize(u32 select, CAMU_Size size, CAMU_Context context);
501 
502 /**
503  * @brief Sets the frame rate of the given camera.
504  * @param select Camera to use.
505  * @param frameRate Frame rate to use.
506  */
507 Result CAMU_SetFrameRate(u32 select, CAMU_FrameRate frameRate);
508 
509 /**
510  * @brief Sets the photo mode of the given camera.
511  * @param select Camera to use.
512  * @param photoMode Photo mode to use.
513  */
514 Result CAMU_SetPhotoMode(u32 select, CAMU_PhotoMode photoMode);
515 
516 /**
517  * @brief Sets the special effects of the given camera in the given context.
518  * @param select Camera to use.
519  * @param effect Effect to use.
520  * @param context Context to use.
521  */
522 Result CAMU_SetEffect(u32 select, CAMU_Effect effect, CAMU_Context context);
523 
524 /**
525  * @brief Sets the contrast mode of the given camera.
526  * @param select Camera to use.
527  * @param contrast Contrast mode to use.
528  */
529 Result CAMU_SetContrast(u32 select, CAMU_Contrast contrast);
530 
531 /**
532  * @brief Sets the lens correction mode of the given camera.
533  * @param select Camera to use.
534  * @param lensCorrection Lens correction mode to use.
535  */
536 Result CAMU_SetLensCorrection(u32 select, CAMU_LensCorrection lensCorrection);
537 
538 /**
539  * @brief Sets the output format of the given camera in the given context.
540  * @param select Camera to use.
541  * @param format Format to output.
542  * @param context Context to use.
543  */
545 
546 /**
547  * @brief Sets the region to base auto exposure off of for the specified camera.
548  * @param select Camera to use.
549  * @param x X of the region.
550  * @param y Y of the region.
551  * @param width Width of the region.
552  * @param height Height of the region.
553  */
554 Result CAMU_SetAutoExposureWindow(u32 select, s16 x, s16 y, s16 width, s16 height);
555 
556 /**
557  * @brief Sets the region to base auto white balance off of for the specified camera.
558  * @param select Camera to use.
559  * @param x X of the region.
560  * @param y Y of the region.
561  * @param width Width of the region.
562  * @param height Height of the region.
563  */
564 Result CAMU_SetAutoWhiteBalanceWindow(u32 select, s16 x, s16 y, s16 width, s16 height);
565 
566 /**
567  * @brief Sets whether the specified camera's noise filter is enabled.
568  * @param select Camera to use.
569  * @param noiseFilter Whether the noise filter is enabled.
570  */
571 Result CAMU_SetNoiseFilter(u32 select, bool noiseFilter);
572 
573 /**
574  * @brief Synchronizes the specified cameras' vsync timing.
575  * @param select1 First camera.
576  * @param select2 Second camera.
577  */
578 Result CAMU_SynchronizeVsyncTiming(u32 select1, u32 select2);
579 
580 /**
581  * @brief Gets the vsync timing record of the specified camera for the specified number of signals.
582  * @param timing Pointer to write timing data to. (size "past * sizeof(s64)")
583  * @param port Port to use.
584  * @param past Number of past timings to retrieve.
585  */
586 Result CAMU_GetLatestVsyncTiming(s64* timing, u32 port, u32 past);
587 
588 /**
589  * @brief Gets the specified camera's stereo camera calibration data.
590  * @param data Pointer to output the stereo camera data to.
591  */
593 
594 /**
595  * @brief Sets the specified camera's stereo camera calibration data.
596  * @param data Data to set.
597  */
599 
600 /**
601  * @brief Writes to the specified I2C register of the specified camera.
602  * @param select Camera to write to.
603  * @param addr Address to write to.
604  * @param data Data to write.
605  */
606 Result CAMU_WriteRegisterI2c(u32 select, u16 addr, u16 data);
607 
608 /**
609  * @brief Writes to the specified MCU variable of the specified camera.
610  * @param select Camera to write to.
611  * @param addr Address to write to.
612  * @param data Data to write.
613  */
614 Result CAMU_WriteMcuVariableI2c(u32 select, u16 addr, u16 data);
615 
616 /**
617  * @brief Reads the specified I2C register of the specified camera.
618  * @param data Pointer to read data to.
619  * @param select Camera to read from.
620  * @param addr Address to read.
621  */
622 Result CAMU_ReadRegisterI2cExclusive(u16* data, u32 select, u16 addr);
623 
624 /**
625  * @brief Reads the specified MCU variable of the specified camera.
626  * @param data Pointer to read data to.
627  * @param select Camera to read from.
628  * @param addr Address to read.
629  */
630 Result CAMU_ReadMcuVariableI2cExclusive(u16* data, u32 select, u16 addr);
631 
632 /**
633  * @brief Sets the specified camera's image quality calibration data.
634  * @param data Data to set.
635  */
637 
638 /**
639  * @brief Gets the specified camera's image quality calibration data.
640  * @param data Pointer to write the quality data to.
641  */
643 
644 /**
645  * @brief Configures a camera with pre-packaged configuration data without a context.
646  * @param Parameter to use.
647  */
649 
650 /**
651  * @brief Configures a camera with pre-packaged configuration data with a context.
652  * @param Parameter to use.
653  */
655 
656 /**
657  * @brief Configures a camera with pre-packaged configuration data without a context and extra resolution details.
658  * @param Parameter to use.
659  */
661 
662 /**
663  * @brief Gets the Y2R coefficient applied to image data by the camera.
664  * @param coefficient Pointer to output the Y2R coefficient to.
665  */
667 
668 /**
669  * @brief Plays the specified shutter sound.
670  * @param sound Shutter sound to play.
671  */
673 
674 /// Initializes the camera driver.
676 
677 /// Finalizes the camera driver.
679 
680 /**
681  * @brief Gets the current activated camera.
682  * @param select Pointer to output the current activated camera to.
683  */
685 
686 /**
687  * @brief Gets the current sleep camera.
688  * @param select Pointer to output the current sleep camera to.
689  */
691 
692 /**
693  * @brief Sets the current sleep camera.
694  * @param select Camera to set.
695  */
697 
698 /**
699  * @brief Sets whether to enable synchronization of left and right camera brightnesses.
700  * @param brightnessSynchronization Whether to enable brightness synchronization.
701  */
702 Result CAMU_SetBrightnessSynchronization(bool brightnessSynchronization);
703 
s16 autoWhiteBalanceWindowWidth
Width of the region to use for auto white balance.
Definition: cam.h:221
s16 autoExposureWindowHeight
Height of the region to use for auto exposure.
Definition: cam.h:218
s16 imageWidth
Image width.
Definition: cam.h:196
15-10 FPS.
Definition: cam.h:79
Result CAMU_WriteMcuVariableI2c(u32 select, u16 addr, u16 data)
Writes to the specified MCU variable of the specified camera.
int8_t s8
8-bit signed integer
Definition: types.h:26
Result CAMU_SetAutoWhiteBalanceWindow(u32 select, s16 x, s16 y, s16 width, s16 height)
Sets the region to base auto white balance off of for the specified camera.
Result CAMU_ClearBuffer(u32 port)
Clears the buffer and error flags of the specified camera port.
No port.
Definition: cam.h:12
Various system types.
Result CAMU_SetTrimmingParamsCenter(u32 port, s16 trimWidth, s16 trimHeight, s16 camWidth, s16 camHeight)
Sets the parameters used for trimming images, relative to the center of the image.
Portrait mode.
Definition: cam.h:106
u8 photoMode
CAMU_PhotoMode Camera photo mode.
Definition: cam.h:210
Image quality calibration data.
Definition: cam.h:168
Batch camera configuration for use with a context.
Definition: cam.h:226
s16 imageHeight
Image height.
Definition: cam.h:197
s32 Result
Function result.
Definition: types.h:42
s16 autoExposureWindowWidth
Width of the region to use for auto exposure.
Definition: cam.h:217
Dark lens correction. (OFF)
Definition: cam.h:149
Pattern 4.
Definition: cam.h:127
Night mode.
Definition: cam.h:108
Result CAMU_ReadRegisterI2cExclusive(u16 *data, u32 select, u16 addr)
Reads the specified I2C register of the specified camera.
Result CAMU_IsFinishedReceiving(bool *finishedReceiving, u32 port)
Gets whether the specified camera port has finished receiving image data.
7000K white balance.
Definition: cam.h:91
u16 awbCcmL9Left
Left camera, left color correction matrix red/green gain.
Definition: cam.h:175
VGA size. (640x480)
Definition: cam.h:54
CAMU_FrameRate
Camera capture frame rates.
Definition: cam.h:68
8.5 FPS.
Definition: cam.h:73
u8 contrast
CAMU_Contrast Camera contrast.
Definition: cam.h:211
u8 camera
Selected camera.
Definition: cam.h:203
6000K white balance.
Definition: cam.h:90
s16 autoWhiteBalanceWindowX
X of the region to use for auto white balance.
Definition: cam.h:219
Result CAMU_SetWhiteBalance(u32 select, CAMU_WhiteBalance whiteBalance)
Sets the white balance mode of the specified camera.
15 FPS.
Definition: cam.h:69
Result CAMU_SetAutoExposureWindow(u32 select, s16 x, s16 y, s16 width, s16 height)
Sets the region to base auto exposure off of for the specified camera.
Result CAMU_Activate(u32 select)
Activates the specified camera.
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
Result CAMU_ReadMcuVariableI2cExclusive(u16 *data, u32 select, u16 addr)
Reads the specified MCU variable of the specified camera.
s16 autoWhiteBalanceWindowHeight
Height of the region to use for auto white balance.
Definition: cam.h:222
Horizontal flip.
Definition: cam.h:47
CAMU_Flip
Ways to flip the camera image.
Definition: cam.h:45
Inner camera 1.
Definition: cam.h:24
float angleOfViewLeft
Left camera angle of view.
Definition: cam.h:193
4150K white balance.
Definition: cam.h:88
3200K white balance.
Definition: cam.h:87
Result CAMU_SetPackageParameterWithContextDetail(CAMU_PackageParameterContextDetail param)
Configures a camera with pre-packaged configuration data without a context and extra resolution detai...
Inner camera 1 and outer camera 2.
Definition: cam.h:30
Result camInit(void)
Initializes the cam service.
s16 autoExposureWindowX
X of the region to use for auto exposure.
Definition: cam.h:215
Stereo camera calibration data.
Definition: cam.h:183
Context A.
Definition: cam.h:37
Both contexts.
Definition: cam.h:41
Result CAMU_GetActivatedCamera(u32 *select)
Gets the current activated camera.
float translationX
X axis translation to match the left camera image with the right.
Definition: cam.h:188
10 FPS.
Definition: cam.h:72
CAMU_OutputFormat
Camera image output formats.
Definition: cam.h:155
Result CAMU_FlipImage(u32 select, CAMU_Flip flip, CAMU_Context context)
Flips the image of the specified camera in the specified context.
u8 lensCorrection
CAMU_LensCorrection Camera lens correction.
Definition: cam.h:212
CAMU_ShutterSoundType
Camera shutter sounds.
Definition: cam.h:161
s16 kGL
Left color correction matrix green normalization coefficient.
Definition: cam.h:171
u16 awbX0Left
Left camera, color correction matrix position threshold.
Definition: cam.h:179
Normal mode.
Definition: cam.h:105
Result CAMU_SetPackageParameterWithoutContext(CAMU_PackageParameterCameraSelect param)
Configures a camera with pre-packaged configuration data without a context.
Result CAMU_DriverInitialize(void)
Initializes the camera driver.
Landscape mode.
Definition: cam.h:107
u32 Handle
Resource handle.
Definition: types.h:41
Result CAMU_SetFrameRate(u32 select, CAMU_FrameRate frameRate)
Sets the frame rate of the given camera.
s16 kRL
Left color correction matrix red normalization coefficient.
Definition: cam.h:170
Letter mode.
Definition: cam.h:109
Result CAMU_GetSuitableY2rStandardCoefficient(Y2RU_StandardCoefficient *coefficient)
Gets the Y2R coefficient applied to image data by the camera.
Result CAMU_SetBrightnessSynchronization(bool brightnessSynchronization)
Sets whether to enable synchronization of left and right camera brightnesses.
s16 cropX0
First crop point X.
Definition: cam.h:242
s16 ccmPosition
Color correction matrix position.
Definition: cam.h:173
Result CAMU_GetTrimmingParams(s16 *xStart, s16 *yStart, s16 *xEnd, s16 *yEnd, u32 port)
Gets the parameters used for trimming images.
Normal lens correction. (70)
Definition: cam.h:150
u8 padding
Padding. (Aligns last 3 fields to 4 bytes)
Definition: cam.h:214
CTR Bottom LCD size. (320x240)
Definition: cam.h:64
Result CAMU_SetTrimming(u32 port, bool trimming)
Sets whether image trimming is enabled.
Context B.
Definition: cam.h:38
Result CAMU_GetSleepCamera(u32 *select)
Gets the current sleep camera.
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
Both outer cameras.
Definition: cam.h:29
Result CAMU_SetAutoWhiteBalance(u32 select, bool autoWhiteBalance)
Sets whether auto white balance is enabled on the specified camera.
No effects.
Definition: cam.h:114
Pattern 11.
Definition: cam.h:134
s16 aeBaseTarget
Auto exposure base target brightness.
Definition: cam.h:169
u8 camera
Selected camera.
Definition: cam.h:236
u16 awbX0Right
Right camera, color correction matrix position threshold.
Definition: cam.h:178
s16 height
Image height.
Definition: cam.h:241
20-5 FPS.
Definition: cam.h:76
s16 width
Image width.
Definition: cam.h:240
Negative film effect.
Definition: cam.h:118
Negative effect.
Definition: cam.h:117
Pattern 6.
Definition: cam.h:129
DS LCD size. (256x192)
Definition: cam.h:59
Pattern 2.
Definition: cam.h:125
u8 effect
CAMU_Effect Camera image special effects.
Definition: cam.h:230
u8 context
CAMU_Context Selected context.
Definition: cam.h:237
CAMU_Contrast
Camera contrast patterns.
Definition: cam.h:123
Pattern 8.
Definition: cam.h:131
No flip.
Definition: cam.h:46
5 FPS.
Definition: cam.h:74
YUV422.
Definition: cam.h:156
u8 frameRate
CAMU_FrameRate Camera frame rate.
Definition: cam.h:209
uint32_t u32
32-bit unsigned integer
Definition: types.h:23
Result CAMU_IsAutoExposure(bool *autoExposure, u32 select)
Gets whether auto exposure is enabled on the specified camera.
Sepia effect.
Definition: cam.h:116
Result CAMU_IsAutoWhiteBalance(bool *autoWhiteBalance, u32 select)
Gets whether auto white balance is enabled on the specified camera.
DS LCD x4 size. (512x384)
Definition: cam.h:60
Result CAMU_DriverFinalize(void)
Finalizes the camera driver.
QVGA size. (320x240)
Definition: cam.h:55
Vertical flip.
Definition: cam.h:48
u8 whiteBalance
CAMU_WhiteBalance Camera white balance.
Definition: cam.h:205
30-5 FPS.
Definition: cam.h:78
Result CAMU_SetSleepCamera(u32 select)
Sets the current sleep camera.
Result CAMU_SetLensCorrection(u32 select, CAMU_LensCorrection lensCorrection)
Sets the lens correction mode of the given camera.
CIF size. (352x288)
Definition: cam.h:57
s16 cropX1
Second crop point X.
Definition: cam.h:244
30 FPS.
Definition: cam.h:77
float rotationY
Y axis rotation to match the left camera image with the right.
Definition: cam.h:191
Result CAMU_GetLatestVsyncTiming(s64 *timing, u32 port, u32 past)
Gets the vsync timing record of the specified camera for the specified number of signals.
Result CAMU_StartCapture(u32 port)
Begins capture on the specified camera port.
Result CAMU_SetSize(u32 select, CAMU_Size size, CAMU_Context context)
Sets the image resolution of the given camera in the given context.
Result CAMU_GetTransferBytes(u32 *transferBytes, u32 port)
Gets the number of bytes to transfer into an image buffer.
No lens correction.
Definition: cam.h:144
15-5 FPS.
Definition: cam.h:70
All cameras.
Definition: cam.h:31
Result CAMU_GetMaxBytes(u32 *maxBytes, s16 width, s16 height)
Gets the maximum number of bytes that can be saved to an image buffer.
Normal shutter sound.
Definition: cam.h:162
u8 size
CAMU_Size Camera image resolution.
Definition: cam.h:231
u8 noiseFilterOn
#bool Whether to enable the camera's noise filter.
Definition: cam.h:213
Result CAMU_SetAutoExposure(u32 select, bool autoExposure)
Sets whether auto exposure is enabled on the specified camera.
Result CAMU_SetReceiving(Handle *event, void *dst, u32 port, u32 imageSize, s16 transferUnit)
Initiates the process of receiving a camera frame.
Outer camera 1.
Definition: cam.h:23
u16 awbCcmL10Right
Right camera, left color correction matrix blue/green gain.
Definition: cam.h:176
float translationY
Y axis translation to match the left camera image with the right.
Definition: cam.h:189
Reverse flip.
Definition: cam.h:49
Result CAMU_SetSharpness(u32 select, s8 sharpness)
Sets the sharpness of the specified camera.
Result CAMU_SetTransferLines(u32 port, s16 lines, s16 width, s16 height)
Sets the number of lines to transfer into an image buffer.
30-10 FPS.
Definition: cam.h:81
No context.
Definition: cam.h:36
Result CAMU_WriteRegisterI2c(u32 select, u16 addr, u16 data)
Writes to the specified I2C register of the specified camera.
u8 flip
CAMU_Flip Camera image flip mode.
Definition: cam.h:229
Result CAMU_StopCapture(u32 port)
Terminates capture on the specified camera port.
Shutter sound to end a movie.
Definition: cam.h:164
float distanceToChart
Distance between cameras and measurement chart.
Definition: cam.h:194
CAMU_Context
Camera contexts.
Definition: cam.h:35
15-2 FPS.
Definition: cam.h:71
Low contrast. (5)
Definition: cam.h:137
Mono effect.
Definition: cam.h:115
Outer camera 2.
Definition: cam.h:25
s16 kBL
Left color correction matrix blue normalization coefficient.
Definition: cam.h:172
Result CAMU_SetEffect(u32 select, CAMU_Effect effect, CAMU_Context context)
Sets the special effects of the given camera in the given context.
Result CAMU_SetTrimmingParams(u32 port, s16 xStart, s16 yStart, s16 xEnd, s16 yEnd)
Sets the parameters used for trimming images.
No camera.
Definition: cam.h:22
u8 isValidRotationXY
#bool Whether the X and Y rotation data is valid.
Definition: cam.h:184
Result CAMU_SwitchContext(u32 select, CAMU_Context context)
Switches the specified camera's active context.
Both ports.
Definition: cam.h:17
CAMU_PhotoMode
Camera photo modes.
Definition: cam.h:104
Pattern 1.
Definition: cam.h:124
Result CAMU_PlayShutterSound(CAMU_ShutterSoundType sound)
Plays the specified shutter sound.
u16 awbCcmL10Left
Left camera, left color correction matrix blue/green gain.
Definition: cam.h:177
float distanceCameras
Distance between left and right cameras.
Definition: cam.h:195
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
CTR Top LCD size. (400x240)
Definition: cam.h:61
Result CAMU_GetBufferErrorInterruptEvent(Handle *event, u32 port)
Gets a handle to the event signaled on camera buffer errors.
Normal contrast. (6)
Definition: cam.h:138
Shutter sound to begin a movie.
Definition: cam.h:163
u16 awbCcmL9Right
Right camera, left color correction matrix red/green gain.
Definition: cam.h:174
Outer camera 1 and inner camera 1.
Definition: cam.h:28
CAMU_Size
Camera image resolutions.
Definition: cam.h:53
Result CAMU_SetWhiteBalanceWithoutBaseUp(u32 select, CAMU_WhiteBalance whiteBalance)
Sets the white balance mode of the specified camera.
int64_t s64
64-bit signed integer
Definition: types.h:29
Batch camera configuration for use with a context and with detailed size information.
Definition: cam.h:235
Result CAMU_SetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData data)
Sets the specified camera's image quality calibration data.
Result CAMU_SetContrast(u32 select, CAMU_Contrast contrast)
Sets the contrast mode of the given camera.
Result CAMU_SetPackageParameterWithContext(CAMU_PackageParameterContext param)
Configures a camera with pre-packaged configuration data with a context.
Y2R service for hardware YUV->RGB conversions.
CAM2 port.
Definition: cam.h:14
s16 autoWhiteBalanceWindowY
Y of the region to use for auto white balance.
Definition: cam.h:220
Result CAMU_SetPhotoMode(u32 select, CAMU_PhotoMode photoMode)
Sets the photo mode of the given camera.
s16 cropY0
First crop point Y.
Definition: cam.h:243
5200K white balance.
Definition: cam.h:89
QCIF size. (176x144)
Definition: cam.h:58
Bright lens correction. (90)
Definition: cam.h:151
s16 autoExposureWindowY
Y of the region to use for auto exposure.
Definition: cam.h:216
Result CAMU_GetVsyncInterruptEvent(Handle *event, u32 port)
Gets a handle to the event signaled on vsync interrupts.
Sepia effect.
Definition: cam.h:119
Batch camera configuration for use without a context.
Definition: cam.h:202
Pattern 7.
Definition: cam.h:130
Pattern 10.
Definition: cam.h:133
Result CAMU_SetExposure(u32 select, s8 exposure)
Sets the exposure value of the specified camera.
CAMU_WhiteBalance
Camera white balance modes.
Definition: cam.h:85
Result CAMU_IsTrimming(bool *trimming, u32 port)
Gets whether image trimming is enabled.
Result CAMU_SetTransferBytes(u32 port, u32 bytes, s16 width, s16 height)
Sets the number of bytes to transfer into an image buffer.
Y2RU_StandardCoefficient
Preset conversion coefficients based on ITU standards for the YUV->RGB formula.
Definition: y2r.h:86
20-10 FPS.
Definition: cam.h:80
CAM1 port.
Definition: cam.h:13
CAMU_LensCorrection
Camera lens correction modes.
Definition: cam.h:143
u8 autoWhiteBalanceOn
#bool Whether to automatically determine the white balance mode.
Definition: cam.h:208
Pattern 3.
Definition: cam.h:126
Result CAMU_SetNoiseFilter(u32 select, bool noiseFilter)
Sets whether the specified camera's noise filter is enabled.
Pattern 5.
Definition: cam.h:128
u8 autoExposureOn
#bool Whether to automatically determine the proper exposure.
Definition: cam.h:207
u8 camera
Selected camera.
Definition: cam.h:227
s16 cropY1
Second crop point Y.
Definition: cam.h:245
Result CAMU_IsBusy(bool *busy, u32 port)
Gets whether the specified camera port is busy.
s8 exposure
Camera exposure.
Definition: cam.h:204
u8 flip
CAMU_Flip Camera image flip mode.
Definition: cam.h:238
20 FPS.
Definition: cam.h:75
Result CAMU_GetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData *data)
Gets the specified camera's image quality calibration data.
u8 context
CAMU_Context Selected context.
Definition: cam.h:228
Result CAMU_GetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData *data)
Gets the specified camera's stereo camera calibration data.
Edge-to-center brightness ratio of 90.
Definition: cam.h:146
float rotationZ
Z axis rotation to match the left camera image with the right.
Definition: cam.h:187
u8 effect
CAMU_Effect Camera image special effects.
Definition: cam.h:239
void camExit(void)
Closes the cam service.
High contrast. (7)
Definition: cam.h:139
QQVGA size. (160x120)
Definition: cam.h:56
Result CAMU_SetOutputFormat(u32 select, CAMU_OutputFormat format, CAMU_Context context)
Sets the output format of the given camera in the given context.
Result CAMU_SynchronizeVsyncTiming(u32 select1, u32 select2)
Synchronizes the specified cameras' vsync timing.
Result CAMU_SetDetailSize(u32 select, s16 width, s16 height, s16 cropX0, s16 cropY0, s16 cropX1, s16 cropY1, CAMU_Context context)
Sets the image resolution of the given camera in the given context, in detail.
Result CAMU_GetMaxLines(s16 *maxLines, s16 width, s16 height)
Gets the maximum number of lines that can be saved to an image buffer.
float angleOfViewRight
Right camera angle of view.
Definition: cam.h:192
Edge-to-center brightness ratio of 70.
Definition: cam.h:145
s8 sharpness
Camera sharpness.
Definition: cam.h:206
float rotationX
X axis rotation to match the left camera image with the right.
Definition: cam.h:190
int16_t s16
16-bit signed integer
Definition: types.h:27
Result CAMU_SetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData data)
Sets the specified camera's stereo camera calibration data.
float scale
Scale to match the left camera image with the right.
Definition: cam.h:186
Auto white balance.
Definition: cam.h:86
CAMU_Effect
Camera special effects.
Definition: cam.h:113
RGB565.
Definition: cam.h:157
Pattern 9.
Definition: cam.h:132