4eb4910798fab27f596d1a17511ab0df5d4f99a9
[openwrt/staging/blogic.git] /
1 /*
2 * Support for Intel Camera Imaging ISP subsystem.
3 * Copyright (c) 2015, Intel Corporation.
4 *
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.
8 *
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
12 * more details.
13 */
14
15 #ifndef _IA_CSS_SDIS_COMMON_HOST_H
16 #define _IA_CSS_SDIS_COMMON_HOST_H
17
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)
24
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)
31
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))
37
38 /* SDIS Projections:
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, \
46 isp_pipe_version) \
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))
50
51 #define __ISP_SDIS_VER_PROJ_NUM_ISP(in_width, deci_factor_log2) \
52 CEIL_SHIFT(_ISP_BQS(in_width), deci_factor_log2)
53
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)
58
59 #ifndef PIPE_GENERATION
60 #if defined(__ISP) || defined (MK_FIRMWARE)
61
62 /* Array cannot be 2-dimensional, since driver ddr allocation does not know stride */
63 struct sh_css_isp_sdis_hori_proj_tbl {
64 int32_t tbl[ISP_DVS_NUM_COEF_TYPES * ISP_MAX_SDIS_HOR_PROJ_NUM_ISP];
65 #if DVS2_PROJ_MARGIN > 0
66 int32_t margin[DVS2_PROJ_MARGIN];
67 #endif
68 };
69
70 struct sh_css_isp_sdis_vert_proj_tbl {
71 int32_t tbl[ISP_DVS_NUM_COEF_TYPES * ISP_MAX_SDIS_VER_PROJ_NUM_ISP];
72 #if DVS2_PROJ_MARGIN > 0
73 int32_t margin[DVS2_PROJ_MARGIN];
74 #endif
75 };
76
77 struct sh_css_isp_sdis_hori_coef_tbl {
78 VMEM_ARRAY(tbl[ISP_DVS_NUM_COEF_TYPES], ISP_MAX_SDIS_HOR_COEF_NUM_VECS*ISP_NWAY);
79 };
80
81 struct sh_css_isp_sdis_vert_coef_tbl {
82 VMEM_ARRAY(tbl[ISP_DVS_NUM_COEF_TYPES], ISP_MAX_SDIS_VER_COEF_NUM_VECS*ISP_NWAY);
83 };
84
85 #endif /* defined(__ISP) || defined (MK_FIRMWARE) */
86 #endif /* PIPE_GENERATION */
87
88 #ifndef PIPE_GENERATION
89 struct s_sdis_config {
90 unsigned horicoef_vectors;
91 unsigned vertcoef_vectors;
92 unsigned horiproj_num;
93 unsigned vertproj_num;
94 };
95
96 extern struct s_sdis_config sdis_config;
97 #endif
98
99 #endif /* _IA_CSS_SDIS_COMMON_HOST_H */