diff mbox series

[v4,20/45] media: sun6i-csi: Add dimensions and format helpers to capture

Message ID 20220415152811.636419-21-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
Define and export useful helpers to access dimensions and pixel format.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 .../sunxi/sun6i-csi/sun6i_csi_capture.c       | 19 +++++++++++++++++++
 .../sunxi/sun6i-csi/sun6i_csi_capture.h       |  5 +++++
 2 files changed, 24 insertions(+)

Comments

Jernej Škrabec April 27, 2022, 6:57 p.m. UTC | #1
Dne petek, 15. april 2022 ob 17:27:46 CEST je Paul Kocialkowski napisal(a):
> Define and export useful helpers to access dimensions and pixel format.
> 
> 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_capture.c       | 19 +++++++++++++++++++
>  .../sunxi/sun6i-csi/sun6i_csi_capture.h       |  5 +++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index
> e227940cb66e..acbd0ea62fd5 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> @@ -25,6 +25,25 @@
> 
>  /* Helpers */
> 
> +void sun6i_csi_capture_dimensions(struct sun6i_csi_device *csi_dev,
> +				  unsigned int *width, unsigned 
int *height)
> +{
> +	if (width)
> +		*width = csi_dev->capture.format.fmt.pix.width;
> +	if (height)
> +		*height = csi_dev->capture.format.fmt.pix.height;
> +}
> +
> +void sun6i_csi_capture_format(struct sun6i_csi_device *csi_dev,
> +			      u32 *pixelformat, u32 *field)
> +{
> +	if (pixelformat)
> +		*pixelformat = csi_dev-
>capture.format.fmt.pix.pixelformat;
> +
> +	if (field)
> +		*field = csi_dev->capture.format.fmt.pix.field;
> +}
> +
>  static struct v4l2_subdev *
>  sun6i_csi_capture_remote_subdev(struct sun6i_csi_capture *capture, u32
> *pad) {
> diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h
> b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h index
> 7fa66a2af5ec..935f35b7049a 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h
> @@ -37,6 +37,11 @@ struct sun6i_csi_capture {
>  	u32				mbus_code;
>  };
> 
> +void sun6i_csi_capture_dimensions(struct sun6i_csi_device *csi_dev,
> +				  unsigned int *width, unsigned 
int *height);
> +void sun6i_csi_capture_format(struct sun6i_csi_device *csi_dev,
> +			      u32 *pixelformat, u32 *field);
> +
>  void sun6i_csi_capture_sync(struct sun6i_csi_device *csi_dev);
>  void sun6i_csi_capture_frame_done(struct sun6i_csi_device *csi_dev);
diff mbox series

Patch

diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
index e227940cb66e..acbd0ea62fd5 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
@@ -25,6 +25,25 @@ 
 
 /* Helpers */
 
+void sun6i_csi_capture_dimensions(struct sun6i_csi_device *csi_dev,
+				  unsigned int *width, unsigned int *height)
+{
+	if (width)
+		*width = csi_dev->capture.format.fmt.pix.width;
+	if (height)
+		*height = csi_dev->capture.format.fmt.pix.height;
+}
+
+void sun6i_csi_capture_format(struct sun6i_csi_device *csi_dev,
+			      u32 *pixelformat, u32 *field)
+{
+	if (pixelformat)
+		*pixelformat = csi_dev->capture.format.fmt.pix.pixelformat;
+
+	if (field)
+		*field = csi_dev->capture.format.fmt.pix.field;
+}
+
 static struct v4l2_subdev *
 sun6i_csi_capture_remote_subdev(struct sun6i_csi_capture *capture, u32 *pad)
 {
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h
index 7fa66a2af5ec..935f35b7049a 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h
@@ -37,6 +37,11 @@  struct sun6i_csi_capture {
 	u32				mbus_code;
 };
 
+void sun6i_csi_capture_dimensions(struct sun6i_csi_device *csi_dev,
+				  unsigned int *width, unsigned int *height);
+void sun6i_csi_capture_format(struct sun6i_csi_device *csi_dev,
+			      u32 *pixelformat, u32 *field);
+
 void sun6i_csi_capture_sync(struct sun6i_csi_device *csi_dev);
 void sun6i_csi_capture_frame_done(struct sun6i_csi_device *csi_dev);