diff mbox

drm/rockchip: Filter out alpha formats for primary plane

Message ID 20180416190103.83171-1-hoegsberg@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Kristian Høgsberg April 16, 2018, 7:01 p.m. UTC
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@chromium.org>
---
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

Comments

Sean Paul April 16, 2018, 8:38 p.m. UTC | #1
On Mon, Apr 16, 2018 at 12:01:03PM -0700, Kristian H. Kristensen wrote:
> 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

Can you please strip this from upstream commit msgs?

> Signed-off-by: Kristian H. Kristensen <hoegsberg@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];

I guess 16 is probably a safe bet, but perhaps either pull it out into a define,
or just devm_kzalloc the format to phy->nformats. If you choose the former, the
loop in formats_for_win should ensure it doesn't overrun formats.

Sean

>  
>  		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
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Eric Anholt April 16, 2018, 9:59 p.m. UTC | #2
"Kristian H. Kristensen" <hoegsberg@gmail.com> writes:

> 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.

In discussing this for VC4, we noted that an alternative is to just set
up the lowest plane as an RGBX format, since alpha is premultiplied and
the background is black.
Kristian Høgsberg April 16, 2018, 10:04 p.m. UTC | #3
On Mon, Apr 16, 2018 at 2:59 PM Eric Anholt <eric@anholt.net> wrote:

> "Kristian H. Kristensen" <hoegsberg@gmail.com> writes:

> > 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.

> In discussing this for VC4, we noted that an alternative is to just set
> up the lowest plane as an RGBX format, since alpha is premultiplied and
> the background is black.

Doh, of course. Thanks Eric.

Kristian
diff mbox

Patch

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) {