1 /* 2 * Copyright (C) 2017-2019 Alibaba Group Holding Limited 3 */ 4 /****************************************************************************** 5 * @file drv_camera.h 6 * @brief header file for camera driver 7 * @version V1.2 8 * @date 27. May 2019 9 * @model camera 10 ******************************************************************************/ 11 #ifndef _DRV_CAMERA_H_ 12 #define _DRV_CAMERA_H_ 13 14 #include <stdint.h> 15 #include <drv/common.h> 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /// definition for camera handle. 22 typedef void *camera_handle_t; 23 24 /**** Camera Data Types ****/ 25 typedef enum { 26 CAMERA_DATA_FORMAT_YUV420_8 = 0, 27 CAMERA_DATA_FORMAT_YUV420_10, 28 CAMERA_DATA_FORMAT_YUV420_8_LEG, 29 CAMERA_DATA_FORMAT_YUV420_8_SHIFT, 30 CAMERA_DATA_FORMAT_YUV420_10_SHIFT, 31 CAMERA_DATA_FORMAT_YUV422_8, 32 CAMERA_DATA_FORMAT_YUV422_10, 33 CAMERA_DATA_FORMAT_RGB444, 34 CAMERA_DATA_FORMAT_RGB555, 35 CAMERA_DATA_FORMAT_RGB565, 36 CAMERA_DATA_FORMAT_RGB666, 37 CAMERA_DATA_FORMAT_RGB888, 38 CAMERA_DATA_FORMAT_RAW6, 39 CAMERA_DATA_FORMAT_RAW7, 40 CAMERA_DATA_FORMAT_RAW8, 41 CAMERA_DATA_FORMAT_RAW10, 42 CAMERA_DATA_FORMAT_RAW12, 43 CAMERA_DATA_FORMAT_RAW14, 44 } camera_data_format_e; 45 46 /**** Camera work mode ****/ 47 typedef enum { 48 CAMERA_OUTPUT_MODE_MIPI = 0, 49 CAMERA_OUTPUT_MODE_DVP, 50 CAMERA_OUTPUT_MODE_FPD, 51 CAMERA_OUTPUT_MODE_GMSL, 52 } camera_output_mode_e; 53 54 /** 55 \brief Camera config structure 56 */ 57 typedef struct { 58 camera_data_format_e format; ///< output image format 59 camera_output_mode_e mode; ///< camera work mode 60 uint32_t width; ///< output image width 61 uint32_t height; ///< output image height 62 } camera_config_t; 63 64 /****** CAMERA Event *****/ 65 typedef enum { 66 CAMERA_EVENT_READY = 0, ///< camera Ready 67 CAMERA_EVENT_ERROR, ///< Read/Write camera Error 68 } camera_event_e; 69 70 typedef void (*camera_event_cb_t)(camera_handle_t handle, camera_event_e event, void *user_data); ///< Pointer to \ref camera_event_cb_t : CAMERA Event call back. 71 72 // Function documentation 73 74 /** 75 \brief Initialize CAMERA Interface. 1. Initializes the resources needed for the CAMERA interface 2.registers event callback function 76 \param[in] idx device id 77 \param[in] cb_event Pointer to \ref camera_event_cb_t 78 \return pointer to camera handle 79 */ 80 camera_handle_t csi_camera_initialize(int32_t idx, camera_event_cb_t cb_event, void *user_data); 81 82 /** 83 \brief De-initialize CAMERA Interface. stops operation and releases the software resources used by the interface 84 \param[in] handle camera handle to operate. 85 \return error code 86 */ 87 int32_t csi_camera_uninitialize(camera_handle_t handle); 88 89 /** 90 \brief Start and config the camera. 91 \param[in] handle camera handle to operate. 92 \param[in] config the config structure of camera 93 \return error code 94 */ 95 int32_t csi_camera_start(camera_handle_t handle, camera_config_t *config); 96 97 /** 98 \brief Stop the camera. 99 \param[in] handle camera handle to operate. 100 \return error code 101 */ 102 int32_t csi_camera_stop(camera_handle_t handle); 103 #ifdef __cplusplus 104 } 105 #endif 106 107 #endif /* _DRV_CAMERA_H_ */ 108