diff mbox series

[v4,28/45] media: sun6i-csi: Get mbus code from bridge instead of storing it

Message ID 20220415152811.636419-29-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
Another instance of removing a duplicated variable and using common
helpers instead.

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

Comments

Jernej Škrabec April 27, 2022, 7:32 p.m. UTC | #1
Dne petek, 15. april 2022 ob 17:27:54 CEST je Paul Kocialkowski napisal(a):
> Another instance of removing a duplicated variable and using common
> helpers instead.
> 
> 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        | 18 +++++-------------
>  .../sunxi/sun6i-csi/sun6i_csi_capture.h        |  1 -
>  2 files changed, 5 insertions(+), 14 deletions(-)
> 
> 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
> c4e803a38851..e2070353f93f 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> @@ -17,6 +17,7 @@
>  #include <media/videobuf2-v4l2.h>
> 
>  #include "sun6i_csi.h"
> +#include "sun6i_csi_bridge.h"
>  #include "sun6i_csi_capture.h"
>  #include "sun6i_csi_reg.h"
> 
> @@ -455,20 +456,20 @@ sun6i_csi_capture_configure_interface(struct
> sun6i_csi_device *csi_dev)
> 
>  static void sun6i_csi_capture_configure_format(struct sun6i_csi_device
> *csi_dev) {
> -	struct sun6i_csi_capture *capture = &csi_dev->capture;
> -	u32 pixelformat, field;
> +	u32 mbus_code, pixelformat, field;
>  	u32 cfg = 0;
>  	u32 val;
> 
>  	sun6i_csi_capture_format(csi_dev, &pixelformat, &field);
> +	sun6i_csi_bridge_format(csi_dev, &mbus_code, NULL);
> 
> -	val = get_csi_input_format(csi_dev, capture->mbus_code, 
pixelformat);
> +	val = get_csi_input_format(csi_dev, mbus_code, pixelformat);
>  	cfg |= SUN6I_CSI_CH_CFG_INPUT_FMT(val);
> 
>  	val = get_csi_output_format(csi_dev, pixelformat, field);
>  	cfg |= SUN6I_CSI_CH_CFG_OUTPUT_FMT(val);
> 
> -	val = get_csi_input_seq(csi_dev, capture->mbus_code, pixelformat);
> +	val = get_csi_input_seq(csi_dev, mbus_code, pixelformat);
>  	cfg |= SUN6I_CSI_CH_CFG_INPUT_YUV_SEQ(val);
> 
>  	if (field == V4L2_FIELD_TOP)
> @@ -739,11 +740,6 @@ static int sun6i_csi_capture_start_streaming(struct
> vb2_queue *queue, if (ret < 0)
>  		goto error_state;
> 
> -	if (capture->mbus_code == 0) {
> -		ret = -EINVAL;
> -		goto error_media_pipeline;
> -	}
> -
>  	subdev = sun6i_csi_capture_remote_subdev(capture, NULL);
>  	if (!subdev) {
>  		ret = -EINVAL;
> @@ -1076,8 +1072,6 @@ static int sun6i_csi_capture_link_validate(struct
> media_link *link) struct v4l2_subdev_format source_fmt;
>  	int ret;
> 
> -	capture->mbus_code = 0;
> -
>  	if (!media_entity_remote_pad(link->sink->entity->pads)) {
>  		dev_info(csi_dev->dev, "capture node %s pad not 
connected\n",
>  			 vdev->name);
> @@ -1109,8 +1103,6 @@ static int sun6i_csi_capture_link_validate(struct
> media_link *link) return -EPIPE;
>  	}
> 
> -	capture->mbus_code = source_fmt.format.code;
> -
>  	return 0;
>  }
> 
> 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
> 02bdf45f7ca5..3b9759e1563d 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h
> @@ -39,7 +39,6 @@ struct sun6i_csi_capture {
>  	struct media_pad		pad;
> 
>  	struct v4l2_format		format;
> -	u32				mbus_code;
>  };
> 
>  void sun6i_csi_capture_dimensions(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 c4e803a38851..e2070353f93f 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
@@ -17,6 +17,7 @@ 
 #include <media/videobuf2-v4l2.h>
 
 #include "sun6i_csi.h"
+#include "sun6i_csi_bridge.h"
 #include "sun6i_csi_capture.h"
 #include "sun6i_csi_reg.h"
 
@@ -455,20 +456,20 @@  sun6i_csi_capture_configure_interface(struct sun6i_csi_device *csi_dev)
 
 static void sun6i_csi_capture_configure_format(struct sun6i_csi_device *csi_dev)
 {
-	struct sun6i_csi_capture *capture = &csi_dev->capture;
-	u32 pixelformat, field;
+	u32 mbus_code, pixelformat, field;
 	u32 cfg = 0;
 	u32 val;
 
 	sun6i_csi_capture_format(csi_dev, &pixelformat, &field);
+	sun6i_csi_bridge_format(csi_dev, &mbus_code, NULL);
 
-	val = get_csi_input_format(csi_dev, capture->mbus_code, pixelformat);
+	val = get_csi_input_format(csi_dev, mbus_code, pixelformat);
 	cfg |= SUN6I_CSI_CH_CFG_INPUT_FMT(val);
 
 	val = get_csi_output_format(csi_dev, pixelformat, field);
 	cfg |= SUN6I_CSI_CH_CFG_OUTPUT_FMT(val);
 
-	val = get_csi_input_seq(csi_dev, capture->mbus_code, pixelformat);
+	val = get_csi_input_seq(csi_dev, mbus_code, pixelformat);
 	cfg |= SUN6I_CSI_CH_CFG_INPUT_YUV_SEQ(val);
 
 	if (field == V4L2_FIELD_TOP)
@@ -739,11 +740,6 @@  static int sun6i_csi_capture_start_streaming(struct vb2_queue *queue,
 	if (ret < 0)
 		goto error_state;
 
-	if (capture->mbus_code == 0) {
-		ret = -EINVAL;
-		goto error_media_pipeline;
-	}
-
 	subdev = sun6i_csi_capture_remote_subdev(capture, NULL);
 	if (!subdev) {
 		ret = -EINVAL;
@@ -1076,8 +1072,6 @@  static int sun6i_csi_capture_link_validate(struct media_link *link)
 	struct v4l2_subdev_format source_fmt;
 	int ret;
 
-	capture->mbus_code = 0;
-
 	if (!media_entity_remote_pad(link->sink->entity->pads)) {
 		dev_info(csi_dev->dev, "capture node %s pad not connected\n",
 			 vdev->name);
@@ -1109,8 +1103,6 @@  static int sun6i_csi_capture_link_validate(struct media_link *link)
 		return -EPIPE;
 	}
 
-	capture->mbus_code = source_fmt.format.code;
-
 	return 0;
 }
 
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 02bdf45f7ca5..3b9759e1563d 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h
@@ -39,7 +39,6 @@  struct sun6i_csi_capture {
 	struct media_pad		pad;
 
 	struct v4l2_format		format;
-	u32				mbus_code;
 };
 
 void sun6i_csi_capture_dimensions(struct sun6i_csi_device *csi_dev,