aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <paul.kocialkowski@bootlin.com>2018-11-23 04:24:57 -0500
committerMaxime Ripard <maxime.ripard@bootlin.com>2018-11-27 03:58:22 -0500
commit411e83069e1590cad8c29adcb04de8e73714fa9f (patch)
tree9d089fff5825f9876e92f91750f246dde6ca3aa0
parentdc7d4b655a2c4a8db1342600319a7939eafeb9af (diff)
drm/sun4i: frontend: Apply format sub-sampling to CH1 dimensions
The frontend comes with two "channels", that can be configured independently. When used in YUV mode, the first channel (CH0) represents the luminance component while the second channel (CH1) represents the chrominance. In RGB mode, both have to be configured the same way. Use variables (with the YUV terminology) for each channel's dimensions, calculating the chroma dimensions from the luma dimensions and the sub-sampling factors from the format description. Since the configured size only has pixel precision, the fractional fixed-point part of the source size is dropped for both components to ensure that the scaling factors are accurate. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20181123092515.2511-26-paul.kocialkowski@bootlin.com
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_frontend.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_frontend.c b/drivers/gpu/drm/sun4i/sun4i_frontend.c
index a75a74fc225d..72e0f1b1624b 100644
--- a/drivers/gpu/drm/sun4i/sun4i_frontend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_frontend.c
@@ -239,16 +239,24 @@ void sun4i_frontend_update_coord(struct sun4i_frontend *frontend,
239 struct drm_plane *plane) 239 struct drm_plane *plane)
240{ 240{
241 struct drm_plane_state *state = plane->state; 241 struct drm_plane_state *state = plane->state;
242 struct drm_framebuffer *fb = state->fb;
243 uint32_t luma_width, luma_height;
244 uint32_t chroma_width, chroma_height;
242 245
243 /* Set height and width */ 246 /* Set height and width */
244 DRM_DEBUG_DRIVER("Frontend size W: %u H: %u\n", 247 DRM_DEBUG_DRIVER("Frontend size W: %u H: %u\n",
245 state->crtc_w, state->crtc_h); 248 state->crtc_w, state->crtc_h);
249
250 luma_width = state->src_w >> 16;
251 luma_height = state->src_h >> 16;
252
253 chroma_width = DIV_ROUND_UP(luma_width, fb->format->hsub);
254 chroma_height = DIV_ROUND_UP(luma_height, fb->format->vsub);
255
246 regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_INSIZE_REG, 256 regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_INSIZE_REG,
247 SUN4I_FRONTEND_INSIZE(state->src_h >> 16, 257 SUN4I_FRONTEND_INSIZE(luma_height, luma_width));
248 state->src_w >> 16));
249 regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_INSIZE_REG, 258 regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_INSIZE_REG,
250 SUN4I_FRONTEND_INSIZE(state->src_h >> 16, 259 SUN4I_FRONTEND_INSIZE(chroma_height, chroma_width));
251 state->src_w >> 16));
252 260
253 regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_OUTSIZE_REG, 261 regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_OUTSIZE_REG,
254 SUN4I_FRONTEND_OUTSIZE(state->crtc_h, state->crtc_w)); 262 SUN4I_FRONTEND_OUTSIZE(state->crtc_h, state->crtc_w));
@@ -256,14 +264,14 @@ void sun4i_frontend_update_coord(struct sun4i_frontend *frontend,
256 SUN4I_FRONTEND_OUTSIZE(state->crtc_h, state->crtc_w)); 264 SUN4I_FRONTEND_OUTSIZE(state->crtc_h, state->crtc_w));
257 265
258 regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_HORZFACT_REG, 266 regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_HORZFACT_REG,
259 state->src_w / state->crtc_w); 267 (luma_width << 16) / state->crtc_w);
260 regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_HORZFACT_REG, 268 regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_HORZFACT_REG,
261 state->src_w / state->crtc_w); 269 (chroma_width << 16) / state->crtc_w);
262 270
263 regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTFACT_REG, 271 regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTFACT_REG,
264 state->src_h / state->crtc_h); 272 (luma_height << 16) / state->crtc_h);
265 regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTFACT_REG, 273 regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTFACT_REG,
266 state->src_h / state->crtc_h); 274 (chroma_height << 16) / state->crtc_h);
267 275
268 regmap_write_bits(frontend->regs, SUN4I_FRONTEND_FRM_CTRL_REG, 276 regmap_write_bits(frontend->regs, SUN4I_FRONTEND_FRM_CTRL_REG,
269 SUN4I_FRONTEND_FRM_CTRL_REG_RDY, 277 SUN4I_FRONTEND_FRM_CTRL_REG_RDY,