rkisp1-config.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  1. /* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR MIT) */
  2. /*
  3. * Rockchip ISP1 userspace API
  4. * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
  5. */
  6. #ifndef _UAPI_RKISP1_CONFIG_H
  7. #define _UAPI_RKISP1_CONFIG_H
  8. #include <linux/types.h>
  9. /* Defect Pixel Cluster Detection */
  10. #define RKISP1_CIF_ISP_MODULE_DPCC (1U << 0)
  11. /* Black Level Subtraction */
  12. #define RKISP1_CIF_ISP_MODULE_BLS (1U << 1)
  13. /* Sensor De-gamma */
  14. #define RKISP1_CIF_ISP_MODULE_SDG (1U << 2)
  15. /* Histogram statistics configuration */
  16. #define RKISP1_CIF_ISP_MODULE_HST (1U << 3)
  17. /* Lens Shade Control */
  18. #define RKISP1_CIF_ISP_MODULE_LSC (1U << 4)
  19. /* Auto White Balance Gain */
  20. #define RKISP1_CIF_ISP_MODULE_AWB_GAIN (1U << 5)
  21. /* Filter */
  22. #define RKISP1_CIF_ISP_MODULE_FLT (1U << 6)
  23. /* Bayer Demosaic */
  24. #define RKISP1_CIF_ISP_MODULE_BDM (1U << 7)
  25. /* Cross Talk */
  26. #define RKISP1_CIF_ISP_MODULE_CTK (1U << 8)
  27. /* Gamma Out Curve */
  28. #define RKISP1_CIF_ISP_MODULE_GOC (1U << 9)
  29. /* Color Processing */
  30. #define RKISP1_CIF_ISP_MODULE_CPROC (1U << 10)
  31. /* Auto Focus Control statistics configuration */
  32. #define RKISP1_CIF_ISP_MODULE_AFC (1U << 11)
  33. /* Auto White Balancing statistics configuration */
  34. #define RKISP1_CIF_ISP_MODULE_AWB (1U << 12)
  35. /* Image Effect */
  36. #define RKISP1_CIF_ISP_MODULE_IE (1U << 13)
  37. /* Auto Exposure Control statistics configuration */
  38. #define RKISP1_CIF_ISP_MODULE_AEC (1U << 14)
  39. /* Wide Dynamic Range */
  40. #define RKISP1_CIF_ISP_MODULE_WDR (1U << 15)
  41. /* Denoise Pre-Filter */
  42. #define RKISP1_CIF_ISP_MODULE_DPF (1U << 16)
  43. /* Denoise Pre-Filter Strength */
  44. #define RKISP1_CIF_ISP_MODULE_DPF_STRENGTH (1U << 17)
  45. #define RKISP1_CIF_ISP_CTK_COEFF_MAX 0x100
  46. #define RKISP1_CIF_ISP_CTK_OFFSET_MAX 0x800
  47. #define RKISP1_CIF_ISP_AE_MEAN_MAX_V10 25
  48. #define RKISP1_CIF_ISP_AE_MEAN_MAX_V12 81
  49. #define RKISP1_CIF_ISP_AE_MEAN_MAX RKISP1_CIF_ISP_AE_MEAN_MAX_V12
  50. #define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 16
  51. #define RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 32
  52. #define RKISP1_CIF_ISP_HIST_BIN_N_MAX RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12
  53. #define RKISP1_CIF_ISP_AFM_MAX_WINDOWS 3
  54. #define RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE 17
  55. #define RKISP1_CIF_ISP_BDM_MAX_TH 0xff
  56. /*
  57. * Black level compensation
  58. */
  59. /* maximum value for horizontal start address */
  60. #define RKISP1_CIF_ISP_BLS_START_H_MAX 0x00000fff
  61. /* maximum value for horizontal stop address */
  62. #define RKISP1_CIF_ISP_BLS_STOP_H_MAX 0x00000fff
  63. /* maximum value for vertical start address */
  64. #define RKISP1_CIF_ISP_BLS_START_V_MAX 0x00000fff
  65. /* maximum value for vertical stop address */
  66. #define RKISP1_CIF_ISP_BLS_STOP_V_MAX 0x00000fff
  67. /* maximum is 2^18 = 262144*/
  68. #define RKISP1_CIF_ISP_BLS_SAMPLES_MAX 0x00000012
  69. /* maximum value for fixed black level */
  70. #define RKISP1_CIF_ISP_BLS_FIX_SUB_MAX 0x00000fff
  71. /* minimum value for fixed black level */
  72. #define RKISP1_CIF_ISP_BLS_FIX_SUB_MIN 0xfffff000
  73. /* 13 bit range (signed)*/
  74. #define RKISP1_CIF_ISP_BLS_FIX_MASK 0x00001fff
  75. /*
  76. * Automatic white balance measurements
  77. */
  78. #define RKISP1_CIF_ISP_AWB_MAX_GRID 1
  79. #define RKISP1_CIF_ISP_AWB_MAX_FRAMES 7
  80. /*
  81. * Gamma out
  82. */
  83. /* Maximum number of color samples supported */
  84. #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 17
  85. #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 34
  86. #define RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
  87. /*
  88. * Lens shade correction
  89. */
  90. #define RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE 8
  91. /*
  92. * The following matches the tuning process,
  93. * not the max capabilities of the chip.
  94. */
  95. #define RKISP1_CIF_ISP_LSC_SAMPLES_MAX 17
  96. /*
  97. * Histogram calculation
  98. */
  99. #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 25
  100. #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 81
  101. #define RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
  102. /*
  103. * Defect Pixel Cluster Correction
  104. */
  105. #define RKISP1_CIF_ISP_DPCC_METHODS_MAX 3
  106. #define RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE (1U << 2)
  107. #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER (1U << 0)
  108. #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_RB_CENTER (1U << 1)
  109. #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_G_3X3 (1U << 2)
  110. #define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_RB_3X3 (1U << 3)
  111. /* 0-2 for sets 1-3 */
  112. #define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_SET(n) ((n) << 0)
  113. #define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_FIX_SET (1U << 3)
  114. #define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_GREEN_ENABLE (1U << 0)
  115. #define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_GREEN_ENABLE (1U << 1)
  116. #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_GREEN_ENABLE (1U << 2)
  117. #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_GREEN_ENABLE (1U << 3)
  118. #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_GREEN_ENABLE (1U << 4)
  119. #define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_RED_BLUE_ENABLE (1U << 8)
  120. #define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_RED_BLUE_ENABLE (1U << 9)
  121. #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_RED_BLUE_ENABLE (1U << 10)
  122. #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_RED_BLUE_ENABLE (1U << 11)
  123. #define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_RED_BLUE_ENABLE (1U << 12)
  124. #define RKISP1_CIF_ISP_DPCC_LINE_THRESH_G(v) ((v) << 0)
  125. #define RKISP1_CIF_ISP_DPCC_LINE_THRESH_RB(v) ((v) << 8)
  126. #define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_G(v) ((v) << 0)
  127. #define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_RB(v) ((v) << 8)
  128. #define RKISP1_CIF_ISP_DPCC_PG_FAC_G(v) ((v) << 0)
  129. #define RKISP1_CIF_ISP_DPCC_PG_FAC_RB(v) ((v) << 8)
  130. #define RKISP1_CIF_ISP_DPCC_RND_THRESH_G(v) ((v) << 0)
  131. #define RKISP1_CIF_ISP_DPCC_RND_THRESH_RB(v) ((v) << 8)
  132. #define RKISP1_CIF_ISP_DPCC_RG_FAC_G(v) ((v) << 0)
  133. #define RKISP1_CIF_ISP_DPCC_RG_FAC_RB(v) ((v) << 8)
  134. #define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_G(n, v) ((v) << ((n) * 4))
  135. #define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_RB(n, v) ((v) << ((n) * 4 + 2))
  136. #define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_G(n, v) ((v) << ((n) * 4))
  137. #define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_RB(n, v) ((v) << ((n) * 4 + 2))
  138. /*
  139. * Denoising pre filter
  140. */
  141. #define RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS 17
  142. #define RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS 6
  143. /*
  144. * Measurement types
  145. */
  146. #define RKISP1_CIF_ISP_STAT_AWB (1U << 0)
  147. #define RKISP1_CIF_ISP_STAT_AUTOEXP (1U << 1)
  148. #define RKISP1_CIF_ISP_STAT_AFM (1U << 2)
  149. #define RKISP1_CIF_ISP_STAT_HIST (1U << 3)
  150. /**
  151. * enum rkisp1_cif_isp_version - ISP variants
  152. *
  153. * @RKISP1_V10: used at least in rk3288 and rk3399
  154. * @RKISP1_V11: declared in the original vendor code, but not used
  155. * @RKISP1_V12: used at least in rk3326 and px30
  156. * @RKISP1_V13: used at least in rk1808
  157. */
  158. enum rkisp1_cif_isp_version {
  159. RKISP1_V10 = 10,
  160. RKISP1_V11,
  161. RKISP1_V12,
  162. RKISP1_V13,
  163. };
  164. enum rkisp1_cif_isp_histogram_mode {
  165. RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
  166. RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,
  167. RKISP1_CIF_ISP_HISTOGRAM_MODE_R_HISTOGRAM,
  168. RKISP1_CIF_ISP_HISTOGRAM_MODE_G_HISTOGRAM,
  169. RKISP1_CIF_ISP_HISTOGRAM_MODE_B_HISTOGRAM,
  170. RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM
  171. };
  172. enum rkisp1_cif_isp_awb_mode_type {
  173. RKISP1_CIF_ISP_AWB_MODE_MANUAL,
  174. RKISP1_CIF_ISP_AWB_MODE_RGB,
  175. RKISP1_CIF_ISP_AWB_MODE_YCBCR
  176. };
  177. enum rkisp1_cif_isp_flt_mode {
  178. RKISP1_CIF_ISP_FLT_STATIC_MODE,
  179. RKISP1_CIF_ISP_FLT_DYNAMIC_MODE
  180. };
  181. /**
  182. * enum rkisp1_cif_isp_exp_ctrl_autostop - stop modes
  183. * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0: continuous measurement
  184. * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
  185. */
  186. enum rkisp1_cif_isp_exp_ctrl_autostop {
  187. RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0 = 0,
  188. RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1 = 1,
  189. };
  190. /**
  191. * enum rkisp1_cif_isp_exp_meas_mode - Exposure measure mode
  192. * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B
  193. * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256)
  194. */
  195. enum rkisp1_cif_isp_exp_meas_mode {
  196. RKISP1_CIF_ISP_EXP_MEASURING_MODE_0,
  197. RKISP1_CIF_ISP_EXP_MEASURING_MODE_1,
  198. };
  199. /*---------- PART1: Input Parameters ------------*/
  200. /**
  201. * struct rkisp1_cif_isp_window - measurement window.
  202. *
  203. * Measurements are calculated per window inside the frame.
  204. * This struct represents a window for a measurement.
  205. *
  206. * @h_offs: the horizontal offset of the window from the left of the frame in pixels.
  207. * @v_offs: the vertical offset of the window from the top of the frame in pixels.
  208. * @h_size: the horizontal size of the window in pixels
  209. * @v_size: the vertical size of the window in pixels.
  210. */
  211. struct rkisp1_cif_isp_window {
  212. __u16 h_offs;
  213. __u16 v_offs;
  214. __u16 h_size;
  215. __u16 v_size;
  216. };
  217. /**
  218. * struct rkisp1_cif_isp_bls_fixed_val - BLS fixed subtraction values
  219. *
  220. * The values will be subtracted from the sensor
  221. * values. Therefore a negative value means addition instead of subtraction!
  222. *
  223. * @r: Fixed (signed!) subtraction value for Bayer pattern R
  224. * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr
  225. * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb
  226. * @b: Fixed (signed!) subtraction value for Bayer pattern B
  227. */
  228. struct rkisp1_cif_isp_bls_fixed_val {
  229. __s16 r;
  230. __s16 gr;
  231. __s16 gb;
  232. __s16 b;
  233. };
  234. /**
  235. * struct rkisp1_cif_isp_bls_config - Configuration used by black level subtraction
  236. *
  237. * @enable_auto: Automatic mode activated means that the measured values
  238. * are subtracted. Otherwise the fixed subtraction
  239. * values will be subtracted.
  240. * @en_windows: enabled window
  241. * @bls_window1: Measurement window 1 size
  242. * @bls_window2: Measurement window 2 size
  243. * @bls_samples: Set amount of measured pixels for each Bayer position
  244. * (A, B,C and D) to 2^bls_samples.
  245. * @fixed_val: Fixed subtraction values
  246. */
  247. struct rkisp1_cif_isp_bls_config {
  248. __u8 enable_auto;
  249. __u8 en_windows;
  250. struct rkisp1_cif_isp_window bls_window1;
  251. struct rkisp1_cif_isp_window bls_window2;
  252. __u8 bls_samples;
  253. struct rkisp1_cif_isp_bls_fixed_val fixed_val;
  254. };
  255. /**
  256. * struct rkisp1_cif_isp_dpcc_methods_config - DPCC methods set configuration
  257. *
  258. * This structure stores the configuration of one set of methods for the DPCC
  259. * algorithm. Multiple methods can be selected in each set (independently for
  260. * the Green and Red/Blue components) through the @method field, the result is
  261. * the logical AND of all enabled methods. The remaining fields set thresholds
  262. * and factors for each method.
  263. *
  264. * @method: Method enable bits (RKISP1_CIF_ISP_DPCC_METHODS_SET_*)
  265. * @line_thresh: Line threshold (RKISP1_CIF_ISP_DPCC_LINE_THRESH_*)
  266. * @line_mad_fac: Line Mean Absolute Difference factor (RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_*)
  267. * @pg_fac: Peak gradient factor (RKISP1_CIF_ISP_DPCC_PG_FAC_*)
  268. * @rnd_thresh: Rank Neighbor Difference threshold (RKISP1_CIF_ISP_DPCC_RND_THRESH_*)
  269. * @rg_fac: Rank gradient factor (RKISP1_CIF_ISP_DPCC_RG_FAC_*)
  270. */
  271. struct rkisp1_cif_isp_dpcc_methods_config {
  272. __u32 method;
  273. __u32 line_thresh;
  274. __u32 line_mad_fac;
  275. __u32 pg_fac;
  276. __u32 rnd_thresh;
  277. __u32 rg_fac;
  278. };
  279. /**
  280. * struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC
  281. *
  282. * Configuration used by Defect Pixel Cluster Correction. Three sets of methods
  283. * can be configured and selected through the @set_use field. The result is the
  284. * logical OR of all enabled sets.
  285. *
  286. * @mode: DPCC mode (RKISP1_CIF_ISP_DPCC_MODE_*)
  287. * @output_mode: Interpolation output mode (RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_*)
  288. * @set_use: Methods sets selection (RKISP1_CIF_ISP_DPCC_SET_USE_*)
  289. * @methods: Methods sets configuration
  290. * @ro_limits: Rank order limits (RKISP1_CIF_ISP_DPCC_RO_LIMITS_*)
  291. * @rnd_offs: Differential rank offsets for rank neighbor difference (RKISP1_CIF_ISP_DPCC_RND_OFFS_*)
  292. */
  293. struct rkisp1_cif_isp_dpcc_config {
  294. __u32 mode;
  295. __u32 output_mode;
  296. __u32 set_use;
  297. struct rkisp1_cif_isp_dpcc_methods_config methods[RKISP1_CIF_ISP_DPCC_METHODS_MAX];
  298. __u32 ro_limits;
  299. __u32 rnd_offs;
  300. };
  301. /**
  302. * struct rkisp1_cif_isp_gamma_corr_curve - gamma curve point definition y-axis (output).
  303. *
  304. * The reset values define a linear curve which has the same effect as bypass. Reset values are:
  305. * gamma_y[0] = 0x0000, gamma_y[1] = 0x0100, ... gamma_y[15] = 0x0f00, gamma_y[16] = 0xfff
  306. *
  307. * @gamma_y: the values for the y-axis of gamma curve points. Each value is 12 bit.
  308. */
  309. struct rkisp1_cif_isp_gamma_corr_curve {
  310. __u16 gamma_y[RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE];
  311. };
  312. /**
  313. * struct rkisp1_cif_isp_gamma_curve_x_axis_pnts - De-Gamma Curve definition x increments
  314. * (sampling points). gamma_dx0 is for the lower samples (1-8), gamma_dx1 is for the
  315. * higher samples (9-16). The reset values for both fields is 0x44444444. This means
  316. * that each sample is 4 units away from the previous one on the x-axis.
  317. *
  318. * @gamma_dx0: gamma curve sample points definitions. Bits 0:2 for sample 1. Bit 3 unused.
  319. * Bits 4:6 for sample 2. bit 7 unused ... Bits 28:30 for sample 8. Bit 31 unused
  320. * @gamma_dx1: gamma curve sample points definitions. Bits 0:2 for sample 9. Bit 3 unused.
  321. * Bits 4:6 for sample 10. bit 7 unused ... Bits 28:30 for sample 16. Bit 31 unused
  322. */
  323. struct rkisp1_cif_isp_gamma_curve_x_axis_pnts {
  324. __u32 gamma_dx0;
  325. __u32 gamma_dx1;
  326. };
  327. /**
  328. * struct rkisp1_cif_isp_sdg_config - Configuration used by sensor degamma
  329. *
  330. * @curve_r: gamma curve point definition axis for red
  331. * @curve_g: gamma curve point definition axis for green
  332. * @curve_b: gamma curve point definition axis for blue
  333. * @xa_pnts: x axis increments
  334. */
  335. struct rkisp1_cif_isp_sdg_config {
  336. struct rkisp1_cif_isp_gamma_corr_curve curve_r;
  337. struct rkisp1_cif_isp_gamma_corr_curve curve_g;
  338. struct rkisp1_cif_isp_gamma_corr_curve curve_b;
  339. struct rkisp1_cif_isp_gamma_curve_x_axis_pnts xa_pnts;
  340. };
  341. /**
  342. * struct rkisp1_cif_isp_lsc_config - Configuration used by Lens shading correction
  343. *
  344. * @r_data_tbl: sample table red
  345. * @gr_data_tbl: sample table green (red)
  346. * @gb_data_tbl: sample table green (blue)
  347. * @b_data_tbl: sample table blue
  348. * @x_grad_tbl: gradient table x
  349. * @y_grad_tbl: gradient table y
  350. * @x_size_tbl: size table x
  351. * @y_size_tbl: size table y
  352. * @config_width: not used at the moment
  353. * @config_height: not used at the moment
  354. */
  355. struct rkisp1_cif_isp_lsc_config {
  356. __u16 r_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
  357. __u16 gr_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
  358. __u16 gb_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
  359. __u16 b_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
  360. __u16 x_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
  361. __u16 y_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
  362. __u16 x_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
  363. __u16 y_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
  364. __u16 config_width;
  365. __u16 config_height;
  366. };
  367. /**
  368. * struct rkisp1_cif_isp_ie_config - Configuration used by image effects
  369. *
  370. * @effect: values from 'enum v4l2_colorfx'. Possible values are: V4L2_COLORFX_SEPIA,
  371. * V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_AQUA, V4L2_COLORFX_EMBOSS,
  372. * V4L2_COLORFX_SKETCH, V4L2_COLORFX_BW, V4L2_COLORFX_NEGATIVE
  373. * @color_sel: bits 0:2 - colors bitmask (001 - blue, 010 - green, 100 - red).
  374. * bits 8:15 - Threshold value of the RGB colors for the color selection effect.
  375. * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1
  376. * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2
  377. * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1
  378. * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2
  379. * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3
  380. * @eff_tint: Chrominance increment values of tint (used for sepia effect)
  381. */
  382. struct rkisp1_cif_isp_ie_config {
  383. __u16 effect;
  384. __u16 color_sel;
  385. __u16 eff_mat_1;
  386. __u16 eff_mat_2;
  387. __u16 eff_mat_3;
  388. __u16 eff_mat_4;
  389. __u16 eff_mat_5;
  390. __u16 eff_tint;
  391. };
  392. /**
  393. * struct rkisp1_cif_isp_cproc_config - Configuration used by Color Processing
  394. *
  395. * @c_out_range: Chrominance pixel clipping range at output.
  396. * (0 for limit, 1 for full)
  397. * @y_in_range: Luminance pixel clipping range at output.
  398. * @y_out_range: Luminance pixel clipping range at output.
  399. * @contrast: 00~ff, 0.0~1.992
  400. * @brightness: 80~7F, -128~+127
  401. * @sat: saturation, 00~FF, 0.0~1.992
  402. * @hue: 80~7F, -90~+87.188
  403. */
  404. struct rkisp1_cif_isp_cproc_config {
  405. __u8 c_out_range;
  406. __u8 y_in_range;
  407. __u8 y_out_range;
  408. __u8 contrast;
  409. __u8 brightness;
  410. __u8 sat;
  411. __u8 hue;
  412. };
  413. /**
  414. * struct rkisp1_cif_isp_awb_meas_config - Configuration for the AWB statistics
  415. *
  416. * @awb_mode: the awb meas mode. From enum rkisp1_cif_isp_awb_mode_type.
  417. * @awb_wnd: white balance measurement window (in pixels)
  418. * @max_y: only pixels values < max_y contribute to awb measurement, set to 0
  419. * to disable this feature
  420. * @min_y: only pixels values > min_y contribute to awb measurement
  421. * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr,
  422. * smaller than threshold for awb measurements
  423. * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr
  424. * each greater than threshold value for awb measurements
  425. * @frames: number of frames - 1 used for mean value calculation
  426. * (ucFrames=0 means 1 Frame)
  427. * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB
  428. * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB
  429. * @enable_ymax_cmp: enable Y_MAX compare (Not valid in RGB measurement mode.)
  430. */
  431. struct rkisp1_cif_isp_awb_meas_config {
  432. /*
  433. * Note: currently the h and v offsets are mapped to grid offsets
  434. */
  435. struct rkisp1_cif_isp_window awb_wnd;
  436. __u32 awb_mode;
  437. __u8 max_y;
  438. __u8 min_y;
  439. __u8 max_csum;
  440. __u8 min_c;
  441. __u8 frames;
  442. __u8 awb_ref_cr;
  443. __u8 awb_ref_cb;
  444. __u8 enable_ymax_cmp;
  445. };
  446. /**
  447. * struct rkisp1_cif_isp_awb_gain_config - Configuration used by auto white balance gain
  448. *
  449. * All fields in this struct are 10 bit, where:
  450. * 0x100h = 1, unsigned integer value, range 0 to 4 with 8 bit fractional part.
  451. *
  452. * out_data_x = ( AWB_GAIN_X * in_data + 128) >> 8
  453. *
  454. * @gain_red: gain value for red component.
  455. * @gain_green_r: gain value for green component in red line.
  456. * @gain_blue: gain value for blue component.
  457. * @gain_green_b: gain value for green component in blue line.
  458. */
  459. struct rkisp1_cif_isp_awb_gain_config {
  460. __u16 gain_red;
  461. __u16 gain_green_r;
  462. __u16 gain_blue;
  463. __u16 gain_green_b;
  464. };
  465. /**
  466. * struct rkisp1_cif_isp_flt_config - Configuration used by ISP filtering
  467. *
  468. * All 4 threshold fields (thresh_*) are 10 bits.
  469. * All 6 factor fields (fac_*) are 6 bits.
  470. *
  471. * @mode: ISP_FILT_MODE register fields (from enum rkisp1_cif_isp_flt_mode)
  472. * @grn_stage1: Green filter stage 1 select (range 0x0...0x8)
  473. * @chr_h_mode: Chroma filter horizontal mode
  474. * @chr_v_mode: Chroma filter vertical mode
  475. * @thresh_bl0: If thresh_bl1 < sum_grad < thresh_bl0 then fac_bl0 is selected (blurring th)
  476. * @thresh_bl1: If sum_grad < thresh_bl1 then fac_bl1 is selected (blurring th)
  477. * @thresh_sh0: If thresh_sh0 < sum_grad < thresh_sh1 then thresh_sh0 is selected (sharpening th)
  478. * @thresh_sh1: If thresh_sh1 < sum_grad then thresh_sh1 is selected (sharpening th)
  479. * @lum_weight: Parameters for luminance weight function.
  480. * @fac_sh1: filter factor for sharp1 level
  481. * @fac_sh0: filter factor for sharp0 level
  482. * @fac_mid: filter factor for mid level and for static filter mode
  483. * @fac_bl0: filter factor for blur 0 level
  484. * @fac_bl1: filter factor for blur 1 level (max blur)
  485. */
  486. struct rkisp1_cif_isp_flt_config {
  487. __u32 mode;
  488. __u8 grn_stage1;
  489. __u8 chr_h_mode;
  490. __u8 chr_v_mode;
  491. __u32 thresh_bl0;
  492. __u32 thresh_bl1;
  493. __u32 thresh_sh0;
  494. __u32 thresh_sh1;
  495. __u32 lum_weight;
  496. __u32 fac_sh1;
  497. __u32 fac_sh0;
  498. __u32 fac_mid;
  499. __u32 fac_bl0;
  500. __u32 fac_bl1;
  501. };
  502. /**
  503. * struct rkisp1_cif_isp_bdm_config - Configuration used by Bayer DeMosaic
  504. *
  505. * @demosaic_th: threshold for bayer demosaicing texture detection
  506. */
  507. struct rkisp1_cif_isp_bdm_config {
  508. __u8 demosaic_th;
  509. };
  510. /**
  511. * struct rkisp1_cif_isp_ctk_config - Configuration used by Cross Talk correction
  512. *
  513. * @coeff: color correction matrix. Values are 11-bit signed fixed-point numbers with 4 bit integer
  514. * and 7 bit fractional part, ranging from -8 (0x400) to +7.992 (0x3FF). 0 is
  515. * represented by 0x000 and a coefficient value of 1 as 0x080.
  516. * @ct_offset: Red, Green, Blue offsets for the crosstalk correction matrix
  517. */
  518. struct rkisp1_cif_isp_ctk_config {
  519. __u16 coeff[3][3];
  520. __u16 ct_offset[3];
  521. };
  522. enum rkisp1_cif_isp_goc_mode {
  523. RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC,
  524. RKISP1_CIF_ISP_GOC_MODE_EQUIDISTANT
  525. };
  526. /**
  527. * struct rkisp1_cif_isp_goc_config - Configuration used by Gamma Out correction
  528. *
  529. * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode)
  530. * @gamma_y: gamma out curve y-axis for all color components
  531. *
  532. * The number of entries of @gamma_y depends on the hardware revision
  533. * as is reported by the hw_revision field of the struct media_device_info
  534. * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  535. *
  536. * Versions <= V11 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10
  537. * entries, versions >= V12 have RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12
  538. * entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum
  539. * of the two.
  540. */
  541. struct rkisp1_cif_isp_goc_config {
  542. __u32 mode;
  543. __u16 gamma_y[RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES];
  544. };
  545. /**
  546. * struct rkisp1_cif_isp_hst_config - Configuration for Histogram statistics
  547. *
  548. * @mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode)
  549. * @histogram_predivider: process every stepsize pixel, all other pixels are
  550. * skipped
  551. * @meas_window: coordinates of the measure window
  552. * @hist_weight: weighting factor for sub-windows
  553. *
  554. * The number of entries of @hist_weight depends on the hardware revision
  555. * as is reported by the hw_revision field of the struct media_device_info
  556. * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  557. *
  558. * Versions <= V11 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10
  559. * entries, versions >= V12 have RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12
  560. * entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum
  561. * of the two.
  562. */
  563. struct rkisp1_cif_isp_hst_config {
  564. __u32 mode;
  565. __u8 histogram_predivider;
  566. struct rkisp1_cif_isp_window meas_window;
  567. __u8 hist_weight[RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE];
  568. };
  569. /**
  570. * struct rkisp1_cif_isp_aec_config - Configuration for Auto Exposure statistics
  571. *
  572. * @mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode)
  573. * @autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop)
  574. * @meas_window: coordinates of the measure window
  575. */
  576. struct rkisp1_cif_isp_aec_config {
  577. __u32 mode;
  578. __u32 autostop;
  579. struct rkisp1_cif_isp_window meas_window;
  580. };
  581. /**
  582. * struct rkisp1_cif_isp_afc_config - Configuration for the Auto Focus statistics
  583. *
  584. * @num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWS
  585. * @afm_win: coordinates of the meas window
  586. * @thres: threshold used for minimizing the influence of noise
  587. * @var_shift: the number of bits for the shift operation at the end of the
  588. * calculation chain.
  589. */
  590. struct rkisp1_cif_isp_afc_config {
  591. __u8 num_afm_win;
  592. struct rkisp1_cif_isp_window afm_win[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
  593. __u32 thres;
  594. __u32 var_shift;
  595. };
  596. /**
  597. * enum rkisp1_cif_isp_dpf_gain_usage - dpf gain usage
  598. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage
  599. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from
  600. * registers DPF_NF_GAIN_R, ...
  601. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS: use only the gains from LSC module
  602. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the
  603. * gains from LSC module
  604. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module
  605. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module
  606. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation)
  607. */
  608. enum rkisp1_cif_isp_dpf_gain_usage {
  609. RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED,
  610. RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS,
  611. RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS,
  612. RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS,
  613. RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS,
  614. RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS,
  615. RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX
  616. };
  617. /**
  618. * enum rkisp1_cif_isp_dpf_rb_filtersize - Red and blue filter sizes
  619. * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9
  620. * (means 7x5 active pixel)
  621. * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9
  622. * (means 5x5 active pixel)
  623. */
  624. enum rkisp1_cif_isp_dpf_rb_filtersize {
  625. RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9,
  626. RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9,
  627. };
  628. /**
  629. * enum rkisp1_cif_isp_dpf_nll_scale_mode - dpf noise level scale mode
  630. * @RKISP1_CIF_ISP_NLL_SCALE_LINEAR: use a linear scaling
  631. * @RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling
  632. */
  633. enum rkisp1_cif_isp_dpf_nll_scale_mode {
  634. RKISP1_CIF_ISP_NLL_SCALE_LINEAR,
  635. RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC,
  636. };
  637. /**
  638. * struct rkisp1_cif_isp_dpf_nll - Noise level lookup
  639. *
  640. * @coeff: Noise level Lookup coefficient
  641. * @scale_mode: dpf noise level scale mode (from enum rkisp1_cif_isp_dpf_nll_scale_mode)
  642. */
  643. struct rkisp1_cif_isp_dpf_nll {
  644. __u16 coeff[RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS];
  645. __u32 scale_mode;
  646. };
  647. /**
  648. * struct rkisp1_cif_isp_dpf_rb_flt - Red blue filter config
  649. *
  650. * @fltsize: The filter size for the red and blue pixels
  651. * (from enum rkisp1_cif_isp_dpf_rb_filtersize)
  652. * @spatial_coeff: Spatial weights
  653. * @r_enable: enable filter processing for red pixels
  654. * @b_enable: enable filter processing for blue pixels
  655. */
  656. struct rkisp1_cif_isp_dpf_rb_flt {
  657. __u32 fltsize;
  658. __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
  659. __u8 r_enable;
  660. __u8 b_enable;
  661. };
  662. /**
  663. * struct rkisp1_cif_isp_dpf_g_flt - Green filter Configuration
  664. *
  665. * @spatial_coeff: Spatial weights
  666. * @gr_enable: enable filter processing for green pixels in green/red lines
  667. * @gb_enable: enable filter processing for green pixels in green/blue lines
  668. */
  669. struct rkisp1_cif_isp_dpf_g_flt {
  670. __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
  671. __u8 gr_enable;
  672. __u8 gb_enable;
  673. };
  674. /**
  675. * struct rkisp1_cif_isp_dpf_gain - Noise function Configuration
  676. *
  677. * @mode: dpf gain usage (from enum rkisp1_cif_isp_dpf_gain_usage)
  678. * @nf_r_gain: Noise function Gain that replaces the AWB gain for red pixels
  679. * @nf_b_gain: Noise function Gain that replaces the AWB gain for blue pixels
  680. * @nf_gr_gain: Noise function Gain that replaces the AWB gain
  681. * for green pixels in a red line
  682. * @nf_gb_gain: Noise function Gain that replaces the AWB gain
  683. * for green pixels in a blue line
  684. */
  685. struct rkisp1_cif_isp_dpf_gain {
  686. __u32 mode;
  687. __u16 nf_r_gain;
  688. __u16 nf_b_gain;
  689. __u16 nf_gr_gain;
  690. __u16 nf_gb_gain;
  691. };
  692. /**
  693. * struct rkisp1_cif_isp_dpf_config - Configuration used by De-noising pre-filter
  694. *
  695. * @gain: noise function gain
  696. * @g_flt: green filter config
  697. * @rb_flt: red blue filter config
  698. * @nll: noise level lookup
  699. */
  700. struct rkisp1_cif_isp_dpf_config {
  701. struct rkisp1_cif_isp_dpf_gain gain;
  702. struct rkisp1_cif_isp_dpf_g_flt g_flt;
  703. struct rkisp1_cif_isp_dpf_rb_flt rb_flt;
  704. struct rkisp1_cif_isp_dpf_nll nll;
  705. };
  706. /**
  707. * struct rkisp1_cif_isp_dpf_strength_config - strength of the filter
  708. *
  709. * @r: filter strength of the RED filter
  710. * @g: filter strength of the GREEN filter
  711. * @b: filter strength of the BLUE filter
  712. */
  713. struct rkisp1_cif_isp_dpf_strength_config {
  714. __u8 r;
  715. __u8 g;
  716. __u8 b;
  717. };
  718. /**
  719. * struct rkisp1_cif_isp_isp_other_cfg - Parameters for some blocks in rockchip isp1
  720. *
  721. * @dpcc_config: Defect Pixel Cluster Correction config
  722. * @bls_config: Black Level Subtraction config
  723. * @sdg_config: sensor degamma config
  724. * @lsc_config: Lens Shade config
  725. * @awb_gain_config: Auto White balance gain config
  726. * @flt_config: filter config
  727. * @bdm_config: demosaic config
  728. * @ctk_config: cross talk config
  729. * @goc_config: gamma out config
  730. * @bls_config: black level subtraction config
  731. * @dpf_config: De-noising pre-filter config
  732. * @dpf_strength_config: dpf strength config
  733. * @cproc_config: color process config
  734. * @ie_config: image effects config
  735. */
  736. struct rkisp1_cif_isp_isp_other_cfg {
  737. struct rkisp1_cif_isp_dpcc_config dpcc_config;
  738. struct rkisp1_cif_isp_bls_config bls_config;
  739. struct rkisp1_cif_isp_sdg_config sdg_config;
  740. struct rkisp1_cif_isp_lsc_config lsc_config;
  741. struct rkisp1_cif_isp_awb_gain_config awb_gain_config;
  742. struct rkisp1_cif_isp_flt_config flt_config;
  743. struct rkisp1_cif_isp_bdm_config bdm_config;
  744. struct rkisp1_cif_isp_ctk_config ctk_config;
  745. struct rkisp1_cif_isp_goc_config goc_config;
  746. struct rkisp1_cif_isp_dpf_config dpf_config;
  747. struct rkisp1_cif_isp_dpf_strength_config dpf_strength_config;
  748. struct rkisp1_cif_isp_cproc_config cproc_config;
  749. struct rkisp1_cif_isp_ie_config ie_config;
  750. };
  751. /**
  752. * struct rkisp1_cif_isp_isp_meas_cfg - Rockchip ISP1 Measure Parameters
  753. *
  754. * @awb_meas_config: auto white balance config
  755. * @hst_config: histogram config
  756. * @aec_config: auto exposure config
  757. * @afc_config: auto focus config
  758. */
  759. struct rkisp1_cif_isp_isp_meas_cfg {
  760. struct rkisp1_cif_isp_awb_meas_config awb_meas_config;
  761. struct rkisp1_cif_isp_hst_config hst_config;
  762. struct rkisp1_cif_isp_aec_config aec_config;
  763. struct rkisp1_cif_isp_afc_config afc_config;
  764. };
  765. /**
  766. * struct rkisp1_params_cfg - Rockchip ISP1 Input Parameters Meta Data
  767. *
  768. * @module_en_update: mask the enable bits of which module should be updated
  769. * @module_ens: mask the enable value of each module, only update the module
  770. * which correspond bit was set in module_en_update
  771. * @module_cfg_update: mask the config bits of which module should be updated
  772. * @meas: measurement config
  773. * @others: other config
  774. */
  775. struct rkisp1_params_cfg {
  776. __u32 module_en_update;
  777. __u32 module_ens;
  778. __u32 module_cfg_update;
  779. struct rkisp1_cif_isp_isp_meas_cfg meas;
  780. struct rkisp1_cif_isp_isp_other_cfg others;
  781. };
  782. /*---------- PART2: Measurement Statistics ------------*/
  783. /**
  784. * struct rkisp1_cif_isp_awb_meas - AWB measured values
  785. *
  786. * @cnt: White pixel count, number of "white pixels" found during last
  787. * measurement
  788. * @mean_y_or_g: Mean value of Y within window and frames,
  789. * Green if RGB is selected.
  790. * @mean_cb_or_b: Mean value of Cb within window and frames,
  791. * Blue if RGB is selected.
  792. * @mean_cr_or_r: Mean value of Cr within window and frames,
  793. * Red if RGB is selected.
  794. */
  795. struct rkisp1_cif_isp_awb_meas {
  796. __u32 cnt;
  797. __u8 mean_y_or_g;
  798. __u8 mean_cb_or_b;
  799. __u8 mean_cr_or_r;
  800. };
  801. /**
  802. * struct rkisp1_cif_isp_awb_stat - statistics automatic white balance data
  803. *
  804. * @awb_mean: Mean measured data
  805. */
  806. struct rkisp1_cif_isp_awb_stat {
  807. struct rkisp1_cif_isp_awb_meas awb_mean[RKISP1_CIF_ISP_AWB_MAX_GRID];
  808. };
  809. /**
  810. * struct rkisp1_cif_isp_bls_meas_val - BLS measured values
  811. *
  812. * @meas_r: Mean measured value for Bayer pattern R
  813. * @meas_gr: Mean measured value for Bayer pattern Gr
  814. * @meas_gb: Mean measured value for Bayer pattern Gb
  815. * @meas_b: Mean measured value for Bayer pattern B
  816. */
  817. struct rkisp1_cif_isp_bls_meas_val {
  818. __u16 meas_r;
  819. __u16 meas_gr;
  820. __u16 meas_gb;
  821. __u16 meas_b;
  822. };
  823. /**
  824. * struct rkisp1_cif_isp_ae_stat - statistics auto exposure data
  825. *
  826. * @exp_mean: Mean luminance value of block xx
  827. * @bls_val: BLS measured values
  828. *
  829. * The number of entries of @exp_mean depends on the hardware revision
  830. * as is reported by the hw_revision field of the struct media_device_info
  831. * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  832. *
  833. * Versions <= V11 have RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries,
  834. * versions >= V12 have RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries.
  835. * RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
  836. *
  837. * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
  838. */
  839. struct rkisp1_cif_isp_ae_stat {
  840. __u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX];
  841. struct rkisp1_cif_isp_bls_meas_val bls_val;
  842. };
  843. /**
  844. * struct rkisp1_cif_isp_af_meas_val - AF measured values
  845. *
  846. * @sum: sharpness value
  847. * @lum: luminance value
  848. */
  849. struct rkisp1_cif_isp_af_meas_val {
  850. __u32 sum;
  851. __u32 lum;
  852. };
  853. /**
  854. * struct rkisp1_cif_isp_af_stat - statistics auto focus data
  855. *
  856. * @window: AF measured value of window x
  857. *
  858. * The module measures the sharpness in 3 windows of selectable size via
  859. * register settings(ISP_AFM_*_A/B/C)
  860. */
  861. struct rkisp1_cif_isp_af_stat {
  862. struct rkisp1_cif_isp_af_meas_val window[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
  863. };
  864. /**
  865. * struct rkisp1_cif_isp_hist_stat - statistics histogram data
  866. *
  867. * @hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point
  868. * type. Bits 0-4 are the fractional part and bits 5-19 are the
  869. * integer part.
  870. *
  871. * The window of the measurements area is divided to 5x5 sub-windows for
  872. * V10/V11 and to 9x9 sub-windows for V12. The histogram is then computed for
  873. * each sub-window independently and the final result is a weighted average of
  874. * the histogram measurements on all sub-windows. The window of the
  875. * measurements area and the weight of each sub-window are configurable using
  876. * struct @rkisp1_cif_isp_hst_config.
  877. *
  878. * The histogram contains 16 bins in V10/V11 and 32 bins in V12/V13.
  879. *
  880. * The number of entries of @hist_bins depends on the hardware revision
  881. * as is reported by the hw_revision field of the struct media_device_info
  882. * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  883. *
  884. * Versions <= V11 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries,
  885. * versions >= V12 have RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries.
  886. * RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
  887. */
  888. struct rkisp1_cif_isp_hist_stat {
  889. __u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
  890. };
  891. /**
  892. * struct rkisp1_cif_isp_stat - Rockchip ISP1 Statistics Data
  893. *
  894. * @awb: statistics data for automatic white balance
  895. * @ae: statistics data for auto exposure
  896. * @af: statistics data for auto focus
  897. * @hist: statistics histogram data
  898. */
  899. struct rkisp1_cif_isp_stat {
  900. struct rkisp1_cif_isp_awb_stat awb;
  901. struct rkisp1_cif_isp_ae_stat ae;
  902. struct rkisp1_cif_isp_af_stat af;
  903. struct rkisp1_cif_isp_hist_stat hist;
  904. };
  905. /**
  906. * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data
  907. *
  908. * @meas_type: measurement types (RKISP1_CIF_ISP_STAT_* definitions)
  909. * @frame_id: frame ID for sync
  910. * @params: statistics data
  911. */
  912. struct rkisp1_stat_buffer {
  913. __u32 meas_type;
  914. __u32 frame_id;
  915. struct rkisp1_cif_isp_stat params;
  916. };
  917. #endif /* _UAPI_RKISP1_CONFIG_H */