libctru v2.5.0
Loading...
Searching...
No Matches
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.
11enum {
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.
21enum {
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.
32};
33
34/// Camera contexts.
35typedef 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.
43
44/// Ways to flip the camera image.
45typedef 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.
53typedef 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.
68typedef 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.
85typedef 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.
104typedef 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.
113typedef 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.
121
122/// Camera contrast patterns.
123typedef 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)
141
142/// Camera lens correction modes.
143typedef 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.
155typedef enum {
156 OUTPUT_YUV_422 = 0x0, ///< YUV422
157 OUTPUT_RGB_565 = 0x1, ///< RGB565
159
160/// Camera shutter sounds.
161typedef 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.
168typedef 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.
183typedef 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.
202typedef 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.
226typedef 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.
235typedef 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 */
254
255/**
256 * @brief Closes the cam service.
257 *
258 * This will internally call CAMU_DriverFinalize and close the handle of the service.
259 */
260void 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 */
279Result 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 */
309Result 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 */
316Result 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 */
325Result 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 */
333Result 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 */
342Result 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 */
349Result 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 */
357Result 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 */
364Result 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 */
371Result 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 */
381Result 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 */
391Result 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 */
401Result 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 */
408
409/**
410 * @brief Switches the specified camera's active context.
411 * @param select Camera to use.
412 * @param context Context to use.
413 */
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 */
421Result 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 */
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 */
443Result 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 */
450Result 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 */
457Result 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 */
464Result 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 */
471Result 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 */
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 */
492Result 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 */
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 */
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 */
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 */
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 */
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 */
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 */
554Result 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 */
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 */
571Result 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 */
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 */
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 */
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 */
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 */
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 */
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 */
702Result CAMU_SetBrightnessSynchronization(bool brightnessSynchronization);
703
Result CAMU_SynchronizeVsyncTiming(u32 select1, u32 select2)
Synchronizes the specified cameras' vsync timing.
Result CAMU_SetReceiving(Handle *event, void *dst, u32 port, u32 imageSize, s16 transferUnit)
Initiates the process of receiving a camera frame.
Result CAMU_FlipImage(u32 select, CAMU_Flip flip, CAMU_Context context)
Flips the image of the specified camera in the specified context.
Result camInit(void)
Initializes the cam service.
Result CAMU_SwitchContext(u32 select, CAMU_Context context)
Switches the specified camera's active context.
Result CAMU_SetNoiseFilter(u32 select, bool noiseFilter)
Sets whether the specified camera's noise filter is enabled.
CAMU_Contrast
Camera contrast patterns.
Definition cam.h:123
@ CONTRAST_PATTERN_08
Pattern 8.
Definition cam.h:131
@ CONTRAST_PATTERN_05
Pattern 5.
Definition cam.h:128
@ CONTRAST_PATTERN_02
Pattern 2.
Definition cam.h:125
@ CONTRAST_LOW
Low contrast. (5)
Definition cam.h:137
@ CONTRAST_HIGH
High contrast. (7)
Definition cam.h:139
@ CONTRAST_PATTERN_11
Pattern 11.
Definition cam.h:134
@ CONTRAST_NORMAL
Normal contrast. (6)
Definition cam.h:138
@ CONTRAST_PATTERN_06
Pattern 6.
Definition cam.h:129
@ CONTRAST_PATTERN_04
Pattern 4.
Definition cam.h:127
@ CONTRAST_PATTERN_01
Pattern 1.
Definition cam.h:124
@ CONTRAST_PATTERN_09
Pattern 9.
Definition cam.h:132
@ CONTRAST_PATTERN_07
Pattern 7.
Definition cam.h:130
@ CONTRAST_PATTERN_10
Pattern 10.
Definition cam.h:133
@ CONTRAST_PATTERN_03
Pattern 3.
Definition cam.h:126
Result CAMU_GetSleepCamera(u32 *select)
Gets the current sleep camera.
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_SetWhiteBalance(u32 select, CAMU_WhiteBalance whiteBalance)
Sets the white balance mode of the specified camera.
Result CAMU_IsTrimming(bool *trimming, u32 port)
Gets whether image trimming is enabled.
Result CAMU_GetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData *data)
Gets the specified camera's image quality calibration data.
CAMU_Flip
Ways to flip the camera image.
Definition cam.h:45
@ FLIP_NONE
No flip.
Definition cam.h:46
@ FLIP_REVERSE
Reverse flip.
Definition cam.h:49
@ FLIP_HORIZONTAL
Horizontal flip.
Definition cam.h:47
@ FLIP_VERTICAL
Vertical flip.
Definition cam.h:48
Result CAMU_SetTransferBytes(u32 port, u32 bytes, s16 width, s16 height)
Sets the number of bytes to transfer into an image buffer.
CAMU_Size
Camera image resolutions.
Definition cam.h:53
@ SIZE_VGA
VGA size. (640x480)
Definition cam.h:54
@ SIZE_CTR_TOP_LCD
CTR Top LCD size. (400x240)
Definition cam.h:61
@ SIZE_DS_LCD
DS LCD size. (256x192)
Definition cam.h:59
@ SIZE_CIF
CIF size. (352x288)
Definition cam.h:57
@ SIZE_QVGA
QVGA size. (320x240)
Definition cam.h:55
@ SIZE_QCIF
QCIF size. (176x144)
Definition cam.h:58
@ SIZE_CTR_BOTTOM_LCD
CTR Bottom LCD size. (320x240)
Definition cam.h:64
@ SIZE_DS_LCDx4
DS LCD x4 size. (512x384)
Definition cam.h:60
@ SIZE_QQVGA
QQVGA size. (160x120)
Definition cam.h:56
Result CAMU_ClearBuffer(u32 port)
Clears the buffer and error flags of the specified camera port.
Result CAMU_SetTransferLines(u32 port, s16 lines, s16 width, s16 height)
Sets the number of lines to transfer into an image buffer.
Result CAMU_SetAutoExposure(u32 select, bool autoExposure)
Sets whether auto exposure is enabled on the specified camera.
Result CAMU_GetBufferErrorInterruptEvent(Handle *event, u32 port)
Gets a handle to the event signaled on camera buffer errors.
Result CAMU_DriverFinalize(void)
Finalizes the camera driver.
Result CAMU_StartCapture(u32 port)
Begins capture on the specified camera port.
Result CAMU_WriteRegisterI2c(u32 select, u16 addr, u16 data)
Writes to the specified I2C register of the specified camera.
Result CAMU_GetTransferBytes(u32 *transferBytes, u32 port)
Gets the number of bytes to transfer into an image buffer.
Result CAMU_DriverInitialize(void)
Initializes the camera driver.
CAMU_OutputFormat
Camera image output formats.
Definition cam.h:155
@ OUTPUT_RGB_565
RGB565.
Definition cam.h:157
@ OUTPUT_YUV_422
YUV422.
Definition cam.h:156
CAMU_FrameRate
Camera capture frame rates.
Definition cam.h:68
@ FRAME_RATE_30_TO_10
30-10 FPS.
Definition cam.h:81
@ FRAME_RATE_10
10 FPS.
Definition cam.h:72
@ FRAME_RATE_30
30 FPS.
Definition cam.h:77
@ FRAME_RATE_8_5
8.5 FPS.
Definition cam.h:73
@ FRAME_RATE_15_TO_2
15-2 FPS.
Definition cam.h:71
@ FRAME_RATE_20_TO_10
20-10 FPS.
Definition cam.h:80
@ FRAME_RATE_5
5 FPS.
Definition cam.h:74
@ FRAME_RATE_15_TO_5
15-5 FPS.
Definition cam.h:70
@ FRAME_RATE_30_TO_5
30-5 FPS.
Definition cam.h:78
@ FRAME_RATE_20
20 FPS.
Definition cam.h:75
@ FRAME_RATE_15
15 FPS.
Definition cam.h:69
@ FRAME_RATE_15_TO_10
15-10 FPS.
Definition cam.h:79
@ FRAME_RATE_20_TO_5
20-5 FPS.
Definition cam.h:76
Result CAMU_ReadMcuVariableI2cExclusive(u16 *data, u32 select, u16 addr)
Reads the specified MCU variable of the specified camera.
CAMU_LensCorrection
Camera lens correction modes.
Definition cam.h:143
@ LENS_CORRECTION_ON_70
Edge-to-center brightness ratio of 70.
Definition cam.h:145
@ LENS_CORRECTION_NORMAL
Normal lens correction. (70)
Definition cam.h:150
@ LENS_CORRECTION_ON_90
Edge-to-center brightness ratio of 90.
Definition cam.h:146
@ LENS_CORRECTION_BRIGHT
Bright lens correction. (90)
Definition cam.h:151
@ LENS_CORRECTION_DARK
Dark lens correction. (OFF)
Definition cam.h:149
@ LENS_CORRECTION_OFF
No lens correction.
Definition cam.h:144
Result CAMU_GetActivatedCamera(u32 *select)
Gets the current activated camera.
Result CAMU_IsFinishedReceiving(bool *finishedReceiving, u32 port)
Gets whether the specified camera port has finished receiving image data.
CAMU_ShutterSoundType
Camera shutter sounds.
Definition cam.h:161
@ SHUTTER_SOUND_TYPE_MOVIE_END
Shutter sound to end a movie.
Definition cam.h:164
@ SHUTTER_SOUND_TYPE_MOVIE
Shutter sound to begin a movie.
Definition cam.h:163
@ SHUTTER_SOUND_TYPE_NORMAL
Normal shutter sound.
Definition cam.h:162
Result CAMU_IsAutoWhiteBalance(bool *autoWhiteBalance, u32 select)
Gets whether auto white balance is enabled on the specified camera.
CAMU_WhiteBalance
Camera white balance modes.
Definition cam.h:85
@ WHITE_BALANCE_5200K
5200K white balance.
Definition cam.h:89
@ WHITE_BALANCE_3200K
3200K white balance.
Definition cam.h:87
@ WHITE_BALANCE_6000K
6000K white balance.
Definition cam.h:90
@ WHITE_BALANCE_AUTO
Auto white balance.
Definition cam.h:86
@ WHITE_BALANCE_7000K
7000K white balance.
Definition cam.h:91
@ WHITE_BALANCE_4150K
4150K white balance.
Definition cam.h:88
Result CAMU_IsBusy(bool *busy, u32 port)
Gets whether the specified camera port is busy.
Result CAMU_SetFrameRate(u32 select, CAMU_FrameRate frameRate)
Sets the frame rate of the given camera.
CAMU_Context
Camera contexts.
Definition cam.h:35
@ CONTEXT_A
Context A.
Definition cam.h:37
@ CONTEXT_B
Context B.
Definition cam.h:38
@ CONTEXT_NONE
No context.
Definition cam.h:36
@ CONTEXT_BOTH
Both contexts.
Definition cam.h:41
Result CAMU_SetTrimmingParams(u32 port, s16 xStart, s16 yStart, s16 xEnd, s16 yEnd)
Sets the parameters used for trimming images.
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_SetSleepCamera(u32 select)
Sets the current sleep camera.
Result CAMU_SetBrightnessSynchronization(bool brightnessSynchronization)
Sets whether to enable synchronization of left and right camera brightnesses.
void camExit(void)
Closes the cam service.
Result CAMU_GetVsyncInterruptEvent(Handle *event, u32 port)
Gets a handle to the event signaled on vsync interrupts.
CAMU_Effect
Camera special effects.
Definition cam.h:113
@ EFFECT_MONO
Mono effect.
Definition cam.h:115
@ EFFECT_NEGATIVE
Negative effect.
Definition cam.h:117
@ EFFECT_NEGAFILM
Negative film effect.
Definition cam.h:118
@ EFFECT_SEPIA
Sepia effect.
Definition cam.h:116
@ EFFECT_SEPIA01
Sepia effect.
Definition cam.h:119
@ EFFECT_NONE
No effects.
Definition cam.h:114
Result CAMU_GetTrimmingParams(s16 *xStart, s16 *yStart, s16 *xEnd, s16 *yEnd, u32 port)
Gets the parameters used for trimming images.
Result CAMU_StopCapture(u32 port)
Terminates capture on the specified camera port.
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_SetExposure(u32 select, s8 exposure)
Sets the exposure value of the specified camera.
Result CAMU_GetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData *data)
Gets the specified camera's stereo camera calibration data.
Result CAMU_SetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData data)
Sets the specified camera's stereo camera calibration data.
Result CAMU_SetPhotoMode(u32 select, CAMU_PhotoMode photoMode)
Sets the photo mode of the given camera.
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_IsAutoExposure(bool *autoExposure, u32 select)
Gets whether auto exposure is enabled on the specified camera.
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.
Result CAMU_SetContrast(u32 select, CAMU_Contrast contrast)
Sets the contrast mode of the given camera.
Result CAMU_SetWhiteBalanceWithoutBaseUp(u32 select, CAMU_WhiteBalance whiteBalance)
Sets the white balance mode of the specified camera.
Result CAMU_SetSharpness(u32 select, s8 sharpness)
Sets the sharpness of the specified camera.
Result CAMU_SetPackageParameterWithContext(CAMU_PackageParameterContext param)
Configures a camera with pre-packaged configuration data with a context.
Result CAMU_GetMaxLines(s16 *maxLines, s16 width, s16 height)
Gets the maximum number of lines that can be saved to an image buffer.
CAMU_PhotoMode
Camera photo modes.
Definition cam.h:104
@ PHOTO_MODE_LETTER
Letter mode.
Definition cam.h:109
@ PHOTO_MODE_NORMAL
Normal mode.
Definition cam.h:105
@ PHOTO_MODE_PORTRAIT
Portrait mode.
Definition cam.h:106
@ PHOTO_MODE_NIGHTVIEW
Night mode.
Definition cam.h:108
@ PHOTO_MODE_LANDSCAPE
Landscape mode.
Definition cam.h:107
Result CAMU_SetTrimming(u32 port, bool trimming)
Sets whether image trimming is enabled.
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_SetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData data)
Sets the specified camera's image quality calibration data.
Result CAMU_WriteMcuVariableI2c(u32 select, u16 addr, u16 data)
Writes to the specified MCU variable of the specified camera.
Result CAMU_SetPackageParameterWithoutContext(CAMU_PackageParameterCameraSelect param)
Configures a camera with pre-packaged configuration data without a context.
Result CAMU_Activate(u32 select)
Activates the specified camera.
Result CAMU_GetSuitableY2rStandardCoefficient(Y2RU_StandardCoefficient *coefficient)
Gets the Y2R coefficient applied to image data by the camera.
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_PlayShutterSound(CAMU_ShutterSoundType sound)
Plays the specified shutter sound.
Result CAMU_ReadRegisterI2cExclusive(u16 *data, u32 select, u16 addr)
Reads the specified I2C register of the specified camera.
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_SetLensCorrection(u32 select, CAMU_LensCorrection lensCorrection)
Sets the lens correction mode of the given camera.
Result CAMU_SetAutoWhiteBalance(u32 select, bool autoWhiteBalance)
Sets whether auto white balance is enabled on the specified camera.
Result CAMU_GetMaxBytes(u32 *maxBytes, s16 width, s16 height)
Gets the maximum number of bytes that can be saved to an image buffer.
@ PORT_CAM2
CAM2 port.
Definition cam.h:14
@ PORT_BOTH
Both ports.
Definition cam.h:17
@ PORT_CAM1
CAM1 port.
Definition cam.h:13
@ PORT_NONE
No port.
Definition cam.h:12
Result CAMU_SetPackageParameterWithContextDetail(CAMU_PackageParameterContextDetail param)
Configures a camera with pre-packaged configuration data without a context and extra resolution detai...
@ SELECT_OUT1
Outer camera 1.
Definition cam.h:23
@ SELECT_OUT2
Outer camera 2.
Definition cam.h:25
@ SELECT_IN1_OUT2
Inner camera 1 and outer camera 2.
Definition cam.h:30
@ SELECT_IN1
Inner camera 1.
Definition cam.h:24
@ SELECT_ALL
All cameras.
Definition cam.h:31
@ SELECT_NONE
No camera.
Definition cam.h:22
@ SELECT_IN1_OUT1
Outer camera 1 and inner camera 1.
Definition cam.h:28
@ SELECT_OUT1_OUT2
Both outer cameras.
Definition cam.h:29
Image quality calibration data.
Definition cam.h:168
u16 awbCcmL10Right
Right camera, left color correction matrix blue/green gain.
Definition cam.h:176
u16 awbCcmL9Left
Left camera, left color correction matrix red/green gain.
Definition cam.h:175
s16 kGL
Left color correction matrix green normalization coefficient.
Definition cam.h:171
u16 awbX0Right
Right camera, color correction matrix position threshold.
Definition cam.h:178
s16 aeBaseTarget
Auto exposure base target brightness.
Definition cam.h:169
u16 awbCcmL9Right
Right camera, left color correction matrix red/green gain.
Definition cam.h:174
s16 kBL
Left color correction matrix blue normalization coefficient.
Definition cam.h:172
u16 awbCcmL10Left
Left camera, left color correction matrix blue/green gain.
Definition cam.h:177
u16 awbX0Left
Left camera, color correction matrix position threshold.
Definition cam.h:179
s16 ccmPosition
Color correction matrix position.
Definition cam.h:173
s16 kRL
Left color correction matrix red normalization coefficient.
Definition cam.h:170
Batch camera configuration for use without a context.
Definition cam.h:202
s16 autoExposureWindowX
X of the region to use for auto exposure.
Definition cam.h:215
u8 frameRate
CAMU_FrameRate Camera frame rate.
Definition cam.h:209
s8 exposure
Camera exposure.
Definition cam.h:204
s16 autoExposureWindowWidth
Width of the region to use for auto exposure.
Definition cam.h:217
u8 whiteBalance
CAMU_WhiteBalance Camera white balance.
Definition cam.h:205
s16 autoWhiteBalanceWindowX
X of the region to use for auto white balance.
Definition cam.h:219
s16 autoExposureWindowHeight
Height of the region to use for auto exposure.
Definition cam.h:218
u8 autoExposureOn
#bool Whether to automatically determine the proper exposure.
Definition cam.h:207
s8 sharpness
Camera sharpness.
Definition cam.h:206
s16 autoWhiteBalanceWindowWidth
Width of the region to use for auto white balance.
Definition cam.h:221
u8 camera
Selected camera.
Definition cam.h:203
s16 autoWhiteBalanceWindowHeight
Height of the region to use for auto white balance.
Definition cam.h:222
u8 padding
Padding. (Aligns last 3 fields to 4 bytes)
Definition cam.h:214
s16 autoExposureWindowY
Y of the region to use for auto exposure.
Definition cam.h:216
u8 noiseFilterOn
#bool Whether to enable the camera's noise filter.
Definition cam.h:213
s16 autoWhiteBalanceWindowY
Y of the region to use for auto white balance.
Definition cam.h:220
u8 contrast
CAMU_Contrast Camera contrast.
Definition cam.h:211
u8 autoWhiteBalanceOn
#bool Whether to automatically determine the white balance mode.
Definition cam.h:208
u8 lensCorrection
CAMU_LensCorrection Camera lens correction.
Definition cam.h:212
u8 photoMode
CAMU_PhotoMode Camera photo mode.
Definition cam.h:210
Batch camera configuration for use with a context and with detailed size information.
Definition cam.h:235
u8 camera
Selected camera.
Definition cam.h:236
u8 flip
CAMU_Flip Camera image flip mode.
Definition cam.h:238
s16 cropY0
First crop point Y.
Definition cam.h:243
s16 height
Image height.
Definition cam.h:241
s16 cropY1
Second crop point Y.
Definition cam.h:245
u8 effect
CAMU_Effect Camera image special effects.
Definition cam.h:239
s16 cropX1
Second crop point X.
Definition cam.h:244
u8 context
CAMU_Context Selected context.
Definition cam.h:237
s16 width
Image width.
Definition cam.h:240
s16 cropX0
First crop point X.
Definition cam.h:242
Batch camera configuration for use with a context.
Definition cam.h:226
u8 flip
CAMU_Flip Camera image flip mode.
Definition cam.h:229
u8 size
CAMU_Size Camera image resolution.
Definition cam.h:231
u8 effect
CAMU_Effect Camera image special effects.
Definition cam.h:230
u8 context
CAMU_Context Selected context.
Definition cam.h:228
u8 camera
Selected camera.
Definition cam.h:227
Stereo camera calibration data.
Definition cam.h:183
float distanceCameras
Distance between left and right cameras.
Definition cam.h:195
float translationY
Y axis translation to match the left camera image with the right.
Definition cam.h:189
float scale
Scale to match the left camera image with the right.
Definition cam.h:186
s16 imageHeight
Image height.
Definition cam.h:197
float distanceToChart
Distance between cameras and measurement chart.
Definition cam.h:194
u8 isValidRotationXY
#bool Whether the X and Y rotation data is valid.
Definition cam.h:184
float rotationX
X axis rotation to match the left camera image with the right.
Definition cam.h:190
float rotationZ
Z axis rotation to match the left camera image with the right.
Definition cam.h:187
float rotationY
Y axis rotation to match the left camera image with the right.
Definition cam.h:191
float translationX
X axis translation to match the left camera image with the right.
Definition cam.h:188
s16 imageWidth
Image width.
Definition cam.h:196
float angleOfViewLeft
Left camera angle of view.
Definition cam.h:193
float angleOfViewRight
Right camera angle of view.
Definition cam.h:192
Various system types.
int64_t s64
64-bit signed integer
Definition types.h:29
#define BIT(n)
Creates a bitmask from a bit number.
Definition types.h:47
uint8_t u8
would be nice if newlib had this already
Definition types.h:21
int8_t s8
8-bit signed integer
Definition types.h:26
int16_t s16
16-bit signed integer
Definition types.h:27
u32 Handle
Resource handle.
Definition types.h:41
s32 Result
Function result.
Definition types.h:42
uint16_t u16
16-bit unsigned integer
Definition types.h:22
uint32_t u32
32-bit unsigned integer
Definition types.h:23
Y2R service for hardware YUV->RGB conversions.
Y2RU_StandardCoefficient
Preset conversion coefficients based on ITU standards for the YUV->RGB formula.
Definition y2r.h:87