[PATCH] drm/rockchip: Filter out alpha formats for primary plane

Kristian H. Kristensen hoegsberg at gmail.com
Mon Apr 16 19:01:03 UTC 2018


Rockchip doesn't support per-pixel alpha blending for the lowest
window in the stack. While the hw supports restacking the windows, we
don't expose that in KMS, so just filter out alpha formats for the
primary plane.

Change-Id: I7828d5bf0f0b5c6dd23f9e52aa01a5a683131d2f
Signed-off-by: Kristian H. Kristensen <hoegsberg at chromium.org>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index fae37b1cd691..2efe78600fd0 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1547,6 +1547,28 @@ static irqreturn_t vop_isr(int irq, void *data)
 	return ret;
 }
 
+static uint32_t formats_for_win(const struct vop_win_phy *phy, uint32_t win,
+				uint32_t *formats, uint32_t max_formats)
+{
+	uint32_t i, j;
+
+	BUG_ON(max_formats < phy->nformats);
+
+	j = 0;
+	for (i = 0; i < phy->nformats; i++) {
+		/*
+		 * win0 doesn't support per-pixel alpha, so don't add any RGBA
+		 * formats for that plane.
+		 */
+		if (win == 0 && is_alpha_support(phy->data_formats[i]))
+			continue;
+
+		formats[j++] = phy->data_formats[i];
+	}
+
+	return j;
+}
+
 static int vop_create_crtc(struct vop *vop)
 {
 	const struct vop_data *vop_data = vop->data;
@@ -1568,15 +1590,17 @@ static int vop_create_crtc(struct vop *vop)
 	for (i = 0; i < vop_data->win_size; i++) {
 		struct vop_win *vop_win = &vop->win[i];
 		const struct vop_win_data *win_data = vop_win->data;
+		uint32_t nformats, formats[16];
 
 		if (win_data->type != DRM_PLANE_TYPE_PRIMARY &&
 		    win_data->type != DRM_PLANE_TYPE_CURSOR)
 			continue;
 
+		nformats = formats_for_win(win_data->phy, i,
+					   formats, ARRAY_SIZE(formats));
 		ret = drm_universal_plane_init(vop->drm_dev, &vop_win->base,
 					       0, &vop_plane_funcs,
-					       win_data->phy->data_formats,
-					       win_data->phy->nformats,
+					       formats, nformats,
 					       win_data->phy->format_modifiers,
 					       win_data->type, NULL);
 		if (ret) {
-- 
2.13.5



More information about the dri-devel mailing list