1 From 5223be7b3a1ee9849730657ade5767bd3f6cf3bd Mon Sep 17 00:00:00 2001
2 From: Philipp Zabel <p.zabel@pengutronix.de>
3 Date: Thu, 21 Sep 2017 17:30:24 +0200
4 Subject: [PATCH 191/703] media: tc358743: fix connected/active CSI-2 lane
7 g_mbus_config was supposed to indicate all supported lane numbers, not
8 only the number of those currently in active use. Since the TC358743
9 can dynamically reduce the number of active lanes if the required
10 bandwidth allows for it, report all lane numbers up to the connected
11 number of lanes as supported in pdata mode.
12 In device tree mode, do not report lane count and clock mode at all, as
13 the receiver driver can determine these from the device tree.
15 To allow communicating the number of currently active lanes, add a new
16 bitfield to the v4l2_mbus_config flags. This is a temporary fix, to be
17 used only until a better solution is found.
19 Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
21 drivers/media/i2c/tc358743.c | 30 ++++++++++++++++--------------
22 include/media/v4l2-mediabus.h | 8 ++++++++
23 2 files changed, 24 insertions(+), 14 deletions(-)
25 --- a/drivers/media/i2c/tc358743.c
26 +++ b/drivers/media/i2c/tc358743.c
27 @@ -1606,28 +1606,29 @@ static int tc358743_g_mbus_config(struct
28 struct v4l2_mbus_config *cfg)
30 struct tc358743_state *state = to_state(sd);
31 + const u32 mask = V4L2_MBUS_CSI2_LANE_MASK;
33 + if (state->csi_lanes_in_use > state->bus.num_data_lanes)
36 cfg->type = V4L2_MBUS_CSI2;
37 + cfg->flags = (state->csi_lanes_in_use << __ffs(mask)) & mask;
39 + /* In DT mode, only report the number of active lanes */
40 + if (sd->dev->of_node)
43 - /* Support for non-continuous CSI-2 clock is missing in the driver */
44 - cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
45 + /* Support for non-continuous CSI-2 clock is missing in pdata mode */
46 + cfg->flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
48 - switch (state->csi_lanes_in_use) {
50 + if (state->bus.num_data_lanes > 0)
51 cfg->flags |= V4L2_MBUS_CSI2_1_LANE;
54 + if (state->bus.num_data_lanes > 1)
55 cfg->flags |= V4L2_MBUS_CSI2_2_LANE;
58 + if (state->bus.num_data_lanes > 2)
59 cfg->flags |= V4L2_MBUS_CSI2_3_LANE;
62 + if (state->bus.num_data_lanes > 3)
63 cfg->flags |= V4L2_MBUS_CSI2_4_LANE;
71 @@ -2052,6 +2053,7 @@ static int tc358743_probe(struct i2c_cli
73 state->pdata = *pdata;
74 state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
75 + state->bus.num_data_lanes = 4;
77 err = tc358743_probe_of(state);
79 --- a/include/media/v4l2-mediabus.h
80 +++ b/include/media/v4l2-mediabus.h
82 V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE)
83 #define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \
84 V4L2_MBUS_CSI2_CHANNEL_2 | V4L2_MBUS_CSI2_CHANNEL_3)
86 + * Number of lanes in use, 0 == use all available lanes (default)
88 + * This is a temporary fix for devices that need to reduce the number of active
89 + * lanes for certain modes, until g_mbus_config() can be replaced with a better
92 +#define V4L2_MBUS_CSI2_LANE_MASK (0xf << 10)
95 * enum v4l2_mbus_type - media bus type