1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2015, Intel Corporation. 5 */ 6 7 #ifndef _IA_CSS_SDIS_COMMON_HOST_H 8 #define _IA_CSS_SDIS_COMMON_HOST_H 9 10 #define ISP_MAX_SDIS_HOR_PROJ_NUM_ISP \ 11 __ISP_SDIS_HOR_PROJ_NUM_ISP(ISP_MAX_INTERNAL_WIDTH, ISP_MAX_INTERNAL_HEIGHT, \ 12 SH_CSS_DIS_DECI_FACTOR_LOG2, ISP_PIPE_VERSION) 13 #define ISP_MAX_SDIS_VER_PROJ_NUM_ISP \ 14 __ISP_SDIS_VER_PROJ_NUM_ISP(ISP_MAX_INTERNAL_WIDTH, \ 15 SH_CSS_DIS_DECI_FACTOR_LOG2) 16 17 #define _ISP_SDIS_HOR_COEF_NUM_VECS \ 18 __ISP_SDIS_HOR_COEF_NUM_VECS(ISP_INTERNAL_WIDTH) 19 #define ISP_MAX_SDIS_HOR_COEF_NUM_VECS \ 20 __ISP_SDIS_HOR_COEF_NUM_VECS(ISP_MAX_INTERNAL_WIDTH) 21 #define ISP_MAX_SDIS_VER_COEF_NUM_VECS \ 22 __ISP_SDIS_VER_COEF_NUM_VECS(ISP_MAX_INTERNAL_HEIGHT) 23 24 /* SDIS Coefficients: */ 25 /* The ISP uses vectors to store the coefficients, so we round 26 the number of coefficients up to vectors. */ 27 #define __ISP_SDIS_HOR_COEF_NUM_VECS(in_width) _ISP_VECS(_ISP_BQS(in_width)) 28 #define __ISP_SDIS_VER_COEF_NUM_VECS(in_height) _ISP_VECS(_ISP_BQS(in_height)) 29 30 /* SDIS Projections: 31 * SDIS1: Horizontal projections are calculated for each line. 32 * Vertical projections are calculated for each column. 33 * SDIS2: Projections are calculated for each grid cell. 34 * Grid cells that do not fall completely within the image are not 35 * valid. The host needs to use the bigger one for the stride but 36 * should only return the valid ones to the 3A. */ 37 #define __ISP_SDIS_HOR_PROJ_NUM_ISP(in_width, in_height, deci_factor_log2, \ 38 isp_pipe_version) \ 39 ((isp_pipe_version == 1) ? \ 40 CEIL_SHIFT(_ISP_BQS(in_height), deci_factor_log2) : \ 41 CEIL_SHIFT(_ISP_BQS(in_width), deci_factor_log2)) 42 43 #define __ISP_SDIS_VER_PROJ_NUM_ISP(in_width, deci_factor_log2) \ 44 CEIL_SHIFT(_ISP_BQS(in_width), deci_factor_log2) 45 46 #define SH_CSS_DIS_VER_NUM_COEF_TYPES(b) \ 47 (((b)->info->sp.pipeline.isp_pipe_version == 2) ? \ 48 IA_CSS_DVS2_NUM_COEF_TYPES : \ 49 IA_CSS_DVS_NUM_COEF_TYPES) 50 51 #ifndef PIPE_GENERATION 52 #if defined(__ISP) || defined(MK_FIRMWARE) 53 54 /* Array cannot be 2-dimensional, since driver ddr allocation does not know stride */ 55 struct sh_css_isp_sdis_hori_proj_tbl { 56 s32 tbl[ISP_DVS_NUM_COEF_TYPES * ISP_MAX_SDIS_HOR_PROJ_NUM_ISP]; 57 #if DVS2_PROJ_MARGIN > 0 58 s32 margin[DVS2_PROJ_MARGIN]; 59 #endif 60 }; 61 62 struct sh_css_isp_sdis_vert_proj_tbl { 63 s32 tbl[ISP_DVS_NUM_COEF_TYPES * ISP_MAX_SDIS_VER_PROJ_NUM_ISP]; 64 #if DVS2_PROJ_MARGIN > 0 65 s32 margin[DVS2_PROJ_MARGIN]; 66 #endif 67 }; 68 69 struct sh_css_isp_sdis_hori_coef_tbl { 70 VMEM_ARRAY(tbl[ISP_DVS_NUM_COEF_TYPES], 71 ISP_MAX_SDIS_HOR_COEF_NUM_VECS * ISP_NWAY); 72 }; 73 74 struct sh_css_isp_sdis_vert_coef_tbl { 75 VMEM_ARRAY(tbl[ISP_DVS_NUM_COEF_TYPES], 76 ISP_MAX_SDIS_VER_COEF_NUM_VECS * ISP_NWAY); 77 }; 78 79 #endif /* defined(__ISP) || defined (MK_FIRMWARE) */ 80 #endif /* PIPE_GENERATION */ 81 82 #ifndef PIPE_GENERATION 83 struct s_sdis_config { 84 unsigned int horicoef_vectors; 85 unsigned int vertcoef_vectors; 86 unsigned int horiproj_num; 87 unsigned int vertproj_num; 88 }; 89 90 extern struct s_sdis_config sdis_config; 91 #endif 92 93 #endif /* _IA_CSS_SDIS_COMMON_HOST_H */ 94