Lines Matching refs:hqvdp
373 static int sti_hqvdp_get_free_cmd(struct sti_hqvdp *hqvdp) in sti_hqvdp_get_free_cmd() argument
376 dma_addr_t cmd = hqvdp->hqvdp_cmd_paddr; in sti_hqvdp_get_free_cmd()
379 curr_cmd = readl(hqvdp->regs + HQVDP_MBX_CURRENT_CMD); in sti_hqvdp_get_free_cmd()
380 next_cmd = readl(hqvdp->regs + HQVDP_MBX_NEXT_CMD); in sti_hqvdp_get_free_cmd()
401 static int sti_hqvdp_get_curr_cmd(struct sti_hqvdp *hqvdp) in sti_hqvdp_get_curr_cmd() argument
404 dma_addr_t cmd = hqvdp->hqvdp_cmd_paddr; in sti_hqvdp_get_curr_cmd()
407 curr_cmd = readl(hqvdp->regs + HQVDP_MBX_CURRENT_CMD); in sti_hqvdp_get_curr_cmd()
497 static bool sti_hqvdp_check_hw_scaling(struct sti_hqvdp *hqvdp, in sti_hqvdp_check_hw_scaling() argument
505 lfw = mode->htotal * (clk_get_rate(hqvdp->clk) / 1000000); in sti_hqvdp_check_hw_scaling()
519 static void sti_hqvdp_disable(struct sti_hqvdp *hqvdp) in sti_hqvdp_disable() argument
523 DRM_DEBUG_DRIVER("%s\n", sti_plane_to_str(&hqvdp->plane)); in sti_hqvdp_disable()
526 if (sti_vtg_unregister_client(hqvdp->vtg, &hqvdp->vtg_nb)) in sti_hqvdp_disable()
530 writel(0, hqvdp->regs + HQVDP_MBX_NEXT_CMD); in sti_hqvdp_disable()
533 if (readl(hqvdp->regs + HQVDP_MBX_INFO_XP70) in sti_hqvdp_disable()
540 clk_disable_unprepare(hqvdp->clk_pix_main); in sti_hqvdp_disable()
545 hqvdp->plane.status = STI_PLANE_DISABLED; in sti_hqvdp_disable()
561 struct sti_hqvdp *hqvdp = container_of(nb, struct sti_hqvdp, vtg_nb); in sti_hqvdp_vtg_cb() local
570 if (hqvdp->plane.status == STI_PLANE_FLUSHING) { in sti_hqvdp_vtg_cb()
573 sti_plane_to_str(&hqvdp->plane)); in sti_hqvdp_vtg_cb()
575 sti_hqvdp_disable(hqvdp); in sti_hqvdp_vtg_cb()
578 if (hqvdp->btm_field_pending) { in sti_hqvdp_vtg_cb()
580 btm_cmd_offset = sti_hqvdp_get_free_cmd(hqvdp); in sti_hqvdp_vtg_cb()
581 top_cmd_offest = sti_hqvdp_get_curr_cmd(hqvdp); in sti_hqvdp_vtg_cb()
587 btm_cmd = hqvdp->hqvdp_cmd + btm_cmd_offset; in sti_hqvdp_vtg_cb()
588 top_cmd = hqvdp->hqvdp_cmd + top_cmd_offest; in sti_hqvdp_vtg_cb()
599 writel(hqvdp->hqvdp_cmd_paddr + btm_cmd_offset, in sti_hqvdp_vtg_cb()
600 hqvdp->regs + HQVDP_MBX_NEXT_CMD); in sti_hqvdp_vtg_cb()
602 hqvdp->curr_field_count++; in sti_hqvdp_vtg_cb()
603 hqvdp->btm_field_pending = false; in sti_hqvdp_vtg_cb()
605 dev_dbg(hqvdp->dev, "%s Posted command:0x%x\n", in sti_hqvdp_vtg_cb()
606 __func__, hqvdp->hqvdp_cmd_paddr); in sti_hqvdp_vtg_cb()
612 static void sti_hqvdp_init(struct sti_hqvdp *hqvdp) in sti_hqvdp_init() argument
616 hqvdp->vtg_nb.notifier_call = sti_hqvdp_vtg_cb; in sti_hqvdp_init()
620 hqvdp->hqvdp_cmd = dma_alloc_writecombine(hqvdp->dev, size, in sti_hqvdp_init()
621 &hqvdp->hqvdp_cmd_paddr, in sti_hqvdp_init()
623 if (!hqvdp->hqvdp_cmd) { in sti_hqvdp_init()
628 memset(hqvdp->hqvdp_cmd, 0, size); in sti_hqvdp_init()
631 static void sti_hqvdp_init_plugs(struct sti_hqvdp *hqvdp) in sti_hqvdp_init_plugs() argument
634 writel(PLUG_PAGE_SIZE_256, hqvdp->regs + HQVDP_RD_PLUG_PAGE_SIZE); in sti_hqvdp_init_plugs()
635 writel(PLUG_MIN_OPC_8, hqvdp->regs + HQVDP_RD_PLUG_MIN_OPC); in sti_hqvdp_init_plugs()
636 writel(PLUG_MAX_OPC_64, hqvdp->regs + HQVDP_RD_PLUG_MAX_OPC); in sti_hqvdp_init_plugs()
637 writel(PLUG_MAX_CHK_2X, hqvdp->regs + HQVDP_RD_PLUG_MAX_CHK); in sti_hqvdp_init_plugs()
638 writel(PLUG_MAX_MSG_1X, hqvdp->regs + HQVDP_RD_PLUG_MAX_MSG); in sti_hqvdp_init_plugs()
639 writel(PLUG_MIN_SPACE_1, hqvdp->regs + HQVDP_RD_PLUG_MIN_SPACE); in sti_hqvdp_init_plugs()
640 writel(PLUG_CONTROL_ENABLE, hqvdp->regs + HQVDP_RD_PLUG_CONTROL); in sti_hqvdp_init_plugs()
642 writel(PLUG_PAGE_SIZE_256, hqvdp->regs + HQVDP_WR_PLUG_PAGE_SIZE); in sti_hqvdp_init_plugs()
643 writel(PLUG_MIN_OPC_8, hqvdp->regs + HQVDP_WR_PLUG_MIN_OPC); in sti_hqvdp_init_plugs()
644 writel(PLUG_MAX_OPC_64, hqvdp->regs + HQVDP_WR_PLUG_MAX_OPC); in sti_hqvdp_init_plugs()
645 writel(PLUG_MAX_CHK_2X, hqvdp->regs + HQVDP_WR_PLUG_MAX_CHK); in sti_hqvdp_init_plugs()
646 writel(PLUG_MAX_MSG_1X, hqvdp->regs + HQVDP_WR_PLUG_MAX_MSG); in sti_hqvdp_init_plugs()
647 writel(PLUG_MIN_SPACE_1, hqvdp->regs + HQVDP_WR_PLUG_MIN_SPACE); in sti_hqvdp_init_plugs()
648 writel(PLUG_CONTROL_ENABLE, hqvdp->regs + HQVDP_WR_PLUG_CONTROL); in sti_hqvdp_init_plugs()
657 static void sti_hqvdp_start_xp70(struct sti_hqvdp *hqvdp) in sti_hqvdp_start_xp70() argument
672 if (hqvdp->xp70_initialized) { in sti_hqvdp_start_xp70()
678 if (request_firmware(&firmware, HQVDP_FMW_NAME, hqvdp->dev)) { in sti_hqvdp_start_xp70()
714 if (clk_prepare_enable(hqvdp->clk)) in sti_hqvdp_start_xp70()
718 writel(SW_RESET_CTRL_FULL, hqvdp->regs + HQVDP_MBX_SW_RESET_CTRL); in sti_hqvdp_start_xp70()
721 if (readl(hqvdp->regs + HQVDP_MBX_STARTUP_CTRL1) in sti_hqvdp_start_xp70()
733 writel(fw_rd_plug[i], hqvdp->regs + HQVDP_RD_PLUG + i * 4); in sti_hqvdp_start_xp70()
735 writel(fw_wr_plug[i], hqvdp->regs + HQVDP_WR_PLUG + i * 4); in sti_hqvdp_start_xp70()
737 sti_hqvdp_init_plugs(hqvdp); in sti_hqvdp_start_xp70()
740 writel(STARTUP_CTRL1_AUTH_IDLE, hqvdp->regs + HQVDP_MBX_STARTUP_CTRL1); in sti_hqvdp_start_xp70()
743 writel(SOFT_VSYNC_SW_CTRL_IRQ, hqvdp->regs + HQVDP_MBX_SOFT_VSYNC); in sti_hqvdp_start_xp70()
744 writel(0, hqvdp->regs + HQVDP_MBX_NEXT_CMD); in sti_hqvdp_start_xp70()
748 writel(fw_pmem[i], hqvdp->regs + HQVDP_PMEM + i * 4); in sti_hqvdp_start_xp70()
750 writel(fw_dmem[i], hqvdp->regs + HQVDP_DMEM + i * 4); in sti_hqvdp_start_xp70()
753 writel(STARTUP_CTRL2_FETCH_EN, hqvdp->regs + HQVDP_MBX_STARTUP_CTRL2); in sti_hqvdp_start_xp70()
757 if (readl(hqvdp->regs + HQVDP_MBX_INFO_XP70) in sti_hqvdp_start_xp70()
768 writel(SOFT_VSYNC_HW, hqvdp->regs + HQVDP_MBX_SOFT_VSYNC); in sti_hqvdp_start_xp70()
772 hqvdp->xp70_initialized = true; in sti_hqvdp_start_xp70()
783 struct sti_hqvdp *hqvdp = to_sti_hqvdp(plane); in sti_hqvdp_atomic_update() local
811 cmd_offset = sti_hqvdp_get_free_cmd(hqvdp); in sti_hqvdp_atomic_update()
816 cmd = hqvdp->hqvdp_cmd + cmd_offset; in sti_hqvdp_atomic_update()
818 if (!sti_hqvdp_check_hw_scaling(hqvdp, mode, in sti_hqvdp_atomic_update()
905 sti_hqvdp_start_xp70(hqvdp); in sti_hqvdp_atomic_update()
908 if (clk_prepare_enable(hqvdp->clk_pix_main)) { in sti_hqvdp_atomic_update()
914 if (sti_vtg_register_client(hqvdp->vtg, in sti_hqvdp_atomic_update()
915 &hqvdp->vtg_nb, in sti_hqvdp_atomic_update()
922 writel(hqvdp->hqvdp_cmd_paddr + cmd_offset, in sti_hqvdp_atomic_update()
923 hqvdp->regs + HQVDP_MBX_NEXT_CMD); in sti_hqvdp_atomic_update()
925 hqvdp->curr_field_count++; in sti_hqvdp_atomic_update()
929 hqvdp->btm_field_pending = true; in sti_hqvdp_atomic_update()
931 dev_dbg(hqvdp->dev, "%s Posted command:0x%x\n", in sti_hqvdp_atomic_update()
932 __func__, hqvdp->hqvdp_cmd_paddr + cmd_offset); in sti_hqvdp_atomic_update()
964 struct sti_hqvdp *hqvdp = dev_get_drvdata(dev); in sti_hqvdp_create() local
967 hqvdp->plane.desc = desc; in sti_hqvdp_create()
968 hqvdp->plane.status = STI_PLANE_DISABLED; in sti_hqvdp_create()
970 sti_hqvdp_init(hqvdp); in sti_hqvdp_create()
972 res = drm_universal_plane_init(drm_dev, &hqvdp->plane.drm_plane, 1, in sti_hqvdp_create()
982 drm_plane_helper_add(&hqvdp->plane.drm_plane, &sti_hqvdp_helpers_funcs); in sti_hqvdp_create()
984 sti_plane_init_property(&hqvdp->plane, DRM_PLANE_TYPE_OVERLAY); in sti_hqvdp_create()
986 return &hqvdp->plane.drm_plane; in sti_hqvdp_create()
991 struct sti_hqvdp *hqvdp = dev_get_drvdata(dev); in sti_hqvdp_bind() local
997 hqvdp->drm_dev = drm_dev; in sti_hqvdp_bind()
1000 plane = sti_hqvdp_create(drm_dev, hqvdp->dev, STI_HQVDP_0); in sti_hqvdp_bind()
1022 struct sti_hqvdp *hqvdp; in sti_hqvdp_probe() local
1027 hqvdp = devm_kzalloc(dev, sizeof(*hqvdp), GFP_KERNEL); in sti_hqvdp_probe()
1028 if (!hqvdp) { in sti_hqvdp_probe()
1033 hqvdp->dev = dev; in sti_hqvdp_probe()
1041 hqvdp->regs = devm_ioremap(dev, res->start, resource_size(res)); in sti_hqvdp_probe()
1042 if (hqvdp->regs == NULL) { in sti_hqvdp_probe()
1048 hqvdp->clk = devm_clk_get(dev, "hqvdp"); in sti_hqvdp_probe()
1049 hqvdp->clk_pix_main = devm_clk_get(dev, "pix_main"); in sti_hqvdp_probe()
1050 if (IS_ERR(hqvdp->clk) || IS_ERR(hqvdp->clk_pix_main)) { in sti_hqvdp_probe()
1056 hqvdp->reset = devm_reset_control_get(dev, "hqvdp"); in sti_hqvdp_probe()
1057 if (!IS_ERR(hqvdp->reset)) in sti_hqvdp_probe()
1058 reset_control_deassert(hqvdp->reset); in sti_hqvdp_probe()
1062 hqvdp->vtg = of_vtg_find(vtg_np); in sti_hqvdp_probe()
1064 platform_set_drvdata(pdev, hqvdp); in sti_hqvdp_probe()