vvsensor.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /****************************************************************************
  2. *
  3. * The MIT License (MIT)
  4. *
  5. * Copyright (c) 2020 VeriSilicon Holdings Co., Ltd.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. *
  25. *****************************************************************************
  26. *
  27. * The GPL License (GPL)
  28. *
  29. * Copyright (c) 2020 VeriSilicon Holdings Co., Ltd.
  30. *
  31. * This program is free software; you can redistribute it and/or
  32. * modify it under the terms of the GNU General Public License
  33. * as published by the Free Software Foundation; either version 2
  34. * of the License, or (at your option) any later version.
  35. *
  36. * This program is distributed in the hope that it will be useful,
  37. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39. * GNU General Public License for more details.
  40. *
  41. * You should have received a copy of the GNU General Public License
  42. * along with this program;
  43. *
  44. *****************************************************************************
  45. *
  46. * Note: This software is released under dual MIT and GPL licenses. A
  47. * recipient may use this file under the terms of either the MIT license or
  48. * GPL License. If you wish to use only one license not the other, you can
  49. * indicate your decision by deleting one of the above license notices in your
  50. * version of this file.
  51. *
  52. *****************************************************************************/
  53. #ifndef _VVSENSOR_PUBLIC_HEADER_H_
  54. #define _VVSENSOR_PUBLIC_HEADER_H_
  55. #ifndef __KERNEL__
  56. #include <stdint.h>
  57. #else
  58. #include <linux/uaccess.h>
  59. #endif
  60. #define VVCAM_SUPPORT_MAX_MODE_COUNT 20
  61. #define VVCAM_CAP_BUS_INFO_I2C_ADAPTER_NR_POS 8
  62. enum {
  63. VVSENSORIOC_RESET = 0x100,
  64. VVSENSORIOC_S_CLK,
  65. VVSENSORIOC_G_CLK,
  66. VVSENSORIOC_S_POWER,
  67. VVSENSORIOC_G_POWER,
  68. VVSENSORIOC_SENSOR_SCCB_CFG,
  69. VVSENSORIOC_FOCUS_SCCB_CFG,
  70. VVSENSORIOC_READ_REG,
  71. VVSENSORIOC_WRITE_REG,
  72. VVSENSORIOC_READ_ARRAY,
  73. VVSENSORIOC_WRITE_ARRAY,
  74. VVSENSORIOC_AF_READ_REG,
  75. VVSENSORIOC_AF_WRITE_REG,
  76. VVSENSORIOC_G_MIPI,
  77. VVSENSORIOC_G_NAME,
  78. VVSENSORIOC_G_RESERVE_ID,
  79. VVSENSORIOC_G_CHIP_ID,
  80. VVSENSORIOC_S_INIT,
  81. VVSENSORIOC_S_STREAM,
  82. VVSENSORIOC_S_LONG_EXP,
  83. VVSENSORIOC_S_EXP,
  84. VVSENSORIOC_S_VSEXP,
  85. VVSENSORIOC_S_LONG_GAIN,
  86. VVSENSORIOC_S_GAIN,
  87. VVSENSORIOC_S_VSGAIN,
  88. VVSENSORIOC_S_FRAMESIZE,
  89. VVSENSORIOC_ENUM_FRAMESIZES,
  90. VVSENSORIOC_S_HDR_MODE,
  91. VVSENSORIOC_G_HDR_MODE,
  92. VVSENSORIOC_S_FPS,
  93. VVSENSORIOC_G_FPS,
  94. VVSENSORIOC_S_HDR_RADIO,
  95. VVSENSORIOC_G_AE_INFO,
  96. VVSENSORIOC_QUERY,
  97. VVSENSORIOC_G_SENSOR_MODE,
  98. VVSENSORIOC_S_WB,
  99. VVSENSORIOC_S_BLC,
  100. VVSENSORIOC_G_EXPAND_CURVE,
  101. VVSENSORIOC_S_SENSOR_MODE,
  102. VVSENSORIOC_MAX,
  103. };
  104. /* W/R registers */
  105. struct vvcam_sccb_data {
  106. uint32_t addr;
  107. uint32_t data;
  108. };
  109. /* init settings */
  110. struct vvsensor_reg_value_t {
  111. uint16_t addr;
  112. uint8_t val;
  113. uint8_t mask;
  114. uint32_t delay;
  115. };
  116. /* priv ioctl */
  117. struct vvsensor_gain_context {
  118. uint32_t again;
  119. uint32_t dgain;
  120. };
  121. /* vsi native usage */
  122. struct vvcam_sccb_cfg_s {
  123. uint8_t slave_addr;
  124. uint8_t addr_byte;
  125. uint8_t data_byte;
  126. };
  127. struct vvcam_sccb_array {
  128. uint32_t count;
  129. struct vvcam_sccb_data *sccb_data;
  130. };
  131. typedef struct vvcam_ae_info_s {
  132. uint32_t DefaultFrameLengthLines;
  133. uint32_t CurFrameLengthLines;
  134. uint32_t one_line_exp_time_ns;
  135. uint32_t max_integration_time;
  136. uint32_t min_integration_time;
  137. uint32_t integration_accuracy;
  138. uint32_t max_gain;
  139. uint32_t min_gain;
  140. uint32_t gain_accuracy;
  141. uint32_t cur_fps;
  142. uint32_t hdr_radio;
  143. } vvcam_ae_info_t;
  144. struct sensor_mipi_info {
  145. uint32_t mipi_lane;
  146. uint32_t sensor_data_bit;
  147. };
  148. enum sensor_hdr_mode_e
  149. {
  150. SENSOR_MODE_LINEAR ,
  151. SENSOR_MODE_HDR_STITCH,
  152. SENSOR_MODE_HDR_NATIVE,
  153. };
  154. enum SENSOR_BAYER_PATTERN_E
  155. {
  156. BAYER_RGGB = 0,
  157. BAYER_GRBG = 1,
  158. BAYER_GBRG = 2,
  159. BAYER_BGGR = 3,
  160. BAYER_BUTT
  161. };
  162. enum sensor_stitching_mode_e
  163. {
  164. SENSOR_STITCHING_DUAL_DCG = 0, /**< dual DCG mode 3x12-bit */
  165. SENSOR_STITCHING_3DOL = 1, /**< dol3 frame 3x12-bit */
  166. SENSOR_STITCHING_LINEBYLINE = 2, /**< 3x12-bit line by line without waiting */
  167. SENSOR_STITCHING_16BIT_COMPRESS = 3, /**< 16-bit compressed data + 12-bit RAW */
  168. SENSOR_STITCHING_DUAL_DCG_NOWAIT = 4, /**< 2x12-bit dual DCG without waiting */
  169. SENSOR_STITCHING_2DOL = 5, /**< dol2 frame or 1 CG+VS sx12-bit RAW */
  170. SENSOR_STITCHING_L_AND_S = 6, /**< L+S 2x12-bit RAW */
  171. SENSOR_STITCHING_MAX
  172. };
  173. typedef struct sensor_expand_curve_s
  174. {
  175. uint32_t x_bit;
  176. uint32_t y_bit;
  177. uint8_t expand_px[64];
  178. uint32_t expand_x_data[65];
  179. uint32_t expand_y_data[65];
  180. }sensor_expand_curve_t;
  181. typedef struct sensor_data_compress_s
  182. {
  183. uint32_t enable;
  184. uint32_t x_bit;
  185. uint32_t y_bit;
  186. }sensor_data_compress_t;
  187. typedef struct vvcam_mode_info {
  188. uint32_t index;
  189. uint32_t width;
  190. uint32_t height;
  191. uint32_t fps;
  192. uint32_t hdr_mode;
  193. uint32_t stitching_mode;
  194. uint32_t bit_width;
  195. sensor_data_compress_t data_compress;
  196. uint32_t bayer_pattern;
  197. vvcam_ae_info_t ae_info;
  198. void *preg_data;
  199. uint32_t reg_data_count;
  200. uint32_t mipi_phy_freq;
  201. uint32_t mipi_line_num;
  202. } vvcam_mode_info_t;
  203. typedef struct sensor_blc_s
  204. {
  205. uint32_t red;
  206. uint32_t gr;
  207. uint32_t gb;
  208. uint32_t blue;
  209. }sensor_blc_t;
  210. typedef struct sensor_white_balance_s
  211. {
  212. uint32_t r_gain;
  213. uint32_t gr_gain;
  214. uint32_t gb_gain;
  215. uint32_t b_gain;
  216. }sensor_white_balance_t;
  217. typedef struct vvcam_mode_info_array {
  218. uint32_t count;
  219. struct vvcam_mode_info modes[VVCAM_SUPPORT_MAX_MODE_COUNT];
  220. } vvcam_mode_info_array_t;
  221. #ifdef SENSOR_CROP
  222. /**************************************
  223. *Reserved for sensor crop
  224. ***************************************/
  225. typedef struct sensor_crop_regions_s
  226. {
  227. uint32_t offs_x;
  228. uint32_t offs_y;
  229. uint32_t width;
  230. uint32_t height;
  231. }sensor_crop_regions_t;
  232. typedef struct sensor_crop_limits_s
  233. {
  234. uint32_t mode_index;
  235. sensor_crop_regions_t max_regions;
  236. sensor_crop_regions_t min_regions;
  237. }sensor_crop_limits_t;
  238. #endif
  239. #endif