History

drm/sun4i: Rework DE2 register defines

Most, if not all, registers found in DE2 still exists in DE3. However, units are on different base addresses. To prepare for addition of DE3 support, registers macros are reworked so they take base address as parameter.

Jernej Skrabec committed 8 years ago

Commit 4b09c071 parent fb3ef5410 files · +219 −159Browse files

Unified · Split

10 files
  1. drivers/gpu/drm/sun4i/sun8i_mixer.c +9 −5
  2. drivers/gpu/drm/sun4i/sun8i_mixer.h +30 −14
  3. drivers/gpu/drm/sun4i/sun8i_ui_layer.c +30 −17
  4. drivers/gpu/drm/sun4i/sun8i_ui_layer.h +20 −17
  5. drivers/gpu/drm/sun4i/sun8i_ui_scaler.c +25 −16
  6. drivers/gpu/drm/sun4i/sun8i_ui_scaler.h +10 −17
  7. drivers/gpu/drm/sun4i/sun8i_vi_layer.c +30 −17
  8. drivers/gpu/drm/sun4i/sun8i_vi_layer.h +12 −11
  9. drivers/gpu/drm/sun4i/sun8i_vi_scaler.c +32 −21
  10. drivers/gpu/drm/sun4i/sun8i_vi_scaler.h +21 −24
