| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2016 MediaTek Inc. |
|---|
| 3 | 4 | * Author: PC Chen <pc.chen@mediatek.com> |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 7 | | - * published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | | - * GNU General Public License for more details. |
|---|
| 13 | 5 | */ |
|---|
| 14 | 6 | |
|---|
| 15 | 7 | #include "mtk_vcodec_drv.h" |
|---|
| 16 | 8 | #include "mtk_vcodec_util.h" |
|---|
| 17 | 9 | #include "vdec_ipi_msg.h" |
|---|
| 18 | 10 | #include "vdec_vpu_if.h" |
|---|
| 11 | +#include "mtk_vcodec_fw.h" |
|---|
| 19 | 12 | |
|---|
| 20 | | -static void handle_init_ack_msg(struct vdec_vpu_ipi_init_ack *msg) |
|---|
| 13 | +static void handle_init_ack_msg(const struct vdec_vpu_ipi_init_ack *msg) |
|---|
| 21 | 14 | { |
|---|
| 22 | 15 | struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *) |
|---|
| 23 | 16 | (unsigned long)msg->ap_inst_addr; |
|---|
| .. | .. |
|---|
| 26 | 19 | |
|---|
| 27 | 20 | /* mapping VPU address to kernel virtual address */ |
|---|
| 28 | 21 | /* the content in vsi is initialized to 0 in VPU */ |
|---|
| 29 | | - vpu->vsi = vpu_mapping_dm_addr(vpu->dev, msg->vpu_inst_addr); |
|---|
| 22 | + vpu->vsi = mtk_vcodec_fw_map_dm_addr(vpu->ctx->dev->fw_handler, |
|---|
| 23 | + msg->vpu_inst_addr); |
|---|
| 30 | 24 | vpu->inst_addr = msg->vpu_inst_addr; |
|---|
| 31 | 25 | |
|---|
| 32 | 26 | mtk_vcodec_debug(vpu, "- vpu_inst_addr = 0x%x", vpu->inst_addr); |
|---|
| 33 | 27 | } |
|---|
| 34 | 28 | |
|---|
| 35 | 29 | /* |
|---|
| 30 | + * vpu_dec_ipi_handler - Handler for VPU ipi message. |
|---|
| 31 | + * |
|---|
| 32 | + * @data: ipi message |
|---|
| 33 | + * @len : length of ipi message |
|---|
| 34 | + * @priv: callback private data which is passed by decoder when register. |
|---|
| 35 | + * |
|---|
| 36 | 36 | * This function runs in interrupt context and it means there's an IPI MSG |
|---|
| 37 | 37 | * from VPU. |
|---|
| 38 | 38 | */ |
|---|
| 39 | | -void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv) |
|---|
| 39 | +static void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv) |
|---|
| 40 | 40 | { |
|---|
| 41 | | - struct vdec_vpu_ipi_ack *msg = data; |
|---|
| 41 | + const struct vdec_vpu_ipi_ack *msg = data; |
|---|
| 42 | 42 | struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *) |
|---|
| 43 | 43 | (unsigned long)msg->ap_inst_addr; |
|---|
| 44 | 44 | |
|---|
| .. | .. |
|---|
| 76 | 76 | vpu->failure = 0; |
|---|
| 77 | 77 | vpu->signaled = 0; |
|---|
| 78 | 78 | |
|---|
| 79 | | - err = vpu_ipi_send(vpu->dev, vpu->id, msg, len); |
|---|
| 79 | + err = mtk_vcodec_fw_ipi_send(vpu->ctx->dev->fw_handler, vpu->id, msg, |
|---|
| 80 | + len, 2000); |
|---|
| 80 | 81 | if (err) { |
|---|
| 81 | 82 | mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X status=%d", |
|---|
| 82 | 83 | vpu->id, *(uint32_t *)msg, err); |
|---|
| .. | .. |
|---|
| 110 | 111 | mtk_vcodec_debug_enter(vpu); |
|---|
| 111 | 112 | |
|---|
| 112 | 113 | init_waitqueue_head(&vpu->wq); |
|---|
| 114 | + vpu->handler = vpu_dec_ipi_handler; |
|---|
| 113 | 115 | |
|---|
| 114 | | - err = vpu_ipi_register(vpu->dev, vpu->id, vpu->handler, "vdec", NULL); |
|---|
| 116 | + err = mtk_vcodec_fw_ipi_register(vpu->ctx->dev->fw_handler, vpu->id, |
|---|
| 117 | + vpu->handler, "vdec", NULL); |
|---|
| 115 | 118 | if (err != 0) { |
|---|
| 116 | 119 | mtk_vcodec_err(vpu, "vpu_ipi_register fail status=%d", err); |
|---|
| 117 | 120 | return err; |
|---|