Skip to content

Commit 09e5cc8

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 51b486f commit 09e5cc8

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
@@ -1609,11 +1609,20 @@ static int tc358743_get_mbus_config(struct v4l2_subdev *sd,
16091609
struct v4l2_mbus_config *cfg)
16101610
{
16111611
struct tc358743_state *state = to_state(sd);
1612+
const u32 mask = V4L2_MBUS_CSI2_LANE_MASK;
1613+
1614+
if (state->csi_lanes_in_use > state->bus.num_data_lanes)
1615+
return -EINVAL;
16121616

16131617
cfg->type = V4L2_MBUS_CSI2_DPHY;
1618+
cfg->flags = (state->csi_lanes_in_use << __ffs(mask)) & mask;
1619+
1620+
/* In DT mode, only report the number of active lanes */
1621+
if (sd->dev->of_node)
1622+
return 0;
16141623

1615-
/* Support for non-continuous CSI-2 clock is missing in the driver */
1616-
cfg->flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
1624+
/* Support for non-continuous CSI-2 clock is missing in pdate mode */
1625+
cfg->flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
16171626

16181627
switch (state->csi_lanes_in_use) {
16191628
case 1:
@@ -2055,6 +2064,7 @@ static int tc358743_probe(struct i2c_client *client)
20552064
if (pdata) {
20562065
state->pdata = *pdata;
20572066
state->bus.flags = V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
2067+
state->bus.num_data_lanes = 4;
20582068
} else {
20592069
err = tc358743_probe_of(state);
20602070
if (err == -ENODEV)

‎include/media/v4l2-mediabus.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@
9292
V4L2_MBUS_CSI2_CHANNEL_1 | \
9393
V4L2_MBUS_CSI2_CHANNEL_2 | \
9494
V4L2_MBUS_CSI2_CHANNEL_3)
95+
/*
96+
* Number of lanes in use, 0 == use all available lanes (default)
97+
*
98+
* This is a temporary fix for devices that need to reduce the number of active
99+
* lanes for certain modes, until g_mbus_config() can be replaced with a better
100+
* solution.
101+
*/
102+
#define V4L2_MBUS_CSI2_LANE_MASK (0xf << 10)
95103

96104
/**
97105
* enum v4l2_mbus_type - media bus type

0 commit comments

Comments
 (0)