1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 * Author: Chandrabhanu Mahapatra <cmahapatra@ti.com>
7 #include <linux/kernel.h>
12 static const struct dispc_coef coef3_M8
[8] = {
15 { 0, -4, 108, 24, 0 },
19 { 0, 24, 108, -4, 0 },
23 static const struct dispc_coef coef3_M9
[8] = {
26 { 0, -2, 100, 30, 0 },
30 { 0, 30, 100, -2, 0 },
34 static const struct dispc_coef coef3_M10
[8] = {
35 { 0, 10, 108, 10, 0 },
45 static const struct dispc_coef coef3_M11
[8] = {
46 { 0, 14, 100, 14, 0 },
56 static const struct dispc_coef coef3_M12
[8] = {
67 static const struct dispc_coef coef3_M13
[8] = {
78 static const struct dispc_coef coef3_M14
[8] = {
89 static const struct dispc_coef coef3_M16
[8] = {
100 static const struct dispc_coef coef3_M19
[8] = {
101 { 0, 24, 80, 24, 0 },
102 { 0, 16, 79, 33, 0 },
108 { 0, 33, 79, 16, 0 },
111 static const struct dispc_coef coef3_M22
[8] = {
112 { 0, 25, 78, 25, 0 },
113 { 0, 17, 77, 34, 0 },
114 { 0, 10, 74, 44, 0 },
118 { 0, 44, 74, 10, 0 },
119 { 0, 34, 77, 17, 0 },
122 static const struct dispc_coef coef3_M26
[8] = {
123 { 0, 26, 76, 26, 0 },
124 { 0, 19, 74, 35, 0 },
125 { 0, 11, 72, 45, 0 },
129 { 0, 45, 72, 11, 0 },
130 { 0, 35, 74, 19, 0 },
133 static const struct dispc_coef coef3_M32
[8] = {
134 { 0, 27, 74, 27, 0 },
135 { 0, 19, 73, 36, 0 },
136 { 0, 12, 71, 45, 0 },
140 { 0, 45, 71, 12, 0 },
141 { 0, 36, 73, 19, 0 },
144 static const struct dispc_coef coef5_M8
[8] = {
146 { -2, 14, 125, -10, 1 },
147 { -6, 33, 114, -15, 2 },
148 { -10, 55, 98, -16, 1 },
149 { 0, -14, 78, 78, -14 },
150 { 1, -16, 98, 55, -10 },
151 { 2, -15, 114, 33, -6 },
152 { 1, -10, 125, 14, -2 },
155 static const struct dispc_coef coef5_M9
[8] = {
156 { -3, 10, 114, 10, -3 },
157 { -6, 24, 111, 0, -1 },
158 { -8, 40, 103, -7, 0 },
159 { -11, 58, 91, -11, 1 },
160 { 0, -12, 76, 76, -12 },
161 { 1, -11, 91, 58, -11 },
162 { 0, -7, 103, 40, -8 },
163 { -1, 0, 111, 24, -6 },
166 static const struct dispc_coef coef5_M10
[8] = {
167 { -4, 18, 100, 18, -4 },
168 { -6, 30, 99, 8, -3 },
169 { -8, 44, 93, 0, -1 },
170 { -9, 58, 84, -5, 0 },
171 { 0, -8, 72, 72, -8 },
172 { 0, -5, 84, 58, -9 },
173 { -1, 0, 93, 44, -8 },
174 { -3, 8, 99, 30, -6 },
177 static const struct dispc_coef coef5_M11
[8] = {
178 { -5, 23, 92, 23, -5 },
179 { -6, 34, 90, 13, -3 },
180 { -6, 45, 85, 6, -2 },
181 { -6, 57, 78, 0, -1 },
182 { 0, -4, 68, 68, -4 },
183 { -1, 0, 78, 57, -6 },
184 { -2, 6, 85, 45, -6 },
185 { -3, 13, 90, 34, -6 },
188 static const struct dispc_coef coef5_M12
[8] = {
189 { -4, 26, 84, 26, -4 },
190 { -5, 36, 82, 18, -3 },
191 { -4, 46, 78, 10, -2 },
192 { -3, 55, 72, 5, -1 },
194 { -1, 5, 72, 55, -3 },
195 { -2, 10, 78, 46, -4 },
196 { -3, 18, 82, 36, -5 },
199 static const struct dispc_coef coef5_M13
[8] = {
200 { -3, 28, 78, 28, -3 },
201 { -3, 37, 76, 21, -3 },
202 { -2, 45, 73, 14, -2 },
203 { 0, 53, 68, 8, -1 },
205 { -1, 8, 68, 53, 0 },
206 { -2, 14, 73, 45, -2 },
207 { -3, 21, 76, 37, -3 },
210 static const struct dispc_coef coef5_M14
[8] = {
211 { -2, 30, 72, 30, -2 },
212 { -1, 37, 71, 23, -2 },
213 { 0, 45, 69, 16, -2 },
214 { 3, 52, 64, 10, -1 },
216 { -1, 10, 64, 52, 3 },
217 { -2, 16, 69, 45, 0 },
218 { -2, 23, 71, 37, -1 },
221 static const struct dispc_coef coef5_M16
[8] = {
222 { 0, 31, 66, 31, 0 },
223 { 1, 38, 65, 25, -1 },
224 { 3, 44, 62, 20, -1 },
225 { 6, 49, 59, 14, 0 },
226 { 0, 10, 54, 54, 10 },
227 { 0, 14, 59, 49, 6 },
228 { -1, 20, 62, 44, 3 },
229 { -1, 25, 65, 38, 1 },
232 static const struct dispc_coef coef5_M19
[8] = {
233 { 3, 32, 58, 32, 3 },
234 { 4, 38, 58, 27, 1 },
235 { 7, 42, 55, 23, 1 },
236 { 10, 46, 54, 18, 0 },
237 { 0, 14, 50, 50, 14 },
238 { 0, 18, 54, 46, 10 },
239 { 1, 23, 55, 42, 7 },
240 { 1, 27, 58, 38, 4 },
243 static const struct dispc_coef coef5_M22
[8] = {
244 { 4, 33, 54, 33, 4 },
245 { 6, 37, 54, 28, 3 },
246 { 9, 41, 53, 24, 1 },
247 { 12, 45, 51, 20, 0 },
248 { 0, 16, 48, 48, 16 },
249 { 0, 20, 51, 45, 12 },
250 { 1, 24, 53, 41, 9 },
251 { 3, 28, 54, 37, 6 },
254 static const struct dispc_coef coef5_M26
[8] = {
255 { 6, 33, 50, 33, 6 },
256 { 8, 36, 51, 29, 4 },
257 { 11, 40, 50, 25, 2 },
258 { 14, 43, 48, 22, 1 },
259 { 0, 18, 46, 46, 18 },
260 { 1, 22, 48, 43, 14 },
261 { 2, 25, 50, 40, 11 },
262 { 4, 29, 51, 36, 8 },
265 static const struct dispc_coef coef5_M32
[8] = {
266 { 7, 33, 48, 33, 7 },
267 { 10, 36, 48, 29, 5 },
268 { 13, 39, 47, 26, 3 },
269 { 16, 42, 46, 23, 1 },
270 { 0, 19, 45, 45, 19 },
271 { 1, 23, 46, 42, 16 },
272 { 3, 26, 47, 39, 13 },
273 { 5, 29, 48, 36, 10 },
276 const struct dispc_coef
*dispc_ovl_get_scale_coef(int inc
, int five_taps
)
279 static const struct {
282 const struct dispc_coef
*coef_3
;
283 const struct dispc_coef
*coef_5
;
285 { 27, 32, coef3_M32
, coef5_M32
},
286 { 23, 26, coef3_M26
, coef5_M26
},
287 { 20, 22, coef3_M22
, coef5_M22
},
288 { 17, 19, coef3_M19
, coef5_M19
},
289 { 15, 16, coef3_M16
, coef5_M16
},
290 { 14, 14, coef3_M14
, coef5_M14
},
291 { 13, 13, coef3_M13
, coef5_M13
},
292 { 12, 12, coef3_M12
, coef5_M12
},
293 { 11, 11, coef3_M11
, coef5_M11
},
294 { 10, 10, coef3_M10
, coef5_M10
},
295 { 9, 9, coef3_M9
, coef5_M9
},
296 { 4, 8, coef3_M8
, coef5_M8
},
298 * When upscaling more than two times, blockiness and outlines
299 * around the image are observed when M8 tables are used. M11,
300 * M16 and M19 tables are used to prevent this.
302 { 3, 3, coef3_M11
, coef5_M11
},
303 { 2, 2, coef3_M16
, coef5_M16
},
304 { 0, 1, coef3_M19
, coef5_M19
},
308 for (i
= 0; i
< ARRAY_SIZE(coefs
); ++i
)
309 if (inc
>= coefs
[i
].Mmin
&& inc
<= coefs
[i
].Mmax
)
310 return five_taps
? coefs
[i
].coef_5
: coefs
[i
].coef_3
;