Lines Matching full:rga
28 #include "rga-hw.h"
29 #include "rga.h"
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()
50 rga_hw_start(rga, vb_to_rga(src), vb_to_rga(dst)); in device_run()
52 spin_unlock_irqrestore(&rga->ctrl_lock, flags); in device_run()
57 struct rockchip_rga *rga = prv; in rga_isr() local
60 intr = rga_read(rga, RGA_INT) & 0xf; in rga_isr()
62 rga_mod(rga, RGA_INT, intr << 4, 0xf << 4); in rga_isr()
66 struct rga_ctx *ctx = rga->curr; in rga_isr()
70 rga->curr = NULL; in rga_isr()
84 v4l2_m2m_job_finish(rga->m2m_dev, ctx->fh.m2m_ctx); in rga_isr()
108 src_vq->lock = &ctx->rga->mutex; in queue_init()
109 src_vq->dev = ctx->rga->v4l2_dev.dev; in queue_init()
123 dst_vq->lock = &ctx->rga->mutex; in queue_init()
124 dst_vq->dev = ctx->rga->v4l2_dev.dev; in queue_init()
135 spin_lock_irqsave(&ctx->rga->ctrl_lock, flags); in rga_s_ctrl()
150 spin_unlock_irqrestore(&ctx->rga->ctrl_lock, flags); in rga_s_ctrl()
160 struct rockchip_rga *rga = ctx->rga; in rga_setup_ctrls() local
179 v4l2_err(&rga->v4l2_dev, "%s failed\n", __func__); in rga_setup_ctrls()
369 struct rockchip_rga *rga = video_drvdata(file); in rga_open() local
376 ctx->rga = rga; in rga_open()
386 if (mutex_lock_interruptible(&rga->mutex)) { in rga_open()
390 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(rga->m2m_dev, ctx, &queue_init); in rga_open()
393 mutex_unlock(&rga->mutex); in rga_open()
407 mutex_unlock(&rga->mutex); in rga_open()
416 struct rockchip_rga *rga = ctx->rga; in rga_release() local
418 mutex_lock(&rga->mutex); in rga_release()
427 mutex_unlock(&rga->mutex); in rga_release()
445 strscpy(cap->card, "rockchip-rga", sizeof(cap->card)); in vidioc_querycap()
446 strscpy(cap->bus_info, "platform:rga", sizeof(cap->bus_info)); in vidioc_querycap()
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()
547 v4l2_dbg(debug, 1, &rga->v4l2_dev, in vidioc_s_fmt()
554 v4l2_dbg(debug, 1, &rga->v4l2_dev, in vidioc_s_fmt()
615 struct rockchip_rga *rga = ctx->rga; in vidioc_s_selection() local
649 v4l2_dbg(debug, 1, &rga->v4l2_dev, in vidioc_s_selection()
657 v4l2_dbg(debug, 1, &rga->v4l2_dev, "unsupported crop value.\n"); in vidioc_s_selection()
698 .name = "rockchip-rga",
707 static int rga_enable_clocks(struct rockchip_rga *rga) in rga_enable_clocks() argument
711 ret = clk_prepare_enable(rga->sclk); in rga_enable_clocks()
713 dev_err(rga->dev, "Cannot enable rga sclk: %d\n", ret); in rga_enable_clocks()
717 ret = clk_prepare_enable(rga->aclk); in rga_enable_clocks()
719 dev_err(rga->dev, "Cannot enable rga aclk: %d\n", ret); in rga_enable_clocks()
723 ret = clk_prepare_enable(rga->hclk); in rga_enable_clocks()
725 dev_err(rga->dev, "Cannot enable rga hclk: %d\n", ret); in rga_enable_clocks()
732 clk_disable_unprepare(rga->aclk); in rga_enable_clocks()
734 clk_disable_unprepare(rga->sclk); in rga_enable_clocks()
739 static void rga_disable_clocks(struct rockchip_rga *rga) in rga_disable_clocks() argument
741 clk_disable_unprepare(rga->sclk); in rga_disable_clocks()
742 clk_disable_unprepare(rga->hclk); in rga_disable_clocks()
743 clk_disable_unprepare(rga->aclk); in rga_disable_clocks()
746 static int rga_parse_dt(struct rockchip_rga *rga) in rga_parse_dt() argument
750 core_rst = devm_reset_control_get(rga->dev, "core"); in rga_parse_dt()
752 dev_err(rga->dev, "failed to get core reset controller\n"); in rga_parse_dt()
756 axi_rst = devm_reset_control_get(rga->dev, "axi"); in rga_parse_dt()
758 dev_err(rga->dev, "failed to get axi reset controller\n"); in rga_parse_dt()
762 ahb_rst = devm_reset_control_get(rga->dev, "ahb"); in rga_parse_dt()
764 dev_err(rga->dev, "failed to get ahb reset controller\n"); in rga_parse_dt()
780 rga->sclk = devm_clk_get(rga->dev, "sclk"); in rga_parse_dt()
781 if (IS_ERR(rga->sclk)) { in rga_parse_dt()
782 dev_err(rga->dev, "failed to get sclk clock\n"); in rga_parse_dt()
783 return PTR_ERR(rga->sclk); in rga_parse_dt()
786 rga->aclk = devm_clk_get(rga->dev, "aclk"); in rga_parse_dt()
787 if (IS_ERR(rga->aclk)) { in rga_parse_dt()
788 dev_err(rga->dev, "failed to get aclk clock\n"); in rga_parse_dt()
789 return PTR_ERR(rga->aclk); in rga_parse_dt()
792 rga->hclk = devm_clk_get(rga->dev, "hclk"); in rga_parse_dt()
793 if (IS_ERR(rga->hclk)) { in rga_parse_dt()
794 dev_err(rga->dev, "failed to get hclk clock\n"); in rga_parse_dt()
795 return PTR_ERR(rga->hclk); in rga_parse_dt()
803 struct rockchip_rga *rga; in rga_probe() local
811 rga = devm_kzalloc(&pdev->dev, sizeof(*rga), GFP_KERNEL); in rga_probe()
812 if (!rga) in rga_probe()
815 rga->dev = &pdev->dev; in rga_probe()
816 spin_lock_init(&rga->ctrl_lock); in rga_probe()
817 mutex_init(&rga->mutex); in rga_probe()
819 ret = rga_parse_dt(rga); in rga_probe()
823 pm_runtime_enable(rga->dev); in rga_probe()
825 rga->regs = devm_platform_ioremap_resource(pdev, 0); in rga_probe()
826 if (IS_ERR(rga->regs)) { in rga_probe()
827 ret = PTR_ERR(rga->regs); in rga_probe()
837 ret = devm_request_irq(rga->dev, irq, rga_isr, 0, in rga_probe()
838 dev_name(rga->dev), rga); in rga_probe()
840 dev_err(rga->dev, "failed to request irq\n"); in rga_probe()
844 ret = dma_set_mask_and_coherent(rga->dev, DMA_BIT_MASK(32)); in rga_probe()
846 dev_err(rga->dev, "32-bit DMA not supported"); in rga_probe()
850 ret = v4l2_device_register(&pdev->dev, &rga->v4l2_dev); in rga_probe()
855 v4l2_err(&rga->v4l2_dev, "Failed to allocate video device\n"); in rga_probe()
860 vfd->lock = &rga->mutex; in rga_probe()
861 vfd->v4l2_dev = &rga->v4l2_dev; in rga_probe()
863 video_set_drvdata(vfd, rga); in rga_probe()
864 rga->vfd = vfd; in rga_probe()
866 platform_set_drvdata(pdev, rga); in rga_probe()
867 rga->m2m_dev = v4l2_m2m_init(&rga_m2m_ops); in rga_probe()
868 if (IS_ERR(rga->m2m_dev)) { in rga_probe()
869 v4l2_err(&rga->v4l2_dev, "Failed to init mem2mem device\n"); in rga_probe()
870 ret = PTR_ERR(rga->m2m_dev); in rga_probe()
874 ret = pm_runtime_resume_and_get(rga->dev); in rga_probe()
878 rga->version.major = (rga_read(rga, RGA_VERSION_INFO) >> 24) & 0xFF; in rga_probe()
879 rga->version.minor = (rga_read(rga, RGA_VERSION_INFO) >> 20) & 0x0F; in rga_probe()
881 v4l2_info(&rga->v4l2_dev, "HW Version: 0x%02x.%02x\n", in rga_probe()
882 rga->version.major, rga->version.minor); in rga_probe()
884 pm_runtime_put(rga->dev); in rga_probe()
887 rga->cmdbuf_virt = dma_alloc_attrs(rga->dev, RGA_CMDBUF_SIZE, in rga_probe()
888 &rga->cmdbuf_phy, GFP_KERNEL, in rga_probe()
890 if (!rga->cmdbuf_virt) { in rga_probe()
900 v4l2_err(&rga->v4l2_dev, "Failed to register video device\n"); in rga_probe()
904 v4l2_info(&rga->v4l2_dev, "Registered %s as /dev/%s\n", in rga_probe()
910 dma_free_attrs(rga->dev, RGA_CMDBUF_SIZE, rga->cmdbuf_virt, in rga_probe()
911 rga->cmdbuf_phy, DMA_ATTR_WRITE_COMBINE); in rga_probe()
913 v4l2_m2m_release(rga->m2m_dev); in rga_probe()
917 v4l2_device_unregister(&rga->v4l2_dev); in rga_probe()
919 pm_runtime_disable(rga->dev); in rga_probe()
926 struct rockchip_rga *rga = platform_get_drvdata(pdev); in rga_remove() local
928 dma_free_attrs(rga->dev, RGA_CMDBUF_SIZE, rga->cmdbuf_virt, in rga_remove()
929 rga->cmdbuf_phy, DMA_ATTR_WRITE_COMBINE); 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()
963 .compatible = "rockchip,rk3288-rga",
966 .compatible = "rockchip,rk3399-rga",