Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media: rp1: cfe: Actually use the number of lanes configured #5941

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ static u64 sensor_link_rate(struct cfe_device *cfe)
}

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

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

cfe->csi2.active_data_lanes = cfe->csi2.dphy.num_lanes;
cfe_dbg("Running with %u data lanes\n", cfe->csi2.active_data_lanes);

ret = v4l2_subdev_call(cfe->sensor, pad, get_mbus_config, 0,
&mbus_config);
if (ret < 0 && ret != -ENOIOCTLCMD) {
cfe_err("g_mbus_config failed\n");
goto err_pm_put;
}

cfe->csi2.active_data_lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
if (!cfe->csi2.active_data_lanes)
cfe->csi2.active_data_lanes = cfe->csi2.dphy.num_lanes;
if (cfe->csi2.active_data_lanes > cfe->csi2.dphy.num_lanes) {
cfe->csi2.dphy.active_lanes = mbus_config.bus.mipi_csi2.num_data_lanes;
if (!cfe->csi2.dphy.active_lanes)
cfe->csi2.dphy.active_lanes = cfe->csi2.dphy.max_lanes;
if (cfe->csi2.dphy.active_lanes > cfe->csi2.dphy.max_lanes) {
cfe_err("Device has requested %u data lanes, which is >%u configured in DT\n",
cfe->csi2.active_data_lanes, cfe->csi2.dphy.num_lanes);
cfe->csi2.dphy.active_lanes, cfe->csi2.dphy.max_lanes);
ret = -EINVAL;
goto err_disable_cfe;
}

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

Expand Down Expand Up @@ -2167,11 +2164,11 @@ static int of_cfe_connect_subdevs(struct cfe_device *cfe)
}
}

cfe->csi2.dphy.num_lanes = ep.bus.mipi_csi2.num_data_lanes;
cfe->csi2.dphy.max_lanes = ep.bus.mipi_csi2.num_data_lanes;
cfe->csi2.bus_flags = ep.bus.mipi_csi2.flags;

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

/* Initialize and register the async notifier. */
Expand Down
1 change: 0 additions & 1 deletion drivers/media/platform/raspberrypi/rp1_cfe/csi2.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct csi2_device {

enum v4l2_mbus_type bus_type;
unsigned int bus_flags;
u32 active_data_lanes;
bool multipacket_line;
unsigned int num_lines[CSI2_NUM_CHANNELS];

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/raspberrypi/rp1_cfe/dphy.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static void dphy_init(struct dphy_data *dphy)

void dphy_start(struct dphy_data *dphy)
{
dw_csi2_host_write(dphy, N_LANES, (dphy->num_lanes - 1));
dw_csi2_host_write(dphy, N_LANES, (dphy->active_lanes - 1));
dphy_init(dphy);
dw_csi2_host_write(dphy, RESETN, 0xffffffff);
usleep_range(10, 50);
Expand Down
3 changes: 2 additions & 1 deletion drivers/media/platform/raspberrypi/rp1_cfe/dphy.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ struct dphy_data {
void __iomem *base;

u32 dphy_rate;
u32 num_lanes;
u32 max_lanes;
u32 active_lanes;
};

void dphy_probe(struct dphy_data *dphy);
Expand Down