Lines Matching refs:vfe
284 struct vfe_device *vfe = to_vfe(line); in vfe_src_pad_code() local
286 switch (vfe->camss->res->version) { in vfe_src_pad_code()
405 int vfe_reset(struct vfe_device *vfe) in vfe_reset() argument
409 reinit_completion(&vfe->reset_complete); in vfe_reset()
411 vfe->res->hw_ops->global_reset(vfe); in vfe_reset()
413 time = wait_for_completion_timeout(&vfe->reset_complete, in vfe_reset()
416 dev_err(vfe->camss->dev, "VFE reset timeout\n"); in vfe_reset()
423 static void vfe_init_outputs(struct vfe_device *vfe) in vfe_init_outputs() argument
427 for (i = 0; i < vfe->res->line_num; i++) { in vfe_init_outputs()
428 struct vfe_output *output = &vfe->line[i].output; in vfe_init_outputs()
437 static void vfe_reset_output_maps(struct vfe_device *vfe) in vfe_reset_output_maps() argument
441 for (i = 0; i < ARRAY_SIZE(vfe->wm_output_map); i++) in vfe_reset_output_maps()
442 vfe->wm_output_map[i] = VFE_LINE_NONE; in vfe_reset_output_maps()
445 int vfe_reserve_wm(struct vfe_device *vfe, enum vfe_line_id line_id) in vfe_reserve_wm() argument
450 for (i = 0; i < ARRAY_SIZE(vfe->wm_output_map); i++) { in vfe_reserve_wm()
451 if (vfe->wm_output_map[i] == VFE_LINE_NONE) { in vfe_reserve_wm()
452 vfe->wm_output_map[i] = line_id; in vfe_reserve_wm()
461 int vfe_release_wm(struct vfe_device *vfe, u8 wm) in vfe_release_wm() argument
463 if (wm >= ARRAY_SIZE(vfe->wm_output_map)) in vfe_release_wm()
466 vfe->wm_output_map[wm] = VFE_LINE_NONE; in vfe_release_wm()
511 struct vfe_device *vfe = to_vfe(line); in vfe_put_output() local
516 spin_lock_irqsave(&vfe->output_lock, flags); in vfe_put_output()
519 vfe_release_wm(vfe, output->wm_idx[i]); in vfe_put_output()
523 spin_unlock_irqrestore(&vfe->output_lock, flags); in vfe_put_output()
529 struct vfe_device *vfe = to_vfe(line); in vfe_disable_output() local
534 spin_lock_irqsave(&vfe->output_lock, flags); in vfe_disable_output()
536 vfe->res->hw_ops->vfe_wm_stop(vfe, output->wm_idx[i]); in vfe_disable_output()
538 spin_unlock_irqrestore(&vfe->output_lock, flags); in vfe_disable_output()
540 return vfe_reset(vfe); in vfe_disable_output()
551 struct vfe_device *vfe = to_vfe(line); in vfe_disable() local
560 mutex_lock(&vfe->stream_lock); in vfe_disable()
562 vfe->stream_count--; in vfe_disable()
564 mutex_unlock(&vfe->stream_lock); in vfe_disable()
575 void vfe_isr_comp_done(struct vfe_device *vfe, u8 comp) in vfe_isr_comp_done() argument
579 for (i = 0; i < ARRAY_SIZE(vfe->wm_output_map); i++) in vfe_isr_comp_done()
580 if (vfe->wm_output_map[i] == VFE_LINE_PIX) { in vfe_isr_comp_done()
581 vfe->isr_ops.wm_done(vfe, i); in vfe_isr_comp_done()
586 void vfe_isr_reset_ack(struct vfe_device *vfe) in vfe_isr_reset_ack() argument
588 complete(&vfe->reset_complete); in vfe_isr_reset_ack()
595 void vfe_pm_domain_off(struct vfe_device *vfe) in vfe_pm_domain_off() argument
597 if (!vfe->genpd) in vfe_pm_domain_off()
600 device_link_del(vfe->genpd_link); in vfe_pm_domain_off()
601 vfe->genpd_link = NULL; in vfe_pm_domain_off()
608 int vfe_pm_domain_on(struct vfe_device *vfe) in vfe_pm_domain_on() argument
610 struct camss *camss = vfe->camss; in vfe_pm_domain_on()
612 if (!vfe->genpd) in vfe_pm_domain_on()
615 vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, in vfe_pm_domain_on()
619 if (!vfe->genpd_link) in vfe_pm_domain_on()
625 static int vfe_match_clock_names(struct vfe_device *vfe, in vfe_match_clock_names() argument
631 snprintf(vfe_name, sizeof(vfe_name), "vfe%d", vfe->id); in vfe_match_clock_names()
632 snprintf(vfe_lite_name, sizeof(vfe_lite_name), "vfe_lite%d", vfe->id); in vfe_match_clock_names()
645 static int vfe_set_clock_rates(struct vfe_device *vfe) in vfe_set_clock_rates() argument
647 struct device *dev = vfe->camss->dev; in vfe_set_clock_rates()
652 for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) { in vfe_set_clock_rates()
653 ret = camss_get_pixel_clock(&vfe->line[i].subdev.entity, in vfe_set_clock_rates()
659 for (i = 0; i < vfe->nclocks; i++) { in vfe_set_clock_rates()
660 struct camss_clock *clock = &vfe->clock[i]; in vfe_set_clock_rates()
662 if (vfe_match_clock_names(vfe, clock)) { in vfe_set_clock_rates()
666 for (j = VFE_LINE_RDI0; j < vfe->res->line_num; j++) { in vfe_set_clock_rates()
673 struct vfe_line *l = &vfe->line[j]; in vfe_set_clock_rates()
727 static int vfe_check_clock_rates(struct vfe_device *vfe) in vfe_check_clock_rates() argument
733 for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) { in vfe_check_clock_rates()
734 ret = camss_get_pixel_clock(&vfe->line[i].subdev.entity, in vfe_check_clock_rates()
740 for (i = 0; i < vfe->nclocks; i++) { in vfe_check_clock_rates()
741 struct camss_clock *clock = &vfe->clock[i]; in vfe_check_clock_rates()
743 if (vfe_match_clock_names(vfe, clock)) { in vfe_check_clock_rates()
747 for (j = VFE_LINE_RDI0; j < vfe->res->line_num; j++) { in vfe_check_clock_rates()
754 struct vfe_line *l = &vfe->line[j]; in vfe_check_clock_rates()
783 int vfe_get(struct vfe_device *vfe) in vfe_get() argument
787 mutex_lock(&vfe->power_lock); in vfe_get()
789 if (vfe->power_count == 0) { in vfe_get()
790 ret = vfe->res->hw_ops->pm_domain_on(vfe); in vfe_get()
794 ret = pm_runtime_resume_and_get(vfe->camss->dev); in vfe_get()
798 ret = vfe_set_clock_rates(vfe); in vfe_get()
802 ret = camss_enable_clocks(vfe->nclocks, vfe->clock, in vfe_get()
803 vfe->camss->dev); in vfe_get()
807 ret = vfe_reset(vfe); in vfe_get()
811 vfe_reset_output_maps(vfe); in vfe_get()
813 vfe_init_outputs(vfe); in vfe_get()
815 vfe->res->hw_ops->hw_version(vfe); in vfe_get()
817 ret = vfe_check_clock_rates(vfe); in vfe_get()
821 vfe->power_count++; in vfe_get()
823 mutex_unlock(&vfe->power_lock); in vfe_get()
828 camss_disable_clocks(vfe->nclocks, vfe->clock); in vfe_get()
831 pm_runtime_put_sync(vfe->camss->dev); in vfe_get()
833 vfe->res->hw_ops->pm_domain_off(vfe); in vfe_get()
836 mutex_unlock(&vfe->power_lock); in vfe_get()
845 void vfe_put(struct vfe_device *vfe) in vfe_put() argument
847 mutex_lock(&vfe->power_lock); in vfe_put()
849 if (vfe->power_count == 0) { in vfe_put()
850 dev_err(vfe->camss->dev, "vfe power off on power_count == 0\n"); in vfe_put()
852 } else if (vfe->power_count == 1) { in vfe_put()
853 if (vfe->was_streaming) { in vfe_put()
854 vfe->was_streaming = 0; in vfe_put()
855 vfe->res->hw_ops->vfe_halt(vfe); in vfe_put()
857 camss_disable_clocks(vfe->nclocks, vfe->clock); in vfe_put()
858 pm_runtime_put_sync(vfe->camss->dev); in vfe_put()
859 vfe->res->hw_ops->pm_domain_off(vfe); in vfe_put()
862 vfe->power_count--; in vfe_put()
865 mutex_unlock(&vfe->power_lock); in vfe_put()
882 struct vfe_device *vfe = to_vfe(line); in vfe_flush_buffers() local
888 spin_lock_irqsave(&vfe->output_lock, flags); in vfe_flush_buffers()
903 spin_unlock_irqrestore(&vfe->output_lock, flags); in vfe_flush_buffers()
918 struct vfe_device *vfe = to_vfe(line); in vfe_set_power() local
922 ret = vfe_get(vfe); in vfe_set_power()
926 vfe_put(vfe); in vfe_set_power()
944 struct vfe_device *vfe = to_vfe(line); in vfe_set_stream() local
949 ret = vfe->res->hw_ops->vfe_enable(line); in vfe_set_stream()
951 dev_err(vfe->camss->dev, in vfe_set_stream()
954 ret = vfe->res->hw_ops->vfe_disable(line); in vfe_set_stream()
956 dev_err(vfe->camss->dev, in vfe_set_stream()
1483 int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe, in msm_vfe_subdev_init() argument
1491 if (!res->vfe.line_num) in msm_vfe_subdev_init()
1494 vfe->res = &res->vfe; in msm_vfe_subdev_init()
1495 vfe->res->hw_ops->subdev_init(dev, vfe); in msm_vfe_subdev_init()
1499 if (res->vfe.pd_name) { in msm_vfe_subdev_init()
1500 vfe->genpd = dev_pm_domain_attach_by_name(camss->dev, in msm_vfe_subdev_init()
1501 res->vfe.pd_name); in msm_vfe_subdev_init()
1502 if (IS_ERR(vfe->genpd)) { in msm_vfe_subdev_init()
1503 ret = PTR_ERR(vfe->genpd); in msm_vfe_subdev_init()
1508 if (!vfe->genpd && res->vfe.has_pd) { in msm_vfe_subdev_init()
1520 vfe->genpd = dev_pm_domain_attach_by_id(camss->dev, id); in msm_vfe_subdev_init()
1521 if (IS_ERR(vfe->genpd)) in msm_vfe_subdev_init()
1522 return PTR_ERR(vfe->genpd); in msm_vfe_subdev_init()
1527 vfe->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]); in msm_vfe_subdev_init()
1528 if (IS_ERR(vfe->base)) { in msm_vfe_subdev_init()
1530 return PTR_ERR(vfe->base); in msm_vfe_subdev_init()
1539 vfe->irq = ret; in msm_vfe_subdev_init()
1540 snprintf(vfe->irq_name, sizeof(vfe->irq_name), "%s_%s%d", in msm_vfe_subdev_init()
1542 ret = devm_request_irq(dev, vfe->irq, vfe->res->hw_ops->isr, in msm_vfe_subdev_init()
1543 IRQF_TRIGGER_RISING, vfe->irq_name, vfe); in msm_vfe_subdev_init()
1551 vfe->nclocks = 0; in msm_vfe_subdev_init()
1552 while (res->clock[vfe->nclocks]) in msm_vfe_subdev_init()
1553 vfe->nclocks++; in msm_vfe_subdev_init()
1555 vfe->clock = devm_kcalloc(dev, vfe->nclocks, sizeof(*vfe->clock), in msm_vfe_subdev_init()
1557 if (!vfe->clock) in msm_vfe_subdev_init()
1560 for (i = 0; i < vfe->nclocks; i++) { in msm_vfe_subdev_init()
1561 struct camss_clock *clock = &vfe->clock[i]; in msm_vfe_subdev_init()
1589 mutex_init(&vfe->power_lock); in msm_vfe_subdev_init()
1590 vfe->power_count = 0; in msm_vfe_subdev_init()
1592 mutex_init(&vfe->stream_lock); in msm_vfe_subdev_init()
1593 vfe->stream_count = 0; in msm_vfe_subdev_init()
1595 spin_lock_init(&vfe->output_lock); in msm_vfe_subdev_init()
1597 vfe->camss = camss; in msm_vfe_subdev_init()
1598 vfe->id = id; in msm_vfe_subdev_init()
1599 vfe->reg_update = 0; in msm_vfe_subdev_init()
1601 for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) { in msm_vfe_subdev_init()
1602 struct vfe_line *l = &vfe->line[i]; in msm_vfe_subdev_init()
1611 l->nformats = res->vfe.formats_pix->nformats; in msm_vfe_subdev_init()
1612 l->formats = res->vfe.formats_pix->formats; in msm_vfe_subdev_init()
1614 l->nformats = res->vfe.formats_rdi->nformats; in msm_vfe_subdev_init()
1615 l->formats = res->vfe.formats_rdi->formats; in msm_vfe_subdev_init()
1619 init_completion(&vfe->reset_complete); in msm_vfe_subdev_init()
1620 init_completion(&vfe->halt_complete); in msm_vfe_subdev_init()
1629 void msm_vfe_genpd_cleanup(struct vfe_device *vfe) in msm_vfe_genpd_cleanup() argument
1631 if (vfe->genpd_link) in msm_vfe_genpd_cleanup()
1632 device_link_del(vfe->genpd_link); in msm_vfe_genpd_cleanup()
1634 if (vfe->genpd) in msm_vfe_genpd_cleanup()
1635 dev_pm_domain_detach(vfe->genpd, true); in msm_vfe_genpd_cleanup()
1690 static int vfe_bpl_align(struct vfe_device *vfe) in vfe_bpl_align() argument
1694 switch (vfe->camss->res->version) { in vfe_bpl_align()
1719 int msm_vfe_register_entities(struct vfe_device *vfe, in msm_vfe_register_entities() argument
1722 struct device *dev = vfe->camss->dev; in msm_vfe_register_entities()
1729 for (i = 0; i < vfe->res->line_num; i++) { in msm_vfe_register_entities()
1732 sd = &vfe->line[i].subdev; in msm_vfe_register_entities()
1733 pads = vfe->line[i].pads; in msm_vfe_register_entities()
1734 video_out = &vfe->line[i].video_out; in msm_vfe_register_entities()
1741 MSM_VFE_NAME, vfe->id, "pix"); in msm_vfe_register_entities()
1744 MSM_VFE_NAME, vfe->id, "rdi", i); in msm_vfe_register_entities()
1746 v4l2_set_subdevdata(sd, &vfe->line[i]); in msm_vfe_register_entities()
1772 video_out->ops = &vfe->video_ops; in msm_vfe_register_entities()
1773 video_out->bpl_alignment = vfe_bpl_align(vfe); in msm_vfe_register_entities()
1780 video_out->nformats = vfe->line[i].nformats; in msm_vfe_register_entities()
1781 video_out->formats = vfe->line[i].formats; in msm_vfe_register_entities()
1784 MSM_VFE_NAME, vfe->id, "video", i); in msm_vfe_register_entities()
1817 sd = &vfe->line[i].subdev; in msm_vfe_register_entities()
1818 video_out = &vfe->line[i].video_out; in msm_vfe_register_entities()
1832 void msm_vfe_unregister_entities(struct vfe_device *vfe) in msm_vfe_unregister_entities() argument
1836 mutex_destroy(&vfe->power_lock); in msm_vfe_unregister_entities()
1837 mutex_destroy(&vfe->stream_lock); in msm_vfe_unregister_entities()
1839 for (i = 0; i < vfe->res->line_num; i++) { in msm_vfe_unregister_entities()
1840 struct v4l2_subdev *sd = &vfe->line[i].subdev; in msm_vfe_unregister_entities()
1841 struct camss_video *video_out = &vfe->line[i].video_out; in msm_vfe_unregister_entities()
1849 bool vfe_is_lite(struct vfe_device *vfe) in vfe_is_lite() argument
1851 return vfe->camss->res->vfe_res[vfe->id].vfe.is_lite; in vfe_is_lite()