xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/amd/display/dc/dcn20/amdgpu_dcn20_dwb_scl.c (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: amdgpu_dcn20_dwb_scl.c,v 1.2 2021/12/18 23:45:03 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2012-17 Advanced Micro Devices, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * Authors: AMD
25  *
26  */
27 
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: amdgpu_dcn20_dwb_scl.c,v 1.2 2021/12/18 23:45:03 riastradh Exp $");
30 
31 #include "reg_helper.h"
32 #include "fixed31_32.h"
33 #include "resource.h"
34 #include "dwb.h"
35 #include "dcn20_dwb.h"
36 
37 #define NUM_PHASES    16
38 #define HORZ_MAX_TAPS 12
39 #define VERT_MAX_TAPS 12
40 
41 #define REG(reg)\
42 	dwbc20->dwbc_regs->reg
43 
44 #define CTX \
45 	dwbc20->base.ctx
46 
47 #undef FN
48 #define FN(reg_name, field_name) \
49 	dwbc20->dwbc_shift->field_name, dwbc20->dwbc_mask->field_name
50 
51 #define TO_DCN20_DWBC(dwbc_base) \
52 	container_of(dwbc_base, struct dcn20_dwbc, base)
53 
54 
55 static const uint16_t filter_3tap_16p_upscale[27] = {
56 	2048, 2048, 0,
57 	1708, 2424, 16348,
58 	1372, 2796, 16308,
59 	1056, 3148, 16272,
60 	768, 3464, 16244,
61 	512, 3728, 16236,
62 	296, 3928, 16252,
63 	124, 4052, 16296,
64 	0, 4096, 0
65 };
66 
67 static const uint16_t filter_3tap_16p_117[27] = {
68 	2048, 2048, 0,
69 	1824, 2276, 16376,
70 	1600, 2496, 16380,
71 	1376, 2700, 16,
72 	1156, 2880, 52,
73 	948, 3032, 108,
74 	756, 3144, 192,
75 	580, 3212, 296,
76 	428, 3236, 428
77 };
78 
79 static const uint16_t filter_3tap_16p_150[27] = {
80 	2048, 2048, 0,
81 	1872, 2184, 36,
82 	1692, 2308, 88,
83 	1516, 2420, 156,
84 	1340, 2516, 236,
85 	1168, 2592, 328,
86 	1004, 2648, 440,
87 	844, 2684, 560,
88 	696, 2696, 696
89 };
90 
91 static const uint16_t filter_3tap_16p_183[27] = {
92 	2048, 2048, 0,
93 	1892, 2104, 92,
94 	1744, 2152, 196,
95 	1592, 2196, 300,
96 	1448, 2232, 412,
97 	1304, 2256, 528,
98 	1168, 2276, 648,
99 	1032, 2288, 772,
100 	900, 2292, 900
101 };
102 
103 static const uint16_t filter_4tap_16p_upscale[36] = {
104 	0, 4096, 0, 0,
105 	16240, 4056, 180, 16380,
106 	16136, 3952, 404, 16364,
107 	16072, 3780, 664, 16344,
108 	16040, 3556, 952, 16312,
109 	16036, 3284, 1268, 16272,
110 	16052, 2980, 1604, 16224,
111 	16084, 2648, 1952, 16176,
112 	16128, 2304, 2304, 16128
113 };
114 
115 static const uint16_t filter_4tap_16p_117[36] = {
116 	428, 3236, 428, 0,
117 	276, 3232, 604, 16364,
118 	148, 3184, 800, 16340,
119 	44, 3104, 1016, 16312,
120 	16344, 2984, 1244, 16284,
121 	16284, 2832, 1488, 16256,
122 	16244, 2648, 1732, 16236,
123 	16220, 2440, 1976, 16220,
124 	16212, 2216, 2216, 16212
125 };
126 
127 static const uint16_t filter_4tap_16p_150[36] = {
128 	696, 2700, 696, 0,
129 	560, 2700, 848, 16364,
130 	436, 2676, 1008, 16348,
131 	328, 2628, 1180, 16336,
132 	232, 2556, 1356, 16328,
133 	152, 2460, 1536, 16328,
134 	84, 2344, 1716, 16332,
135 	28, 2208, 1888, 16348,
136 	16376, 2052, 2052, 16376
137 };
138 
139 static const uint16_t filter_4tap_16p_183[36] = {
140 	940, 2208, 940, 0,
141 	832, 2200, 1052, 4,
142 	728, 2180, 1164, 16,
143 	628, 2148, 1280, 36,
144 	536, 2100, 1392, 60,
145 	448, 2044, 1504, 92,
146 	368, 1976, 1612, 132,
147 	296, 1900, 1716, 176,
148 	232, 1812, 1812, 232
149 };
150 
151 static const uint16_t filter_5tap_16p_upscale[45] = {
152 	15936, 2496, 2496, 15936, 0,
153 	15992, 2128, 2832, 15896, 12,
154 	16056, 1760, 3140, 15876, 24,
155 	16120, 1404, 3420, 15876, 36,
156 	16188, 1060, 3652, 15908, 44,
157 	16248, 744, 3844, 15972, 44,
158 	16304, 460, 3980, 16072, 40,
159 	16348, 212, 4064, 16208, 24,
160 	0, 0, 4096, 0, 0,
161 };
162 
163 static const uint16_t filter_5tap_16p_117[45] = {
164 	16056, 2372, 2372, 16056, 0,
165 	16052, 2124, 2600, 16076, 0,
166 	16060, 1868, 2808, 16120, 0,
167 	16080, 1612, 2992, 16180, 16376,
168 	16112, 1356, 3144, 16268, 16364,
169 	16144, 1108, 3268, 16376, 16344,
170 	16184, 872, 3356, 124, 16320,
171 	16220, 656, 3412, 276, 16292,
172 	16256, 456, 3428, 456, 16256,
173 };
174 
175 static const uint16_t filter_5tap_16p_150[45] = {
176 	16368, 2064, 2064, 16368, 0,
177 	16316, 1924, 2204, 44, 16372,
178 	16280, 1772, 2328, 116, 16356,
179 	16256, 1616, 2440, 204, 16340,
180 	16240, 1456, 2536, 304, 16320,
181 	16232, 1296, 2612, 416, 16300,
182 	16232, 1132, 2664, 544, 16284,
183 	16240, 976, 2700, 680, 16264,
184 	16248, 824, 2708, 824, 16248,
185 };
186 
187 static const uint16_t filter_5tap_16p_183[45] = {
188 	228, 1816, 1816, 228, 0,
189 	168, 1728, 1904, 300, 16372,
190 	116, 1632, 1988, 376, 16360,
191 	72, 1528, 2060, 460, 16348,
192 	36, 1424, 2120, 552, 16340,
193 	4, 1312, 2168, 652, 16336,
194 	16368, 1200, 2204, 752, 16332,
195 	16352, 1084, 2224, 860, 16332,
196 	16340, 972, 2232, 972, 16340,
197 };
198 
199 static const uint16_t filter_6tap_16p_upscale[54] = {
200 	0, 0, 4092, 0, 0, 0,
201 	44, 16188, 4064, 228, 16324, 0,
202 	80, 16036, 3980, 492, 16256, 4,
203 	108, 15916, 3844, 788, 16184, 16,
204 	120, 15836, 3656, 1108, 16104, 28,
205 	128, 15792, 3420, 1448, 16024, 44,
206 	124, 15776, 3144, 1800, 15948, 64,
207 	112, 15792, 2836, 2152, 15880, 80,
208 	100, 15828, 2504, 2504, 15828, 100,
209 };
210 
211 static const uint16_t filter_6tap_16p_117[54] = {
212 	16168, 476, 3568, 476, 16168, 0,
213 	16216, 280, 3540, 692, 16116, 8,
214 	16264, 104, 3472, 924, 16068, 16,
215 	16304, 16340, 3372, 1168, 16024, 28,
216 	16344, 16212, 3236, 1424, 15988, 36,
217 	16372, 16112, 3072, 1680, 15956, 44,
218 	12, 16036, 2880, 1936, 15940, 48,
219 	28, 15984, 2668, 2192, 15936, 48,
220 	40, 15952, 2436, 2436, 15952, 40,
221 };
222 
223 static const uint16_t filter_6tap_16p_150[54] = {
224 	16148, 920, 2724, 920, 16148, 0,
225 	16156, 768, 2712, 1072, 16144, 0,
226 	16172, 628, 2684, 1232, 16148, 16380,
227 	16192, 492, 2632, 1388, 16160, 16372,
228 	16212, 368, 2564, 1548, 16180, 16364,
229 	16232, 256, 2480, 1704, 16212, 16352,
230 	16256, 156, 2380, 1856, 16256, 16336,
231 	16276, 64, 2268, 2004, 16308, 16320,
232 	16300, 16372, 2140, 2140, 16372, 16300,
233 };
234 
235 static const uint16_t filter_6tap_16p_183[54] = {
236 	16296, 1032, 2196, 1032, 16296, 0,
237 	16284, 924, 2196, 1144, 16320, 16376,
238 	16272, 820, 2180, 1256, 16348, 16364,
239 	16268, 716, 2156, 1364, 16380, 16352,
240 	16264, 620, 2116, 1472, 36, 16340,
241 	16268, 524, 2068, 1576, 88, 16328,
242 	16272, 436, 2008, 1680, 144, 16316,
243 	16280, 352, 1940, 1772, 204, 16304,
244 	16292, 276, 1860, 1860, 276, 16292,
245 };
246 
247 static const uint16_t filter_7tap_16p_upscale[63] = {
248 	176, 15760, 2488, 2488, 15760, 176, 0,
249 	160, 15812, 2152, 2816, 15728, 192, 16376,
250 	136, 15884, 1812, 3124, 15720, 196, 16368,
251 	108, 15964, 1468, 3400, 15740, 196, 16364,
252 	84, 16048, 1132, 3640, 15792, 180, 16360,
253 	56, 16140, 812, 3832, 15884, 152, 16360,
254 	32, 16228, 512, 3976, 16012, 116, 16364,
255 	12, 16308, 240, 4064, 16180, 60, 16372,
256 	0, 0, 0, 4096, 0, 0, 0,
257 };
258 
259 static const uint16_t filter_7tap_16p_117[63] = {
260 	92, 15868, 2464, 2464, 15868, 92, 0,
261 	108, 15852, 2216, 2700, 15904, 72, 0,
262 	112, 15856, 1960, 2916, 15964, 44, 0,
263 	116, 15876, 1696, 3108, 16048, 8, 8,
264 	112, 15908, 1428, 3268, 16156, 16348, 12,
265 	104, 15952, 1168, 3400, 16288, 16300, 24,
266 	92, 16004, 916, 3496, 64, 16244, 36,
267 	80, 16064, 676, 3556, 248, 16184, 48,
268 	64, 16124, 452, 3576, 452, 16124, 64,
269 };
270 
271 static const uint16_t filter_7tap_16p_150[63] = {
272 	16224, 16380, 2208, 2208, 16380, 16224, 0,
273 	16252, 16304, 2072, 2324, 84, 16196, 4,
274 	16276, 16240, 1924, 2432, 184, 16172, 8,
275 	16300, 16184, 1772, 2524, 296, 16144, 12,
276 	16324, 16144, 1616, 2600, 416, 16124, 12,
277 	16344, 16112, 1456, 2660, 548, 16104, 12,
278 	16360, 16092, 1296, 2704, 688, 16088, 12,
279 	16372, 16080, 1140, 2732, 832, 16080, 8,
280 	0, 16076, 984, 2740, 984, 16076, 0,
281 };
282 
283 static const uint16_t filter_7tap_16p_183[63] = {
284 	16216, 324, 1884, 1884, 324, 16216, 0,
285 	16228, 248, 1804, 1960, 408, 16212, 16380,
286 	16240, 176, 1716, 2028, 496, 16208, 16376,
287 	16252, 112, 1624, 2084, 588, 16208, 16372,
288 	16264, 56, 1524, 2132, 684, 16212, 16364,
289 	16280, 4, 1424, 2168, 788, 16220, 16356,
290 	16292, 16344, 1320, 2196, 892, 16232, 16344,
291 	16308, 16308, 1212, 2212, 996, 16252, 16332,
292 	16320, 16276, 1104, 2216, 1104, 16276, 16320,
293 };
294 
295 static const uint16_t filter_8tap_16p_upscale[72] = {
296 	0, 0, 0, 4096, 0, 0, 0, 0,
297 	16360, 76, 16172, 4064, 244, 16296, 24, 16380,
298 	16340, 136, 15996, 3980, 524, 16204, 56, 16380,
299 	16328, 188, 15860, 3844, 828, 16104, 92, 16372,
300 	16320, 224, 15760, 3656, 1156, 16008, 128, 16368,
301 	16320, 248, 15696, 3428, 1496, 15912, 160, 16360,
302 	16320, 256, 15668, 3156, 1844, 15828, 192, 16348,
303 	16324, 256, 15672, 2856, 2192, 15756, 220, 16340,
304 	16332, 244, 15704, 2532, 2532, 15704, 244, 16332,
305 };
306 
307 static const uint16_t filter_8tap_16p_117[72] = {
308 	116, 16100, 428, 3564, 428, 16100, 116, 0,
309 	96, 16168, 220, 3548, 656, 16032, 136, 16376,
310 	76, 16236, 32, 3496, 904, 15968, 152, 16372,
311 	56, 16300, 16252, 3408, 1164, 15908, 164, 16368,
312 	36, 16360, 16116, 3284, 1428, 15856, 172, 16364,
313 	20, 28, 16000, 3124, 1700, 15820, 176, 16364,
314 	4, 76, 15912, 2940, 1972, 15800, 172, 16364,
315 	16380, 112, 15848, 2724, 2236, 15792, 160, 16364,
316 	16372, 140, 15812, 2488, 2488, 15812, 140, 16372,
317 };
318 
319 static const uint16_t filter_8tap_16p_150[72] = {
320 	16380, 16020, 1032, 2756, 1032, 16020, 16380, 0,
321 	12, 16020, 876, 2744, 1184, 16032, 16364, 4,
322 	24, 16028, 728, 2716, 1344, 16052, 16340, 8,
323 	36, 16040, 584, 2668, 1500, 16080, 16316, 16,
324 	40, 16060, 448, 2608, 1652, 16120, 16288, 20,
325 	44, 16080, 320, 2528, 1804, 16168, 16260, 28,
326 	48, 16108, 204, 2436, 1948, 16232, 16228, 32,
327 	44, 16136, 100, 2328, 2084, 16304, 16200, 40,
328 	44, 16168, 4, 2212, 2212, 4, 16168, 44,
329 };
330 
331 static const uint16_t filter_8tap_16p_183[72] = {
332 	16264, 16264, 1164, 2244, 1164, 16264, 16264, 0,
333 	16280, 16232, 1056, 2236, 1268, 16300, 16248, 0,
334 	16296, 16204, 948, 2220, 1372, 16348, 16232, 0,
335 	16312, 16184, 844, 2192, 1472, 12, 16216, 4,
336 	16328, 16172, 740, 2156, 1572, 72, 16200, 0,
337 	16340, 16160, 640, 2108, 1668, 136, 16188, 0,
338 	16352, 16156, 544, 2052, 1756, 204, 16176, 16380,
339 	16360, 16156, 452, 1988, 1840, 280, 16164, 16376,
340 	16368, 16160, 364, 1920, 1920, 364, 16160, 16368,
341 };
342 
343 static const uint16_t filter_9tap_16p_upscale[81] = {
344 	16284, 296, 15660, 2572, 2572, 15660, 296, 16284, 0,
345 	16296, 272, 15712, 2228, 2896, 15632, 304, 16276, 4,
346 	16308, 240, 15788, 1876, 3192, 15632, 304, 16276, 4,
347 	16320, 204, 15876, 1520, 3452, 15664, 288, 16280, 8,
348 	16336, 164, 15976, 1176, 3676, 15732, 260, 16288, 12,
349 	16348, 120, 16080, 844, 3856, 15840, 216, 16300, 12,
350 	16364, 76, 16188, 532, 3988, 15984, 156, 16324, 8,
351 	16376, 36, 16288, 252, 4068, 16164, 84, 16352, 4,
352 	0, 0, 0, 0, 4096, 0, 0, 0, 0,
353 };
354 
355 static const uint16_t filter_9tap_16p_117[81] = {
356 	16356, 172, 15776, 2504, 2504, 15776, 172, 16356, 0,
357 	16344, 200, 15756, 2252, 2740, 15816, 136, 16372, 16380,
358 	16336, 216, 15756, 1988, 2956, 15884, 92, 8, 16380,
359 	16332, 224, 15780, 1720, 3144, 15976, 40, 28, 16376,
360 	16328, 224, 15816, 1448, 3304, 16096, 16364, 52, 16372,
361 	16328, 216, 15868, 1180, 3432, 16240, 16296, 80, 16364,
362 	16332, 200, 15928, 916, 3524, 24, 16224, 108, 16356,
363 	16336, 184, 15996, 668, 3580, 220, 16148, 132, 16352,
364 	16344, 160, 16072, 436, 3600, 436, 16072, 160, 16344,
365 };
366 
367 static const uint16_t filter_9tap_16p_150[81] = {
368 	84, 16128, 0, 2216, 2216, 0, 16128, 84, 0,
369 	80, 16160, 16296, 2088, 2332, 100, 16092, 84, 0,
370 	76, 16196, 16220, 1956, 2432, 208, 16064, 80, 0,
371 	72, 16232, 16152, 1812, 2524, 328, 16036, 76, 4,
372 	64, 16264, 16096, 1664, 2600, 460, 16012, 64, 8,
373 	56, 16300, 16052, 1508, 2656, 596, 15996, 52, 12,
374 	48, 16328, 16020, 1356, 2700, 740, 15984, 36, 20,
375 	40, 16356, 15996, 1196, 2728, 888, 15980, 20, 24,
376 	32, 0, 15984, 1044, 2736, 1044, 15984, 0, 32,
377 };
378 
379 static const uint16_t filter_9tap_16p_183[81] = {
380 	16356, 16112, 388, 1952, 1952, 388, 16112, 16356, 0,
381 	16368, 16116, 304, 1876, 2020, 480, 16112, 16344, 4,
382 	16376, 16124, 224, 1792, 2080, 576, 16116, 16328, 8,
383 	0, 16136, 148, 1700, 2132, 672, 16124, 16312, 8,
384 	8, 16148, 80, 1604, 2176, 772, 16140, 16296, 12,
385 	12, 16164, 16, 1504, 2208, 876, 16156, 16276, 16,
386 	16, 16180, 16344, 1404, 2232, 980, 16184, 16256, 20,
387 	20, 16200, 16296, 1300, 2244, 1088, 16212, 16240, 20,
388 	20, 16220, 16252, 1196, 2252, 1196, 16252, 16220, 20,
389 };
390 
391 static const uint16_t filter_10tap_16p_upscale[90] = {
392 	0, 0, 0, 0, 4096, 0, 0, 0, 0, 0,
393 	12, 16344, 88, 16160, 4068, 252, 16280, 44, 16368, 0,
394 	24, 16308, 168, 15976, 3988, 540, 16176, 92, 16348, 0,
395 	32, 16280, 236, 15828, 3852, 852, 16064, 140, 16328, 4,
396 	36, 16260, 284, 15720, 3672, 1184, 15956, 188, 16308, 8,
397 	36, 16244, 320, 15648, 3448, 1528, 15852, 236, 16288, 12,
398 	36, 16240, 336, 15612, 3184, 1880, 15764, 276, 16272, 20,
399 	32, 16240, 340, 15608, 2888, 2228, 15688, 308, 16256, 24,
400 	28, 16244, 332, 15636, 2568, 2568, 15636, 332, 16244, 28,
401 };
402 
403 static const uint16_t filter_10tap_16p_117[90] = {
404 	16308, 196, 16048, 440, 3636, 440, 16048, 196, 16308, 0,
405 	16316, 164, 16132, 220, 3612, 676, 15972, 220, 16300, 0,
406 	16324, 132, 16212, 20, 3552, 932, 15900, 240, 16296, 4,
407 	16336, 100, 16292, 16232, 3456, 1192, 15836, 256, 16296, 4,
408 	16348, 68, 16364, 16084, 3324, 1464, 15784, 264, 16296, 8,
409 	16356, 36, 48, 15960, 3164, 1736, 15748, 260, 16304, 4,
410 	16364, 8, 108, 15864, 2972, 2008, 15728, 252, 16312, 4,
411 	16372, 16368, 160, 15792, 2756, 2268, 15724, 228, 16328, 0,
412 	16380, 16344, 200, 15748, 2520, 2520, 15748, 200, 16344, 16380,
413 };
414 
415 static const uint16_t filter_10tap_16p_150[90] = {
416 	64, 0, 15956, 1048, 2716, 1048, 15956, 0, 64, 0,
417 	52, 24, 15952, 896, 2708, 1204, 15972, 16356, 72, 16380,
418 	44, 48, 15952, 748, 2684, 1360, 16000, 16320, 84, 16380,
419 	32, 68, 15964, 604, 2644, 1516, 16032, 16288, 92, 16376,
420 	24, 88, 15980, 464, 2588, 1668, 16080, 16248, 100, 16376,
421 	16, 100, 16004, 332, 2516, 1816, 16140, 16212, 108, 16376,
422 	8, 108, 16032, 212, 2428, 1956, 16208, 16172, 112, 16376,
423 	4, 116, 16060, 100, 2328, 2092, 16288, 16132, 116, 16380,
424 	0, 116, 16096, 16380, 2216, 2216, 16380, 16096, 116, 0,
425 };
426 
427 static const uint16_t filter_10tap_16p_183[90] = {
428 	40, 16180, 16240, 1216, 2256, 1216, 16240, 16180, 40, 0,
429 	44, 16204, 16200, 1112, 2252, 1320, 16288, 16160, 36, 0,
430 	44, 16224, 16168, 1004, 2236, 1424, 16344, 16144, 28, 4,
431 	44, 16248, 16136, 900, 2208, 1524, 16, 16124, 24, 8,
432 	44, 16268, 16116, 796, 2176, 1620, 84, 16108, 12, 12,
433 	40, 16288, 16100, 692, 2132, 1712, 156, 16096, 4, 16,
434 	36, 16308, 16088, 592, 2080, 1796, 232, 16088, 16376, 20,
435 	32, 16328, 16080, 496, 2020, 1876, 316, 16080, 16360, 24,
436 	28, 16344, 16080, 404, 1952, 1952, 404, 16080, 16344, 28,
437 };
438 
439 static const uint16_t filter_11tap_16p_upscale[99] = {
440 	60, 16216, 356, 15620, 2556, 2556, 15620, 356, 16216, 60, 0,
441 	52, 16224, 336, 15672, 2224, 2876, 15592, 368, 16208, 64, 16380,
442 	44, 16244, 304, 15744, 1876, 3176, 15596, 364, 16212, 64, 16376,
443 	36, 16264, 260, 15836, 1532, 3440, 15636, 340, 16220, 60, 16376,
444 	28, 16288, 212, 15940, 1188, 3668, 15708, 304, 16236, 56, 16376,
445 	20, 16312, 160, 16052, 856, 3848, 15820, 248, 16264, 48, 16376,
446 	12, 16336, 104, 16164, 544, 3984, 15968, 180, 16296, 36, 16376,
447 	4, 16360, 48, 16276, 256, 4068, 16160, 96, 16336, 16, 16380,
448 	0, 0, 0, 0, 0, 4096, 0, 0, 0, 0, 0,
449 };
450 
451 static const uint16_t filter_11tap_16p_117[99] = {
452 	16380, 16332, 220, 15728, 2536, 2536, 15728, 220, 16332, 16380, 0,
453 	4, 16308, 256, 15704, 2280, 2768, 15772, 176, 16360, 16368, 0,
454 	12, 16292, 280, 15704, 2016, 2984, 15848, 120, 8, 16356, 0,
455 	20, 16276, 292, 15724, 1744, 3172, 15948, 56, 40, 16340, 4,
456 	24, 16268, 292, 15760, 1468, 3328, 16072, 16368, 80, 16324, 8,
457 	24, 16264, 288, 15816, 1196, 3456, 16224, 16288, 116, 16312, 12,
458 	24, 16264, 272, 15880, 932, 3548, 16, 16208, 152, 16296, 16,
459 	24, 16268, 248, 15956, 676, 3604, 216, 16120, 188, 16284, 20,
460 	24, 16276, 220, 16036, 436, 3624, 436, 16036, 220, 16276, 24,
461 };
462 
463 static const uint16_t filter_11tap_16p_150[99] = {
464 	0, 144, 16072, 0, 2212, 2212, 0, 16072, 144, 0, 0,
465 	16376, 144, 16112, 16288, 2092, 2324, 104, 16036, 140, 8, 16380,
466 	16368, 144, 16152, 16204, 1960, 2424, 216, 16004, 132, 16, 16376,
467 	16364, 140, 16192, 16132, 1820, 2512, 340, 15976, 116, 28, 16376,
468 	16364, 132, 16232, 16072, 1676, 2584, 476, 15952, 100, 40, 16372,
469 	16360, 124, 16272, 16020, 1528, 2644, 612, 15936, 80, 52, 16368,
470 	16360, 116, 16312, 15980, 1372, 2684, 760, 15928, 56, 64, 16364,
471 	16360, 104, 16348, 15952, 1216, 2712, 908, 15928, 28, 76, 16364,
472 	16360, 92, 0, 15936, 1064, 2720, 1064, 15936, 0, 92, 16360,
473 };
474 
475 static const uint16_t filter_11tap_16p_183[99] = {
476 	60, 16336, 16052, 412, 1948, 1948, 412, 16052, 16336, 60, 0,
477 	56, 16356, 16052, 324, 1876, 2016, 504, 16056, 16316, 64, 0,
478 	48, 16372, 16060, 240, 1796, 2072, 604, 16064, 16292, 64, 0,
479 	44, 4, 16068, 160, 1712, 2124, 700, 16080, 16272, 68, 0,
480 	40, 20, 16080, 84, 1620, 2164, 804, 16096, 16248, 68, 4,
481 	32, 32, 16096, 16, 1524, 2200, 908, 16124, 16224, 68, 4,
482 	28, 40, 16112, 16340, 1428, 2220, 1012, 16152, 16200, 64, 8,
483 	24, 52, 16132, 16284, 1328, 2236, 1120, 16192, 16176, 64, 12,
484 	16, 56, 16156, 16236, 1224, 2240, 1224, 16236, 16156, 56, 16,
485 };
486 
487 static const uint16_t filter_12tap_16p_upscale[108] = {
488 	0, 0, 0, 0, 0, 4096, 0, 0, 0, 0, 0, 0,
489 	16376, 24, 16332, 100, 16156, 4068, 260, 16272, 56, 16356, 8, 0,
490 	16368, 44, 16284, 188, 15964, 3988, 548, 16156, 112, 16328, 20, 16380,
491 	16360, 64, 16248, 260, 15812, 3856, 864, 16040, 172, 16296, 32, 16380,
492 	16360, 76, 16216, 320, 15696, 3672, 1196, 15928, 228, 16268, 44, 16376,
493 	16356, 84, 16196, 360, 15620, 3448, 1540, 15820, 280, 16240, 56, 16372,
494 	16356, 88, 16184, 384, 15580, 3188, 1888, 15728, 324, 16216, 68, 16368,
495 	16360, 88, 16180, 392, 15576, 2892, 2236, 15652, 360, 16200, 80, 16364,
496 	16360, 84, 16188, 384, 15600, 2576, 2576, 15600, 384, 16188, 84, 16360,
497 };
498 
499 static const uint16_t filter_12tap_16p_117[108] = {
500 	48, 16248, 240, 16028, 436, 3612, 436, 16028, 240, 16248, 48, 0,
501 	44, 16260, 208, 16116, 212, 3596, 676, 15944, 272, 16240, 48, 16380,
502 	40, 16276, 168, 16204, 12, 3540, 932, 15868, 296, 16240, 48, 16380,
503 	36, 16292, 128, 16288, 16220, 3452, 1196, 15800, 312, 16240, 44, 16380,
504 	28, 16308, 84, 16372, 16064, 3324, 1472, 15748, 316, 16244, 40, 16380,
505 	24, 16328, 44, 64, 15936, 3168, 1744, 15708, 312, 16256, 32, 16380,
506 	16, 16344, 8, 132, 15836, 2980, 2016, 15688, 300, 16272, 20, 0,
507 	12, 16364, 16356, 188, 15760, 2768, 2280, 15688, 272, 16296, 8, 4,
508 	8, 16380, 16324, 236, 15712, 2532, 2532, 15712, 236, 16324, 16380, 8,
509 };
510 
511 static const uint16_t filter_12tap_16p_150[108] = {
512 	16340, 116, 0, 15916, 1076, 2724, 1076, 15916, 0, 116, 16340, 0,
513 	16340, 100, 32, 15908, 920, 2716, 1232, 15936, 16344, 128, 16340, 0,
514 	16344, 84, 64, 15908, 772, 2692, 1388, 15968, 16304, 140, 16344, 16380,
515 	16344, 68, 92, 15912, 624, 2652, 1540, 16008, 16264, 152, 16344, 16380,
516 	16348, 52, 112, 15928, 484, 2592, 1688, 16060, 16220, 160, 16348, 16380,
517 	16352, 40, 132, 15952, 348, 2520, 1836, 16124, 16176, 168, 16356, 16376,
518 	16356, 24, 148, 15980, 224, 2436, 1976, 16200, 16132, 172, 16364, 16372,
519 	16360, 12, 160, 16012, 108, 2336, 2104, 16288, 16088, 172, 16372, 16368,
520 	16364, 0, 168, 16048, 0, 2228, 2228, 0, 16048, 168, 0, 16364,
521 };
522 
523 static const uint16_t filter_12tap_16p_183[108] = {
524 	36, 72, 16132, 16228, 1224, 2224, 1224, 16228, 16132, 72, 36, 0,
525 	28, 80, 16156, 16184, 1120, 2224, 1328, 16280, 16112, 64, 40, 16380,
526 	24, 84, 16180, 16144, 1016, 2208, 1428, 16340, 16092, 52, 48, 16380,
527 	16, 88, 16208, 16112, 912, 2188, 1524, 16, 16072, 36, 56, 16380,
528 	12, 92, 16232, 16084, 812, 2156, 1620, 88, 16056, 24, 64, 16380,
529 	8, 92, 16256, 16064, 708, 2116, 1708, 164, 16044, 4, 68, 16380,
530 	4, 88, 16280, 16048, 608, 2068, 1792, 244, 16036, 16372, 76, 16380,
531 	0, 88, 16308, 16036, 512, 2008, 1872, 328, 16032, 16352, 80, 16380,
532 	0, 84, 16328, 16032, 416, 1944, 1944, 416, 16032, 16328, 84, 0,
533 };
534 
wbscl_get_filter_3tap_16p(struct fixed31_32 ratio)535 const uint16_t *wbscl_get_filter_3tap_16p(struct fixed31_32 ratio)
536 {
537 	if (ratio.value < dc_fixpt_one.value)
538 		return filter_3tap_16p_upscale;
539 	else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
540 		return filter_3tap_16p_117;
541 	else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
542 		return filter_3tap_16p_150;
543 	else
544 		return filter_3tap_16p_183;
545 }
546 
wbscl_get_filter_4tap_16p(struct fixed31_32 ratio)547 const uint16_t *wbscl_get_filter_4tap_16p(struct fixed31_32 ratio)
548 {
549 	if (ratio.value < dc_fixpt_one.value)
550 		return filter_4tap_16p_upscale;
551 	else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
552 		return filter_4tap_16p_117;
553 	else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
554 		return filter_4tap_16p_150;
555 	else
556 		return filter_4tap_16p_183;
557 }
558 
wbscl_get_filter_5tap_16p(struct fixed31_32 ratio)559 static const uint16_t *wbscl_get_filter_5tap_16p(struct fixed31_32 ratio)
560 {
561 	if (ratio.value < dc_fixpt_one.value)
562 		return filter_5tap_16p_upscale;
563 	else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
564 		return filter_5tap_16p_117;
565 	else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
566 		return filter_5tap_16p_150;
567 	else
568 		return filter_5tap_16p_183;
569 }
570 
wbscl_get_filter_6tap_16p(struct fixed31_32 ratio)571 static const uint16_t *wbscl_get_filter_6tap_16p(struct fixed31_32 ratio)
572 {
573 	if (ratio.value < dc_fixpt_one.value)
574 		return filter_6tap_16p_upscale;
575 	else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
576 		return filter_6tap_16p_117;
577 	else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
578 		return filter_6tap_16p_150;
579 	else
580 		return filter_6tap_16p_183;
581 }
582 
wbscl_get_filter_7tap_16p(struct fixed31_32 ratio)583 static const uint16_t *wbscl_get_filter_7tap_16p(struct fixed31_32 ratio)
584 {
585 	if (ratio.value < dc_fixpt_one.value)
586 		return filter_7tap_16p_upscale;
587 	else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
588 		return filter_7tap_16p_117;
589 	else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
590 		return filter_7tap_16p_150;
591 	else
592 		return filter_7tap_16p_183;
593 }
594 
wbscl_get_filter_8tap_16p(struct fixed31_32 ratio)595 static const uint16_t *wbscl_get_filter_8tap_16p(struct fixed31_32 ratio)
596 {
597 	if (ratio.value < dc_fixpt_one.value)
598 		return filter_8tap_16p_upscale;
599 	else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
600 		return filter_8tap_16p_117;
601 	else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
602 		return filter_8tap_16p_150;
603 	else
604 		return filter_8tap_16p_183;
605 }
606 
wbscl_get_filter_9tap_16p(struct fixed31_32 ratio)607 static const uint16_t *wbscl_get_filter_9tap_16p(struct fixed31_32 ratio)
608 {
609 	if (ratio.value < dc_fixpt_one.value)
610 		return filter_9tap_16p_upscale;
611 	else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
612 		return filter_9tap_16p_117;
613 	else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
614 		return filter_9tap_16p_150;
615 	else
616 		return filter_9tap_16p_183;
617 }
wbscl_get_filter_10tap_16p(struct fixed31_32 ratio)618 static const uint16_t *wbscl_get_filter_10tap_16p(struct fixed31_32 ratio)
619 {
620 	if (ratio.value < dc_fixpt_one.value)
621 		return filter_10tap_16p_upscale;
622 	else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
623 		return filter_10tap_16p_117;
624 	else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
625 		return filter_10tap_16p_150;
626 	else
627 		return filter_10tap_16p_183;
628 }
629 
wbscl_get_filter_11tap_16p(struct fixed31_32 ratio)630 static const uint16_t *wbscl_get_filter_11tap_16p(struct fixed31_32 ratio)
631 {
632 	if (ratio.value < dc_fixpt_one.value)
633 		return filter_11tap_16p_upscale;
634 	else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
635 		return filter_11tap_16p_117;
636 	else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
637 		return filter_11tap_16p_150;
638 	else
639 		return filter_11tap_16p_183;
640 }
641 
wbscl_get_filter_12tap_16p(struct fixed31_32 ratio)642 static const uint16_t *wbscl_get_filter_12tap_16p(struct fixed31_32 ratio)
643 {
644 	if (ratio.value < dc_fixpt_one.value)
645 		return filter_12tap_16p_upscale;
646 	else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
647 		return filter_12tap_16p_117;
648 	else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
649 		return filter_12tap_16p_150;
650 	else
651 		return filter_12tap_16p_183;
652 }
653 
wbscl_get_filter_coeffs_16p(int taps,struct fixed31_32 ratio)654 static const uint16_t *wbscl_get_filter_coeffs_16p(int taps, struct fixed31_32 ratio)
655 {
656 	if (taps == 12)
657 		return wbscl_get_filter_12tap_16p(ratio);
658 	else if (taps == 11)
659 		return wbscl_get_filter_11tap_16p(ratio);
660 	else if (taps == 10)
661 		return wbscl_get_filter_10tap_16p(ratio);
662 	else if (taps == 9)
663 		return wbscl_get_filter_9tap_16p(ratio);
664 	else if (taps == 8)
665 		return wbscl_get_filter_8tap_16p(ratio);
666 	else if (taps == 7)
667 		return wbscl_get_filter_7tap_16p(ratio);
668 	else if (taps == 6)
669 		return wbscl_get_filter_6tap_16p(ratio);
670 	else if (taps == 5)
671 		return wbscl_get_filter_5tap_16p(ratio);
672 	else if (taps == 4)
673 		return wbscl_get_filter_4tap_16p(ratio);
674 	else if (taps == 3)
675 		return wbscl_get_filter_3tap_16p(ratio);
676 	else if (taps == 2)
677 		return get_filter_2tap_16p();
678 	else if (taps == 1)
679 		return NULL;
680 	else {
681 		/* should never happen, bug */
682 		BREAK_TO_DEBUGGER();
683 		return NULL;
684 	}
685 }
686 
wbscl_set_scaler_filter(struct dcn20_dwbc * dwbc20,uint32_t taps,enum wbscl_coef_filter_type_sel filter_type,const uint16_t * filter)687 static void wbscl_set_scaler_filter(
688 	struct dcn20_dwbc *dwbc20,
689 	uint32_t taps,
690 	enum wbscl_coef_filter_type_sel filter_type,
691 	const uint16_t *filter)
692 {
693 	const int tap_pairs = (taps + 1) / 2;
694 	int phase;
695 	int pair;
696 	uint16_t odd_coef, even_coef;
697 
698 	for (phase = 0; phase < (NUM_PHASES / 2 + 1); phase++) {
699 		for (pair = 0; pair < tap_pairs; pair++) {
700 			even_coef = filter[phase * taps + 2 * pair];
701 			if ((pair * 2 + 1) < taps)
702 				odd_coef = filter[phase * taps + 2 * pair + 1];
703 			else
704 				odd_coef = 0;
705 
706 			REG_SET_3(WBSCL_COEF_RAM_SELECT, 0,
707 				WBSCL_COEF_RAM_TAP_PAIR_IDX, pair,
708 				WBSCL_COEF_RAM_PHASE, phase,
709 				WBSCL_COEF_RAM_FILTER_TYPE, filter_type);
710 
711 			REG_SET_4(WBSCL_COEF_RAM_TAP_DATA, 0,
712 				/* Even tap coefficient (bits 1:0 fixed to 0) */
713 				WBSCL_COEF_RAM_EVEN_TAP_COEF, even_coef,
714 				/* Write/read control for even coefficient */
715 				WBSCL_COEF_RAM_EVEN_TAP_COEF_EN, 1,
716 				/* Odd tap coefficient (bits 1:0 fixed to 0) */
717 				WBSCL_COEF_RAM_ODD_TAP_COEF, odd_coef,
718 				/* Write/read control for odd coefficient */
719 				WBSCL_COEF_RAM_ODD_TAP_COEF_EN, 1);
720 		}
721 	}
722 }
723 
dwb_program_horz_scalar(struct dcn20_dwbc * dwbc20,uint32_t src_width,uint32_t dest_width,struct scaling_taps num_taps)724 bool dwb_program_horz_scalar(struct dcn20_dwbc *dwbc20,
725 		uint32_t src_width,
726 		uint32_t dest_width,
727 		struct scaling_taps num_taps)
728 {
729 	uint32_t h_ratio_luma = 1;
730 	uint32_t h_taps_luma = num_taps.h_taps;
731 	uint32_t h_taps_chroma = num_taps.h_taps_c;
732 	int32_t h_init_phase_luma = 0;
733 	int32_t h_init_phase_chroma = 0;
734 	uint32_t h_init_phase_luma_int = 0;
735 	uint32_t h_init_phase_luma_frac = 0;
736 	uint32_t h_init_phase_chroma_int = 0;
737 	uint32_t h_init_phase_chroma_frac = 0;
738 	const uint16_t *filter_h = NULL;
739 	const uint16_t *filter_h_c = NULL;
740 
741 
742 	struct fixed31_32 tmp_h_init_phase_luma = dc_fixpt_from_int(0);
743 	struct fixed31_32 tmp_h_init_phase_chroma = dc_fixpt_from_int(0);
744 
745 
746 	/*Calculate ratio*/
747 	struct fixed31_32 tmp_h_ratio_luma = dc_fixpt_from_fraction(
748 		src_width, dest_width);
749 
750 	if (dc_fixpt_floor(tmp_h_ratio_luma) == 8)
751 		h_ratio_luma = -1;
752 	else
753 		h_ratio_luma = dc_fixpt_u3d19(tmp_h_ratio_luma) << 5;
754 
755 	/*Program ratio*/
756 	REG_UPDATE(WBSCL_HORZ_FILTER_SCALE_RATIO, WBSCL_H_SCALE_RATIO, h_ratio_luma);
757 
758 	/* Program taps*/
759 	REG_UPDATE(WBSCL_TAP_CONTROL, WBSCL_H_NUM_OF_TAPS_Y_RGB, h_taps_luma - 1);
760 	REG_UPDATE(WBSCL_TAP_CONTROL, WBSCL_H_NUM_OF_TAPS_CBCR, h_taps_chroma - 1);
761 
762 	/* Calculate phase*/
763 	tmp_h_init_phase_luma = dc_fixpt_add_int(tmp_h_ratio_luma, h_taps_luma + 1);
764 	tmp_h_init_phase_luma = dc_fixpt_div_int(tmp_h_init_phase_luma, 2);
765 	tmp_h_init_phase_luma = dc_fixpt_sub_int(tmp_h_init_phase_luma, h_taps_luma);
766 
767 	h_init_phase_luma = dc_fixpt_s4d19(tmp_h_init_phase_luma);
768 	h_init_phase_luma_int = (h_init_phase_luma >> 19) & 0x1f;
769 	h_init_phase_luma_frac = (h_init_phase_luma & 0x7ffff) << 5;
770 
771 	tmp_h_init_phase_chroma = dc_fixpt_mul_int(tmp_h_ratio_luma, 2);
772 	tmp_h_init_phase_chroma = dc_fixpt_add_int(tmp_h_init_phase_chroma, h_taps_chroma + 1);
773 	tmp_h_init_phase_chroma = dc_fixpt_div_int(tmp_h_init_phase_chroma, 2);
774 	tmp_h_init_phase_chroma = dc_fixpt_sub_int(tmp_h_init_phase_chroma, h_taps_chroma);
775 	tmp_h_init_phase_chroma = dc_fixpt_add(tmp_h_init_phase_chroma, dc_fixpt_from_fraction(1, 4));
776 
777 	h_init_phase_chroma = dc_fixpt_s4d19(tmp_h_init_phase_chroma);
778 	h_init_phase_chroma_int = (h_init_phase_chroma >> 19) & 0x1f;
779 	h_init_phase_chroma_frac = (h_init_phase_chroma & 0x7ffff) << 5;
780 
781 	/* Program phase*/
782 	REG_UPDATE(WBSCL_HORZ_FILTER_INIT_Y_RGB, WBSCL_H_INIT_INT_Y_RGB, h_init_phase_luma_int);
783 	REG_UPDATE(WBSCL_HORZ_FILTER_INIT_Y_RGB, WBSCL_H_INIT_FRAC_Y_RGB, h_init_phase_luma_frac);
784 	REG_UPDATE(WBSCL_HORZ_FILTER_INIT_CBCR, WBSCL_H_INIT_INT_CBCR, h_init_phase_chroma_int);
785 	REG_UPDATE(WBSCL_HORZ_FILTER_INIT_CBCR, WBSCL_H_INIT_FRAC_CBCR, h_init_phase_chroma_frac);
786 
787 	/* Program LUT coefficients*/
788 	filter_h = wbscl_get_filter_coeffs_16p(
789 		h_taps_luma, tmp_h_ratio_luma);
790 	filter_h_c = wbscl_get_filter_coeffs_16p(
791 		h_taps_chroma, dc_fixpt_from_int(h_ratio_luma * 2));
792 
793 	wbscl_set_scaler_filter(dwbc20, h_taps_luma,
794 		WBSCL_COEF_LUMA_HORZ_FILTER, filter_h);
795 
796 	wbscl_set_scaler_filter(dwbc20, h_taps_chroma,
797 		WBSCL_COEF_CHROMA_HORZ_FILTER, filter_h_c);
798 
799 	return true;
800 }
801 
dwb_program_vert_scalar(struct dcn20_dwbc * dwbc20,uint32_t src_height,uint32_t dest_height,struct scaling_taps num_taps,enum dwb_subsample_position subsample_position)802 bool dwb_program_vert_scalar(struct dcn20_dwbc *dwbc20,
803 		uint32_t src_height,
804 		uint32_t dest_height,
805 		struct scaling_taps num_taps,
806 		enum dwb_subsample_position subsample_position)
807 {
808 	uint32_t v_ratio_luma = 1;
809 	uint32_t v_taps_luma = num_taps.v_taps;
810 	uint32_t v_taps_chroma = num_taps.v_taps_c;
811 	int32_t v_init_phase_luma = 0;
812 	int32_t v_init_phase_chroma = 0;
813 	uint32_t v_init_phase_luma_int = 0;
814 	uint32_t v_init_phase_luma_frac = 0;
815 	uint32_t v_init_phase_chroma_int = 0;
816 	uint32_t v_init_phase_chroma_frac = 0;
817 
818 	const uint16_t *filter_v = NULL;
819 	const uint16_t *filter_v_c = NULL;
820 
821 	struct fixed31_32 tmp_v_init_phase_luma = dc_fixpt_from_int(0);
822 	struct fixed31_32 tmp_v_init_phase_chroma = dc_fixpt_from_int(0);
823 
824 	/*Calculate ratio*/
825 	struct fixed31_32 tmp_v_ratio_luma = dc_fixpt_from_fraction(
826 		src_height, dest_height);
827 
828 	if (dc_fixpt_floor(tmp_v_ratio_luma) == 8)
829 		v_ratio_luma = -1;
830 	else
831 		v_ratio_luma = dc_fixpt_u3d19(tmp_v_ratio_luma) << 5;
832 
833 	/*Program ratio*/
834 	REG_UPDATE(WBSCL_VERT_FILTER_SCALE_RATIO, WBSCL_V_SCALE_RATIO, v_ratio_luma);
835 
836 	/* Program taps*/
837 	REG_UPDATE(WBSCL_TAP_CONTROL, WBSCL_V_NUM_OF_TAPS_Y_RGB, v_taps_luma - 1);
838 	REG_UPDATE(WBSCL_TAP_CONTROL, WBSCL_V_NUM_OF_TAPS_CBCR, v_taps_chroma - 1);
839 
840 	/* Calculate phase*/
841 	tmp_v_init_phase_luma = dc_fixpt_add_int(tmp_v_ratio_luma, v_taps_luma + 1);
842 	tmp_v_init_phase_luma = dc_fixpt_div_int(tmp_v_init_phase_luma, 2);
843 	tmp_v_init_phase_luma = dc_fixpt_sub_int(tmp_v_init_phase_luma, v_taps_luma);
844 
845 	v_init_phase_luma = dc_fixpt_s4d19(tmp_v_init_phase_luma);
846 	v_init_phase_luma_int = (v_init_phase_luma >> 19) & 0x1f;
847 	v_init_phase_luma_frac = (v_init_phase_luma & 0x7ffff) << 5;
848 
849 	tmp_v_init_phase_chroma = dc_fixpt_mul_int(tmp_v_ratio_luma, 2);
850 	tmp_v_init_phase_chroma = dc_fixpt_add_int(tmp_v_init_phase_chroma, v_taps_chroma + 1);
851 	tmp_v_init_phase_chroma = dc_fixpt_div_int(tmp_v_init_phase_chroma, 2);
852 	tmp_v_init_phase_chroma = dc_fixpt_sub_int(tmp_v_init_phase_chroma, v_taps_chroma);
853 	if (subsample_position == DWB_COSITED_SUBSAMPLING)
854 		tmp_v_init_phase_chroma = dc_fixpt_add(tmp_v_init_phase_chroma, dc_fixpt_from_fraction(1, 4));
855 
856 	v_init_phase_chroma = dc_fixpt_s4d19(tmp_v_init_phase_chroma);
857 	v_init_phase_chroma_int = (v_init_phase_chroma >> 19) & 0x1f;
858 	v_init_phase_chroma_frac = (v_init_phase_chroma & 0x7ffff) << 5;
859 
860 	/* Program phase*/
861 	REG_UPDATE(WBSCL_VERT_FILTER_INIT_Y_RGB, WBSCL_V_INIT_INT_Y_RGB, v_init_phase_luma_int);
862 	REG_UPDATE(WBSCL_VERT_FILTER_INIT_Y_RGB, WBSCL_V_INIT_FRAC_Y_RGB, v_init_phase_luma_frac);
863 	REG_UPDATE(WBSCL_VERT_FILTER_INIT_CBCR, WBSCL_V_INIT_INT_CBCR, v_init_phase_chroma_int);
864 	REG_UPDATE(WBSCL_VERT_FILTER_INIT_CBCR, WBSCL_V_INIT_FRAC_CBCR, v_init_phase_chroma_frac);
865 
866 
867 	/* Program LUT coefficients*/
868 	filter_v  = wbscl_get_filter_coeffs_16p(
869 		v_taps_luma, tmp_v_ratio_luma);
870 	filter_v_c = wbscl_get_filter_coeffs_16p(
871 		v_taps_chroma, dc_fixpt_from_int(v_ratio_luma * 2));
872 	wbscl_set_scaler_filter(dwbc20, v_taps_luma,
873 		WBSCL_COEF_LUMA_VERT_FILTER, filter_v);
874 
875 	wbscl_set_scaler_filter(dwbc20, v_taps_chroma,
876 		WBSCL_COEF_CHROMA_VERT_FILTER, filter_v_c);
877 	return true;
878 }
879