ql_api_camera.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /*================================================================
  2. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  3. Quectel Wireless Solutions Proprietary and Confidential.
  4. =================================================================*/
  5. /**
  6. @file
  7. ql_api_camera.h
  8. @brief
  9. This file provides the definitions for camera API functions.
  10. */
  11. /*=================================================================
  12. EDIT HISTORY FOR MODULE
  13. This section contains comments describing changes made to the module.
  14. Notice that changes are listed in reverse chronological order.
  15. WHEN WHO WHAT, WHERE, WHY
  16. ------------ ------- -------------------------------------------------------------------------------
  17. =================================================================*/
  18. #ifndef QL_API_CAMERA_H
  19. #define QL_API_CAMERA_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #include "ql_api_common.h"
  24. #include "ql_api_osi.h"
  25. /*===========================================================================
  26. * Macro Definition
  27. ===========================================================================*/
  28. #define QL_CAMERA_ERRCODE_BASE (QL_COMPONENT_BSP_CAMERA<<16)
  29. #define AC_BLACK 0
  30. #define AC_ST7735S_ZX 1
  31. #define AC_ST7735S_ST 2
  32. /*===========================================================================
  33. * Struct
  34. ===========================================================================*/
  35. typedef struct
  36. {
  37. bool Cam_Init_status; //the status of camera init
  38. bool Cam_Power_status; //the status of camera pwoer
  39. bool Cam_Preview_status; //the status of camera preview
  40. }ql_cam_status_s;
  41. typedef struct
  42. {
  43. char *pNamestr; //the name of camera
  44. uint32_t img_width; //the width of image
  45. uint32_t img_height; //the height of image
  46. uint32_t nPixcels; //the pixcels of image
  47. ql_cam_status_s Status; //the status of camera
  48. ql_mutex_t camera_mutex;
  49. } ql_cam_drv_s;
  50. /*===========================================================================
  51. * Enum
  52. ===========================================================================*/
  53. typedef enum
  54. {
  55. QL_CAMERA_SUCCESS = QL_SUCCESS,
  56. QL_CAMERA_INIT_ERR = 1|QL_CAMERA_ERRCODE_BASE,
  57. QL_CAMERA_ALREADY_INIT_ERR,
  58. QL_CAMERA_NO_INIT_ERR,
  59. QL_CAMERA_POWER_ON_ERR = 5|QL_CAMERA_ERRCODE_BASE,
  60. QL_CAMERA_ALREADY_POWER_ON_ERR,
  61. QL_CAMERA_CLOSE_ERR, // power off, had closed
  62. QL_CAMERA_PREVIEW_ERR = 10|QL_CAMERA_ERRCODE_BASE,
  63. QL_CAMERA_PREVIEWING_ERR, // Preview has started
  64. QL_CAMERA_NO_PREVIEW_ERR, // Preview has ended
  65. QL_CAMERA_STOP_PREVIEW_ERR, // stop preview API execute error
  66. QL_CAMERA_CAPTURE_ERR = 15|QL_CAMERA_ERRCODE_BASE,
  67. QL_CAMERA_GET_INFO_ERR, // camera info
  68. QL_CAMERA_LCDINFO_GET_ERR, // LCD info
  69. QL_CAMERA_PRINT_ERR,
  70. QL_CAMERA_DQBUF_ERR,
  71. QL_CAMERA_QBUF_ERR, // no use
  72. QL_CAMERA_SET_BUF_ERR,
  73. QL_CAMERA_CREATE_MUTEX_ERR,
  74. QL_CAMERA_MUTEX_ALREADY_EXIST_ERR,
  75. QL_CAMERA_MUTEX_TIMEOUT_ERR,
  76. QL_CAMERA_DELETE_MUTEX_ERR,
  77. QL_CAMERA_I2C_READ_ERR,
  78. QL_CAMERA_I2C_WRITE_ERR,
  79. }ql_errcode_camera_e;
  80. typedef enum
  81. {
  82. single_buf,
  83. double_buf,
  84. }ql_buf_config_e;
  85. /*===========================================================================
  86. * Variate
  87. ===========================================================================*/
  88. /*===========================================================================
  89. * Functions
  90. ===========================================================================*/
  91. /*****************************************************************
  92. * Function: ql_CamInit
  93. *
  94. * Description: Initialize the camera
  95. *
  96. * Parameters:
  97. * width [in] the width of the camera
  98. * height [in] the height of the camera
  99. *
  100. * Return:
  101. * ql_errcode_camera_e
  102. *
  103. *****************************************************************/
  104. ql_errcode_camera_e ql_CamInit(uint16_t width, uint16_t height);
  105. /*****************************************************************
  106. * Function: ql_CamPowerOn
  107. *
  108. * Description: power on the camera
  109. *
  110. * Parameters:
  111. *
  112. * Return:
  113. * ql_errcode_camera_e
  114. *
  115. *****************************************************************/
  116. ql_errcode_camera_e ql_CamPowerOn(void);
  117. /*****************************************************************
  118. * Function: ql_CamPowerOff
  119. *
  120. * Description: power off the camera
  121. *
  122. * Parameters:
  123. *
  124. * Return:
  125. * ql_errcode_camera_e
  126. *
  127. *****************************************************************/
  128. ql_errcode_camera_e ql_CamPowerOff(void);
  129. /*****************************************************************
  130. * Function: ql_CamClose
  131. *
  132. * Description: close the camera
  133. *
  134. * Parameters:
  135. *
  136. * Return:
  137. * ql_errcode_camera_e
  138. *
  139. *****************************************************************/
  140. ql_errcode_camera_e ql_CamClose(void);
  141. /*****************************************************************
  142. * Function: ql_CamGetSensorInfo
  143. *
  144. * Description: get the information of camera
  145. *
  146. * Parameters:
  147. * *pCamDevice [out] the camera driver
  148. * Return:
  149. * ql_errcode_camera_e
  150. *
  151. *****************************************************************/
  152. ql_errcode_camera_e ql_CamGetSensorInfo(ql_cam_drv_s *pCamDevice);
  153. /*****************************************************************
  154. * Function: ql_CamPreview
  155. *
  156. * Description: start preview
  157. *
  158. * Parameters:
  159. *
  160. * Return:
  161. * ql_errcode_camera_e
  162. *
  163. *****************************************************************/
  164. ql_errcode_camera_e ql_CamPreview(void);
  165. /*****************************************************************
  166. * Function: ql_CamStopPreview
  167. *
  168. * Description: stop preview
  169. *
  170. * Parameters:
  171. *
  172. * Return:
  173. * ql_errcode_camera_e
  174. *
  175. *****************************************************************/
  176. ql_errcode_camera_e ql_CamStopPreview(void);
  177. /*****************************************************************
  178. * Function: ql_CamStopPreview
  179. *
  180. * Description: capture function
  181. *
  182. * Parameters:
  183. * **pFrameBuf [out] the buf used to save capture image
  184. * Return:
  185. * ql_errcode_camera_e
  186. *
  187. *****************************************************************/
  188. ql_errcode_camera_e ql_CamCaptureImage(uint16_t **pFrameBuf);
  189. /*****************************************************************
  190. * Function: ql_camPrint
  191. *
  192. * Description: display the image on lcd
  193. *
  194. * Parameters:
  195. * *imageBuf [in] the image need to be displayed
  196. * Return:
  197. * ql_errcode_camera_e
  198. *
  199. *****************************************************************/
  200. ql_errcode_camera_e ql_camPrint(uint16_t *imageBuf);
  201. /*****************************************************************
  202. * Function: ql_CamSetBufopt
  203. *
  204. * Description: set the number of buf
  205. *
  206. * Parameters:
  207. * buf_cfg [in] the number of buffer
  208. *
  209. * Return:
  210. * ql_errcode_camera_e
  211. *
  212. *****************************************************************/
  213. ql_errcode_camera_e ql_CamSetBufopt(ql_buf_config_e buf_cfg);
  214. /*****************************************************************
  215. * Function: ql_Cam_Init_0310_SPI
  216. *
  217. * Description: modify the infomation of 0310
  218. *
  219. * Parameters:void
  220. *
  221. * Return:
  222. * ql_errcode_camera_e
  223. *
  224. *****************************************************************/
  225. ql_errcode_camera_e ql_CamInit0310SPI(uint16_t width, uint16_t height);
  226. /*****************************************************************
  227. * Function: ql_CamPreviewDQBUF
  228. *
  229. * Description: preview image function, DQBUF means dequeue preview buffer.
  230. * get preview buffer from queue. After used, must be add preview buffer to queue.
  231. * !!! use with ql_CamPreviewQBUF
  232. * this API is only used for bwscreen LCD, color LCD still use ql_camPrint.
  233. *
  234. * Parameters:
  235. * **pFrameBuf [out] the buf used to get preview image
  236. *
  237. * Return:
  238. * ql_errcode_camera_e
  239. *
  240. *****************************************************************/
  241. ql_errcode_camera_e ql_CamPreviewDQBUF(uint16_t **pFrameBuf);
  242. /*****************************************************************
  243. * Function: ql_CamPreviewQBUF
  244. *
  245. * Description: preview image function, QBUF means enqueue preview buffer.
  246. * Add free memory to the queue that can preview
  247. * !!! use with ql_CamPreviewDQBUF
  248. *
  249. * Parameters:
  250. * *pFrameBuf [in] the buf used to restart preview image
  251. *
  252. * Return:
  253. * ql_errcode_camera_e
  254. *
  255. *****************************************************************/
  256. ql_errcode_camera_e ql_CamPreviewQBUF(uint16_t *pFrameBuf);
  257. /*****************************************************************
  258. * Function: ql_CamI2CRead
  259. *
  260. * Description: Cami2c master read,after the camera is successfully powered on
  261. *
  262. * Parameters:
  263. * addr [in] the i2c slave regiser address
  264. * data [out] the data that was read
  265. * len [in] the length of the data
  266. *
  267. * Return:
  268. * ql_errcode_camera_e
  269. *
  270. *****************************************************************/
  271. ql_errcode_camera_e ql_CamI2CRead(uint8_t addr, uint8_t *data, uint32_t len);
  272. /*****************************************************************
  273. * Function: ql_CamI2CWrite
  274. *
  275. * Description: Cami2c master write,after the camera is successfully powered on
  276. *
  277. * Parameters:
  278. * addr [in] the i2c slave regiser address
  279. * data [in] the data need to be sent
  280. *
  281. * Return:
  282. * ql_errcode_camera_e
  283. *
  284. *****************************************************************/
  285. ql_errcode_camera_e ql_CamI2CWrite(uint8_t addr, uint8_t data);
  286. #ifdef __cplusplus
  287. } /*"C" */
  288. #endif
  289. #endif /* QL_API_CAMERA_H*/