Linux 7.3 added validate_blend_mode_for_alpha_formats(), which warns once
per plane that exposes a pixel format with an alpha channel but has no
blend mode property:

  sun4i-drm display-engine: [drm] [PLANE:35:plane-0] pixel format with
  alpha exposed but blend mode not setup. Please fix.

The mixer blends a layer using its own alpha channel: ALPHA_MODE is set
to PIXEL when plane alpha is opaque and to COMBINED otherwise, while
BLEND_PREMULTIPLY keeps its reset value.  That is straight alpha, i.e. the
DRM "coverage" blending equation.

Advertise exactly DRM_MODE_BLEND_COVERAGE on every mixer layer that can
expose an alpha format (UI always, VI on DE3 and later).  This matches the
existing register programming, keeps userspace behaviour unchanged and
satisfies the validation.  Premultiplied blending would require driving
BLEND_PREMULTIPLY and is left as a follow-up.

The DE1 backend planes are handled by the next patch.

Signed-off-by: Yang Siyuan <[email protected]>
---
 drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 7 +++++++
 drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c 
b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
index 00756ab..57bc603 100644
--- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
@@ -283,6 +283,13 @@ struct sun8i_layer *sun8i_ui_layer_init_one(struct 
drm_device *drm,
                return ERR_PTR(ret);
        }
 
+       ret = drm_plane_create_blend_mode_property(&layer->plane,
+                                                  
BIT(DRM_MODE_BLEND_COVERAGE));
+       if (ret) {
+               dev_err(drm->dev, "Couldn't add blend mode property\n");
+               return ERR_PTR(ret);
+       }
+
        ret = drm_plane_create_zpos_property(&layer->plane, index,
                                             0, plane_cnt - 1);
        if (ret) {
diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c 
b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
index 09f668c..ab95c55 100644
--- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
@@ -436,6 +436,15 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct 
drm_device *drm,
                }
        }
 
+       if (layer->cfg->de_type >= SUN8I_MIXER_DE3) {
+               ret = drm_plane_create_blend_mode_property(&layer->plane,
+                                                          
BIT(DRM_MODE_BLEND_COVERAGE));
+               if (ret) {
+                       dev_err(drm->dev, "Couldn't add blend mode property\n");
+                       return ERR_PTR(ret);
+               }
+       }
+
        ret = drm_plane_create_zpos_property(&layer->plane, index,
                                             0, plane_cnt - 1);
        if (ret) {
-- 
2.56.1

Reply via email to