Lines Matching refs:rga
37 struct rockchip_rga *rga = ctx->rga; in device_run() local
41 spin_lock_irqsave(&rga->ctrl_lock, flags); in device_run()
43 rga->curr = ctx; in device_run()
51 rga_hw_start(rga); in device_run()
53 spin_unlock_irqrestore(&rga->ctrl_lock, flags); in device_run()
58 struct rockchip_rga *rga = prv; in rga_isr() local
61 intr = rga_read(rga, RGA_INT) & 0xf; in rga_isr()
63 rga_mod(rga, RGA_INT, intr << 4, 0xf << 4); in rga_isr()
67 struct rga_ctx *ctx = rga->curr; in rga_isr()
71 rga->curr = NULL; in rga_isr()
83 v4l2_m2m_job_finish(rga->m2m_dev, ctx->fh.m2m_ctx); in rga_isr()
106 src_vq->lock = &ctx->rga->mutex; in queue_init()
107 src_vq->dev = ctx->rga->v4l2_dev.dev; in queue_init()
120 dst_vq->lock = &ctx->rga->mutex; in queue_init()
121 dst_vq->dev = ctx->rga->v4l2_dev.dev; in queue_init()
132 spin_lock_irqsave(&ctx->rga->ctrl_lock, flags); in rga_s_ctrl()
147 spin_unlock_irqrestore(&ctx->rga->ctrl_lock, flags); in rga_s_ctrl()
157 struct rockchip_rga *rga = ctx->rga; in rga_setup_ctrls() local
176 v4l2_err(&rga->v4l2_dev, "%s failed\n", __func__); in rga_setup_ctrls()
360 struct rockchip_rga *rga = video_drvdata(file); in rga_open() local
367 ctx->rga = rga; in rga_open()
372 if (mutex_lock_interruptible(&rga->mutex)) { in rga_open()
376 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(rga->m2m_dev, ctx, &queue_init); in rga_open()
379 mutex_unlock(&rga->mutex); in rga_open()
393 mutex_unlock(&rga->mutex); in rga_open()
402 struct rockchip_rga *rga = ctx->rga; in rga_release() local
404 mutex_lock(&rga->mutex); in rga_release()
413 mutex_unlock(&rga->mutex); in rga_release()
510 struct rockchip_rga *rga = ctx->rga; in vidioc_s_fmt() local
524 v4l2_err(&rga->v4l2_dev, "queue (%d) bust\n", f->type); in vidioc_s_fmt()
601 struct rockchip_rga *rga = ctx->rga; in vidioc_s_selection() local
635 v4l2_dbg(debug, 1, &rga->v4l2_dev, in vidioc_s_selection()
643 v4l2_dbg(debug, 1, &rga->v4l2_dev, "unsupported crop value.\n"); in vidioc_s_selection()
693 static int rga_enable_clocks(struct rockchip_rga *rga) in rga_enable_clocks() argument
697 ret = clk_prepare_enable(rga->sclk); in rga_enable_clocks()
699 dev_err(rga->dev, "Cannot enable rga sclk: %d\n", ret); in rga_enable_clocks()
703 ret = clk_prepare_enable(rga->aclk); in rga_enable_clocks()
705 dev_err(rga->dev, "Cannot enable rga aclk: %d\n", ret); in rga_enable_clocks()
709 ret = clk_prepare_enable(rga->hclk); in rga_enable_clocks()
711 dev_err(rga->dev, "Cannot enable rga hclk: %d\n", ret); in rga_enable_clocks()
718 clk_disable_unprepare(rga->aclk); in rga_enable_clocks()
720 clk_disable_unprepare(rga->sclk); in rga_enable_clocks()
725 static void rga_disable_clocks(struct rockchip_rga *rga) in rga_disable_clocks() argument
727 clk_disable_unprepare(rga->sclk); in rga_disable_clocks()
728 clk_disable_unprepare(rga->hclk); in rga_disable_clocks()
729 clk_disable_unprepare(rga->aclk); in rga_disable_clocks()
732 static int rga_parse_dt(struct rockchip_rga *rga) in rga_parse_dt() argument
736 core_rst = devm_reset_control_get(rga->dev, "core"); in rga_parse_dt()
738 dev_err(rga->dev, "failed to get core reset controller\n"); in rga_parse_dt()
742 axi_rst = devm_reset_control_get(rga->dev, "axi"); in rga_parse_dt()
744 dev_err(rga->dev, "failed to get axi reset controller\n"); in rga_parse_dt()
748 ahb_rst = devm_reset_control_get(rga->dev, "ahb"); in rga_parse_dt()
750 dev_err(rga->dev, "failed to get ahb reset controller\n"); in rga_parse_dt()
766 rga->sclk = devm_clk_get(rga->dev, "sclk"); in rga_parse_dt()
767 if (IS_ERR(rga->sclk)) { in rga_parse_dt()
768 dev_err(rga->dev, "failed to get sclk clock\n"); in rga_parse_dt()
769 return PTR_ERR(rga->sclk); in rga_parse_dt()
772 rga->aclk = devm_clk_get(rga->dev, "aclk"); in rga_parse_dt()
773 if (IS_ERR(rga->aclk)) { in rga_parse_dt()
774 dev_err(rga->dev, "failed to get aclk clock\n"); in rga_parse_dt()
775 return PTR_ERR(rga->aclk); in rga_parse_dt()
778 rga->hclk = devm_clk_get(rga->dev, "hclk"); in rga_parse_dt()
779 if (IS_ERR(rga->hclk)) { in rga_parse_dt()
780 dev_err(rga->dev, "failed to get hclk clock\n"); in rga_parse_dt()
781 return PTR_ERR(rga->hclk); in rga_parse_dt()
789 struct rockchip_rga *rga; in rga_probe() local
797 rga = devm_kzalloc(&pdev->dev, sizeof(*rga), GFP_KERNEL); in rga_probe()
798 if (!rga) in rga_probe()
801 rga->dev = &pdev->dev; in rga_probe()
802 spin_lock_init(&rga->ctrl_lock); in rga_probe()
803 mutex_init(&rga->mutex); in rga_probe()
805 ret = rga_parse_dt(rga); in rga_probe()
809 pm_runtime_enable(rga->dev); in rga_probe()
811 rga->regs = devm_platform_ioremap_resource(pdev, 0); in rga_probe()
812 if (IS_ERR(rga->regs)) { in rga_probe()
813 ret = PTR_ERR(rga->regs); in rga_probe()
823 ret = devm_request_irq(rga->dev, irq, rga_isr, 0, in rga_probe()
824 dev_name(rga->dev), rga); in rga_probe()
826 dev_err(rga->dev, "failed to request irq\n"); in rga_probe()
830 ret = v4l2_device_register(&pdev->dev, &rga->v4l2_dev); in rga_probe()
835 v4l2_err(&rga->v4l2_dev, "Failed to allocate video device\n"); in rga_probe()
840 vfd->lock = &rga->mutex; in rga_probe()
841 vfd->v4l2_dev = &rga->v4l2_dev; in rga_probe()
843 video_set_drvdata(vfd, rga); in rga_probe()
844 rga->vfd = vfd; in rga_probe()
846 platform_set_drvdata(pdev, rga); in rga_probe()
847 rga->m2m_dev = v4l2_m2m_init(&rga_m2m_ops); in rga_probe()
848 if (IS_ERR(rga->m2m_dev)) { in rga_probe()
849 v4l2_err(&rga->v4l2_dev, "Failed to init mem2mem device\n"); in rga_probe()
850 ret = PTR_ERR(rga->m2m_dev); in rga_probe()
854 ret = pm_runtime_resume_and_get(rga->dev); in rga_probe()
858 rga->version.major = (rga_read(rga, RGA_VERSION_INFO) >> 24) & 0xFF; in rga_probe()
859 rga->version.minor = (rga_read(rga, RGA_VERSION_INFO) >> 20) & 0x0F; in rga_probe()
861 v4l2_info(&rga->v4l2_dev, "HW Version: 0x%02x.%02x\n", in rga_probe()
862 rga->version.major, rga->version.minor); in rga_probe()
864 pm_runtime_put(rga->dev); in rga_probe()
867 rga->cmdbuf_virt = dma_alloc_attrs(rga->dev, RGA_CMDBUF_SIZE, in rga_probe()
868 &rga->cmdbuf_phy, GFP_KERNEL, in rga_probe()
870 if (!rga->cmdbuf_virt) { in rga_probe()
875 rga->src_mmu_pages = in rga_probe()
877 if (!rga->src_mmu_pages) { in rga_probe()
881 rga->dst_mmu_pages = in rga_probe()
883 if (!rga->dst_mmu_pages) { in rga_probe()
893 v4l2_err(&rga->v4l2_dev, "Failed to register video device\n"); in rga_probe()
897 v4l2_info(&rga->v4l2_dev, "Registered %s as /dev/%s\n", in rga_probe()
903 free_pages((unsigned long)rga->dst_mmu_pages, 3); in rga_probe()
905 free_pages((unsigned long)rga->src_mmu_pages, 3); in rga_probe()
907 dma_free_attrs(rga->dev, RGA_CMDBUF_SIZE, rga->cmdbuf_virt, in rga_probe()
908 rga->cmdbuf_phy, DMA_ATTR_WRITE_COMBINE); in rga_probe()
910 v4l2_m2m_release(rga->m2m_dev); in rga_probe()
914 v4l2_device_unregister(&rga->v4l2_dev); in rga_probe()
916 pm_runtime_disable(rga->dev); in rga_probe()
923 struct rockchip_rga *rga = platform_get_drvdata(pdev); in rga_remove() local
925 dma_free_attrs(rga->dev, RGA_CMDBUF_SIZE, rga->cmdbuf_virt, in rga_remove()
926 rga->cmdbuf_phy, DMA_ATTR_WRITE_COMBINE); in rga_remove()
928 free_pages((unsigned long)rga->src_mmu_pages, 3); in rga_remove()
929 free_pages((unsigned long)rga->dst_mmu_pages, 3); in rga_remove()
931 v4l2_info(&rga->v4l2_dev, "Removing\n"); in rga_remove()
933 v4l2_m2m_release(rga->m2m_dev); in rga_remove()
934 video_unregister_device(rga->vfd); in rga_remove()
935 v4l2_device_unregister(&rga->v4l2_dev); in rga_remove()
937 pm_runtime_disable(rga->dev); in rga_remove()
942 struct rockchip_rga *rga = dev_get_drvdata(dev); in rga_runtime_suspend() local
944 rga_disable_clocks(rga); in rga_runtime_suspend()
951 struct rockchip_rga *rga = dev_get_drvdata(dev); in rga_runtime_resume() local
953 return rga_enable_clocks(rga); in rga_runtime_resume()