]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - drivers/staging/media/atomisp/pci/atomisp2/css2400/isp/kernels/iefd2_6/ia_css_iefd2_6.host.c
staging/atomisp: Add support for the Intel IPU v2
[mirror_ubuntu-hirsute-kernel.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / isp / kernels / iefd2_6 / ia_css_iefd2_6.host.c
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_NO_DEBUG
16 #include "ia_css_debug.h"
17 #endif
18 #include "ia_css_iefd2_6.host.h"
19
20 /* Copy parameters to VMEM
21 */
22 void
23 ia_css_iefd2_6_vmem_encode(
24 struct iefd2_6_vmem_params *to,
25 const struct ia_css_iefd2_6_config *from,
26 size_t size)
27 {
28 const unsigned total_blocks = 4;
29 const unsigned shuffle_block = 16;
30 unsigned i, j, base;
31 (void)size;
32
33 /* For configurable units parameters are copied to vmem. Per CU 3 arrays are copied:
34 * x containing the x coordinates
35 * a containing the slopes
36 * b containing the intercept values.
37 *
38 * A 64 element vector is split up in 4 blocks of 16 element. Each array is copied to
39 * a vector 4 times, (starting at 0, 16, 32 and 48). All array elements are copied or
40 * initialised as described in the KFS. The remaining elements of a vector are set to 0.
41 */
42 /* first init the vectors */
43 for(i = 0; i < total_blocks*shuffle_block; i++) {
44 to->e_cued_x[0][i] = 0;
45 to->e_cued_a[0][i] = 0;
46 to->e_cued_b[0][i] = 0;
47
48 to->e_cu_dir_x[0][i] = 0;
49 to->e_cu_dir_a[0][i] = 0;
50 to->e_cu_dir_b[0][i] = 0;
51
52 to->e_cu_non_dir_x[0][i] = 0;
53 to->e_cu_non_dir_a[0][i] = 0;
54 to->e_cu_non_dir_b[0][i] = 0;
55
56 to->e_curad_x[0][i] = 0;
57 to->e_curad_a[0][i] = 0;
58 to->e_curad_b[0][i] = 0;
59 }
60
61 /* Copy all data */
62 for(i = 0; i < total_blocks; i++) {
63 base = shuffle_block*i;
64
65
66 to->e_cued_x[0][base] = 0;
67 to->e_cued_a[0][base] = 0;
68 to->e_cued_b[0][base] = from->cu_ed_slopes_b[0];
69
70 to->e_cu_dir_x[0][base] = 0;
71 to->e_cu_dir_a[0][base] = 0;
72 to->e_cu_dir_b[0][base] = from->cu_dir_sharp_slopes_b[0];
73
74 to->e_cu_non_dir_x[0][base] = 0;
75 to->e_cu_non_dir_a[0][base] = 0;
76 to->e_cu_non_dir_b[0][base] = from->cu_non_dir_sharp_slopes_b[0];
77
78 to->e_curad_x[0][base] = 0;
79 to->e_curad_a[0][base] = 0;
80 to->e_curad_b[0][base] = from->cu_radial_slopes_b[0];
81
82 for (j = 1; j < 4; j++) {
83 to->e_cu_dir_a[0][base+j] = from->cu_dir_sharp_slopes_a[j-1];
84 to->e_cu_dir_b[0][base+j] = from->cu_dir_sharp_slopes_b[j-1];
85 to->e_cu_non_dir_a[0][base+j] = from->cu_non_dir_sharp_slopes_a[j-1];
86 to->e_cu_non_dir_b[0][base+j] = from->cu_non_dir_sharp_slopes_b[j-1];
87 }
88
89 for (j = 1; j < 5; j++) {
90 to->e_cu_dir_x[0][base+j] = from->cu_dir_sharp_points_x[j-1];
91 to->e_cu_non_dir_x[0][base+j] = from->cu_non_dir_sharp_points_x[j-1];
92 }
93
94
95 for (j = 1; j < 6; j++) {
96 to->e_cued_x[0][base+j] = from->cu_ed_points_x[j-1];
97 to->e_cued_a[0][base+j] = from->cu_ed_slopes_a[j-1];
98 to->e_cued_b[0][base+j] = from->cu_ed_slopes_b[j-1];
99 }
100 to->e_cued_x[0][base+6] = from->cu_ed_points_x[5];
101
102 for (j = 1; j < 6; j++) {
103 to->e_curad_x[0][base+j] = from->cu_radial_points_x[j-1];
104 to->e_curad_a[0][base+j] = from->cu_radial_slopes_a[j-1];
105 to->e_curad_b[0][base+j] = from->cu_radial_slopes_b[j-1];
106 }
107 to->e_curad_x[0][base+6] = from->cu_radial_points_x[5];
108
109 /* Init asrrnd_lut */
110 to->asrrnd_lut[0][base] = 8192;
111 to->asrrnd_lut[0][base+1] = 4096;
112 to->asrrnd_lut[0][base+2] = 2048;
113 to->asrrnd_lut[0][base+3] = 1024;
114 to->asrrnd_lut[0][base+4] = 512;
115 to->asrrnd_lut[0][base+5] = 256;
116 to->asrrnd_lut[0][base+6] = 128;
117 to->asrrnd_lut[0][base+7] = 64;
118 to->asrrnd_lut[0][base+8] = 32;
119 }
120
121 }
122
123 void
124 ia_css_iefd2_6_encode(
125 struct iefd2_6_dmem_params *to,
126 const struct ia_css_iefd2_6_config *from,
127 size_t size)
128 {
129 (void)size;
130
131 /* Copy parameters to dmem, as described in the KFS
132 */
133 to->horver_diag_coeff = from->horver_diag_coeff;
134 to->ed_horver_diag_coeff = from->ed_horver_diag_coeff;
135 to->dir_smooth_enable = from->dir_smooth_enable;
136 to->dir_metric_update = from->dir_metric_update;
137 to->unsharp_c00 = from->unsharp_c00;
138 to->unsharp_c01 = from->unsharp_c01;
139 to->unsharp_c02 = from->unsharp_c02;
140 to->unsharp_c11 = from->unsharp_c11;
141 to->unsharp_c12 = from->unsharp_c12;
142 to->unsharp_c22 = from->unsharp_c22;
143 to->unsharp_weight = from->unsharp_weight;
144 to->unsharp_amount = from->unsharp_amount;
145 to->cu_dir_sharp_pow = from->cu_dir_sharp_pow;
146 to->cu_dir_sharp_pow_bright = from->cu_dir_sharp_pow_bright;
147 to->cu_non_dir_sharp_pow = from->cu_non_dir_sharp_pow;
148 to->cu_non_dir_sharp_pow_bright = from->cu_non_dir_sharp_pow_bright;
149 to->dir_far_sharp_weight = from->dir_far_sharp_weight;
150 to->rad_cu_dir_sharp_x1 = from->rad_cu_dir_sharp_x1;
151 to->rad_cu_non_dir_sharp_x1 = from->rad_cu_non_dir_sharp_x1;
152 to->rad_dir_far_sharp_weight = from->rad_dir_far_sharp_weight;
153 to->sharp_nega_lmt_txt = from->sharp_nega_lmt_txt;
154 to->sharp_posi_lmt_txt = from->sharp_posi_lmt_txt;
155 to->sharp_nega_lmt_dir = from->sharp_nega_lmt_dir;
156 to->sharp_posi_lmt_dir = from->sharp_posi_lmt_dir;
157 to->clamp_stitch = from->clamp_stitch;
158 to->rad_enable = from->rad_enable;
159 to->rad_x_origin = from->rad_x_origin;
160 to->rad_y_origin = from->rad_y_origin;
161 to->rad_nf = from->rad_nf;
162 to->rad_inv_r2 = from->rad_inv_r2;
163 to->vssnlm_enable = from->vssnlm_enable;
164 to->vssnlm_x0 = from->vssnlm_x0;
165 to->vssnlm_x1 = from->vssnlm_x1;
166 to->vssnlm_x2 = from->vssnlm_x2;
167 to->vssnlm_y1 = from->vssnlm_y1;
168 to->vssnlm_y2 = from->vssnlm_y2;
169 to->vssnlm_y3 = from->vssnlm_y3;
170
171 /* Setup for configurable units */
172 to->e_cued2_a = from->cu_ed2_slopes_a;
173 to->e_cu_vssnlm_a = from->cu_vssnlm_slopes_a;
174 to->e_cued2_x1 = from->cu_ed2_points_x[0];
175 to->e_cued2_x_diff = from->cu_ed2_points_x[1] - from->cu_ed2_points_x[0];
176 to->e_cu_vssnlm_x1 = from->cu_vssnlm_points_x[0];
177 to->e_cu_vssnlm_x_diff = from->cu_vssnlm_points_x[1] - from->cu_vssnlm_points_x[0];
178 }
179
180 /* TODO: AM: This needs a proper implementation. */
181 void
182 ia_css_init_iefd2_6_state(
183 void *state,
184 size_t size)
185 {
186 (void)state;
187 (void)size;
188 }
189
190 #ifndef IA_CSS_NO_DEBUG
191 /* TODO: AM: This needs a proper implementation. */
192 void
193 ia_css_iefd2_6_debug_dtrace(
194 const struct ia_css_iefd2_6_config *config,
195 unsigned level)
196 {
197 (void)config;
198 (void)level;
199 }
200 #endif