Lines Matching +full:bcm2835 +full:- +full:vc4
1 // SPDX-License-Identifier: GPL-2.0-only
7 * DOC: VC4 SDTV module
13 * PAL and PAL-M or NTSC and NTSC-J.
85 * VEC_FREQ1_0 contains the most significant 16-bit half-word,
86 * VEC_FREQ3_2 contains the least significant 16-bit half-word.
92 * NTSC (3579545.[45] Hz) - 0x21F07C1F
93 * PAL (4433618.75 Hz) - 0x2A098ACB
94 * PAL-M (3575611.[888111] Hz) - 0x21E6EFE3
95 * PAL-N (3582056.25 Hz) - 0x21F69446
213 readl(vec->regs + (offset)); \
219 writel(val, vec->regs + (offset)); \
302 /* PAL-60 */
354 if (tv_mode->mode == mode && in vc4_vec_tv_mode_lookup()
355 tv_mode->expected_htotal == htotal) in vc4_vec_tv_mode_lookup()
364 { VC4_VEC_TV_MODE_NTSC_443, "NTSC-443", },
365 { VC4_VEC_TV_MODE_NTSC_J, "NTSC-J", },
367 { VC4_VEC_TV_MODE_PAL_60, "PAL-60", },
368 { VC4_VEC_TV_MODE_PAL_M, "PAL-M", },
369 { VC4_VEC_TV_MODE_PAL_N, "PAL-N", },
394 if (property != vec->legacy_tv_mode_property) in vc4_vec_connector_set_property()
395 return -EINVAL; in vc4_vec_connector_set_property()
399 state->tv.mode = DRM_MODE_TV_MODE_NTSC; in vc4_vec_connector_set_property()
403 state->tv.mode = DRM_MODE_TV_MODE_NTSC_443; in vc4_vec_connector_set_property()
407 state->tv.mode = DRM_MODE_TV_MODE_NTSC_J; in vc4_vec_connector_set_property()
412 state->tv.mode = DRM_MODE_TV_MODE_PAL; in vc4_vec_connector_set_property()
416 state->tv.mode = DRM_MODE_TV_MODE_PAL_M; in vc4_vec_connector_set_property()
420 state->tv.mode = DRM_MODE_TV_MODE_PAL_N; in vc4_vec_connector_set_property()
424 state->tv.mode = DRM_MODE_TV_MODE_SECAM; in vc4_vec_connector_set_property()
428 state->tv.mode = DRM_MODE_TV_MODE_MONOCHROME; in vc4_vec_connector_set_property()
432 return -EINVAL; in vc4_vec_connector_set_property()
446 if (property != vec->legacy_tv_mode_property) in vc4_vec_connector_get_property()
447 return -EINVAL; in vc4_vec_connector_get_property()
449 switch (state->tv.mode) { in vc4_vec_connector_get_property()
483 return -EINVAL; in vc4_vec_connector_get_property()
506 struct drm_connector *connector = &vec->connector; in vc4_vec_connector_init()
510 connector->interlace_allowed = true; in vc4_vec_connector_init()
519 drm_object_attach_property(&connector->base, in vc4_vec_connector_init()
520 dev->mode_config.tv_mode_property, in vc4_vec_connector_init()
527 return -ENOMEM; in vc4_vec_connector_init()
528 vec->legacy_tv_mode_property = prop; in vc4_vec_connector_init()
530 drm_object_attach_property(&connector->base, prop, VC4_VEC_TV_MODE_NTSC); in vc4_vec_connector_init()
534 drm_connector_attach_encoder(connector, &vec->encoder.base); in vc4_vec_connector_init()
542 struct drm_device *drm = encoder->dev; in vc4_vec_encoder_disable()
556 clk_disable_unprepare(vec->clock); in vc4_vec_encoder_disable()
558 ret = pm_runtime_put(&vec->pdev->dev); in vc4_vec_encoder_disable()
574 struct drm_device *drm = encoder->dev; in vc4_vec_encoder_enable()
576 struct drm_connector *connector = &vec->connector; in vc4_vec_encoder_enable()
580 &encoder->crtc->state->adjusted_mode; in vc4_vec_encoder_enable()
587 tv_mode = vc4_vec_tv_mode_lookup(conn_state->tv.mode, in vc4_vec_encoder_enable()
588 adjusted_mode->htotal); in vc4_vec_encoder_enable()
592 ret = pm_runtime_resume_and_get(&vec->pdev->dev); in vc4_vec_encoder_enable()
605 ret = clk_set_rate(vec->clock, 108000000); in vc4_vec_encoder_enable()
611 ret = clk_prepare_enable(vec->clock); in vc4_vec_encoder_enable()
621 /* Disable the CGSM-A and WSE blocks */ in vc4_vec_encoder_enable()
640 ((adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) ? 0 : VEC_CONFIG2_PROG_SCAN)); in vc4_vec_encoder_enable()
642 VEC_WRITE(VEC_DAC_CONFIG, vec->variant->dac_config); in vc4_vec_encoder_enable()
647 VEC_WRITE(VEC_CONFIG0, tv_mode->config0); in vc4_vec_encoder_enable()
648 VEC_WRITE(VEC_CONFIG1, tv_mode->config1); in vc4_vec_encoder_enable()
650 if (tv_mode->custom_freq) { in vc4_vec_encoder_enable()
652 (tv_mode->custom_freq >> 16) & 0xffff); in vc4_vec_encoder_enable()
654 tv_mode->custom_freq & 0xffff); in vc4_vec_encoder_enable()
665 pm_runtime_put(&vec->pdev->dev); in vc4_vec_encoder_enable()
674 const struct drm_display_mode *mode = &crtc_state->adjusted_mode; in vc4_vec_encoder_atomic_check()
677 tv_mode = vc4_vec_tv_mode_lookup(conn_state->tv.mode, mode->htotal); in vc4_vec_encoder_atomic_check()
679 return -EINVAL; in vc4_vec_encoder_atomic_check()
681 if (mode->crtc_hdisplay % 4) in vc4_vec_encoder_atomic_check()
682 return -EINVAL; in vc4_vec_encoder_atomic_check()
684 if (!(mode->crtc_hsync_end - mode->crtc_hsync_start)) in vc4_vec_encoder_atomic_check()
685 return -EINVAL; in vc4_vec_encoder_atomic_check()
687 switch (mode->htotal) { in vc4_vec_encoder_atomic_check()
690 if (mode->crtc_vtotal > 262) in vc4_vec_encoder_atomic_check()
691 return -EINVAL; in vc4_vec_encoder_atomic_check()
693 if (mode->crtc_vdisplay < 1 || mode->crtc_vdisplay > 253) in vc4_vec_encoder_atomic_check()
694 return -EINVAL; in vc4_vec_encoder_atomic_check()
696 if (!(mode->crtc_vsync_start - mode->crtc_vdisplay)) in vc4_vec_encoder_atomic_check()
697 return -EINVAL; in vc4_vec_encoder_atomic_check()
699 if ((mode->crtc_vsync_end - mode->crtc_vsync_start) != 3) in vc4_vec_encoder_atomic_check()
700 return -EINVAL; in vc4_vec_encoder_atomic_check()
702 if ((mode->crtc_vtotal - mode->crtc_vsync_end) < 4) in vc4_vec_encoder_atomic_check()
703 return -EINVAL; in vc4_vec_encoder_atomic_check()
709 if (mode->crtc_vtotal > 312) in vc4_vec_encoder_atomic_check()
710 return -EINVAL; in vc4_vec_encoder_atomic_check()
712 if (mode->crtc_vdisplay < 1 || mode->crtc_vdisplay > 305) in vc4_vec_encoder_atomic_check()
713 return -EINVAL; in vc4_vec_encoder_atomic_check()
715 if (!(mode->crtc_vsync_start - mode->crtc_vdisplay)) in vc4_vec_encoder_atomic_check()
716 return -EINVAL; in vc4_vec_encoder_atomic_check()
718 if ((mode->crtc_vsync_end - mode->crtc_vsync_start) != 3) in vc4_vec_encoder_atomic_check()
719 return -EINVAL; in vc4_vec_encoder_atomic_check()
721 if ((mode->crtc_vtotal - mode->crtc_vsync_end) < 2) in vc4_vec_encoder_atomic_check()
722 return -EINVAL; in vc4_vec_encoder_atomic_check()
727 return -EINVAL; in vc4_vec_encoder_atomic_check()
741 struct drm_device *drm = encoder->dev; in vc4_vec_late_register()
744 vc4_debugfs_add_regset32(drm, "vec_regs", &vec->regset); in vc4_vec_late_register()
766 { .compatible = "brcm,bcm2835-vec", .data = &bcm2835_vec_variant },
767 { .compatible = "brcm,bcm2711-vec", .data = &bcm2711_vec_variant },
792 return -ENOMEM; in vc4_vec_bind()
794 vec->encoder.type = VC4_ENCODER_TYPE_VEC; in vc4_vec_bind()
795 vec->pdev = pdev; in vc4_vec_bind()
796 vec->variant = (const struct vc4_vec_variant *) in vc4_vec_bind()
798 vec->regs = vc4_ioremap_regs(pdev, 0); in vc4_vec_bind()
799 if (IS_ERR(vec->regs)) in vc4_vec_bind()
800 return PTR_ERR(vec->regs); in vc4_vec_bind()
801 vec->regset.base = vec->regs; in vc4_vec_bind()
802 vec->regset.regs = vec_regs; in vc4_vec_bind()
803 vec->regset.nregs = ARRAY_SIZE(vec_regs); in vc4_vec_bind()
805 vec->clock = devm_clk_get(dev, NULL); in vc4_vec_bind()
806 if (IS_ERR(vec->clock)) { in vc4_vec_bind()
807 ret = PTR_ERR(vec->clock); in vc4_vec_bind()
808 if (ret != -EPROBE_DEFER) in vc4_vec_bind()
817 ret = drmm_encoder_init(drm, &vec->encoder.base, in vc4_vec_bind()
824 drm_encoder_helper_add(&vec->encoder.base, &vc4_vec_encoder_helper_funcs); in vc4_vec_bind()
841 return component_add(&pdev->dev, &vc4_vec_ops); in vc4_vec_dev_probe()
846 component_del(&pdev->dev, &vc4_vec_ops); in vc4_vec_dev_remove()