.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2017 Icenowy Zheng <icenowy@aosc.io> |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or |
---|
5 | | - * modify it under the terms of the GNU General Public License as |
---|
6 | | - * published by the Free Software Foundation; either version 2 of |
---|
7 | | - * the License, or (at your option) any later version. |
---|
8 | 4 | */ |
---|
9 | 5 | |
---|
10 | 6 | #ifndef _SUN8I_MIXER_H_ |
---|
.. | .. |
---|
14 | 10 | #include <linux/regmap.h> |
---|
15 | 11 | #include <linux/reset.h> |
---|
16 | 12 | |
---|
17 | | -#include "sun8i_csc.h" |
---|
18 | 13 | #include "sunxi_engine.h" |
---|
19 | 14 | |
---|
20 | 15 | #define SUN8I_MIXER_SIZE(w, h) (((h) - 1) << 16 | ((w) - 1)) |
---|
.. | .. |
---|
29 | 24 | |
---|
30 | 25 | #define SUN8I_MIXER_GLOBAL_DBUFF_ENABLE BIT(0) |
---|
31 | 26 | |
---|
32 | | -#define SUN8I_MIXER_BLEND_PIPE_CTL 0x1000 |
---|
33 | | -#define SUN8I_MIXER_BLEND_ATTR_FCOLOR(x) (0x1004 + 0x10 * (x) + 0x0) |
---|
34 | | -#define SUN8I_MIXER_BLEND_ATTR_INSIZE(x) (0x1004 + 0x10 * (x) + 0x4) |
---|
35 | | -#define SUN8I_MIXER_BLEND_ATTR_COORD(x) (0x1004 + 0x10 * (x) + 0x8) |
---|
36 | | -#define SUN8I_MIXER_BLEND_ROUTE 0x1080 |
---|
37 | | -#define SUN8I_MIXER_BLEND_PREMULTIPLY 0x1084 |
---|
38 | | -#define SUN8I_MIXER_BLEND_BKCOLOR 0x1088 |
---|
39 | | -#define SUN8I_MIXER_BLEND_OUTSIZE 0x108c |
---|
40 | | -#define SUN8I_MIXER_BLEND_MODE(x) (0x1090 + 0x04 * (x)) |
---|
41 | | -#define SUN8I_MIXER_BLEND_CK_CTL 0x10b0 |
---|
42 | | -#define SUN8I_MIXER_BLEND_CK_CFG 0x10b4 |
---|
43 | | -#define SUN8I_MIXER_BLEND_CK_MAX(x) (0x10c0 + 0x04 * (x)) |
---|
44 | | -#define SUN8I_MIXER_BLEND_CK_MIN(x) (0x10e0 + 0x04 * (x)) |
---|
45 | | -#define SUN8I_MIXER_BLEND_OUTCTL 0x10fc |
---|
| 27 | +#define DE2_MIXER_UNIT_SIZE 0x6000 |
---|
| 28 | +#define DE3_MIXER_UNIT_SIZE 0x3000 |
---|
| 29 | + |
---|
| 30 | +#define DE2_BLD_BASE 0x1000 |
---|
| 31 | +#define DE2_CH_BASE 0x2000 |
---|
| 32 | +#define DE2_CH_SIZE 0x1000 |
---|
| 33 | + |
---|
| 34 | +#define DE3_BLD_BASE 0x0800 |
---|
| 35 | +#define DE3_CH_BASE 0x1000 |
---|
| 36 | +#define DE3_CH_SIZE 0x0800 |
---|
| 37 | + |
---|
| 38 | +#define SUN8I_MIXER_BLEND_PIPE_CTL(base) ((base) + 0) |
---|
| 39 | +#define SUN8I_MIXER_BLEND_ATTR_FCOLOR(base, x) ((base) + 0x4 + 0x10 * (x)) |
---|
| 40 | +#define SUN8I_MIXER_BLEND_ATTR_INSIZE(base, x) ((base) + 0x8 + 0x10 * (x)) |
---|
| 41 | +#define SUN8I_MIXER_BLEND_ATTR_COORD(base, x) ((base) + 0xc + 0x10 * (x)) |
---|
| 42 | +#define SUN8I_MIXER_BLEND_ROUTE(base) ((base) + 0x80) |
---|
| 43 | +#define SUN8I_MIXER_BLEND_PREMULTIPLY(base) ((base) + 0x84) |
---|
| 44 | +#define SUN8I_MIXER_BLEND_BKCOLOR(base) ((base) + 0x88) |
---|
| 45 | +#define SUN8I_MIXER_BLEND_OUTSIZE(base) ((base) + 0x8c) |
---|
| 46 | +#define SUN8I_MIXER_BLEND_MODE(base, x) ((base) + 0x90 + 0x04 * (x)) |
---|
| 47 | +#define SUN8I_MIXER_BLEND_CK_CTL(base) ((base) + 0xb0) |
---|
| 48 | +#define SUN8I_MIXER_BLEND_CK_CFG(base) ((base) + 0xb4) |
---|
| 49 | +#define SUN8I_MIXER_BLEND_CK_MAX(base, x) ((base) + 0xc0 + 0x04 * (x)) |
---|
| 50 | +#define SUN8I_MIXER_BLEND_CK_MIN(base, x) ((base) + 0xe0 + 0x04 * (x)) |
---|
| 51 | +#define SUN8I_MIXER_BLEND_OUTCTL(base) ((base) + 0xfc) |
---|
| 52 | +#define SUN50I_MIXER_BLEND_CSC_CTL(base) ((base) + 0x100) |
---|
| 53 | +#define SUN50I_MIXER_BLEND_CSC_COEFF(base, layer, x, y) \ |
---|
| 54 | + ((base) + 0x110 + (layer) * 0x30 + (x) * 0x10 + 4 * (y)) |
---|
| 55 | +#define SUN50I_MIXER_BLEND_CSC_CONST(base, layer, i) \ |
---|
| 56 | + ((base) + 0x110 + (layer) * 0x30 + (i) * 0x10 + 0x0c) |
---|
46 | 57 | |
---|
47 | 58 | #define SUN8I_MIXER_BLEND_PIPE_CTL_EN_MSK GENMASK(12, 8) |
---|
48 | 59 | #define SUN8I_MIXER_BLEND_PIPE_CTL_EN(pipe) BIT(8 + pipe) |
---|
49 | 60 | #define SUN8I_MIXER_BLEND_PIPE_CTL_FC_EN(pipe) BIT(pipe) |
---|
| 61 | + |
---|
50 | 62 | /* colors are always in AARRGGBB format */ |
---|
51 | 63 | #define SUN8I_MIXER_BLEND_COLOR_BLACK 0xff000000 |
---|
52 | 64 | /* The following numbers are some still unknown magic numbers */ |
---|
.. | .. |
---|
56 | 68 | #define SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(n) ((n) << 2) |
---|
57 | 69 | |
---|
58 | 70 | #define SUN8I_MIXER_BLEND_OUTCTL_INTERLACED BIT(1) |
---|
| 71 | + |
---|
| 72 | +#define SUN50I_MIXER_BLEND_CSC_CTL_EN(ch) BIT(ch) |
---|
| 73 | +#define SUN50I_MIXER_BLEND_CSC_CONST_VAL(d, c) (((d) << 16) | ((c) & 0xffff)) |
---|
59 | 74 | |
---|
60 | 75 | #define SUN8I_MIXER_FBFMT_ARGB8888 0 |
---|
61 | 76 | #define SUN8I_MIXER_FBFMT_ABGR8888 1 |
---|
.. | .. |
---|
77 | 92 | #define SUN8I_MIXER_FBFMT_ABGR1555 17 |
---|
78 | 93 | #define SUN8I_MIXER_FBFMT_RGBA5551 18 |
---|
79 | 94 | #define SUN8I_MIXER_FBFMT_BGRA5551 19 |
---|
| 95 | +#define SUN8I_MIXER_FBFMT_ARGB2101010 20 |
---|
| 96 | +#define SUN8I_MIXER_FBFMT_ABGR2101010 21 |
---|
| 97 | +#define SUN8I_MIXER_FBFMT_RGBA1010102 22 |
---|
| 98 | +#define SUN8I_MIXER_FBFMT_BGRA1010102 23 |
---|
80 | 99 | |
---|
81 | 100 | #define SUN8I_MIXER_FBFMT_YUYV 0 |
---|
82 | 101 | #define SUN8I_MIXER_FBFMT_UYVY 1 |
---|
.. | .. |
---|
93 | 112 | /* format 12 is semi-planar YUV411 UVUV */ |
---|
94 | 113 | /* format 13 is semi-planar YUV411 VUVU */ |
---|
95 | 114 | #define SUN8I_MIXER_FBFMT_YUV411 14 |
---|
| 115 | +/* format 15 doesn't exist */ |
---|
| 116 | +#define SUN8I_MIXER_FBFMT_P010_YUV 16 |
---|
| 117 | +/* format 17 is P010 YVU */ |
---|
| 118 | +#define SUN8I_MIXER_FBFMT_P210_YUV 18 |
---|
| 119 | +/* format 19 is P210 YVU */ |
---|
| 120 | +/* format 20 is packed YVU444 10-bit */ |
---|
| 121 | +/* format 21 is packed YUV444 10-bit */ |
---|
96 | 122 | |
---|
97 | 123 | /* |
---|
98 | | - * These sub-engines are still unknown now, the EN registers are here only to |
---|
99 | | - * be used to disable these sub-engines. |
---|
| 124 | + * Sub-engines listed bellow are unused for now. The EN registers are here only |
---|
| 125 | + * to be used to disable these sub-engines. |
---|
100 | 126 | */ |
---|
101 | 127 | #define SUN8I_MIXER_FCE_EN 0xa0000 |
---|
102 | 128 | #define SUN8I_MIXER_BWS_EN 0xa2000 |
---|
.. | .. |
---|
106 | 132 | #define SUN8I_MIXER_FCC_EN 0xaa000 |
---|
107 | 133 | #define SUN8I_MIXER_DCSC_EN 0xb0000 |
---|
108 | 134 | |
---|
109 | | -struct de2_fmt_info { |
---|
110 | | - u32 drm_fmt; |
---|
111 | | - u32 de2_fmt; |
---|
112 | | - bool rgb; |
---|
113 | | - enum sun8i_csc_mode csc; |
---|
114 | | -}; |
---|
| 135 | +#define SUN50I_MIXER_FCE_EN 0x70000 |
---|
| 136 | +#define SUN50I_MIXER_PEAK_EN 0x70800 |
---|
| 137 | +#define SUN50I_MIXER_LCTI_EN 0x71000 |
---|
| 138 | +#define SUN50I_MIXER_BLS_EN 0x71800 |
---|
| 139 | +#define SUN50I_MIXER_FCC_EN 0x72000 |
---|
| 140 | +#define SUN50I_MIXER_DNS_EN 0x80000 |
---|
| 141 | +#define SUN50I_MIXER_DRC_EN 0xa0000 |
---|
| 142 | +#define SUN50I_MIXER_FMT_EN 0xa8000 |
---|
| 143 | +#define SUN50I_MIXER_CDC0_EN 0xd0000 |
---|
| 144 | +#define SUN50I_MIXER_CDC1_EN 0xd8000 |
---|
115 | 145 | |
---|
116 | 146 | /** |
---|
117 | 147 | * struct sun8i_mixer_cfg - mixer HW configuration |
---|
.. | .. |
---|
127 | 157 | * are invalid. |
---|
128 | 158 | * @mod_rate: module clock rate that needs to be set in order to have |
---|
129 | 159 | * a functional block. |
---|
| 160 | + * @is_de3: true, if this is next gen display engine 3.0, false otherwise. |
---|
| 161 | + * @scaline_yuv: size of a scanline for VI scaler for YUV formats. |
---|
130 | 162 | */ |
---|
131 | 163 | struct sun8i_mixer_cfg { |
---|
132 | 164 | int vi_num; |
---|
.. | .. |
---|
134 | 166 | int scaler_mask; |
---|
135 | 167 | int ccsc; |
---|
136 | 168 | unsigned long mod_rate; |
---|
| 169 | + unsigned int is_de3 : 1; |
---|
| 170 | + unsigned int scanline_yuv; |
---|
137 | 171 | }; |
---|
138 | 172 | |
---|
139 | 173 | struct sun8i_mixer { |
---|
.. | .. |
---|
153 | 187 | return container_of(engine, struct sun8i_mixer, engine); |
---|
154 | 188 | } |
---|
155 | 189 | |
---|
156 | | -const struct de2_fmt_info *sun8i_mixer_format_info(u32 format); |
---|
| 190 | +static inline u32 |
---|
| 191 | +sun8i_blender_base(struct sun8i_mixer *mixer) |
---|
| 192 | +{ |
---|
| 193 | + return mixer->cfg->is_de3 ? DE3_BLD_BASE : DE2_BLD_BASE; |
---|
| 194 | +} |
---|
| 195 | + |
---|
| 196 | +static inline u32 |
---|
| 197 | +sun8i_channel_base(struct sun8i_mixer *mixer, int channel) |
---|
| 198 | +{ |
---|
| 199 | + if (mixer->cfg->is_de3) |
---|
| 200 | + return DE3_CH_BASE + channel * DE3_CH_SIZE; |
---|
| 201 | + else |
---|
| 202 | + return DE2_CH_BASE + channel * DE2_CH_SIZE; |
---|
| 203 | +} |
---|
| 204 | + |
---|
| 205 | +int sun8i_mixer_drm_format_to_hw(u32 format, u32 *hw_format); |
---|
157 | 206 | #endif /* _SUN8I_MIXER_H_ */ |
---|