drv_camera.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DRV_CAMP_H_
  13. #define _DRV_CAMP_H_
  14. OSI_EXTERN_C_BEGIN
  15. #include <stdint.h>
  16. #include "drv_i2c.h"
  17. #include "drv_ifc.h"
  18. #include "hal_chip.h"
  19. #include "osi_api.h"
  20. typedef struct
  21. {
  22. uint8_t addr;
  23. uint8_t data;
  24. } cameraReg_t;
  25. typedef struct
  26. {
  27. uint8_t overflow : 1;
  28. uint8_t fstart : 1;
  29. uint8_t fend : 1;
  30. uint8_t dma : 1;
  31. } cameraIrqCause_t;
  32. typedef enum
  33. {
  34. //CAM_NPIX_UXGA = (1600*1200),
  35. CAM_NPIX_VGA = (640 * 480),
  36. } CAM_SIZE_T;
  37. // enum: image format about sensor output
  38. typedef enum
  39. {
  40. CAM_FORMAT_RGB565,
  41. CAM_FORMAT_YUV,
  42. CAM_FORMAT_RAW8,
  43. CAM_FORMAT_RAW10,
  44. } cameraImageFormat_t;
  45. typedef enum
  46. {
  47. SPI_MODE_NO = 0,
  48. SPI_MODE_SLAVE,
  49. SPI_MODE_MASTER1,
  50. SPI_MODE_MASTER2_1,
  51. SPI_MODE_MASTER2_2,
  52. SPI_MODE_MASTER2_4,
  53. SPI_MODE_UNDEF,
  54. } camSpiMode_t;
  55. typedef enum
  56. {
  57. SPI_OUT_Y0_U0_Y1_V0 = 0,
  58. SPI_OUT_Y0_V0_Y1_U0,
  59. SPI_OUT_U0_Y0_V0_Y1,
  60. SPI_OUT_U0_Y1_V0_Y0,
  61. SPI_OUT_V0_Y1_U1_Y0,
  62. SPI_OUT_V0_Y0_U0_Y1,
  63. SPI_OUT_Y1_V0_Y0_U0,
  64. SPI_OUT_Y1_U0_Y0_V0,
  65. } camSpiYuv_t;
  66. typedef enum
  67. {
  68. camCaptureIdle = 0,
  69. camCaptureState1,
  70. camCaptureState2,
  71. campPreviewState1,
  72. campPreviewState2,
  73. } camCapture_t;
  74. typedef enum
  75. {
  76. ROW_RATIO_1_1,
  77. ROW_RATIO_1_2,
  78. ROW_RATIO_1_3,
  79. ROW_RATIO_1_4,
  80. } camRowRatio_t;
  81. typedef enum
  82. {
  83. COL_RATIO_1_1,
  84. COL_RATIO_1_2,
  85. COL_RATIO_1_3,
  86. COL_RATIO_1_4,
  87. } camColRatio_t;
  88. typedef enum
  89. {
  90. camSpi_In,
  91. camCsi_In,
  92. } camInputSensor_t;
  93. #ifdef CONFIG_QUEC_PROJECT_FEATURE
  94. #define QL_CAM_BF30A2_width_MAX 240
  95. #define QL_CAM_BF30A2_height_MAX 320
  96. #define QL_CAM_GC032A_width_MAX 640
  97. #define QL_CAM_GC032A_height_MAX 480
  98. typedef enum
  99. {
  100. QL_CAM_TYPE_GC032A = 0,
  101. QL_CAM_TYPE_BF30A2,
  102. QL_CAM_TYPE_MAX,
  103. } QL_CAM_TYPE_E;
  104. typedef struct
  105. {
  106. uint16_t cam_width;
  107. uint16_t cam_height;
  108. } ql_cam_sensor_info_s;
  109. #endif
  110. typedef struct sensorInfo
  111. {
  112. const char *name; // name of sensor
  113. drvI2cBps_t baud;
  114. uint8_t salve_i2c_addr_w; // salve i2c write address
  115. uint8_t salve_i2c_addr_r; // salve i2c read address
  116. uint8_t reg_addr_value_bits; // bit0: 0: i2c register value is 8 bit, 1: i2c register value is 16 bit
  117. uint8_t sensorid[2];
  118. uint16_t spi_pixels_per_line; // max width of source image
  119. uint16_t spi_pixels_per_column; // max height of source image
  120. uint16_t rstActiveH; // 1: high level valid; 0: low level valid
  121. uint16_t rstPulseWidth; // Unit: ms. Less than 200ms
  122. uint16_t pdnActiveH; // 1: high level valid; 0: low level valid
  123. uint16_t dstWinColStart;
  124. uint16_t dstWinColEnd;
  125. uint16_t dstWinRowStart;
  126. uint16_t dstWinRowEnd;
  127. uint16_t spi_ctrl_clk_div;
  128. uint32_t i2c_name;
  129. uint32_t nPixcels;
  130. uint8_t captureDrops;
  131. uint8_t preview_page;
  132. uint8_t page_turn;
  133. uint8_t *capturedata;
  134. uint8_t *previewdata[2];
  135. bool isFirstFrame;
  136. bool isStopPrev;
  137. bool isFirst;
  138. bool isCamIfcStart;
  139. bool scaleEnable;
  140. bool cropEnable;
  141. bool dropFrame;
  142. bool spi_href_inv;
  143. bool spi_little_endian_en;
  144. bool isCapture;
  145. bool isCamOpen;
  146. bool ddr_en;
  147. cameraVDD_t avdd_val; // voltage of avdd
  148. cameraVDD_t dvdd_val;
  149. cameraClk_t sensorClk;
  150. camRowRatio_t rowRatio;
  151. camColRatio_t colRatio;
  152. cameraImageFormat_t image_format; // define in SENSOR_IMAGE_FORMAT_E enum,
  153. camSpiMode_t camSpiMode;
  154. camSpiYuv_t camYuvMode;
  155. camCapture_t camCapStatus;
  156. camInputSensor_t sensorType;
  157. drvIfcChannel_t *camp_ipc;
  158. drvI2cMaster_t *i2c_p;
  159. osiSemaphore_t *cam_sem_capture;
  160. osiSemaphore_t *cam_sem_preview;
  161. } sensorInfo_t;
  162. void unittestCam(void);
  163. void drvCamSetPdn(bool pdnActivH);
  164. void drvCamSetRst(bool rstActiveH);
  165. #ifdef CONFIG_SOC_8850
  166. bool drvCamGc2145SetRst(bool rstActiveH);
  167. #endif
  168. void drvCampRegInit(sensorInfo_t *config);
  169. void drvCamClrIrqMask(void);
  170. void drvCamSetIrqMask(cameraIrqCause_t mask);
  171. void drvCamCmdSetFifoRst(void);
  172. void drvCamSetIrqHandler(osiIrqHandler_t hanlder, void *ctx);
  173. void drvCamDisableIrq(void);
  174. void drvCamInitIfc(void);
  175. void drvCampStartTransfer(uint32_t size, uint8_t *data);
  176. bool drvWaitCamIfcDone(void);
  177. void drvCamStopIfc(void);
  178. bool drvCampStopTransfer(uint32_t size, uint8_t *data);
  179. void drvCampIfcDeinit(void);
  180. void drvCamDisableMCLK(void);
  181. void drvCamSetMCLK(cameraClk_t Mclk);
  182. void drvCameraControllerEnable(bool enable);
  183. void drvCampRegDeInit(void);
  184. void drvCamSetPowerLevel(uint32_t id, cameraVDD_t mv);
  185. OSI_EXTERN_C_END
  186. #endif