Skip to content

Commit e9c849c

Browse files
committed
media: rp1: cfe: Actually use the number of lanes configured
The driver was calling get_mbus_config to ask the sensor subdev how many CSI2 data lanes it wished to use and with what other properties, but then failed to pass that to the DPHY configuration. Signed-off-by: Dave Stevenson <[email protected]>
1 parent 79148c9 commit e9c849c

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

drivers/media/platform/raspberrypi/rp1_cfe/cfe.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ static u64 sensor_link_rate(struct cfe_device *cfe)
10861086
}
10871087

10881088
link_freq = v4l2_get_link_freq(subdev->ctrl_handler, fmt->depth,
1089-
cfe->csi2.active_data_lanes * 2);
1089+
cfe->csi2.dphy.active_lanes * 2);
10901090
if (link_freq < 0)
10911091
goto err;
10921092

@@ -1149,27 +1149,24 @@ static int cfe_start_streaming(struct vb2_queue *vq, unsigned int count)
11491149
cfg_reg_write(cfe, MIPICFG_CFG, MIPICFG_CFG_SEL_CSI);
11501150
cfg_reg_write(cfe, MIPICFG_INTE, MIPICFG_INT_CSI_DMA | MIPICFG_INT_PISP_FE);
11511151

1152-
cfe->csi2.active_data_lanes = cfe->csi2.dphy.num_lanes;
1153-
cfe_dbg("Running with %u data lanes\n", cfe->csi2.active_data_lanes);
1154-
11551152
ret = v4l2_subdev_call(cfe->sensor, pad, get_mbus_config, 0,
11561153
&mbus_config);
11571154
if (ret < 0 && ret != -ENOIOCTLCMD) {
11581155
cfe_err("g_mbus_config failed\n");
11591156
goto err_pm_put;
11601157
}
11611158

1162-
cfe->csi2.active_data_lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
1163-
if (!cfe->csi2.active_data_lanes)
1164-
cfe->csi2.active_data_lanes = cfe->csi2.dphy.num_lanes;
1165-
if (cfe->csi2.active_data_lanes > cfe->csi2.dphy.num_lanes) {
1159+
cfe->csi2.dphy.active_lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
1160+
if (!cfe->csi2.dphy.active_lanes)
1161+
cfe->csi2.dphy.active_lanes = cfe->csi2.dphy.max_lanes;
1162+
if (cfe->csi2.dphy.active_lanes > cfe->csi2.dphy.max_lanes) {
11661163
cfe_err("Device has requested %u data lanes, which is >%u configured in DT\n",
1167-
cfe->csi2.active_data_lanes, cfe->csi2.dphy.num_lanes);
1164+
cfe->csi2.dphy.active_lanes, cfe->csi2.dphy.max_lanes);
11681165
ret = -EINVAL;
11691166
goto err_disable_cfe;
11701167
}
11711168

1172-
cfe_dbg("Configuring CSI-2 block\n");
1169+
cfe_dbg("Configuring CSI-2 block - %u data lanes\n", cfe->csi2.dphy.active_lanes);
11731170
cfe->csi2.dphy.dphy_rate = sensor_link_rate(cfe) / 1000000UL;
11741171
csi2_open_rx(&cfe->csi2);
11751172

@@ -2167,11 +2164,11 @@ static int of_cfe_connect_subdevs(struct cfe_device *cfe)
21672164
}
21682165
}
21692166

2170-
cfe->csi2.dphy.num_lanes = ep.bus.mipi_csi2.num_data_lanes;
2167+
cfe->csi2.dphy.max_lanes = ep.bus.mipi_csi2.num_data_lanes;
21712168
cfe->csi2.bus_flags = ep.bus.mipi_csi2.flags;
21722169

21732170
cfe_dbg("subdevice %pOF: %u data lanes, flags=0x%08x, multipacket_line=%u\n",
2174-
sensor_node, cfe->csi2.dphy.num_lanes, cfe->csi2.bus_flags,
2171+
sensor_node, cfe->csi2.dphy.max_lanes, cfe->csi2.bus_flags,
21752172
cfe->csi2.multipacket_line);
21762173

21772174
/* Initialize and register the async notifier. */

drivers/media/platform/raspberrypi/rp1_cfe/csi2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ struct csi2_device {
5757

5858
enum v4l2_mbus_type bus_type;
5959
unsigned int bus_flags;
60-
u32 active_data_lanes;
6160
bool multipacket_line;
6261
unsigned int num_lines[CSI2_NUM_CHANNELS];
6362

drivers/media/platform/raspberrypi/rp1_cfe/dphy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static void dphy_init(struct dphy_data *dphy)
149149

150150
void dphy_start(struct dphy_data *dphy)
151151
{
152-
dw_csi2_host_write(dphy, N_LANES, (dphy->num_lanes - 1));
152+
dw_csi2_host_write(dphy, N_LANES, (dphy->active_lanes - 1));
153153
dphy_init(dphy);
154154
dw_csi2_host_write(dphy, RESETN, 0xffffffff);
155155
usleep_range(10, 50);

drivers/media/platform/raspberrypi/rp1_cfe/dphy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ struct dphy_data {
1616
void __iomem *base;
1717

1818
u32 dphy_rate;
19-
u32 num_lanes;
19+
u32 max_lanes;
20+
u32 active_lanes;
2021
};
2122

2223
void dphy_probe(struct dphy_data *dphy);

0 commit comments

Comments
 (0)