1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2015, Intel Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms and conditions of the GNU General Public License, 8 * version 2, as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 */ 15 16 #ifndef __IA_CSS_SDIS_COMMON_TYPES_H 17 #define __IA_CSS_SDIS_COMMON_TYPES_H 18 19 /* @file 20 * CSS-API header file for DVS statistics parameters. 21 */ 22 23 #include <type_support.h> 24 25 /* DVS statistics grid dimensions in number of cells. 26 */ 27 28 struct ia_css_dvs_grid_dim { 29 u32 width; /** Width of DVS grid table in cells */ 30 u32 height; /** Height of DVS grid table in cells */ 31 }; 32 33 /* DVS statistics dimensions in number of cells for 34 * grid, coeffieicient and projection. 35 */ 36 37 struct ia_css_sdis_info { 38 struct { 39 struct ia_css_dvs_grid_dim dim; /* Dimensions */ 40 struct ia_css_dvs_grid_dim pad; /* Padded dimensions */ 41 } grid, coef, proj; 42 u32 deci_factor_log2; 43 }; 44 45 /* DVS statistics grid 46 * 47 * ISP block: SDVS1 (DIS/DVS Support for DIS/DVS ver.1 (2-axes)) 48 * SDVS2 (DVS Support for DVS ver.2 (6-axes)) 49 * ISP1: SDVS1 is used. 50 * ISP2: SDVS2 is used. 51 */ 52 struct ia_css_dvs_grid_res { 53 u32 width; /** Width of DVS grid table. 54 (= Horizontal number of grid cells 55 in table, which cells have effective 56 statistics.) 57 For DVS1, this is equal to 58 the number of vertical statistics. */ 59 u32 aligned_width; /** Stride of each grid line. 60 (= Horizontal number of grid cells 61 in table, which means 62 the allocated width.) */ 63 u32 height; /** Height of DVS grid table. 64 (= Vertical number of grid cells 65 in table, which cells have effective 66 statistics.) 67 For DVS1, This is equal to 68 the number of horizontal statistics. */ 69 u32 aligned_height;/** Stride of each grid column. 70 (= Vertical number of grid cells 71 in table, which means 72 the allocated height.) */ 73 }; 74 75 /* TODO: use ia_css_dvs_grid_res in here. 76 * However, that implies driver I/F changes 77 */ 78 struct ia_css_dvs_grid_info { 79 u32 enable; /** DVS statistics enabled. 80 0:disabled, 1:enabled */ 81 u32 width; /** Width of DVS grid table. 82 (= Horizontal number of grid cells 83 in table, which cells have effective 84 statistics.) 85 For DVS1, this is equal to 86 the number of vertical statistics. */ 87 u32 aligned_width; /** Stride of each grid line. 88 (= Horizontal number of grid cells 89 in table, which means 90 the allocated width.) */ 91 u32 height; /** Height of DVS grid table. 92 (= Vertical number of grid cells 93 in table, which cells have effective 94 statistics.) 95 For DVS1, This is equal to 96 the number of horizontal statistics. */ 97 u32 aligned_height;/** Stride of each grid column. 98 (= Vertical number of grid cells 99 in table, which means 100 the allocated height.) */ 101 u32 bqs_per_grid_cell; /** Grid cell size in BQ(Bayer Quad) unit. 102 (1BQ means {Gr,R,B,Gb}(2x2 pixels).) 103 For DVS1, valid value is 64. 104 For DVS2, valid value is only 64, 105 currently. */ 106 u32 num_hor_coefs; /** Number of horizontal coefficients. */ 107 u32 num_ver_coefs; /** Number of vertical coefficients. */ 108 }; 109 110 /* Number of DVS statistics levels 111 */ 112 #define IA_CSS_DVS_STAT_NUM_OF_LEVELS 3 113 114 /* DVS statistics generated by accelerator global configuration 115 */ 116 struct dvs_stat_public_dvs_global_cfg { 117 unsigned char kappa; 118 /** DVS statistics global configuration - kappa */ 119 unsigned char match_shift; 120 /** DVS statistics global configuration - match_shift */ 121 unsigned char ybin_mode; 122 /** DVS statistics global configuration - y binning mode */ 123 }; 124 125 /* DVS statistics generated by accelerator level grid 126 * configuration 127 */ 128 struct dvs_stat_public_dvs_level_grid_cfg { 129 unsigned char grid_width; 130 /** DVS statistics grid width */ 131 unsigned char grid_height; 132 /** DVS statistics grid height */ 133 unsigned char block_width; 134 /** DVS statistics block width */ 135 unsigned char block_height; 136 /** DVS statistics block height */ 137 }; 138 139 /* DVS statistics generated by accelerator level grid start 140 * configuration 141 */ 142 struct dvs_stat_public_dvs_level_grid_start { 143 unsigned short x_start; 144 /** DVS statistics level x start */ 145 unsigned short y_start; 146 /** DVS statistics level y start */ 147 unsigned char enable; 148 /** DVS statistics level enable */ 149 }; 150 151 /* DVS statistics generated by accelerator level grid end 152 * configuration 153 */ 154 struct dvs_stat_public_dvs_level_grid_end { 155 unsigned short x_end; 156 /** DVS statistics level x end */ 157 unsigned short y_end; 158 /** DVS statistics level y end */ 159 }; 160 161 /* DVS statistics generated by accelerator Feature Extraction 162 * Region Of Interest (FE-ROI) configuration 163 */ 164 struct dvs_stat_public_dvs_level_fe_roi_cfg { 165 unsigned char x_start; 166 /** DVS statistics fe-roi level x start */ 167 unsigned char y_start; 168 /** DVS statistics fe-roi level y start */ 169 unsigned char x_end; 170 /** DVS statistics fe-roi level x end */ 171 unsigned char y_end; 172 /** DVS statistics fe-roi level y end */ 173 }; 174 175 /* DVS statistics generated by accelerator public configuration 176 */ 177 struct dvs_stat_public_dvs_grd_cfg { 178 struct dvs_stat_public_dvs_level_grid_cfg grd_cfg; 179 /** DVS statistics level grid configuration */ 180 struct dvs_stat_public_dvs_level_grid_start grd_start; 181 /** DVS statistics level grid start configuration */ 182 struct dvs_stat_public_dvs_level_grid_end grd_end; 183 /** DVS statistics level grid end configuration */ 184 }; 185 186 /* DVS statistics grid generated by accelerator 187 */ 188 struct ia_css_dvs_stat_grid_info { 189 struct dvs_stat_public_dvs_global_cfg dvs_gbl_cfg; 190 /** DVS statistics global configuration (kappa, match, binning) */ 191 struct dvs_stat_public_dvs_grd_cfg grd_cfg[IA_CSS_DVS_STAT_NUM_OF_LEVELS]; 192 /** DVS statistics grid configuration (blocks and grids) */ 193 struct dvs_stat_public_dvs_level_fe_roi_cfg 194 fe_roi_cfg[IA_CSS_DVS_STAT_NUM_OF_LEVELS]; 195 /** DVS statistics FE ROI (region of interest) configuration */ 196 }; 197 198 /* DVS statistics generated by accelerator default grid info 199 */ 200 #define DEFAULT_DVS_GRID_INFO { \ 201 .dvs_stat_grid_info = { \ 202 .fe_roi_cfg = { \ 203 [1] = { \ 204 .x_start = 4 \ 205 } \ 206 } \ 207 } \ 208 } 209 210 /* Union that holds all types of DVS statistics grid info in 211 * CSS format 212 * */ 213 union ia_css_dvs_grid_u { 214 struct ia_css_dvs_stat_grid_info dvs_stat_grid_info; 215 /** DVS statistics produced by accelerator grid info */ 216 struct ia_css_dvs_grid_info dvs_grid_info; 217 /** DVS (DVS1/DVS2) grid info */ 218 }; 219 220 #endif /* __IA_CSS_SDIS_COMMON_TYPES_H */ 221