Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/exynos: mixer: refactor layer setup

Properly configure blending properties of given hardware layer based on
the selected pixel format. Currently only per-pixel-based alpha is possible
when respective pixel format has been selected. Configuration of global,
per-plane alpha value, color key and background color will be added later.

This patch is heavily inspired by earlier work done by Tobias Jakobi
<tjakobi@math.uni-bielefeld.de>.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>

authored by

Marek Szyprowski and committed by
Inki Dae
f657a996 5bec0193

+44
+43
drivers/gpu/drm/exynos/exynos_mixer.c
··· 165 165 70, 59, 48, 37, 27, 19, 11, 5, 166 166 }; 167 167 168 + static inline bool is_alpha_format(unsigned int pixel_format) 169 + { 170 + switch (pixel_format) { 171 + case DRM_FORMAT_ARGB8888: 172 + return true; 173 + default: 174 + return false; 175 + } 176 + } 177 + 168 178 static inline u32 vp_reg_read(struct mixer_resources *res, u32 reg_id) 169 179 { 170 180 return readl(res->vp_regs + reg_id); ··· 302 292 filter_y_vert_tap4, sizeof(filter_y_vert_tap4)); 303 293 vp_filter_set(res, VP_POLY4_C0_LL, 304 294 filter_cr_horiz_tap4, sizeof(filter_cr_horiz_tap4)); 295 + } 296 + 297 + static void mixer_cfg_gfx_blend(struct mixer_context *ctx, unsigned int win, 298 + bool alpha) 299 + { 300 + struct mixer_resources *res = &ctx->mixer_res; 301 + u32 val; 302 + 303 + val = MXR_GRP_CFG_COLOR_KEY_DISABLE; /* no blank key */ 304 + if (alpha) { 305 + /* blending based on pixel alpha */ 306 + val |= MXR_GRP_CFG_BLEND_PRE_MUL; 307 + val |= MXR_GRP_CFG_PIXEL_BLEND_EN; 308 + } 309 + mixer_reg_writemask(res, MXR_GRAPHIC_CFG(win), 310 + val, MXR_GRP_CFG_MISC_MASK); 311 + } 312 + 313 + static void mixer_cfg_vp_blend(struct mixer_context *ctx) 314 + { 315 + struct mixer_resources *res = &ctx->mixer_res; 316 + u32 val; 317 + 318 + /* 319 + * No blending at the moment since the NV12/NV21 pixelformats don't 320 + * have an alpha channel. However the mixer supports a global alpha 321 + * value for a layer. Once this functionality is exposed, we can 322 + * support blending of the video layer through this. 323 + */ 324 + val = 0; 325 + mixer_reg_write(res, MXR_VIDEO_CFG, val); 305 326 } 306 327 307 328 static void mixer_vsync_set_update(struct mixer_context *ctx, bool enable) ··· 560 519 mixer_cfg_scan(ctx, mode->vdisplay); 561 520 mixer_cfg_rgb_fmt(ctx, mode->vdisplay); 562 521 mixer_cfg_layer(ctx, plane->index, state->zpos + 1, true); 522 + mixer_cfg_vp_blend(ctx); 563 523 mixer_run(ctx); 564 524 565 525 mixer_vsync_set_update(ctx, true); ··· 676 634 mixer_cfg_scan(ctx, mode->vdisplay); 677 635 mixer_cfg_rgb_fmt(ctx, mode->vdisplay); 678 636 mixer_cfg_layer(ctx, win, state->zpos + 1, true); 637 + mixer_cfg_gfx_blend(ctx, win, is_alpha_format(fb->pixel_format)); 679 638 680 639 /* layer update mandatory for mixer 16.0.33.0 */ 681 640 if (ctx->mxr_ver == MXR_VER_16_0_33_0 ||
+1
drivers/gpu/drm/exynos/regs-mixer.h
··· 113 113 #define MXR_GRP_CFG_BLEND_PRE_MUL (1 << 20) 114 114 #define MXR_GRP_CFG_WIN_BLEND_EN (1 << 17) 115 115 #define MXR_GRP_CFG_PIXEL_BLEND_EN (1 << 16) 116 + #define MXR_GRP_CFG_MISC_MASK ((3 << 16) | (3 << 20)) 116 117 #define MXR_GRP_CFG_FORMAT_VAL(x) MXR_MASK_VAL(x, 11, 8) 117 118 #define MXR_GRP_CFG_FORMAT_MASK MXR_GRP_CFG_FORMAT_VAL(~0) 118 119 #define MXR_GRP_CFG_ALPHA_VAL(x) MXR_MASK_VAL(x, 7, 0)