/*---------------------------------------------------------------------------* Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ // camera.h // // Interface for Camera Library #ifndef _CAMERA_LIB_H #define _CAMERA_LIB_H #ifdef __cplusplus extern "C" { #endif /* * Camera Spec */ #define CAMERA_STREAM_WIDTH (640) #define CAMERA_STREAM_PITCH (768) #define CAMERA_STREAM_HEIGHT (480) #define NUM_STREAM_BUFFER (20) #define CAMERA_Y_BUFFER_SIZE ( CAMERA_STREAM_PITCH * CAMERA_STREAM_HEIGHT ) #define CAMERA_UV_BUFFER_SIZE ( CAMERA_STREAM_PITCH * CAMERA_STREAM_HEIGHT / 2 ) #define CAMERA_YUV_BUFFER_SIZE ( CAMERA_Y_BUFFER_SIZE + CAMERA_UV_BUFFER_SIZE ) #define CAMERA_YUV_BUFFER_ALIGNMENT (256) /* * error codes */ #define CAMERA_ERROR_NONE (0) #define CAMERA_ERROR_INVALID_ARG (-1) #define CAMERA_ERROR_INVALID_HANDLE (-2) #define CAMERA_ERROR_INVALID_STATE (-3) #define CAMERA_ERROR_QUEUE_FULL (-4) #define CAMERA_ERROR_INSUFFICIENT_MEMORY (-5) #define CAMERA_ERROR_NOT_READY (-6) #define CAMERA_ERROR_FSA_FAILURE (-7) #define CAMERA_ERROR_UNIINITIALIZED (-8) #define CAMERA_ERROR_DEVICE_NOT_READY (-9) #define CAMERA_ERROR_UNKNOWN (-10) #define CAMERA_ERROR_NOT_IMPLEMENTED (-11) #define CAMERA_ERROR_DEVICE_IN_USE (-12) #define CAMERA_ERROR_UVD_FAILURE (-13) #define CAMERA_ERROR_NOT_SUPPORTED (-14) #define CAMERA_ERROR_SEGMENT_VIOLATION (-15) typedef enum _CAM_STATE { CAMERA_DEVICE_POWER_MODE = 0, ///< Not Implemented CAMERA_AUTO_EXPOSURE_MODE, CAMERA_AUTO_EXPOSURE_TIME_ABSOLUTE, CAMERA_BRIGHTNESS, CAMERA_CONTRAST, CAMERA_GAIN, CAMERA_POWER_LINE_FREQUENCY, CAMERA_HUE, CAMERA_SATURATION, CAMERA_SHARPNESS, CAMERA_GAMMA, CAMERA_DIGITAL_MULTIPLIER_STEP, ///< Not Implemented CAMERA_DIGITAL_MULTIPLIER_LIMIT, ///< Not Implemented CAMERA_WHITE_BALANCE_COMPONENT, CAMERA_WHITE_BALANCE_COMPONENT_AUTO, CAMERA_DRC_CONNECTION_STATE, ///< 1: DRC attached, 0: DRC detached; Only implemented in CAMGetState CAMERA_GENERATE_KEY_FRAME, CAMERA_STATE_NUM ///< Number of camera states } CAM_STATE; /// \brief define a type for camera handle typedef int CAMHandle; /// \brief define all supported Camera IDs here typedef enum _CAMERA_INSTANCE { CAMERA_INSTANCE_0 = 0, CAMERA_INSTANCE_NUM } CAMERA_INSTANCE; /// \brief enumerates pixel formats for target decode surface typedef enum _CAMERA_PIXEL_FORMAT { CAMERA_NV12 = 0 } CAMERA_PIXEL_FORMAT; /// \brief enumerates tiling modes for target decode surface typedef enum _CAMERA_TILE_MODE { CAMERA_LINEAR = 0 } CAMERA_TILE_MODE; /// \brief enumerates event types typedef enum _CAMERA_EVENT_TYPE { CAMERA_DECODE_DONE = 0, CAMERA_DRC_DETACH } CAMERA_EVENT_TYPE; /// \brief enumerates DRC camera's display modes typedef enum _DRC_CAMERA_DISPLAY_MODE { DRC_CAMERA_DOWNSTREAM, DRC_CAMERA_LOCAL_LOOPBACK }DRC_CAMERA_DISPLAY_MODE; /// \brief enumerates DRC camera's FPS typedef enum _DRC_CAMERA_FPS { DRC_CAMERA_FPS_15, DRC_CAMERA_FPS_30 }DRC_CAMERA_FPS; /// \brief camera request to prevent flickering typedef enum _DRC_POWER_LINE_FREQUENCY { DRC_POWER_LINE_FREQUENCY_DISABLED = 0, DRC_POWER_LINE_FREQUENCY_50Hz = 1, DRC_POWER_LINE_FREQUENCY_60Hz = 2 }DRC_POWER_LINE_FREQUENCY; /// \brief holds different mode settings for camera typedef struct _CAMMode { DRC_CAMERA_DISPLAY_MODE display; DRC_CAMERA_FPS fps; }CAMMode; /// \brief holds different state information typedef struct _CAMStateInfo { int max; int min; int res; }CAMStateInfo; /// \brief Input parameters for UVDEventHandler method typedef struct _Camera_Event_Handler_Input { CAMERA_EVENT_TYPE type; ///< event type u32 data0; ///< event data u32 data1; ///< event data u32 data2; ///< event data } Camera_Event_Handler_Input; /** * \brief Event handler method * \param event_handler_input input structure * \return Whether this call is successful * * This method is called from an ISR. So, any processing * in this function should be kept to the bare minimum */ typedef void (*CAMEventHandler)( Camera_Event_Handler_Input *event_handler_input ); /// \brief enumerates camera stream types typedef enum _CAMERA_STREAM_TYPE { CAMERA_STREAM_VIDEO } CAMERA_STREAM_TYPE; /// \brief holds information about work memory typedef struct _CAMWorkMem { int size; ///< size of work memory void *pMem; ///< pointer to the work memory } CAMWorkMem; /// \brief holds information about the compressed data stream typedef struct _CamearaStreamInfo { CAMERA_STREAM_TYPE type; ///< stream type int height; ///< height of the encoded picture int width; ///< width of the encoded picture } CAMStreamInfo; #define CAM_THREAD_ATTR_AFFINITY_NONE 0x00000007u // affinity to run on every core #define CAM_THREAD_ATTR_AFFINITY_CORE0 0x00000001u // run only on core0 #define CAM_THREAD_ATTR_AFFINITY_CORE1 0x00000002u // run only on core1 #define CAM_THREAD_ATTR_AFFINITY_CORE2 0x00000004u // run only on core2 /// \brief holds information to setup camera typedef struct _CAMSetupInfo { CAMStreamInfo StreamInfo; ///< info about stream CAMWorkMem WorkMem; ///< info about the work memory CAMEventHandler eventHandler; ///< event handler function CAMMode mode; ///< camera mode settings int ThreadAffinity; ///< core affinity attribute for camera threads; ///< This is OR'd bit value of CAM_THREAD_ATTR_AFFINITY_* attributes int reserve[4]; ///< Reserved for future use } CAMSetupInfo; /// \brief camera surface structure typedef struct _CAMSurface { int imageSize; ///< size of image in bytes void *imagePtr; ///< pointer to the image int height; ///< height of the image in pixels int width; ///< width of the image in pixels int pitch; ///< pitch of the image in bytes int alignment; ///< alignment to use when allocating memory for the image CAMERA_TILE_MODE tileMode; ///< tiling mode of the image CAMERA_PIXEL_FORMAT pixelFormat; ///< pixel format of the image } CAMSurface; /** * \brief Initializes camera library * * \param instance camera instance number * \param pSetup camera setup info * \return whether the call is successful */ CAMHandle CAMInit(CAMERA_INSTANCE instance, CAMSetupInfo *pSetup, int *err); /** * \brief Exit camera library * * \param hCam camera handle */ void CAMExit(CAMHandle hCam); /** * \brief Opens camera library for use * * \param hCam camera handle * \return whether the call is successful */ int CAMOpen(CAMHandle hCam); /** * \brief Closes camera library * * \param hCam camera handle * \return whether the call is successful */ int CAMClose(CAMHandle hCam); /** * \brief Get total memory required for camera * * \param StreamInfo camera stream information like desired resolution * \return total memory required for operating camera */ int CAMGetMemReq(CAMStreamInfo *StreamInfo); /** * \brief submits a target surface for camera library to write out the picture * * \param hCam camera handle * \param surface camera surface where a picture is desired * \return whether the call is successful */ int CAMSubmitTargetSurface(CAMHandle hCam, CAMSurface *surface); /** * \brief gets the current value of a camera state (CAM_STATE) variable * * \param hCam camera handle * \param state one of camera state variables * \return whether the call is successful */ int CAMGetState(CAMHandle hCam, CAM_STATE state, int *pVal); /** * \brief gets information about a camera state (CAM_STATE) variable * * \param hCam camera handle * \param state one of camera state variables * \param pInfo holds min, max and resolution (res) of a camera state * \return whether the call is successful */ int CAMGetStateInfo(CAMHandle hCam, CAM_STATE state, CAMStateInfo *pInfo); /** * \brief sets the value of a camera state (CAM_STATE) variable * * \param hCam camera handle * \param state one of camera state variables * \return whether the call is successful */ int CAMSetState(CAMHandle hCam, CAM_STATE state, int *pVal); /** * \brief This method checks whether the memory allocated by the * caller meets hardware limitation of not crossing a 256 MB segment. * This limitation applies only to the work memory and target decode * surface memory. * If this API returns FALSE, caller should re-allocate the * memory, free the memory allocated earlier, and call this API * again to validate the new memory. * * \param pMem Start address of the allocated memory region * \param size Size of the allocated memory region * \returns CAMERA_ERROR_NONE if the allocated memory does not straddle * 256 MB boundary; otherwise returns CAMERA_ERROR_SEGMENT_VIOLATION */ int CAMCheckMemSegmentation(void *pMem, unsigned int size); #ifdef __cplusplus } #endif #endif //_CAMERA_LIB_H