From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Kocialkowski Subject: Re: [PATCH v4 4/5] drm/sun4i: Add support for plane alpha Date: Wed, 04 Apr 2018 10:49:21 +0200 Message-ID: References: <7d9d81363e23bd5d8a312b443f9080b52923f7e1.1520974361.git-series.maxime.ripard@bootlin.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0680302548==" Return-path: Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 27316897EF for ; Wed, 4 Apr 2018 08:50:39 +0000 (UTC) In-Reply-To: <7d9d81363e23bd5d8a312b443f9080b52923f7e1.1520974361.git-series.maxime.ripard@bootlin.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Maxime Ripard , Gustavo Padovan , Daniel Vetter , Maarten Lankhorst , Sean Paul Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Stefan Schake , Boris Brezillon , Chen-Yu Tsai , Laurent Pinchart List-Id: dri-devel@lists.freedesktop.org --===============0680302548== Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-L2Mhz2T88OfTXBfzJ+EC" --=-L2Mhz2T88OfTXBfzJ+EC Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Tue, 2018-03-13 at 21:54 +0100, Maxime Ripard wrote: > Our backend supports a per-plane alpha property. Support it through > our new > helper. See one comment below. Otherwise, this is: Reviewed-by: Paul Kocialkowski > Reviewed-by: Chen-Yu Tsai > Signed-off-by: Maxime Ripard > --- > drivers/gpu/drm/sun4i/sun4i_backend.c | 16 +++++++++++++--- > drivers/gpu/drm/sun4i/sun4i_backend.h | 3 +++ > drivers/gpu/drm/sun4i/sun4i_layer.c | 2 ++ > 3 files changed, 18 insertions(+), 3 deletions(-) >=20 > diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c > b/drivers/gpu/drm/sun4i/sun4i_backend.c > index 092ade4ff6a5..98cd4a8a93ed 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_backend.c > +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c > @@ -186,6 +186,15 @@ int sun4i_backend_update_layer_formats(struct > sun4i_backend *backend, > DRM_DEBUG_DRIVER("Switching display backend interlaced mode > %s\n", > interlaced ? "on" : "off"); > =20 > + val =3D SUN4I_BACKEND_ATTCTL_REG0_LAY_GLBALPHA(state->alpha >> > 8); Have you checked that the alpha value expected by the hardware does match the "premultiplied" alpha blemding equation? > + if (state->alpha !=3D DRM_BLEND_ALPHA_OPAQUE) > + val |=3D SUN4I_BACKEND_ATTCTL_REG0_LAY_GLBALPHA_EN; Maybe insert a newline for improved readability here? > + regmap_update_bits(backend->engine.regs, > + SUN4I_BACKEND_ATTCTL_REG0(layer), > + SUN4I_BACKEND_ATTCTL_REG0_LAY_GLBALPHA_MAS > K | > + SUN4I_BACKEND_ATTCTL_REG0_LAY_GLBALPHA_EN, > + val); > + > ret =3D sun4i_backend_drm_format_to_layer(fb->format->format, > &val); > if (ret) { > DRM_DEBUG_DRIVER("Invalid format\n"); > @@ -359,7 +368,7 @@ static int sun4i_backend_atomic_check(struct > sunxi_engine *engine, > DRM_DEBUG_DRIVER("Plane FB format is %s\n", > drm_get_format_name(fb->format- > >format, > &format_name)); > - if (fb->format->has_alpha) > + if (fb->format->has_alpha || (plane_state->alpha !=3D > DRM_BLEND_ALPHA_OPAQUE)) > num_alpha_planes++; > =20 > DRM_DEBUG_DRIVER("Plane zpos is %d\n", > @@ -412,7 +421,8 @@ static int sun4i_backend_atomic_check(struct > sunxi_engine *engine, > } > =20 > /* We can't have an alpha plane at the lowest position */ > - if (plane_states[0]->fb->format->has_alpha) > + if (plane_states[0]->fb->format->has_alpha || > + (plane_states[0]->alpha !=3D DRM_BLEND_ALPHA_OPAQUE)) > return -EINVAL; > =20 > for (i =3D 1; i < num_planes; i++) { > @@ -424,7 +434,7 @@ static int sun4i_backend_atomic_check(struct > sunxi_engine *engine, > * The only alpha position is the lowest plane of the > * second pipe. > */ > - if (fb->format->has_alpha) > + if (fb->format->has_alpha || (p_state->alpha !=3D > DRM_BLEND_ALPHA_OPAQUE)) > current_pipe++; > =20 > s_state->pipe =3D current_pipe; > diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.h > b/drivers/gpu/drm/sun4i/sun4i_backend.h > index 52e77591186a..03294d5dd1a2 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_backend.h > +++ b/drivers/gpu/drm/sun4i/sun4i_backend.h > @@ -68,11 +68,14 @@ > #define SUN4I_BACKEND_CKMIN_REG 0x884 > #define SUN4I_BACKEND_CKCFG_REG 0x888 > #define SUN4I_BACKEND_ATTCTL_REG0(l) (0x890 + (0x4 * > (l))) > +#define SUN4I_BACKEND_ATTCTL_REG0_LAY_GLBALPHA_MASK GENMASK(31 > , 24) > +#define SUN4I_BACKEND_ATTCTL_REG0_LAY_GLBALPHA(x) ((x) > << 24) > #define SUN4I_BACKEND_ATTCTL_REG0_LAY_PIPESEL_MASK BIT(15) > #define SUN4I_BACKEND_ATTCTL_REG0_LAY_PIPESEL(x) ((x) > << 15) > #define SUN4I_BACKEND_ATTCTL_REG0_LAY_PRISEL_MASK GENMASK(11, > 10) > #define SUN4I_BACKEND_ATTCTL_REG0_LAY_PRISEL(x) =09 > ((x) << 10) > #define SUN4I_BACKEND_ATTCTL_REG0_LAY_VDOEN BIT(1) > +#define SUN4I_BACKEND_ATTCTL_REG0_LAY_GLBALPHA_EN BIT(0) > =20 > #define SUN4I_BACKEND_ATTCTL_REG1(l) (0x8a0 + (0x4 * > (l))) > #define SUN4I_BACKEND_ATTCTL_REG1_LAY_HSCAFCT GENMASK( > 15, 14) > diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c > b/drivers/gpu/drm/sun4i/sun4i_layer.c > index 33ad377569ec..cf7857b8ac5c 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_layer.c > +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c > @@ -37,6 +37,7 @@ static void sun4i_backend_layer_reset(struct > drm_plane *plane) > if (state) { > plane->state =3D &state->state; > plane->state->plane =3D plane; > + plane->state->alpha =3D DRM_BLEND_ALPHA_OPAQUE; > plane->state->zpos =3D layer->id; > } > } > @@ -163,6 +164,7 @@ static struct sun4i_layer > *sun4i_layer_init_one(struct drm_device *drm, > &sun4i_backend_layer_helper_funcs); > layer->backend =3D backend; > =20 > + drm_plane_create_alpha_property(&layer->plane); > drm_plane_create_zpos_property(&layer->plane, 0, 0, > SUN4I_BACKEND_NUM_LAYERS - 1); > =20 --=20 Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com --=-L2Mhz2T88OfTXBfzJ+EC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAlrEkZEACgkQ3cLmz3+f v9FqJgf/VdpNP3zZtqGIjQ6EtQEWzNsfKoT3YoWkCaTq/TL2PVJG2PW08krDZcbl pCGK9hyK5+dckoh2gvfaqU6jstDEbxi/yFCYPRvklsTIjmVj+Vn1LUGy5AfTcRkn pPv0Q4dqZHJsC5tFFrP7moa4TYI9qgbDcDSm0x+oiVu26PTXm3JinNuVU3jW3i5Q 15lXcp0OH7fRJobcLeKNZd8Rlb/enuUIFLnuGNMckK4qtAoRU1hARQT5JYZJ/nFJ ehy/hl1yPXfS/qguqFpxmAJda3WOKpH62oImZ7qzTbop7zkTm0LW9tGNrPcglICM mq4a17CscTEpmNsaFmSfoR8HwpIuMw== =u+Bb -----END PGP SIGNATURE----- --=-L2Mhz2T88OfTXBfzJ+EC-- --===============0680302548== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0680302548==--