Lines Matching +full:pk +full:- +full:pk

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Author: Ping-Hsun Wu <ping-hsun.wu@mediatek.com>
9 #include "mtk-mdp3-vpu.h"
10 #include "mtk-mdp3-core.h"
26 dev = scp_get_device(vpu->scp); in mdp_vpu_shared_mem_alloc()
28 if (!vpu->param) { in mdp_vpu_shared_mem_alloc()
29 vpu->param = dma_alloc_wc(dev, vpu->param_size, in mdp_vpu_shared_mem_alloc()
30 &vpu->param_addr, GFP_KERNEL); in mdp_vpu_shared_mem_alloc()
31 if (!vpu->param) in mdp_vpu_shared_mem_alloc()
35 if (!vpu->work) { in mdp_vpu_shared_mem_alloc()
36 vpu->work = dma_alloc_wc(dev, vpu->work_size, in mdp_vpu_shared_mem_alloc()
37 &vpu->work_addr, GFP_KERNEL); in mdp_vpu_shared_mem_alloc()
38 if (!vpu->work) in mdp_vpu_shared_mem_alloc()
42 if (!vpu->config) { in mdp_vpu_shared_mem_alloc()
43 vpu->config = dma_alloc_wc(dev, vpu->config_size, in mdp_vpu_shared_mem_alloc()
44 &vpu->config_addr, GFP_KERNEL); in mdp_vpu_shared_mem_alloc()
45 if (!vpu->config) in mdp_vpu_shared_mem_alloc()
52 dma_free_wc(dev, vpu->work_size, vpu->work, vpu->work_addr); in mdp_vpu_shared_mem_alloc()
53 vpu->work = NULL; in mdp_vpu_shared_mem_alloc()
55 dma_free_wc(dev, vpu->param_size, vpu->param, vpu->param_addr); in mdp_vpu_shared_mem_alloc()
56 vpu->param = NULL; in mdp_vpu_shared_mem_alloc()
58 return -ENOMEM; in mdp_vpu_shared_mem_alloc()
68 dev = scp_get_device(vpu->scp); in mdp_vpu_shared_mem_free()
70 if (vpu->param && vpu->param_addr) in mdp_vpu_shared_mem_free()
71 dma_free_wc(dev, vpu->param_size, vpu->param, vpu->param_addr); in mdp_vpu_shared_mem_free()
73 if (vpu->work && vpu->work_addr) in mdp_vpu_shared_mem_free()
74 dma_free_wc(dev, vpu->work_size, vpu->work, vpu->work_addr); in mdp_vpu_shared_mem_free()
76 if (vpu->config && vpu->config_addr) in mdp_vpu_shared_mem_free()
77 dma_free_wc(dev, vpu->config_size, vpu->config, vpu->config_addr); in mdp_vpu_shared_mem_free()
85 (struct mdp_vpu_dev *)(unsigned long)msg->drv_data; in mdp_vpu_ipi_handle_init_ack()
87 if (!vpu->work_size) in mdp_vpu_ipi_handle_init_ack()
88 vpu->work_size = msg->work_size; in mdp_vpu_ipi_handle_init_ack()
90 vpu->status = msg->status; in mdp_vpu_ipi_handle_init_ack()
91 complete(&vpu->ipi_acked); in mdp_vpu_ipi_handle_init_ack()
99 (struct mdp_vpu_dev *)(unsigned long)msg->drv_data; in mdp_vpu_ipi_handle_deinit_ack()
101 vpu->status = msg->status; in mdp_vpu_ipi_handle_deinit_ack()
102 complete(&vpu->ipi_acked); in mdp_vpu_ipi_handle_deinit_ack()
110 (struct img_ipi_frameparam *)(unsigned long)addr->va; in mdp_vpu_ipi_handle_frame_ack()
112 (struct mdp_vpu_dev *)(unsigned long)param->drv_data; in mdp_vpu_ipi_handle_frame_ack()
114 if (param->state) { in mdp_vpu_ipi_handle_frame_ack()
117 dev_err(&mdp->pdev->dev, "VPU MDP failure:%d\n", param->state); in mdp_vpu_ipi_handle_frame_ack()
119 vpu->status = param->state; in mdp_vpu_ipi_handle_frame_ack()
120 complete(&vpu->ipi_acked); in mdp_vpu_ipi_handle_frame_ack()
126 struct mtk_scp *scp = mdp->scp; in mdp_vpu_register()
127 struct device *dev = &mdp->pdev->dev; in mdp_vpu_register()
160 scp_ipi_unregister(mdp->scp, SCP_IPI_MDP_INIT); in mdp_vpu_unregister()
161 scp_ipi_unregister(mdp->scp, SCP_IPI_MDP_DEINIT); in mdp_vpu_unregister()
162 scp_ipi_unregister(mdp->scp, SCP_IPI_MDP_FRAME); in mdp_vpu_unregister()
172 if (!vpu->scp) { in mdp_vpu_sendmsg()
173 dev_dbg(&mdp->pdev->dev, "vpu scp is NULL"); in mdp_vpu_sendmsg()
174 return -EINVAL; in mdp_vpu_sendmsg()
176 ret = scp_ipi_send(vpu->scp, id, buf, len, 2000); in mdp_vpu_sendmsg()
179 dev_err(&mdp->pdev->dev, "scp_ipi_send failed %d\n", ret); in mdp_vpu_sendmsg()
180 return -EPERM; in mdp_vpu_sendmsg()
182 ret = wait_for_completion_timeout(&vpu->ipi_acked, in mdp_vpu_sendmsg()
185 ret = -ETIME; in mdp_vpu_sendmsg()
186 else if (vpu->status) in mdp_vpu_sendmsg()
187 ret = -EINVAL; in mdp_vpu_sendmsg()
201 u8 pp_num = mdp->mdp_data->pp_used; in mdp_vpu_dev_init()
203 init_completion(&vpu->ipi_acked); in mdp_vpu_dev_init()
204 vpu->scp = scp; in mdp_vpu_dev_init()
205 vpu->lock = lock; in mdp_vpu_dev_init()
206 vpu->work_size = 0; in mdp_vpu_dev_init()
212 mutex_lock(vpu->lock); in mdp_vpu_dev_init()
213 vpu->work_size = ALIGN(vpu->work_size, 64); in mdp_vpu_dev_init()
214 vpu->param_size = ALIGN(sizeof(struct img_ipi_frameparam), 64); in mdp_vpu_dev_init()
215 vpu->config_size = ALIGN(sizeof(struct img_config) * pp_num, 64); in mdp_vpu_dev_init()
217 mutex_unlock(vpu->lock); in mdp_vpu_dev_init()
219 dev_err(&mdp->pdev->dev, "VPU memory alloc fail!"); in mdp_vpu_dev_init()
223 dev_dbg(&mdp->pdev->dev, in mdp_vpu_dev_init()
224 "VPU param:%pK pa:%pad sz:%zx, work:%pK pa:%pad sz:%zx, config:%pK pa:%pad sz:%zx", in mdp_vpu_dev_init()
225 vpu->param, &vpu->param_addr, vpu->param_size, in mdp_vpu_dev_init()
226 vpu->work, &vpu->work_addr, vpu->work_size, in mdp_vpu_dev_init()
227 vpu->config, &vpu->config_addr, vpu->config_size); in mdp_vpu_dev_init()
229 msg.work_addr = vpu->work_addr; in mdp_vpu_dev_init()
230 msg.work_size = vpu->work_size; in mdp_vpu_dev_init()
238 switch (vpu->status) { in mdp_vpu_dev_init()
239 case -MDP_IPI_EBUSY: in mdp_vpu_dev_init()
240 err = -EBUSY; in mdp_vpu_dev_init()
242 case -MDP_IPI_ENOMEM: in mdp_vpu_dev_init()
243 err = -ENOSPC; /* -ENOMEM */ in mdp_vpu_dev_init()
255 .work_addr = vpu->work_addr, in mdp_vpu_dev_deinit()
266 mutex_lock(vpu->lock); in mdp_vpu_process()
268 dev_err(&mdp->pdev->dev, "VPU memory alloc fail!"); in mdp_vpu_process()
269 mutex_unlock(vpu->lock); in mdp_vpu_process()
270 return -ENOMEM; in mdp_vpu_process()
273 memset(vpu->param, 0, vpu->param_size); in mdp_vpu_process()
274 memset(vpu->work, 0, vpu->work_size); in mdp_vpu_process()
275 memset(vpu->config, 0, vpu->config_size); in mdp_vpu_process()
277 param->self_data.va = (unsigned long)vpu->work; in mdp_vpu_process()
278 param->self_data.pa = vpu->work_addr; in mdp_vpu_process()
279 param->config_data.va = (unsigned long)vpu->config; in mdp_vpu_process()
280 param->config_data.pa = vpu->config_addr; in mdp_vpu_process()
281 param->drv_data = (unsigned long)vpu; in mdp_vpu_process()
282 memcpy(vpu->param, param, sizeof(*param)); in mdp_vpu_process()
284 addr.pa = vpu->param_addr; in mdp_vpu_process()
285 addr.va = (unsigned long)vpu->param; in mdp_vpu_process()
286 mutex_unlock(vpu->lock); in mdp_vpu_process()