0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include "reg_helper.h"
0027 #include "fixed31_32.h"
0028 #include "resource.h"
0029 #include "dwb.h"
0030 #include "dcn20_dwb.h"
0031
0032 #define NUM_PHASES 16
0033 #define HORZ_MAX_TAPS 12
0034 #define VERT_MAX_TAPS 12
0035
0036 #define REG(reg)\
0037 dwbc20->dwbc_regs->reg
0038
0039 #define CTX \
0040 dwbc20->base.ctx
0041
0042 #undef FN
0043 #define FN(reg_name, field_name) \
0044 dwbc20->dwbc_shift->field_name, dwbc20->dwbc_mask->field_name
0045
0046 #define TO_DCN20_DWBC(dwbc_base) \
0047 container_of(dwbc_base, struct dcn20_dwbc, base)
0048
0049
0050 static const uint16_t filter_3tap_16p_upscale[27] = {
0051 2048, 2048, 0,
0052 1708, 2424, 16348,
0053 1372, 2796, 16308,
0054 1056, 3148, 16272,
0055 768, 3464, 16244,
0056 512, 3728, 16236,
0057 296, 3928, 16252,
0058 124, 4052, 16296,
0059 0, 4096, 0
0060 };
0061
0062 static const uint16_t filter_3tap_16p_117[27] = {
0063 2048, 2048, 0,
0064 1824, 2276, 16376,
0065 1600, 2496, 16380,
0066 1376, 2700, 16,
0067 1156, 2880, 52,
0068 948, 3032, 108,
0069 756, 3144, 192,
0070 580, 3212, 296,
0071 428, 3236, 428
0072 };
0073
0074 static const uint16_t filter_3tap_16p_150[27] = {
0075 2048, 2048, 0,
0076 1872, 2184, 36,
0077 1692, 2308, 88,
0078 1516, 2420, 156,
0079 1340, 2516, 236,
0080 1168, 2592, 328,
0081 1004, 2648, 440,
0082 844, 2684, 560,
0083 696, 2696, 696
0084 };
0085
0086 static const uint16_t filter_3tap_16p_183[27] = {
0087 2048, 2048, 0,
0088 1892, 2104, 92,
0089 1744, 2152, 196,
0090 1592, 2196, 300,
0091 1448, 2232, 412,
0092 1304, 2256, 528,
0093 1168, 2276, 648,
0094 1032, 2288, 772,
0095 900, 2292, 900
0096 };
0097
0098 static const uint16_t filter_4tap_16p_upscale[36] = {
0099 0, 4096, 0, 0,
0100 16240, 4056, 180, 16380,
0101 16136, 3952, 404, 16364,
0102 16072, 3780, 664, 16344,
0103 16040, 3556, 952, 16312,
0104 16036, 3284, 1268, 16272,
0105 16052, 2980, 1604, 16224,
0106 16084, 2648, 1952, 16176,
0107 16128, 2304, 2304, 16128
0108 };
0109
0110 static const uint16_t filter_4tap_16p_117[36] = {
0111 428, 3236, 428, 0,
0112 276, 3232, 604, 16364,
0113 148, 3184, 800, 16340,
0114 44, 3104, 1016, 16312,
0115 16344, 2984, 1244, 16284,
0116 16284, 2832, 1488, 16256,
0117 16244, 2648, 1732, 16236,
0118 16220, 2440, 1976, 16220,
0119 16212, 2216, 2216, 16212
0120 };
0121
0122 static const uint16_t filter_4tap_16p_150[36] = {
0123 696, 2700, 696, 0,
0124 560, 2700, 848, 16364,
0125 436, 2676, 1008, 16348,
0126 328, 2628, 1180, 16336,
0127 232, 2556, 1356, 16328,
0128 152, 2460, 1536, 16328,
0129 84, 2344, 1716, 16332,
0130 28, 2208, 1888, 16348,
0131 16376, 2052, 2052, 16376
0132 };
0133
0134 static const uint16_t filter_4tap_16p_183[36] = {
0135 940, 2208, 940, 0,
0136 832, 2200, 1052, 4,
0137 728, 2180, 1164, 16,
0138 628, 2148, 1280, 36,
0139 536, 2100, 1392, 60,
0140 448, 2044, 1504, 92,
0141 368, 1976, 1612, 132,
0142 296, 1900, 1716, 176,
0143 232, 1812, 1812, 232
0144 };
0145
0146 static const uint16_t filter_5tap_16p_upscale[45] = {
0147 15936, 2496, 2496, 15936, 0,
0148 15992, 2128, 2832, 15896, 12,
0149 16056, 1760, 3140, 15876, 24,
0150 16120, 1404, 3420, 15876, 36,
0151 16188, 1060, 3652, 15908, 44,
0152 16248, 744, 3844, 15972, 44,
0153 16304, 460, 3980, 16072, 40,
0154 16348, 212, 4064, 16208, 24,
0155 0, 0, 4096, 0, 0,
0156 };
0157
0158 static const uint16_t filter_5tap_16p_117[45] = {
0159 16056, 2372, 2372, 16056, 0,
0160 16052, 2124, 2600, 16076, 0,
0161 16060, 1868, 2808, 16120, 0,
0162 16080, 1612, 2992, 16180, 16376,
0163 16112, 1356, 3144, 16268, 16364,
0164 16144, 1108, 3268, 16376, 16344,
0165 16184, 872, 3356, 124, 16320,
0166 16220, 656, 3412, 276, 16292,
0167 16256, 456, 3428, 456, 16256,
0168 };
0169
0170 static const uint16_t filter_5tap_16p_150[45] = {
0171 16368, 2064, 2064, 16368, 0,
0172 16316, 1924, 2204, 44, 16372,
0173 16280, 1772, 2328, 116, 16356,
0174 16256, 1616, 2440, 204, 16340,
0175 16240, 1456, 2536, 304, 16320,
0176 16232, 1296, 2612, 416, 16300,
0177 16232, 1132, 2664, 544, 16284,
0178 16240, 976, 2700, 680, 16264,
0179 16248, 824, 2708, 824, 16248,
0180 };
0181
0182 static const uint16_t filter_5tap_16p_183[45] = {
0183 228, 1816, 1816, 228, 0,
0184 168, 1728, 1904, 300, 16372,
0185 116, 1632, 1988, 376, 16360,
0186 72, 1528, 2060, 460, 16348,
0187 36, 1424, 2120, 552, 16340,
0188 4, 1312, 2168, 652, 16336,
0189 16368, 1200, 2204, 752, 16332,
0190 16352, 1084, 2224, 860, 16332,
0191 16340, 972, 2232, 972, 16340,
0192 };
0193
0194 static const uint16_t filter_6tap_16p_upscale[54] = {
0195 0, 0, 4092, 0, 0, 0,
0196 44, 16188, 4064, 228, 16324, 0,
0197 80, 16036, 3980, 492, 16256, 4,
0198 108, 15916, 3844, 788, 16184, 16,
0199 120, 15836, 3656, 1108, 16104, 28,
0200 128, 15792, 3420, 1448, 16024, 44,
0201 124, 15776, 3144, 1800, 15948, 64,
0202 112, 15792, 2836, 2152, 15880, 80,
0203 100, 15828, 2504, 2504, 15828, 100,
0204 };
0205
0206 static const uint16_t filter_6tap_16p_117[54] = {
0207 16168, 476, 3568, 476, 16168, 0,
0208 16216, 280, 3540, 692, 16116, 8,
0209 16264, 104, 3472, 924, 16068, 16,
0210 16304, 16340, 3372, 1168, 16024, 28,
0211 16344, 16212, 3236, 1424, 15988, 36,
0212 16372, 16112, 3072, 1680, 15956, 44,
0213 12, 16036, 2880, 1936, 15940, 48,
0214 28, 15984, 2668, 2192, 15936, 48,
0215 40, 15952, 2436, 2436, 15952, 40,
0216 };
0217
0218 static const uint16_t filter_6tap_16p_150[54] = {
0219 16148, 920, 2724, 920, 16148, 0,
0220 16156, 768, 2712, 1072, 16144, 0,
0221 16172, 628, 2684, 1232, 16148, 16380,
0222 16192, 492, 2632, 1388, 16160, 16372,
0223 16212, 368, 2564, 1548, 16180, 16364,
0224 16232, 256, 2480, 1704, 16212, 16352,
0225 16256, 156, 2380, 1856, 16256, 16336,
0226 16276, 64, 2268, 2004, 16308, 16320,
0227 16300, 16372, 2140, 2140, 16372, 16300,
0228 };
0229
0230 static const uint16_t filter_6tap_16p_183[54] = {
0231 16296, 1032, 2196, 1032, 16296, 0,
0232 16284, 924, 2196, 1144, 16320, 16376,
0233 16272, 820, 2180, 1256, 16348, 16364,
0234 16268, 716, 2156, 1364, 16380, 16352,
0235 16264, 620, 2116, 1472, 36, 16340,
0236 16268, 524, 2068, 1576, 88, 16328,
0237 16272, 436, 2008, 1680, 144, 16316,
0238 16280, 352, 1940, 1772, 204, 16304,
0239 16292, 276, 1860, 1860, 276, 16292,
0240 };
0241
0242 static const uint16_t filter_7tap_16p_upscale[63] = {
0243 176, 15760, 2488, 2488, 15760, 176, 0,
0244 160, 15812, 2152, 2816, 15728, 192, 16376,
0245 136, 15884, 1812, 3124, 15720, 196, 16368,
0246 108, 15964, 1468, 3400, 15740, 196, 16364,
0247 84, 16048, 1132, 3640, 15792, 180, 16360,
0248 56, 16140, 812, 3832, 15884, 152, 16360,
0249 32, 16228, 512, 3976, 16012, 116, 16364,
0250 12, 16308, 240, 4064, 16180, 60, 16372,
0251 0, 0, 0, 4096, 0, 0, 0,
0252 };
0253
0254 static const uint16_t filter_7tap_16p_117[63] = {
0255 92, 15868, 2464, 2464, 15868, 92, 0,
0256 108, 15852, 2216, 2700, 15904, 72, 0,
0257 112, 15856, 1960, 2916, 15964, 44, 0,
0258 116, 15876, 1696, 3108, 16048, 8, 8,
0259 112, 15908, 1428, 3268, 16156, 16348, 12,
0260 104, 15952, 1168, 3400, 16288, 16300, 24,
0261 92, 16004, 916, 3496, 64, 16244, 36,
0262 80, 16064, 676, 3556, 248, 16184, 48,
0263 64, 16124, 452, 3576, 452, 16124, 64,
0264 };
0265
0266 static const uint16_t filter_7tap_16p_150[63] = {
0267 16224, 16380, 2208, 2208, 16380, 16224, 0,
0268 16252, 16304, 2072, 2324, 84, 16196, 4,
0269 16276, 16240, 1924, 2432, 184, 16172, 8,
0270 16300, 16184, 1772, 2524, 296, 16144, 12,
0271 16324, 16144, 1616, 2600, 416, 16124, 12,
0272 16344, 16112, 1456, 2660, 548, 16104, 12,
0273 16360, 16092, 1296, 2704, 688, 16088, 12,
0274 16372, 16080, 1140, 2732, 832, 16080, 8,
0275 0, 16076, 984, 2740, 984, 16076, 0,
0276 };
0277
0278 static const uint16_t filter_7tap_16p_183[63] = {
0279 16216, 324, 1884, 1884, 324, 16216, 0,
0280 16228, 248, 1804, 1960, 408, 16212, 16380,
0281 16240, 176, 1716, 2028, 496, 16208, 16376,
0282 16252, 112, 1624, 2084, 588, 16208, 16372,
0283 16264, 56, 1524, 2132, 684, 16212, 16364,
0284 16280, 4, 1424, 2168, 788, 16220, 16356,
0285 16292, 16344, 1320, 2196, 892, 16232, 16344,
0286 16308, 16308, 1212, 2212, 996, 16252, 16332,
0287 16320, 16276, 1104, 2216, 1104, 16276, 16320,
0288 };
0289
0290 static const uint16_t filter_8tap_16p_upscale[72] = {
0291 0, 0, 0, 4096, 0, 0, 0, 0,
0292 16360, 76, 16172, 4064, 244, 16296, 24, 16380,
0293 16340, 136, 15996, 3980, 524, 16204, 56, 16380,
0294 16328, 188, 15860, 3844, 828, 16104, 92, 16372,
0295 16320, 224, 15760, 3656, 1156, 16008, 128, 16368,
0296 16320, 248, 15696, 3428, 1496, 15912, 160, 16360,
0297 16320, 256, 15668, 3156, 1844, 15828, 192, 16348,
0298 16324, 256, 15672, 2856, 2192, 15756, 220, 16340,
0299 16332, 244, 15704, 2532, 2532, 15704, 244, 16332,
0300 };
0301
0302 static const uint16_t filter_8tap_16p_117[72] = {
0303 116, 16100, 428, 3564, 428, 16100, 116, 0,
0304 96, 16168, 220, 3548, 656, 16032, 136, 16376,
0305 76, 16236, 32, 3496, 904, 15968, 152, 16372,
0306 56, 16300, 16252, 3408, 1164, 15908, 164, 16368,
0307 36, 16360, 16116, 3284, 1428, 15856, 172, 16364,
0308 20, 28, 16000, 3124, 1700, 15820, 176, 16364,
0309 4, 76, 15912, 2940, 1972, 15800, 172, 16364,
0310 16380, 112, 15848, 2724, 2236, 15792, 160, 16364,
0311 16372, 140, 15812, 2488, 2488, 15812, 140, 16372,
0312 };
0313
0314 static const uint16_t filter_8tap_16p_150[72] = {
0315 16380, 16020, 1032, 2756, 1032, 16020, 16380, 0,
0316 12, 16020, 876, 2744, 1184, 16032, 16364, 4,
0317 24, 16028, 728, 2716, 1344, 16052, 16340, 8,
0318 36, 16040, 584, 2668, 1500, 16080, 16316, 16,
0319 40, 16060, 448, 2608, 1652, 16120, 16288, 20,
0320 44, 16080, 320, 2528, 1804, 16168, 16260, 28,
0321 48, 16108, 204, 2436, 1948, 16232, 16228, 32,
0322 44, 16136, 100, 2328, 2084, 16304, 16200, 40,
0323 44, 16168, 4, 2212, 2212, 4, 16168, 44,
0324 };
0325
0326 static const uint16_t filter_8tap_16p_183[72] = {
0327 16264, 16264, 1164, 2244, 1164, 16264, 16264, 0,
0328 16280, 16232, 1056, 2236, 1268, 16300, 16248, 0,
0329 16296, 16204, 948, 2220, 1372, 16348, 16232, 0,
0330 16312, 16184, 844, 2192, 1472, 12, 16216, 4,
0331 16328, 16172, 740, 2156, 1572, 72, 16200, 0,
0332 16340, 16160, 640, 2108, 1668, 136, 16188, 0,
0333 16352, 16156, 544, 2052, 1756, 204, 16176, 16380,
0334 16360, 16156, 452, 1988, 1840, 280, 16164, 16376,
0335 16368, 16160, 364, 1920, 1920, 364, 16160, 16368,
0336 };
0337
0338 static const uint16_t filter_9tap_16p_upscale[81] = {
0339 16284, 296, 15660, 2572, 2572, 15660, 296, 16284, 0,
0340 16296, 272, 15712, 2228, 2896, 15632, 304, 16276, 4,
0341 16308, 240, 15788, 1876, 3192, 15632, 304, 16276, 4,
0342 16320, 204, 15876, 1520, 3452, 15664, 288, 16280, 8,
0343 16336, 164, 15976, 1176, 3676, 15732, 260, 16288, 12,
0344 16348, 120, 16080, 844, 3856, 15840, 216, 16300, 12,
0345 16364, 76, 16188, 532, 3988, 15984, 156, 16324, 8,
0346 16376, 36, 16288, 252, 4068, 16164, 84, 16352, 4,
0347 0, 0, 0, 0, 4096, 0, 0, 0, 0,
0348 };
0349
0350 static const uint16_t filter_9tap_16p_117[81] = {
0351 16356, 172, 15776, 2504, 2504, 15776, 172, 16356, 0,
0352 16344, 200, 15756, 2252, 2740, 15816, 136, 16372, 16380,
0353 16336, 216, 15756, 1988, 2956, 15884, 92, 8, 16380,
0354 16332, 224, 15780, 1720, 3144, 15976, 40, 28, 16376,
0355 16328, 224, 15816, 1448, 3304, 16096, 16364, 52, 16372,
0356 16328, 216, 15868, 1180, 3432, 16240, 16296, 80, 16364,
0357 16332, 200, 15928, 916, 3524, 24, 16224, 108, 16356,
0358 16336, 184, 15996, 668, 3580, 220, 16148, 132, 16352,
0359 16344, 160, 16072, 436, 3600, 436, 16072, 160, 16344,
0360 };
0361
0362 static const uint16_t filter_9tap_16p_150[81] = {
0363 84, 16128, 0, 2216, 2216, 0, 16128, 84, 0,
0364 80, 16160, 16296, 2088, 2332, 100, 16092, 84, 0,
0365 76, 16196, 16220, 1956, 2432, 208, 16064, 80, 0,
0366 72, 16232, 16152, 1812, 2524, 328, 16036, 76, 4,
0367 64, 16264, 16096, 1664, 2600, 460, 16012, 64, 8,
0368 56, 16300, 16052, 1508, 2656, 596, 15996, 52, 12,
0369 48, 16328, 16020, 1356, 2700, 740, 15984, 36, 20,
0370 40, 16356, 15996, 1196, 2728, 888, 15980, 20, 24,
0371 32, 0, 15984, 1044, 2736, 1044, 15984, 0, 32,
0372 };
0373
0374 static const uint16_t filter_9tap_16p_183[81] = {
0375 16356, 16112, 388, 1952, 1952, 388, 16112, 16356, 0,
0376 16368, 16116, 304, 1876, 2020, 480, 16112, 16344, 4,
0377 16376, 16124, 224, 1792, 2080, 576, 16116, 16328, 8,
0378 0, 16136, 148, 1700, 2132, 672, 16124, 16312, 8,
0379 8, 16148, 80, 1604, 2176, 772, 16140, 16296, 12,
0380 12, 16164, 16, 1504, 2208, 876, 16156, 16276, 16,
0381 16, 16180, 16344, 1404, 2232, 980, 16184, 16256, 20,
0382 20, 16200, 16296, 1300, 2244, 1088, 16212, 16240, 20,
0383 20, 16220, 16252, 1196, 2252, 1196, 16252, 16220, 20,
0384 };
0385
0386 static const uint16_t filter_10tap_16p_upscale[90] = {
0387 0, 0, 0, 0, 4096, 0, 0, 0, 0, 0,
0388 12, 16344, 88, 16160, 4068, 252, 16280, 44, 16368, 0,
0389 24, 16308, 168, 15976, 3988, 540, 16176, 92, 16348, 0,
0390 32, 16280, 236, 15828, 3852, 852, 16064, 140, 16328, 4,
0391 36, 16260, 284, 15720, 3672, 1184, 15956, 188, 16308, 8,
0392 36, 16244, 320, 15648, 3448, 1528, 15852, 236, 16288, 12,
0393 36, 16240, 336, 15612, 3184, 1880, 15764, 276, 16272, 20,
0394 32, 16240, 340, 15608, 2888, 2228, 15688, 308, 16256, 24,
0395 28, 16244, 332, 15636, 2568, 2568, 15636, 332, 16244, 28,
0396 };
0397
0398 static const uint16_t filter_10tap_16p_117[90] = {
0399 16308, 196, 16048, 440, 3636, 440, 16048, 196, 16308, 0,
0400 16316, 164, 16132, 220, 3612, 676, 15972, 220, 16300, 0,
0401 16324, 132, 16212, 20, 3552, 932, 15900, 240, 16296, 4,
0402 16336, 100, 16292, 16232, 3456, 1192, 15836, 256, 16296, 4,
0403 16348, 68, 16364, 16084, 3324, 1464, 15784, 264, 16296, 8,
0404 16356, 36, 48, 15960, 3164, 1736, 15748, 260, 16304, 4,
0405 16364, 8, 108, 15864, 2972, 2008, 15728, 252, 16312, 4,
0406 16372, 16368, 160, 15792, 2756, 2268, 15724, 228, 16328, 0,
0407 16380, 16344, 200, 15748, 2520, 2520, 15748, 200, 16344, 16380,
0408 };
0409
0410 static const uint16_t filter_10tap_16p_150[90] = {
0411 64, 0, 15956, 1048, 2716, 1048, 15956, 0, 64, 0,
0412 52, 24, 15952, 896, 2708, 1204, 15972, 16356, 72, 16380,
0413 44, 48, 15952, 748, 2684, 1360, 16000, 16320, 84, 16380,
0414 32, 68, 15964, 604, 2644, 1516, 16032, 16288, 92, 16376,
0415 24, 88, 15980, 464, 2588, 1668, 16080, 16248, 100, 16376,
0416 16, 100, 16004, 332, 2516, 1816, 16140, 16212, 108, 16376,
0417 8, 108, 16032, 212, 2428, 1956, 16208, 16172, 112, 16376,
0418 4, 116, 16060, 100, 2328, 2092, 16288, 16132, 116, 16380,
0419 0, 116, 16096, 16380, 2216, 2216, 16380, 16096, 116, 0,
0420 };
0421
0422 static const uint16_t filter_10tap_16p_183[90] = {
0423 40, 16180, 16240, 1216, 2256, 1216, 16240, 16180, 40, 0,
0424 44, 16204, 16200, 1112, 2252, 1320, 16288, 16160, 36, 0,
0425 44, 16224, 16168, 1004, 2236, 1424, 16344, 16144, 28, 4,
0426 44, 16248, 16136, 900, 2208, 1524, 16, 16124, 24, 8,
0427 44, 16268, 16116, 796, 2176, 1620, 84, 16108, 12, 12,
0428 40, 16288, 16100, 692, 2132, 1712, 156, 16096, 4, 16,
0429 36, 16308, 16088, 592, 2080, 1796, 232, 16088, 16376, 20,
0430 32, 16328, 16080, 496, 2020, 1876, 316, 16080, 16360, 24,
0431 28, 16344, 16080, 404, 1952, 1952, 404, 16080, 16344, 28,
0432 };
0433
0434 static const uint16_t filter_11tap_16p_upscale[99] = {
0435 60, 16216, 356, 15620, 2556, 2556, 15620, 356, 16216, 60, 0,
0436 52, 16224, 336, 15672, 2224, 2876, 15592, 368, 16208, 64, 16380,
0437 44, 16244, 304, 15744, 1876, 3176, 15596, 364, 16212, 64, 16376,
0438 36, 16264, 260, 15836, 1532, 3440, 15636, 340, 16220, 60, 16376,
0439 28, 16288, 212, 15940, 1188, 3668, 15708, 304, 16236, 56, 16376,
0440 20, 16312, 160, 16052, 856, 3848, 15820, 248, 16264, 48, 16376,
0441 12, 16336, 104, 16164, 544, 3984, 15968, 180, 16296, 36, 16376,
0442 4, 16360, 48, 16276, 256, 4068, 16160, 96, 16336, 16, 16380,
0443 0, 0, 0, 0, 0, 4096, 0, 0, 0, 0, 0,
0444 };
0445
0446 static const uint16_t filter_11tap_16p_117[99] = {
0447 16380, 16332, 220, 15728, 2536, 2536, 15728, 220, 16332, 16380, 0,
0448 4, 16308, 256, 15704, 2280, 2768, 15772, 176, 16360, 16368, 0,
0449 12, 16292, 280, 15704, 2016, 2984, 15848, 120, 8, 16356, 0,
0450 20, 16276, 292, 15724, 1744, 3172, 15948, 56, 40, 16340, 4,
0451 24, 16268, 292, 15760, 1468, 3328, 16072, 16368, 80, 16324, 8,
0452 24, 16264, 288, 15816, 1196, 3456, 16224, 16288, 116, 16312, 12,
0453 24, 16264, 272, 15880, 932, 3548, 16, 16208, 152, 16296, 16,
0454 24, 16268, 248, 15956, 676, 3604, 216, 16120, 188, 16284, 20,
0455 24, 16276, 220, 16036, 436, 3624, 436, 16036, 220, 16276, 24,
0456 };
0457
0458 static const uint16_t filter_11tap_16p_150[99] = {
0459 0, 144, 16072, 0, 2212, 2212, 0, 16072, 144, 0, 0,
0460 16376, 144, 16112, 16288, 2092, 2324, 104, 16036, 140, 8, 16380,
0461 16368, 144, 16152, 16204, 1960, 2424, 216, 16004, 132, 16, 16376,
0462 16364, 140, 16192, 16132, 1820, 2512, 340, 15976, 116, 28, 16376,
0463 16364, 132, 16232, 16072, 1676, 2584, 476, 15952, 100, 40, 16372,
0464 16360, 124, 16272, 16020, 1528, 2644, 612, 15936, 80, 52, 16368,
0465 16360, 116, 16312, 15980, 1372, 2684, 760, 15928, 56, 64, 16364,
0466 16360, 104, 16348, 15952, 1216, 2712, 908, 15928, 28, 76, 16364,
0467 16360, 92, 0, 15936, 1064, 2720, 1064, 15936, 0, 92, 16360,
0468 };
0469
0470 static const uint16_t filter_11tap_16p_183[99] = {
0471 60, 16336, 16052, 412, 1948, 1948, 412, 16052, 16336, 60, 0,
0472 56, 16356, 16052, 324, 1876, 2016, 504, 16056, 16316, 64, 0,
0473 48, 16372, 16060, 240, 1796, 2072, 604, 16064, 16292, 64, 0,
0474 44, 4, 16068, 160, 1712, 2124, 700, 16080, 16272, 68, 0,
0475 40, 20, 16080, 84, 1620, 2164, 804, 16096, 16248, 68, 4,
0476 32, 32, 16096, 16, 1524, 2200, 908, 16124, 16224, 68, 4,
0477 28, 40, 16112, 16340, 1428, 2220, 1012, 16152, 16200, 64, 8,
0478 24, 52, 16132, 16284, 1328, 2236, 1120, 16192, 16176, 64, 12,
0479 16, 56, 16156, 16236, 1224, 2240, 1224, 16236, 16156, 56, 16,
0480 };
0481
0482 static const uint16_t filter_12tap_16p_upscale[108] = {
0483 0, 0, 0, 0, 0, 4096, 0, 0, 0, 0, 0, 0,
0484 16376, 24, 16332, 100, 16156, 4068, 260, 16272, 56, 16356, 8, 0,
0485 16368, 44, 16284, 188, 15964, 3988, 548, 16156, 112, 16328, 20, 16380,
0486 16360, 64, 16248, 260, 15812, 3856, 864, 16040, 172, 16296, 32, 16380,
0487 16360, 76, 16216, 320, 15696, 3672, 1196, 15928, 228, 16268, 44, 16376,
0488 16356, 84, 16196, 360, 15620, 3448, 1540, 15820, 280, 16240, 56, 16372,
0489 16356, 88, 16184, 384, 15580, 3188, 1888, 15728, 324, 16216, 68, 16368,
0490 16360, 88, 16180, 392, 15576, 2892, 2236, 15652, 360, 16200, 80, 16364,
0491 16360, 84, 16188, 384, 15600, 2576, 2576, 15600, 384, 16188, 84, 16360,
0492 };
0493
0494 static const uint16_t filter_12tap_16p_117[108] = {
0495 48, 16248, 240, 16028, 436, 3612, 436, 16028, 240, 16248, 48, 0,
0496 44, 16260, 208, 16116, 212, 3596, 676, 15944, 272, 16240, 48, 16380,
0497 40, 16276, 168, 16204, 12, 3540, 932, 15868, 296, 16240, 48, 16380,
0498 36, 16292, 128, 16288, 16220, 3452, 1196, 15800, 312, 16240, 44, 16380,
0499 28, 16308, 84, 16372, 16064, 3324, 1472, 15748, 316, 16244, 40, 16380,
0500 24, 16328, 44, 64, 15936, 3168, 1744, 15708, 312, 16256, 32, 16380,
0501 16, 16344, 8, 132, 15836, 2980, 2016, 15688, 300, 16272, 20, 0,
0502 12, 16364, 16356, 188, 15760, 2768, 2280, 15688, 272, 16296, 8, 4,
0503 8, 16380, 16324, 236, 15712, 2532, 2532, 15712, 236, 16324, 16380, 8,
0504 };
0505
0506 static const uint16_t filter_12tap_16p_150[108] = {
0507 16340, 116, 0, 15916, 1076, 2724, 1076, 15916, 0, 116, 16340, 0,
0508 16340, 100, 32, 15908, 920, 2716, 1232, 15936, 16344, 128, 16340, 0,
0509 16344, 84, 64, 15908, 772, 2692, 1388, 15968, 16304, 140, 16344, 16380,
0510 16344, 68, 92, 15912, 624, 2652, 1540, 16008, 16264, 152, 16344, 16380,
0511 16348, 52, 112, 15928, 484, 2592, 1688, 16060, 16220, 160, 16348, 16380,
0512 16352, 40, 132, 15952, 348, 2520, 1836, 16124, 16176, 168, 16356, 16376,
0513 16356, 24, 148, 15980, 224, 2436, 1976, 16200, 16132, 172, 16364, 16372,
0514 16360, 12, 160, 16012, 108, 2336, 2104, 16288, 16088, 172, 16372, 16368,
0515 16364, 0, 168, 16048, 0, 2228, 2228, 0, 16048, 168, 0, 16364,
0516 };
0517
0518 static const uint16_t filter_12tap_16p_183[108] = {
0519 36, 72, 16132, 16228, 1224, 2224, 1224, 16228, 16132, 72, 36, 0,
0520 28, 80, 16156, 16184, 1120, 2224, 1328, 16280, 16112, 64, 40, 16380,
0521 24, 84, 16180, 16144, 1016, 2208, 1428, 16340, 16092, 52, 48, 16380,
0522 16, 88, 16208, 16112, 912, 2188, 1524, 16, 16072, 36, 56, 16380,
0523 12, 92, 16232, 16084, 812, 2156, 1620, 88, 16056, 24, 64, 16380,
0524 8, 92, 16256, 16064, 708, 2116, 1708, 164, 16044, 4, 68, 16380,
0525 4, 88, 16280, 16048, 608, 2068, 1792, 244, 16036, 16372, 76, 16380,
0526 0, 88, 16308, 16036, 512, 2008, 1872, 328, 16032, 16352, 80, 16380,
0527 0, 84, 16328, 16032, 416, 1944, 1944, 416, 16032, 16328, 84, 0,
0528 };
0529
0530 static const uint16_t *wbscl_get_filter_3tap_16p(struct fixed31_32 ratio)
0531 {
0532 if (ratio.value < dc_fixpt_one.value)
0533 return filter_3tap_16p_upscale;
0534 else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
0535 return filter_3tap_16p_117;
0536 else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
0537 return filter_3tap_16p_150;
0538 else
0539 return filter_3tap_16p_183;
0540 }
0541
0542 static const uint16_t *wbscl_get_filter_4tap_16p(struct fixed31_32 ratio)
0543 {
0544 if (ratio.value < dc_fixpt_one.value)
0545 return filter_4tap_16p_upscale;
0546 else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
0547 return filter_4tap_16p_117;
0548 else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
0549 return filter_4tap_16p_150;
0550 else
0551 return filter_4tap_16p_183;
0552 }
0553
0554 static const uint16_t *wbscl_get_filter_5tap_16p(struct fixed31_32 ratio)
0555 {
0556 if (ratio.value < dc_fixpt_one.value)
0557 return filter_5tap_16p_upscale;
0558 else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
0559 return filter_5tap_16p_117;
0560 else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
0561 return filter_5tap_16p_150;
0562 else
0563 return filter_5tap_16p_183;
0564 }
0565
0566 static const uint16_t *wbscl_get_filter_6tap_16p(struct fixed31_32 ratio)
0567 {
0568 if (ratio.value < dc_fixpt_one.value)
0569 return filter_6tap_16p_upscale;
0570 else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
0571 return filter_6tap_16p_117;
0572 else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
0573 return filter_6tap_16p_150;
0574 else
0575 return filter_6tap_16p_183;
0576 }
0577
0578 static const uint16_t *wbscl_get_filter_7tap_16p(struct fixed31_32 ratio)
0579 {
0580 if (ratio.value < dc_fixpt_one.value)
0581 return filter_7tap_16p_upscale;
0582 else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
0583 return filter_7tap_16p_117;
0584 else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
0585 return filter_7tap_16p_150;
0586 else
0587 return filter_7tap_16p_183;
0588 }
0589
0590 static const uint16_t *wbscl_get_filter_8tap_16p(struct fixed31_32 ratio)
0591 {
0592 if (ratio.value < dc_fixpt_one.value)
0593 return filter_8tap_16p_upscale;
0594 else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
0595 return filter_8tap_16p_117;
0596 else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
0597 return filter_8tap_16p_150;
0598 else
0599 return filter_8tap_16p_183;
0600 }
0601
0602 static const uint16_t *wbscl_get_filter_9tap_16p(struct fixed31_32 ratio)
0603 {
0604 if (ratio.value < dc_fixpt_one.value)
0605 return filter_9tap_16p_upscale;
0606 else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
0607 return filter_9tap_16p_117;
0608 else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
0609 return filter_9tap_16p_150;
0610 else
0611 return filter_9tap_16p_183;
0612 }
0613 static const uint16_t *wbscl_get_filter_10tap_16p(struct fixed31_32 ratio)
0614 {
0615 if (ratio.value < dc_fixpt_one.value)
0616 return filter_10tap_16p_upscale;
0617 else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
0618 return filter_10tap_16p_117;
0619 else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
0620 return filter_10tap_16p_150;
0621 else
0622 return filter_10tap_16p_183;
0623 }
0624
0625 static const uint16_t *wbscl_get_filter_11tap_16p(struct fixed31_32 ratio)
0626 {
0627 if (ratio.value < dc_fixpt_one.value)
0628 return filter_11tap_16p_upscale;
0629 else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
0630 return filter_11tap_16p_117;
0631 else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
0632 return filter_11tap_16p_150;
0633 else
0634 return filter_11tap_16p_183;
0635 }
0636
0637 static const uint16_t *wbscl_get_filter_12tap_16p(struct fixed31_32 ratio)
0638 {
0639 if (ratio.value < dc_fixpt_one.value)
0640 return filter_12tap_16p_upscale;
0641 else if (ratio.value < dc_fixpt_from_fraction(4, 3).value)
0642 return filter_12tap_16p_117;
0643 else if (ratio.value < dc_fixpt_from_fraction(5, 3).value)
0644 return filter_12tap_16p_150;
0645 else
0646 return filter_12tap_16p_183;
0647 }
0648
0649 static const uint16_t *wbscl_get_filter_coeffs_16p(int taps, struct fixed31_32 ratio)
0650 {
0651 if (taps == 12)
0652 return wbscl_get_filter_12tap_16p(ratio);
0653 else if (taps == 11)
0654 return wbscl_get_filter_11tap_16p(ratio);
0655 else if (taps == 10)
0656 return wbscl_get_filter_10tap_16p(ratio);
0657 else if (taps == 9)
0658 return wbscl_get_filter_9tap_16p(ratio);
0659 else if (taps == 8)
0660 return wbscl_get_filter_8tap_16p(ratio);
0661 else if (taps == 7)
0662 return wbscl_get_filter_7tap_16p(ratio);
0663 else if (taps == 6)
0664 return wbscl_get_filter_6tap_16p(ratio);
0665 else if (taps == 5)
0666 return wbscl_get_filter_5tap_16p(ratio);
0667 else if (taps == 4)
0668 return wbscl_get_filter_4tap_16p(ratio);
0669 else if (taps == 3)
0670 return wbscl_get_filter_3tap_16p(ratio);
0671 else if (taps == 2)
0672 return get_filter_2tap_16p();
0673 else if (taps == 1)
0674 return NULL;
0675 else {
0676
0677 BREAK_TO_DEBUGGER();
0678 return NULL;
0679 }
0680 }
0681
0682 static void wbscl_set_scaler_filter(
0683 struct dcn20_dwbc *dwbc20,
0684 uint32_t taps,
0685 enum wbscl_coef_filter_type_sel filter_type,
0686 const uint16_t *filter)
0687 {
0688 const int tap_pairs = (taps + 1) / 2;
0689 int phase;
0690 int pair;
0691 uint16_t odd_coef, even_coef;
0692
0693 for (phase = 0; phase < (NUM_PHASES / 2 + 1); phase++) {
0694 for (pair = 0; pair < tap_pairs; pair++) {
0695 even_coef = filter[phase * taps + 2 * pair];
0696 if ((pair * 2 + 1) < taps)
0697 odd_coef = filter[phase * taps + 2 * pair + 1];
0698 else
0699 odd_coef = 0;
0700
0701 REG_SET_3(WBSCL_COEF_RAM_SELECT, 0,
0702 WBSCL_COEF_RAM_TAP_PAIR_IDX, pair,
0703 WBSCL_COEF_RAM_PHASE, phase,
0704 WBSCL_COEF_RAM_FILTER_TYPE, filter_type);
0705
0706 REG_SET_4(WBSCL_COEF_RAM_TAP_DATA, 0,
0707
0708 WBSCL_COEF_RAM_EVEN_TAP_COEF, even_coef,
0709
0710 WBSCL_COEF_RAM_EVEN_TAP_COEF_EN, 1,
0711
0712 WBSCL_COEF_RAM_ODD_TAP_COEF, odd_coef,
0713
0714 WBSCL_COEF_RAM_ODD_TAP_COEF_EN, 1);
0715 }
0716 }
0717 }
0718
0719 bool dwb_program_horz_scalar(struct dcn20_dwbc *dwbc20,
0720 uint32_t src_width,
0721 uint32_t dest_width,
0722 struct scaling_taps num_taps)
0723 {
0724 uint32_t h_ratio_luma = 1;
0725 uint32_t h_taps_luma = num_taps.h_taps;
0726 uint32_t h_taps_chroma = num_taps.h_taps_c;
0727 int32_t h_init_phase_luma = 0;
0728 int32_t h_init_phase_chroma = 0;
0729 uint32_t h_init_phase_luma_int = 0;
0730 uint32_t h_init_phase_luma_frac = 0;
0731 uint32_t h_init_phase_chroma_int = 0;
0732 uint32_t h_init_phase_chroma_frac = 0;
0733 const uint16_t *filter_h = NULL;
0734 const uint16_t *filter_h_c = NULL;
0735
0736
0737 struct fixed31_32 tmp_h_init_phase_luma = dc_fixpt_from_int(0);
0738 struct fixed31_32 tmp_h_init_phase_chroma = dc_fixpt_from_int(0);
0739
0740
0741
0742 struct fixed31_32 tmp_h_ratio_luma = dc_fixpt_from_fraction(
0743 src_width, dest_width);
0744
0745 if (dc_fixpt_floor(tmp_h_ratio_luma) == 8)
0746 h_ratio_luma = -1;
0747 else
0748 h_ratio_luma = dc_fixpt_u3d19(tmp_h_ratio_luma) << 5;
0749
0750
0751 REG_UPDATE(WBSCL_HORZ_FILTER_SCALE_RATIO, WBSCL_H_SCALE_RATIO, h_ratio_luma);
0752
0753
0754 REG_UPDATE(WBSCL_TAP_CONTROL, WBSCL_H_NUM_OF_TAPS_Y_RGB, h_taps_luma - 1);
0755 REG_UPDATE(WBSCL_TAP_CONTROL, WBSCL_H_NUM_OF_TAPS_CBCR, h_taps_chroma - 1);
0756
0757
0758 tmp_h_init_phase_luma = dc_fixpt_add_int(tmp_h_ratio_luma, h_taps_luma + 1);
0759 tmp_h_init_phase_luma = dc_fixpt_div_int(tmp_h_init_phase_luma, 2);
0760 tmp_h_init_phase_luma = dc_fixpt_sub_int(tmp_h_init_phase_luma, h_taps_luma);
0761
0762 h_init_phase_luma = dc_fixpt_s4d19(tmp_h_init_phase_luma);
0763 h_init_phase_luma_int = (h_init_phase_luma >> 19) & 0x1f;
0764 h_init_phase_luma_frac = (h_init_phase_luma & 0x7ffff) << 5;
0765
0766 tmp_h_init_phase_chroma = dc_fixpt_mul_int(tmp_h_ratio_luma, 2);
0767 tmp_h_init_phase_chroma = dc_fixpt_add_int(tmp_h_init_phase_chroma, h_taps_chroma + 1);
0768 tmp_h_init_phase_chroma = dc_fixpt_div_int(tmp_h_init_phase_chroma, 2);
0769 tmp_h_init_phase_chroma = dc_fixpt_sub_int(tmp_h_init_phase_chroma, h_taps_chroma);
0770 tmp_h_init_phase_chroma = dc_fixpt_add(tmp_h_init_phase_chroma, dc_fixpt_from_fraction(1, 4));
0771
0772 h_init_phase_chroma = dc_fixpt_s4d19(tmp_h_init_phase_chroma);
0773 h_init_phase_chroma_int = (h_init_phase_chroma >> 19) & 0x1f;
0774 h_init_phase_chroma_frac = (h_init_phase_chroma & 0x7ffff) << 5;
0775
0776
0777 REG_UPDATE(WBSCL_HORZ_FILTER_INIT_Y_RGB, WBSCL_H_INIT_INT_Y_RGB, h_init_phase_luma_int);
0778 REG_UPDATE(WBSCL_HORZ_FILTER_INIT_Y_RGB, WBSCL_H_INIT_FRAC_Y_RGB, h_init_phase_luma_frac);
0779 REG_UPDATE(WBSCL_HORZ_FILTER_INIT_CBCR, WBSCL_H_INIT_INT_CBCR, h_init_phase_chroma_int);
0780 REG_UPDATE(WBSCL_HORZ_FILTER_INIT_CBCR, WBSCL_H_INIT_FRAC_CBCR, h_init_phase_chroma_frac);
0781
0782
0783 filter_h = wbscl_get_filter_coeffs_16p(
0784 h_taps_luma, tmp_h_ratio_luma);
0785 filter_h_c = wbscl_get_filter_coeffs_16p(
0786 h_taps_chroma, dc_fixpt_from_int(h_ratio_luma * 2));
0787
0788 wbscl_set_scaler_filter(dwbc20, h_taps_luma,
0789 WBSCL_COEF_LUMA_HORZ_FILTER, filter_h);
0790
0791 wbscl_set_scaler_filter(dwbc20, h_taps_chroma,
0792 WBSCL_COEF_CHROMA_HORZ_FILTER, filter_h_c);
0793
0794 return true;
0795 }
0796
0797 bool dwb_program_vert_scalar(struct dcn20_dwbc *dwbc20,
0798 uint32_t src_height,
0799 uint32_t dest_height,
0800 struct scaling_taps num_taps,
0801 enum dwb_subsample_position subsample_position)
0802 {
0803 uint32_t v_ratio_luma = 1;
0804 uint32_t v_taps_luma = num_taps.v_taps;
0805 uint32_t v_taps_chroma = num_taps.v_taps_c;
0806 int32_t v_init_phase_luma = 0;
0807 int32_t v_init_phase_chroma = 0;
0808 uint32_t v_init_phase_luma_int = 0;
0809 uint32_t v_init_phase_luma_frac = 0;
0810 uint32_t v_init_phase_chroma_int = 0;
0811 uint32_t v_init_phase_chroma_frac = 0;
0812
0813 const uint16_t *filter_v = NULL;
0814 const uint16_t *filter_v_c = NULL;
0815
0816 struct fixed31_32 tmp_v_init_phase_luma = dc_fixpt_from_int(0);
0817 struct fixed31_32 tmp_v_init_phase_chroma = dc_fixpt_from_int(0);
0818
0819
0820 struct fixed31_32 tmp_v_ratio_luma = dc_fixpt_from_fraction(
0821 src_height, dest_height);
0822
0823 if (dc_fixpt_floor(tmp_v_ratio_luma) == 8)
0824 v_ratio_luma = -1;
0825 else
0826 v_ratio_luma = dc_fixpt_u3d19(tmp_v_ratio_luma) << 5;
0827
0828
0829 REG_UPDATE(WBSCL_VERT_FILTER_SCALE_RATIO, WBSCL_V_SCALE_RATIO, v_ratio_luma);
0830
0831
0832 REG_UPDATE(WBSCL_TAP_CONTROL, WBSCL_V_NUM_OF_TAPS_Y_RGB, v_taps_luma - 1);
0833 REG_UPDATE(WBSCL_TAP_CONTROL, WBSCL_V_NUM_OF_TAPS_CBCR, v_taps_chroma - 1);
0834
0835
0836 tmp_v_init_phase_luma = dc_fixpt_add_int(tmp_v_ratio_luma, v_taps_luma + 1);
0837 tmp_v_init_phase_luma = dc_fixpt_div_int(tmp_v_init_phase_luma, 2);
0838 tmp_v_init_phase_luma = dc_fixpt_sub_int(tmp_v_init_phase_luma, v_taps_luma);
0839
0840 v_init_phase_luma = dc_fixpt_s4d19(tmp_v_init_phase_luma);
0841 v_init_phase_luma_int = (v_init_phase_luma >> 19) & 0x1f;
0842 v_init_phase_luma_frac = (v_init_phase_luma & 0x7ffff) << 5;
0843
0844 tmp_v_init_phase_chroma = dc_fixpt_mul_int(tmp_v_ratio_luma, 2);
0845 tmp_v_init_phase_chroma = dc_fixpt_add_int(tmp_v_init_phase_chroma, v_taps_chroma + 1);
0846 tmp_v_init_phase_chroma = dc_fixpt_div_int(tmp_v_init_phase_chroma, 2);
0847 tmp_v_init_phase_chroma = dc_fixpt_sub_int(tmp_v_init_phase_chroma, v_taps_chroma);
0848 if (subsample_position == DWB_COSITED_SUBSAMPLING)
0849 tmp_v_init_phase_chroma = dc_fixpt_add(tmp_v_init_phase_chroma, dc_fixpt_from_fraction(1, 4));
0850
0851 v_init_phase_chroma = dc_fixpt_s4d19(tmp_v_init_phase_chroma);
0852 v_init_phase_chroma_int = (v_init_phase_chroma >> 19) & 0x1f;
0853 v_init_phase_chroma_frac = (v_init_phase_chroma & 0x7ffff) << 5;
0854
0855
0856 REG_UPDATE(WBSCL_VERT_FILTER_INIT_Y_RGB, WBSCL_V_INIT_INT_Y_RGB, v_init_phase_luma_int);
0857 REG_UPDATE(WBSCL_VERT_FILTER_INIT_Y_RGB, WBSCL_V_INIT_FRAC_Y_RGB, v_init_phase_luma_frac);
0858 REG_UPDATE(WBSCL_VERT_FILTER_INIT_CBCR, WBSCL_V_INIT_INT_CBCR, v_init_phase_chroma_int);
0859 REG_UPDATE(WBSCL_VERT_FILTER_INIT_CBCR, WBSCL_V_INIT_FRAC_CBCR, v_init_phase_chroma_frac);
0860
0861
0862
0863 filter_v = wbscl_get_filter_coeffs_16p(
0864 v_taps_luma, tmp_v_ratio_luma);
0865 filter_v_c = wbscl_get_filter_coeffs_16p(
0866 v_taps_chroma, dc_fixpt_from_int(v_ratio_luma * 2));
0867 wbscl_set_scaler_filter(dwbc20, v_taps_luma,
0868 WBSCL_COEF_LUMA_VERT_FILTER, filter_v);
0869
0870 wbscl_set_scaler_filter(dwbc20, v_taps_chroma,
0871 WBSCL_COEF_CHROMA_VERT_FILTER, filter_v_c);
0872 return true;
0873 }