| .. | .. |
|---|
| 10 | 10 | */ |
|---|
| 11 | 11 | |
|---|
| 12 | 12 | #include "sun8i_ui_scaler.h" |
|---|
| 13 | +#include "sun8i_vi_scaler.h" |
|---|
| 13 | 14 | |
|---|
| 14 | 15 | static const u32 lan2coefftab16[240] = { |
|---|
| 15 | 16 | 0x00004000, 0x00033ffe, 0x00063efc, 0x000a3bfb, |
|---|
| .. | .. |
|---|
| 88 | 89 | 0x0b1c1603, 0x0d1c1502, 0x0e1d1401, 0x0f1d1301, |
|---|
| 89 | 90 | }; |
|---|
| 90 | 91 | |
|---|
| 92 | +static u32 sun8i_ui_scaler_base(struct sun8i_mixer *mixer, int channel) |
|---|
| 93 | +{ |
|---|
| 94 | + int vi_num = mixer->cfg->vi_num; |
|---|
| 95 | + |
|---|
| 96 | + if (mixer->cfg->is_de3) |
|---|
| 97 | + return DE3_VI_SCALER_UNIT_BASE + |
|---|
| 98 | + DE3_VI_SCALER_UNIT_SIZE * vi_num + |
|---|
| 99 | + DE3_UI_SCALER_UNIT_SIZE * (channel - vi_num); |
|---|
| 100 | + else |
|---|
| 101 | + return DE2_VI_SCALER_UNIT_BASE + |
|---|
| 102 | + DE2_VI_SCALER_UNIT_SIZE * vi_num + |
|---|
| 103 | + DE2_UI_SCALER_UNIT_SIZE * (channel - vi_num); |
|---|
| 104 | +} |
|---|
| 105 | + |
|---|
| 91 | 106 | static int sun8i_ui_scaler_coef_index(unsigned int step) |
|---|
| 92 | 107 | { |
|---|
| 93 | 108 | unsigned int scale, int_part, float_part; |
|---|
| .. | .. |
|---|
| 114 | 129 | |
|---|
| 115 | 130 | void sun8i_ui_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable) |
|---|
| 116 | 131 | { |
|---|
| 117 | | - int vi_cnt = mixer->cfg->vi_num; |
|---|
| 118 | | - u32 val; |
|---|
| 132 | + u32 val, base; |
|---|
| 119 | 133 | |
|---|
| 120 | | - if (WARN_ON(layer < vi_cnt)) |
|---|
| 134 | + if (WARN_ON(layer < mixer->cfg->vi_num)) |
|---|
| 121 | 135 | return; |
|---|
| 136 | + |
|---|
| 137 | + base = sun8i_ui_scaler_base(mixer, layer); |
|---|
| 122 | 138 | |
|---|
| 123 | 139 | if (enable) |
|---|
| 124 | 140 | val = SUN8I_SCALER_GSU_CTRL_EN | |
|---|
| .. | .. |
|---|
| 126 | 142 | else |
|---|
| 127 | 143 | val = 0; |
|---|
| 128 | 144 | |
|---|
| 129 | | - regmap_write(mixer->engine.regs, |
|---|
| 130 | | - SUN8I_SCALER_GSU_CTRL(vi_cnt, layer - vi_cnt), val); |
|---|
| 145 | + regmap_write(mixer->engine.regs, SUN8I_SCALER_GSU_CTRL(base), val); |
|---|
| 131 | 146 | } |
|---|
| 132 | 147 | |
|---|
| 133 | 148 | void sun8i_ui_scaler_setup(struct sun8i_mixer *mixer, int layer, |
|---|
| 134 | 149 | u32 src_w, u32 src_h, u32 dst_w, u32 dst_h, |
|---|
| 135 | 150 | u32 hscale, u32 vscale, u32 hphase, u32 vphase) |
|---|
| 136 | 151 | { |
|---|
| 137 | | - int vi_cnt = mixer->cfg->vi_num; |
|---|
| 138 | 152 | u32 insize, outsize; |
|---|
| 139 | 153 | int i, offset; |
|---|
| 154 | + u32 base; |
|---|
| 140 | 155 | |
|---|
| 141 | | - if (WARN_ON(layer < vi_cnt)) |
|---|
| 156 | + if (WARN_ON(layer < mixer->cfg->vi_num)) |
|---|
| 142 | 157 | return; |
|---|
| 158 | + |
|---|
| 159 | + base = sun8i_ui_scaler_base(mixer, layer); |
|---|
| 143 | 160 | |
|---|
| 144 | 161 | hphase <<= SUN8I_UI_SCALER_PHASE_FRAC - 16; |
|---|
| 145 | 162 | vphase <<= SUN8I_UI_SCALER_PHASE_FRAC - 16; |
|---|
| .. | .. |
|---|
| 149 | 166 | insize = SUN8I_UI_SCALER_SIZE(src_w, src_h); |
|---|
| 150 | 167 | outsize = SUN8I_UI_SCALER_SIZE(dst_w, dst_h); |
|---|
| 151 | 168 | |
|---|
| 152 | | - layer -= vi_cnt; |
|---|
| 153 | | - |
|---|
| 154 | 169 | regmap_write(mixer->engine.regs, |
|---|
| 155 | | - SUN8I_SCALER_GSU_OUTSIZE(vi_cnt, layer), outsize); |
|---|
| 170 | + SUN8I_SCALER_GSU_OUTSIZE(base), outsize); |
|---|
| 156 | 171 | regmap_write(mixer->engine.regs, |
|---|
| 157 | | - SUN8I_SCALER_GSU_INSIZE(vi_cnt, layer), insize); |
|---|
| 172 | + SUN8I_SCALER_GSU_INSIZE(base), insize); |
|---|
| 158 | 173 | regmap_write(mixer->engine.regs, |
|---|
| 159 | | - SUN8I_SCALER_GSU_HSTEP(vi_cnt, layer), hscale); |
|---|
| 174 | + SUN8I_SCALER_GSU_HSTEP(base), hscale); |
|---|
| 160 | 175 | regmap_write(mixer->engine.regs, |
|---|
| 161 | | - SUN8I_SCALER_GSU_VSTEP(vi_cnt, layer), vscale); |
|---|
| 176 | + SUN8I_SCALER_GSU_VSTEP(base), vscale); |
|---|
| 162 | 177 | regmap_write(mixer->engine.regs, |
|---|
| 163 | | - SUN8I_SCALER_GSU_HPHASE(vi_cnt, layer), hphase); |
|---|
| 178 | + SUN8I_SCALER_GSU_HPHASE(base), hphase); |
|---|
| 164 | 179 | regmap_write(mixer->engine.regs, |
|---|
| 165 | | - SUN8I_SCALER_GSU_VPHASE(vi_cnt, layer), vphase); |
|---|
| 180 | + SUN8I_SCALER_GSU_VPHASE(base), vphase); |
|---|
| 166 | 181 | offset = sun8i_ui_scaler_coef_index(hscale) * |
|---|
| 167 | 182 | SUN8I_UI_SCALER_COEFF_COUNT; |
|---|
| 168 | 183 | for (i = 0; i < SUN8I_UI_SCALER_COEFF_COUNT; i++) |
|---|
| 169 | 184 | regmap_write(mixer->engine.regs, |
|---|
| 170 | | - SUN8I_SCALER_GSU_HCOEFF(vi_cnt, layer, i), |
|---|
| 185 | + SUN8I_SCALER_GSU_HCOEFF(base, i), |
|---|
| 171 | 186 | lan2coefftab16[offset + i]); |
|---|
| 172 | 187 | } |
|---|