2  * Support for Intel Camera Imaging ISP subsystem.
 
   3  * Copyright (c) 2015, Intel Corporation.
 
   5  * This program is free software; you can redistribute it and/or modify it
 
   6  * under the terms and conditions of the GNU General Public License,
 
   7  * version 2, as published by the Free Software Foundation.
 
   9  * This program is distributed in the hope it will be useful, but WITHOUT
 
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 
  15 #ifndef _IA_CSS_SDIS_COMMON_HOST_H
 
  16 #define _IA_CSS_SDIS_COMMON_HOST_H
 
  18 #define ISP_MAX_SDIS_HOR_PROJ_NUM_ISP \
 
  19         __ISP_SDIS_HOR_PROJ_NUM_ISP(ISP_MAX_INTERNAL_WIDTH, ISP_MAX_INTERNAL_HEIGHT, \
 
  20                 SH_CSS_DIS_DECI_FACTOR_LOG2, ISP_PIPE_VERSION)
 
  21 #define ISP_MAX_SDIS_VER_PROJ_NUM_ISP \
 
  22         __ISP_SDIS_VER_PROJ_NUM_ISP(ISP_MAX_INTERNAL_WIDTH, \
 
  23                 SH_CSS_DIS_DECI_FACTOR_LOG2)
 
  25 #define _ISP_SDIS_HOR_COEF_NUM_VECS \
 
  26         __ISP_SDIS_HOR_COEF_NUM_VECS(ISP_INTERNAL_WIDTH)
 
  27 #define ISP_MAX_SDIS_HOR_COEF_NUM_VECS \
 
  28         __ISP_SDIS_HOR_COEF_NUM_VECS(ISP_MAX_INTERNAL_WIDTH)
 
  29 #define ISP_MAX_SDIS_VER_COEF_NUM_VECS \
 
  30         __ISP_SDIS_VER_COEF_NUM_VECS(ISP_MAX_INTERNAL_HEIGHT)
 
  32 /* SDIS Coefficients: */
 
  33 /* The ISP uses vectors to store the coefficients, so we round
 
  34    the number of coefficients up to vectors. */
 
  35 #define __ISP_SDIS_HOR_COEF_NUM_VECS(in_width)  _ISP_VECS(_ISP_BQS(in_width))
 
  36 #define __ISP_SDIS_VER_COEF_NUM_VECS(in_height) _ISP_VECS(_ISP_BQS(in_height))
 
  39  * SDIS1: Horizontal projections are calculated for each line.
 
  40  * Vertical projections are calculated for each column.
 
  41  * SDIS2: Projections are calculated for each grid cell.
 
  42  * Grid cells that do not fall completely within the image are not
 
  43  * valid. The host needs to use the bigger one for the stride but
 
  44  * should only return the valid ones to the 3A. */
 
  45 #define __ISP_SDIS_HOR_PROJ_NUM_ISP(in_width, in_height, deci_factor_log2, \
 
  47         ((isp_pipe_version == 1) ? \
 
  48                 CEIL_SHIFT(_ISP_BQS(in_height), deci_factor_log2) : \
 
  49                 CEIL_SHIFT(_ISP_BQS(in_width), deci_factor_log2))
 
  51 #define __ISP_SDIS_VER_PROJ_NUM_ISP(in_width, deci_factor_log2) \
 
  52         CEIL_SHIFT(_ISP_BQS(in_width), deci_factor_log2)
 
  54 #define SH_CSS_DIS_VER_NUM_COEF_TYPES(b) \
 
  55   (((b)->info->sp.pipeline.isp_pipe_version == 2) ? \
 
  56         IA_CSS_DVS2_NUM_COEF_TYPES : \
 
  57         IA_CSS_DVS_NUM_COEF_TYPES)
 
  59 #ifndef PIPE_GENERATION
 
  60 #if defined(__ISP) || defined(MK_FIRMWARE)
 
  62 /* Array cannot be 2-dimensional, since driver ddr allocation does not know stride */
 
  63 struct sh_css_isp_sdis_hori_proj_tbl {
 
  64         s32 tbl[ISP_DVS_NUM_COEF_TYPES * ISP_MAX_SDIS_HOR_PROJ_NUM_ISP];
 
  65 #if DVS2_PROJ_MARGIN > 0
 
  66         s32 margin[DVS2_PROJ_MARGIN];
 
  70 struct sh_css_isp_sdis_vert_proj_tbl {
 
  71         s32 tbl[ISP_DVS_NUM_COEF_TYPES * ISP_MAX_SDIS_VER_PROJ_NUM_ISP];
 
  72 #if DVS2_PROJ_MARGIN > 0
 
  73         s32 margin[DVS2_PROJ_MARGIN];
 
  77 struct sh_css_isp_sdis_hori_coef_tbl {
 
  78         VMEM_ARRAY(tbl[ISP_DVS_NUM_COEF_TYPES],
 
  79                    ISP_MAX_SDIS_HOR_COEF_NUM_VECS *ISP_NWAY);
 
  82 struct sh_css_isp_sdis_vert_coef_tbl {
 
  83         VMEM_ARRAY(tbl[ISP_DVS_NUM_COEF_TYPES],
 
  84                    ISP_MAX_SDIS_VER_COEF_NUM_VECS *ISP_NWAY);
 
  87 #endif /* defined(__ISP) || defined (MK_FIRMWARE) */
 
  88 #endif /* PIPE_GENERATION */
 
  90 #ifndef PIPE_GENERATION
 
  91 struct s_sdis_config {
 
  92         unsigned int horicoef_vectors;
 
  93         unsigned int vertcoef_vectors;
 
  94         unsigned int horiproj_num;
 
  95         unsigned int vertproj_num;
 
  98 extern struct s_sdis_config sdis_config;
 
 101 #endif /* _IA_CSS_SDIS_COMMON_HOST_H */