drivers/gpu/drm/sun4i/sun8i_mixer.c+9−5
@@ -368,6 +368,7 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, · 367 unmodified lines
368 struct sun8i_mixer *mixer;368 struct sun8i_mixer *mixer;
369 struct resource *res;369 struct resource *res;
370 void __iomem *regs;370 void __iomem *regs;
371 unsigned int base;
371 int plane_cnt;372 int plane_cnt;
372 int i, ret;373 int i, ret;
373 374
@@ -456,6 +457,8 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, · 82 unmodified lines
456 457
457 list_add_tail(&mixer->engine.list, &drv->engine_list);458 list_add_tail(&mixer->engine.list, &drv->engine_list);
458 459
460 base = sun8i_blender_base(mixer);
461
459 /* Reset the registers */462 /* Reset the registers */
460 for (i = 0x0; i < 0x20000; i += 4)463 for (i = 0x0; i < 0x20000; i += 4)
461 regmap_write(mixer->engine.regs, i, 0);464 regmap_write(mixer->engine.regs, i, 0);
@@ -465,24 +468,25 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, · 3 unmodified lines
465 SUN8I_MIXER_GLOBAL_CTL_RT_EN);468 SUN8I_MIXER_GLOBAL_CTL_RT_EN);
466 469
467 /* Set background color to black */470 /* Set background color to black */
468 regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_BKCOLOR,471 regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_BKCOLOR(base),
469 SUN8I_MIXER_BLEND_COLOR_BLACK);472 SUN8I_MIXER_BLEND_COLOR_BLACK);
470 473
471 /*474 /*
472 * Set fill color of bottom plane to black. Generally not needed475 * Set fill color of bottom plane to black. Generally not needed
473 * except when VI plane is at bottom (zpos = 0) and enabled.476 * except when VI plane is at bottom (zpos = 0) and enabled.
474 */477 */
475 regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL,478 regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL(base),
476 SUN8I_MIXER_BLEND_PIPE_CTL_FC_EN(0));479 SUN8I_MIXER_BLEND_PIPE_CTL_FC_EN(0));
477 regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_ATTR_FCOLOR(0),480 regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_ATTR_FCOLOR(base, 0),
478 SUN8I_MIXER_BLEND_COLOR_BLACK);481 SUN8I_MIXER_BLEND_COLOR_BLACK);
479 482
480 plane_cnt = mixer->cfg->vi_num + mixer->cfg->ui_num;483 plane_cnt = mixer->cfg->vi_num + mixer->cfg->ui_num;
481 for (i = 0; i < plane_cnt; i++)484 for (i = 0; i < plane_cnt; i++)
482 regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_MODE(i),485 regmap_write(mixer->engine.regs,
486 SUN8I_MIXER_BLEND_MODE(base, i),
483 SUN8I_MIXER_BLEND_MODE_DEF);487 SUN8I_MIXER_BLEND_MODE_DEF);
484 488
485 regmap_update_bits(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL,489 regmap_update_bits(mixer->engine.regs, SUN8I_MIXER_BLEND_PIPE_CTL(base),
486 SUN8I_MIXER_BLEND_PIPE_CTL_EN_MSK, 0);490 SUN8I_MIXER_BLEND_PIPE_CTL_EN_MSK, 0);
487 491
488 return 0;492 return 0;
drivers/gpu/drm/sun4i/sun8i_mixer.h+30−14
@@ -29,20 +29,24 @@ · 28 unmodified lines
29 29
30#define SUN8I_MIXER_GLOBAL_DBUFF_ENABLE BIT(0)30#define SUN8I_MIXER_GLOBAL_DBUFF_ENABLE BIT(0)
31 31
32#define SUN8I_MIXER_BLEND_PIPE_CTL 0x100032#define DE2_BLD_BASE 0x1000
33#define SUN8I_MIXER_BLEND_ATTR_FCOLOR(x) (0x1004 + 0x10 * (x) + 0x0)33#define DE2_CH_BASE 0x2000
34#define SUN8I_MIXER_BLEND_ATTR_INSIZE(x) (0x1004 + 0x10 * (x) + 0x4)34#define DE2_CH_SIZE 0x1000
35#define SUN8I_MIXER_BLEND_ATTR_COORD(x) (0x1004 + 0x10 * (x) + 0x8)35
36#define SUN8I_MIXER_BLEND_ROUTE 0x108036#define SUN8I_MIXER_BLEND_PIPE_CTL(base) ((base) + 0)
37#define SUN8I_MIXER_BLEND_PREMULTIPLY 0x108437#define SUN8I_MIXER_BLEND_ATTR_FCOLOR(base, x) ((base) + 0x4 + 0x10 * (x))
38#define SUN8I_MIXER_BLEND_BKCOLOR 0x108838#define SUN8I_MIXER_BLEND_ATTR_INSIZE(base, x) ((base) + 0x8 + 0x10 * (x))
39#define SUN8I_MIXER_BLEND_OUTSIZE 0x108c39#define SUN8I_MIXER_BLEND_ATTR_COORD(base, x) ((base) + 0xc + 0x10 * (x))
40#define SUN8I_MIXER_BLEND_MODE(x) (0x1090 + 0x04 * (x))40#define SUN8I_MIXER_BLEND_ROUTE(base) ((base) + 0x80)
41#define SUN8I_MIXER_BLEND_CK_CTL 0x10b041#define SUN8I_MIXER_BLEND_PREMULTIPLY(base) ((base) + 0x84)
42#define SUN8I_MIXER_BLEND_CK_CFG 0x10b442#define SUN8I_MIXER_BLEND_BKCOLOR(base) ((base) + 0x88)
43#define SUN8I_MIXER_BLEND_CK_MAX(x) (0x10c0 + 0x04 * (x))43#define SUN8I_MIXER_BLEND_OUTSIZE(base) ((base) + 0x8c)
44#define SUN8I_MIXER_BLEND_CK_MIN(x) (0x10e0 + 0x04 * (x))44#define SUN8I_MIXER_BLEND_MODE(base, x) ((base) + 0x90 + 0x04 * (x))
45#define SUN8I_MIXER_BLEND_OUTCTL 0x10fc45#define SUN8I_MIXER_BLEND_CK_CTL(base) ((base) + 0xb0)
46#define SUN8I_MIXER_BLEND_CK_CFG(base) ((base) + 0xb4)
47#define SUN8I_MIXER_BLEND_CK_MAX(base, x) ((base) + 0xc0 + 0x04 * (x))
48#define SUN8I_MIXER_BLEND_CK_MIN(base, x) ((base) + 0xe0 + 0x04 * (x))
49#define SUN8I_MIXER_BLEND_OUTCTL(base) ((base) + 0xfc)
46 50
47#define SUN8I_MIXER_BLEND_PIPE_CTL_EN_MSK GENMASK(12, 8)51#define SUN8I_MIXER_BLEND_PIPE_CTL_EN_MSK GENMASK(12, 8)
48#define SUN8I_MIXER_BLEND_PIPE_CTL_EN(pipe) BIT(8 + pipe)52#define SUN8I_MIXER_BLEND_PIPE_CTL_EN(pipe) BIT(8 + pipe)
@@ -153,5 +157,17 @@ engine_to_sun8i_mixer(struct sunxi_engine *engine) · 104 unmodified lines
153 return container_of(engine, struct sun8i_mixer, engine);157 return container_of(engine, struct sun8i_mixer, engine);
154}158}
155 159
160static inline u32
161sun8i_blender_base(struct sun8i_mixer *mixer)
162{
163 return DE2_BLD_BASE;
164}
165
166static inline u32
167sun8i_channel_base(struct sun8i_mixer *mixer, int channel)
168{
169 return DE2_CH_BASE + channel * DE2_CH_SIZE;
170}
171
156const struct de2_fmt_info *sun8i_mixer_format_info(u32 format);172const struct de2_fmt_info *sun8i_mixer_format_info(u32 format);
157#endif /* _SUN8I_MIXER_H_ */173#endif /* _SUN8I_MIXER_H_ */
drivers/gpu/drm/sun4i/sun8i_ui_layer.c+30−17
@@ -30,7 +30,10 @@ static void sun8i_ui_layer_enable(struct sun8i_mixer *mixer, int channel, · 29 unmodified lines
30 int overlay, bool enable, unsigned int zpos,30 int overlay, bool enable, unsigned int zpos,
31 unsigned int old_zpos)31 unsigned int old_zpos)
32{32{
33 u32 val;33 u32 val, bld_base, ch_base;
34
35 bld_base = sun8i_blender_base(mixer);
36 ch_base = sun8i_channel_base(mixer, channel);
34 37
35 DRM_DEBUG_DRIVER("%sabling channel %d overlay %d\n",38 DRM_DEBUG_DRIVER("%sabling channel %d overlay %d\n",
36 enable ? "En" : "Dis", channel, overlay);39 enable ? "En" : "Dis", channel, overlay);
@@ -41,17 +44,17 @@ static void sun8i_ui_layer_enable(struct sun8i_mixer *mixer, int channel, · 4 unmodified lines
41 val = 0;44 val = 0;
42 45
43 regmap_update_bits(mixer->engine.regs,46 regmap_update_bits(mixer->engine.regs,
44 SUN8I_MIXER_CHAN_UI_LAYER_ATTR(channel, overlay),47 SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, overlay),
45 SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN, val);48 SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN, val);
46 49
47 if (!enable || zpos != old_zpos) {50 if (!enable || zpos != old_zpos) {
48 regmap_update_bits(mixer->engine.regs,51 regmap_update_bits(mixer->engine.regs,
49 SUN8I_MIXER_BLEND_PIPE_CTL,52 SUN8I_MIXER_BLEND_PIPE_CTL(bld_base),
50 SUN8I_MIXER_BLEND_PIPE_CTL_EN(old_zpos),53 SUN8I_MIXER_BLEND_PIPE_CTL_EN(old_zpos),
51 0);54 0);
52 55
53 regmap_update_bits(mixer->engine.regs,56 regmap_update_bits(mixer->engine.regs,
54 SUN8I_MIXER_BLEND_ROUTE,57 SUN8I_MIXER_BLEND_ROUTE(bld_base),
55 SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(old_zpos),58 SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(old_zpos),
56 0);59 0);
57 }60 }
@@ -60,12 +63,13 @@ static void sun8i_ui_layer_enable(struct sun8i_mixer *mixer, int channel, · 2 unmodified lines
60 val = SUN8I_MIXER_BLEND_PIPE_CTL_EN(zpos);63 val = SUN8I_MIXER_BLEND_PIPE_CTL_EN(zpos);
61 64
62 regmap_update_bits(mixer->engine.regs,65 regmap_update_bits(mixer->engine.regs,
63 SUN8I_MIXER_BLEND_PIPE_CTL, val, val);66 SUN8I_MIXER_BLEND_PIPE_CTL(bld_base),
67 val, val);
64 68
65 val = channel << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos);69 val = channel << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos);
66 70
67 regmap_update_bits(mixer->engine.regs,71 regmap_update_bits(mixer->engine.regs,
68 SUN8I_MIXER_BLEND_ROUTE,72 SUN8I_MIXER_BLEND_ROUTE(bld_base),
69 SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(zpos),73 SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(zpos),
70 val);74 val);
71 }75 }
@@ -77,12 +81,16 @@ static int sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel, · 5 unmodified lines
77{81{
78 struct drm_plane_state *state = plane->state;82 struct drm_plane_state *state = plane->state;
79 u32 src_w, src_h, dst_w, dst_h;83 u32 src_w, src_h, dst_w, dst_h;
84 u32 bld_base, ch_base;
80 u32 outsize, insize;85 u32 outsize, insize;
81 u32 hphase, vphase;86 u32 hphase, vphase;
82 87
83 DRM_DEBUG_DRIVER("Updating UI channel %d overlay %d\n",88 DRM_DEBUG_DRIVER("Updating UI channel %d overlay %d\n",
84 channel, overlay);89 channel, overlay);
85 90
91 bld_base = sun8i_blender_base(mixer);
92 ch_base = sun8i_channel_base(mixer, channel);
93
86 src_w = drm_rect_width(&state->src) >> 16;94 src_w = drm_rect_width(&state->src) >> 16;
87 src_h = drm_rect_height(&state->src) >> 16;95 src_h = drm_rect_height(&state->src) >> 16;
88 dst_w = drm_rect_width(&state->dst);96 dst_w = drm_rect_width(&state->dst);
@@ -103,8 +111,8 @@ static int sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel, · 14 unmodified lines
103 regmap_write(mixer->engine.regs,111 regmap_write(mixer->engine.regs,
104 SUN8I_MIXER_GLOBAL_SIZE,112 SUN8I_MIXER_GLOBAL_SIZE,
105 outsize);113 outsize);
106 regmap_write(mixer->engine.regs, SUN8I_MIXER_BLEND_OUTSIZE,114 regmap_write(mixer->engine.regs,
107 outsize);115 SUN8I_MIXER_BLEND_OUTSIZE(bld_base), outsize);
108 116
109 if (state->crtc)117 if (state->crtc)
110 interlaced = state->crtc->state->adjusted_mode.flags118 interlaced = state->crtc->state->adjusted_mode.flags
@@ -116,7 +124,7 @@ static int sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel, · 5 unmodified lines
116 val = 0;124 val = 0;
117 125
118 regmap_update_bits(mixer->engine.regs,126 regmap_update_bits(mixer->engine.regs,
119 SUN8I_MIXER_BLEND_OUTCTL,127 SUN8I_MIXER_BLEND_OUTCTL(bld_base),
120 SUN8I_MIXER_BLEND_OUTCTL_INTERLACED,128 SUN8I_MIXER_BLEND_OUTCTL_INTERLACED,
121 val);129 val);
122 130
@@ -129,10 +137,10 @@ static int sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel, · 6 unmodified lines
129 state->src.x1 >> 16, state->src.y1 >> 16);137 state->src.x1 >> 16, state->src.y1 >> 16);
130 DRM_DEBUG_DRIVER("Layer source size W: %d H: %d\n", src_w, src_h);138 DRM_DEBUG_DRIVER("Layer source size W: %d H: %d\n", src_w, src_h);
131 regmap_write(mixer->engine.regs,139 regmap_write(mixer->engine.regs,
132 SUN8I_MIXER_CHAN_UI_LAYER_SIZE(channel, overlay),140 SUN8I_MIXER_CHAN_UI_LAYER_SIZE(ch_base, overlay),
133 insize);141 insize);
134 regmap_write(mixer->engine.regs,142 regmap_write(mixer->engine.regs,
135 SUN8I_MIXER_CHAN_UI_OVL_SIZE(channel),143 SUN8I_MIXER_CHAN_UI_OVL_SIZE(ch_base),
136 insize);144 insize);
137 145
138 if (insize != outsize || hphase || vphase) {146 if (insize != outsize || hphase || vphase) {
@@ -156,10 +164,10 @@ static int sun8i_ui_layer_update_coord(struct sun8i_mixer *mixer, int channel, · 17 unmodified lines
156 state->dst.x1, state->dst.y1);164 state->dst.x1, state->dst.y1);
157 DRM_DEBUG_DRIVER("Layer destination size W: %d H: %d\n", dst_w, dst_h);165 DRM_DEBUG_DRIVER("Layer destination size W: %d H: %d\n", dst_w, dst_h);
158 regmap_write(mixer->engine.regs,166 regmap_write(mixer->engine.regs,
159 SUN8I_MIXER_BLEND_ATTR_COORD(zpos),167 SUN8I_MIXER_BLEND_ATTR_COORD(bld_base, zpos),
160 SUN8I_MIXER_COORD(state->dst.x1, state->dst.y1));168 SUN8I_MIXER_COORD(state->dst.x1, state->dst.y1));
161 regmap_write(mixer->engine.regs,169 regmap_write(mixer->engine.regs,
162 SUN8I_MIXER_BLEND_ATTR_INSIZE(zpos),170 SUN8I_MIXER_BLEND_ATTR_INSIZE(bld_base, zpos),
163 outsize);171 outsize);
164 172
165 return 0;173 return 0;
@@ -170,7 +178,9 @@ static int sun8i_ui_layer_update_formats(struct sun8i_mixer *mixer, int channel, · 4 unmodified lines
170{178{
171 struct drm_plane_state *state = plane->state;179 struct drm_plane_state *state = plane->state;
172 const struct de2_fmt_info *fmt_info;180 const struct de2_fmt_info *fmt_info;
173 u32 val;181 u32 val, ch_base;
182
183 ch_base = sun8i_channel_base(mixer, channel);
174 184
175 fmt_info = sun8i_mixer_format_info(state->fb->format->format);185 fmt_info = sun8i_mixer_format_info(state->fb->format->format);
176 if (!fmt_info || !fmt_info->rgb) {186 if (!fmt_info || !fmt_info->rgb) {
@@ -180,7 +190,7 @@ static int sun8i_ui_layer_update_formats(struct sun8i_mixer *mixer, int channel, · 3 unmodified lines
180 190
181 val = fmt_info->de2_fmt << SUN8I_MIXER_CHAN_UI_LAYER_ATTR_FBFMT_OFFSET;191 val = fmt_info->de2_fmt << SUN8I_MIXER_CHAN_UI_LAYER_ATTR_FBFMT_OFFSET;
182 regmap_update_bits(mixer->engine.regs,192 regmap_update_bits(mixer->engine.regs,
183 SUN8I_MIXER_CHAN_UI_LAYER_ATTR(channel, overlay),193 SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch_base, overlay),
184 SUN8I_MIXER_CHAN_UI_LAYER_ATTR_FBFMT_MASK, val);194 SUN8I_MIXER_CHAN_UI_LAYER_ATTR_FBFMT_MASK, val);
185 195
186 return 0;196 return 0;
@@ -193,8 +203,11 @@ static int sun8i_ui_layer_update_buffer(struct sun8i_mixer *mixer, int channel, · 6 unmodified lines
193 struct drm_framebuffer *fb = state->fb;203 struct drm_framebuffer *fb = state->fb;
194 struct drm_gem_cma_object *gem;204 struct drm_gem_cma_object *gem;
195 dma_addr_t paddr;205 dma_addr_t paddr;
206 u32 ch_base;
196 int bpp;207 int bpp;
197 208
209 ch_base = sun8i_channel_base(mixer, channel);
210
198 /* Get the physical address of the buffer in memory */211 /* Get the physical address of the buffer in memory */
199 gem = drm_fb_cma_get_gem_obj(fb, 0);212 gem = drm_fb_cma_get_gem_obj(fb, 0);
200 213
@@ -211,13 +224,13 @@ static int sun8i_ui_layer_update_buffer(struct sun8i_mixer *mixer, int channel, · 10 unmodified lines
211 /* Set the line width */224 /* Set the line width */
212 DRM_DEBUG_DRIVER("Layer line width: %d bytes\n", fb->pitches[0]);225 DRM_DEBUG_DRIVER("Layer line width: %d bytes\n", fb->pitches[0]);
213 regmap_write(mixer->engine.regs,226 regmap_write(mixer->engine.regs,
214 SUN8I_MIXER_CHAN_UI_LAYER_PITCH(channel, overlay),227 SUN8I_MIXER_CHAN_UI_LAYER_PITCH(ch_base, overlay),
215 fb->pitches[0]);228 fb->pitches[0]);
216 229
217 DRM_DEBUG_DRIVER("Setting buffer address to %pad\n", &paddr);230 DRM_DEBUG_DRIVER("Setting buffer address to %pad\n", &paddr);
218 231
219 regmap_write(mixer->engine.regs,232 regmap_write(mixer->engine.regs,
220 SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR(channel, overlay),233 SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR(ch_base, overlay),
221 lower_32_bits(paddr));234 lower_32_bits(paddr));
222 235
223 return 0;236 return 0;
drivers/gpu/drm/sun4i/sun8i_ui_layer.h+20−17
@@ -18,23 +18,26 @@ · 17 unmodified lines
18 18
19#include <drm/drm_plane.h>19#include <drm/drm_plane.h>
20 20
21#define SUN8I_MIXER_CHAN_UI_LAYER_ATTR(ch, layer) \21#define SUN8I_MIXER_CHAN_UI_LAYER_ATTR(base, layer) \
22 (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x0)22 ((base) + 0x20 * (layer) + 0x0)
23#define SUN8I_MIXER_CHAN_UI_LAYER_SIZE(ch, layer) \23#define SUN8I_MIXER_CHAN_UI_LAYER_SIZE(base, layer) \
24 (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x4)24 ((base) + 0x20 * (layer) + 0x4)
25#define SUN8I_MIXER_CHAN_UI_LAYER_COORD(ch, layer) \25#define SUN8I_MIXER_CHAN_UI_LAYER_COORD(base, layer) \
26 (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x8)26 ((base) + 0x20 * (layer) + 0x8)
27#define SUN8I_MIXER_CHAN_UI_LAYER_PITCH(ch, layer) \27#define SUN8I_MIXER_CHAN_UI_LAYER_PITCH(base, layer) \
28 (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0xc)28 ((base) + 0x20 * (layer) + 0xc)
29#define SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR(ch, layer) \29#define SUN8I_MIXER_CHAN_UI_LAYER_TOP_LADDR(base, layer) \
30 (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x10)30 ((base) + 0x20 * (layer) + 0x10)
31#define SUN8I_MIXER_CHAN_UI_LAYER_BOT_LADDR(ch, layer) \31#define SUN8I_MIXER_CHAN_UI_LAYER_BOT_LADDR(base, layer) \
32 (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x14)32 ((base) + 0x20 * (layer) + 0x14)
33#define SUN8I_MIXER_CHAN_UI_LAYER_FCOLOR(ch, layer) \33#define SUN8I_MIXER_CHAN_UI_LAYER_FCOLOR(base, layer) \
34 (0x2000 + 0x1000 * (ch) + 0x20 * (layer) + 0x18)34 ((base) + 0x20 * (layer) + 0x18)
35#define SUN8I_MIXER_CHAN_UI_TOP_HADDR(ch) (0x2000 + 0x1000 * (ch) + 0x80)35#define SUN8I_MIXER_CHAN_UI_TOP_HADDR(base) \
36#define SUN8I_MIXER_CHAN_UI_BOT_HADDR(ch) (0x2000 + 0x1000 * (ch) + 0x84)36 ((base) + 0x80)
37#define SUN8I_MIXER_CHAN_UI_OVL_SIZE(ch) (0x2000 + 0x1000 * (ch) + 0x88)37#define SUN8I_MIXER_CHAN_UI_BOT_HADDR(base) \
38 ((base) + 0x84)
39#define SUN8I_MIXER_CHAN_UI_OVL_SIZE(base) \
40 ((base) + 0x88)
38 41
39#define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN BIT(0)42#define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_EN BIT(0)
40#define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_MASK GENMASK(2, 1)43#define SUN8I_MIXER_CHAN_UI_LAYER_ATTR_ALPHA_MODE_MASK GENMASK(2, 1)
drivers/gpu/drm/sun4i/sun8i_ui_scaler.c+25−16
@@ -10,6 +10,7 @@ · 9 unmodified lines
10 */10 */
11 11
12#include "sun8i_ui_scaler.h"12#include "sun8i_ui_scaler.h"
13#include "sun8i_vi_scaler.h"
13 14
14static const u32 lan2coefftab16[240] = {15static const u32 lan2coefftab16[240] = {
15 0x00004000, 0x00033ffe, 0x00063efc, 0x000a3bfb,16 0x00004000, 0x00033ffe, 0x00063efc, 0x000a3bfb,
@@ -88,6 +89,14 @@ static const u32 lan2coefftab16[240] = { · 72 unmodified lines
88 0x0b1c1603, 0x0d1c1502, 0x0e1d1401, 0x0f1d1301,89 0x0b1c1603, 0x0d1c1502, 0x0e1d1401, 0x0f1d1301,
89};90};
90 91
92static u32 sun8i_ui_scaler_base(struct sun8i_mixer *mixer, int channel)
93{
94 int vi_num = mixer->cfg->vi_num;
95
96 return DE2_VI_SCALER_UNIT_BASE + DE2_VI_SCALER_UNIT_SIZE * vi_num +
97 DE2_UI_SCALER_UNIT_SIZE * (channel - vi_num);
98}
99
91static int sun8i_ui_scaler_coef_index(unsigned int step)100static int sun8i_ui_scaler_coef_index(unsigned int step)
92{101{
93 unsigned int scale, int_part, float_part;102 unsigned int scale, int_part, float_part;
@@ -114,33 +123,35 @@ static int sun8i_ui_scaler_coef_index(unsigned int step) · 20 unmodified lines
114 123
115void sun8i_ui_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable)124void sun8i_ui_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable)
116{125{
117 int vi_cnt = mixer->cfg->vi_num;126 u32 val, base;
118 u32 val;
119 127
120 if (WARN_ON(layer < vi_cnt))128 if (WARN_ON(layer < mixer->cfg->vi_num))
121 return;129 return;
122 130
131 base = sun8i_ui_scaler_base(mixer, layer);
132
123 if (enable)133 if (enable)
124 val = SUN8I_SCALER_GSU_CTRL_EN |134 val = SUN8I_SCALER_GSU_CTRL_EN |
125 SUN8I_SCALER_GSU_CTRL_COEFF_RDY;135 SUN8I_SCALER_GSU_CTRL_COEFF_RDY;
126 else136 else
127 val = 0;137 val = 0;
128 138
129 regmap_write(mixer->engine.regs,139 regmap_write(mixer->engine.regs, SUN8I_SCALER_GSU_CTRL(base), val);
130 SUN8I_SCALER_GSU_CTRL(vi_cnt, layer - vi_cnt), val);
131}140}
132 141
133void sun8i_ui_scaler_setup(struct sun8i_mixer *mixer, int layer,142void sun8i_ui_scaler_setup(struct sun8i_mixer *mixer, int layer,
134 u32 src_w, u32 src_h, u32 dst_w, u32 dst_h,143 u32 src_w, u32 src_h, u32 dst_w, u32 dst_h,
135 u32 hscale, u32 vscale, u32 hphase, u32 vphase)144 u32 hscale, u32 vscale, u32 hphase, u32 vphase)
136{145{
137 int vi_cnt = mixer->cfg->vi_num;
138 u32 insize, outsize;146 u32 insize, outsize;
139 int i, offset;147 int i, offset;
148 u32 base;
140 149
141 if (WARN_ON(layer < vi_cnt))150 if (WARN_ON(layer < mixer->cfg->vi_num))
142 return;151 return;
143 152
153 base = sun8i_ui_scaler_base(mixer, layer);
154
144 hphase <<= SUN8I_UI_SCALER_PHASE_FRAC - 16;155 hphase <<= SUN8I_UI_SCALER_PHASE_FRAC - 16;
145 vphase <<= SUN8I_UI_SCALER_PHASE_FRAC - 16;156 vphase <<= SUN8I_UI_SCALER_PHASE_FRAC - 16;
146 hscale <<= SUN8I_UI_SCALER_SCALE_FRAC - 16;157 hscale <<= SUN8I_UI_SCALER_SCALE_FRAC - 16;
@@ -149,24 +160,22 @@ void sun8i_ui_scaler_setup(struct sun8i_mixer *mixer, int layer, · 2 unmodified lines
149 insize = SUN8I_UI_SCALER_SIZE(src_w, src_h);160 insize = SUN8I_UI_SCALER_SIZE(src_w, src_h);
150 outsize = SUN8I_UI_SCALER_SIZE(dst_w, dst_h);161 outsize = SUN8I_UI_SCALER_SIZE(dst_w, dst_h);
151 162
152 layer -= vi_cnt;
153
154 regmap_write(mixer->engine.regs,163 regmap_write(mixer->engine.regs,
155 SUN8I_SCALER_GSU_OUTSIZE(vi_cnt, layer), outsize);164 SUN8I_SCALER_GSU_OUTSIZE(base), outsize);
156 regmap_write(mixer->engine.regs,165 regmap_write(mixer->engine.regs,
157 SUN8I_SCALER_GSU_INSIZE(vi_cnt, layer), insize);166 SUN8I_SCALER_GSU_INSIZE(base), insize);
158 regmap_write(mixer->engine.regs,167 regmap_write(mixer->engine.regs,
159 SUN8I_SCALER_GSU_HSTEP(vi_cnt, layer), hscale);168 SUN8I_SCALER_GSU_HSTEP(base), hscale);
160 regmap_write(mixer->engine.regs,169 regmap_write(mixer->engine.regs,
161 SUN8I_SCALER_GSU_VSTEP(vi_cnt, layer), vscale);170 SUN8I_SCALER_GSU_VSTEP(base), vscale);
162 regmap_write(mixer->engine.regs,171 regmap_write(mixer->engine.regs,
163 SUN8I_SCALER_GSU_HPHASE(vi_cnt, layer), hphase);172 SUN8I_SCALER_GSU_HPHASE(base), hphase);
164 regmap_write(mixer->engine.regs,173 regmap_write(mixer->engine.regs,
165 SUN8I_SCALER_GSU_VPHASE(vi_cnt, layer), vphase);174 SUN8I_SCALER_GSU_VPHASE(base), vphase);
166 offset = sun8i_ui_scaler_coef_index(hscale) *175 offset = sun8i_ui_scaler_coef_index(hscale) *
167 SUN8I_UI_SCALER_COEFF_COUNT;176 SUN8I_UI_SCALER_COEFF_COUNT;
168 for (i = 0; i < SUN8I_UI_SCALER_COEFF_COUNT; i++)177 for (i = 0; i < SUN8I_UI_SCALER_COEFF_COUNT; i++)
169 regmap_write(mixer->engine.regs,178 regmap_write(mixer->engine.regs,
170 SUN8I_SCALER_GSU_HCOEFF(vi_cnt, layer, i),179 SUN8I_SCALER_GSU_HCOEFF(base, i),
171 lan2coefftab16[offset + i]);180 lan2coefftab16[offset + i]);
172}181}
drivers/gpu/drm/sun4i/sun8i_ui_scaler.h+10−17
@@ -11,6 +11,8 @@ · 10 unmodified lines
11 11
12#include "sun8i_mixer.h"12#include "sun8i_mixer.h"
13 13
14#define DE2_UI_SCALER_UNIT_SIZE 0x10000
15
14/* this two macros assumes 16 fractional bits which is standard in DRM */16/* this two macros assumes 16 fractional bits which is standard in DRM */
15#define SUN8I_UI_SCALER_SCALE_MIN 117#define SUN8I_UI_SCALER_SCALE_MIN 1
16#define SUN8I_UI_SCALER_SCALE_MAX ((1UL << 20) - 1)18#define SUN8I_UI_SCALER_SCALE_MAX ((1UL << 20) - 1)
@@ -20,23 +22,14 @@ · 3 unmodified lines
20#define SUN8I_UI_SCALER_COEFF_COUNT 1622#define SUN8I_UI_SCALER_COEFF_COUNT 16
21#define SUN8I_UI_SCALER_SIZE(w, h) (((h) - 1) << 16 | ((w) - 1))23#define SUN8I_UI_SCALER_SIZE(w, h) (((h) - 1) << 16 | ((w) - 1))
22 24
23#define SUN8I_SCALER_GSU_CTRL(vi_cnt, ui_idx) \25#define SUN8I_SCALER_GSU_CTRL(base) ((base) + 0x0)
24 (0x20000 + 0x20000 * (vi_cnt) + 0x10000 * (ui_idx) + 0x0)26#define SUN8I_SCALER_GSU_OUTSIZE(base) ((base) + 0x40)
25#define SUN8I_SCALER_GSU_OUTSIZE(vi_cnt, ui_idx) \27#define SUN8I_SCALER_GSU_INSIZE(base) ((base) + 0x80)
26 (0x20000 + 0x20000 * (vi_cnt) + 0x10000 * (ui_idx) + 0x40)28#define SUN8I_SCALER_GSU_HSTEP(base) ((base) + 0x88)
27#define SUN8I_SCALER_GSU_INSIZE(vi_cnt, ui_idx) \29#define SUN8I_SCALER_GSU_VSTEP(base) ((base) + 0x8c)
28 (0x20000 + 0x20000 * (vi_cnt) + 0x10000 * (ui_idx) + 0x80)30#define SUN8I_SCALER_GSU_HPHASE(base) ((base) + 0x90)
29#define SUN8I_SCALER_GSU_HSTEP(vi_cnt, ui_idx) \31#define SUN8I_SCALER_GSU_VPHASE(base) ((base) + 0x98)
30 (0x20000 + 0x20000 * (vi_cnt) + 0x10000 * (ui_idx) + 0x88)32#define SUN8I_SCALER_GSU_HCOEFF(base, index) ((base) + 0x200 + 0x4 * (index))
31#define SUN8I_SCALER_GSU_VSTEP(vi_cnt, ui_idx) \
32 (0x20000 + 0x20000 * (vi_cnt) + 0x10000 * (ui_idx) + 0x8c)
33#define SUN8I_SCALER_GSU_HPHASE(vi_cnt, ui_idx) \
34 (0x20000 + 0x20000 * (vi_cnt) + 0x10000 * (ui_idx) + 0x90)
35#define SUN8I_SCALER_GSU_VPHASE(vi_cnt, ui_idx) \
36 (0x20000 + 0x20000 * (vi_cnt) + 0x10000 * (ui_idx) + 0x98)
37#define SUN8I_SCALER_GSU_HCOEFF(vi_cnt, ui_idx, index) \
38 (0x20000 + 0x20000 * (vi_cnt) + 0x10000 * (ui_idx) + 0x200 + \
39 0x4 * (index))
40 33
41#define SUN8I_SCALER_GSU_CTRL_EN BIT(0)34#define SUN8I_SCALER_GSU_CTRL_EN BIT(0)
42#define SUN8I_SCALER_GSU_CTRL_COEFF_RDY BIT(4)35#define SUN8I_SCALER_GSU_CTRL_COEFF_RDY BIT(4)
drivers/gpu/drm/sun4i/sun8i_vi_layer.c+30−17
@@ -24,7 +24,10 @@ static void sun8i_vi_layer_enable(struct sun8i_mixer *mixer, int channel, · 23 unmodified lines
24 int overlay, bool enable, unsigned int zpos,24 int overlay, bool enable, unsigned int zpos,
25 unsigned int old_zpos)25 unsigned int old_zpos)
26{26{
27 u32 val;27 u32 val, bld_base, ch_base;
28
29 bld_base = sun8i_blender_base(mixer);
30 ch_base = sun8i_channel_base(mixer, channel);
28 31
29 DRM_DEBUG_DRIVER("%sabling VI channel %d overlay %d\n",32 DRM_DEBUG_DRIVER("%sabling VI channel %d overlay %d\n",
30 enable ? "En" : "Dis", channel, overlay);33 enable ? "En" : "Dis", channel, overlay);
@@ -35,17 +38,17 @@ static void sun8i_vi_layer_enable(struct sun8i_mixer *mixer, int channel, · 4 unmodified lines
35 val = 0;38 val = 0;
36 39
37 regmap_update_bits(mixer->engine.regs,40 regmap_update_bits(mixer->engine.regs,
38 SUN8I_MIXER_CHAN_VI_LAYER_ATTR(channel, overlay),41 SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, overlay),
39 SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN, val);42 SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN, val);
40 43
41 if (!enable || zpos != old_zpos) {44 if (!enable || zpos != old_zpos) {
42 regmap_update_bits(mixer->engine.regs,45 regmap_update_bits(mixer->engine.regs,
43 SUN8I_MIXER_BLEND_PIPE_CTL,46 SUN8I_MIXER_BLEND_PIPE_CTL(bld_base),
44 SUN8I_MIXER_BLEND_PIPE_CTL_EN(old_zpos),47 SUN8I_MIXER_BLEND_PIPE_CTL_EN(old_zpos),
45 0);48 0);
46 49
47 regmap_update_bits(mixer->engine.regs,50 regmap_update_bits(mixer->engine.regs,
48 SUN8I_MIXER_BLEND_ROUTE,51 SUN8I_MIXER_BLEND_ROUTE(bld_base),
49 SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(old_zpos),52 SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(old_zpos),
50 0);53 0);
51 }54 }
@@ -54,12 +57,13 @@ static void sun8i_vi_layer_enable(struct sun8i_mixer *mixer, int channel, · 2 unmodified lines
54 val = SUN8I_MIXER_BLEND_PIPE_CTL_EN(zpos);57 val = SUN8I_MIXER_BLEND_PIPE_CTL_EN(zpos);
55 58
56 regmap_update_bits(mixer->engine.regs,59 regmap_update_bits(mixer->engine.regs,
57 SUN8I_MIXER_BLEND_PIPE_CTL, val, val);60 SUN8I_MIXER_BLEND_PIPE_CTL(bld_base),
61 val, val);
58 62
59 val = channel << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos);63 val = channel << SUN8I_MIXER_BLEND_ROUTE_PIPE_SHIFT(zpos);
60 64
61 regmap_update_bits(mixer->engine.regs,65 regmap_update_bits(mixer->engine.regs,
62 SUN8I_MIXER_BLEND_ROUTE,66 SUN8I_MIXER_BLEND_ROUTE(bld_base),
63 SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(zpos),67 SUN8I_MIXER_BLEND_ROUTE_PIPE_MSK(zpos),
64 val);68 val);
65 }69 }
@@ -72,6 +76,7 @@ static int sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel, · 6 unmodified lines
72 struct drm_plane_state *state = plane->state;76 struct drm_plane_state *state = plane->state;
73 const struct drm_format_info *format = state->fb->format;77 const struct drm_format_info *format = state->fb->format;
74 u32 src_w, src_h, dst_w, dst_h;78 u32 src_w, src_h, dst_w, dst_h;
79 u32 bld_base, ch_base;
75 u32 outsize, insize;80 u32 outsize, insize;
76 u32 hphase, vphase;81 u32 hphase, vphase;
77 bool subsampled;82 bool subsampled;
@@ -79,6 +84,9 @@ static int sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel, · 1 unmodified line
79 DRM_DEBUG_DRIVER("Updating VI channel %d overlay %d\n",84 DRM_DEBUG_DRIVER("Updating VI channel %d overlay %d\n",
80 channel, overlay);85 channel, overlay);
81 86
87 bld_base = sun8i_blender_base(mixer);
88 ch_base = sun8i_channel_base(mixer, channel);
89
82 src_w = drm_rect_width(&state->src) >> 16;90 src_w = drm_rect_width(&state->src) >> 16;
83 src_h = drm_rect_height(&state->src) >> 16;91 src_h = drm_rect_height(&state->src) >> 16;
84 dst_w = drm_rect_width(&state->dst);92 dst_w = drm_rect_width(&state->dst);
@@ -115,10 +123,10 @@ static int sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel, · 30 unmodified lines
115 (state->src.y1 >> 16) & ~(format->vsub - 1));123 (state->src.y1 >> 16) & ~(format->vsub - 1));
116 DRM_DEBUG_DRIVER("Layer source size W: %d H: %d\n", src_w, src_h);124 DRM_DEBUG_DRIVER("Layer source size W: %d H: %d\n", src_w, src_h);
117 regmap_write(mixer->engine.regs,125 regmap_write(mixer->engine.regs,
118 SUN8I_MIXER_CHAN_VI_LAYER_SIZE(channel, overlay),126 SUN8I_MIXER_CHAN_VI_LAYER_SIZE(ch_base, overlay),
119 insize);127 insize);
120 regmap_write(mixer->engine.regs,128 regmap_write(mixer->engine.regs,
121 SUN8I_MIXER_CHAN_VI_OVL_SIZE(channel),129 SUN8I_MIXER_CHAN_VI_OVL_SIZE(ch_base),
122 insize);130 insize);
123 131
124 /*132 /*
@@ -149,10 +157,10 @@ static int sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel, · 24 unmodified lines
149 state->dst.x1, state->dst.y1);157 state->dst.x1, state->dst.y1);
150 DRM_DEBUG_DRIVER("Layer destination size W: %d H: %d\n", dst_w, dst_h);158 DRM_DEBUG_DRIVER("Layer destination size W: %d H: %d\n", dst_w, dst_h);
151 regmap_write(mixer->engine.regs,159 regmap_write(mixer->engine.regs,
152 SUN8I_MIXER_BLEND_ATTR_COORD(zpos),160 SUN8I_MIXER_BLEND_ATTR_COORD(bld_base, zpos),
153 SUN8I_MIXER_COORD(state->dst.x1, state->dst.y1));161 SUN8I_MIXER_COORD(state->dst.x1, state->dst.y1));
154 regmap_write(mixer->engine.regs,162 regmap_write(mixer->engine.regs,
155 SUN8I_MIXER_BLEND_ATTR_INSIZE(zpos),163 SUN8I_MIXER_BLEND_ATTR_INSIZE(bld_base, zpos),
156 outsize);164 outsize);
157 165
158 return 0;166 return 0;
@@ -163,7 +171,9 @@ static int sun8i_vi_layer_update_formats(struct sun8i_mixer *mixer, int channel, · 4 unmodified lines
163{171{
164 struct drm_plane_state *state = plane->state;172 struct drm_plane_state *state = plane->state;
165 const struct de2_fmt_info *fmt_info;173 const struct de2_fmt_info *fmt_info;
166 u32 val;174 u32 val, ch_base;
175
176 ch_base = sun8i_channel_base(mixer, channel);
167 177
168 fmt_info = sun8i_mixer_format_info(state->fb->format->format);178 fmt_info = sun8i_mixer_format_info(state->fb->format->format);
169 if (!fmt_info) {179 if (!fmt_info) {
@@ -173,7 +183,7 @@ static int sun8i_vi_layer_update_formats(struct sun8i_mixer *mixer, int channel, · 3 unmodified lines
173 183
174 val = fmt_info->de2_fmt << SUN8I_MIXER_CHAN_VI_LAYER_ATTR_FBFMT_OFFSET;184 val = fmt_info->de2_fmt << SUN8I_MIXER_CHAN_VI_LAYER_ATTR_FBFMT_OFFSET;
175 regmap_update_bits(mixer->engine.regs,185 regmap_update_bits(mixer->engine.regs,
176 SUN8I_MIXER_CHAN_VI_LAYER_ATTR(channel, overlay),186 SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, overlay),
177 SUN8I_MIXER_CHAN_VI_LAYER_ATTR_FBFMT_MASK, val);187 SUN8I_MIXER_CHAN_VI_LAYER_ATTR_FBFMT_MASK, val);
178 188
179 if (fmt_info->csc != SUN8I_CSC_MODE_OFF) {189 if (fmt_info->csc != SUN8I_CSC_MODE_OFF) {
@@ -189,7 +199,7 @@ static int sun8i_vi_layer_update_formats(struct sun8i_mixer *mixer, int channel, · 9 unmodified lines
189 val = 0;199 val = 0;
190 200
191 regmap_update_bits(mixer->engine.regs,201 regmap_update_bits(mixer->engine.regs,
192 SUN8I_MIXER_CHAN_VI_LAYER_ATTR(channel, overlay),202 SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, overlay),
193 SUN8I_MIXER_CHAN_VI_LAYER_ATTR_RGB_MODE, val);203 SUN8I_MIXER_CHAN_VI_LAYER_ATTR_RGB_MODE, val);
194 204
195 return 0;205 return 0;
@@ -204,8 +214,11 @@ static int sun8i_vi_layer_update_buffer(struct sun8i_mixer *mixer, int channel, · 8 unmodified lines
204 struct drm_gem_cma_object *gem;214 struct drm_gem_cma_object *gem;
205 u32 dx, dy, src_x, src_y;215 u32 dx, dy, src_x, src_y;
206 dma_addr_t paddr;216 dma_addr_t paddr;
217 u32 ch_base;
207 int i;218 int i;
208 219
220 ch_base = sun8i_channel_base(mixer, channel);
221
209 /* Adjust x and y to be dividable by subsampling factor */222 /* Adjust x and y to be dividable by subsampling factor */
210 src_x = (state->src.x1 >> 16) & ~(format->hsub - 1);223 src_x = (state->src.x1 >> 16) & ~(format->hsub - 1);
211 src_y = (state->src.y1 >> 16) & ~(format->vsub - 1);224 src_y = (state->src.y1 >> 16) & ~(format->vsub - 1);
@@ -235,17 +248,17 @@ static int sun8i_vi_layer_update_buffer(struct sun8i_mixer *mixer, int channel, · 23 unmodified lines
235 DRM_DEBUG_DRIVER("Layer %d. line width: %d bytes\n",248 DRM_DEBUG_DRIVER("Layer %d. line width: %d bytes\n",
236 i + 1, fb->pitches[i]);249 i + 1, fb->pitches[i]);
237 regmap_write(mixer->engine.regs,250 regmap_write(mixer->engine.regs,
238 SUN8I_MIXER_CHAN_VI_LAYER_PITCH(channel,251 SUN8I_MIXER_CHAN_VI_LAYER_PITCH(ch_base,
239 overlay, i),252 overlay, i),
240 fb->pitches[i]);253 fb->pitches[i]);
241 254
242 DRM_DEBUG_DRIVER("Setting %d. buffer address to %pad\n",255 DRM_DEBUG_DRIVER("Setting %d. buffer address to %pad\n",
243 i + 1, &paddr);256 i + 1, &paddr);
244 257
245 regmap_write(mixer->engine.regs,258 regmap_write(mixer->engine.regs,
246 SUN8I_MIXER_CHAN_VI_LAYER_TOP_LADDR(channel,259 SUN8I_MIXER_CHAN_VI_LAYER_TOP_LADDR(ch_base,
247 overlay, i),260 overlay, i),
248 lower_32_bits(paddr));261 lower_32_bits(paddr));
249 }262 }
250 263
251 return 0;264 return 0;
drivers/gpu/drm/sun4i/sun8i_vi_layer.h+12−11
@@ -12,17 +12,18 @@ · 11 unmodified lines
12 12
13#include <drm/drm_plane.h>13#include <drm/drm_plane.h>
14 14
15#define SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch, layer) \15#define SUN8I_MIXER_CHAN_VI_LAYER_ATTR(base, layer) \
16 (0x2000 + 0x1000 * (ch) + 0x30 * (layer) + 0x0)16 ((base) + 0x30 * (layer) + 0x0)
17#define SUN8I_MIXER_CHAN_VI_LAYER_SIZE(ch, layer) \17#define SUN8I_MIXER_CHAN_VI_LAYER_SIZE(base, layer) \
18 (0x2000 + 0x1000 * (ch) + 0x30 * (layer) + 0x4)18 ((base) + 0x30 * (layer) + 0x4)
19#define SUN8I_MIXER_CHAN_VI_LAYER_COORD(ch, layer) \19#define SUN8I_MIXER_CHAN_VI_LAYER_COORD(base, layer) \
20 (0x2000 + 0x1000 * (ch) + 0x30 * (layer) + 0x8)20 ((base) + 0x30 * (layer) + 0x8)
21#define SUN8I_MIXER_CHAN_VI_LAYER_PITCH(ch, layer, plane) \21#define SUN8I_MIXER_CHAN_VI_LAYER_PITCH(base, layer, plane) \
22 (0x2000 + 0x1000 * (ch) + 0x30 * (layer) + 0xc + 4 * (plane))22 ((base) + 0x30 * (layer) + 0xc + 4 * (plane))
23#define SUN8I_MIXER_CHAN_VI_LAYER_TOP_LADDR(ch, layer, plane) \23#define SUN8I_MIXER_CHAN_VI_LAYER_TOP_LADDR(base, layer, plane) \
24 (0x2000 + 0x1000 * (ch) + 0x30 * (layer) + 0x18 + 4 * (plane))24 ((base) + 0x30 * (layer) + 0x18 + 4 * (plane))
25#define SUN8I_MIXER_CHAN_VI_OVL_SIZE(ch) (0x2000 + 0x1000 * (ch) + 0xe8)25#define SUN8I_MIXER_CHAN_VI_OVL_SIZE(base) \
26 ((base) + 0xe8)
26 27
27#define SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN BIT(0)28#define SUN8I_MIXER_CHAN_VI_LAYER_ATTR_EN BIT(0)
28/* RGB mode should be set for RGB formats and cleared for YCbCr */29/* RGB mode should be set for RGB formats and cleared for YCbCr */
drivers/gpu/drm/sun4i/sun8i_vi_scaler.c+32−21
@@ -833,6 +833,11 @@ static const u32 bicubic4coefftab32[480] = { · 832 unmodified lines
833 0x1012110d, 0x1012110d, 0x1013110c, 0x1013110c,833 0x1012110d, 0x1012110d, 0x1013110c, 0x1013110c,
834};834};
835 835
836static u32 sun8i_vi_scaler_base(struct sun8i_mixer *mixer, int channel)
837{
838 return DE2_VI_SCALER_UNIT_BASE + DE2_VI_SCALER_UNIT_SIZE * channel;
839}
840
836static int sun8i_vi_scaler_coef_index(unsigned int step)841static int sun8i_vi_scaler_coef_index(unsigned int step)
837{842{
838 unsigned int scale, int_part, float_part;843 unsigned int scale, int_part, float_part;
@@ -857,7 +862,7 @@ static int sun8i_vi_scaler_coef_index(unsigned int step) · 18 unmodified lines
857 }862 }
858}863}
859 864
860static void sun8i_vi_scaler_set_coeff(struct regmap *map, int layer,865static void sun8i_vi_scaler_set_coeff(struct regmap *map, u32 base,
861 u32 hstep, u32 vstep,866 u32 hstep, u32 vstep,
862 const struct drm_format_info *format)867 const struct drm_format_info *format)
863{868{
@@ -877,29 +882,31 @@ static void sun8i_vi_scaler_set_coeff(struct regmap *map, int layer, · 13 unmodified lines
877 offset = sun8i_vi_scaler_coef_index(hstep) *882 offset = sun8i_vi_scaler_coef_index(hstep) *
878 SUN8I_VI_SCALER_COEFF_COUNT;883 SUN8I_VI_SCALER_COEFF_COUNT;
879 for (i = 0; i < SUN8I_VI_SCALER_COEFF_COUNT; i++) {884 for (i = 0; i < SUN8I_VI_SCALER_COEFF_COUNT; i++) {
880 regmap_write(map, SUN8I_SCALER_VSU_YHCOEFF0(layer, i),885 regmap_write(map, SUN8I_SCALER_VSU_YHCOEFF0(base, i),
881 lan3coefftab32_left[offset + i]);886 lan3coefftab32_left[offset + i]);
882 regmap_write(map, SUN8I_SCALER_VSU_YHCOEFF1(layer, i),887 regmap_write(map, SUN8I_SCALER_VSU_YHCOEFF1(base, i),
883 lan3coefftab32_right[offset + i]);888 lan3coefftab32_right[offset + i]);
884 regmap_write(map, SUN8I_SCALER_VSU_CHCOEFF0(layer, i),889 regmap_write(map, SUN8I_SCALER_VSU_CHCOEFF0(base, i),
885 ch_left[offset + i]);890 ch_left[offset + i]);
886 regmap_write(map, SUN8I_SCALER_VSU_CHCOEFF1(layer, i),891 regmap_write(map, SUN8I_SCALER_VSU_CHCOEFF1(base, i),
887 ch_right[offset + i]);892 ch_right[offset + i]);
888 }893 }
889 894
890 offset = sun8i_vi_scaler_coef_index(hstep) *895 offset = sun8i_vi_scaler_coef_index(hstep) *
891 SUN8I_VI_SCALER_COEFF_COUNT;896 SUN8I_VI_SCALER_COEFF_COUNT;
892 for (i = 0; i < SUN8I_VI_SCALER_COEFF_COUNT; i++) {897 for (i = 0; i < SUN8I_VI_SCALER_COEFF_COUNT; i++) {
893 regmap_write(map, SUN8I_SCALER_VSU_YVCOEFF(layer, i),898 regmap_write(map, SUN8I_SCALER_VSU_YVCOEFF(base, i),
894 lan2coefftab32[offset + i]);899 lan2coefftab32[offset + i]);
895 regmap_write(map, SUN8I_SCALER_VSU_CVCOEFF(layer, i),900 regmap_write(map, SUN8I_SCALER_VSU_CVCOEFF(base, i),
896 cy[offset + i]);901 cy[offset + i]);
897 }902 }
898}903}
899 904
900void sun8i_vi_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable)905void sun8i_vi_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable)
901{906{
902 u32 val;907 u32 val, base;
908
909 base = sun8i_vi_scaler_base(mixer, layer);
903 910
904 if (enable)911 if (enable)
905 val = SUN8I_SCALER_VSU_CTRL_EN |912 val = SUN8I_SCALER_VSU_CTRL_EN |
@@ -907,7 +914,8 @@ void sun8i_vi_scaler_enable(struct sun8i_mixer *mixer, int layer, bool enable) · 1 unmodified line
907 else914 else
908 val = 0;915 val = 0;
909 916
910 regmap_write(mixer->engine.regs, SUN8I_SCALER_VSU_CTRL(layer), val);917 regmap_write(mixer->engine.regs,
918 SUN8I_SCALER_VSU_CTRL(base), val);
911}919}
912 920
913void sun8i_vi_scaler_setup(struct sun8i_mixer *mixer, int layer,921void sun8i_vi_scaler_setup(struct sun8i_mixer *mixer, int layer,
@@ -917,6 +925,9 @@ void sun8i_vi_scaler_setup(struct sun8i_mixer *mixer, int layer, · 3 unmodified lines
917{925{
918 u32 chphase, cvphase;926 u32 chphase, cvphase;
919 u32 insize, outsize;927 u32 insize, outsize;
928 u32 base;
929
930 base = sun8i_vi_scaler_base(mixer, layer);
920 931
921 hphase <<= SUN8I_VI_SCALER_PHASE_FRAC - 16;932 hphase <<= SUN8I_VI_SCALER_PHASE_FRAC - 16;
922 vphase <<= SUN8I_VI_SCALER_PHASE_FRAC - 16;933 vphase <<= SUN8I_VI_SCALER_PHASE_FRAC - 16;
@@ -941,31 +952,31 @@ void sun8i_vi_scaler_setup(struct sun8i_mixer *mixer, int layer, · 18 unmodified lines
941 }952 }
942 953
943 regmap_write(mixer->engine.regs,954 regmap_write(mixer->engine.regs,
944 SUN8I_SCALER_VSU_OUTSIZE(layer), outsize);955 SUN8I_SCALER_VSU_OUTSIZE(base), outsize);
945 regmap_write(mixer->engine.regs,956 regmap_write(mixer->engine.regs,
946 SUN8I_SCALER_VSU_YINSIZE(layer), insize);957 SUN8I_SCALER_VSU_YINSIZE(base), insize);
947 regmap_write(mixer->engine.regs,958 regmap_write(mixer->engine.regs,
948 SUN8I_SCALER_VSU_YHSTEP(layer), hscale);959 SUN8I_SCALER_VSU_YHSTEP(base), hscale);
949 regmap_write(mixer->engine.regs,960 regmap_write(mixer->engine.regs,
950 SUN8I_SCALER_VSU_YVSTEP(layer), vscale);961 SUN8I_SCALER_VSU_YVSTEP(base), vscale);
951 regmap_write(mixer->engine.regs,962 regmap_write(mixer->engine.regs,
952 SUN8I_SCALER_VSU_YHPHASE(layer), hphase);963 SUN8I_SCALER_VSU_YHPHASE(base), hphase);
953 regmap_write(mixer->engine.regs,964 regmap_write(mixer->engine.regs,
954 SUN8I_SCALER_VSU_YVPHASE(layer), vphase);965 SUN8I_SCALER_VSU_YVPHASE(base), vphase);
955 regmap_write(mixer->engine.regs,966 regmap_write(mixer->engine.regs,
956 SUN8I_SCALER_VSU_CINSIZE(layer),967 SUN8I_SCALER_VSU_CINSIZE(base),
957 SUN8I_VI_SCALER_SIZE(src_w / format->hsub,968 SUN8I_VI_SCALER_SIZE(src_w / format->hsub,
958 src_h / format->vsub));969 src_h / format->vsub));
959 regmap_write(mixer->engine.regs,970 regmap_write(mixer->engine.regs,
960 SUN8I_SCALER_VSU_CHSTEP(layer),971 SUN8I_SCALER_VSU_CHSTEP(base),
961 hscale / format->hsub);972 hscale / format->hsub);
962 regmap_write(mixer->engine.regs,973 regmap_write(mixer->engine.regs,
963 SUN8I_SCALER_VSU_CVSTEP(layer),974 SUN8I_SCALER_VSU_CVSTEP(base),
964 vscale / format->vsub);975 vscale / format->vsub);
965 regmap_write(mixer->engine.regs,976 regmap_write(mixer->engine.regs,
966 SUN8I_SCALER_VSU_CHPHASE(layer), chphase);977 SUN8I_SCALER_VSU_CHPHASE(base), chphase);
967 regmap_write(mixer->engine.regs,978 regmap_write(mixer->engine.regs,
968 SUN8I_SCALER_VSU_CVPHASE(layer), cvphase);979 SUN8I_SCALER_VSU_CVPHASE(base), cvphase);
969 sun8i_vi_scaler_set_coeff(mixer->engine.regs, layer,980 sun8i_vi_scaler_set_coeff(mixer->engine.regs, base,
970 hscale, vscale, format);981 hscale, vscale, format);
971}982}
drivers/gpu/drm/sun4i/sun8i_vi_scaler.h+21−24
@@ -12,6 +12,9 @@ · 11 unmodified lines
12#include <drm/drm_fourcc.h>12#include <drm/drm_fourcc.h>
13#include "sun8i_mixer.h"13#include "sun8i_mixer.h"
14 14
15#define DE2_VI_SCALER_UNIT_BASE 0x20000
16#define DE2_VI_SCALER_UNIT_SIZE 0x20000
17
15/* this two macros assumes 16 fractional bits which is standard in DRM */18/* this two macros assumes 16 fractional bits which is standard in DRM */
16#define SUN8I_VI_SCALER_SCALE_MIN 119#define SUN8I_VI_SCALER_SCALE_MIN 1
17#define SUN8I_VI_SCALER_SCALE_MAX ((1UL << 20) - 1)20#define SUN8I_VI_SCALER_SCALE_MAX ((1UL << 20) - 1)
@@ -21,30 +24,24 @@ · 3 unmodified lines
21#define SUN8I_VI_SCALER_COEFF_COUNT 3224#define SUN8I_VI_SCALER_COEFF_COUNT 32
22#define SUN8I_VI_SCALER_SIZE(w, h) (((h) - 1) << 16 | ((w) - 1))25#define SUN8I_VI_SCALER_SIZE(w, h) (((h) - 1) << 16 | ((w) - 1))
23 26
24#define SUN8I_SCALER_VSU_CTRL(ch) (0x20000 + 0x20000 * (ch) + 0x0)27#define SUN8I_SCALER_VSU_CTRL(base) ((base) + 0x0)
25#define SUN8I_SCALER_VSU_OUTSIZE(ch) (0x20000 + 0x20000 * (ch) + 0x40)28#define SUN8I_SCALER_VSU_OUTSIZE(base) ((base) + 0x40)
26#define SUN8I_SCALER_VSU_YINSIZE(ch) (0x20000 + 0x20000 * (ch) + 0x80)29#define SUN8I_SCALER_VSU_YINSIZE(base) ((base) + 0x80)
27#define SUN8I_SCALER_VSU_YHSTEP(ch) (0x20000 + 0x20000 * (ch) + 0x88)30#define SUN8I_SCALER_VSU_YHSTEP(base) ((base) + 0x88)
28#define SUN8I_SCALER_VSU_YVSTEP(ch) (0x20000 + 0x20000 * (ch) + 0x8c)31#define SUN8I_SCALER_VSU_YVSTEP(base) ((base) + 0x8c)
29#define SUN8I_SCALER_VSU_YHPHASE(ch) (0x20000 + 0x20000 * (ch) + 0x90)32#define SUN8I_SCALER_VSU_YHPHASE(base) ((base) + 0x90)
30#define SUN8I_SCALER_VSU_YVPHASE(ch) (0x20000 + 0x20000 * (ch) + 0x98)33#define SUN8I_SCALER_VSU_YVPHASE(base) ((base) + 0x98)
31#define SUN8I_SCALER_VSU_CINSIZE(ch) (0x20000 + 0x20000 * (ch) + 0xc0)34#define SUN8I_SCALER_VSU_CINSIZE(base) ((base) + 0xc0)
32#define SUN8I_SCALER_VSU_CHSTEP(ch) (0x20000 + 0x20000 * (ch) + 0xc8)35#define SUN8I_SCALER_VSU_CHSTEP(base) ((base) + 0xc8)
33#define SUN8I_SCALER_VSU_CVSTEP(ch) (0x20000 + 0x20000 * (ch) + 0xcc)36#define SUN8I_SCALER_VSU_CVSTEP(base) ((base) + 0xcc)
34#define SUN8I_SCALER_VSU_CHPHASE(ch) (0x20000 + 0x20000 * (ch) + 0xd0)37#define SUN8I_SCALER_VSU_CHPHASE(base) ((base) + 0xd0)
35#define SUN8I_SCALER_VSU_CVPHASE(ch) (0x20000 + 0x20000 * (ch) + 0xd8)38#define SUN8I_SCALER_VSU_CVPHASE(base) ((base) + 0xd8)
36#define SUN8I_SCALER_VSU_YHCOEFF0(ch, i) \39#define SUN8I_SCALER_VSU_YHCOEFF0(base, i) ((base) + 0x200 + 0x4 * (i))
37 (0x20000 + 0x20000 * (ch) + 0x200 + 0x4 * (i))40#define SUN8I_SCALER_VSU_YHCOEFF1(base, i) ((base) + 0x300 + 0x4 * (i))
38#define SUN8I_SCALER_VSU_YHCOEFF1(ch, i) \41#define SUN8I_SCALER_VSU_YVCOEFF(base, i) ((base) + 0x400 + 0x4 * (i))
39 (0x20000 + 0x20000 * (ch) + 0x300 + 0x4 * (i))42#define SUN8I_SCALER_VSU_CHCOEFF0(base, i) ((base) + 0x600 + 0x4 * (i))
40#define SUN8I_SCALER_VSU_YVCOEFF(ch, i) \43#define SUN8I_SCALER_VSU_CHCOEFF1(base, i) ((base) + 0x700 + 0x4 * (i))
41 (0x20000 + 0x20000 * (ch) + 0x400 + 0x4 * (i))44#define SUN8I_SCALER_VSU_CVCOEFF(base, i) ((base) + 0x800 + 0x4 * (i))
42#define SUN8I_SCALER_VSU_CHCOEFF0(ch, i) \
43 (0x20000 + 0x20000 * (ch) + 0x600 + 0x4 * (i))
44#define SUN8I_SCALER_VSU_CHCOEFF1(ch, i) \
45 (0x20000 + 0x20000 * (ch) + 0x700 + 0x4 * (i))
46#define SUN8I_SCALER_VSU_CVCOEFF(ch, i) \
47 (0x20000 + 0x20000 * (ch) + 0x800 + 0x4 * (i))
48 45
49#define SUN8I_SCALER_VSU_CTRL_EN BIT(0)46#define SUN8I_SCALER_VSU_CTRL_EN BIT(0)
50#define SUN8I_SCALER_VSU_CTRL_COEFF_RDY BIT(4)47#define SUN8I_SCALER_VSU_CTRL_COEFF_RDY BIT(4)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t