969 lines · c
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 Ltd6 *7 */8#ifndef _UAPI_PISP_BE_CONFIG_H_9#define _UAPI_PISP_BE_CONFIG_H_10 11#include <linux/types.h>12 13#include "pisp_common.h"14 15/* byte alignment for inputs */16#define PISP_BACK_END_INPUT_ALIGN 4u17/* alignment for compressed inputs */18#define PISP_BACK_END_COMPRESSED_ALIGN 8u19/* minimum required byte alignment for outputs */20#define PISP_BACK_END_OUTPUT_MIN_ALIGN 16u21/* preferred byte alignment for outputs */22#define PISP_BACK_END_OUTPUT_MAX_ALIGN 64u23 24/* minimum allowed tile width anywhere in the pipeline */25#define PISP_BACK_END_MIN_TILE_WIDTH 16u26/* minimum allowed tile width anywhere in the pipeline */27#define PISP_BACK_END_MIN_TILE_HEIGHT 16u28 29#define PISP_BACK_END_NUM_OUTPUTS 230#define PISP_BACK_END_HOG_OUTPUT 131 32#define PISP_BACK_END_NUM_TILES 6433 34enum pisp_be_bayer_enable {35 PISP_BE_BAYER_ENABLE_INPUT = 0x000001,36 PISP_BE_BAYER_ENABLE_DECOMPRESS = 0x000002,37 PISP_BE_BAYER_ENABLE_DPC = 0x000004,38 PISP_BE_BAYER_ENABLE_GEQ = 0x000008,39 PISP_BE_BAYER_ENABLE_TDN_INPUT = 0x000010,40 PISP_BE_BAYER_ENABLE_TDN_DECOMPRESS = 0x000020,41 PISP_BE_BAYER_ENABLE_TDN = 0x000040,42 PISP_BE_BAYER_ENABLE_TDN_COMPRESS = 0x000080,43 PISP_BE_BAYER_ENABLE_TDN_OUTPUT = 0x000100,44 PISP_BE_BAYER_ENABLE_SDN = 0x000200,45 PISP_BE_BAYER_ENABLE_BLC = 0x000400,46 PISP_BE_BAYER_ENABLE_STITCH_INPUT = 0x000800,47 PISP_BE_BAYER_ENABLE_STITCH_DECOMPRESS = 0x001000,48 PISP_BE_BAYER_ENABLE_STITCH = 0x002000,49 PISP_BE_BAYER_ENABLE_STITCH_COMPRESS = 0x004000,50 PISP_BE_BAYER_ENABLE_STITCH_OUTPUT = 0x008000,51 PISP_BE_BAYER_ENABLE_WBG = 0x010000,52 PISP_BE_BAYER_ENABLE_CDN = 0x020000,53 PISP_BE_BAYER_ENABLE_LSC = 0x040000,54 PISP_BE_BAYER_ENABLE_TONEMAP = 0x080000,55 PISP_BE_BAYER_ENABLE_CAC = 0x100000,56 PISP_BE_BAYER_ENABLE_DEBIN = 0x200000,57 PISP_BE_BAYER_ENABLE_DEMOSAIC = 0x400000,58};59 60enum pisp_be_rgb_enable {61 PISP_BE_RGB_ENABLE_INPUT = 0x000001,62 PISP_BE_RGB_ENABLE_CCM = 0x000002,63 PISP_BE_RGB_ENABLE_SAT_CONTROL = 0x000004,64 PISP_BE_RGB_ENABLE_YCBCR = 0x000008,65 PISP_BE_RGB_ENABLE_FALSE_COLOUR = 0x000010,66 PISP_BE_RGB_ENABLE_SHARPEN = 0x000020,67 /* Preferred colours would occupy 0x000040 */68 PISP_BE_RGB_ENABLE_YCBCR_INVERSE = 0x000080,69 PISP_BE_RGB_ENABLE_GAMMA = 0x000100,70 PISP_BE_RGB_ENABLE_CSC0 = 0x000200,71 PISP_BE_RGB_ENABLE_CSC1 = 0x000400,72 PISP_BE_RGB_ENABLE_DOWNSCALE0 = 0x001000,73 PISP_BE_RGB_ENABLE_DOWNSCALE1 = 0x002000,74 PISP_BE_RGB_ENABLE_RESAMPLE0 = 0x008000,75 PISP_BE_RGB_ENABLE_RESAMPLE1 = 0x010000,76 PISP_BE_RGB_ENABLE_OUTPUT0 = 0x040000,77 PISP_BE_RGB_ENABLE_OUTPUT1 = 0x080000,78 PISP_BE_RGB_ENABLE_HOG = 0x20000079};80 81#define PISP_BE_RGB_ENABLE_CSC(i) (PISP_BE_RGB_ENABLE_CSC0 << (i))82#define PISP_BE_RGB_ENABLE_DOWNSCALE(i) (PISP_BE_RGB_ENABLE_DOWNSCALE0 << (i))83#define PISP_BE_RGB_ENABLE_RESAMPLE(i) (PISP_BE_RGB_ENABLE_RESAMPLE0 << (i))84#define PISP_BE_RGB_ENABLE_OUTPUT(i) (PISP_BE_RGB_ENABLE_OUTPUT0 << (i))85 86/*87 * We use the enable flags to show when blocks are "dirty", but we need some88 * extra ones too.89 */90enum pisp_be_dirty {91 PISP_BE_DIRTY_GLOBAL = 0x0001,92 PISP_BE_DIRTY_SH_FC_COMBINE = 0x0002,93 PISP_BE_DIRTY_CROP = 0x000494};95 96/**97 * struct pisp_be_global_config - PiSP global enable bitmaps98 * @bayer_enables: Bayer input enable flags99 * @rgb_enables: RGB output enable flags100 * @bayer_order: Bayer input format ordering101 * @pad: Padding bytes102 */103struct pisp_be_global_config {104 __u32 bayer_enables;105 __u32 rgb_enables;106 __u8 bayer_order;107 __u8 pad[3];108} __attribute__((packed));109 110/**111 * struct pisp_be_input_buffer_config - PiSP Back End input buffer112 * @addr: Input buffer address113 */114struct pisp_be_input_buffer_config {115 /* low 32 bits followed by high 32 bits (for each of up to 3 planes) */116 __u32 addr[3][2];117} __attribute__((packed));118 119/**120 * struct pisp_be_dpc_config - PiSP Back End DPC config121 *122 * Defective Pixel Correction configuration123 *124 * @coeff_level: Coefficient for the darkest neighbouring pixel value125 * @coeff_range: Coefficient for the range of pixels for this Bayer channel126 * @pad: Padding byte127 * @flags: DPC configuration flags128 */129struct pisp_be_dpc_config {130 __u8 coeff_level;131 __u8 coeff_range;132 __u8 pad;133#define PISP_BE_DPC_FLAG_FOLDBACK 1134 __u8 flags;135} __attribute__((packed));136 137/**138 * struct pisp_be_geq_config - PiSP Back End GEQ config139 *140 * Green Equalisation configuration141 *142 * @offset: Offset value for threshold calculation143 * @slope_sharper: Slope/Sharper configuration144 * @min: Minimum value the threshold may have145 * @max: Maximum value the threshold may have146 */147struct pisp_be_geq_config {148 __u16 offset;149#define PISP_BE_GEQ_SHARPER (1U << 15)150#define PISP_BE_GEQ_SLOPE ((1 << 10) - 1)151 /* top bit is the "sharper" flag, slope value is bottom 10 bits */152 __u16 slope_sharper;153 __u16 min;154 __u16 max;155} __attribute__((packed));156 157/**158 * struct pisp_be_tdn_input_buffer_config - PiSP Back End TDN input buffer159 * @addr: TDN input buffer address160 */161struct pisp_be_tdn_input_buffer_config {162 /* low 32 bits followed by high 32 bits */163 __u32 addr[2];164} __attribute__((packed));165 166/**167 * struct pisp_be_tdn_config - PiSP Back End TDN config168 *169 * Temporal Denoise configuration170 *171 * @black_level: Black level value subtracted from pixels172 * @ratio: Multiplier for the LTA input frame173 * @noise_constant: Constant offset value used in noise estimation174 * @noise_slope: Noise estimation multiplier175 * @threshold: Threshold for TDN operations176 * @reset: Disable TDN operations177 * @pad: Padding byte178 */179struct pisp_be_tdn_config {180 __u16 black_level;181 __u16 ratio;182 __u16 noise_constant;183 __u16 noise_slope;184 __u16 threshold;185 __u8 reset;186 __u8 pad;187} __attribute__((packed));188 189/**190 * struct pisp_be_tdn_output_buffer_config - PiSP Back End TDN output buffer191 * @addr: TDN output buffer address192 */193struct pisp_be_tdn_output_buffer_config {194 /* low 32 bits followed by high 32 bits */195 __u32 addr[2];196} __attribute__((packed));197 198/**199 * struct pisp_be_sdn_config - PiSP Back End SDN config200 *201 * Spatial Denoise configuration202 *203 * @black_level: Black level subtracted from pixel for noise estimation204 * @leakage: Proportion of the original undenoised value to mix in205 * denoised output206 * @pad: Padding byte207 * @noise_constant: Noise constant used for noise estimation208 * @noise_slope: Noise slope value used for noise estimation209 * @noise_constant2: Second noise constant used for noise estimation210 * @noise_slope2: Second slope value used for noise estimation211 */212struct pisp_be_sdn_config {213 __u16 black_level;214 __u8 leakage;215 __u8 pad;216 __u16 noise_constant;217 __u16 noise_slope;218 __u16 noise_constant2;219 __u16 noise_slope2;220} __attribute__((packed));221 222/**223 * struct pisp_be_stitch_input_buffer_config - PiSP Back End Stitch input224 * @addr: Stitch input buffer address225 */226struct pisp_be_stitch_input_buffer_config {227 /* low 32 bits followed by high 32 bits */228 __u32 addr[2];229} __attribute__((packed));230 231#define PISP_BE_STITCH_STREAMING_LONG 0x8000232#define PISP_BE_STITCH_EXPOSURE_RATIO_MASK 0x7fff233 234/**235 * struct pisp_be_stitch_config - PiSP Back End Stitch config236 *237 * Stitch block configuration238 *239 * @threshold_lo: Low threshold value240 * @threshold_diff_power: Low and high threshold difference241 * @pad: Padding bytes242 * @exposure_ratio: Multiplier to convert long exposure pixels into243 * short exposure pixels244 * @motion_threshold_256: Motion threshold above which short exposure245 * pixels are used246 * @motion_threshold_recip: Reciprocal of motion_threshold_256 value247 */248struct pisp_be_stitch_config {249 __u16 threshold_lo;250 __u8 threshold_diff_power;251 __u8 pad;252 253 /* top bit indicates whether streaming input is the long exposure */254 __u16 exposure_ratio;255 256 __u8 motion_threshold_256;257 __u8 motion_threshold_recip;258} __attribute__((packed));259 260/**261 * struct pisp_be_stitch_output_buffer_config - PiSP Back End Stitch output262 * @addr: Stitch input buffer address263 */264struct pisp_be_stitch_output_buffer_config {265 /* low 32 bits followed by high 32 bits */266 __u32 addr[2];267} __attribute__((packed));268 269/**270 * struct pisp_be_cdn_config - PiSP Back End CDN config271 *272 * Colour Denoise configuration273 *274 * @thresh: Constant for noise estimation275 * @iir_strength: Relative strength of the IIR part of the filter276 * @g_adjust: Proportion of the change assigned to the G channel277 */278struct pisp_be_cdn_config {279 __u16 thresh;280 __u8 iir_strength;281 __u8 g_adjust;282} __attribute__((packed));283 284#define PISP_BE_LSC_LOG_GRID_SIZE 5285#define PISP_BE_LSC_GRID_SIZE (1 << PISP_BE_LSC_LOG_GRID_SIZE)286#define PISP_BE_LSC_STEP_PRECISION 18287 288/**289 * struct pisp_be_lsc_config - PiSP Back End LSC config290 *291 * Lens Shading Correction configuration292 *293 * @grid_step_x: Reciprocal of cell size width294 * @grid_step_y: Reciprocal of cell size height295 * @lut_packed: Jointly-coded RGB gains for each LSC grid296 */297struct pisp_be_lsc_config {298 /* (1<<18) / grid_cell_width */299 __u16 grid_step_x;300 /* (1<<18) / grid_cell_height */301 __u16 grid_step_y;302 /* RGB gains jointly encoded in 32 bits */303#define PISP_BE_LSC_LUT_SIZE (PISP_BE_LSC_GRID_SIZE + 1)304 __u32 lut_packed[PISP_BE_LSC_LUT_SIZE][PISP_BE_LSC_LUT_SIZE];305} __attribute__((packed));306 307/**308 * struct pisp_be_lsc_extra - PiSP Back End LSC Extra config309 * @offset_x: Horizontal offset into the LSC table of this tile310 * @offset_y: Vertical offset into the LSC table of this tile311 */312struct pisp_be_lsc_extra {313 __u16 offset_x;314 __u16 offset_y;315} __attribute__((packed));316 317#define PISP_BE_CAC_LOG_GRID_SIZE 3318#define PISP_BE_CAC_GRID_SIZE (1 << PISP_BE_CAC_LOG_GRID_SIZE)319#define PISP_BE_CAC_STEP_PRECISION 20320 321/**322 * struct pisp_be_cac_config - PiSP Back End CAC config323 *324 * Chromatic Aberration Correction config325 *326 * @grid_step_x: Reciprocal of cell size width327 * @grid_step_y: Reciprocal of cell size height328 * @lut: Pixel shift for the CAC grid329 */330struct pisp_be_cac_config {331 /* (1<<20) / grid_cell_width */332 __u16 grid_step_x;333 /* (1<<20) / grid_cell_height */334 __u16 grid_step_y;335 /* [gridy][gridx][rb][xy] */336#define PISP_BE_CAC_LUT_SIZE (PISP_BE_CAC_GRID_SIZE + 1)337 __s8 lut[PISP_BE_CAC_LUT_SIZE][PISP_BE_CAC_LUT_SIZE][2][2];338} __attribute__((packed));339 340/**341 * struct pisp_be_cac_extra - PiSP Back End CAC extra config342 * @offset_x: Horizontal offset into the CAC table of this tile343 * @offset_y: Horizontal offset into the CAC table of this tile344 */345struct pisp_be_cac_extra {346 __u16 offset_x;347 __u16 offset_y;348} __attribute__((packed));349 350#define PISP_BE_DEBIN_NUM_COEFFS 4351 352/**353 * struct pisp_be_debin_config - PiSP Back End Debin config354 *355 * Debinning configuration356 *357 * @coeffs: Filter coefficients for debinning358 * @h_enable: Horizontal debinning enable359 * @v_enable: Vertical debinning enable360 * @pad: Padding bytes361 */362struct pisp_be_debin_config {363 __s8 coeffs[PISP_BE_DEBIN_NUM_COEFFS];364 __s8 h_enable;365 __s8 v_enable;366 __s8 pad[2];367} __attribute__((packed));368 369#define PISP_BE_TONEMAP_LUT_SIZE 64370 371/**372 * struct pisp_be_tonemap_config - PiSP Back End Tonemap config373 *374 * Tonemapping configuration375 *376 * @detail_constant: Constant value for threshold calculation377 * @detail_slope: Slope value for threshold calculation378 * @iir_strength: Relative strength of the IIR fiter379 * @strength: Strength factor380 * @lut: Look-up table for tonemap curve381 */382struct pisp_be_tonemap_config {383 __u16 detail_constant;384 __u16 detail_slope;385 __u16 iir_strength;386 __u16 strength;387 __u32 lut[PISP_BE_TONEMAP_LUT_SIZE];388} __attribute__((packed));389 390/**391 * struct pisp_be_demosaic_config - PiSP Back End Demosaic config392 *393 * Demosaic configuration394 *395 * @sharper: Use other Bayer channels to increase sharpness396 * @fc_mode: Built-in false colour suppression mode397 * @pad: Padding bytes398 */399struct pisp_be_demosaic_config {400 __u8 sharper;401 __u8 fc_mode;402 __u8 pad[2];403} __attribute__((packed));404 405/**406 * struct pisp_be_ccm_config - PiSP Back End CCM config407 *408 * Colour Correction Matrix configuration409 *410 * @coeffs: Matrix coefficients411 * @pad: Padding bytes412 * @offsets: Offsets triplet413 */414struct pisp_be_ccm_config {415 __s16 coeffs[9];416 __u8 pad[2];417 __s32 offsets[3];418} __attribute__((packed));419 420/**421 * struct pisp_be_sat_control_config - PiSP Back End SAT config422 *423 * Saturation Control configuration424 *425 * @shift_r: Left shift for Red colour channel426 * @shift_g: Left shift for Green colour channel427 * @shift_b: Left shift for Blue colour channel428 * @pad: Padding byte429 */430struct pisp_be_sat_control_config {431 __u8 shift_r;432 __u8 shift_g;433 __u8 shift_b;434 __u8 pad;435} __attribute__((packed));436 437/**438 * struct pisp_be_false_colour_config - PiSP Back End False Colour config439 *440 * False Colour configuration441 *442 * @distance: Distance of neighbouring pixels, either 1 or 2443 * @pad: Padding bytes444 */445struct pisp_be_false_colour_config {446 __u8 distance;447 __u8 pad[3];448} __attribute__((packed));449 450#define PISP_BE_SHARPEN_SIZE 5451#define PISP_BE_SHARPEN_FUNC_NUM_POINTS 9452 453/**454 * struct pisp_be_sharpen_config - PiSP Back End Sharpening config455 *456 * Sharpening configuration457 *458 * @kernel0: Coefficient for filter 0459 * @pad0: Padding byte460 * @kernel1: Coefficient for filter 1461 * @pad1: Padding byte462 * @kernel2: Coefficient for filter 2463 * @pad2: Padding byte464 * @kernel3: Coefficient for filter 3465 * @pad3: Padding byte466 * @kernel4: Coefficient for filter 4467 * @pad4: Padding byte468 * @threshold_offset0: Offset for filter 0 response calculation469 * @threshold_slope0: Slope multiplier for the filter 0 response calculation470 * @scale0: Scale factor for filter 0 response calculation471 * @pad5: Padding byte472 * @threshold_offset1: Offset for filter 0 response calculation473 * @threshold_slope1: Slope multiplier for the filter 0 response calculation474 * @scale1: Scale factor for filter 0 response calculation475 * @pad6: Padding byte476 * @threshold_offset2: Offset for filter 0 response calculation477 * @threshold_slope2: Slope multiplier for the filter 0 response calculation478 * @scale2: Scale factor for filter 0 response calculation479 * @pad7: Padding byte480 * @threshold_offset3: Offset for filter 0 response calculation481 * @threshold_slope3: Slope multiplier for the filter 0 response calculation482 * @scale3: Scale factor for filter 0 response calculation483 * @pad8: Padding byte484 * @threshold_offset4: Offset for filter 0 response calculation485 * @threshold_slope4: Slope multiplier for the filter 0 response calculation486 * @scale4: Scale factor for filter 0 response calculation487 * @pad9: Padding byte488 * @positive_strength: Factor to scale the positive sharpening strength489 * @positive_pre_limit: Maximum allowed possible positive sharpening value490 * @positive_func: Gain factor applied to positive sharpening response491 * @positive_limit: Final gain factor applied to positive sharpening492 * @negative_strength: Factor to scale the negative sharpening strength493 * @negative_pre_limit: Maximum allowed possible negative sharpening value494 * @negative_func: Gain factor applied to negative sharpening response495 * @negative_limit: Final gain factor applied to negative sharpening496 * @enables: Filter enable mask497 * @white: White output pixel filter mask498 * @black: Black output pixel filter mask499 * @grey: Grey output pixel filter mask500 */501struct pisp_be_sharpen_config {502 __s8 kernel0[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];503 __s8 pad0[3];504 __s8 kernel1[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];505 __s8 pad1[3];506 __s8 kernel2[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];507 __s8 pad2[3];508 __s8 kernel3[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];509 __s8 pad3[3];510 __s8 kernel4[PISP_BE_SHARPEN_SIZE * PISP_BE_SHARPEN_SIZE];511 __s8 pad4[3];512 __u16 threshold_offset0;513 __u16 threshold_slope0;514 __u16 scale0;515 __u16 pad5;516 __u16 threshold_offset1;517 __u16 threshold_slope1;518 __u16 scale1;519 __u16 pad6;520 __u16 threshold_offset2;521 __u16 threshold_slope2;522 __u16 scale2;523 __u16 pad7;524 __u16 threshold_offset3;525 __u16 threshold_slope3;526 __u16 scale3;527 __u16 pad8;528 __u16 threshold_offset4;529 __u16 threshold_slope4;530 __u16 scale4;531 __u16 pad9;532 __u16 positive_strength;533 __u16 positive_pre_limit;534 __u16 positive_func[PISP_BE_SHARPEN_FUNC_NUM_POINTS];535 __u16 positive_limit;536 __u16 negative_strength;537 __u16 negative_pre_limit;538 __u16 negative_func[PISP_BE_SHARPEN_FUNC_NUM_POINTS];539 __u16 negative_limit;540 __u8 enables;541 __u8 white;542 __u8 black;543 __u8 grey;544} __attribute__((packed));545 546/**547 * struct pisp_be_sh_fc_combine_config - PiSP Back End Sharpening and548 * False Colour config549 *550 * Sharpening and False Colour configuration551 *552 * @y_factor: Control amount of desaturation of pixels being darkened553 * @c1_factor: Control amount of brightening of a pixel for the Cb554 * channel555 * @c2_factor: Control amount of brightening of a pixel for the Cr556 * channel557 * @pad: Padding byte558 */559struct pisp_be_sh_fc_combine_config {560 __u8 y_factor;561 __u8 c1_factor;562 __u8 c2_factor;563 __u8 pad;564} __attribute__((packed));565 566#define PISP_BE_GAMMA_LUT_SIZE 64567 568/**569 * struct pisp_be_gamma_config - PiSP Back End Gamma configuration570 * @lut: Gamma curve look-up table571 */572struct pisp_be_gamma_config {573 __u32 lut[PISP_BE_GAMMA_LUT_SIZE];574} __attribute__((packed));575 576/**577 * struct pisp_be_crop_config - PiSP Back End Crop config578 *579 * Crop configuration580 *581 * @offset_x: Number of pixels cropped from the left of the tile582 * @offset_y: Number of pixels cropped from the top of the tile583 * @width: Width of the cropped tile output584 * @height: Height of the cropped tile output585 */586struct pisp_be_crop_config {587 __u16 offset_x, offset_y;588 __u16 width, height;589} __attribute__((packed));590 591#define PISP_BE_RESAMPLE_FILTER_SIZE 96592 593/**594 * struct pisp_be_resample_config - PiSP Back End Resampling config595 *596 * Resample configuration597 *598 * @scale_factor_h: Horizontal scale factor599 * @scale_factor_v: Vertical scale factor600 * @coef: Resample coefficients601 */602struct pisp_be_resample_config {603 __u16 scale_factor_h, scale_factor_v;604 __s16 coef[PISP_BE_RESAMPLE_FILTER_SIZE];605} __attribute__((packed));606 607/**608 * struct pisp_be_resample_extra - PiSP Back End Resample config609 *610 * Resample configuration611 *612 * @scaled_width: Width in pixels of the scaled output613 * @scaled_height: Height in pixels of the scaled output614 * @initial_phase_h: Initial horizontal phase615 * @initial_phase_v: Initial vertical phase616 */617struct pisp_be_resample_extra {618 __u16 scaled_width;619 __u16 scaled_height;620 __s16 initial_phase_h[3];621 __s16 initial_phase_v[3];622} __attribute__((packed));623 624/**625 * struct pisp_be_downscale_config - PiSP Back End Downscale config626 *627 * Downscale configuration628 *629 * @scale_factor_h: Horizontal scale factor630 * @scale_factor_v: Vertical scale factor631 * @scale_recip_h: Horizontal reciprocal factor632 * @scale_recip_v: Vertical reciprocal factor633 */634struct pisp_be_downscale_config {635 __u16 scale_factor_h;636 __u16 scale_factor_v;637 __u16 scale_recip_h;638 __u16 scale_recip_v;639} __attribute__((packed));640 641/**642 * struct pisp_be_downscale_extra - PiSP Back End Downscale Extra config643 * @scaled_width: Scaled image width644 * @scaled_height: Scaled image height645 */646struct pisp_be_downscale_extra {647 __u16 scaled_width;648 __u16 scaled_height;649} __attribute__((packed));650 651/**652 * struct pisp_be_hog_config - PiSP Back End HOG config653 *654 * Histogram of Oriented Gradients configuration655 *656 * @compute_signed: Set 0 for unsigned gradients, 1 for signed657 * @channel_mix: Channels proportions to use658 * @stride: Stride in bytes between blocks directly below659 */660struct pisp_be_hog_config {661 __u8 compute_signed;662 __u8 channel_mix[3];663 __u32 stride;664} __attribute__((packed));665 666struct pisp_be_axi_config {667 __u8 r_qos; /* Read QoS */668 __u8 r_cache_prot; /* Read { prot[2:0], cache[3:0] } */669 __u8 w_qos; /* Write QoS */670 __u8 w_cache_prot; /* Write { prot[2:0], cache[3:0] } */671} __attribute__((packed));672 673/**674 * enum pisp_be_transform - PiSP Back End Transform flags675 * @PISP_BE_TRANSFORM_NONE: No transform676 * @PISP_BE_TRANSFORM_HFLIP: Horizontal flip677 * @PISP_BE_TRANSFORM_VFLIP: Vertical flip678 * @PISP_BE_TRANSFORM_ROT180: 180 degress rotation679 */680enum pisp_be_transform {681 PISP_BE_TRANSFORM_NONE = 0x0,682 PISP_BE_TRANSFORM_HFLIP = 0x1,683 PISP_BE_TRANSFORM_VFLIP = 0x2,684 PISP_BE_TRANSFORM_ROT180 =685 (PISP_BE_TRANSFORM_HFLIP | PISP_BE_TRANSFORM_VFLIP)686};687 688struct pisp_be_output_format_config {689 struct pisp_image_format_config image;690 __u8 transform;691 __u8 pad[3];692 __u16 lo;693 __u16 hi;694 __u16 lo2;695 __u16 hi2;696} __attribute__((packed));697 698/**699 * struct pisp_be_output_buffer_config - PiSP Back End Output buffer700 * @addr: Output buffer address701 */702struct pisp_be_output_buffer_config {703 /* low 32 bits followed by high 32 bits (for each of 3 planes) */704 __u32 addr[3][2];705} __attribute__((packed));706 707/**708 * struct pisp_be_hog_buffer_config - PiSP Back End HOG buffer709 * @addr: HOG buffer address710 */711struct pisp_be_hog_buffer_config {712 /* low 32 bits followed by high 32 bits */713 __u32 addr[2];714} __attribute__((packed));715 716/**717 * struct pisp_be_config - RaspberryPi PiSP Back End Processing configuration718 *719 * @input_buffer: Input buffer addresses720 * @tdn_input_buffer: TDN input buffer addresses721 * @stitch_input_buffer: Stitch input buffer addresses722 * @tdn_output_buffer: TDN output buffer addresses723 * @stitch_output_buffer: Stitch output buffer addresses724 * @output_buffer: Output buffers addresses725 * @hog_buffer: HOG buffer addresses726 * @global: Global PiSP configuration727 * @input_format: Input image format728 * @decompress: Decompress configuration729 * @dpc: Defective Pixel Correction configuration730 * @geq: Green Equalisation configuration731 * @tdn_input_format: Temporal Denoise input format732 * @tdn_decompress: Temporal Denoise decompress configuration733 * @tdn: Temporal Denoise configuration734 * @tdn_compress: Temporal Denoise compress configuration735 * @tdn_output_format: Temporal Denoise output format736 * @sdn: Spatial Denoise configuration737 * @blc: Black Level Correction configuration738 * @stitch_compress: Stitch compress configuration739 * @stitch_output_format: Stitch output format740 * @stitch_input_format: Stitch input format741 * @stitch_decompress: Stitch decompress configuration742 * @stitch: Stitch configuration743 * @lsc: Lens Shading Correction configuration744 * @wbg: White Balance Gain configuration745 * @cdn: Colour Denoise configuration746 * @cac: Colour Aberration Correction configuration747 * @debin: Debinning configuration748 * @tonemap: Tonemapping configuration749 * @demosaic: Demosaicing configuration750 * @ccm: Colour Correction Matrix configuration751 * @sat_control: Saturation Control configuration752 * @ycbcr: YCbCr colour correction configuration753 * @sharpen: Sharpening configuration754 * @false_colour: False colour correction755 * @sh_fc_combine: Sharpening and False Colour correction756 * @ycbcr_inverse: Inverse YCbCr colour correction757 * @gamma: Gamma curve configuration758 * @csc: Color Space Conversion configuration759 * @downscale: Downscale configuration760 * @resample: Resampling configuration761 * @output_format: Output format configuration762 * @hog: HOG configuration763 * @axi: AXI bus configuration764 * @lsc_extra: LSC extra info765 * @cac_extra: CAC extra info766 * @downscale_extra: Downscaler extra info767 * @resample_extra: Resample extra info768 * @crop: Crop configuration769 * @hog_format: HOG format info770 * @dirty_flags_bayer: Bayer enable dirty flags771 * (:c:type:`pisp_be_bayer_enable`)772 * @dirty_flags_rgb: RGB enable dirty flags773 * (:c:type:`pisp_be_rgb_enable`)774 * @dirty_flags_extra: Extra dirty flags775 */776struct pisp_be_config {777 /* I/O configuration: */778 struct pisp_be_input_buffer_config input_buffer;779 struct pisp_be_tdn_input_buffer_config tdn_input_buffer;780 struct pisp_be_stitch_input_buffer_config stitch_input_buffer;781 struct pisp_be_tdn_output_buffer_config tdn_output_buffer;782 struct pisp_be_stitch_output_buffer_config stitch_output_buffer;783 struct pisp_be_output_buffer_config784 output_buffer[PISP_BACK_END_NUM_OUTPUTS];785 struct pisp_be_hog_buffer_config hog_buffer;786 /* Processing configuration: */787 struct pisp_be_global_config global;788 struct pisp_image_format_config input_format;789 struct pisp_decompress_config decompress;790 struct pisp_be_dpc_config dpc;791 struct pisp_be_geq_config geq;792 struct pisp_image_format_config tdn_input_format;793 struct pisp_decompress_config tdn_decompress;794 struct pisp_be_tdn_config tdn;795 struct pisp_compress_config tdn_compress;796 struct pisp_image_format_config tdn_output_format;797 struct pisp_be_sdn_config sdn;798 struct pisp_bla_config blc;799 struct pisp_compress_config stitch_compress;800 struct pisp_image_format_config stitch_output_format;801 struct pisp_image_format_config stitch_input_format;802 struct pisp_decompress_config stitch_decompress;803 struct pisp_be_stitch_config stitch;804 struct pisp_be_lsc_config lsc;805 struct pisp_wbg_config wbg;806 struct pisp_be_cdn_config cdn;807 struct pisp_be_cac_config cac;808 struct pisp_be_debin_config debin;809 struct pisp_be_tonemap_config tonemap;810 struct pisp_be_demosaic_config demosaic;811 struct pisp_be_ccm_config ccm;812 struct pisp_be_sat_control_config sat_control;813 struct pisp_be_ccm_config ycbcr;814 struct pisp_be_sharpen_config sharpen;815 struct pisp_be_false_colour_config false_colour;816 struct pisp_be_sh_fc_combine_config sh_fc_combine;817 struct pisp_be_ccm_config ycbcr_inverse;818 struct pisp_be_gamma_config gamma;819 struct pisp_be_ccm_config csc[PISP_BACK_END_NUM_OUTPUTS];820 struct pisp_be_downscale_config downscale[PISP_BACK_END_NUM_OUTPUTS];821 struct pisp_be_resample_config resample[PISP_BACK_END_NUM_OUTPUTS];822 struct pisp_be_output_format_config823 output_format[PISP_BACK_END_NUM_OUTPUTS];824 struct pisp_be_hog_config hog;825 struct pisp_be_axi_config axi;826 /* Non-register fields: */827 struct pisp_be_lsc_extra lsc_extra;828 struct pisp_be_cac_extra cac_extra;829 struct pisp_be_downscale_extra830 downscale_extra[PISP_BACK_END_NUM_OUTPUTS];831 struct pisp_be_resample_extra resample_extra[PISP_BACK_END_NUM_OUTPUTS];832 struct pisp_be_crop_config crop;833 struct pisp_image_format_config hog_format;834 __u32 dirty_flags_bayer; /* these use pisp_be_bayer_enable */835 __u32 dirty_flags_rgb; /* use pisp_be_rgb_enable */836 __u32 dirty_flags_extra; /* these use pisp_be_dirty_t */837} __attribute__((packed));838 839/**840 * enum pisp_tile_edge - PiSP Back End Tile position841 * @PISP_LEFT_EDGE: Left edge tile842 * @PISP_RIGHT_EDGE: Right edge tile843 * @PISP_TOP_EDGE: Top edge tile844 * @PISP_BOTTOM_EDGE: Bottom edge tile845 */846enum pisp_tile_edge {847 PISP_LEFT_EDGE = (1 << 0),848 PISP_RIGHT_EDGE = (1 << 1),849 PISP_TOP_EDGE = (1 << 2),850 PISP_BOTTOM_EDGE = (1 << 3)851};852 853/**854 * struct pisp_tile - Raspberry Pi PiSP Back End tile configuration855 *856 * Tile parameters: each set of tile parameters is a 160-bytes block of data857 * which contains the tile processing parameters.858 *859 * @edge: Edge tile flag860 * @pad0: Padding bytes861 * @input_addr_offset: Top-left pixel offset, in bytes862 * @input_addr_offset2: Top-left pixel offset, in bytes for the second/863 * third image planes864 * @input_offset_x: Horizontal offset in pixels of this tile in the865 * input image866 * @input_offset_y: Vertical offset in pixels of this tile in the867 * input image868 * @input_width: Width in pixels of this tile869 * @input_height: Height in pixels of the this tile870 * @tdn_input_addr_offset: TDN input image offset, in bytes871 * @tdn_output_addr_offset: TDN output image offset, in bytes872 * @stitch_input_addr_offset: Stitch input image offset, in bytes873 * @stitch_output_addr_offset: Stitch output image offset, in bytes874 * @lsc_grid_offset_x: Horizontal offset in the LSC table for this tile875 * @lsc_grid_offset_y: Vertical offset in the LSC table for this tile876 * @cac_grid_offset_x: Horizontal offset in the CAC table for this tile877 * @cac_grid_offset_y: Horizontal offset in the CAC table for this tile878 * @crop_x_start: Number of pixels cropped from the left of the879 * tile880 * @crop_x_end: Number of pixels cropped from the right of the881 * tile882 * @crop_y_start: Number of pixels cropped from the top of the883 * tile884 * @crop_y_end: Number of pixels cropped from the bottom of the885 * tile886 * @downscale_phase_x: Initial horizontal phase in pixels887 * @downscale_phase_y: Initial vertical phase in pixels888 * @resample_in_width: Width in pixels of the tile entering the889 * Resample block890 * @resample_in_height: Height in pixels of the tile entering the891 * Resample block892 * @resample_phase_x: Initial horizontal phase for the Resample block893 * @resample_phase_y: Initial vertical phase for the Resample block894 * @output_offset_x: Horizontal offset in pixels where the tile will895 * be written into the output image896 * @output_offset_y: Vertical offset in pixels where the tile will be897 * written into the output image898 * @output_width: Width in pixels in the output image of this tile899 * @output_height: Height in pixels in the output image of this tile900 * @output_addr_offset: Offset in bytes into the output buffer901 * @output_addr_offset2: Offset in bytes into the output buffer for the902 * second and third plane903 * @output_hog_addr_offset: Offset in bytes into the HOG buffer where904 * results of this tile are to be written905 */906struct pisp_tile {907 __u8 edge; /* enum pisp_tile_edge */908 __u8 pad0[3];909 /* 4 bytes */910 __u32 input_addr_offset;911 __u32 input_addr_offset2;912 __u16 input_offset_x;913 __u16 input_offset_y;914 __u16 input_width;915 __u16 input_height;916 /* 20 bytes */917 __u32 tdn_input_addr_offset;918 __u32 tdn_output_addr_offset;919 __u32 stitch_input_addr_offset;920 __u32 stitch_output_addr_offset;921 /* 36 bytes */922 __u32 lsc_grid_offset_x;923 __u32 lsc_grid_offset_y;924 /* 44 bytes */925 __u32 cac_grid_offset_x;926 __u32 cac_grid_offset_y;927 /* 52 bytes */928 __u16 crop_x_start[PISP_BACK_END_NUM_OUTPUTS];929 __u16 crop_x_end[PISP_BACK_END_NUM_OUTPUTS];930 __u16 crop_y_start[PISP_BACK_END_NUM_OUTPUTS];931 __u16 crop_y_end[PISP_BACK_END_NUM_OUTPUTS];932 /* 68 bytes */933 /* Ordering is planes then branches */934 __u16 downscale_phase_x[3 * PISP_BACK_END_NUM_OUTPUTS];935 __u16 downscale_phase_y[3 * PISP_BACK_END_NUM_OUTPUTS];936 /* 92 bytes */937 __u16 resample_in_width[PISP_BACK_END_NUM_OUTPUTS];938 __u16 resample_in_height[PISP_BACK_END_NUM_OUTPUTS];939 /* 100 bytes */940 /* Ordering is planes then branches */941 __u16 resample_phase_x[3 * PISP_BACK_END_NUM_OUTPUTS];942 __u16 resample_phase_y[3 * PISP_BACK_END_NUM_OUTPUTS];943 /* 124 bytes */944 __u16 output_offset_x[PISP_BACK_END_NUM_OUTPUTS];945 __u16 output_offset_y[PISP_BACK_END_NUM_OUTPUTS];946 __u16 output_width[PISP_BACK_END_NUM_OUTPUTS];947 __u16 output_height[PISP_BACK_END_NUM_OUTPUTS];948 /* 140 bytes */949 __u32 output_addr_offset[PISP_BACK_END_NUM_OUTPUTS];950 __u32 output_addr_offset2[PISP_BACK_END_NUM_OUTPUTS];951 /* 156 bytes */952 __u32 output_hog_addr_offset;953 /* 160 bytes */954} __attribute__((packed));955 956/**957 * struct pisp_be_tiles_config - Raspberry Pi PiSP Back End configuration958 * @tiles: Tile descriptors959 * @num_tiles: Number of tiles960 * @config: PiSP Back End configuration961 */962struct pisp_be_tiles_config {963 struct pisp_be_config config;964 struct pisp_tile tiles[PISP_BACK_END_NUM_TILES];965 __u32 num_tiles;966} __attribute__((packed));967 968#endif /* _UAPI_PISP_BE_CONFIG_H_ */969