bcm27xx: import latest patches from the RPi foundation
[openwrt/staging/ynezz.git] / target / linux / bcm27xx / patches-5.4 / 950-0802-media-i2c-adv748x-Implement-get_mbus_config.patch
1 From 3269627852346852f99244b2650daaa79056b29d Mon Sep 17 00:00:00 2001
2 From: Jacopo Mondi <jacopo+renesas@jmondi.org>
3 Date: Tue, 16 Jun 2020 16:12:43 +0200
4 Subject: [PATCH] media: i2c: adv748x: Implement get_mbus_config
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Upstream https://patchwork.linuxtv.org/patch/64676/
10
11 Implement the newly introduced get_mbus_config operation to report the
12 number of currently used data lanes on the MIPI CSI-2 interface.
13
14 Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
15 Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
16 Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
17 ---
18 drivers/media/i2c/adv748x/adv748x-csi2.c | 31 ++++++++++++++++++++++++
19 1 file changed, 31 insertions(+)
20
21 --- a/drivers/media/i2c/adv748x/adv748x-csi2.c
22 +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
23 @@ -214,9 +214,40 @@ unlock:
24 return ret;
25 }
26
27 +static int adv748x_csi2_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
28 + struct v4l2_mbus_config *config)
29 +{
30 + struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
31 +
32 + if (pad != ADV748X_CSI2_SOURCE)
33 + return -EINVAL;
34 +
35 + config->type = V4L2_MBUS_CSI2_DPHY;
36 + switch (tx->active_lanes) {
37 + case 1:
38 + config->flags = V4L2_MBUS_CSI2_1_LANE;
39 + break;
40 +
41 + case 2:
42 + config->flags = V4L2_MBUS_CSI2_2_LANE;
43 + break;
44 +
45 + case 3:
46 + config->flags = V4L2_MBUS_CSI2_3_LANE;
47 + break;
48 +
49 + case 4:
50 + config->flags = V4L2_MBUS_CSI2_4_LANE;
51 + break;
52 + }
53 +
54 + return 0;
55 +}
56 +
57 static const struct v4l2_subdev_pad_ops adv748x_csi2_pad_ops = {
58 .get_fmt = adv748x_csi2_get_format,
59 .set_fmt = adv748x_csi2_set_format,
60 + .get_mbus_config = adv748x_csi2_get_mbus_config,
61 };
62
63 /* -----------------------------------------------------------------------------