From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Anholt Subject: Re: [PATCH 2/3] drm: Make sure at least one plane supports the fb format Date: Thu, 15 Mar 2018 10:42:17 -0700 Message-ID: <87woydgrra.fsf@anholt.net> References: <20180312204035.31387-1-ville.syrjala@linux.intel.com> <20180312204035.31387-2-ville.syrjala@linux.intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1081374988==" Return-path: In-Reply-To: <20180312204035.31387-2-ville.syrjala@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Ville Syrjala , dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1081374988== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ville Syrjala writes: > From: Ville Syrj=C3=A4l=C3=A4 > > To make life easier for drivers, let's have the core check that the > requested pixel format is supported by at least one plane when creating > a new framebuffer. > > This eases the burden on drivers by making sure they'll never get > requests to create fbs with unsupported pixel formats. Thanks to the > new .fb_modifier() hook this check can now be done whether the request > specifies the modifier directly or driver has to deduce it from the > gem bo tiling (or via any other method really). > > v0: Accept anyformat if the driver doesn't do planes (Eric) > s/planes_have_format/any_plane_has_format/ (Eric) > Check the modifier as well since we already have a function > that does both > v3: Don't do the check in the core since we may not know the > modifier yet, instead export the function and let drivers > call it themselves > v4: Unexport the functiona and put the format_default check back > since this will again be called by the core, ie. undo v3 ;) > > Cc: Eric Anholt > Testcase: igt/kms_addfb_basic/expected-formats > Signed-off-by: Ville Syrj=C3=A4l=C3=A4 > --- > drivers/gpu/drm/drm_framebuffer.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_fram= ebuffer.c > index 21d3d51eb261..e618a6b728d4 100644 > --- a/drivers/gpu/drm/drm_framebuffer.c > +++ b/drivers/gpu/drm/drm_framebuffer.c > @@ -152,6 +152,26 @@ static int fb_plane_height(int height, > return DIV_ROUND_UP(height, format->vsub); > } >=20=20 > +static bool any_plane_has_format(struct drm_device *dev, > + u32 format, u64 modifier) > +{ > + struct drm_plane *plane; > + > + drm_for_each_plane(plane, dev) { > + /* > + * In case the driver doesn't really do > + * planes we have to accept any format here. > + */ > + if (plane->format_default) > + return true; > + > + if (drm_plane_check_pixel_format(plane, format, modifier) =3D=3D 0) > + return true; > + } > + > + return false; > +} This drm_plane_check_pixel_format() will always fail for VC4's SAND modifiers or VC5's UIF modifiers, where we're using the middle 48 bits as a bit of metadata (like how we have horizontal stride passed outside of the modifier) and you can't list all of the possible values in an array on the plane. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE/JuuFDWp9/ZkuCBXtdYpNtH8nugFAlqqsHoACgkQtdYpNtH8 nugVbw//boyRbboi3hBTn8/F84hFKYbxNhTBBb6iMMY/80jq/bb4OeG5M8oxFona jV58QiQcDA8m+Hlv/NGmwS008eGQ9L6Ue6Nm4MAZANsLKgkCng6QY+8m85HZ22j+ /A4AzRwrakVGtouEHER6pRvS7NBqNKuVW79j01sre3z6M4zHD3JnlvaPlWNKGeCq OYFyO4pCGF2Ot6lxORaIoZU74eI0q7hadZHlm41v1kI5Rn+lUhTyyi9o+ugZQQra JuUP0WDfVq3F97hwpQVZ3JT8UAnoO6YjZ6rz1yc7jDfOJuCGSPXto4Z3o8gCILPY Bi3Pmy4XuP0RSc4rQFqnqHnSrob82vV4cDgKRBdiPu2ZbD7edrPrceAho3XKjpcK zu2tgVo45FQqxAJZtJxHXZjpO/PBEw3k27MVcqJwWOp9wqkHSGDmKvkLkpTGOTFr LP2HQ3MIAvFe6s/PB7tvSBurkw4vna5Rn1sKtK1cAjuEpjNRdQVUwjXX911q4Z+0 xQJNM4R5uYfGrT00S9i5dGZp7V2c3q3Pl2kSgKsc2rjkWJGDL4yNF0BKvfMNKJLS NdrMgihx5xUvC+aEXN0CvtaxeevV//2WwNFSBK64X2zm3q16zhwJNns5dZSLthkE Ol/LYg9uD2iU4IKuh2GrFTFtpKSnHwwCXcuIfDy24gmh+yxrNW0= =dWyV -----END PGP SIGNATURE----- --=-=-=-- --===============1081374988== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1081374988==--