logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

rkisp1-config.h (58368B)


  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 _RKISP1_CONFIG_H
  7. #define _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. * Compand
  145. */
  146. #define RKISP1_CIF_ISP_COMPAND_NUM_POINTS 64
  147. /*
  148. * Measurement types
  149. */
  150. #define RKISP1_CIF_ISP_STAT_AWB (1U << 0)
  151. #define RKISP1_CIF_ISP_STAT_AUTOEXP (1U << 1)
  152. #define RKISP1_CIF_ISP_STAT_AFM (1U << 2)
  153. #define RKISP1_CIF_ISP_STAT_HIST (1U << 3)
  154. /**
  155. * enum rkisp1_cif_isp_version - ISP variants
  156. *
  157. * @RKISP1_V10: Used at least in RK3288 and RK3399.
  158. * @RKISP1_V11: Declared in the original vendor code, but not used. Same number
  159. * of entries in grids and histogram as v10.
  160. * @RKISP1_V12: Used at least in RK3326 and PX30.
  161. * @RKISP1_V13: Used at least in RK1808. Same number of entries in grids and
  162. * histogram as v12.
  163. * @RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids
  164. * and histogram as v10.
  165. */
  166. enum rkisp1_cif_isp_version {
  167. RKISP1_V10 = 10,
  168. RKISP1_V11,
  169. RKISP1_V12,
  170. RKISP1_V13,
  171. RKISP1_V_IMX8MP,
  172. };
  173. enum rkisp1_cif_isp_histogram_mode {
  174. RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
  175. RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED,
  176. RKISP1_CIF_ISP_HISTOGRAM_MODE_R_HISTOGRAM,
  177. RKISP1_CIF_ISP_HISTOGRAM_MODE_G_HISTOGRAM,
  178. RKISP1_CIF_ISP_HISTOGRAM_MODE_B_HISTOGRAM,
  179. RKISP1_CIF_ISP_HISTOGRAM_MODE_Y_HISTOGRAM
  180. };
  181. enum rkisp1_cif_isp_awb_mode_type {
  182. RKISP1_CIF_ISP_AWB_MODE_MANUAL,
  183. RKISP1_CIF_ISP_AWB_MODE_RGB,
  184. RKISP1_CIF_ISP_AWB_MODE_YCBCR
  185. };
  186. enum rkisp1_cif_isp_flt_mode {
  187. RKISP1_CIF_ISP_FLT_STATIC_MODE,
  188. RKISP1_CIF_ISP_FLT_DYNAMIC_MODE
  189. };
  190. /**
  191. * enum rkisp1_cif_isp_exp_ctrl_autostop - stop modes
  192. * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0: continuous measurement
  193. * @RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
  194. */
  195. enum rkisp1_cif_isp_exp_ctrl_autostop {
  196. RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0 = 0,
  197. RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1 = 1,
  198. };
  199. /**
  200. * enum rkisp1_cif_isp_exp_meas_mode - Exposure measure mode
  201. * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B
  202. * @RKISP1_CIF_ISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256)
  203. */
  204. enum rkisp1_cif_isp_exp_meas_mode {
  205. RKISP1_CIF_ISP_EXP_MEASURING_MODE_0,
  206. RKISP1_CIF_ISP_EXP_MEASURING_MODE_1,
  207. };
  208. /*---------- PART1: Input Parameters ------------*/
  209. /**
  210. * struct rkisp1_cif_isp_window - measurement window.
  211. *
  212. * Measurements are calculated per window inside the frame.
  213. * This struct represents a window for a measurement.
  214. *
  215. * @h_offs: the horizontal offset of the window from the left of the frame in pixels.
  216. * @v_offs: the vertical offset of the window from the top of the frame in pixels.
  217. * @h_size: the horizontal size of the window in pixels
  218. * @v_size: the vertical size of the window in pixels.
  219. */
  220. struct rkisp1_cif_isp_window {
  221. __u16 h_offs;
  222. __u16 v_offs;
  223. __u16 h_size;
  224. __u16 v_size;
  225. };
  226. /**
  227. * struct rkisp1_cif_isp_bls_fixed_val - BLS fixed subtraction values
  228. *
  229. * The values will be subtracted from the sensor
  230. * values. Therefore a negative value means addition instead of subtraction!
  231. *
  232. * @r: Fixed (signed!) subtraction value for Bayer pattern R
  233. * @gr: Fixed (signed!) subtraction value for Bayer pattern Gr
  234. * @gb: Fixed (signed!) subtraction value for Bayer pattern Gb
  235. * @b: Fixed (signed!) subtraction value for Bayer pattern B
  236. */
  237. struct rkisp1_cif_isp_bls_fixed_val {
  238. __s16 r;
  239. __s16 gr;
  240. __s16 gb;
  241. __s16 b;
  242. };
  243. /**
  244. * struct rkisp1_cif_isp_bls_config - Configuration used by black level subtraction
  245. *
  246. * @enable_auto: Automatic mode activated means that the measured values
  247. * are subtracted. Otherwise the fixed subtraction
  248. * values will be subtracted.
  249. * @en_windows: enabled window
  250. * @bls_window1: Measurement window 1 size
  251. * @bls_window2: Measurement window 2 size
  252. * @bls_samples: Set amount of measured pixels for each Bayer position
  253. * (A, B,C and D) to 2^bls_samples.
  254. * @fixed_val: Fixed subtraction values
  255. */
  256. struct rkisp1_cif_isp_bls_config {
  257. __u8 enable_auto;
  258. __u8 en_windows;
  259. struct rkisp1_cif_isp_window bls_window1;
  260. struct rkisp1_cif_isp_window bls_window2;
  261. __u8 bls_samples;
  262. struct rkisp1_cif_isp_bls_fixed_val fixed_val;
  263. };
  264. /**
  265. * struct rkisp1_cif_isp_dpcc_methods_config - DPCC methods set configuration
  266. *
  267. * This structure stores the configuration of one set of methods for the DPCC
  268. * algorithm. Multiple methods can be selected in each set (independently for
  269. * the Green and Red/Blue components) through the @method field, the result is
  270. * the logical AND of all enabled methods. The remaining fields set thresholds
  271. * and factors for each method.
  272. *
  273. * @method: Method enable bits (RKISP1_CIF_ISP_DPCC_METHODS_SET_*)
  274. * @line_thresh: Line threshold (RKISP1_CIF_ISP_DPCC_LINE_THRESH_*)
  275. * @line_mad_fac: Line Mean Absolute Difference factor (RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_*)
  276. * @pg_fac: Peak gradient factor (RKISP1_CIF_ISP_DPCC_PG_FAC_*)
  277. * @rnd_thresh: Rank Neighbor Difference threshold (RKISP1_CIF_ISP_DPCC_RND_THRESH_*)
  278. * @rg_fac: Rank gradient factor (RKISP1_CIF_ISP_DPCC_RG_FAC_*)
  279. */
  280. struct rkisp1_cif_isp_dpcc_methods_config {
  281. __u32 method;
  282. __u32 line_thresh;
  283. __u32 line_mad_fac;
  284. __u32 pg_fac;
  285. __u32 rnd_thresh;
  286. __u32 rg_fac;
  287. };
  288. /**
  289. * struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC
  290. *
  291. * Configuration used by Defect Pixel Cluster Correction. Three sets of methods
  292. * can be configured and selected through the @set_use field. The result is the
  293. * logical OR of all enabled sets.
  294. *
  295. * @mode: DPCC mode (RKISP1_CIF_ISP_DPCC_MODE_*)
  296. * @output_mode: Interpolation output mode (RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_*)
  297. * @set_use: Methods sets selection (RKISP1_CIF_ISP_DPCC_SET_USE_*)
  298. * @methods: Methods sets configuration
  299. * @ro_limits: Rank order limits (RKISP1_CIF_ISP_DPCC_RO_LIMITS_*)
  300. * @rnd_offs: Differential rank offsets for rank neighbor difference (RKISP1_CIF_ISP_DPCC_RND_OFFS_*)
  301. */
  302. struct rkisp1_cif_isp_dpcc_config {
  303. __u32 mode;
  304. __u32 output_mode;
  305. __u32 set_use;
  306. struct rkisp1_cif_isp_dpcc_methods_config methods[RKISP1_CIF_ISP_DPCC_METHODS_MAX];
  307. __u32 ro_limits;
  308. __u32 rnd_offs;
  309. };
  310. /**
  311. * struct rkisp1_cif_isp_gamma_corr_curve - gamma curve point definition y-axis (output).
  312. *
  313. * The reset values define a linear curve which has the same effect as bypass. Reset values are:
  314. * gamma_y[0] = 0x0000, gamma_y[1] = 0x0100, ... gamma_y[15] = 0x0f00, gamma_y[16] = 0xfff
  315. *
  316. * @gamma_y: the values for the y-axis of gamma curve points. Each value is 12 bit.
  317. */
  318. struct rkisp1_cif_isp_gamma_corr_curve {
  319. __u16 gamma_y[RKISP1_CIF_ISP_DEGAMMA_CURVE_SIZE];
  320. };
  321. /**
  322. * struct rkisp1_cif_isp_gamma_curve_x_axis_pnts - De-Gamma Curve definition x increments
  323. * (sampling points). gamma_dx0 is for the lower samples (1-8), gamma_dx1 is for the
  324. * higher samples (9-16). The reset values for both fields is 0x44444444. This means
  325. * that each sample is 4 units away from the previous one on the x-axis.
  326. *
  327. * @gamma_dx0: gamma curve sample points definitions. Bits 0:2 for sample 1. Bit 3 unused.
  328. * Bits 4:6 for sample 2. bit 7 unused ... Bits 28:30 for sample 8. Bit 31 unused
  329. * @gamma_dx1: gamma curve sample points definitions. Bits 0:2 for sample 9. Bit 3 unused.
  330. * Bits 4:6 for sample 10. bit 7 unused ... Bits 28:30 for sample 16. Bit 31 unused
  331. */
  332. struct rkisp1_cif_isp_gamma_curve_x_axis_pnts {
  333. __u32 gamma_dx0;
  334. __u32 gamma_dx1;
  335. };
  336. /**
  337. * struct rkisp1_cif_isp_sdg_config - Configuration used by sensor degamma
  338. *
  339. * @curve_r: gamma curve point definition axis for red
  340. * @curve_g: gamma curve point definition axis for green
  341. * @curve_b: gamma curve point definition axis for blue
  342. * @xa_pnts: x axis increments
  343. */
  344. struct rkisp1_cif_isp_sdg_config {
  345. struct rkisp1_cif_isp_gamma_corr_curve curve_r;
  346. struct rkisp1_cif_isp_gamma_corr_curve curve_g;
  347. struct rkisp1_cif_isp_gamma_corr_curve curve_b;
  348. struct rkisp1_cif_isp_gamma_curve_x_axis_pnts xa_pnts;
  349. };
  350. /**
  351. * struct rkisp1_cif_isp_lsc_config - Configuration used by Lens shading correction
  352. *
  353. * @r_data_tbl: sample table red
  354. * @gr_data_tbl: sample table green (red)
  355. * @gb_data_tbl: sample table green (blue)
  356. * @b_data_tbl: sample table blue
  357. * @x_grad_tbl: gradient table x
  358. * @y_grad_tbl: gradient table y
  359. * @x_size_tbl: size table x
  360. * @y_size_tbl: size table y
  361. * @config_width: not used at the moment
  362. * @config_height: not used at the moment
  363. */
  364. struct rkisp1_cif_isp_lsc_config {
  365. __u16 r_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
  366. __u16 gr_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
  367. __u16 gb_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
  368. __u16 b_data_tbl[RKISP1_CIF_ISP_LSC_SAMPLES_MAX][RKISP1_CIF_ISP_LSC_SAMPLES_MAX];
  369. __u16 x_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
  370. __u16 y_grad_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
  371. __u16 x_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
  372. __u16 y_size_tbl[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];
  373. __u16 config_width;
  374. __u16 config_height;
  375. };
  376. /**
  377. * struct rkisp1_cif_isp_ie_config - Configuration used by image effects
  378. *
  379. * @effect: values from 'enum v4l2_colorfx'. Possible values are: V4L2_COLORFX_SEPIA,
  380. * V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_AQUA, V4L2_COLORFX_EMBOSS,
  381. * V4L2_COLORFX_SKETCH, V4L2_COLORFX_BW, V4L2_COLORFX_NEGATIVE
  382. * @color_sel: bits 0:2 - colors bitmask (001 - blue, 010 - green, 100 - red).
  383. * bits 8:15 - Threshold value of the RGB colors for the color selection effect.
  384. * @eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1
  385. * @eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2
  386. * @eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1
  387. * @eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2
  388. * @eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3
  389. * @eff_tint: Chrominance increment values of tint (used for sepia effect)
  390. */
  391. struct rkisp1_cif_isp_ie_config {
  392. __u16 effect;
  393. __u16 color_sel;
  394. __u16 eff_mat_1;
  395. __u16 eff_mat_2;
  396. __u16 eff_mat_3;
  397. __u16 eff_mat_4;
  398. __u16 eff_mat_5;
  399. __u16 eff_tint;
  400. };
  401. /**
  402. * struct rkisp1_cif_isp_cproc_config - Configuration used by Color Processing
  403. *
  404. * @c_out_range: Chrominance pixel clipping range at output.
  405. * (0 for limit, 1 for full)
  406. * @y_in_range: Luminance pixel clipping range at output.
  407. * @y_out_range: Luminance pixel clipping range at output.
  408. * @contrast: 00~ff, 0.0~1.992
  409. * @brightness: 80~7F, -128~+127
  410. * @sat: saturation, 00~FF, 0.0~1.992
  411. * @hue: 80~7F, -90~+87.188
  412. */
  413. struct rkisp1_cif_isp_cproc_config {
  414. __u8 c_out_range;
  415. __u8 y_in_range;
  416. __u8 y_out_range;
  417. __u8 contrast;
  418. __u8 brightness;
  419. __u8 sat;
  420. __u8 hue;
  421. };
  422. /**
  423. * struct rkisp1_cif_isp_awb_meas_config - Configuration for the AWB statistics
  424. *
  425. * @awb_mode: the awb meas mode. From enum rkisp1_cif_isp_awb_mode_type.
  426. * @awb_wnd: white balance measurement window (in pixels)
  427. * @max_y: only pixels values < max_y contribute to awb measurement, set to 0
  428. * to disable this feature
  429. * @min_y: only pixels values > min_y contribute to awb measurement
  430. * @max_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr,
  431. * smaller than threshold for awb measurements
  432. * @min_c: Chrominance minimum value, only consider pixels with Cb/Cr
  433. * each greater than threshold value for awb measurements
  434. * @frames: number of frames - 1 used for mean value calculation
  435. * (ucFrames=0 means 1 Frame)
  436. * @awb_ref_cr: reference Cr value for AWB regulation, target for AWB
  437. * @awb_ref_cb: reference Cb value for AWB regulation, target for AWB
  438. * @enable_ymax_cmp: enable Y_MAX compare (Not valid in RGB measurement mode.)
  439. */
  440. struct rkisp1_cif_isp_awb_meas_config {
  441. /*
  442. * Note: currently the h and v offsets are mapped to grid offsets
  443. */
  444. struct rkisp1_cif_isp_window awb_wnd;
  445. __u32 awb_mode;
  446. __u8 max_y;
  447. __u8 min_y;
  448. __u8 max_csum;
  449. __u8 min_c;
  450. __u8 frames;
  451. __u8 awb_ref_cr;
  452. __u8 awb_ref_cb;
  453. __u8 enable_ymax_cmp;
  454. };
  455. /**
  456. * struct rkisp1_cif_isp_awb_gain_config - Configuration used by auto white balance gain
  457. *
  458. * All fields in this struct are 10 bit, where:
  459. * 0x100h = 1, unsigned integer value, range 0 to 4 with 8 bit fractional part.
  460. *
  461. * out_data_x = ( AWB_GAIN_X * in_data + 128) >> 8
  462. *
  463. * @gain_red: gain value for red component.
  464. * @gain_green_r: gain value for green component in red line.
  465. * @gain_blue: gain value for blue component.
  466. * @gain_green_b: gain value for green component in blue line.
  467. */
  468. struct rkisp1_cif_isp_awb_gain_config {
  469. __u16 gain_red;
  470. __u16 gain_green_r;
  471. __u16 gain_blue;
  472. __u16 gain_green_b;
  473. };
  474. /**
  475. * struct rkisp1_cif_isp_flt_config - Configuration used by ISP filtering
  476. *
  477. * All 4 threshold fields (thresh_*) are 10 bits.
  478. * All 6 factor fields (fac_*) are 6 bits.
  479. *
  480. * @mode: ISP_FILT_MODE register fields (from enum rkisp1_cif_isp_flt_mode)
  481. * @grn_stage1: Green filter stage 1 select (range 0x0...0x8)
  482. * @chr_h_mode: Chroma filter horizontal mode
  483. * @chr_v_mode: Chroma filter vertical mode
  484. * @thresh_bl0: If thresh_bl1 < sum_grad < thresh_bl0 then fac_bl0 is selected (blurring th)
  485. * @thresh_bl1: If sum_grad < thresh_bl1 then fac_bl1 is selected (blurring th)
  486. * @thresh_sh0: If thresh_sh0 < sum_grad < thresh_sh1 then thresh_sh0 is selected (sharpening th)
  487. * @thresh_sh1: If thresh_sh1 < sum_grad then thresh_sh1 is selected (sharpening th)
  488. * @lum_weight: Parameters for luminance weight function.
  489. * @fac_sh1: filter factor for sharp1 level
  490. * @fac_sh0: filter factor for sharp0 level
  491. * @fac_mid: filter factor for mid level and for static filter mode
  492. * @fac_bl0: filter factor for blur 0 level
  493. * @fac_bl1: filter factor for blur 1 level (max blur)
  494. */
  495. struct rkisp1_cif_isp_flt_config {
  496. __u32 mode;
  497. __u8 grn_stage1;
  498. __u8 chr_h_mode;
  499. __u8 chr_v_mode;
  500. __u32 thresh_bl0;
  501. __u32 thresh_bl1;
  502. __u32 thresh_sh0;
  503. __u32 thresh_sh1;
  504. __u32 lum_weight;
  505. __u32 fac_sh1;
  506. __u32 fac_sh0;
  507. __u32 fac_mid;
  508. __u32 fac_bl0;
  509. __u32 fac_bl1;
  510. };
  511. /**
  512. * struct rkisp1_cif_isp_bdm_config - Configuration used by Bayer DeMosaic
  513. *
  514. * @demosaic_th: threshold for bayer demosaicing texture detection
  515. */
  516. struct rkisp1_cif_isp_bdm_config {
  517. __u8 demosaic_th;
  518. };
  519. /**
  520. * struct rkisp1_cif_isp_ctk_config - Configuration used by Cross Talk correction
  521. *
  522. * @coeff: color correction matrix. Values are 11-bit signed fixed-point numbers with 4 bit integer
  523. * and 7 bit fractional part, ranging from -8 (0x400) to +7.992 (0x3FF). 0 is
  524. * represented by 0x000 and a coefficient value of 1 as 0x080.
  525. * @ct_offset: Red, Green, Blue offsets for the crosstalk correction matrix
  526. */
  527. struct rkisp1_cif_isp_ctk_config {
  528. __u16 coeff[3][3];
  529. __u16 ct_offset[3];
  530. };
  531. enum rkisp1_cif_isp_goc_mode {
  532. RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC,
  533. RKISP1_CIF_ISP_GOC_MODE_EQUIDISTANT
  534. };
  535. /**
  536. * struct rkisp1_cif_isp_goc_config - Configuration used by Gamma Out correction
  537. *
  538. * @mode: goc mode (from enum rkisp1_cif_isp_goc_mode)
  539. * @gamma_y: gamma out curve y-axis for all color components
  540. *
  541. * The number of entries of @gamma_y depends on the hardware revision
  542. * as is reported by the hw_revision field of the struct media_device_info
  543. * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  544. *
  545. * V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has
  546. * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries.
  547. * RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
  548. */
  549. struct rkisp1_cif_isp_goc_config {
  550. __u32 mode;
  551. __u16 gamma_y[RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES];
  552. };
  553. /**
  554. * struct rkisp1_cif_isp_hst_config - Configuration for Histogram statistics
  555. *
  556. * @mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode)
  557. * @histogram_predivider: process every stepsize pixel, all other pixels are
  558. * skipped
  559. * @meas_window: coordinates of the measure window
  560. * @hist_weight: weighting factor for sub-windows
  561. *
  562. * The number of entries of @hist_weight depends on the hardware revision
  563. * as is reported by the hw_revision field of the struct media_device_info
  564. * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  565. *
  566. * V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has
  567. * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries.
  568. * RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the
  569. * two.
  570. */
  571. struct rkisp1_cif_isp_hst_config {
  572. __u32 mode;
  573. __u8 histogram_predivider;
  574. struct rkisp1_cif_isp_window meas_window;
  575. __u8 hist_weight[RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE];
  576. };
  577. /**
  578. * struct rkisp1_cif_isp_aec_config - Configuration for Auto Exposure statistics
  579. *
  580. * @mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode)
  581. * @autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop)
  582. * @meas_window: coordinates of the measure window
  583. */
  584. struct rkisp1_cif_isp_aec_config {
  585. __u32 mode;
  586. __u32 autostop;
  587. struct rkisp1_cif_isp_window meas_window;
  588. };
  589. /**
  590. * struct rkisp1_cif_isp_afc_config - Configuration for the Auto Focus statistics
  591. *
  592. * @num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWS
  593. * @afm_win: coordinates of the meas window
  594. * @thres: threshold used for minimizing the influence of noise
  595. * @var_shift: the number of bits for the shift operation at the end of the
  596. * calculation chain.
  597. */
  598. struct rkisp1_cif_isp_afc_config {
  599. __u8 num_afm_win;
  600. struct rkisp1_cif_isp_window afm_win[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
  601. __u32 thres;
  602. __u32 var_shift;
  603. };
  604. /**
  605. * enum rkisp1_cif_isp_dpf_gain_usage - dpf gain usage
  606. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stage
  607. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from
  608. * registers DPF_NF_GAIN_R, ...
  609. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS: use only the gains from LSC module
  610. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the
  611. * gains from LSC module
  612. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB module
  613. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC module
  614. * @RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation)
  615. */
  616. enum rkisp1_cif_isp_dpf_gain_usage {
  617. RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED,
  618. RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS,
  619. RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS,
  620. RKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS,
  621. RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS,
  622. RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS,
  623. RKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX
  624. };
  625. /**
  626. * enum rkisp1_cif_isp_dpf_rb_filtersize - Red and blue filter sizes
  627. * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9
  628. * (means 7x5 active pixel)
  629. * @RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9
  630. * (means 5x5 active pixel)
  631. */
  632. enum rkisp1_cif_isp_dpf_rb_filtersize {
  633. RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9,
  634. RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9,
  635. };
  636. /**
  637. * enum rkisp1_cif_isp_dpf_nll_scale_mode - dpf noise level scale mode
  638. * @RKISP1_CIF_ISP_NLL_SCALE_LINEAR: use a linear scaling
  639. * @RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling
  640. */
  641. enum rkisp1_cif_isp_dpf_nll_scale_mode {
  642. RKISP1_CIF_ISP_NLL_SCALE_LINEAR,
  643. RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC,
  644. };
  645. /**
  646. * struct rkisp1_cif_isp_dpf_nll - Noise level lookup
  647. *
  648. * @coeff: Noise level Lookup coefficient
  649. * @scale_mode: dpf noise level scale mode (from enum rkisp1_cif_isp_dpf_nll_scale_mode)
  650. */
  651. struct rkisp1_cif_isp_dpf_nll {
  652. __u16 coeff[RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS];
  653. __u32 scale_mode;
  654. };
  655. /**
  656. * struct rkisp1_cif_isp_dpf_rb_flt - Red blue filter config
  657. *
  658. * @fltsize: The filter size for the red and blue pixels
  659. * (from enum rkisp1_cif_isp_dpf_rb_filtersize)
  660. * @spatial_coeff: Spatial weights
  661. * @r_enable: enable filter processing for red pixels
  662. * @b_enable: enable filter processing for blue pixels
  663. */
  664. struct rkisp1_cif_isp_dpf_rb_flt {
  665. __u32 fltsize;
  666. __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
  667. __u8 r_enable;
  668. __u8 b_enable;
  669. };
  670. /**
  671. * struct rkisp1_cif_isp_dpf_g_flt - Green filter Configuration
  672. *
  673. * @spatial_coeff: Spatial weights
  674. * @gr_enable: enable filter processing for green pixels in green/red lines
  675. * @gb_enable: enable filter processing for green pixels in green/blue lines
  676. */
  677. struct rkisp1_cif_isp_dpf_g_flt {
  678. __u8 spatial_coeff[RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS];
  679. __u8 gr_enable;
  680. __u8 gb_enable;
  681. };
  682. /**
  683. * struct rkisp1_cif_isp_dpf_gain - Noise function Configuration
  684. *
  685. * @mode: dpf gain usage (from enum rkisp1_cif_isp_dpf_gain_usage)
  686. * @nf_r_gain: Noise function Gain that replaces the AWB gain for red pixels
  687. * @nf_b_gain: Noise function Gain that replaces the AWB gain for blue pixels
  688. * @nf_gr_gain: Noise function Gain that replaces the AWB gain
  689. * for green pixels in a red line
  690. * @nf_gb_gain: Noise function Gain that replaces the AWB gain
  691. * for green pixels in a blue line
  692. */
  693. struct rkisp1_cif_isp_dpf_gain {
  694. __u32 mode;
  695. __u16 nf_r_gain;
  696. __u16 nf_b_gain;
  697. __u16 nf_gr_gain;
  698. __u16 nf_gb_gain;
  699. };
  700. /**
  701. * struct rkisp1_cif_isp_dpf_config - Configuration used by De-noising pre-filter
  702. *
  703. * @gain: noise function gain
  704. * @g_flt: green filter config
  705. * @rb_flt: red blue filter config
  706. * @nll: noise level lookup
  707. */
  708. struct rkisp1_cif_isp_dpf_config {
  709. struct rkisp1_cif_isp_dpf_gain gain;
  710. struct rkisp1_cif_isp_dpf_g_flt g_flt;
  711. struct rkisp1_cif_isp_dpf_rb_flt rb_flt;
  712. struct rkisp1_cif_isp_dpf_nll nll;
  713. };
  714. /**
  715. * struct rkisp1_cif_isp_dpf_strength_config - strength of the filter
  716. *
  717. * @r: filter strength of the RED filter
  718. * @g: filter strength of the GREEN filter
  719. * @b: filter strength of the BLUE filter
  720. */
  721. struct rkisp1_cif_isp_dpf_strength_config {
  722. __u8 r;
  723. __u8 g;
  724. __u8 b;
  725. };
  726. /**
  727. * struct rkisp1_cif_isp_isp_other_cfg - Parameters for some blocks in rockchip isp1
  728. *
  729. * @dpcc_config: Defect Pixel Cluster Correction config
  730. * @bls_config: Black Level Subtraction config
  731. * @sdg_config: sensor degamma config
  732. * @lsc_config: Lens Shade config
  733. * @awb_gain_config: Auto White balance gain config
  734. * @flt_config: filter config
  735. * @bdm_config: demosaic config
  736. * @ctk_config: cross talk config
  737. * @goc_config: gamma out config
  738. * @bls_config: black level subtraction config
  739. * @dpf_config: De-noising pre-filter config
  740. * @dpf_strength_config: dpf strength config
  741. * @cproc_config: color process config
  742. * @ie_config: image effects config
  743. */
  744. struct rkisp1_cif_isp_isp_other_cfg {
  745. struct rkisp1_cif_isp_dpcc_config dpcc_config;
  746. struct rkisp1_cif_isp_bls_config bls_config;
  747. struct rkisp1_cif_isp_sdg_config sdg_config;
  748. struct rkisp1_cif_isp_lsc_config lsc_config;
  749. struct rkisp1_cif_isp_awb_gain_config awb_gain_config;
  750. struct rkisp1_cif_isp_flt_config flt_config;
  751. struct rkisp1_cif_isp_bdm_config bdm_config;
  752. struct rkisp1_cif_isp_ctk_config ctk_config;
  753. struct rkisp1_cif_isp_goc_config goc_config;
  754. struct rkisp1_cif_isp_dpf_config dpf_config;
  755. struct rkisp1_cif_isp_dpf_strength_config dpf_strength_config;
  756. struct rkisp1_cif_isp_cproc_config cproc_config;
  757. struct rkisp1_cif_isp_ie_config ie_config;
  758. };
  759. /**
  760. * struct rkisp1_cif_isp_isp_meas_cfg - Rockchip ISP1 Measure Parameters
  761. *
  762. * @awb_meas_config: auto white balance config
  763. * @hst_config: histogram config
  764. * @aec_config: auto exposure config
  765. * @afc_config: auto focus config
  766. */
  767. struct rkisp1_cif_isp_isp_meas_cfg {
  768. struct rkisp1_cif_isp_awb_meas_config awb_meas_config;
  769. struct rkisp1_cif_isp_hst_config hst_config;
  770. struct rkisp1_cif_isp_aec_config aec_config;
  771. struct rkisp1_cif_isp_afc_config afc_config;
  772. };
  773. /**
  774. * struct rkisp1_params_cfg - Rockchip ISP1 Input Parameters Meta Data
  775. *
  776. * @module_en_update: mask the enable bits of which module should be updated
  777. * @module_ens: mask the enable value of each module, only update the module
  778. * which correspond bit was set in module_en_update
  779. * @module_cfg_update: mask the config bits of which module should be updated
  780. * @meas: measurement config
  781. * @others: other config
  782. */
  783. struct rkisp1_params_cfg {
  784. __u32 module_en_update;
  785. __u32 module_ens;
  786. __u32 module_cfg_update;
  787. struct rkisp1_cif_isp_isp_meas_cfg meas;
  788. struct rkisp1_cif_isp_isp_other_cfg others;
  789. };
  790. /**
  791. * struct rkisp1_cif_isp_compand_bls_config - Rockchip ISP1 Companding parameters (BLS)
  792. * @r: Fixed subtraction value for Bayer pattern R
  793. * @gr: Fixed subtraction value for Bayer pattern Gr
  794. * @gb: Fixed subtraction value for Bayer pattern Gb
  795. * @b: Fixed subtraction value for Bayer pattern B
  796. *
  797. * The values will be subtracted from the sensor values. Note that unlike the
  798. * dedicated BLS block, the BLS values in the compander are 20-bit unsigned.
  799. */
  800. struct rkisp1_cif_isp_compand_bls_config {
  801. __u32 r;
  802. __u32 gr;
  803. __u32 gb;
  804. __u32 b;
  805. };
  806. /**
  807. * struct rkisp1_cif_isp_compand_curve_config - Rockchip ISP1 Companding
  808. * parameters (expand and compression curves)
  809. * @px: Compand curve x-values. Each value stores the distance from the
  810. * previous x-value, expressed as log2 of the distance on 5 bits.
  811. * @x: Compand curve x-values. The functionality of these parameters are
  812. * unknown due to do a lack of hardware documentation, but these are left
  813. * here for future compatibility purposes.
  814. * @y: Compand curve y-values
  815. */
  816. struct rkisp1_cif_isp_compand_curve_config {
  817. __u8 px[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
  818. __u32 x[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
  819. __u32 y[RKISP1_CIF_ISP_COMPAND_NUM_POINTS];
  820. };
  821. /*---------- PART2: Measurement Statistics ------------*/
  822. /**
  823. * struct rkisp1_cif_isp_awb_meas - AWB measured values
  824. *
  825. * @cnt: White pixel count, number of "white pixels" found during last
  826. * measurement
  827. * @mean_y_or_g: Mean value of Y within window and frames,
  828. * Green if RGB is selected.
  829. * @mean_cb_or_b: Mean value of Cb within window and frames,
  830. * Blue if RGB is selected.
  831. * @mean_cr_or_r: Mean value of Cr within window and frames,
  832. * Red if RGB is selected.
  833. */
  834. struct rkisp1_cif_isp_awb_meas {
  835. __u32 cnt;
  836. __u8 mean_y_or_g;
  837. __u8 mean_cb_or_b;
  838. __u8 mean_cr_or_r;
  839. };
  840. /**
  841. * struct rkisp1_cif_isp_awb_stat - statistics automatic white balance data
  842. *
  843. * @awb_mean: Mean measured data
  844. */
  845. struct rkisp1_cif_isp_awb_stat {
  846. struct rkisp1_cif_isp_awb_meas awb_mean[RKISP1_CIF_ISP_AWB_MAX_GRID];
  847. };
  848. /**
  849. * struct rkisp1_cif_isp_bls_meas_val - BLS measured values
  850. *
  851. * @meas_r: Mean measured value for Bayer pattern R
  852. * @meas_gr: Mean measured value for Bayer pattern Gr
  853. * @meas_gb: Mean measured value for Bayer pattern Gb
  854. * @meas_b: Mean measured value for Bayer pattern B
  855. */
  856. struct rkisp1_cif_isp_bls_meas_val {
  857. __u16 meas_r;
  858. __u16 meas_gr;
  859. __u16 meas_gb;
  860. __u16 meas_b;
  861. };
  862. /**
  863. * struct rkisp1_cif_isp_ae_stat - statistics auto exposure data
  864. *
  865. * @exp_mean: Mean luminance value of block xx
  866. * @bls_val: BLS measured values
  867. *
  868. * The number of entries of @exp_mean depends on the hardware revision
  869. * as is reported by the hw_revision field of the struct media_device_info
  870. * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  871. *
  872. * V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has
  873. * RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal
  874. * to the maximum of the two.
  875. *
  876. * Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
  877. */
  878. struct rkisp1_cif_isp_ae_stat {
  879. __u8 exp_mean[RKISP1_CIF_ISP_AE_MEAN_MAX];
  880. struct rkisp1_cif_isp_bls_meas_val bls_val;
  881. };
  882. /**
  883. * struct rkisp1_cif_isp_af_meas_val - AF measured values
  884. *
  885. * @sum: sharpness value
  886. * @lum: luminance value
  887. */
  888. struct rkisp1_cif_isp_af_meas_val {
  889. __u32 sum;
  890. __u32 lum;
  891. };
  892. /**
  893. * struct rkisp1_cif_isp_af_stat - statistics auto focus data
  894. *
  895. * @window: AF measured value of window x
  896. *
  897. * The module measures the sharpness in 3 windows of selectable size via
  898. * register settings(ISP_AFM_*_A/B/C)
  899. */
  900. struct rkisp1_cif_isp_af_stat {
  901. struct rkisp1_cif_isp_af_meas_val window[RKISP1_CIF_ISP_AFM_MAX_WINDOWS];
  902. };
  903. /**
  904. * struct rkisp1_cif_isp_hist_stat - statistics histogram data
  905. *
  906. * @hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point
  907. * type. Bits 0-4 are the fractional part and bits 5-19 are the
  908. * integer part.
  909. *
  910. * The window of the measurements area is divided to 5x5 sub-windows for
  911. * V10 and to 9x9 sub-windows for V12. The histogram is then computed for each
  912. * sub-window independently and the final result is a weighted average of the
  913. * histogram measurements on all sub-windows. The window of the measurements
  914. * area and the weight of each sub-window are configurable using
  915. * struct @rkisp1_cif_isp_hst_config.
  916. *
  917. * The histogram contains 16 bins in V10 and 32 bins in V12.
  918. *
  919. * The number of entries of @hist_bins depends on the hardware revision
  920. * as is reported by the hw_revision field of the struct media_device_info
  921. * that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
  922. *
  923. * V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has
  924. * RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is
  925. * equal to the maximum of the two.
  926. */
  927. struct rkisp1_cif_isp_hist_stat {
  928. __u32 hist_bins[RKISP1_CIF_ISP_HIST_BIN_N_MAX];
  929. };
  930. /**
  931. * struct rkisp1_cif_isp_stat - Rockchip ISP1 Statistics Data
  932. *
  933. * @awb: statistics data for automatic white balance
  934. * @ae: statistics data for auto exposure
  935. * @af: statistics data for auto focus
  936. * @hist: statistics histogram data
  937. */
  938. struct rkisp1_cif_isp_stat {
  939. struct rkisp1_cif_isp_awb_stat awb;
  940. struct rkisp1_cif_isp_ae_stat ae;
  941. struct rkisp1_cif_isp_af_stat af;
  942. struct rkisp1_cif_isp_hist_stat hist;
  943. };
  944. /**
  945. * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Meta Data
  946. *
  947. * @meas_type: measurement types (RKISP1_CIF_ISP_STAT_* definitions)
  948. * @frame_id: frame ID for sync
  949. * @params: statistics data
  950. */
  951. struct rkisp1_stat_buffer {
  952. __u32 meas_type;
  953. __u32 frame_id;
  954. struct rkisp1_cif_isp_stat params;
  955. };
  956. /*---------- PART3: Extensible Configuration Parameters ------------*/
  957. /**
  958. * enum rkisp1_ext_params_block_type - RkISP1 extensible params block type
  959. *
  960. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS: Black level subtraction
  961. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC: Defect pixel cluster correction
  962. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG: Sensor de-gamma
  963. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN: Auto white balance gains
  964. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT: ISP filtering
  965. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM: Bayer de-mosaic
  966. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK: Cross-talk correction
  967. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC: Gamma out correction
  968. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF: De-noise pre-filter
  969. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH: De-noise pre-filter strength
  970. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC: Color processing
  971. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_IE: Image effects
  972. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC: Lens shading correction
  973. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS: Auto white balance statistics
  974. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS: Histogram statistics
  975. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS: Auto exposure statistics
  976. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS: Auto-focus statistics
  977. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS: BLS in the compand block
  978. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND: Companding expand curve
  979. * @RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS: Companding compress curve
  980. */
  981. enum rkisp1_ext_params_block_type {
  982. RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS,
  983. RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC,
  984. RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG,
  985. RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN,
  986. RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT,
  987. RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM,
  988. RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK,
  989. RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC,
  990. RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF,
  991. RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH,
  992. RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC,
  993. RKISP1_EXT_PARAMS_BLOCK_TYPE_IE,
  994. RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC,
  995. RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS,
  996. RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS,
  997. RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS,
  998. RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS,
  999. RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS,
  1000. RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND,
  1001. RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS,
  1002. };
  1003. #define RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE (1U << 0)
  1004. #define RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE (1U << 1)
  1005. /**
  1006. * struct rkisp1_ext_params_block_header - RkISP1 extensible parameters block
  1007. * header
  1008. *
  1009. * This structure represents the common part of all the ISP configuration
  1010. * blocks. Each parameters block shall embed an instance of this structure type
  1011. * as its first member, followed by the block-specific configuration data. The
  1012. * driver inspects this common header to discern the block type and its size and
  1013. * properly handle the block content by casting it to the correct block-specific
  1014. * type.
  1015. *
  1016. * The @type field is one of the values enumerated by
  1017. * :c:type:`rkisp1_ext_params_block_type` and specifies how the data should be
  1018. * interpreted by the driver. The @size field specifies the size of the
  1019. * parameters block and is used by the driver for validation purposes.
  1020. *
  1021. * The @flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*.
  1022. *
  1023. * When userspace wants to configure and enable an ISP block it shall fully
  1024. * populate the block configuration and set the
  1025. * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE bit in the @flags field.
  1026. *
  1027. * When userspace simply wants to disable an ISP block the
  1028. * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bit should be set in @flags field. The
  1029. * driver ignores the rest of the block configuration structure in this case.
  1030. *
  1031. * If a new configuration of an ISP block has to be applied userspace shall
  1032. * fully populate the ISP block configuration and omit setting the
  1033. * RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits
  1034. * in the @flags field.
  1035. *
  1036. * Setting both the RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE and
  1037. * RKISP1_EXT_PARAMS_FL_BLOCK_DISABLE bits in the @flags field is not allowed
  1038. * and not accepted by the driver.
  1039. *
  1040. * Userspace is responsible for correctly populating the parameters block header
  1041. * fields (@type, @flags and @size) and the block-specific parameters.
  1042. *
  1043. * For example:
  1044. *
  1045. * .. code-block:: c
  1046. *
  1047. * void populate_bls(struct rkisp1_ext_params_block_header *block) {
  1048. * struct rkisp1_ext_params_bls_config *bls =
  1049. * (struct rkisp1_ext_params_bls_config *)block;
  1050. *
  1051. * bls->header.type = RKISP1_EXT_PARAMS_BLOCK_ID_BLS;
  1052. * bls->header.flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE;
  1053. * bls->header.size = sizeof(*bls);
  1054. *
  1055. * bls->config.enable_auto = 0;
  1056. * bls->config.fixed_val.r = blackLevelRed_;
  1057. * bls->config.fixed_val.gr = blackLevelGreenR_;
  1058. * bls->config.fixed_val.gb = blackLevelGreenB_;
  1059. * bls->config.fixed_val.b = blackLevelBlue_;
  1060. * }
  1061. *
  1062. * @type: The parameters block type, see
  1063. * :c:type:`rkisp1_ext_params_block_type`
  1064. * @flags: A bitmask of block flags
  1065. * @size: Size (in bytes) of the parameters block, including this header
  1066. */
  1067. struct rkisp1_ext_params_block_header {
  1068. __u16 type;
  1069. __u16 flags;
  1070. __u32 size;
  1071. };
  1072. /**
  1073. * struct rkisp1_ext_params_bls_config - RkISP1 extensible params BLS config
  1074. *
  1075. * RkISP1 extensible parameters Black Level Subtraction configuration block.
  1076. * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS`.
  1077. *
  1078. * @header: The RkISP1 extensible parameters header, see
  1079. * :c:type:`rkisp1_ext_params_block_header`
  1080. * @config: Black Level Subtraction configuration, see
  1081. * :c:type:`rkisp1_cif_isp_bls_config`
  1082. */
  1083. struct rkisp1_ext_params_bls_config {
  1084. struct rkisp1_ext_params_block_header header;
  1085. struct rkisp1_cif_isp_bls_config config;
  1086. } __attribute__((aligned(8)));
  1087. /**
  1088. * struct rkisp1_ext_params_dpcc_config - RkISP1 extensible params DPCC config
  1089. *
  1090. * RkISP1 extensible parameters Defective Pixel Cluster Correction configuration
  1091. * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC`.
  1092. *
  1093. * @header: The RkISP1 extensible parameters header, see
  1094. * :c:type:`rkisp1_ext_params_block_header`
  1095. * @config: Defective Pixel Cluster Correction configuration, see
  1096. * :c:type:`rkisp1_cif_isp_dpcc_config`
  1097. */
  1098. struct rkisp1_ext_params_dpcc_config {
  1099. struct rkisp1_ext_params_block_header header;
  1100. struct rkisp1_cif_isp_dpcc_config config;
  1101. } __attribute__((aligned(8)));
  1102. /**
  1103. * struct rkisp1_ext_params_sdg_config - RkISP1 extensible params SDG config
  1104. *
  1105. * RkISP1 extensible parameters Sensor Degamma configuration block. Identified
  1106. * by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG`.
  1107. *
  1108. * @header: The RkISP1 extensible parameters header, see
  1109. * :c:type:`rkisp1_ext_params_block_header`
  1110. * @config: Sensor Degamma configuration, see
  1111. * :c:type:`rkisp1_cif_isp_sdg_config`
  1112. */
  1113. struct rkisp1_ext_params_sdg_config {
  1114. struct rkisp1_ext_params_block_header header;
  1115. struct rkisp1_cif_isp_sdg_config config;
  1116. } __attribute__((aligned(8)));
  1117. /**
  1118. * struct rkisp1_ext_params_lsc_config - RkISP1 extensible params LSC config
  1119. *
  1120. * RkISP1 extensible parameters Lens Shading Correction configuration block.
  1121. * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC`.
  1122. *
  1123. * @header: The RkISP1 extensible parameters header, see
  1124. * :c:type:`rkisp1_ext_params_block_header`
  1125. * @config: Lens Shading Correction configuration, see
  1126. * :c:type:`rkisp1_cif_isp_lsc_config`
  1127. */
  1128. struct rkisp1_ext_params_lsc_config {
  1129. struct rkisp1_ext_params_block_header header;
  1130. struct rkisp1_cif_isp_lsc_config config;
  1131. } __attribute__((aligned(8)));
  1132. /**
  1133. * struct rkisp1_ext_params_awb_gain_config - RkISP1 extensible params AWB
  1134. * gain config
  1135. *
  1136. * RkISP1 extensible parameters Auto-White Balance Gains configuration block.
  1137. * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN`.
  1138. *
  1139. * @header: The RkISP1 extensible parameters header, see
  1140. * :c:type:`rkisp1_ext_params_block_header`
  1141. * @config: Auto-White Balance Gains configuration, see
  1142. * :c:type:`rkisp1_cif_isp_awb_gain_config`
  1143. */
  1144. struct rkisp1_ext_params_awb_gain_config {
  1145. struct rkisp1_ext_params_block_header header;
  1146. struct rkisp1_cif_isp_awb_gain_config config;
  1147. } __attribute__((aligned(8)));
  1148. /**
  1149. * struct rkisp1_ext_params_flt_config - RkISP1 extensible params FLT config
  1150. *
  1151. * RkISP1 extensible parameters Filter configuration block. Identified by
  1152. * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT`.
  1153. *
  1154. * @header: The RkISP1 extensible parameters header, see
  1155. * :c:type:`rkisp1_ext_params_block_header`
  1156. * @config: Filter configuration, see :c:type:`rkisp1_cif_isp_flt_config`
  1157. */
  1158. struct rkisp1_ext_params_flt_config {
  1159. struct rkisp1_ext_params_block_header header;
  1160. struct rkisp1_cif_isp_flt_config config;
  1161. } __attribute__((aligned(8)));
  1162. /**
  1163. * struct rkisp1_ext_params_bdm_config - RkISP1 extensible params BDM config
  1164. *
  1165. * RkISP1 extensible parameters Demosaicing configuration block. Identified by
  1166. * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM`.
  1167. *
  1168. * @header: The RkISP1 extensible parameters header, see
  1169. * :c:type:`rkisp1_ext_params_block_header`
  1170. * @config: Demosaicing configuration, see :c:type:`rkisp1_cif_isp_bdm_config`
  1171. */
  1172. struct rkisp1_ext_params_bdm_config {
  1173. struct rkisp1_ext_params_block_header header;
  1174. struct rkisp1_cif_isp_bdm_config config;
  1175. } __attribute__((aligned(8)));
  1176. /**
  1177. * struct rkisp1_ext_params_ctk_config - RkISP1 extensible params CTK config
  1178. *
  1179. * RkISP1 extensible parameters Cross-Talk configuration block. Identified by
  1180. * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK`.
  1181. *
  1182. * @header: The RkISP1 extensible parameters header, see
  1183. * :c:type:`rkisp1_ext_params_block_header`
  1184. * @config: Cross-Talk configuration, see :c:type:`rkisp1_cif_isp_ctk_config`
  1185. */
  1186. struct rkisp1_ext_params_ctk_config {
  1187. struct rkisp1_ext_params_block_header header;
  1188. struct rkisp1_cif_isp_ctk_config config;
  1189. } __attribute__((aligned(8)));
  1190. /**
  1191. * struct rkisp1_ext_params_goc_config - RkISP1 extensible params GOC config
  1192. *
  1193. * RkISP1 extensible parameters Gamma-Out configuration block. Identified by
  1194. * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC`.
  1195. *
  1196. * @header: The RkISP1 extensible parameters header, see
  1197. * :c:type:`rkisp1_ext_params_block_header`
  1198. * @config: Gamma-Out configuration, see :c:type:`rkisp1_cif_isp_goc_config`
  1199. */
  1200. struct rkisp1_ext_params_goc_config {
  1201. struct rkisp1_ext_params_block_header header;
  1202. struct rkisp1_cif_isp_goc_config config;
  1203. } __attribute__((aligned(8)));
  1204. /**
  1205. * struct rkisp1_ext_params_dpf_config - RkISP1 extensible params DPF config
  1206. *
  1207. * RkISP1 extensible parameters De-noise Pre-Filter configuration block.
  1208. * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF`.
  1209. *
  1210. * @header: The RkISP1 extensible parameters header, see
  1211. * :c:type:`rkisp1_ext_params_block_header`
  1212. * @config: De-noise Pre-Filter configuration, see
  1213. * :c:type:`rkisp1_cif_isp_dpf_config`
  1214. */
  1215. struct rkisp1_ext_params_dpf_config {
  1216. struct rkisp1_ext_params_block_header header;
  1217. struct rkisp1_cif_isp_dpf_config config;
  1218. } __attribute__((aligned(8)));
  1219. /**
  1220. * struct rkisp1_ext_params_dpf_strength_config - RkISP1 extensible params DPF
  1221. * strength config
  1222. *
  1223. * RkISP1 extensible parameters De-noise Pre-Filter strength configuration
  1224. * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH`.
  1225. *
  1226. * @header: The RkISP1 extensible parameters header, see
  1227. * :c:type:`rkisp1_ext_params_block_header`
  1228. * @config: De-noise Pre-Filter strength configuration, see
  1229. * :c:type:`rkisp1_cif_isp_dpf_strength_config`
  1230. */
  1231. struct rkisp1_ext_params_dpf_strength_config {
  1232. struct rkisp1_ext_params_block_header header;
  1233. struct rkisp1_cif_isp_dpf_strength_config config;
  1234. } __attribute__((aligned(8)));
  1235. /**
  1236. * struct rkisp1_ext_params_cproc_config - RkISP1 extensible params CPROC config
  1237. *
  1238. * RkISP1 extensible parameters Color Processing configuration block.
  1239. * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC`.
  1240. *
  1241. * @header: The RkISP1 extensible parameters header, see
  1242. * :c:type:`rkisp1_ext_params_block_header`
  1243. * @config: Color processing configuration, see
  1244. * :c:type:`rkisp1_cif_isp_cproc_config`
  1245. */
  1246. struct rkisp1_ext_params_cproc_config {
  1247. struct rkisp1_ext_params_block_header header;
  1248. struct rkisp1_cif_isp_cproc_config config;
  1249. } __attribute__((aligned(8)));
  1250. /**
  1251. * struct rkisp1_ext_params_ie_config - RkISP1 extensible params IE config
  1252. *
  1253. * RkISP1 extensible parameters Image Effect configuration block. Identified by
  1254. * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_IE`.
  1255. *
  1256. * @header: The RkISP1 extensible parameters header, see
  1257. * :c:type:`rkisp1_ext_params_block_header`
  1258. * @config: Image Effect configuration, see :c:type:`rkisp1_cif_isp_ie_config`
  1259. */
  1260. struct rkisp1_ext_params_ie_config {
  1261. struct rkisp1_ext_params_block_header header;
  1262. struct rkisp1_cif_isp_ie_config config;
  1263. } __attribute__((aligned(8)));
  1264. /**
  1265. * struct rkisp1_ext_params_awb_meas_config - RkISP1 extensible params AWB
  1266. * Meas config
  1267. *
  1268. * RkISP1 extensible parameters Auto-White Balance Measurement configuration
  1269. * block. Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS`.
  1270. *
  1271. * @header: The RkISP1 extensible parameters header, see
  1272. * :c:type:`rkisp1_ext_params_block_header`
  1273. * @config: Auto-White Balance measure configuration, see
  1274. * :c:type:`rkisp1_cif_isp_awb_meas_config`
  1275. */
  1276. struct rkisp1_ext_params_awb_meas_config {
  1277. struct rkisp1_ext_params_block_header header;
  1278. struct rkisp1_cif_isp_awb_meas_config config;
  1279. } __attribute__((aligned(8)));
  1280. /**
  1281. * struct rkisp1_ext_params_hst_config - RkISP1 extensible params Histogram config
  1282. *
  1283. * RkISP1 extensible parameters Histogram statistics configuration block.
  1284. * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS`.
  1285. *
  1286. * @header: The RkISP1 extensible parameters header, see
  1287. * :c:type:`rkisp1_ext_params_block_header`
  1288. * @config: Histogram statistics configuration, see
  1289. * :c:type:`rkisp1_cif_isp_hst_config`
  1290. */
  1291. struct rkisp1_ext_params_hst_config {
  1292. struct rkisp1_ext_params_block_header header;
  1293. struct rkisp1_cif_isp_hst_config config;
  1294. } __attribute__((aligned(8)));
  1295. /**
  1296. * struct rkisp1_ext_params_aec_config - RkISP1 extensible params AEC config
  1297. *
  1298. * RkISP1 extensible parameters Auto-Exposure statistics configuration block.
  1299. * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS`.
  1300. *
  1301. * @header: The RkISP1 extensible parameters header, see
  1302. * :c:type:`rkisp1_ext_params_block_header`
  1303. * @config: Auto-Exposure statistics configuration, see
  1304. * :c:type:`rkisp1_cif_isp_aec_config`
  1305. */
  1306. struct rkisp1_ext_params_aec_config {
  1307. struct rkisp1_ext_params_block_header header;
  1308. struct rkisp1_cif_isp_aec_config config;
  1309. } __attribute__((aligned(8)));
  1310. /**
  1311. * struct rkisp1_ext_params_afc_config - RkISP1 extensible params AFC config
  1312. *
  1313. * RkISP1 extensible parameters Auto-Focus statistics configuration block.
  1314. * Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS`.
  1315. *
  1316. * @header: The RkISP1 extensible parameters header, see
  1317. * :c:type:`rkisp1_ext_params_block_header`
  1318. * @config: Auto-Focus statistics configuration, see
  1319. * :c:type:`rkisp1_cif_isp_afc_config`
  1320. */
  1321. struct rkisp1_ext_params_afc_config {
  1322. struct rkisp1_ext_params_block_header header;
  1323. struct rkisp1_cif_isp_afc_config config;
  1324. } __attribute__((aligned(8)));
  1325. /**
  1326. * struct rkisp1_ext_params_compand_bls_config - RkISP1 extensible params
  1327. * Compand BLS config
  1328. *
  1329. * RkISP1 extensible parameters Companding configuration block (black level
  1330. * subtraction). Identified by :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS`.
  1331. *
  1332. * @header: The RkISP1 extensible parameters header, see
  1333. * :c:type:`rkisp1_ext_params_block_header`
  1334. * @config: Companding BLS configuration, see
  1335. * :c:type:`rkisp1_cif_isp_compand_bls_config`
  1336. */
  1337. struct rkisp1_ext_params_compand_bls_config {
  1338. struct rkisp1_ext_params_block_header header;
  1339. struct rkisp1_cif_isp_compand_bls_config config;
  1340. } __attribute__((aligned(8)));
  1341. /**
  1342. * struct rkisp1_ext_params_compand_curve_config - RkISP1 extensible params
  1343. * Compand curve config
  1344. *
  1345. * RkISP1 extensible parameters Companding configuration block (expand and
  1346. * compression curves). Identified by
  1347. * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND` or
  1348. * :c:type:`RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS`.
  1349. *
  1350. * @header: The RkISP1 extensible parameters header, see
  1351. * :c:type:`rkisp1_ext_params_block_header`
  1352. * @config: Companding curve configuration, see
  1353. * :c:type:`rkisp1_cif_isp_compand_curve_config`
  1354. */
  1355. struct rkisp1_ext_params_compand_curve_config {
  1356. struct rkisp1_ext_params_block_header header;
  1357. struct rkisp1_cif_isp_compand_curve_config config;
  1358. } __attribute__((aligned(8)));
  1359. /*
  1360. * The rkisp1_ext_params_compand_curve_config structure is counted twice as it
  1361. * is used for both the COMPAND_EXPAND and COMPAND_COMPRESS block types.
  1362. */
  1363. #define RKISP1_EXT_PARAMS_MAX_SIZE \
  1364. (sizeof(struct rkisp1_ext_params_bls_config) +\
  1365. sizeof(struct rkisp1_ext_params_dpcc_config) +\
  1366. sizeof(struct rkisp1_ext_params_sdg_config) +\
  1367. sizeof(struct rkisp1_ext_params_lsc_config) +\
  1368. sizeof(struct rkisp1_ext_params_awb_gain_config) +\
  1369. sizeof(struct rkisp1_ext_params_flt_config) +\
  1370. sizeof(struct rkisp1_ext_params_bdm_config) +\
  1371. sizeof(struct rkisp1_ext_params_ctk_config) +\
  1372. sizeof(struct rkisp1_ext_params_goc_config) +\
  1373. sizeof(struct rkisp1_ext_params_dpf_config) +\
  1374. sizeof(struct rkisp1_ext_params_dpf_strength_config) +\
  1375. sizeof(struct rkisp1_ext_params_cproc_config) +\
  1376. sizeof(struct rkisp1_ext_params_ie_config) +\
  1377. sizeof(struct rkisp1_ext_params_awb_meas_config) +\
  1378. sizeof(struct rkisp1_ext_params_hst_config) +\
  1379. sizeof(struct rkisp1_ext_params_aec_config) +\
  1380. sizeof(struct rkisp1_ext_params_afc_config) +\
  1381. sizeof(struct rkisp1_ext_params_compand_bls_config) +\
  1382. sizeof(struct rkisp1_ext_params_compand_curve_config) +\
  1383. sizeof(struct rkisp1_ext_params_compand_curve_config))
  1384. /**
  1385. * enum rksip1_ext_param_buffer_version - RkISP1 extensible parameters version
  1386. *
  1387. * @RKISP1_EXT_PARAM_BUFFER_V1: First version of RkISP1 extensible parameters
  1388. */
  1389. enum rksip1_ext_param_buffer_version {
  1390. RKISP1_EXT_PARAM_BUFFER_V1 = 1,
  1391. };
  1392. /**
  1393. * struct rkisp1_ext_params_cfg - RkISP1 extensible parameters configuration
  1394. *
  1395. * This struct contains the configuration parameters of the RkISP1 ISP
  1396. * algorithms, serialized by userspace into a data buffer. Each configuration
  1397. * parameter block is represented by a block-specific structure which contains a
  1398. * :c:type:`rkisp1_ext_params_block_header` entry as first member. Userspace
  1399. * populates the @data buffer with configuration parameters for the blocks that
  1400. * it intends to configure. As a consequence, the data buffer effective size
  1401. * changes according to the number of ISP blocks that userspace intends to
  1402. * configure and is set by userspace in the @data_size field.
  1403. *
  1404. * The parameters buffer is versioned by the @version field to allow modifying
  1405. * and extending its definition. Userspace shall populate the @version field to
  1406. * inform the driver about the version it intends to use. The driver will parse
  1407. * and handle the @data buffer according to the data layout specific to the
  1408. * indicated version and return an error if the desired version is not
  1409. * supported.
  1410. *
  1411. * Currently the single RKISP1_EXT_PARAM_BUFFER_V1 version is supported.
  1412. * When a new format version will be added, a mechanism for userspace to query
  1413. * the supported format versions will be implemented in the form of a read-only
  1414. * V4L2 control. If such control is not available, userspace should assume only
  1415. * RKISP1_EXT_PARAM_BUFFER_V1 is supported by the driver.
  1416. *
  1417. * For each ISP block that userspace wants to configure, a block-specific
  1418. * structure is appended to the @data buffer, one after the other without gaps
  1419. * in between nor overlaps. Userspace shall populate the @data_size field with
  1420. * the effective size, in bytes, of the @data buffer.
  1421. *
  1422. * The expected memory layout of the parameters buffer is::
  1423. *
  1424. * +-------------------- struct rkisp1_ext_params_cfg -------------------+
  1425. * | version = RKISP_EXT_PARAMS_BUFFER_V1; |
  1426. * | data_size = sizeof(struct rkisp1_ext_params_bls_config) |
  1427. * | + sizeof(struct rkisp1_ext_params_dpcc_config); |
  1428. * | +------------------------- data ---------------------------------+ |
  1429. * | | +------------- struct rkisp1_ext_params_bls_config -----------+ | |
  1430. * | | | +-------- struct rkisp1_ext_params_block_header ---------+ | | |
  1431. * | | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS; | | | |
  1432. * | | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; | | | |
  1433. * | | | | size = sizeof(struct rkisp1_ext_params_bls_config); | | | |
  1434. * | | | +---------------------------------------------------------+ | | |
  1435. * | | | +---------- struct rkisp1_cif_isp_bls_config -------------+ | | |
  1436. * | | | | enable_auto = 0; | | | |
  1437. * | | | | fixed_val.r = 256; | | | |
  1438. * | | | | fixed_val.gr = 256; | | | |
  1439. * | | | | fixed_val.gb = 256; | | | |
  1440. * | | | | fixed_val.b = 256; | | | |
  1441. * | | | +---------------------------------------------------------+ | | |
  1442. * | | +------------ struct rkisp1_ext_params_dpcc_config -----------+ | |
  1443. * | | | +-------- struct rkisp1_ext_params_block_header ---------+ | | |
  1444. * | | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC; | | | |
  1445. * | | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; | | | |
  1446. * | | | | size = sizeof(struct rkisp1_ext_params_dpcc_config); | | | |
  1447. * | | | +---------------------------------------------------------+ | | |
  1448. * | | | +---------- struct rkisp1_cif_isp_dpcc_config ------------+ | | |
  1449. * | | | | mode = RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE; | | | |
  1450. * | | | | output_mode = | | | |
  1451. * | | | | RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER; | | | |
  1452. * | | | | set_use = ... ; | | | |
  1453. * | | | | ... = ... ; | | | |
  1454. * | | | +---------------------------------------------------------+ | | |
  1455. * | | +-------------------------------------------------------------+ | |
  1456. * | +-----------------------------------------------------------------+ |
  1457. * +---------------------------------------------------------------------+
  1458. *
  1459. * @version: The RkISP1 extensible parameters buffer version, see
  1460. * :c:type:`rksip1_ext_param_buffer_version`
  1461. * @data_size: The RkISP1 configuration data effective size, excluding this
  1462. * header
  1463. * @data: The RkISP1 extensible configuration data blocks
  1464. */
  1465. struct rkisp1_ext_params_cfg {
  1466. __u32 version;
  1467. __u32 data_size;
  1468. __u8 data[RKISP1_EXT_PARAMS_MAX_SIZE];
  1469. };
  1470. #endif /* _RKISP1_CONFIG_H */