Lines Matching refs:enc

806 	struct rkvenc_dev *enc = to_rkvenc_dev(mpp);  in rkvenc2_set_rcbbuf()  local
812 if (priv && enc->sram_iova) { in rkvenc2_set_rcbbuf()
823 if (rcb_offset > enc->sram_size || in rkvenc2_set_rcbbuf()
824 (rcb_offset + rcb_size) > enc->sram_used) in rkvenc2_set_rcbbuf()
832 *reg = enc->sram_iova + rcb_offset; in rkvenc2_set_rcbbuf()
838 if (enc->sram_enabled != sram_enabled) { in rkvenc2_set_rcbbuf()
840 enc->sram_enabled = sram_enabled; in rkvenc2_set_rcbbuf()
1036 static void rkvenc2_patch_dchs(struct rkvenc_dev *enc, struct rkvenc_task *task) in rkvenc2_patch_dchs() argument
1042 int core_id = enc->mpp.core_id; in rkvenc2_patch_dchs()
1046 if (!enc->ccu) in rkvenc2_patch_dchs()
1050 dev_err(enc->mpp.dev, "invalid core id %d max %d\n", in rkvenc2_patch_dchs()
1055 ccu = enc->ccu; in rkvenc2_patch_dchs()
1154 static void rkvenc2_update_dchs(struct rkvenc_dev *enc, struct rkvenc_task *task) in rkvenc2_update_dchs() argument
1156 struct rkvenc_ccu *ccu = enc->ccu; in rkvenc2_update_dchs()
1157 int core_id = enc->mpp.core_id; in rkvenc2_update_dchs()
1164 dev_err(enc->mpp.dev, "invalid core id %d max %d\n", in rkvenc2_update_dchs()
1193 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_run() local
1195 struct rkvenc_hw_info *hw = enc->hw_info; in rkvenc_run()
1208 rkvenc2_patch_dchs(enc, task); in rkvenc_run()
1227 if (off == enc->hw_info->enc_start_base) { in rkvenc_run()
1237 mpp_read_relaxed(&enc->mpp, DCHS_REG_OFFSET)); in rkvenc_run()
1250 mpp_write(mpp, enc->hw_info->enc_start_base, start_val); in rkvenc_run()
1297 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_irq() local
1298 struct rkvenc_hw_info *hw = enc->hw_info; in rkvenc_irq()
1326 if (enc->bs_overflow) { in rkvenc_irq()
1328 enc->bs_overflow = 0; in rkvenc_irq()
1356 enc->bs_overflow = 1; in rkvenc_irq()
1385 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_isr() local
1407 rkvenc2_update_dchs(enc, task); in rkvenc_isr()
1412 if (task->irq_status & enc->hw_info->err_mask) { in rkvenc_isr()
1587 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_procfs_remove() local
1589 if (enc->procfs) { in rkvenc_procfs_remove()
1590 proc_remove(enc->procfs); in rkvenc_procfs_remove()
1591 enc->procfs = NULL; in rkvenc_procfs_remove()
1664 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_procfs_init() local
1674 enc->procfs = proc_mkdir(name, mpp->srv->procfs); in rkvenc_procfs_init()
1675 if (IS_ERR_OR_NULL(enc->procfs)) { in rkvenc_procfs_init()
1677 enc->procfs = NULL; in rkvenc_procfs_init()
1682 mpp_procfs_create_common(enc->procfs, mpp); in rkvenc_procfs_init()
1686 enc->procfs, &enc->aclk_info.debug_rate_hz); in rkvenc_procfs_init()
1688 enc->procfs, &enc->core_clk_info.debug_rate_hz); in rkvenc_procfs_init()
1690 enc->procfs, &mpp->session_max_buffers); in rkvenc_procfs_init()
1693 enc->procfs, rkvenc_show_session_info, mpp); in rkvenc_procfs_init()
1700 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_procfs_ccu_init() local
1702 if (!enc->procfs) in rkvenc_procfs_ccu_init()
1767 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_devfreq_init() local
1768 struct clk *clk_core = enc->core_clk_info.clk; in rkvenc_devfreq_init()
1793 rockchip_get_opp_data(rockchip_rkvenc_of_match, &enc->opp_info); in rkvenc_devfreq_init()
1794 ret = rockchip_init_opp_table(dev, &enc->opp_info, "leakage", "venc"); in rkvenc_devfreq_init()
1800 enc->mdev_info = rockchip_system_monitor_register(dev, &venc_mdevp); in rkvenc_devfreq_init()
1801 if (IS_ERR(enc->mdev_info)) { in rkvenc_devfreq_init()
1803 enc->mdev_info = NULL; in rkvenc_devfreq_init()
1811 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_devfreq_remove() local
1813 if (enc->mdev_info) in rkvenc_devfreq_remove()
1814 rockchip_system_monitor_unregister(enc->mdev_info); in rkvenc_devfreq_remove()
1822 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_init() local
1828 ret = mpp_get_clk_info(mpp, &enc->aclk_info, "aclk_vcodec"); in rkvenc_init()
1831 ret = mpp_get_clk_info(mpp, &enc->hclk_info, "hclk_vcodec"); in rkvenc_init()
1834 ret = mpp_get_clk_info(mpp, &enc->core_clk_info, "clk_core"); in rkvenc_init()
1840 &enc->default_max_load); in rkvenc_init()
1842 mpp_set_clk_info_rate_hz(&enc->aclk_info, CLK_MODE_DEFAULT, 300 * MHZ); in rkvenc_init()
1843 mpp_set_clk_info_rate_hz(&enc->core_clk_info, CLK_MODE_DEFAULT, 600 * MHZ); in rkvenc_init()
1846 enc->rst_a = mpp_reset_control_get(mpp, RST_TYPE_A, "video_a"); in rkvenc_init()
1847 if (!enc->rst_a) in rkvenc_init()
1849 enc->rst_h = mpp_reset_control_get(mpp, RST_TYPE_H, "video_h"); in rkvenc_init()
1850 if (!enc->rst_h) in rkvenc_init()
1852 enc->rst_core = mpp_reset_control_get(mpp, RST_TYPE_CORE, "video_core"); in rkvenc_init()
1853 if (!enc->rst_core) in rkvenc_init()
1876 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_soft_reset() local
1877 struct rkvenc_hw_info *hw = enc->hw_info; in rkvenc_soft_reset()
1897 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_reset() local
1907 if (ret && enc->rst_a && enc->rst_h && enc->rst_core) { in rkvenc_reset()
1910 mpp_safe_reset(enc->rst_a); in rkvenc_reset()
1911 mpp_safe_reset(enc->rst_h); in rkvenc_reset()
1912 mpp_safe_reset(enc->rst_core); in rkvenc_reset()
1914 mpp_safe_unreset(enc->rst_a); in rkvenc_reset()
1915 mpp_safe_unreset(enc->rst_h); in rkvenc_reset()
1916 mpp_safe_unreset(enc->rst_core); in rkvenc_reset()
1921 if (enc->ccu) in rkvenc_reset()
1922 enc->ccu->dchs[mpp->core_id].val = 0; in rkvenc_reset()
1933 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_clk_on() local
1935 mpp_clk_safe_enable(enc->aclk_info.clk); in rkvenc_clk_on()
1936 mpp_clk_safe_enable(enc->hclk_info.clk); in rkvenc_clk_on()
1937 mpp_clk_safe_enable(enc->core_clk_info.clk); in rkvenc_clk_on()
1944 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_clk_off() local
1946 clk_disable_unprepare(enc->aclk_info.clk); in rkvenc_clk_off()
1947 clk_disable_unprepare(enc->hclk_info.clk); in rkvenc_clk_off()
1948 clk_disable_unprepare(enc->core_clk_info.clk); in rkvenc_clk_off()
1955 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_set_freq() local
1958 mpp_clk_set_rate(&enc->aclk_info, task->clk_mode); in rkvenc_set_freq()
1959 mpp_clk_set_rate(&enc->core_clk_info, task->clk_mode); in rkvenc_set_freq()
2250 static int rkvenc_attach_ccu(struct device *dev, struct rkvenc_dev *enc) in rkvenc_attach_ccu() argument
2271 INIT_LIST_HEAD(&enc->core_link); in rkvenc_attach_ccu()
2274 list_add_tail(&enc->core_link, &ccu->core_list); in rkvenc_attach_ccu()
2283 ccu->main_core = &enc->mpp; in rkvenc_attach_ccu()
2289 cur_info = enc->mpp.iommu_info; in rkvenc_attach_ccu()
2299 enc->mpp.msgs_cap = 0; in rkvenc_attach_ccu()
2301 enc->ccu = ccu; in rkvenc_attach_ccu()
2303 dev_info(dev, "attach ccu as core %d\n", enc->mpp.core_id); in rkvenc_attach_ccu()
2309 static int rkvenc2_alloc_rcbbuf(struct platform_device *pdev, struct rkvenc_dev *enc) in rkvenc2_alloc_rcbbuf() argument
2362 domain = enc->mpp.iommu_info->domain; in rkvenc2_alloc_rcbbuf()
2387 enc->rcb_page = page; in rkvenc2_alloc_rcbbuf()
2390 enc->sram_size = sram_size; in rkvenc2_alloc_rcbbuf()
2391 enc->sram_used = sram_used; in rkvenc2_alloc_rcbbuf()
2392 enc->sram_iova = iova; in rkvenc2_alloc_rcbbuf()
2393 enc->sram_enabled = -1; in rkvenc2_alloc_rcbbuf()
2395 dev_info(dev, "sram_iova %pad\n", &enc->sram_iova); in rkvenc2_alloc_rcbbuf()
2396 dev_info(dev, "sram_size %u\n", enc->sram_size); in rkvenc2_alloc_rcbbuf()
2397 dev_info(dev, "sram_used %u\n", enc->sram_used); in rkvenc2_alloc_rcbbuf()
2412 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc2_iommu_fault_handle() local
2416 mpp->core_id, mpp_read_relaxed(&enc->mpp, DCHS_REG_OFFSET)); in rkvenc2_iommu_fault_handle()
2428 struct rkvenc_dev *enc = NULL; in rkvenc_core_probe() local
2431 enc = devm_kzalloc(dev, sizeof(*enc), GFP_KERNEL); in rkvenc_core_probe()
2432 if (!enc) in rkvenc_core_probe()
2435 mpp = &enc->mpp; in rkvenc_core_probe()
2454 ret = rkvenc_attach_ccu(dev, enc); in rkvenc_core_probe()
2459 rkvenc2_alloc_rcbbuf(pdev, enc); in rkvenc_core_probe()
2471 enc->hw_info = to_rkvenc_info(mpp->var->hw_info); in rkvenc_core_probe()
2478 if (mpp == enc->ccu->main_core) in rkvenc_core_probe()
2488 struct rkvenc_dev *enc = NULL; in rkvenc_probe_default() local
2492 enc = devm_kzalloc(dev, sizeof(*enc), GFP_KERNEL); in rkvenc_probe_default()
2493 if (!enc) in rkvenc_probe_default()
2496 mpp = &enc->mpp; in rkvenc_probe_default()
2509 rkvenc2_alloc_rcbbuf(pdev, enc); in rkvenc_probe_default()
2521 enc->hw_info = to_rkvenc_info(mpp->var->hw_info); in rkvenc_probe_default()
2553 static int rkvenc2_free_rcbbuf(struct platform_device *pdev, struct rkvenc_dev *enc) in rkvenc2_free_rcbbuf() argument
2557 if (enc->rcb_page) { in rkvenc2_free_rcbbuf()
2558 size_t page_size = PAGE_ALIGN(enc->sram_used - enc->sram_size); in rkvenc2_free_rcbbuf()
2561 __free_pages(enc->rcb_page, order); in rkvenc2_free_rcbbuf()
2563 if (enc->sram_iova) { in rkvenc2_free_rcbbuf()
2564 domain = enc->mpp.iommu_info->domain; in rkvenc2_free_rcbbuf()
2565 iommu_unmap(domain, enc->sram_iova, enc->sram_used); in rkvenc2_free_rcbbuf()
2580 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_remove() local
2583 if (enc->ccu) { in rkvenc_remove()
2584 mutex_lock(&enc->ccu->lock); in rkvenc_remove()
2585 list_del_init(&enc->core_link); in rkvenc_remove()
2586 enc->ccu->core_num--; in rkvenc_remove()
2587 mutex_unlock(&enc->ccu->lock); in rkvenc_remove()
2589 rkvenc2_free_rcbbuf(pdev, enc); in rkvenc_remove()
2590 mpp_dev_remove(&enc->mpp); in rkvenc_remove()
2591 rkvenc_procfs_remove(&enc->mpp); in rkvenc_remove()
2594 struct rkvenc_dev *enc = to_rkvenc_dev(mpp); in rkvenc_remove() local
2597 rkvenc2_free_rcbbuf(pdev, enc); in rkvenc_remove()