| .. | .. |
|---|
| 833 | 833 | 0x1012110d, 0x1012110d, 0x1013110c, 0x1013110c, |
|---|
| 834 | 834 | }; |
|---|
| 835 | 835 | |
|---|
| 836 | +static u32 sun8i_vi_scaler_base(struct sun8i_mixer *mixer, int channel) |
|---|
| 837 | +{ |
|---|
| 838 | + if (mixer->cfg->is_de3) |
|---|
| 839 | + return DE3_VI_SCALER_UNIT_BASE + |
|---|
| 840 | + DE3_VI_SCALER_UNIT_SIZE * channel; |
|---|
| 841 | + else |
|---|
| 842 | + return DE2_VI_SCALER_UNIT_BASE + |
|---|
| 843 | + DE2_VI_SCALER_UNIT_SIZE * channel; |
|---|
| 844 | +} |
|---|
| 845 | + |
|---|
| 836 | 846 | static int sun8i_vi_scaler_coef_index(unsigned int step) |
|---|
| 837 | 847 | { |
|---|
| 838 | 848 | unsigned int scale, int_part, float_part; |
|---|
| .. | .. |
|---|
| 857 | 867 | } |
|---|
| 858 | 868 | } |
|---|
| 859 | 869 | |
|---|
| 860 | | -static void sun8i_vi_scaler_set_coeff(struct regmap *map, int layer, |
|---|
| 870 | +static void sun8i_vi_scaler_set_coeff(struct regmap *map, u32 base, |
|---|
| 861 | 871 | u32 hstep, u32 vstep, |
|---|
| 862 | 872 | const struct drm_format_info *format) |
|---|
| 863 | 873 | { |
|---|
| .. | .. |
|---|
| 877 | 887 | offset = sun8i_vi_scaler_coef_index(hstep) * |
|---|
| 878 | 888 | SUN8I_VI_SCALER_COEFF_COUNT; |
|---|
| 879 | 889 | for (i = 0; i < SUN8I_VI_SCALER_COEFF_COUNT; i++) { |
|---|
| 880 | | - regmap_write(map, SUN8I_SCALER_VSU_YHCOEFF0(layer, i), |
|---|
| 890 | + regmap_write(map, SUN8I_SCALER_VSU_YHCOEFF0(base, i), |
|---|
| 881 | 891 | lan3coefftab32_left[offset + i]); |
|---|
| 882 | | - regmap_write(map, SUN8I_SCALER_VSU_YHCOEFF1(layer, i), |
|---|
| 892 | + regmap_write(map, SUN8I_SCALER_VSU_YHCOEFF1(base, i), |
|---|
| 883 | 893 | lan3coefftab32_right[offset + i]); |
|---|
| 884 | | - regmap_write(map, SUN8I_SCALER_VSU_CHCOEFF0(layer, i), |
|---|
| 894 | + regmap_write(map, SUN8I_SCALER_VSU_CHCOEFF0(base, i), |
|---|
| 885 | 895 | ch_left[offset + i]); |
|---|
| 886 | | - regmap_write(map, SUN8I_SCALER_VSU_CHCOEFF1(layer, i), |
|---|
| 896 | + regmap_write(map, SUN8I_SCALER_VSU_CHCOEFF1(base, i), |
|---|
| 887 | 897 | ch_right[offset + i]); |
|---|
| 888 | 898 | } |
|---|
| 889 | 899 | |
|---|
| 890 | 900 | offset = sun8i_vi_scaler_coef_index(hstep) * |
|---|
| 891 | 901 | SUN8I_VI_SCALER_COEFF_COUNT; |
|---|
| 892 | 902 | for (i = 0; i < SUN8I_VI_SCALER_COEFF_COUNT; i++) { |
|---|
| 893 | | - regmap_write(map, SUN8I_SCALER_VSU_YVCOEFF(layer, i), |
|---|
| 903 | + regmap_write(map, SUN8I_SCALER_VSU_YVCOEFF(base, i), |
|---|
| 894 | 904 | lan2coefftab32[offset + i]); |
|---|
| 895 | | - regmap_write(map, SUN8I_SCALER_VSU_CVCOEFF(layer, i), |
|---|
| 905 | + regmap_write(map, SUN8I_SCALER_VSU_CVCOEFF(base, i), |
|---|
| 896 | 906 | cy[offset + i]); |
|---|
| 897 | 907 | } |
|---|
| 898 | 908 | } |
|---|
| 899 | 909 | |
|---|
| 900 | 910 | void sun8i_vi_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable) |
|---|
| 901 | 911 | { |
|---|
| 902 | | - u32 val; |
|---|
| 912 | + u32 val, base; |
|---|
| 913 | + |
|---|
| 914 | + base = sun8i_vi_scaler_base(mixer, layer); |
|---|
| 903 | 915 | |
|---|
| 904 | 916 | if (enable) |
|---|
| 905 | 917 | val = SUN8I_SCALER_VSU_CTRL_EN | |
|---|
| .. | .. |
|---|
| 907 | 919 | else |
|---|
| 908 | 920 | val = 0; |
|---|
| 909 | 921 | |
|---|
| 910 | | - regmap_write(mixer->engine.regs, SUN8I_SCALER_VSU_CTRL(layer), val); |
|---|
| 922 | + regmap_write(mixer->engine.regs, |
|---|
| 923 | + SUN8I_SCALER_VSU_CTRL(base), val); |
|---|
| 911 | 924 | } |
|---|
| 912 | 925 | |
|---|
| 913 | 926 | void sun8i_vi_scaler_setup(struct sun8i_mixer *mixer, int layer, |
|---|
| .. | .. |
|---|
| 917 | 930 | { |
|---|
| 918 | 931 | u32 chphase, cvphase; |
|---|
| 919 | 932 | u32 insize, outsize; |
|---|
| 933 | + u32 base; |
|---|
| 934 | + |
|---|
| 935 | + base = sun8i_vi_scaler_base(mixer, layer); |
|---|
| 920 | 936 | |
|---|
| 921 | 937 | hphase <<= SUN8I_VI_SCALER_PHASE_FRAC - 16; |
|---|
| 922 | 938 | vphase <<= SUN8I_VI_SCALER_PHASE_FRAC - 16; |
|---|
| .. | .. |
|---|
| 940 | 956 | cvphase = vphase; |
|---|
| 941 | 957 | } |
|---|
| 942 | 958 | |
|---|
| 959 | + if (mixer->cfg->is_de3) { |
|---|
| 960 | + u32 val; |
|---|
| 961 | + |
|---|
| 962 | + if (format->hsub == 1 && format->vsub == 1) |
|---|
| 963 | + val = SUN50I_SCALER_VSU_SCALE_MODE_UI; |
|---|
| 964 | + else |
|---|
| 965 | + val = SUN50I_SCALER_VSU_SCALE_MODE_NORMAL; |
|---|
| 966 | + |
|---|
| 967 | + regmap_write(mixer->engine.regs, |
|---|
| 968 | + SUN50I_SCALER_VSU_SCALE_MODE(base), val); |
|---|
| 969 | + } |
|---|
| 970 | + |
|---|
| 943 | 971 | regmap_write(mixer->engine.regs, |
|---|
| 944 | | - SUN8I_SCALER_VSU_OUTSIZE(layer), outsize); |
|---|
| 972 | + SUN8I_SCALER_VSU_OUTSIZE(base), outsize); |
|---|
| 945 | 973 | regmap_write(mixer->engine.regs, |
|---|
| 946 | | - SUN8I_SCALER_VSU_YINSIZE(layer), insize); |
|---|
| 974 | + SUN8I_SCALER_VSU_YINSIZE(base), insize); |
|---|
| 947 | 975 | regmap_write(mixer->engine.regs, |
|---|
| 948 | | - SUN8I_SCALER_VSU_YHSTEP(layer), hscale); |
|---|
| 976 | + SUN8I_SCALER_VSU_YHSTEP(base), hscale); |
|---|
| 949 | 977 | regmap_write(mixer->engine.regs, |
|---|
| 950 | | - SUN8I_SCALER_VSU_YVSTEP(layer), vscale); |
|---|
| 978 | + SUN8I_SCALER_VSU_YVSTEP(base), vscale); |
|---|
| 951 | 979 | regmap_write(mixer->engine.regs, |
|---|
| 952 | | - SUN8I_SCALER_VSU_YHPHASE(layer), hphase); |
|---|
| 980 | + SUN8I_SCALER_VSU_YHPHASE(base), hphase); |
|---|
| 953 | 981 | regmap_write(mixer->engine.regs, |
|---|
| 954 | | - SUN8I_SCALER_VSU_YVPHASE(layer), vphase); |
|---|
| 982 | + SUN8I_SCALER_VSU_YVPHASE(base), vphase); |
|---|
| 955 | 983 | regmap_write(mixer->engine.regs, |
|---|
| 956 | | - SUN8I_SCALER_VSU_CINSIZE(layer), |
|---|
| 984 | + SUN8I_SCALER_VSU_CINSIZE(base), |
|---|
| 957 | 985 | SUN8I_VI_SCALER_SIZE(src_w / format->hsub, |
|---|
| 958 | 986 | src_h / format->vsub)); |
|---|
| 959 | 987 | regmap_write(mixer->engine.regs, |
|---|
| 960 | | - SUN8I_SCALER_VSU_CHSTEP(layer), |
|---|
| 988 | + SUN8I_SCALER_VSU_CHSTEP(base), |
|---|
| 961 | 989 | hscale / format->hsub); |
|---|
| 962 | 990 | regmap_write(mixer->engine.regs, |
|---|
| 963 | | - SUN8I_SCALER_VSU_CVSTEP(layer), |
|---|
| 991 | + SUN8I_SCALER_VSU_CVSTEP(base), |
|---|
| 964 | 992 | vscale / format->vsub); |
|---|
| 965 | 993 | regmap_write(mixer->engine.regs, |
|---|
| 966 | | - SUN8I_SCALER_VSU_CHPHASE(layer), chphase); |
|---|
| 994 | + SUN8I_SCALER_VSU_CHPHASE(base), chphase); |
|---|
| 967 | 995 | regmap_write(mixer->engine.regs, |
|---|
| 968 | | - SUN8I_SCALER_VSU_CVPHASE(layer), cvphase); |
|---|
| 969 | | - sun8i_vi_scaler_set_coeff(mixer->engine.regs, layer, |
|---|
| 996 | + SUN8I_SCALER_VSU_CVPHASE(base), cvphase); |
|---|
| 997 | + sun8i_vi_scaler_set_coeff(mixer->engine.regs, base, |
|---|
| 970 | 998 | hscale, vscale, format); |
|---|
| 971 | 999 | } |
|---|