Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3943314yba; Wed, 17 Apr 2019 00:56:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+unICDHneknt4e3kIAr+afHhd9SyXcMmeK/J9ONUVGiYS7xkzgRw3au176iDCzoWv8LDX X-Received: by 2002:a62:1f92:: with SMTP id l18mr89265803pfj.180.1555487803558; Wed, 17 Apr 2019 00:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555487803; cv=none; d=google.com; s=arc-20160816; b=EJoDgOQOhabRRmnoJt0h2EdGcv1JxZoexJ0eVzNlG6AJ0d97Ofp331g2ckO1iSfCsl siZn4Q6w++J1h5DcvRrpDT7M0cIrIDWsE37Tn/VUNlCLorwuQT1QOZyRb0+e1QoKBwPQ CpF3zH5r8yBDqG1yISZfYfNi9ksz+1fN5yktul7HwXkmRO+f0uDEez32dmFAj7v/s9md 73jyT2ySR5diut5ELDhj3EpTOi6bkxTc5aibk4zn9CDQs1BURJhHwoRSteArj0QhyuZQ OupbmGcVsPrbwkdgETanVKyFAv8t/nq22fNUxWP8t6tAUQGH/q3sKRtfHjg0fs9YAUAL TKEQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ZV/At2CW4Y8raUPa+f9+XTuI1MpswbpuGRm+a2LYNdE=; b=CI8gjUfnjWQQhkbU97GdCn4uQizgosg87LXb0t0yENtjvYCgBQc1epNCo/rZWznh8A oxkB4ZIq15H8vjJVsT0DJeqBb8AKU//x3RMGUjZ+bhIZwb8q9dt34xvCEWwDrPC5i9B6 v4k4VKm+HoZx3/X4BCrSLIcVpk0aTGuPpUGfHmrt3V51AFaI7yz0llrRE4gaMHL/n8M3 qITsU5Qwb1ef9hJ+DTfmWHqHChYLuuAOAUBgXQisBMnAdaSfzjynA3a/5jtDTcmm2XdI ojqQgiPxT847VozdbQb1XER6pSS0Pmp97IZEZihcaoDY7NPE8jjQWsXy3kC+WpCaLPtI uipw== 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 j4si40618958pfc.101.2019.04.17.00.56.28; Wed, 17 Apr 2019 00:56:43 -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 S1731313AbfDQHzS (ORCPT + 99 others); Wed, 17 Apr 2019 03:55:18 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:48045 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731281AbfDQHzS (ORCPT ); Wed, 17 Apr 2019 03:55:18 -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 8074E20000F; Wed, 17 Apr 2019 07:55:14 +0000 (UTC) From: Maxime Ripard To: Daniel Vetter , David Airlie , Maarten Lankhorst , Sean Paul , Maxime Ripard , Mauro Carvalho Chehab Cc: 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 Subject: [PATCH 19/20] lib: image-formats: Add more functions Date: Wed, 17 Apr 2019 09:54:45 +0200 Message-Id: <382f72c5938f538c8489cb2032050f4be252ad59.1555487650.git-series.maxime.ripard@bootlin.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. + */ +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); -- git-series 0.9.1