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()
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()
86 v4l2_m2m_job_finish(rga->m2m_dev, ctx->fh.m2m_ctx); in rga_isr()
109 src_vq->lock = &ctx->rga->mutex; in queue_init()
110 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()
372 struct rockchip_rga *rga = video_drvdata(file); in rga_open() local
379 ctx->rga = rga; in rga_open()
384 if (mutex_lock_interruptible(&rga->mutex)) { in rga_open()
388 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(rga->m2m_dev, ctx, &queue_init); in rga_open()
391 mutex_unlock(&rga->mutex); in rga_open()
405 mutex_unlock(&rga->mutex); in rga_open()
414 struct rockchip_rga *rga = ctx->rga; in rga_release() local
416 mutex_lock(&rga->mutex); in rga_release()
425 mutex_unlock(&rga->mutex); in rga_release()
443 strscpy(cap->card, "rockchip-rga", sizeof(cap->card)); in vidioc_querycap()
444 strscpy(cap->bus_info, "platform:rga", sizeof(cap->bus_info)); in vidioc_querycap()
522 struct rockchip_rga *rga = ctx->rga; in vidioc_s_fmt() local
536 v4l2_err(&rga->v4l2_dev, "queue (%d) bust\n", f->type); in vidioc_s_fmt()
613 struct rockchip_rga *rga = ctx->rga; in vidioc_s_selection() local
647 v4l2_dbg(debug, 1, &rga->v4l2_dev, in vidioc_s_selection()
655 v4l2_dbg(debug, 1, &rga->v4l2_dev, "unsupported crop value.\n"); in vidioc_s_selection()
696 .name = "rockchip-rga",
705 static int rga_enable_clocks(struct rockchip_rga *rga) in rga_enable_clocks() argument
709 ret = clk_prepare_enable(rga->sclk); in rga_enable_clocks()
711 dev_err(rga->dev, "Cannot enable rga sclk: %d\n", ret); in rga_enable_clocks()
715 ret = clk_prepare_enable(rga->aclk); in rga_enable_clocks()
717 dev_err(rga->dev, "Cannot enable rga aclk: %d\n", ret); in rga_enable_clocks()
721 ret = clk_prepare_enable(rga->hclk); in rga_enable_clocks()
723 dev_err(rga->dev, "Cannot enable rga hclk: %d\n", ret); in rga_enable_clocks()
730 clk_disable_unprepare(rga->sclk); in rga_enable_clocks()
732 clk_disable_unprepare(rga->aclk); in rga_enable_clocks()
737 static void rga_disable_clocks(struct rockchip_rga *rga) in rga_disable_clocks() argument
739 clk_disable_unprepare(rga->sclk); in rga_disable_clocks()
740 clk_disable_unprepare(rga->hclk); in rga_disable_clocks()
741 clk_disable_unprepare(rga->aclk); in rga_disable_clocks()
744 static int rga_parse_dt(struct rockchip_rga *rga) in rga_parse_dt() argument
748 core_rst = devm_reset_control_get(rga->dev, "core"); in rga_parse_dt()
750 dev_err(rga->dev, "failed to get core reset controller\n"); in rga_parse_dt()
754 axi_rst = devm_reset_control_get(rga->dev, "axi"); in rga_parse_dt()
756 dev_err(rga->dev, "failed to get axi reset controller\n"); in rga_parse_dt()
760 ahb_rst = devm_reset_control_get(rga->dev, "ahb"); in rga_parse_dt()
762 dev_err(rga->dev, "failed to get ahb reset controller\n"); in rga_parse_dt()
778 rga->sclk = devm_clk_get(rga->dev, "sclk"); in rga_parse_dt()
779 if (IS_ERR(rga->sclk)) { in rga_parse_dt()
780 dev_err(rga->dev, "failed to get sclk clock\n"); in rga_parse_dt()
781 return PTR_ERR(rga->sclk); in rga_parse_dt()
784 rga->aclk = devm_clk_get(rga->dev, "aclk"); in rga_parse_dt()
785 if (IS_ERR(rga->aclk)) { in rga_parse_dt()
786 dev_err(rga->dev, "failed to get aclk clock\n"); in rga_parse_dt()
787 return PTR_ERR(rga->aclk); in rga_parse_dt()
790 rga->hclk = devm_clk_get(rga->dev, "hclk"); in rga_parse_dt()
791 if (IS_ERR(rga->hclk)) { in rga_parse_dt()
792 dev_err(rga->dev, "failed to get hclk clock\n"); in rga_parse_dt()
793 return PTR_ERR(rga->hclk); in rga_parse_dt()
801 struct rockchip_rga *rga; in rga_probe() local
810 rga = devm_kzalloc(&pdev->dev, sizeof(*rga), GFP_KERNEL); in rga_probe()
811 if (!rga) in rga_probe()
814 rga->dev = &pdev->dev; in rga_probe()
815 spin_lock_init(&rga->ctrl_lock); in rga_probe()
816 mutex_init(&rga->mutex); in rga_probe()
818 ret = rga_parse_dt(rga); in rga_probe()
822 pm_runtime_enable(rga->dev); in rga_probe()
826 rga->regs = devm_ioremap_resource(rga->dev, res); in rga_probe()
827 if (IS_ERR(rga->regs)) { in rga_probe()
828 ret = PTR_ERR(rga->regs); in rga_probe()
838 ret = devm_request_irq(rga->dev, irq, rga_isr, 0, in rga_probe()
839 dev_name(rga->dev), rga); in rga_probe()
841 dev_err(rga->dev, "failed to request irq\n"); in rga_probe()
845 ret = v4l2_device_register(&pdev->dev, &rga->v4l2_dev); in rga_probe()
850 v4l2_err(&rga->v4l2_dev, "Failed to allocate video device\n"); in rga_probe()
855 vfd->lock = &rga->mutex; in rga_probe()
856 vfd->v4l2_dev = &rga->v4l2_dev; in rga_probe()
858 video_set_drvdata(vfd, rga); in rga_probe()
859 rga->vfd = vfd; in rga_probe()
861 platform_set_drvdata(pdev, rga); in rga_probe()
862 rga->m2m_dev = v4l2_m2m_init(&rga_m2m_ops); in rga_probe()
863 if (IS_ERR(rga->m2m_dev)) { in rga_probe()
864 v4l2_err(&rga->v4l2_dev, "Failed to init mem2mem device\n"); in rga_probe()
865 ret = PTR_ERR(rga->m2m_dev); in rga_probe()
869 pm_runtime_get_sync(rga->dev); in rga_probe()
871 rga->version.major = (rga_read(rga, RGA_VERSION_INFO) >> 24) & 0xFF; in rga_probe()
872 rga->version.minor = (rga_read(rga, RGA_VERSION_INFO) >> 20) & 0x0F; in rga_probe()
874 v4l2_info(&rga->v4l2_dev, "HW Version: 0x%02x.%02x\n", in rga_probe()
875 rga->version.major, rga->version.minor); in rga_probe()
877 pm_runtime_put(rga->dev); in rga_probe()
880 rga->cmdbuf_virt = dma_alloc_attrs(rga->dev, RGA_CMDBUF_SIZE, in rga_probe()
881 &rga->cmdbuf_phy, GFP_KERNEL, in rga_probe()
884 rga->src_mmu_pages = in rga_probe()
886 rga->dst_mmu_pages = in rga_probe()
894 v4l2_err(&rga->v4l2_dev, "Failed to register video device\n"); in rga_probe()
898 v4l2_info(&rga->v4l2_dev, "Registered %s as /dev/%s\n", in rga_probe()
906 video_unregister_device(rga->vfd); in rga_probe()
908 v4l2_device_unregister(&rga->v4l2_dev); in rga_probe()
910 pm_runtime_disable(rga->dev); in rga_probe()
917 struct rockchip_rga *rga = platform_get_drvdata(pdev); in rga_remove() local
919 dma_free_attrs(rga->dev, RGA_CMDBUF_SIZE, rga->cmdbuf_virt, in rga_remove()
920 rga->cmdbuf_phy, DMA_ATTR_WRITE_COMBINE); in rga_remove()
922 free_pages((unsigned long)rga->src_mmu_pages, 3); in rga_remove()
923 free_pages((unsigned long)rga->dst_mmu_pages, 3); in rga_remove()
925 v4l2_info(&rga->v4l2_dev, "Removing\n"); in rga_remove()
927 v4l2_m2m_release(rga->m2m_dev); in rga_remove()
928 video_unregister_device(rga->vfd); in rga_remove()
929 v4l2_device_unregister(&rga->v4l2_dev); in rga_remove()
931 pm_runtime_disable(rga->dev); in rga_remove()
938 struct rockchip_rga *rga = dev_get_drvdata(dev); in rga_runtime_suspend() local
940 rga_disable_clocks(rga); in rga_runtime_suspend()
947 struct rockchip_rga *rga = dev_get_drvdata(dev); in rga_runtime_resume() local
949 return rga_enable_clocks(rga); in rga_runtime_resume()
959 .compatible = "rockchip,rk3288-rga",
962 .compatible = "rockchip,rk3399-rga",