Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4148255yba; Wed, 17 Apr 2019 05:44:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZ2fP3xmonTM3ac0Rt84U9mhqKgaBxf4H2jGiqGJBqWLN/x0fHzfvMgeZ0UHsRIscX7xiX X-Received: by 2002:a62:1a06:: with SMTP id a6mr89327674pfa.18.1555505047734; Wed, 17 Apr 2019 05:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555505047; cv=none; d=google.com; s=arc-20160816; b=qeXFgjlLsCrDiFMNG2Cxco7oxvhM+3JfrgyHRqNvH5pDcf7UGU+0tbDhz4/6bz6vEB s0ZdBNnNycBwe3te07yn1ri8kYNrkWFbfgT7F+2MJMDJQzGQv6X61QJXio1o8fLrrxn9 lzjIgtiT8iLVwgG8gsTnGrYnEWUe38eROldqvrA1iUXZi38f9aLQ2eXG4rkIUaIePcg/ QY68plEQUA9obUKcLSZw8gm+JCI98YvR6jzI2QaFIY/hVwi28A0eXoW9+60x0bmeyyYv KuKfIQsMg9TTjEuTJflJ5fJwU1CzhCE+HZjPkNCqWvG4cfQiw3BgJRk5k2uuSgfQuUE+ 5ZZw== 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=pjePlRHVFKHTtQRbhojcuJ/FUu8VTDVGaOVMDf1k6sg=; b=RicGnTpX/AC1de8HzikY/z3JlvfrqpEulMlgYa387IVfCUNjZUnYTgxnppCcTmM4dH VX8H6zRs0PrE9JQRHWGbrwX92xGdiUH+I2c6tjfxw9hAZ32TrTZHtVEhvooWsTyp0IqV r43E8fKfkDHZraHRzdudd03BMTHGrkScL6TYw8LI2FN3KWLQDk//R0X0s1FhWd0S4WDJ QrW1L04d+0MU69vAtwbnGrGUzTr05PyHARYDh0/80SPTE7e5eYyt7y3YEHVH2mPlHxBO LWGcDjQOkk3tvXrnabsWbAoboC2TPB8759XRIpnOuOuZOJUArqZN0u7DCmml4iGnrHhK piPw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si873410pgv.128.2019.04.17.05.43.52; Wed, 17 Apr 2019 05:44:07 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732122AbfDQMli (ORCPT + 99 others); Wed, 17 Apr 2019 08:41:38 -0400 Received: from mga12.intel.com ([192.55.52.136]:49137 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729898AbfDQMli (ORCPT ); Wed, 17 Apr 2019 08:41:38 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 05:41:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,361,1549958400"; d="scan'208";a="132141962" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga007.jf.intel.com with ESMTP; 17 Apr 2019 05:41:33 -0700 Received: by paasikivi.fi.intel.com (Postfix, from userid 1000) id 62E01204DA; Wed, 17 Apr 2019 15:41:32 +0300 (EEST) Date: Wed, 17 Apr 2019 15:41:32 +0300 From: Sakari Ailus To: Maxime Ripard Cc: Daniel Vetter , David Airlie , Maarten Lankhorst , Sean Paul , Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Thomas Petazzoni , Paul Kocialkowski , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH 19/20] lib: image-formats: Add more functions Message-ID: <20190417124131.febnqtpp6oetbafs@paasikivi.fi.intel.com> References: <382f72c5938f538c8489cb2032050f4be252ad59.1555487650.git-series.maxime.ripard@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <382f72c5938f538c8489cb2032050f4be252ad59.1555487650.git-series.maxime.ripard@bootlin.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime, On Wed, Apr 17, 2019 at 09:54:45AM +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. In V4L2 the bytesperline (stride) value is user configurable and is also subject to hardware capabilities. So effectively this makes what the function returns a minimum value for a given format. I think you could add this to the documentation. This is also not the number of bytes per pixel, as suggested above. So, e.g. Returns the minimum number of bytes between two consecutive lines. > + */ > +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. Similarly: Returns the minimum size of the plane buffer. With these, Acked-by: Sakari Ailus > + */ > +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); -- Sakari Ailus sakari.ailus@linux.intel.com