Lines Matching refs:csi2dc
231 struct csi2dc_device *csi2dc = csi2dc_sd_to_csi2dc_device(csi2dc_sd); in csi2dc_get_fmt() local
242 format->format = csi2dc->format; in csi2dc_get_fmt()
251 struct csi2dc_device *csi2dc = csi2dc_sd_to_csi2dc_device(csi2dc_sd); in csi2dc_set_fmt() local
274 dev_dbg(csi2dc->dev, in csi2dc_set_fmt()
297 csi2dc->format = req_fmt->format; in csi2dc_set_fmt()
300 csi2dc->cur_fmt = try_fmt; in csi2dc_set_fmt()
302 dev_dbg(csi2dc->dev, "new format set: 0x%x @%dx%d\n", in csi2dc_set_fmt()
303 csi2dc->format.code, csi2dc->format.width, in csi2dc_set_fmt()
304 csi2dc->format.height); in csi2dc_set_fmt()
309 static int csi2dc_power(struct csi2dc_device *csi2dc, int on) in csi2dc_power() argument
314 ret = clk_prepare_enable(csi2dc->pclk); in csi2dc_power()
316 dev_err(csi2dc->dev, "failed to enable pclk:%d\n", ret); in csi2dc_power()
320 ret = clk_prepare_enable(csi2dc->scck); in csi2dc_power()
322 dev_err(csi2dc->dev, "failed to enable scck:%d\n", ret); in csi2dc_power()
323 clk_disable_unprepare(csi2dc->pclk); in csi2dc_power()
328 csi2dc_writel(csi2dc, CSI2DC_GCTLR, CSI2DC_GCTLR_SWRST); in csi2dc_power()
331 csi2dc_writel(csi2dc, CSI2DC_GCTLR, 0); in csi2dc_power()
333 clk_disable_unprepare(csi2dc->scck); in csi2dc_power()
334 clk_disable_unprepare(csi2dc->pclk); in csi2dc_power()
340 static int csi2dc_get_mbus_config(struct csi2dc_device *csi2dc) in csi2dc_get_mbus_config() argument
345 ret = v4l2_subdev_call(csi2dc->input_sd, pad, get_mbus_config, in csi2dc_get_mbus_config()
346 csi2dc->remote_pad, &mbus_config); in csi2dc_get_mbus_config()
348 dev_dbg(csi2dc->dev, in csi2dc_get_mbus_config()
354 dev_err(csi2dc->dev, in csi2dc_get_mbus_config()
359 dev_dbg(csi2dc->dev, "subdev sending on channel %d\n", csi2dc->vc); in csi2dc_get_mbus_config()
361 csi2dc->clk_gated = mbus_config.bus.parallel.flags & in csi2dc_get_mbus_config()
364 dev_dbg(csi2dc->dev, "mbus_config: %s clock\n", in csi2dc_get_mbus_config()
365 csi2dc->clk_gated ? "gated" : "free running"); in csi2dc_get_mbus_config()
370 static void csi2dc_vp_update(struct csi2dc_device *csi2dc) in csi2dc_vp_update() argument
374 if (!csi2dc->video_pipe) { in csi2dc_vp_update()
375 dev_err(csi2dc->dev, "video pipeline unavailable\n"); in csi2dc_vp_update()
379 if (csi2dc->parallel_mode) { in csi2dc_vp_update()
381 gcfg = csi2dc_readl(csi2dc, CSI2DC_GCFG); in csi2dc_vp_update()
383 csi2dc_writel(csi2dc, CSI2DC_GCFG, gcfg); in csi2dc_vp_update()
389 csi2dc_writel(csi2dc, CSI2DC_GCFG, in csi2dc_vp_update()
391 (csi2dc->clk_gated ? 0 : CSI2DC_GCFG_MIPIFRN)); in csi2dc_vp_update()
393 vp = CSI2DC_VPCFG_DT(csi2dc->cur_fmt->dt) & CSI2DC_VPCFG_DT_MASK; in csi2dc_vp_update()
394 vp |= CSI2DC_VPCFG_VC(csi2dc->vc) & CSI2DC_VPCFG_VC_MASK; in csi2dc_vp_update()
401 csi2dc_writel(csi2dc, CSI2DC_VPCFG, vp); in csi2dc_vp_update()
402 csi2dc_writel(csi2dc, CSI2DC_VPE, CSI2DC_VPE_ENABLE); in csi2dc_vp_update()
403 csi2dc_writel(csi2dc, CSI2DC_PU, CSI2DC_PU_VP); in csi2dc_vp_update()
408 struct csi2dc_device *csi2dc = csi2dc_sd_to_csi2dc_device(csi2dc_sd); in csi2dc_s_stream() local
412 ret = pm_runtime_resume_and_get(csi2dc->dev); in csi2dc_s_stream()
416 csi2dc_get_mbus_config(csi2dc); in csi2dc_s_stream()
418 csi2dc_vp_update(csi2dc); in csi2dc_s_stream()
420 return v4l2_subdev_call(csi2dc->input_sd, video, s_stream, in csi2dc_s_stream()
424 dev_dbg(csi2dc->dev, in csi2dc_s_stream()
426 csi2dc_readl(csi2dc, CSI2DC_VPCOL), in csi2dc_s_stream()
427 csi2dc_readl(csi2dc, CSI2DC_VPROW), in csi2dc_s_stream()
428 csi2dc_readl(csi2dc, CSI2DC_VPISR)); in csi2dc_s_stream()
431 ret = v4l2_subdev_call(csi2dc->input_sd, video, s_stream, false); in csi2dc_s_stream()
433 pm_runtime_put_sync(csi2dc->dev); in csi2dc_s_stream()
483 struct csi2dc_device *csi2dc = container_of(notifier, in csi2dc_async_bound() local
488 csi2dc->input_sd = subdev; in csi2dc_async_bound()
493 dev_err(csi2dc->dev, "Failed to find pad for %s\n", in csi2dc_async_bound()
498 csi2dc->remote_pad = pad; in csi2dc_async_bound()
500 ret = media_create_pad_link(&csi2dc->input_sd->entity, in csi2dc_async_bound()
501 csi2dc->remote_pad, in csi2dc_async_bound()
502 &csi2dc->csi2dc_sd.entity, 0, in csi2dc_async_bound()
505 dev_err(csi2dc->dev, in csi2dc_async_bound()
507 csi2dc->input_sd->entity.name, in csi2dc_async_bound()
508 csi2dc->csi2dc_sd.entity.name); in csi2dc_async_bound()
512 dev_dbg(csi2dc->dev, "link with %s pad: %d\n", in csi2dc_async_bound()
513 csi2dc->input_sd->name, csi2dc->remote_pad); in csi2dc_async_bound()
522 static int csi2dc_prepare_notifier(struct csi2dc_device *csi2dc, in csi2dc_prepare_notifier() argument
528 v4l2_async_subdev_nf_init(&csi2dc->notifier, &csi2dc->csi2dc_sd); in csi2dc_prepare_notifier()
530 asd = v4l2_async_nf_add_fwnode_remote(&csi2dc->notifier, in csi2dc_prepare_notifier()
538 dev_err(csi2dc->dev, in csi2dc_prepare_notifier()
541 v4l2_async_nf_cleanup(&csi2dc->notifier); in csi2dc_prepare_notifier()
545 csi2dc->notifier.ops = &csi2dc_async_ops; in csi2dc_prepare_notifier()
547 ret = v4l2_async_nf_register(&csi2dc->notifier); in csi2dc_prepare_notifier()
549 dev_err(csi2dc->dev, "fail to register async notifier: %d\n", in csi2dc_prepare_notifier()
551 v4l2_async_nf_cleanup(&csi2dc->notifier); in csi2dc_prepare_notifier()
557 static int csi2dc_of_parse(struct csi2dc_device *csi2dc, in csi2dc_of_parse() argument
568 dev_err(csi2dc->dev, in csi2dc_of_parse()
576 dev_err(csi2dc->dev, "endpoint not defined at %pOF\n", of_node); in csi2dc_of_parse()
582 csi2dc->parallel_mode = true; in csi2dc_of_parse()
583 dev_dbg(csi2dc->dev, in csi2dc_of_parse()
588 csi2dc->clk_gated = input_endpoint.bus.mipi_csi2.flags & in csi2dc_of_parse()
590 dev_dbg(csi2dc->dev, in csi2dc_of_parse()
592 dev_dbg(csi2dc->dev, "DT: %s clock\n", in csi2dc_of_parse()
593 csi2dc->clk_gated ? "gated" : "free running"); in csi2dc_of_parse()
606 dev_info(csi2dc->dev, in csi2dc_of_parse()
612 dev_err(csi2dc->dev, in csi2dc_of_parse()
618 csi2dc->video_pipe = true; in csi2dc_of_parse()
620 dev_dbg(csi2dc->dev, in csi2dc_of_parse()
628 return csi2dc_prepare_notifier(csi2dc, input_fwnode); in csi2dc_of_parse()
635 static void csi2dc_default_format(struct csi2dc_device *csi2dc) in csi2dc_default_format() argument
637 csi2dc->cur_fmt = &csi2dc_formats[0]; in csi2dc_default_format()
639 csi2dc->format.height = 480; in csi2dc_default_format()
640 csi2dc->format.width = 640; in csi2dc_default_format()
641 csi2dc->format.code = csi2dc_formats[0].mbus_code; in csi2dc_default_format()
642 csi2dc->format.colorspace = V4L2_COLORSPACE_SRGB; in csi2dc_default_format()
643 csi2dc->format.field = V4L2_FIELD_NONE; in csi2dc_default_format()
644 csi2dc->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; in csi2dc_default_format()
645 csi2dc->format.quantization = V4L2_QUANTIZATION_DEFAULT; in csi2dc_default_format()
646 csi2dc->format.xfer_func = V4L2_XFER_FUNC_DEFAULT; in csi2dc_default_format()
652 struct csi2dc_device *csi2dc; in csi2dc_probe() local
656 csi2dc = devm_kzalloc(dev, sizeof(*csi2dc), GFP_KERNEL); in csi2dc_probe()
657 if (!csi2dc) in csi2dc_probe()
660 csi2dc->dev = dev; in csi2dc_probe()
662 csi2dc->base = devm_platform_ioremap_resource(pdev, 0); in csi2dc_probe()
663 if (IS_ERR(csi2dc->base)) { in csi2dc_probe()
665 return PTR_ERR(csi2dc->base); in csi2dc_probe()
668 csi2dc->pclk = devm_clk_get(dev, "pclk"); in csi2dc_probe()
669 if (IS_ERR(csi2dc->pclk)) { in csi2dc_probe()
670 ret = PTR_ERR(csi2dc->pclk); in csi2dc_probe()
675 csi2dc->scck = devm_clk_get(dev, "scck"); in csi2dc_probe()
676 if (IS_ERR(csi2dc->scck)) { in csi2dc_probe()
677 ret = PTR_ERR(csi2dc->scck); in csi2dc_probe()
682 v4l2_subdev_init(&csi2dc->csi2dc_sd, &csi2dc_subdev_ops); in csi2dc_probe()
683 csi2dc->csi2dc_sd.internal_ops = &csi2dc_internal_ops; in csi2dc_probe()
685 csi2dc->csi2dc_sd.owner = THIS_MODULE; in csi2dc_probe()
686 csi2dc->csi2dc_sd.dev = dev; in csi2dc_probe()
687 snprintf(csi2dc->csi2dc_sd.name, sizeof(csi2dc->csi2dc_sd.name), in csi2dc_probe()
690 csi2dc->csi2dc_sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in csi2dc_probe()
691 csi2dc->csi2dc_sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; in csi2dc_probe()
692 csi2dc->csi2dc_sd.entity.ops = &csi2dc_entity_ops; in csi2dc_probe()
694 platform_set_drvdata(pdev, csi2dc); in csi2dc_probe()
696 ret = csi2dc_of_parse(csi2dc, dev->of_node); in csi2dc_probe()
700 csi2dc->pads[CSI2DC_PAD_SINK].flags = MEDIA_PAD_FL_SINK; in csi2dc_probe()
701 if (csi2dc->video_pipe) in csi2dc_probe()
702 csi2dc->pads[CSI2DC_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; in csi2dc_probe()
704 ret = media_entity_pads_init(&csi2dc->csi2dc_sd.entity, in csi2dc_probe()
705 csi2dc->video_pipe ? CSI2DC_PADS_NUM : 1, in csi2dc_probe()
706 csi2dc->pads); in csi2dc_probe()
712 csi2dc_default_format(csi2dc); in csi2dc_probe()
715 ret = csi2dc_power(csi2dc, true); in csi2dc_probe()
721 ver = csi2dc_readl(csi2dc, CSI2DC_VERSION); in csi2dc_probe()
728 ret = v4l2_async_register_subdev(&csi2dc->csi2dc_sd); in csi2dc_probe()
730 dev_err(csi2dc->dev, "failed to register the subdevice\n"); in csi2dc_probe()
739 v4l2_async_nf_cleanup(&csi2dc->notifier); in csi2dc_probe()
741 media_entity_cleanup(&csi2dc->csi2dc_sd.entity); in csi2dc_probe()
748 struct csi2dc_device *csi2dc = platform_get_drvdata(pdev); in csi2dc_remove() local
752 v4l2_async_unregister_subdev(&csi2dc->csi2dc_sd); in csi2dc_remove()
753 v4l2_async_nf_unregister(&csi2dc->notifier); in csi2dc_remove()
754 v4l2_async_nf_cleanup(&csi2dc->notifier); in csi2dc_remove()
755 media_entity_cleanup(&csi2dc->csi2dc_sd.entity); in csi2dc_remove()
760 struct csi2dc_device *csi2dc = dev_get_drvdata(dev); in csi2dc_runtime_suspend() local
762 return csi2dc_power(csi2dc, false); in csi2dc_runtime_suspend()
767 struct csi2dc_device *csi2dc = dev_get_drvdata(dev); in csi2dc_runtime_resume() local
769 return csi2dc_power(csi2dc, true); in csi2dc_runtime_resume()