Lines Matching +full:clock +full:- +full:lane
4 * SPDX-License-Identifier: Apache-2.0
11 #include <zephyr/drivers/video-controls.h>
22 #define ABS(a, b) (a > b ? a - b : b - a)
51 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_update_settings()
52 struct mipi_csi2rx_data *drv_data = dev->data; in mipi_csi2rx_update_settings()
59 ret = video_get_format(config->sensor_dev, ep, &fmt); in mipi_csi2rx_update_settings()
65 ret = video_get_ctrl(config->sensor_dev, VIDEO_CID_PIXEL_RATE, &sensor_pixel_rate); in mipi_csi2rx_update_settings()
73 return -ENOTSUP; in mipi_csi2rx_update_settings()
77 sensor_byte_clk = sensor_pixel_rate * bpp / drv_data->csi2rxConfig.laneNum / 8; in mipi_csi2rx_update_settings()
79 ret = clock_control_get_rate(drv_data->clock_dev, drv_data->clock_root, &root_clk_rate); in mipi_csi2rx_update_settings()
85 ret = clock_control_set_rate(drv_data->clock_dev, drv_data->clock_root, in mipi_csi2rx_update_settings()
92 ret = clock_control_get_rate(drv_data->clock_dev, drv_data->clock_ui, &ui_clk_rate); in mipi_csi2rx_update_settings()
99 drv_data->clock_dev, drv_data->clock_ui, in mipi_csi2rx_update_settings()
116 drv_data->csi2rxConfig.tHsSettle_EscClk = tHsSettleEscClk_configs[ind].tHsSettle_EscClk; in mipi_csi2rx_update_settings()
124 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_set_fmt()
126 if (video_set_format(config->sensor_dev, ep, fmt)) { in mipi_csi2rx_set_fmt()
127 return -EIO; in mipi_csi2rx_set_fmt()
136 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_get_fmt()
139 return -EINVAL; in mipi_csi2rx_get_fmt()
142 if (video_get_format(config->sensor_dev, ep, fmt)) { in mipi_csi2rx_get_fmt()
143 return -EIO; in mipi_csi2rx_get_fmt()
151 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_stream_start()
152 struct mipi_csi2rx_data *drv_data = dev->data; in mipi_csi2rx_stream_start()
154 CSI2RX_Init((MIPI_CSI2RX_Type *)config->base, &drv_data->csi2rxConfig); in mipi_csi2rx_stream_start()
156 if (video_stream_start(config->sensor_dev)) { in mipi_csi2rx_stream_start()
157 return -EIO; in mipi_csi2rx_stream_start()
165 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_stream_stop()
167 if (video_stream_stop(config->sensor_dev)) { in mipi_csi2rx_stream_stop()
168 return -EIO; in mipi_csi2rx_stream_stop()
171 CSI2RX_Deinit((MIPI_CSI2RX_Type *)config->base); in mipi_csi2rx_stream_stop()
179 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_get_caps()
182 return -EINVAL; in mipi_csi2rx_get_caps()
186 return video_get_caps(config->sensor_dev, ep, caps); in mipi_csi2rx_get_caps()
191 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_set_ctrl()
193 if (config->sensor_dev) { in mipi_csi2rx_set_ctrl()
194 return video_set_ctrl(config->sensor_dev, cid, value); in mipi_csi2rx_set_ctrl()
197 return -ENOTSUP; in mipi_csi2rx_set_ctrl()
203 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_set_frmival()
206 ret = video_set_frmival(config->sensor_dev, ep, frmival); in mipi_csi2rx_set_frmival()
220 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_get_frmival()
222 return video_get_frmival(config->sensor_dev, ep, frmival); in mipi_csi2rx_get_frmival()
227 return fmt->height * fmt->width * video_pix_fmt_bpp(fmt->pixelformat) * 8; in mipi_csi2rx_cal_frame_size()
236 return mipi_csi2rx_cal_frame_size(cur_format) * fie_frmival->denominator * in mipi_csi2rx_estimate_pixel_rate()
237 cur_fmival->numerator * cur_pixel_rate / in mipi_csi2rx_estimate_pixel_rate()
238 (mipi_csi2rx_cal_frame_size(fie_format) * fie_frmival->numerator * in mipi_csi2rx_estimate_pixel_rate()
239 cur_fmival->denominator); in mipi_csi2rx_estimate_pixel_rate()
245 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_enum_frmival()
246 struct mipi_csi2rx_data *drv_data = dev->data; in mipi_csi2rx_enum_frmival()
252 ret = video_enum_frmival(config->sensor_dev, ep, fie); in mipi_csi2rx_enum_frmival()
257 ret = video_get_ctrl(config->sensor_dev, VIDEO_CID_PIXEL_RATE, &cur_pixel_rate); in mipi_csi2rx_enum_frmival()
263 ret = video_get_frmival(config->sensor_dev, ep, &cur_frmival); in mipi_csi2rx_enum_frmival()
269 ret = video_get_format(config->sensor_dev, ep, &cur_fmt); in mipi_csi2rx_enum_frmival()
275 if (fie->type == VIDEO_FRMIVAL_TYPE_DISCRETE) { in mipi_csi2rx_enum_frmival()
277 &cur_frmival, &fie->discrete, &cur_fmt, fie->format, cur_pixel_rate, in mipi_csi2rx_enum_frmival()
278 drv_data->csi2rxConfig.laneNum); in mipi_csi2rx_enum_frmival()
280 return -EINVAL; in mipi_csi2rx_enum_frmival()
284 /* Check the lane rate of the lower bound framerate */ in mipi_csi2rx_enum_frmival()
286 &cur_frmival, &fie->stepwise.min, &cur_fmt, fie->format, cur_pixel_rate, in mipi_csi2rx_enum_frmival()
287 drv_data->csi2rxConfig.laneNum); in mipi_csi2rx_enum_frmival()
289 return -EINVAL; in mipi_csi2rx_enum_frmival()
292 /* Check the lane rate of the upper bound framerate */ in mipi_csi2rx_enum_frmival()
294 &cur_frmival, &fie->stepwise.max, &cur_fmt, fie->format, cur_pixel_rate, in mipi_csi2rx_enum_frmival()
295 drv_data->csi2rxConfig.laneNum); in mipi_csi2rx_enum_frmival()
297 fie->stepwise.max.denominator = in mipi_csi2rx_enum_frmival()
300 (mipi_csi2rx_cal_frame_size(fie->format) * cur_pixel_rate * in mipi_csi2rx_enum_frmival()
302 fie->stepwise.max.numerator = 1; in mipi_csi2rx_enum_frmival()
323 const struct mipi_csi2rx_config *config = dev->config; in mipi_csi2rx_init()
324 struct mipi_csi2rx_data *drv_data = dev->data; in mipi_csi2rx_init()
328 if (!device_is_ready(config->sensor_dev)) { in mipi_csi2rx_init()
329 return -ENODEV; in mipi_csi2rx_init()
333 * CSI2 escape clock should be in the range [60, 80] Mhz. We set it in mipi_csi2rx_init()
336 ret = clock_control_set_rate(drv_data->clock_dev, drv_data->clock_esc, in mipi_csi2rx_init()