Skip to content

Commit edfbfec

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 3c8b360 commit edfbfec

2 files changed

Lines changed: 24 additions & 14 deletions

File tree

‎drivers/media/i2c/tc358743.c‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,28 +1606,29 @@ 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;
1615+
cfg->flags = (state->csi_lanes_in_use << __ffs(mask)) & mask;
16111616

1612-
/* Support for non-continuous CSI-2 clock is missing in the driver */
1613-
cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
1617+
/* In DT mode, only report the number of active lanes */
1618+
if (sd->dev->of_node)
1619+
return 0;
16141620

1615-
switch (state->csi_lanes_in_use) {
1616-
case 1:
1621+
/* Support for non-continuous CSI-2 clock is missing in pdata mode */
1622+
cfg->flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
1623+
1624+
if (state->bus.num_data_lanes > 0)
16171625
cfg->flags |= V4L2_MBUS_CSI2_1_LANE;
1618-
break;
1619-
case 2:
1626+
if (state->bus.num_data_lanes > 1)
16201627
cfg->flags |= V4L2_MBUS_CSI2_2_LANE;
1621-
break;
1622-
case 3:
1628+
if (state->bus.num_data_lanes > 2)
16231629
cfg->flags |= V4L2_MBUS_CSI2_3_LANE;
1624-
break;
1625-
case 4:
1630+
if (state->bus.num_data_lanes > 3)
16261631
cfg->flags |= V4L2_MBUS_CSI2_4_LANE;
1627-
break;
1628-
default:
1629-
return -EINVAL;
1630-
}
16311632

16321633
return 0;
16331634
}
@@ -2052,6 +2053,7 @@ static int tc358743_probe(struct i2c_client *client,
20522053
if (pdata) {
20532054
state->pdata = *pdata;
20542055
state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
2056+
state->bus.num_data_lanes = 4;
20552057
} else {
20562058
err = tc358743_probe_of(state);
20572059
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_3_LANE | V4L2_MBUS_CSI2_4_LANE)
6868
#define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \
6969
V4L2_MBUS_CSI2_CHANNEL_2 | 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)