Received: by 10.213.65.68 with SMTP id h4csp403442imn; Tue, 27 Mar 2018 01:11:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELvY+/5aFrKJVOxQPADxzh/wDJzuUOPXfDlJ7gn2sltposHnqadTgJ9Vcxz3wOiDw2zOjEV0 X-Received: by 10.98.131.75 with SMTP id h72mr26539760pfe.166.1522138268691; Tue, 27 Mar 2018 01:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522138268; cv=none; d=google.com; s=arc-20160816; b=Qn6YthNGNaY0r53tpMQGHUfFvhCH7RaJwcNStGq1LFj9cN8c00OIfnLUA5+7emOmf0 i73fo59JG5qBkgv+mDfqPqbky7RC7HxPtv0tDP/NbnWUEiB3HPrk8Lr6Qutj9E7/PkCC Kv2+cUZd3eUeI+/mErh1+bXLJSkEI4lP5GCoxK2C5Bmxxaltc1gn6nspljhenXi7QgrV VqasXIpVAKIY3xGQEzpjg1ru4rB4ozkq2xCj7/IIw4AEeysD8Fl/dQw23NFvuNaJ8MEf Vw1YuhRKyrPRy7cfg/taVTB/EpMFWXUpEdY1oYjue79k2tgo0q7GVfV56/coZhMJ29hN U3Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:references :in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=G599aG11gr8y4aH5gr0V3IzoYJil3R3FjRK/ABx2s3M=; b=FgGmtEyz4QIlTn0d+Riwt+eWgUvBQlk7JXGUeIO805sTBCnikv+h1CdexJfQCsY+sZ qlcWUwPZOA2yGVO8p8IuBna5Yo5Y1jQx1AF3kzvylEQCMbh0Oh5VrarfvhqeEV9xTjWZ oI/2yTZXVPDbfg40hu4EqERtXW1vMgya3GZ9W+8Sisx41ccUPbCSBxRC6ouFJt10KN8q vN8/rFEFyTbB0/CL5BmJy+/nZM2d6xnTdH0UalBwCfzuQMn5T0Q5/YjGLLI1sgN9VelW hF+TxkPZKoZ1/uEdUt60V1JaRegx1olXQ7fqJjNG+IkXmFj6TjLbUQdhvURLhoMoqdoR O5Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10-v6si759544pll.237.2018.03.27.01.10.54; Tue, 27 Mar 2018 01:11:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752188AbeC0IJ4 (ORCPT + 99 others); Tue, 27 Mar 2018 04:09:56 -0400 Received: from mail.bootlin.com ([62.4.15.54]:36552 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751067AbeC0IJx (ORCPT ); Tue, 27 Mar 2018 04:09:53 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id EA63E20711; Tue, 27 Mar 2018 10:09:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from aptenodytes (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 747382055E; Tue, 27 Mar 2018 10:09:50 +0200 (CEST) Message-ID: <1522138128.1110.11.camel@bootlin.com> Subject: Re: [PATCH 04/10] drm/sun4i: Explicitly list and check formats supported by the backend From: Paul Kocialkowski To: Maxime Ripard Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, David Airlie , Chen-Yu Tsai , Daniel Vetter , Gustavo Padovan , Sean Paul Date: Tue, 27 Mar 2018 10:08:48 +0200 In-Reply-To: <20180323100330.2sijtsp5bdyyel5a@flea> References: <20180321152904.22411-1-paul.kocialkowski@bootlin.com> <20180321152904.22411-5-paul.kocialkowski@bootlin.com> <20180323100330.2sijtsp5bdyyel5a@flea> Organization: Bootlin Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-7YxdHzJFmXMgAXat6VNd" X-Mailer: Evolution 3.26.5 Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-7YxdHzJFmXMgAXat6VNd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Fri, 2018-03-23 at 11:03 +0100, Maxime Ripard wrote: > On Wed, Mar 21, 2018 at 04:28:58PM +0100, Paul Kocialkowski wrote: > > In order to check whether the backend supports a specific format, an > > explicit list and a related helper are introduced. > >=20 > > They are then used to determine whether the frontend should be used > > for > > a layer, when the format is not supported by the backend. > >=20 > > Signed-off-by: Paul Kocialkowski > > --- > > drivers/gpu/drm/sun4i/sun4i_backend.c | 48 > > ++++++++++++++++++++++++++++++++++- > > drivers/gpu/drm/sun4i/sun4i_backend.h | 1 + > > 2 files changed, 48 insertions(+), 1 deletion(-) > >=20 > > diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c > > b/drivers/gpu/drm/sun4i/sun4i_backend.c > > index 274a1db6fa8e..7703ba989743 100644 > > --- a/drivers/gpu/drm/sun4i/sun4i_backend.c > > +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c > > @@ -172,6 +172,39 @@ static int > > sun4i_backend_drm_format_to_layer(u32 format, u32 *mode) > > return 0; > > } > > =20 > > +static const uint32_t sun4i_backend_formats[] =3D { > > + /* RGB */ > > + DRM_FORMAT_ARGB4444, > > + DRM_FORMAT_RGBA4444, > > + DRM_FORMAT_ARGB1555, > > + DRM_FORMAT_RGBA5551, > > + DRM_FORMAT_RGB565, > > + DRM_FORMAT_RGB888, > > + DRM_FORMAT_XRGB8888, > > + DRM_FORMAT_BGRX8888, > > + DRM_FORMAT_ARGB8888, > > + /* YUV422 */ > > + DRM_FORMAT_YUYV, > > + DRM_FORMAT_YVYU, > > + DRM_FORMAT_UYVY, > > + DRM_FORMAT_VYUY, >=20 > Ordering them by alphabetical order would be better. Frankly I find it a lot harder to read when the formats are not grouped by "family". This is the drm_fourcc enumeration order, which has some kind of logic behind it. What is the advantage of alphabetical ordering here? > > +}; > > + > > +bool sun4i_backend_format_is_supported(uint32_t fmt) > > +{ > > + bool found =3D false; > > + unsigned int i; > > + > > + for (i =3D 0; i < ARRAY_SIZE(sun4i_backend_formats); i++) { > > + if (sun4i_backend_formats[i] =3D=3D fmt) { > > + found =3D true; > > + break; >=20 > return true? Definitely. > > + } > > + } > > + > > + return found; > > +} > > + > > int sun4i_backend_update_layer_coord(struct sun4i_backend *backend, > > int layer, struct drm_plane > > *plane) > > { > > @@ -436,15 +469,28 @@ static bool > > sun4i_backend_plane_uses_frontend(struct drm_plane_state *state) > > { > > struct sun4i_layer *layer =3D plane_to_sun4i_layer(state- > > >plane); > > struct sun4i_backend *backend =3D layer->backend; > > + struct drm_framebuffer *fb =3D state->fb; > > =20 > > if (IS_ERR(backend->frontend)) > > return false; > > =20 > > + /* > > + * Let's pretend that every format is either supported by > > the backend or > > + * the frontend. This is not true in practice, as some > > tiling modes are > > + * not supported by either. There is still room to check > > this later in > > + * the atomic check process. >=20 > Then I guess there these tiling modes will not be exposed and we won't > ever get that far, wouldn't we? This comment is indeed a bit irrelevant at this stage given that the tiling modifier was not introduced yet. So in practice, this never happens with this patch. I should probably move it to a subsequent one. > > + */ > > + if (!sun4i_backend_format_is_supported(fb->format->format)) > > + return true; >=20 > Even though there's a comment, this is not really natural. We are > checking whether the frontend supports the current plane_state, so it > just makes more sense to check whether the frontend supports the > format, rather than if the backend doesn't support them. The rationale behind this logic is that we should try to use the backend first and only use the frontend as a last resort. Some formats are supported by both and checking that the backend supports a format first ensures that we don't bring up the frontend without need. Cheers, --=20 Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com --=-7YxdHzJFmXMgAXat6VNd 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+fv9EFAlq5/BAACgkQ3cLmz3+f v9EpBQf+MGBvlBKQs5IFljknOQ0NY7nauEqUAVxNtGLO9ZRdytdo+5tJA+6kFujw K/J8b0YObb6qFmteKltlbRc4cCWYnUZNT+LssSk13oTDaTKTiIpGzaxGuLrnVXqC QfVH7fptxTmM5uE75cfF3gsZZRO5yjopdwJuKu3VfjNVpKzNHFhslG6p9T8LO+Tb Exs0P/5YNLHlrKnNg9QU0S7heCULEBu/4dF62tpgJZFLynDtnhVzQYISijMNhNv/ 7oIxAtGquIQQYQRjZt0FCxoP1S+0ZfF8Dpmejc/SGtw167v46adDRhJ2721PmUQz cbk4tF9u+H/YriACylCrYNl55hId2A== =buD5 -----END PGP SIGNATURE----- --=-7YxdHzJFmXMgAXat6VNd--