Skip to content

Commit 04480c8

Browse files
Alain Volmatdkalowsk
authored andcommitted
video: stm32: dcmipp: use video_get_csi_link_freq helper
Rely on video_get_csi_link_freq for getting CSI phy bitrate informations. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
1 parent 52d1e2f commit 04480c8

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

drivers/video/video_stm32_dcmipp.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -329,28 +329,24 @@ static int stm32_dcmipp_conf_csi(const struct device *dev, uint32_t dcmipp_csi_b
329329
const struct stm32_dcmipp_config *config = dev->config;
330330
struct stm32_dcmipp_data *dcmipp = dev->data;
331331
DCMIPP_CSI_ConfTypeDef csiconf = { 0 };
332-
uint64_t phy_bitrate;
333-
struct video_control ctrl = {
334-
.id = VIDEO_CID_PIXEL_RATE,
335-
};
332+
int64_t phy_bitrate;
336333
int err, i;
337334

338335
csiconf.NumberOfLanes = config->csi.nb_lanes == 2 ? DCMIPP_CSI_TWO_DATA_LANES :
339336
DCMIPP_CSI_ONE_DATA_LANE;
340337
csiconf.DataLaneMapping = config->csi.lanes[0] == 1 ? DCMIPP_CSI_PHYSICAL_DATA_LANES :
341338
DCMIPP_CSI_INVERTED_DATA_LANES;
342339

343-
/* Get the pixel_rate from the source to guess the bitrate */
344-
err = video_get_ctrl(config->source_dev, &ctrl);
345-
if (err < 0) {
346-
LOG_ERR("Can not get source_dev pixel rate");
347-
return err;
340+
/* Get link-frequency information from source */
341+
phy_bitrate = video_get_csi_link_freq(config->source_dev,
342+
video_bits_per_pixel(dcmipp->source_fmt.pixelformat),
343+
config->csi.nb_lanes);
344+
if (phy_bitrate < 0) {
345+
LOG_ERR("Failed to retrieve source link-frequency");
346+
return -EIO;
348347
}
349-
phy_bitrate = ctrl.val64 * video_bits_per_pixel(dcmipp->source_fmt.pixelformat) /
350-
(2 * config->csi.nb_lanes);
348+
351349
phy_bitrate /= MHZ(1);
352-
LOG_DBG("Sensor PixelRate = %lld, PHY Bitrate computed = %lld MHz",
353-
ctrl.val64, phy_bitrate);
354350

355351
for (i = 0; i < ARRAY_SIZE(stm32_dcmipp_bitrate); i++) {
356352
if (stm32_dcmipp_bitrate[i].rate >= phy_bitrate) {

0 commit comments

Comments
 (0)