Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4145912yba; Wed, 17 Apr 2019 05:41:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUq87CmSwysLYN1BHxsHardXFqw8dcaHZFfUMxk+XsKOtl5PWQMKr8vUvT9yzub+m3/6+3 X-Received: by 2002:a63:ff66:: with SMTP id s38mr83526810pgk.120.1555504860895; Wed, 17 Apr 2019 05:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555504860; cv=none; d=google.com; s=arc-20160816; b=vCIaVuX6gzjXLU790eiscMH2xwSUgqpB1YU/6yaE1Q9oDSvFFWvu4a+hfq0rSG5vRF uTZFSKOKcNwK4NvBnMrWRsb/uzkaRwOJP2iArdBwd4zCwbDVwMCkG9oHVXK6xYI5SjFw PanfPozj9ubGqFI/no7Kq/o6ByAmz+x6xu3DDg4dM00rHtaXGj9CBe4L6b+GnmK8m5lp Okgaru7IiUjKfAY0ivoWUXweg4vXcC0iE1/tWBahJnpl6mnZzs81dPnRIevsUL+4MAA2 t8vOPD7PTneeBqp01V23vsNaBSAhPbzc42zw7CW8ev/hStF+ABb4lnwPwWMAkZtuvp+Y wMbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=cv/Siy479QFE+Aifq5CH5ZC3StTcr29SOXc3bWlk8ts=; b=XZ17YAdgUraOB88XUQIetBzc6SUeELS0jzn1es0f1iYITFXwQNkdsiK1NQxfu2N18Q MiFIHYrKL/O9BxiHSbxCTPzcofe9qXzDcPDow9O9geyyUg40kOpBSX+wBVNjEGbQbJ6/ Roc55RA0Ky4dAusWGSy1I96dGbRe+OPyGl7Oz0/PjqxBVH+OCr1uw5oZSYjcAqz9ebTe 3vn3s+zkLpbByNvUmTAjRtk3Ll8O6n0QcCLhT+kKoxOvlH1+3t6StZGCL7WbA2qpIBx4 ClOcwCns9TBycFVK4wsJFQx7PoRlFsiOViajBbKun93g0NVOs5YLfi6+LTLsVp79Yyok FQDg== 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 m7si50272926pgg.78.2019.04.17.05.40.45; Wed, 17 Apr 2019 05:41:00 -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 S1732191AbfDQMjk (ORCPT + 99 others); Wed, 17 Apr 2019 08:39:40 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:55957 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732049AbfDQMjk (ORCPT ); Wed, 17 Apr 2019 08:39:40 -0400 Received: from aptenodytes (aaubervilliers-681-1-42-238.w90-88.abo.wanadoo.fr [90.88.160.238]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 1DA81240010; Wed, 17 Apr 2019 12:39:36 +0000 (UTC) Message-ID: <9747977af63d2cb66a51e18ce5e545ed99803718.camel@bootlin.com> Subject: Re: [PATCH 19/20] lib: image-formats: Add more functions From: Paul Kocialkowski To: Maxime Ripard , Daniel Vetter , David Airlie , Maarten Lankhorst , Sean Paul , Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , Laurent Pinchart , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Date: Wed, 17 Apr 2019 14:39:36 +0200 In-Reply-To: <382f72c5938f538c8489cb2032050f4be252ad59.1555487650.git-series.maxime.ripard@bootlin.com> References: <382f72c5938f538c8489cb2032050f4be252ad59.1555487650.git-series.maxime.ripard@bootlin.com> Organization: Bootlin Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, 2019-04-17 at 09:54 +0200, Maxime Ripard wrote: > V4L2 drivers typically need a few more helpers compared to DRM drivers, so > let's add them. > > Signed-off-by: Maxime Ripard > --- > include/linux/image-formats.h | 42 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 42 insertions(+) > > diff --git a/include/linux/image-formats.h b/include/linux/image-formats.h > index b78b8e861fc9..a2cf3528bd31 100644 > --- a/include/linux/image-formats.h > +++ b/include/linux/image-formats.h > @@ -388,6 +388,48 @@ uint64_t image_format_info_min_pitch(const struct image_format_info *info, > image_format_info_block_height(info, plane)); > } > > +/** > + * image_format_info_plane_stride - determine the stride value > + * @format: pointer to the image_format_info > + * @width: plane width > + * @plane: plane index > + * > + * Returns: > + * The bytes per pixel value for the specified plane. Looks like this needs to be updated to "bytes per line" ;) Cheers, Paul > + */ > +static inline > +unsigned int image_format_info_plane_stride(const struct image_format_info *format, > + unsigned int width, int plane) > +{ > + if (!format || plane >= format->num_planes) > + return 0; > + > + return image_format_info_plane_width(format, width, plane) * > + image_format_info_plane_cpp(format, plane); > +} > + > +/** > + * image_format_info_plane_size - determine the size value > + * @format: pointer to the image_format_info > + * @width: plane width > + * @height: plane width > + * @plane: plane index > + * > + * Returns: > + * The size of the plane buffer. > + */ > +static inline > +unsigned int image_format_info_plane_size(const struct image_format_info *format, > + unsigned int width, unsigned int height, > + int plane) > +{ > + if (!format || plane >= format->num_planes) > + return 0; > + > + return image_format_info_plane_stride(format, width, plane) * > + image_format_info_plane_height(format, height, plane); > +} > + > const struct image_format_info *__image_format_drm_lookup(u32 drm); > const struct image_format_info *__image_format_v4l2_lookup(u32 v4l2); > const struct image_format_info *image_format_drm_lookup(u32 drm); -- Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com