[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <f7196882b8aca389d99b4cba109704b4c79e0113.1553032382.git-series.maxime.ripard@bootlin.com>
Date: Tue, 19 Mar 2019 22:57:24 +0100
From: Maxime Ripard <maxime.ripard@...tlin.com>
To: Daniel Vetter <daniel.vetter@...el.com>,
David Airlie <airlied@...ux.ie>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Sean Paul <seanpaul@...omium.org>,
Maxime Ripard <maxime.ripard@...tlin.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>
Cc: Sakari Ailus <sakari.ailus@...ux.intel.com>,
Hans Verkuil <hans.verkuil@...co.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Paul Kocialkowski <paul.kocialkowski@...tlin.com>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org
Subject: [RFC PATCH 19/20] lib: image-formats: Add more functions
V4L2 drivers typically need a few more helpers compared to DRM drivers, so
let's add them.
Signed-off-by: Maxime Ripard <maxime.ripard@...tlin.com>
---
include/linux/image-formats.h | 4 +++-
lib/image-formats.c | 42 ++++++++++++++++++++++++++++++++++++-
2 files changed, 46 insertions(+)
diff --git a/include/linux/image-formats.h b/include/linux/image-formats.h
index fbc3a4501ebd..f1d4a2a03cc0 100644
--- a/include/linux/image-formats.h
+++ b/include/linux/image-formats.h
@@ -236,9 +236,13 @@ unsigned int image_format_plane_cpp(const struct image_format_info *format,
unsigned int image_format_plane_width(int width,
const struct image_format_info *format,
int plane);
+unsigned int image_format_plane_stride(const struct image_format_info *format,
+ int width, int plane);
unsigned int image_format_plane_height(int height,
const struct image_format_info *format,
int plane);
+unsigned int image_format_plane_size(const struct image_format_info *format,
+ int width, int height, int plane);
unsigned int image_format_block_width(const struct image_format_info *format,
int plane);
unsigned int image_format_block_height(const struct image_format_info *format,
diff --git a/lib/image-formats.c b/lib/image-formats.c
index 39f1d38ae861..c4e213a89edb 100644
--- a/lib/image-formats.c
+++ b/lib/image-formats.c
@@ -740,6 +740,26 @@ unsigned int image_format_plane_width(int width,
EXPORT_SYMBOL(image_format_plane_width);
/**
+ * image_format_plane_stride - determine the stride value
+ * @format: pointer to the image_format
+ * @width: plane width
+ * @plane: plane index
+ *
+ * Returns:
+ * The bytes per pixel value for the specified plane.
+ */
+unsigned int image_format_plane_stride(const struct image_format_info *format,
+ unsigned int width, int plane)
+{
+ if (!format || plane >= format->num_planes)
+ return 0;
+
+ return image_format_plane_width(width, format, plane) *
+ image_format_plane_cpp(format, plane);
+}
+EXPORT_SYMBOL(image_format_plane_stride);
+
+/**
* image_format_plane_height - height of the plane given the first plane
* @format: pointer to the image_format
* @height: height of the first plane
@@ -763,6 +783,28 @@ unsigned int image_format_plane_height(int height,
EXPORT_SYMBOL(image_format_plane_height);
/**
+ * image_format_plane_size - determine the size value
+ * @format: pointer to the image_format
+ * @width: plane width
+ * @height: plane width
+ * @plane: plane index
+ *
+ * Returns:
+ * The size of the plane buffer.
+ */
+unsigned int image_format_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_plane_stride(format, width, plane) *
+ image_format_plane_height(format, height, plane);
+}
+EXPORT_SYMBOL(image_format_plane_size);
+
+/**
* image_format_block_width - width in pixels of block.
* @format: pointer to the image_format
* @plane: plane index
--
git-series 0.9.1
Powered by blists - more mailing lists