Lines Matching full:csi
3 * Rockchip ISP1 Driver - CSI-2 Receiver
22 #include "rkisp1-csi.h"
34 rkisp1_csi_get_pad_fmt(struct rkisp1_csi *csi, in rkisp1_csi_get_pad_fmt() argument
39 .pads = csi->pad_cfg in rkisp1_csi_get_pad_fmt()
42 lockdep_assert_held(&csi->lock); in rkisp1_csi_get_pad_fmt()
45 return v4l2_subdev_get_try_format(&csi->sd, sd_state, pad); in rkisp1_csi_get_pad_fmt()
47 return v4l2_subdev_get_try_format(&csi->sd, &state, pad); in rkisp1_csi_get_pad_fmt()
54 struct rkisp1_csi *csi = &rkisp1->csi; in rkisp1_csi_link_sensor() local
65 /* Create the link from the sensor to the CSI receiver. */ in rkisp1_csi_link_sensor()
67 &csi->sd.entity, RKISP1_CSI_PAD_SINK, in rkisp1_csi_link_sensor()
70 dev_err(csi->rkisp1->dev, "failed to link src pad of %s\n", in rkisp1_csi_link_sensor()
78 static int rkisp1_csi_config(struct rkisp1_csi *csi, in rkisp1_csi_config() argument
81 struct rkisp1_device *rkisp1 = csi->rkisp1; in rkisp1_csi_config()
101 RKISP1_CIF_MIPI_DATA_SEL_DT(csi->sink_fmt->mipi_dt) | in rkisp1_csi_config()
129 static void rkisp1_csi_enable(struct rkisp1_csi *csi) in rkisp1_csi_enable() argument
131 struct rkisp1_device *rkisp1 = csi->rkisp1; in rkisp1_csi_enable()
139 static void rkisp1_csi_disable(struct rkisp1_csi *csi) in rkisp1_csi_disable() argument
141 struct rkisp1_device *rkisp1 = csi->rkisp1; in rkisp1_csi_disable()
165 static int rkisp1_csi_start(struct rkisp1_csi *csi, in rkisp1_csi_start() argument
168 struct rkisp1_device *rkisp1 = csi->rkisp1; in rkisp1_csi_start()
174 ret = rkisp1_csi_config(csi, sensor); in rkisp1_csi_start()
184 phy_mipi_dphy_get_default_config(pixel_clock, csi->sink_fmt->bus_width, in rkisp1_csi_start()
186 phy_set_mode(csi->dphy, PHY_MODE_MIPI_DPHY); in rkisp1_csi_start()
187 phy_configure(csi->dphy, &opts); in rkisp1_csi_start()
188 phy_power_on(csi->dphy); in rkisp1_csi_start()
190 rkisp1_csi_enable(csi); in rkisp1_csi_start()
201 static void rkisp1_csi_stop(struct rkisp1_csi *csi) in rkisp1_csi_stop() argument
203 rkisp1_csi_disable(csi); in rkisp1_csi_stop()
205 phy_power_off(csi->dphy); in rkisp1_csi_stop()
233 rkisp1->csi.is_dphy_errctrl_disabled = true; in rkisp1_csi_isr()
245 if (rkisp1->csi.is_dphy_errctrl_disabled) { in rkisp1_csi_isr()
249 rkisp1->csi.is_dphy_errctrl_disabled = false; in rkisp1_csi_isr()
266 struct rkisp1_csi *csi = to_rkisp1_csi(sd); in rkisp1_csi_enum_mbus_code() local
276 mutex_lock(&csi->lock); in rkisp1_csi_enum_mbus_code()
278 sink_fmt = rkisp1_csi_get_pad_fmt(csi, sd_state, in rkisp1_csi_enum_mbus_code()
283 mutex_unlock(&csi->lock); in rkisp1_csi_enum_mbus_code()
333 struct rkisp1_csi *csi = to_rkisp1_csi(sd); in rkisp1_csi_get_fmt() local
335 mutex_lock(&csi->lock); in rkisp1_csi_get_fmt()
336 fmt->format = *rkisp1_csi_get_pad_fmt(csi, sd_state, fmt->pad, in rkisp1_csi_get_fmt()
338 mutex_unlock(&csi->lock); in rkisp1_csi_get_fmt()
347 struct rkisp1_csi *csi = to_rkisp1_csi(sd); in rkisp1_csi_set_fmt() local
355 mutex_lock(&csi->lock); in rkisp1_csi_set_fmt()
357 sink_fmt = rkisp1_csi_get_pad_fmt(csi, sd_state, RKISP1_CSI_PAD_SINK, in rkisp1_csi_set_fmt()
378 csi->sink_fmt = mbus_info; in rkisp1_csi_set_fmt()
381 src_fmt = rkisp1_csi_get_pad_fmt(csi, sd_state, RKISP1_CSI_PAD_SRC, in rkisp1_csi_set_fmt()
385 mutex_unlock(&csi->lock); in rkisp1_csi_set_fmt()
396 struct rkisp1_csi *csi = to_rkisp1_csi(sd); in rkisp1_csi_s_stream() local
397 struct rkisp1_device *rkisp1 = csi->rkisp1; in rkisp1_csi_s_stream()
405 v4l2_subdev_call(csi->source, video, s_stream, false); in rkisp1_csi_s_stream()
407 rkisp1_csi_stop(csi); in rkisp1_csi_s_stream()
414 dev_dbg(rkisp1->dev, "Failed to get source for CSI: %ld\n", in rkisp1_csi_s_stream()
433 mutex_lock(&csi->lock); in rkisp1_csi_s_stream()
434 ret = rkisp1_csi_start(csi, source_asd); in rkisp1_csi_s_stream()
435 mutex_unlock(&csi->lock); in rkisp1_csi_s_stream()
441 rkisp1_csi_stop(csi); in rkisp1_csi_s_stream()
445 csi->source = source; in rkisp1_csi_s_stream()
476 struct rkisp1_csi *csi = &rkisp1->csi; in rkisp1_csi_register() local
482 csi->rkisp1 = rkisp1; in rkisp1_csi_register()
483 mutex_init(&csi->lock); in rkisp1_csi_register()
485 sd = &csi->sd; in rkisp1_csi_register()
493 pads = csi->pads; in rkisp1_csi_register()
499 csi->sink_fmt = rkisp1_mbus_info_get_by_code(RKISP1_CSI_DEF_FMT); in rkisp1_csi_register()
505 state.pads = csi->pad_cfg; in rkisp1_csi_register()
508 ret = v4l2_device_register_subdev(&csi->rkisp1->v4l2_dev, sd); in rkisp1_csi_register()
510 dev_err(sd->dev, "Failed to register csi receiver subdev\n"); in rkisp1_csi_register()
518 mutex_destroy(&csi->lock); in rkisp1_csi_register()
519 csi->rkisp1 = NULL; in rkisp1_csi_register()
525 struct rkisp1_csi *csi = &rkisp1->csi; in rkisp1_csi_unregister() local
527 if (!csi->rkisp1) in rkisp1_csi_unregister()
530 v4l2_device_unregister_subdev(&csi->sd); in rkisp1_csi_unregister()
531 media_entity_cleanup(&csi->sd.entity); in rkisp1_csi_unregister()
532 mutex_destroy(&csi->lock); in rkisp1_csi_unregister()
537 struct rkisp1_csi *csi = &rkisp1->csi; in rkisp1_csi_init() local
539 csi->rkisp1 = rkisp1; in rkisp1_csi_init()
541 csi->dphy = devm_phy_get(rkisp1->dev, "dphy"); in rkisp1_csi_init()
542 if (IS_ERR(csi->dphy)) in rkisp1_csi_init()
543 return dev_err_probe(rkisp1->dev, PTR_ERR(csi->dphy), in rkisp1_csi_init()
546 phy_init(csi->dphy); in rkisp1_csi_init()
553 struct rkisp1_csi *csi = &rkisp1->csi; in rkisp1_csi_cleanup() local
555 phy_exit(csi->dphy); in rkisp1_csi_cleanup()