diff mbox series

[v4,27/45] media: sun6i-csi: Add bridge dimensions and format helpers

Message ID 20220415152811.636419-28-paul.kocialkowski@bootlin.com (mailing list archive)
State New, archived
Headers show
Series Allwinner A31/A83T MIPI CSI-2 and A31 ISP / CSI Rework | expand

Commit Message

Paul Kocialkowski April 15, 2022, 3:27 p.m. UTC
Introduce new helpers to ease getting information about the bridge.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 .../sunxi/sun6i-csi/sun6i_csi_bridge.c        | 20 +++++++++++++++++++
 .../sunxi/sun6i-csi/sun6i_csi_bridge.h        |  7 +++++++
 2 files changed, 27 insertions(+)

Comments

Jernej Škrabec April 27, 2022, 7:31 p.m. UTC | #1
Dne petek, 15. april 2022 ob 17:27:53 CEST je Paul Kocialkowski napisal(a):
> Introduce new helpers to ease getting information about the bridge.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej

> ---
>  .../sunxi/sun6i-csi/sun6i_csi_bridge.c        | 20 +++++++++++++++++++
>  .../sunxi/sun6i-csi/sun6i_csi_bridge.h        |  7 +++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
> b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c index
> bba825db8322..0c1e159537a7 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
> @@ -12,6 +12,26 @@
>  #include "sun6i_csi.h"
>  #include "sun6i_csi_bridge.h"
> 
> +/* Helpers */
> +
> +void sun6i_csi_bridge_dimensions(struct sun6i_csi_device *csi_dev,
> +				 unsigned int *width, unsigned int 
*height)
> +{
> +	if (width)
> +		*width = csi_dev->bridge.mbus_format.width;
> +	if (height)
> +		*height = csi_dev->bridge.mbus_format.height;
> +}
> +
> +void sun6i_csi_bridge_format(struct sun6i_csi_device *csi_dev,
> +			     u32 *mbus_code, u32 *field)
> +{
> +	if (mbus_code)
> +		*mbus_code = csi_dev->bridge.mbus_format.code;
> +	if (field)
> +		*field = csi_dev->bridge.mbus_format.field;
> +}
> +
>  /* Format */
> 
>  static const u32 sun6i_csi_bridge_mbus_codes[] = {
> diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h
> b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h index
> f9bf87bf3667..5e6448aa522f 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h
> @@ -41,6 +41,13 @@ struct sun6i_csi_bridge {
>  	struct sun6i_csi_bridge_source	source_parallel;
>  };
> 
> +/* Helpers */
> +
> +void sun6i_csi_bridge_dimensions(struct sun6i_csi_device *csi_dev,
> +				 unsigned int *width, unsigned int 
*height);
> +void sun6i_csi_bridge_format(struct sun6i_csi_device *csi_dev,
> +			     u32 *mbus_code, u32 *field);
> +
>  /* Bridge */
> 
>  int sun6i_csi_bridge_setup(struct sun6i_csi_device *csi_dev);
diff mbox series

Patch

diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
index bba825db8322..0c1e159537a7 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
@@ -12,6 +12,26 @@ 
 #include "sun6i_csi.h"
 #include "sun6i_csi_bridge.h"
 
+/* Helpers */
+
+void sun6i_csi_bridge_dimensions(struct sun6i_csi_device *csi_dev,
+				 unsigned int *width, unsigned int *height)
+{
+	if (width)
+		*width = csi_dev->bridge.mbus_format.width;
+	if (height)
+		*height = csi_dev->bridge.mbus_format.height;
+}
+
+void sun6i_csi_bridge_format(struct sun6i_csi_device *csi_dev,
+			     u32 *mbus_code, u32 *field)
+{
+	if (mbus_code)
+		*mbus_code = csi_dev->bridge.mbus_format.code;
+	if (field)
+		*field = csi_dev->bridge.mbus_format.field;
+}
+
 /* Format */
 
 static const u32 sun6i_csi_bridge_mbus_codes[] = {
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h
index f9bf87bf3667..5e6448aa522f 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h
@@ -41,6 +41,13 @@  struct sun6i_csi_bridge {
 	struct sun6i_csi_bridge_source	source_parallel;
 };
 
+/* Helpers */
+
+void sun6i_csi_bridge_dimensions(struct sun6i_csi_device *csi_dev,
+				 unsigned int *width, unsigned int *height);
+void sun6i_csi_bridge_format(struct sun6i_csi_device *csi_dev,
+			     u32 *mbus_code, u32 *field);
+
 /* Bridge */
 
 int sun6i_csi_bridge_setup(struct sun6i_csi_device *csi_dev);