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

pisp_be_config.h (31055B)


  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * PiSP Back End configuration definitions.
  4. *
  5. * Copyright (C) 2021 - Raspberry Pi Ltd
  6. *
  7. */
  8. #ifndef _PISP_BE_CONFIG_H_
  9. #define _PISP_BE_CONFIG_H_
  10. #include <linux/types.h>
  11. #include "pisp_common.h"
  12. /* byte alignment for inputs */
  13. #define PISP_BACK_END_INPUT_ALIGN 4u
  14. /* alignment for compressed inputs */
  15. #define PISP_BACK_END_COMPRESSED_ALIGN 8u
  16. /* minimum required byte alignment for outputs */
  17. #define PISP_BACK_END_OUTPUT_MIN_ALIGN 16u
  18. /* preferred byte alignment for outputs */
  19. #define PISP_BACK_END_OUTPUT_MAX_ALIGN 64u
  20. /* minimum allowed tile width anywhere in the pipeline */
  21. #define PISP_BACK_END_MIN_TILE_WIDTH 16u
  22. /* minimum allowed tile width anywhere in the pipeline */
  23. #define PISP_BACK_END_MIN_TILE_HEIGHT 16u
  24. #define PISP_BACK_END_NUM_OUTPUTS 2
  25. #define PISP_BACK_END_HOG_OUTPUT 1
  26. #define PISP_BACK_END_NUM_TILES 64
  27. enum pisp_be_bayer_enable {
  28. PISP_BE_BAYER_ENABLE_INPUT = 0x000001,
  29. PISP_BE_BAYER_ENABLE_DECOMPRESS = 0x000002,
  30. PISP_BE_BAYER_ENABLE_DPC = 0x000004,
  31. PISP_BE_BAYER_ENABLE_GEQ = 0x000008,
  32. PISP_BE_BAYER_ENABLE_TDN_INPUT = 0x000010,
  33. PISP_BE_BAYER_ENABLE_TDN_DECOMPRESS = 0x000020,
  34. PISP_BE_BAYER_ENABLE_TDN = 0x000040,
  35. PISP_BE_BAYER_ENABLE_TDN_COMPRESS = 0x000080,
  36. PISP_BE_BAYER_ENABLE_TDN_OUTPUT = 0x000100,
  37. PISP_BE_BAYER_ENABLE_SDN = 0x000200,
  38. PISP_BE_BAYER_ENABLE_BLC = 0x000400,
  39. PISP_BE_BAYER_ENABLE_STITCH_INPUT = 0x000800,
  40. PISP_BE_BAYER_ENABLE_STITCH_DECOMPRESS = 0x001000,
  41. PISP_BE_BAYER_ENABLE_STITCH = 0x002000,
  42. PISP_BE_BAYER_ENABLE_STITCH_COMPRESS = 0x004000,
  43. PISP_BE_BAYER_ENABLE_STITCH_OUTPUT = 0x008000,
  44. PISP_BE_BAYER_ENABLE_WBG = 0x010000,
  45. PISP_BE_BAYER_ENABLE_CDN = 0x020000,
  46. PISP_BE_BAYER_ENABLE_LSC = 0x040000,
  47. PISP_BE_BAYER_ENABLE_TONEMAP = 0x080000,
  48. PISP_BE_BAYER_ENABLE_CAC = 0x100000,
  49. PISP_BE_BAYER_ENABLE_DEBIN = 0x200000,
  50. PISP_BE_BAYER_ENABLE_DEMOSAIC = 0x400000,
  51. };
  52. enum pisp_be_rgb_enable {
  53. PISP_BE_RGB_ENABLE_INPUT = 0x000001,
  54. PISP_BE_RGB_ENABLE_CCM = 0x000002,
  55. PISP_BE_RGB_ENABLE_SAT_CONTROL = 0x000004,
  56. PISP_BE_RGB_ENABLE_YCBCR = 0x000008,
  57. PISP_BE_RGB_ENABLE_FALSE_COLOUR = 0x000010,
  58. PISP_BE_RGB_ENABLE_SHARPEN = 0x000020,
  59. /* Preferred colours would occupy 0x000040 */
  60. PISP_BE_RGB_ENABLE_YCBCR_INVERSE = 0x000080,
  61. PISP_BE_RGB_ENABLE_GAMMA = 0x000100,
  62. PISP_BE_RGB_ENABLE_CSC0 = 0x000200,
  63. PISP_BE_RGB_ENABLE_CSC1 = 0x000400,
  64. PISP_BE_RGB_ENABLE_DOWNSCALE0 = 0x001000,
  65. PISP_BE_RGB_ENABLE_DOWNSCALE1 = 0x002000,
  66. PISP_BE_RGB_ENABLE_RESAMPLE0 = 0x008000,
  67. PISP_BE_RGB_ENABLE_RESAMPLE1 = 0x010000,
  68. PISP_BE_RGB_ENABLE_OUTPUT0 = 0x040000,
  69. PISP_BE_RGB_ENABLE_OUTPUT1 = 0x080000,
  70. PISP_BE_RGB_ENABLE_HOG = 0x200000
  71. };
  72. #define PISP_BE_RGB_ENABLE_CSC(i) (PISP_BE_RGB_ENABLE_CSC0 << (i))
  73. #define PISP_BE_RGB_ENABLE_DOWNSCALE(i) (PISP_BE_RGB_ENABLE_DOWNSCALE0 << (i))
  74. #define PISP_BE_RGB_ENABLE_RESAMPLE(i) (PISP_BE_RGB_ENABLE_RESAMPLE0 << (i))
  75. #define PISP_BE_RGB_ENABLE_OUTPUT(i) (PISP_BE_RGB_ENABLE_OUTPUT0 << (i))
  76. /*
  77. * We use the enable flags to show when blocks are "dirty", but we need some
  78. * extra ones too.
  79. */
  80. enum pisp_be_dirty {
  81. PISP_BE_DIRTY_GLOBAL = 0x0001,
  82. PISP_BE_DIRTY_SH_FC_COMBINE = 0x0002,
  83. PISP_BE_DIRTY_CROP = 0x0004
  84. };
  85. /**
  86. * struct pisp_be_global_config - PiSP global enable bitmaps
  87. * @bayer_enables: Bayer input enable flags
  88. * @rgb_enables: RGB output enable flags
  89. * @bayer_order: Bayer input format ordering
  90. * @pad: Padding bytes
  91. */
  92. struct pisp_be_global_config {
  93. __u32 bayer_enables;
  94. __u32 rgb_enables;
  95. __u8 bayer_order;
  96. __u8 pad[3];
  97. } __attribute__((packed));
  98. /**
  99. * struct pisp_be_input_buffer_config - PiSP Back End input buffer
  100. * @addr: Input buffer address
  101. */
  102. struct pisp_be_input_buffer_config {
  103. /* low 32 bits followed by high 32 bits (for each of up to 3 planes) */
  104. __u32 addr[3][2];
  105. } __attribute__((packed));
  106. /**
  107. * struct pisp_be_dpc_config - PiSP Back End DPC config
  108. *
  109. * Defective Pixel Correction configuration
  110. *
  111. * @coeff_level: Coefficient for the darkest neighbouring pixel value
  112. * @coeff_range: Coefficient for the range of pixels for this Bayer channel
  113. * @pad: Padding byte
  114. * @flags: DPC configuration flags
  115. */
  116. struct pisp_be_dpc_config {
  117. __u8 coeff_level;
  118. __u8 coeff_range;
  119. __u8 pad;
  120. #define PISP_BE_DPC_FLAG_FOLDBACK 1
  121. __u8 flags;
  122. } __attribute__((packed));
  123. /**
  124. * struct pisp_be_geq_config - PiSP Back End GEQ config
  125. *
  126. * Green Equalisation configuration
  127. *
  128. * @offset: Offset value for threshold calculation
  129. * @slope_sharper: Slope/Sharper configuration
  130. * @min: Minimum value the threshold may have
  131. * @max: Maximum value the threshold may have
  132. */
  133. struct pisp_be_geq_config {
  134. __u16 offset;
  135. #define PISP_BE_GEQ_SHARPER (1U << 15)
  136. #define PISP_BE_GEQ_SLOPE ((1 << 10) - 1)
  137. /* top bit is the "sharper" flag, slope value is bottom 10 bits */
  138. __u16 slope_sharper;
  139. __u16 min;
  140. __u16 max;
  141. } __attribute__((packed));
  142. /**
  143. * struct pisp_be_tdn_input_buffer_config - PiSP Back End TDN input buffer
  144. * @addr: TDN input buffer address
  145. */
  146. struct pisp_be_tdn_input_buffer_config {
  147. /* low 32 bits followed by high 32 bits */
  148. __u32 addr[2];
  149. } __attribute__((packed));
  150. /**
  151. * struct pisp_be_tdn_config - PiSP Back End TDN config
  152. *
  153. * Temporal Denoise configuration
  154. *
  155. * @black_level: Black level value subtracted from pixels
  156. * @ratio: Multiplier for the LTA input frame
  157. * @noise_constant: Constant offset value used in noise estimation
  158. * @noise_slope: Noise estimation multiplier
  159. * @threshold: Threshold for TDN operations
  160. * @reset: Disable TDN operations
  161. * @pad: Padding byte
  162. */
  163. struct pisp_be_tdn_config {
  164. __u16 black_level;
  165. __u16 ratio;
  166. __u16 noise_constant;
  167. __u16 noise_slope;
  168. __u16 threshold;
  169. __u8 reset;
  170. __u8 pad;
  171. } __attribute__((packed));
  172. /**
  173. * struct pisp_be_tdn_output_buffer_config - PiSP Back End TDN output buffer
  174. * @addr: TDN output buffer address
  175. */
  176. struct pisp_be_tdn_output_buffer_config {
  177. /* low 32 bits followed by high 32 bits */
  178. __u32 addr[2];
  179. } __attribute__((packed));
  180. /**
  181. * struct pisp_be_sdn_config - PiSP Back End SDN config
  182. *
  183. * Spatial Denoise configuration
  184. *
  185. * @black_level: Black level subtracted from pixel for noise estimation
  186. * @leakage: Proportion of the original undenoised value to mix in
  187. * denoised output
  188. * @pad: Padding byte
  189. * @noise_constant: Noise constant used for noise estimation
  190. * @noise_slope: Noise slope value used for noise estimation
  191. * @noise_constant2: Second noise constant used for noise estimation
  192. * @noise_slope2: Second slope value used for noise estimation
  193. */
  194. struct pisp_be_sdn_config {
  195. __u16 black_level;
  196. __u8 leakage;
  197. __u8 pad;
  198. __u16 noise_constant;
  199. __u16 noise_slope;
  200. __u16 noise_constant2;
  201. __u16 noise_slope2;
  202. } __attribute__((packed));
  203. /**
  204. * struct pisp_be_stitch_input_buffer_config - PiSP Back End Stitch input
  205. * @addr: Stitch input buffer address
  206. */
  207. struct pisp_be_stitch_input_buffer_config {
  208. /* low 32 bits followed by high 32 bits */
  209. __u32 addr[2];
  210. } __attribute__((packed));
  211. #define PISP_BE_STITCH_STREAMING_LONG 0x8000
  212. #define PISP_BE_STITCH_EXPOSURE_RATIO_MASK 0x7fff
  213. /**
  214. * struct pisp_be_stitch_config - PiSP Back End Stitch config
  215. *
  216. * Stitch block configuration
  217. *
  218. * @threshold_lo: Low threshold value
  219. * @threshold_diff_power: Low and high threshold difference
  220. * @pad: Padding bytes
  221. * @exposure_ratio: Multiplier to convert long exposure pixels into
  222. * short exposure pixels
  223. * @motion_threshold_256: Motion threshold above which short exposure
  224. * pixels are used
  225. * @motion_threshold_recip: Reciprocal of motion_threshold_256 value
  226. */
  227. struct pisp_be_stitch_config {
  228. __u16 threshold_lo;
  229. __u8 threshold_diff_power;
  230. __u8 pad;
  231. /* top bit indicates whether streaming input is the long exposure */
  232. __u16 exposure_ratio;
  233. __u8 motion_threshold_256;
  234. __u8 motion_threshold_recip;
  235. } __attribute__((packed));
  236. /**
  237. * struct pisp_be_stitch_output_buffer_config - PiSP Back End Stitch output
  238. * @addr: Stitch input buffer address
  239. */
  240. struct pisp_be_stitch_output_buffer_config {
  241. /* low 32 bits followed by high 32 bits */
  242. __u32 addr[2];
  243. } __attribute__((packed));
  244. /**
  245. * struct pisp_be_cdn_config - PiSP Back End CDN config
  246. *
  247. * Colour Denoise configuration
  248. *
  249. * @thresh: Constant for noise estimation
  250. * @iir_strength: Relative strength of the IIR part of the filter
  251. * @g_adjust: Proportion of the change assigned to the G channel
  252. */
  253. struct pisp_be_cdn_config {
  254. __u16 thresh;
  255. __u8 iir_strength;
  256. __u8 g_adjust;
  257. } __attribute__((packed));
  258. #define PISP_BE_LSC_LOG_GRID_SIZE 5
  259. #define PISP_BE_LSC_GRID_SIZE (1 << PISP_BE_LSC_LOG_GRID_SIZE)
  260. #define PISP_BE_LSC_STEP_PRECISION 18
  261. /**
  262. * struct pisp_be_lsc_config - PiSP Back End LSC config
  263. *
  264. * Lens Shading Correction configuration
  265. *
  266. * @grid_step_x: Reciprocal of cell size width
  267. * @grid_step_y: Reciprocal of cell size height
  268. * @lut_packed: Jointly-coded RGB gains for each LSC grid
  269. */
  270. struct pisp_be_lsc_config {
  271. /* (1<<18) / grid_cell_width */
  272. __u16 grid_step_x;
  273. /* (1<<18) / grid_cell_height */
  274. __u16 grid_step_y;
  275. /* RGB gains jointly encoded in 32 bits */
  276. #define PISP_BE_LSC_LUT_SIZE (PISP_BE_LSC_GRID_SIZE + 1)
  277. __u32 lut_packed[PISP_BE_LSC_LUT_SIZE][PISP_BE_LSC_LUT_SIZE];
  278. } __attribute__((packed));
  279. /**
  280. * struct pisp_be_lsc_extra - PiSP Back End LSC Extra config
  281. * @offset_x: Horizontal offset into the LSC table of this tile
  282. * @offset_y: Vertical offset into the LSC table of this tile
  283. */
  284. struct pisp_be_lsc_extra {
  285. __u16 offset_x;
  286. __u16 offset_y;
  287. } __attribute__((packed));
  288. #define PISP_BE_CAC_LOG_GRID_SIZE 3
  289. #define PISP_BE_CAC_GRID_SIZE (1 << PISP_BE_CAC_LOG_GRID_SIZE)
  290. #define PISP_BE_CAC_STEP_PRECISION 20
  291. /**
  292. * struct pisp_be_cac_config - PiSP Back End CAC config
  293. *
  294. * Chromatic Aberration Correction config
  295. *
  296. * @grid_step_x: Reciprocal of cell size width
  297. * @grid_step_y: Reciprocal of cell size height
  298. * @lut: Pixel shift for the CAC grid
  299. */
  300. struct pisp_be_cac_config {
  301. /* (1<<20) / grid_cell_width */
  302. __u16 grid_step_x;
  303. /* (1<<20) / grid_cell_height */
  304. __u16 grid_step_y;
  305. /* [gridy][gridx][rb][xy] */
  306. #define PISP_BE_CAC_LUT_SIZE (PISP_BE_CAC_GRID_SIZE + 1)
  307. __s8 lut[PISP_BE_CAC_LUT_SIZE][PISP_BE_CAC_LUT_SIZE][2][2];
  308. } __attribute__((packed));
  309. /**
  310. * struct pisp_be_cac_extra - PiSP Back End CAC extra config
  311. * @offset_x: Horizontal offset into the CAC table of this tile
  312. * @offset_y: Horizontal offset into the CAC table of this tile
  313. */
  314. struct pisp_be_cac_extra {
  315. __u16 offset_x;
  316. __u16 offset_y;
  317. } __attribute__((packed));
  318. #define PISP_BE_DEBIN_NUM_COEFFS 4
  319. /**
  320. * struct pisp_be_debin_config - PiSP Back End Debin config
  321. *
  322. * Debinning configuration
  323. *
  324. * @coeffs: Filter coefficients for debinning
  325. * @h_enable: Horizontal debinning enable
  326. * @v_enable: Vertical debinning enable
  327. * @pad: Padding bytes
  328. */
  329. struct pisp_be_debin_config {
  330. __s8 coeffs[PISP_BE_DEBIN_NUM_COEFFS];
  331. __s8 h_enable;
  332. __s8 v_enable;
  333. __s8 pad[2];
  334. } __attribute__((packed));
  335. #define PISP_BE_TONEMAP_LUT_SIZE 64
  336. /**
  337. * struct pisp_be_tonemap_config - PiSP Back End Tonemap config
  338. *
  339. * Tonemapping configuration
  340. *
  341. * @detail_constant: Constant value for threshold calculation
  342. * @detail_slope: Slope value for threshold calculation
  343. * @iir_strength: Relative strength of the IIR fiter
  344. * @strength: Strength factor
  345. * @lut: Look-up table for tonemap curve
  346. */
  347. struct pisp_be_tonemap_config {
  348. __u16 detail_constant;
  349. __u16 detail_slope;
  350. __u16 iir_strength;
  351. __u16 strength;
  352. __u32 lut[PISP_BE_TONEMAP_LUT_SIZE];
  353. } __attribute__((packed));
  354. /**
  355. * struct pisp_be_demosaic_config - PiSP Back End Demosaic config
  356. *
  357. * Demosaic configuration
  358. *
  359. * @sharper: Use other Bayer channels to increase sharpness
  360. * @fc_mode: Built-in false colour suppression mode
  361. * @pad: Padding bytes
  362. */
  363. struct pisp_be_demosaic_config {
  364. __u8 sharper;
  365. __u8 fc_mode;
  366. __u8 pad[2];
  367. } __attribute__((packed));
  368. /**
  369. * struct pisp_be_ccm_config - PiSP Back End CCM config
  370. *
  371. * Colour Correction Matrix configuration
  372. *
  373. * @coeffs: Matrix coefficients
  374. * @pad: Padding bytes
  375. * @offsets: Offsets triplet
  376. */
  377. struct pisp_be_ccm_config {
  378. __s16 coeffs[9];
  379. __u8 pad[2];
  380. __s32 offsets[3];
  381. } __attribute__((packed));
  382. /**
  383. * struct pisp_be_sat_control_config - PiSP Back End SAT config
  384. *
  385. * Saturation Control configuration
  386. *
  387. * @shift_r: Left shift for Red colour channel
  388. * @shift_g: Left shift for Green colour channel
  389. * @shift_b: Left shift for Blue colour channel
  390. * @pad: Padding byte
  391. */
  392. struct pisp_be_sat_control_config {
  393. __u8 shift_r;
  394. __u8 shift_g;
  395. __u8 shift_b;
  396. __u8 pad;
  397. } __attribute__((packed));
  398. /**
  399. * struct pisp_be_false_colour_config - PiSP Back End False Colour config
  400. *
  401. * False Colour configuration
  402. *
  403. * @distance: Distance of neighbouring pixels, either 1 or 2
  404. * @pad: Padding bytes
  405. */
  406. struct pisp_be_false_colour_config {
  407. __u8 distance;
  408. __u8 pad[3];
  409. } __attribute__((packed));
  410. #define PISP_BE_SHARPEN_SIZE 5
  411. #define PISP_BE_SHARPEN_FUNC_NUM_POINTS 9
  412. /**
  413. * struct pisp_be_sharpen_config - PiSP Back End Sharpening config
  414. *
  415. * Sharpening configuration
  416. *
  417. * @kernel0: Coefficient for filter 0
  418. * @pad0: Padding byte
  419. * @kernel1: Coefficient for filter 1
  420. * @pad1: Padding byte
  421. * @kernel2: Coefficient for filter 2
  422. * @pad2: Padding byte
  423. * @kernel3: Coefficient for filter 3
  424. * @pad3: Padding byte
  425. * @kernel4: Coefficient for filter 4
  426. * @pad4: Padding byte
  427. * @threshold_offset0: Offset for filter 0 response calculation
  428. * @threshold_slope0: Slope multiplier for the filter 0 response calculation
  429. * @scale0: Scale factor for filter 0 response calculation
  430. * @pad5: Padding byte
  431. * @threshold_offset1: Offset for filter 0 response calculation
  432. * @threshold_slope1: Slope multiplier for the filter 0 response calculation
  433. * @scale1: Scale factor for filter 0 response calculation
  434. * @pad6: Padding byte
  435. * @threshold_offset2: Offset for filter 0 response calculation
  436. * @threshold_slope2: Slope multiplier for the filter 0 response calculation
  437. * @scale2: Scale factor for filter 0 response calculation
  438. * @pad7: Padding byte
  439. * @threshold_offset3: Offset for filter 0 response calculation
  440. * @threshold_slope3: Slope multiplier for the filter 0 response calculation
  441. * @scale3: Scale factor for filter 0 response calculation
  442. * @pad8: Padding byte
  443. * @threshold_offset4: Offset for filter 0 response calculation
  444. * @threshold_slope4: Slope multiplier for the filter 0 response calculation
  445. * @scale4: Scale factor for filter 0 response calculation
  446. * @pad9: Padding byte
  447. * @positive_strength: Factor to scale the positive sharpening strength
  448. * @positive_pre_limit: Maximum allowed possible positive sharpening value
  449. * @positive_func: Gain factor applied to positive sharpening response
  450. * @positive_limit: Final gain factor applied to positive sharpening
  451. * @negative_strength: Factor to scale the negative sharpening strength
  452. * @negative_pre_limit: Maximum allowed possible negative sharpening value
  453. * @negative_func: Gain factor applied to negative sharpening response
  454. * @negative_limit: Final gain factor applied to negative sharpening
  455. * @enables: Filter enable mask
  456. * @white: White output pixel filter mask
  457. * @black: Black output pixel filter mask
  458. * @grey: Grey output pixel filter mask
  459. */
  460. struct pisp_be_sharpen_config {
  461. __s8 kernel0[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];
  462. __s8 pad0[3];
  463. __s8 kernel1[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];
  464. __s8 pad1[3];
  465. __s8 kernel2[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];
  466. __s8 pad2[3];
  467. __s8 kernel3[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];
  468. __s8 pad3[3];
  469. __s8 kernel4[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];
  470. __s8 pad4[3];
  471. __u16 threshold_offset0;
  472. __u16 threshold_slope0;
  473. __u16 scale0;
  474. __u16 pad5;
  475. __u16 threshold_offset1;
  476. __u16 threshold_slope1;
  477. __u16 scale1;
  478. __u16 pad6;
  479. __u16 threshold_offset2;
  480. __u16 threshold_slope2;
  481. __u16 scale2;
  482. __u16 pad7;
  483. __u16 threshold_offset3;
  484. __u16 threshold_slope3;
  485. __u16 scale3;
  486. __u16 pad8;
  487. __u16 threshold_offset4;
  488. __u16 threshold_slope4;
  489. __u16 scale4;
  490. __u16 pad9;
  491. __u16 positive_strength;
  492. __u16 positive_pre_limit;
  493. __u16 positive_func[PISP_BE_SHARPEN_FUNC_NUM_POINTS];
  494. __u16 positive_limit;
  495. __u16 negative_strength;
  496. __u16 negative_pre_limit;
  497. __u16 negative_func[PISP_BE_SHARPEN_FUNC_NUM_POINTS];
  498. __u16 negative_limit;
  499. __u8 enables;
  500. __u8 white;
  501. __u8 black;
  502. __u8 grey;
  503. } __attribute__((packed));
  504. /**
  505. * struct pisp_be_sh_fc_combine_config - PiSP Back End Sharpening and
  506. * False Colour config
  507. *
  508. * Sharpening and False Colour configuration
  509. *
  510. * @y_factor: Control amount of desaturation of pixels being darkened
  511. * @c1_factor: Control amount of brightening of a pixel for the Cb
  512. * channel
  513. * @c2_factor: Control amount of brightening of a pixel for the Cr
  514. * channel
  515. * @pad: Padding byte
  516. */
  517. struct pisp_be_sh_fc_combine_config {
  518. __u8 y_factor;
  519. __u8 c1_factor;
  520. __u8 c2_factor;
  521. __u8 pad;
  522. } __attribute__((packed));
  523. #define PISP_BE_GAMMA_LUT_SIZE 64
  524. /**
  525. * struct pisp_be_gamma_config - PiSP Back End Gamma configuration
  526. * @lut: Gamma curve look-up table
  527. */
  528. struct pisp_be_gamma_config {
  529. __u32 lut[PISP_BE_GAMMA_LUT_SIZE];
  530. } __attribute__((packed));
  531. /**
  532. * struct pisp_be_crop_config - PiSP Back End Crop config
  533. *
  534. * Crop configuration
  535. *
  536. * @offset_x: Number of pixels cropped from the left of the tile
  537. * @offset_y: Number of pixels cropped from the top of the tile
  538. * @width: Width of the cropped tile output
  539. * @height: Height of the cropped tile output
  540. */
  541. struct pisp_be_crop_config {
  542. __u16 offset_x, offset_y;
  543. __u16 width, height;
  544. } __attribute__((packed));
  545. #define PISP_BE_RESAMPLE_FILTER_SIZE 96
  546. /**
  547. * struct pisp_be_resample_config - PiSP Back End Resampling config
  548. *
  549. * Resample configuration
  550. *
  551. * @scale_factor_h: Horizontal scale factor
  552. * @scale_factor_v: Vertical scale factor
  553. * @coef: Resample coefficients
  554. */
  555. struct pisp_be_resample_config {
  556. __u16 scale_factor_h, scale_factor_v;
  557. __s16 coef[PISP_BE_RESAMPLE_FILTER_SIZE];
  558. } __attribute__((packed));
  559. /**
  560. * struct pisp_be_resample_extra - PiSP Back End Resample config
  561. *
  562. * Resample configuration
  563. *
  564. * @scaled_width: Width in pixels of the scaled output
  565. * @scaled_height: Height in pixels of the scaled output
  566. * @initial_phase_h: Initial horizontal phase
  567. * @initial_phase_v: Initial vertical phase
  568. */
  569. struct pisp_be_resample_extra {
  570. __u16 scaled_width;
  571. __u16 scaled_height;
  572. __s16 initial_phase_h[3];
  573. __s16 initial_phase_v[3];
  574. } __attribute__((packed));
  575. /**
  576. * struct pisp_be_downscale_config - PiSP Back End Downscale config
  577. *
  578. * Downscale configuration
  579. *
  580. * @scale_factor_h: Horizontal scale factor
  581. * @scale_factor_v: Vertical scale factor
  582. * @scale_recip_h: Horizontal reciprocal factor
  583. * @scale_recip_v: Vertical reciprocal factor
  584. */
  585. struct pisp_be_downscale_config {
  586. __u16 scale_factor_h;
  587. __u16 scale_factor_v;
  588. __u16 scale_recip_h;
  589. __u16 scale_recip_v;
  590. } __attribute__((packed));
  591. /**
  592. * struct pisp_be_downscale_extra - PiSP Back End Downscale Extra config
  593. * @scaled_width: Scaled image width
  594. * @scaled_height: Scaled image height
  595. */
  596. struct pisp_be_downscale_extra {
  597. __u16 scaled_width;
  598. __u16 scaled_height;
  599. } __attribute__((packed));
  600. /**
  601. * struct pisp_be_hog_config - PiSP Back End HOG config
  602. *
  603. * Histogram of Oriented Gradients configuration
  604. *
  605. * @compute_signed: Set 0 for unsigned gradients, 1 for signed
  606. * @channel_mix: Channels proportions to use
  607. * @stride: Stride in bytes between blocks directly below
  608. */
  609. struct pisp_be_hog_config {
  610. __u8 compute_signed;
  611. __u8 channel_mix[3];
  612. __u32 stride;
  613. } __attribute__((packed));
  614. struct pisp_be_axi_config {
  615. __u8 r_qos; /* Read QoS */
  616. __u8 r_cache_prot; /* Read { prot[2:0], cache[3:0] } */
  617. __u8 w_qos; /* Write QoS */
  618. __u8 w_cache_prot; /* Write { prot[2:0], cache[3:0] } */
  619. } __attribute__((packed));
  620. /**
  621. * enum pisp_be_transform - PiSP Back End Transform flags
  622. * @PISP_BE_TRANSFORM_NONE: No transform
  623. * @PISP_BE_TRANSFORM_HFLIP: Horizontal flip
  624. * @PISP_BE_TRANSFORM_VFLIP: Vertical flip
  625. * @PISP_BE_TRANSFORM_ROT180: 180 degress rotation
  626. */
  627. enum pisp_be_transform {
  628. PISP_BE_TRANSFORM_NONE = 0x0,
  629. PISP_BE_TRANSFORM_HFLIP = 0x1,
  630. PISP_BE_TRANSFORM_VFLIP = 0x2,
  631. PISP_BE_TRANSFORM_ROT180 =
  632. (PISP_BE_TRANSFORM_HFLIP | PISP_BE_TRANSFORM_VFLIP)
  633. };
  634. struct pisp_be_output_format_config {
  635. struct pisp_image_format_config image;
  636. __u8 transform;
  637. __u8 pad[3];
  638. __u16 lo;
  639. __u16 hi;
  640. __u16 lo2;
  641. __u16 hi2;
  642. } __attribute__((packed));
  643. /**
  644. * struct pisp_be_output_buffer_config - PiSP Back End Output buffer
  645. * @addr: Output buffer address
  646. */
  647. struct pisp_be_output_buffer_config {
  648. /* low 32 bits followed by high 32 bits (for each of 3 planes) */
  649. __u32 addr[3][2];
  650. } __attribute__((packed));
  651. /**
  652. * struct pisp_be_hog_buffer_config - PiSP Back End HOG buffer
  653. * @addr: HOG buffer address
  654. */
  655. struct pisp_be_hog_buffer_config {
  656. /* low 32 bits followed by high 32 bits */
  657. __u32 addr[2];
  658. } __attribute__((packed));
  659. /**
  660. * struct pisp_be_config - RaspberryPi PiSP Back End Processing configuration
  661. *
  662. * @input_buffer: Input buffer addresses
  663. * @tdn_input_buffer: TDN input buffer addresses
  664. * @stitch_input_buffer: Stitch input buffer addresses
  665. * @tdn_output_buffer: TDN output buffer addresses
  666. * @stitch_output_buffer: Stitch output buffer addresses
  667. * @output_buffer: Output buffers addresses
  668. * @hog_buffer: HOG buffer addresses
  669. * @global: Global PiSP configuration
  670. * @input_format: Input image format
  671. * @decompress: Decompress configuration
  672. * @dpc: Defective Pixel Correction configuration
  673. * @geq: Green Equalisation configuration
  674. * @tdn_input_format: Temporal Denoise input format
  675. * @tdn_decompress: Temporal Denoise decompress configuration
  676. * @tdn: Temporal Denoise configuration
  677. * @tdn_compress: Temporal Denoise compress configuration
  678. * @tdn_output_format: Temporal Denoise output format
  679. * @sdn: Spatial Denoise configuration
  680. * @blc: Black Level Correction configuration
  681. * @stitch_compress: Stitch compress configuration
  682. * @stitch_output_format: Stitch output format
  683. * @stitch_input_format: Stitch input format
  684. * @stitch_decompress: Stitch decompress configuration
  685. * @stitch: Stitch configuration
  686. * @lsc: Lens Shading Correction configuration
  687. * @wbg: White Balance Gain configuration
  688. * @cdn: Colour Denoise configuration
  689. * @cac: Colour Aberration Correction configuration
  690. * @debin: Debinning configuration
  691. * @tonemap: Tonemapping configuration
  692. * @demosaic: Demosaicing configuration
  693. * @ccm: Colour Correction Matrix configuration
  694. * @sat_control: Saturation Control configuration
  695. * @ycbcr: YCbCr colour correction configuration
  696. * @sharpen: Sharpening configuration
  697. * @false_colour: False colour correction
  698. * @sh_fc_combine: Sharpening and False Colour correction
  699. * @ycbcr_inverse: Inverse YCbCr colour correction
  700. * @gamma: Gamma curve configuration
  701. * @csc: Color Space Conversion configuration
  702. * @downscale: Downscale configuration
  703. * @resample: Resampling configuration
  704. * @output_format: Output format configuration
  705. * @hog: HOG configuration
  706. * @axi: AXI bus configuration
  707. * @lsc_extra: LSC extra info
  708. * @cac_extra: CAC extra info
  709. * @downscale_extra: Downscaler extra info
  710. * @resample_extra: Resample extra info
  711. * @crop: Crop configuration
  712. * @hog_format: HOG format info
  713. * @dirty_flags_bayer: Bayer enable dirty flags
  714. * (:c:type:`pisp_be_bayer_enable`)
  715. * @dirty_flags_rgb: RGB enable dirty flags
  716. * (:c:type:`pisp_be_rgb_enable`)
  717. * @dirty_flags_extra: Extra dirty flags
  718. */
  719. struct pisp_be_config {
  720. /* I/O configuration: */
  721. struct pisp_be_input_buffer_config input_buffer;
  722. struct pisp_be_tdn_input_buffer_config tdn_input_buffer;
  723. struct pisp_be_stitch_input_buffer_config stitch_input_buffer;
  724. struct pisp_be_tdn_output_buffer_config tdn_output_buffer;
  725. struct pisp_be_stitch_output_buffer_config stitch_output_buffer;
  726. struct pisp_be_output_buffer_config
  727. output_buffer[PISP_BACK_END_NUM_OUTPUTS];
  728. struct pisp_be_hog_buffer_config hog_buffer;
  729. /* Processing configuration: */
  730. struct pisp_be_global_config global;
  731. struct pisp_image_format_config input_format;
  732. struct pisp_decompress_config decompress;
  733. struct pisp_be_dpc_config dpc;
  734. struct pisp_be_geq_config geq;
  735. struct pisp_image_format_config tdn_input_format;
  736. struct pisp_decompress_config tdn_decompress;
  737. struct pisp_be_tdn_config tdn;
  738. struct pisp_compress_config tdn_compress;
  739. struct pisp_image_format_config tdn_output_format;
  740. struct pisp_be_sdn_config sdn;
  741. struct pisp_bla_config blc;
  742. struct pisp_compress_config stitch_compress;
  743. struct pisp_image_format_config stitch_output_format;
  744. struct pisp_image_format_config stitch_input_format;
  745. struct pisp_decompress_config stitch_decompress;
  746. struct pisp_be_stitch_config stitch;
  747. struct pisp_be_lsc_config lsc;
  748. struct pisp_wbg_config wbg;
  749. struct pisp_be_cdn_config cdn;
  750. struct pisp_be_cac_config cac;
  751. struct pisp_be_debin_config debin;
  752. struct pisp_be_tonemap_config tonemap;
  753. struct pisp_be_demosaic_config demosaic;
  754. struct pisp_be_ccm_config ccm;
  755. struct pisp_be_sat_control_config sat_control;
  756. struct pisp_be_ccm_config ycbcr;
  757. struct pisp_be_sharpen_config sharpen;
  758. struct pisp_be_false_colour_config false_colour;
  759. struct pisp_be_sh_fc_combine_config sh_fc_combine;
  760. struct pisp_be_ccm_config ycbcr_inverse;
  761. struct pisp_be_gamma_config gamma;
  762. struct pisp_be_ccm_config csc[PISP_BACK_END_NUM_OUTPUTS];
  763. struct pisp_be_downscale_config downscale[PISP_BACK_END_NUM_OUTPUTS];
  764. struct pisp_be_resample_config resample[PISP_BACK_END_NUM_OUTPUTS];
  765. struct pisp_be_output_format_config
  766. output_format[PISP_BACK_END_NUM_OUTPUTS];
  767. struct pisp_be_hog_config hog;
  768. struct pisp_be_axi_config axi;
  769. /* Non-register fields: */
  770. struct pisp_be_lsc_extra lsc_extra;
  771. struct pisp_be_cac_extra cac_extra;
  772. struct pisp_be_downscale_extra
  773. downscale_extra[PISP_BACK_END_NUM_OUTPUTS];
  774. struct pisp_be_resample_extra resample_extra[PISP_BACK_END_NUM_OUTPUTS];
  775. struct pisp_be_crop_config crop;
  776. struct pisp_image_format_config hog_format;
  777. __u32 dirty_flags_bayer; /* these use pisp_be_bayer_enable */
  778. __u32 dirty_flags_rgb; /* use pisp_be_rgb_enable */
  779. __u32 dirty_flags_extra; /* these use pisp_be_dirty_t */
  780. } __attribute__((packed));
  781. /**
  782. * enum pisp_tile_edge - PiSP Back End Tile position
  783. * @PISP_LEFT_EDGE: Left edge tile
  784. * @PISP_RIGHT_EDGE: Right edge tile
  785. * @PISP_TOP_EDGE: Top edge tile
  786. * @PISP_BOTTOM_EDGE: Bottom edge tile
  787. */
  788. enum pisp_tile_edge {
  789. PISP_LEFT_EDGE = (1 << 0),
  790. PISP_RIGHT_EDGE = (1 << 1),
  791. PISP_TOP_EDGE = (1 << 2),
  792. PISP_BOTTOM_EDGE = (1 << 3)
  793. };
  794. /**
  795. * struct pisp_tile - Raspberry Pi PiSP Back End tile configuration
  796. *
  797. * Tile parameters: each set of tile parameters is a 160-bytes block of data
  798. * which contains the tile processing parameters.
  799. *
  800. * @edge: Edge tile flag
  801. * @pad0: Padding bytes
  802. * @input_addr_offset: Top-left pixel offset, in bytes
  803. * @input_addr_offset2: Top-left pixel offset, in bytes for the second/
  804. * third image planes
  805. * @input_offset_x: Horizontal offset in pixels of this tile in the
  806. * input image
  807. * @input_offset_y: Vertical offset in pixels of this tile in the
  808. * input image
  809. * @input_width: Width in pixels of this tile
  810. * @input_height: Height in pixels of the this tile
  811. * @tdn_input_addr_offset: TDN input image offset, in bytes
  812. * @tdn_output_addr_offset: TDN output image offset, in bytes
  813. * @stitch_input_addr_offset: Stitch input image offset, in bytes
  814. * @stitch_output_addr_offset: Stitch output image offset, in bytes
  815. * @lsc_grid_offset_x: Horizontal offset in the LSC table for this tile
  816. * @lsc_grid_offset_y: Vertical offset in the LSC table for this tile
  817. * @cac_grid_offset_x: Horizontal offset in the CAC table for this tile
  818. * @cac_grid_offset_y: Horizontal offset in the CAC table for this tile
  819. * @crop_x_start: Number of pixels cropped from the left of the
  820. * tile
  821. * @crop_x_end: Number of pixels cropped from the right of the
  822. * tile
  823. * @crop_y_start: Number of pixels cropped from the top of the
  824. * tile
  825. * @crop_y_end: Number of pixels cropped from the bottom of the
  826. * tile
  827. * @downscale_phase_x: Initial horizontal phase in pixels
  828. * @downscale_phase_y: Initial vertical phase in pixels
  829. * @resample_in_width: Width in pixels of the tile entering the
  830. * Resample block
  831. * @resample_in_height: Height in pixels of the tile entering the
  832. * Resample block
  833. * @resample_phase_x: Initial horizontal phase for the Resample block
  834. * @resample_phase_y: Initial vertical phase for the Resample block
  835. * @output_offset_x: Horizontal offset in pixels where the tile will
  836. * be written into the output image
  837. * @output_offset_y: Vertical offset in pixels where the tile will be
  838. * written into the output image
  839. * @output_width: Width in pixels in the output image of this tile
  840. * @output_height: Height in pixels in the output image of this tile
  841. * @output_addr_offset: Offset in bytes into the output buffer
  842. * @output_addr_offset2: Offset in bytes into the output buffer for the
  843. * second and third plane
  844. * @output_hog_addr_offset: Offset in bytes into the HOG buffer where
  845. * results of this tile are to be written
  846. */
  847. struct pisp_tile {
  848. __u8 edge; /* enum pisp_tile_edge */
  849. __u8 pad0[3];
  850. /* 4 bytes */
  851. __u32 input_addr_offset;
  852. __u32 input_addr_offset2;
  853. __u16 input_offset_x;
  854. __u16 input_offset_y;
  855. __u16 input_width;
  856. __u16 input_height;
  857. /* 20 bytes */
  858. __u32 tdn_input_addr_offset;
  859. __u32 tdn_output_addr_offset;
  860. __u32 stitch_input_addr_offset;
  861. __u32 stitch_output_addr_offset;
  862. /* 36 bytes */
  863. __u32 lsc_grid_offset_x;
  864. __u32 lsc_grid_offset_y;
  865. /* 44 bytes */
  866. __u32 cac_grid_offset_x;
  867. __u32 cac_grid_offset_y;
  868. /* 52 bytes */
  869. __u16 crop_x_start[PISP_BACK_END_NUM_OUTPUTS];
  870. __u16 crop_x_end[PISP_BACK_END_NUM_OUTPUTS];
  871. __u16 crop_y_start[PISP_BACK_END_NUM_OUTPUTS];
  872. __u16 crop_y_end[PISP_BACK_END_NUM_OUTPUTS];
  873. /* 68 bytes */
  874. /* Ordering is planes then branches */
  875. __u16 downscale_phase_x[3 * PISP_BACK_END_NUM_OUTPUTS];
  876. __u16 downscale_phase_y[3 * PISP_BACK_END_NUM_OUTPUTS];
  877. /* 92 bytes */
  878. __u16 resample_in_width[PISP_BACK_END_NUM_OUTPUTS];
  879. __u16 resample_in_height[PISP_BACK_END_NUM_OUTPUTS];
  880. /* 100 bytes */
  881. /* Ordering is planes then branches */
  882. __u16 resample_phase_x[3 * PISP_BACK_END_NUM_OUTPUTS];
  883. __u16 resample_phase_y[3 * PISP_BACK_END_NUM_OUTPUTS];
  884. /* 124 bytes */
  885. __u16 output_offset_x[PISP_BACK_END_NUM_OUTPUTS];
  886. __u16 output_offset_y[PISP_BACK_END_NUM_OUTPUTS];
  887. __u16 output_width[PISP_BACK_END_NUM_OUTPUTS];
  888. __u16 output_height[PISP_BACK_END_NUM_OUTPUTS];
  889. /* 140 bytes */
  890. __u32 output_addr_offset[PISP_BACK_END_NUM_OUTPUTS];
  891. __u32 output_addr_offset2[PISP_BACK_END_NUM_OUTPUTS];
  892. /* 156 bytes */
  893. __u32 output_hog_addr_offset;
  894. /* 160 bytes */
  895. } __attribute__((packed));
  896. /**
  897. * struct pisp_be_tiles_config - Raspberry Pi PiSP Back End configuration
  898. * @tiles: Tile descriptors
  899. * @num_tiles: Number of tiles
  900. * @config: PiSP Back End configuration
  901. */
  902. struct pisp_be_tiles_config {
  903. struct pisp_be_config config;
  904. struct pisp_tile tiles[PISP_BACK_END_NUM_TILES];
  905. __u32 num_tiles;
  906. } __attribute__((packed));
  907. #endif /* _PISP_BE_CONFIG_H_ */