Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4174121yba; Wed, 17 Apr 2019 06:14:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxu6Gq0T6TaSN1tFdv6TYfYKTUAdTmDnC+y6Mr2HwwC5a2E5DndTZ/ijuYdASKST53OP2Th X-Received: by 2002:a65:420b:: with SMTP id c11mr83068830pgq.24.1555506862768; Wed, 17 Apr 2019 06:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555506862; cv=none; d=google.com; s=arc-20160816; b=a9UXA/aA40+9hi1N3mGLl3Df2Kh4iKuwVGZ+AYkiU+NuIFRaFOFS/ZLAUO3GHYeUhh yN6/xN5HaCBozk8DUjpK+OhZ+u8savbNMPRl4T/5SMOZWK4t7PHn+2QY94rmerqISkOi JGe1MXSMLtMgDC8UBVIlAZryGdSkBXdTBiuoc0Oiktv+/y3aFqSpbxQU6oEv7QlC5e/v TnwgoCuxNbZKuRan7Us4wsGspVwYNRI3CS1WKgeU1jP/udFNDy+jt/7zHeB41m3Rdvq3 QFkNG9VWBclZRltWlNKiM28T5gJsA+2tGpjQTCARm8frEOM/vgFOc0xXHHl4VhTCZAZo s3og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=x8L0pGbT65lsAePRdDwJCaoqJ2MCaZaJcKyOxASa3ug=; b=gWBLUp0UtkhipkperuivqLTopVWZPiKRQdtzia/u16Cw8Zel3rJwJglfuo4to6yWdQ dQ9CQO5RYv0JnWz0Q1FFVozzuKc2xO3beNLOBuZ+E9VRmAujeNHpDS9jso8JqgxL2BWV A9H0bYaP6kN20Ia7hqdpaO9aA4xMw+2quuJiUB7wPz19pKaeNHD+xfVtUO9ix1G/IqNb 1RLrCo37FtMSQKzfv9ZWrUQwcHBvCkPSOeyiTVjKAJ7ASRUHJiUCyNYsC7NFhZZBisfY cj7DQAMhrFBzwLEJOwyhRIM4fg9+i3+8dTmpdyFNQS6F9YQgc7ZPaNMSBVvz2OWh8qxP MO1g== 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 e1si49972147pgf.254.2019.04.17.06.14.07; Wed, 17 Apr 2019 06:14:22 -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 S1732222AbfDQNNF (ORCPT + 99 others); Wed, 17 Apr 2019 09:13:05 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:57265 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731958AbfDQNNC (ORCPT ); Wed, 17 Apr 2019 09:13:02 -0400 Received: from localhost (aaubervilliers-681-1-42-238.w90-88.abo.wanadoo.fr [90.88.160.238]) (Authenticated sender: maxime.ripard@bootlin.com) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 799ED200019; Wed, 17 Apr 2019 13:12:57 +0000 (UTC) Date: Wed, 17 Apr 2019 15:12:56 +0200 From: Maxime Ripard To: Maarten Lankhorst Cc: Daniel Vetter , David Airlie , Sean Paul , Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Laurent Pinchart , Thomas Petazzoni , Paul Kocialkowski , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Emil Velikov Subject: Re: [PATCH 04/20] drm/fourcc: Pass the format_info pointer to drm_format_plane_width/height Message-ID: <20190417131256.s7dwk6cda5ezgedd@flea> References: <194fd02a37172de6f2a799fee5c98ced5e7e9d76.1555487650.git-series.maxime.ripard@bootlin.com> <776131c6-b8be-4302-ea9a-f7d84203f28c@linux.intel.com> <20190417110119.ygp6h7kpzzo5a27l@flea> <8d909dcf-16de-7462-1cc6-2713778ed8b1@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kvnadm2bo6fe5gqf" Content-Disposition: inline In-Reply-To: <8d909dcf-16de-7462-1cc6-2713778ed8b1@linux.intel.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --kvnadm2bo6fe5gqf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Apr 17, 2019 at 01:10:33PM +0200, Maarten Lankhorst wrote: > Op 17-04-2019 om 13:01 schreef Maxime Ripard: > > On Wed, Apr 17, 2019 at 12:47:48PM +0200, Maarten Lankhorst wrote: > >>> +/** > >>> + * drm_format_info_plane_width - width of the plane given the first plane > >>> + * @format: pixel format info > >>> + * @width: width of the first plane > >>> + * @plane: plane index > >>> + * > >>> + * Returns: > >>> + * The width of @plane, given that the width of the first plane is @width. > >>> + */ > >>> +static inline > >>> +int drm_format_info_plane_width(const struct drm_format_info *info, int width, > >>> + int plane) > >>> +{ > >>> + if (!info || plane >= info->num_planes) > >>> + return 0; > >>> + > >>> + if (plane == 0) > >>> + return width; > >>> + > >>> + return width / info->hsub; > >>> +} > >>> + > >>> +/** > >>> + * drm_format_info_plane_height - height of the plane given the first plane > >>> + * @format: pixel format info > >>> + * @height: height of the first plane > >>> + * @plane: plane index > >>> + * > >>> + * Returns: > >>> + * The height of @plane, given that the height of the first plane is @height. > >>> + */ > >>> +static inline > >>> +int drm_format_info_plane_height(const struct drm_format_info *info, int height, > >>> + int plane) > >>> +{ > >>> + if (!info || plane >= info->num_planes) > >>> + return 0; > >>> + > >>> + if (plane == 0) > >>> + return height; > >>> + > >>> + return height / info->vsub; > >>> +} > >> Why the null checks? None of the other inlines for drm_format_info > >> perform them. > > Unless I'm mistaken, the subsampling only applies to the planes with > > the chrominance, which are always >= 1. Therefore the plane 0 is > > always the luminance, to which the subsampling doesn't apply. > > > > Or are you talking about something else? > > > The info == NULL check. :) Aaah, sorry :) That's true, and that's actually the first four patches that change that behaviour a bit. Previously, drm_format_plane_cpp, _width, and _height will do the lookup themselves using drm_format_info, and test whether the pointer returned is null or not. Patches 3 and 4 removed that lookup but kept the null pointer check. We could remove it, but there's two downsides for that: * since the lookup is now effectively pushed to the caller (or the caller's caller), we would have to check there that the pointer isn't NULL. That's a lot of boilerplate to add. * And since this is a generic function, I wouldn't trust the caller to give a pointer that can be dereferenced right away. This might be more subjective though. So I guess we should make sure that we are consistent, but I'd be in favor of putting that check in all the functions. Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --kvnadm2bo6fe5gqf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXLcmWAAKCRDj7w1vZxhR xaPNAP92L9ciIW3gEMnYB1PtGzfhqgemZhqKiIES5NyhTkygcwEA9u6+JtowTsyQ wYGHeFVWHijR1wqA+oxf1HcSl9D1FgQ= =uZbL -----END PGP SIGNATURE----- --kvnadm2bo6fe5gqf--