aboutsummaryrefslogtreecommitdiff
path: root/target/linux/bcm27xx/patches-6.1/950-1210-media-rp1-csi2-Use-standard-link_validate.patch
blob: a3836150dc675dd45738d2a20e936ba5b887e7bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
From b6316a8450d3cb99b7599175d59b1b7f710770f5 Mon Sep 17 00:00:00 2001
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Date: Tue, 3 Oct 2023 13:59:02 +0300
Subject: [PATCH] media: rp1: csi2: Use standard link_validate

The current csi2_link_validate() skips some important checks. Let's
rather use the standard v4l2_subdev_link_validate_default() as the
link_validate hook.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 .../media/platform/raspberrypi/rp1_cfe/csi2.c | 41 +------------------
 1 file changed, 1 insertion(+), 40 deletions(-)

--- a/drivers/media/platform/raspberrypi/rp1_cfe/csi2.c
+++ b/drivers/media/platform/raspberrypi/rp1_cfe/csi2.c
@@ -462,11 +462,6 @@ void csi2_close_rx(struct csi2_device *c
 	csi2_reg_write(csi2, CSI2_IRQ_MASK, 0);
 }
 
-static struct csi2_device *to_csi2_device(struct v4l2_subdev *subdev)
-{
-	return container_of(subdev, struct csi2_device, sd);
-}
-
 static int csi2_init_cfg(struct v4l2_subdev *sd,
 			 struct v4l2_subdev_state *state)
 {
@@ -554,45 +549,11 @@ static int csi2_pad_set_fmt(struct v4l2_
 	return 0;
 }
 
-static int csi2_link_validate(struct v4l2_subdev *sd, struct media_link *link,
-			      struct v4l2_subdev_format *source_fmt,
-			      struct v4l2_subdev_format *sink_fmt)
-{
-	struct csi2_device *csi2 = to_csi2_device(sd);
-
-	csi2_dbg("%s: link \"%s\":%u -> \"%s\":%u\n", __func__,
-		 link->source->entity->name, link->source->index,
-		 link->sink->entity->name, link->sink->index);
-
-	if ((link->source->entity == &csi2->sd.entity &&
-	     link->source->index == 1) ||
-	    (link->sink->entity == &csi2->sd.entity &&
-	     link->sink->index == 1)) {
-		csi2_dbg("Ignore metadata pad for now\n");
-		return 0;
-	}
-
-	/* The width, height and code must match. */
-	if (source_fmt->format.width != sink_fmt->format.width ||
-	    source_fmt->format.width != sink_fmt->format.width ||
-	    source_fmt->format.code != sink_fmt->format.code) {
-		csi2_err("%s: format does not match (source %ux%u 0x%x, sink %ux%u 0x%x)\n",
-			 __func__,
-			 source_fmt->format.width, source_fmt->format.height,
-			 source_fmt->format.code,
-			 sink_fmt->format.width, sink_fmt->format.height,
-			 sink_fmt->format.code);
-		return -EPIPE;
-	}
-
-	return 0;
-}
-
 static const struct v4l2_subdev_pad_ops csi2_subdev_pad_ops = {
 	.init_cfg = csi2_init_cfg,
 	.get_fmt = v4l2_subdev_get_fmt,
 	.set_fmt = csi2_pad_set_fmt,
-	.link_validate = csi2_link_validate,
+	.link_validate = v4l2_subdev_link_validate_default,
 };
 
 static const struct media_entity_operations csi2_entity_ops = {