Skip to content

Commit fa9e4e7

Browse files
pH5popcornmix
authored andcommitted
media: tc358743: fix connected/active CSI-2 lane reporting
g_mbus_config was supposed to indicate all supported lane numbers, not only the number of those currently in active use. Since the TC358743 can dynamically reduce the number of active lanes if the required bandwidth allows for it, report all lane numbers up to the connected number of lanes as supported in pdata mode. In device tree mode, do not report lane count and clock mode at all, as the receiver driver can determine these from the device tree. To allow communicating the number of currently active lanes, add a new bitfield to the v4l2_mbus_config flags. This is a temporary fix, to be used only until a better solution is found. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
1 parent f15b133 commit fa9e4e7

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎drivers/media/i2c/tc358743.c‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,11 +1606,20 @@ static int tc358743_g_mbus_config(struct v4l2_subdev *sd,
16061606
struct v4l2_mbus_config *cfg)
16071607
{
16081608
struct tc358743_state *state = to_state(sd);
1609+
const u32 mask = V4L2_MBUS_CSI2_LANE_MASK;
1610+
1611+
if (state->csi_lanes_in_use > state->bus.num_data_lanes)
1612+
return -EINVAL;
16091613

16101614
cfg->type = V4L2_MBUS_CSI2_DPHY;
1615+
cfg->flags = (state->csi_lanes_in_use << __ffs(mask)) & mask;
1616+
1617+
/* In DT mode, only report the number of active lanes */
1618+
if (sd->dev->of_node)
1619+
return 0;
16111620

1612-
/* Support for non-continuous CSI-2 clock is missing in the driver */
1613-
cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
1621+
/* Support for non-continuous CSI-2 clock is missing in pdate mode */
1622+
cfg->flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
16141623

16151624
switch (state->csi_lanes_in_use) {
16161625
case 1:
@@ -2052,6 +2061,7 @@ static int tc358743_probe(struct i2c_client *client)
20522061
if (pdata) {
20532062
state->pdata = *pdata;
20542063
state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
2064+
state->bus.num_data_lanes = 4;
20552065
} else {
20562066
err = tc358743_probe_of(state);
20572067
if (err == -ENODEV)

‎include/media/v4l2-mediabus.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@
6767
V4L2_MBUS_CSI2_CHANNEL_1 | \
6868
V4L2_MBUS_CSI2_CHANNEL_2 | \
6969
V4L2_MBUS_CSI2_CHANNEL_3)
70+
/*
71+
* Number of lanes in use, 0 == use all available lanes (default)
72+
*
73+
* This is a temporary fix for devices that need to reduce the number of active
74+
* lanes for certain modes, until g_mbus_config() can be replaced with a better
75+
* solution.
76+
*/
77+
#define V4L2_MBUS_CSI2_LANE_MASK (0xf << 10)
7078

7179
/**
7280
* enum v4l2_mbus_type - media bus type

0 commit comments

Comments
 (0)