Lines Matching +full:sub +full:- +full:components

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Author: Ping-Hsun Wu <ping-hsun.wu@mediatek.com>
9 #include "mtk-mdp3-cmdq.h"
10 #include "mtk-mdp3-comp.h"
11 #include "mtk-mdp3-core.h"
12 #include "mtk-mdp3-m2m.h"
27 ((ctx)->comp->ops && (ctx)->comp->ops->op)
29 (has_op(ctx, op) ? (ctx)->comp->ops->op(ctx, ##__VA_ARGS__) : 0)
33 return (count < param->num_subfrms) ? in is_output_disabled()
34 (param->frame.output_disable || in is_output_disabled()
35 param->subfrms[count].tile_disable) : in is_output_disabled()
43 const struct img_config *config = path->config; in mdp_path_subfrm_require()
45 const struct mtk_mdp_driver_data *data = path->mdp_dev->mdp_data; in mdp_path_subfrm_require()
46 struct device *dev = &path->mdp_dev->pdev->dev; in mdp_path_subfrm_require()
47 struct mtk_mutex **mutex = path->mdp_dev->mdp_mutex; in mdp_path_subfrm_require()
51 switch (path->comps[0].comp->id) { in mdp_path_subfrm_require()
66 return -EINVAL; in mdp_path_subfrm_require()
70 for (index = 0; index < config->num_components; index++) { in mdp_path_subfrm_require()
71 ctx = &path->comps[index]; in mdp_path_subfrm_require()
72 if (is_output_disabled(ctx->param, count)) in mdp_path_subfrm_require()
74 id = ctx->comp->id; in mdp_path_subfrm_require()
76 data->mdp_mutex_table_idx[id], false); in mdp_path_subfrm_require()
89 const struct img_config *config = path->config; in mdp_path_subfrm_run()
91 struct device *dev = &path->mdp_dev->pdev->dev; in mdp_path_subfrm_run()
92 struct mtk_mutex **mutex = path->mdp_dev->mdp_mutex; in mdp_path_subfrm_run()
96 if (-1 == *mutex_id) { in mdp_path_subfrm_run()
98 return -EINVAL; in mdp_path_subfrm_run()
103 for (index = 0; index < config->num_components; index++) { in mdp_path_subfrm_run()
104 ctx = &path->comps[index]; in mdp_path_subfrm_run()
105 if (is_output_disabled(ctx->param, count)) in mdp_path_subfrm_run()
107 event = ctx->comp->gce_event[MDP_GCE_EVENT_SOF]; in mdp_path_subfrm_run()
113 mtk_mutex_enable_by_cmdq(mutex[*mutex_id], (void *)&cmd->pkt); in mdp_path_subfrm_run()
116 for (index = 0; index < config->num_components; index++) { in mdp_path_subfrm_run()
117 ctx = &path->comps[index]; in mdp_path_subfrm_run()
118 if (is_output_disabled(ctx->param, count)) in mdp_path_subfrm_run()
120 event = ctx->comp->gce_event[MDP_GCE_EVENT_SOF]; in mdp_path_subfrm_run()
130 const struct img_config *config = path->config; in mdp_path_ctx_init()
133 if (config->num_components < 1) in mdp_path_ctx_init()
134 return -EINVAL; in mdp_path_ctx_init()
136 for (index = 0; index < config->num_components; index++) { in mdp_path_ctx_init()
137 ret = mdp_comp_ctx_config(mdp, &path->comps[index], in mdp_path_ctx_init()
138 &config->components[index], in mdp_path_ctx_init()
139 path->param); in mdp_path_ctx_init()
150 const struct img_config *config = path->config; in mdp_path_config_subfrm()
151 const struct img_mmsys_ctrl *ctrl = &config->ctrls[count]; in mdp_path_config_subfrm()
157 /* Acquire components */ in mdp_path_config_subfrm()
162 for (index = 0; index < ctrl->num_sets; index++) { in mdp_path_config_subfrm()
163 set = &ctrl->sets[index]; in mdp_path_config_subfrm()
164 cmdq_pkt_write_mask(&cmd->pkt, set->subsys_id, set->reg, in mdp_path_config_subfrm()
165 set->value, 0xFFFFFFFF); in mdp_path_config_subfrm()
167 /* Config sub-frame information */ in mdp_path_config_subfrm()
168 for (index = (config->num_components - 1); index >= 0; index--) { in mdp_path_config_subfrm()
169 ctx = &path->comps[index]; in mdp_path_config_subfrm()
170 if (is_output_disabled(ctx->param, count)) in mdp_path_config_subfrm()
176 /* Run components */ in mdp_path_config_subfrm()
180 /* Wait components done */ in mdp_path_config_subfrm()
181 for (index = 0; index < config->num_components; index++) { in mdp_path_config_subfrm()
182 ctx = &path->comps[index]; in mdp_path_config_subfrm()
183 if (is_output_disabled(ctx->param, count)) in mdp_path_config_subfrm()
189 /* Advance to the next sub-frame */ in mdp_path_config_subfrm()
190 for (index = 0; index < config->num_components; index++) { in mdp_path_config_subfrm()
191 ctx = &path->comps[index]; in mdp_path_config_subfrm()
197 for (index = 0; index < ctrl->num_sets; index++) { in mdp_path_config_subfrm()
198 set = &ctrl->sets[index]; in mdp_path_config_subfrm()
199 cmdq_pkt_write_mask(&cmd->pkt, set->subsys_id, set->reg, in mdp_path_config_subfrm()
209 const struct img_config *config = path->config; in mdp_path_config()
214 /* Reset components */ in mdp_path_config()
215 for (index = 0; index < config->num_components; index++) { in mdp_path_config()
216 ctx = &path->comps[index]; in mdp_path_config()
222 for (index = 0; index < config->num_components; index++) { in mdp_path_config()
224 path->composes[ctx->param->outputs[0]]; in mdp_path_config()
226 ctx = &path->comps[index]; in mdp_path_config()
232 /* Config path sub-frames */ in mdp_path_config()
233 for (count = 0; count < config->num_subfrms; count++) { in mdp_path_config()
239 for (index = 0; index < config->num_components; index++) { in mdp_path_config()
240 ctx = &path->comps[index]; in mdp_path_config()
254 pkt->va_base = kzalloc(size, GFP_KERNEL); in mdp_cmdq_pkt_create()
255 if (!pkt->va_base) { in mdp_cmdq_pkt_create()
257 return -ENOMEM; in mdp_cmdq_pkt_create()
259 pkt->buf_size = size; in mdp_cmdq_pkt_create()
260 pkt->cl = (void *)client; in mdp_cmdq_pkt_create()
262 dev = client->chan->mbox->dev; in mdp_cmdq_pkt_create()
263 dma_addr = dma_map_single(dev, pkt->va_base, pkt->buf_size, in mdp_cmdq_pkt_create()
267 kfree(pkt->va_base); in mdp_cmdq_pkt_create()
268 return -ENOMEM; in mdp_cmdq_pkt_create()
271 pkt->pa_base = dma_addr; in mdp_cmdq_pkt_create()
278 struct cmdq_client *client = (struct cmdq_client *)pkt->cl; in mdp_cmdq_pkt_destroy()
280 dma_unmap_single(client->chan->mbox->dev, pkt->pa_base, pkt->buf_size, in mdp_cmdq_pkt_destroy()
282 kfree(pkt->va_base); in mdp_cmdq_pkt_destroy()
283 pkt->va_base = NULL; in mdp_cmdq_pkt_destroy()
292 mdp = cmd->mdp; in mdp_auto_release_work()
294 mtk_mutex_unprepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]); in mdp_auto_release_work()
295 mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps, in mdp_auto_release_work()
296 cmd->num_comps); in mdp_auto_release_work()
298 atomic_dec(&mdp->job_count); in mdp_auto_release_work()
299 wake_up(&mdp->callback_wq); in mdp_auto_release_work()
301 mdp_cmdq_pkt_destroy(&cmd->pkt); in mdp_auto_release_work()
302 kfree(cmd->comps); in mdp_auto_release_work()
303 cmd->comps = NULL; in mdp_auto_release_work()
321 cmd = container_of(data->pkt, struct mdp_cmdq_cmd, pkt); in mdp_handle_cmdq_callback()
322 mdp = cmd->mdp; in mdp_handle_cmdq_callback()
323 dev = &mdp->pdev->dev; in mdp_handle_cmdq_callback()
325 if (cmd->mdp_ctx) in mdp_handle_cmdq_callback()
326 mdp_m2m_job_finish(cmd->mdp_ctx); in mdp_handle_cmdq_callback()
328 if (cmd->user_cmdq_cb) { in mdp_handle_cmdq_callback()
331 user_cb_data.sta = data->sta; in mdp_handle_cmdq_callback()
332 user_cb_data.pkt = data->pkt; in mdp_handle_cmdq_callback()
333 cmd->user_cmdq_cb(user_cb_data); in mdp_handle_cmdq_callback()
336 INIT_WORK(&cmd->auto_release_work, mdp_auto_release_work); in mdp_handle_cmdq_callback()
337 if (!queue_work(mdp->clock_wq, &cmd->auto_release_work)) { in mdp_handle_cmdq_callback()
339 mtk_mutex_unprepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]); in mdp_handle_cmdq_callback()
340 mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps, in mdp_handle_cmdq_callback()
341 cmd->num_comps); in mdp_handle_cmdq_callback()
343 atomic_dec(&mdp->job_count); in mdp_handle_cmdq_callback()
344 wake_up(&mdp->callback_wq); in mdp_handle_cmdq_callback()
346 mdp_cmdq_pkt_destroy(&cmd->pkt); in mdp_handle_cmdq_callback()
347 kfree(cmd->comps); in mdp_handle_cmdq_callback()
348 cmd->comps = NULL; in mdp_handle_cmdq_callback()
359 struct device *dev = &mdp->pdev->dev; in mdp_cmdq_send()
362 atomic_inc(&mdp->job_count); in mdp_cmdq_send()
363 if (atomic_read(&mdp->suspended)) { in mdp_cmdq_send()
364 atomic_dec(&mdp->job_count); in mdp_cmdq_send()
365 return -ECANCELED; in mdp_cmdq_send()
370 ret = -ENOMEM; in mdp_cmdq_send()
374 if (mdp_cmdq_pkt_create(mdp->cmdq_clt, &cmd->pkt, SZ_16K)) { in mdp_cmdq_send()
375 ret = -ENOMEM; in mdp_cmdq_send()
379 comps = kcalloc(param->config->num_components, sizeof(*comps), in mdp_cmdq_send()
382 ret = -ENOMEM; in mdp_cmdq_send()
388 ret = -ENOMEM; in mdp_cmdq_send()
392 path->mdp_dev = mdp; in mdp_cmdq_send()
393 path->config = param->config; in mdp_cmdq_send()
394 path->param = param->param; in mdp_cmdq_send()
395 for (i = 0; i < param->param->num_outputs; i++) { in mdp_cmdq_send()
396 path->bounds[i].left = 0; in mdp_cmdq_send()
397 path->bounds[i].top = 0; in mdp_cmdq_send()
398 path->bounds[i].width = in mdp_cmdq_send()
399 param->param->outputs[i].buffer.format.width; in mdp_cmdq_send()
400 path->bounds[i].height = in mdp_cmdq_send()
401 param->param->outputs[i].buffer.format.height; in mdp_cmdq_send()
402 path->composes[i] = param->composes[i] ? in mdp_cmdq_send()
403 param->composes[i] : &path->bounds[i]; in mdp_cmdq_send()
412 mtk_mutex_prepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]); in mdp_cmdq_send()
419 cmdq_pkt_finalize(&cmd->pkt); in mdp_cmdq_send()
421 for (i = 0; i < param->config->num_components; i++) in mdp_cmdq_send()
422 memcpy(&comps[i], path->comps[i].comp, in mdp_cmdq_send()
425 mdp->cmdq_clt->client.rx_callback = mdp_handle_cmdq_callback; in mdp_cmdq_send()
426 cmd->mdp = mdp; in mdp_cmdq_send()
427 cmd->user_cmdq_cb = param->cmdq_cb; in mdp_cmdq_send()
428 cmd->user_cb_data = param->cb_data; in mdp_cmdq_send()
429 cmd->comps = comps; in mdp_cmdq_send()
430 cmd->num_comps = param->config->num_components; in mdp_cmdq_send()
431 cmd->mdp_ctx = param->mdp_ctx; in mdp_cmdq_send()
433 ret = mdp_comp_clocks_on(&mdp->pdev->dev, cmd->comps, cmd->num_comps); in mdp_cmdq_send()
439 dma_sync_single_for_device(mdp->cmdq_clt->chan->mbox->dev, in mdp_cmdq_send()
440 cmd->pkt.pa_base, cmd->pkt.cmd_buf_size, in mdp_cmdq_send()
442 ret = mbox_send_message(mdp->cmdq_clt->chan, &cmd->pkt); in mdp_cmdq_send()
447 mbox_client_txdone(mdp->cmdq_clt->chan, 0); in mdp_cmdq_send()
453 mtk_mutex_unprepare(mdp->mdp_mutex[MDP_PIPE_RDMA0]); in mdp_cmdq_send()
454 mdp_comp_clocks_off(&mdp->pdev->dev, cmd->comps, in mdp_cmdq_send()
455 cmd->num_comps); in mdp_cmdq_send()
458 atomic_dec(&mdp->job_count); in mdp_cmdq_send()
459 wake_up(&mdp->callback_wq); in mdp_cmdq_send()
460 if (cmd && cmd->pkt.buf_size > 0) in mdp_cmdq_send()
461 mdp_cmdq_pkt_destroy(&cmd->pkt); in mdp_cmdq_send()