/*
* Copyright (C) 2017 Jernej Skrabec <jernej.skrabec@siol.net>
*
* Coefficients are taken from BSP driver, which is:
* Copyright (C) 2014-2015 Allwinner
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#include "sun8i_ui_scaler.h"
#include "sun8i_vi_scaler.h"
static const u32 lan2coefftab16[240 ] = {
0 x00004000, 0 x00033ffe, 0 x00063efc, 0 x000a3bfb,
0 xff0f37fb, 0 xfe1433fb, 0 xfd192ffb, 0 xfd1f29fb,
0 xfc2424fc, 0 xfb291ffd, 0 xfb2f19fd, 0 xfb3314fe,
0 xfb370fff, 0 xfb3b0a00, 0 xfc3e0600, 0 xfe3f0300,
0 xff053804, 0 xff083801, 0 xff0a3700, 0 xff0e34ff,
0 xff1232fd, 0 xfe162ffd, 0 xfd1b2cfc, 0 xfd1f28fc,
0 xfd2323fd, 0 xfc281ffd, 0 xfc2c1bfd, 0 xfd2f16fe,
0 xfd3212ff, 0 xff340eff, 0 x00360a00, 0 x02370700,
0 xff083207, 0 xff0a3205, 0 xff0d3103, 0 xfe113001,
0 xfe142e00, 0 xfe182bff, 0 xfe1b29fe, 0 xfe1f25fe,
0 xfe2222fe, 0 xfe251ffe, 0 xfe291bfe, 0 xff2b18fe,
0 x002e14fe, 0 x013010ff, 0 x03310dff, 0 x05310a00,
0 xff0a2e09, 0 xff0c2e07, 0 xff0f2d05, 0 xff122c03,
0 xfe152b02, 0 xfe182901, 0 xfe1b2700, 0 xff1e24ff,
0 xff2121ff, 0 xff241eff, 0 x00261bff, 0 x012818ff,
0 x022a15ff, 0 x032c12ff, 0 x052d0fff, 0 x072d0c00,
0 xff0c2a0b, 0 xff0e2a09, 0 xff102a07, 0 xff132905,
0 xff162803, 0 xff182702, 0 xff1b2501, 0 xff1e2300,
0 x00202000, 0 x01221d00, 0 x01251bff, 0 x032618ff,
0 x042815ff, 0 x052913ff, 0 x072a10ff, 0 x092a0d00,
0 xff0d280c, 0 xff0f280a, 0 xff112808, 0 xff142706,
0 xff162605, 0 xff192503, 0 x001b2302, 0 x001d2201,
0 x011f1f01, 0 x01221d00, 0 x02231b00, 0 x04241800,
0 x052616ff, 0 x072713ff, 0 x08271100, 0 x0a280e00,
0 xff0e260d, 0 xff10260b, 0 xff122609, 0 xff142508,
0 x00152506, 0 x00182305, 0 x001b2203, 0 x011d2002,
0 x011f1f01, 0 x02201d01, 0 x03221b00, 0 x04231801,
0 x06241600, 0 x08251300, 0 x09261100, 0 x0b260f00,
0 xff0e250e, 0 xff10250c, 0 x0011250a, 0 x00142408,
0 x00162307, 0 x00182206, 0 x011a2104, 0 x011c2003,
0 x021e1e02, 0 x03201c01, 0 x04211a01, 0 x05221801,
0 x07231600, 0 x08241400, 0 x0a241200, 0 x0c241000,
0 x000e240e, 0 x0010240c, 0 x0013230a, 0 x00142309,
0 x00162208, 0 x01182106, 0 x011a2005, 0 x021b1f04,
0 x031d1d03, 0 x041e1c02, 0 x05201a01, 0 x06211801,
0 x07221601, 0 x09231400, 0 x0a231300, 0 x0c231100,
0 x000f220f, 0 x0011220d, 0 x0013220b, 0 x0015210a,
0 x01162108, 0 x01182007, 0 x02191f06, 0 x031a1e05,
0 x041c1c04, 0 x051d1b03, 0 x061f1902, 0 x07201801,
0 x08211601, 0 x0a211500, 0 x0b221300, 0 x0d221100,
0 x0010210f, 0 x0011210e, 0 x0013210c, 0 x0114200b,
0 x01161f0a, 0 x02171f08, 0 x03181e07, 0 x031a1d06,
0 x041c1c04, 0 x051d1a04, 0 x071d1903, 0 x081e1802,
0 x091f1602, 0 x0b1f1501, 0 x0c211300, 0 x0e201200,
0 x00102010, 0 x0012200e, 0 x0013200d, 0 x01151f0b,
0 x01161f0a, 0 x02171e09, 0 x03191d07, 0 x041a1c06,
0 x051b1b05, 0 x061c1a04, 0 x071d1903, 0 x081e1703,
0 x0a1f1601, 0 x0b1f1501, 0 x0d201300, 0 x0e201200,
0 x00102010, 0 x00121f0f, 0 x00141f0d, 0 x01141f0c,
0 x02161e0a, 0 x03171d09, 0 x03181d08, 0 x041a1c06,
0 x051b1b05, 0 x061c1a04, 0 x081c1903, 0 x091d1703,
0 x0a1e1602, 0 x0c1e1501, 0 x0d1f1400, 0 x0e1f1201,
0 x00111e11, 0 x00131e0f, 0 x01131e0e, 0 x02151d0c,
0 x02161d0b, 0 x03171c0a, 0 x04181b09, 0 x05191b07,
0 x061a1a06, 0 x071b1905, 0 x091b1804, 0 x0a1c1703,
0 x0b1d1602, 0 x0c1d1502, 0 x0e1d1401, 0 x0f1e1300,
0 x00111e11, 0 x00131d10, 0 x01141d0e, 0 x02151c0d,
0 x03161c0b, 0 x04171b0a, 0 x05171b09, 0 x06181a08,
0 x07191907, 0 x081a1806, 0 x091a1805, 0 x0a1b1704,
0 x0b1c1603, 0 x0d1c1502, 0 x0e1d1401, 0 x0f1d1301,
};
static u32 sun8i_ui_scaler_base(struct sun8i_mixer *mixer, int channel)
{
int vi_num = mixer->cfg->vi_num;
if (mixer->cfg->de_type == SUN8I_MIXER_DE3)
return DE3_VI_SCALER_UNIT_BASE +
DE3_VI_SCALER_UNIT_SIZE * vi_num +
DE3_UI_SCALER_UNIT_SIZE * (channel - vi_num);
else
return DE2_VI_SCALER_UNIT_BASE +
DE2_VI_SCALER_UNIT_SIZE * vi_num +
DE2_UI_SCALER_UNIT_SIZE * (channel - vi_num);
}
static int sun8i_ui_scaler_coef_index(unsigned int step)
{
unsigned int scale, int_part, float_part;
scale = step >> (SUN8I_UI_SCALER_SCALE_FRAC - 3 );
int_part = scale >> 3 ;
float_part = scale & 0 x7;
switch (int_part) {
case 0 :
return 0 ;
case 1 :
return float_part;
case 2 :
return 8 + (float_part >> 1 );
case 3 :
return 12 ;
case 4 :
return 13 ;
default :
return 14 ;
}
}
void sun8i_ui_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable)
{
u32 val, base;
if (WARN_ON(layer < mixer->cfg->vi_num))
return ;
base = sun8i_ui_scaler_base(mixer, layer);
if (enable)
val = SUN8I_SCALER_GSU_CTRL_EN |
SUN8I_SCALER_GSU_CTRL_COEFF_RDY;
else
val = 0 ;
regmap_write(mixer->engine.regs, SUN8I_SCALER_GSU_CTRL(base), val);
}
void sun8i_ui_scaler_setup(struct sun8i_mixer *mixer, int layer,
u32 src_w, u32 src_h, u32 dst_w, u32 dst_h,
u32 hscale, u32 vscale, u32 hphase, u32 vphase)
{
u32 insize, outsize;
int i, offset;
u32 base;
if (WARN_ON(layer < mixer->cfg->vi_num))
return ;
base = sun8i_ui_scaler_base(mixer, layer);
hphase <<= SUN8I_UI_SCALER_PHASE_FRAC - 16 ;
vphase <<= SUN8I_UI_SCALER_PHASE_FRAC - 16 ;
hscale <<= SUN8I_UI_SCALER_SCALE_FRAC - 16 ;
vscale <<= SUN8I_UI_SCALER_SCALE_FRAC - 16 ;
insize = SUN8I_UI_SCALER_SIZE(src_w, src_h);
outsize = SUN8I_UI_SCALER_SIZE(dst_w, dst_h);
regmap_write(mixer->engine.regs,
SUN8I_SCALER_GSU_OUTSIZE(base), outsize);
regmap_write(mixer->engine.regs,
SUN8I_SCALER_GSU_INSIZE(base), insize);
regmap_write(mixer->engine.regs,
SUN8I_SCALER_GSU_HSTEP(base), hscale);
regmap_write(mixer->engine.regs,
SUN8I_SCALER_GSU_VSTEP(base), vscale);
regmap_write(mixer->engine.regs,
SUN8I_SCALER_GSU_HPHASE(base), hphase);
regmap_write(mixer->engine.regs,
SUN8I_SCALER_GSU_VPHASE(base), vphase);
offset = sun8i_ui_scaler_coef_index(hscale) *
SUN8I_UI_SCALER_COEFF_COUNT;
for (i = 0 ; i < SUN8I_UI_SCALER_COEFF_COUNT; i++)
regmap_write(mixer->engine.regs,
SUN8I_SCALER_GSU_HCOEFF(base, i),
lan2coefftab16[offset + i]);
}
Messung V0.5 in Prozent C=95 H=92 G=93
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-08)
¤
*© Formatika GbR, Deutschland