All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: Filter out alpha formats for primary plane
@ 2018-04-16 19:01 Kristian H. Kristensen
  2018-04-16 20:38 ` Sean Paul
  2018-04-16 21:59 ` Eric Anholt
  0 siblings, 2 replies; 4+ messages in thread
From: Kristian H. Kristensen @ 2018-04-16 19:01 UTC (permalink / raw)
  To: dri-devel; +Cc: Kristian H. Kristensen

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

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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/rockchip: Filter out alpha formats for primary plane
  2018-04-16 19:01 [PATCH] drm/rockchip: Filter out alpha formats for primary plane Kristian H. Kristensen
@ 2018-04-16 20:38 ` Sean Paul
  2018-04-16 21:59 ` Eric Anholt
  1 sibling, 0 replies; 4+ messages in thread
From: Sean Paul @ 2018-04-16 20:38 UTC (permalink / raw)
  To: Kristian H. Kristensen; +Cc: Kristian H. Kristensen, dri-devel

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

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/rockchip: Filter out alpha formats for primary plane
  2018-04-16 19:01 [PATCH] drm/rockchip: Filter out alpha formats for primary plane Kristian H. Kristensen
  2018-04-16 20:38 ` Sean Paul
@ 2018-04-16 21:59 ` Eric Anholt
  2018-04-16 22:04   ` Kristian Høgsberg
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Anholt @ 2018-04-16 21:59 UTC (permalink / raw)
  To: Kristian H. Kristensen, dri-devel; +Cc: Kristian H. Kristensen


[-- Attachment #1.1: Type: text/plain, Size: 451 bytes --]

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

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/rockchip: Filter out alpha formats for primary plane
  2018-04-16 21:59 ` Eric Anholt
@ 2018-04-16 22:04   ` Kristian Høgsberg
  0 siblings, 0 replies; 4+ messages in thread
From: Kristian Høgsberg @ 2018-04-16 22:04 UTC (permalink / raw)
  To: Eric Anholt; +Cc: Kristian H. Kristensen, dri-devel

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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-16 22:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16 19:01 [PATCH] drm/rockchip: Filter out alpha formats for primary plane Kristian H. Kristensen
2018-04-16 20:38 ` Sean Paul
2018-04-16 21:59 ` Eric Anholt
2018-04-16 22:04   ` Kristian Høgsberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.