mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-25 13:43:55 +08:00
5800571960
-----BEGIN PGP SIGNATURE----- iQFSBAABCAA8FiEEq68RxlopcLEwq+PEeb4+QwBBGIYFAlz8fAYeHHRvcnZhbGRz QGxpbnV4LWZvdW5kYXRpb24ub3JnAAoJEHm+PkMAQRiG1asH/3ySguxqtqL1MCBa 4/SZ37PHeWKMerfX6ZyJdgEqK3B+PWlmuLiOMNK5h2bPLzeQQQAmHU/mfKmpXqgB dHwUbG9yNnyUtTfsfRqAnCA6vpuw9Yb1oIzTCVQrgJLSWD0j7scBBvmzYqguOkto ThwigLUq3AILr8EfR4rh+GM+5Dn9OTEFAxwil9fPHQo7QoczwZxpURhScT6Co9TB DqLA3fvXbBvLs/CZy/S5vKM9hKzC+p39ApFTURvFPrelUVnythAM0dPDJg3pIn5u g+/+gDxDFa+7ANxvxO2ng1sJPDqJMeY/xmjJYlYyLpA33B7zLNk2vDHhAP06VTtr XCMhQ9s= =cb80 -----END PGP SIGNATURE----- Merge tag 'v5.2-rc4' into media/master There are some conflicts due to SPDX changes. We also have more patches being merged via media tree touching them. So, let's merge back from upstream and address those. Linux 5.2-rc4 * tag 'v5.2-rc4': (767 commits) Linux 5.2-rc4 MAINTAINERS: Karthikeyan Ramasubramanian is MIA i2c: xiic: Add max_read_len quirk lockref: Limit number of cmpxchg loop retries uaccess: add noop untagged_addr definition x86/insn-eval: Fix use-after-free access to LDT entry kbuild: use more portable 'command -v' for cc-cross-prefix s390/unwind: correct stack switching during unwind block, bfq: add weight symlink to the bfq.weight cgroup parameter cgroup: let a symlink too be created with a cftype file drm/nouveau/secboot/gp10[2467]: support newer FW to fix SEC2 failures on some boards drm/nouveau/secboot: enable loading of versioned LS PMU/SEC2 ACR msgqueue FW drm/nouveau/secboot: split out FW version-specific LS function pointers drm/nouveau/secboot: pass max supported FW version to LS load funcs drm/nouveau/core: support versioned firmware loading drm/nouveau/core: pass subdev into nvkm_firmware_get, rather than device block: free sched's request pool in blk_cleanup_queue pktgen: do not sleep with the thread lock held. net: mvpp2: Use strscpy to handle stat strings net: rds: fix memory leak in rds_ib_flush_mr_pool ... Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
162 lines
3.7 KiB
C
162 lines
3.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (c) 2016 MediaTek Inc.
|
|
* Author: PC Chen <pc.chen@mediatek.com>
|
|
*/
|
|
|
|
#include "mtk_vcodec_drv.h"
|
|
#include "mtk_vcodec_util.h"
|
|
#include "vdec_ipi_msg.h"
|
|
#include "vdec_vpu_if.h"
|
|
|
|
static void handle_init_ack_msg(struct vdec_vpu_ipi_init_ack *msg)
|
|
{
|
|
struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
|
|
(unsigned long)msg->ap_inst_addr;
|
|
|
|
mtk_vcodec_debug(vpu, "+ ap_inst_addr = 0x%llx", msg->ap_inst_addr);
|
|
|
|
/* mapping VPU address to kernel virtual address */
|
|
/* the content in vsi is initialized to 0 in VPU */
|
|
vpu->vsi = vpu_mapping_dm_addr(vpu->dev, msg->vpu_inst_addr);
|
|
vpu->inst_addr = msg->vpu_inst_addr;
|
|
|
|
mtk_vcodec_debug(vpu, "- vpu_inst_addr = 0x%x", vpu->inst_addr);
|
|
}
|
|
|
|
/*
|
|
* This function runs in interrupt context and it means there's an IPI MSG
|
|
* from VPU.
|
|
*/
|
|
void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv)
|
|
{
|
|
struct vdec_vpu_ipi_ack *msg = data;
|
|
struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
|
|
(unsigned long)msg->ap_inst_addr;
|
|
|
|
mtk_vcodec_debug(vpu, "+ id=%X", msg->msg_id);
|
|
|
|
if (msg->status == 0) {
|
|
switch (msg->msg_id) {
|
|
case VPU_IPIMSG_DEC_INIT_ACK:
|
|
handle_init_ack_msg(data);
|
|
break;
|
|
|
|
case VPU_IPIMSG_DEC_START_ACK:
|
|
case VPU_IPIMSG_DEC_END_ACK:
|
|
case VPU_IPIMSG_DEC_DEINIT_ACK:
|
|
case VPU_IPIMSG_DEC_RESET_ACK:
|
|
break;
|
|
|
|
default:
|
|
mtk_vcodec_err(vpu, "invalid msg=%X", msg->msg_id);
|
|
break;
|
|
}
|
|
}
|
|
|
|
mtk_vcodec_debug(vpu, "- id=%X", msg->msg_id);
|
|
vpu->failure = msg->status;
|
|
vpu->signaled = 1;
|
|
}
|
|
|
|
static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
|
|
{
|
|
int err;
|
|
|
|
mtk_vcodec_debug(vpu, "id=%X", *(uint32_t *)msg);
|
|
|
|
vpu->failure = 0;
|
|
vpu->signaled = 0;
|
|
|
|
err = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
|
|
if (err) {
|
|
mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X status=%d",
|
|
vpu->id, *(uint32_t *)msg, err);
|
|
return err;
|
|
}
|
|
|
|
return vpu->failure;
|
|
}
|
|
|
|
static int vcodec_send_ap_ipi(struct vdec_vpu_inst *vpu, unsigned int msg_id)
|
|
{
|
|
struct vdec_ap_ipi_cmd msg;
|
|
int err = 0;
|
|
|
|
mtk_vcodec_debug(vpu, "+ id=%X", msg_id);
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
|
msg.msg_id = msg_id;
|
|
msg.vpu_inst_addr = vpu->inst_addr;
|
|
|
|
err = vcodec_vpu_send_msg(vpu, &msg, sizeof(msg));
|
|
mtk_vcodec_debug(vpu, "- id=%X ret=%d", msg_id, err);
|
|
return err;
|
|
}
|
|
|
|
int vpu_dec_init(struct vdec_vpu_inst *vpu)
|
|
{
|
|
struct vdec_ap_ipi_init msg;
|
|
int err;
|
|
|
|
mtk_vcodec_debug_enter(vpu);
|
|
|
|
init_waitqueue_head(&vpu->wq);
|
|
|
|
err = vpu_ipi_register(vpu->dev, vpu->id, vpu->handler, "vdec", NULL);
|
|
if (err != 0) {
|
|
mtk_vcodec_err(vpu, "vpu_ipi_register fail status=%d", err);
|
|
return err;
|
|
}
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
|
msg.msg_id = AP_IPIMSG_DEC_INIT;
|
|
msg.ap_inst_addr = (unsigned long)vpu;
|
|
|
|
mtk_vcodec_debug(vpu, "vdec_inst=%p", vpu);
|
|
|
|
err = vcodec_vpu_send_msg(vpu, (void *)&msg, sizeof(msg));
|
|
mtk_vcodec_debug(vpu, "- ret=%d", err);
|
|
return err;
|
|
}
|
|
|
|
int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len)
|
|
{
|
|
struct vdec_ap_ipi_dec_start msg;
|
|
int i;
|
|
int err = 0;
|
|
|
|
mtk_vcodec_debug_enter(vpu);
|
|
|
|
if (len > ARRAY_SIZE(msg.data)) {
|
|
mtk_vcodec_err(vpu, "invalid len = %d\n", len);
|
|
return -EINVAL;
|
|
}
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
|
msg.msg_id = AP_IPIMSG_DEC_START;
|
|
msg.vpu_inst_addr = vpu->inst_addr;
|
|
|
|
for (i = 0; i < len; i++)
|
|
msg.data[i] = data[i];
|
|
|
|
err = vcodec_vpu_send_msg(vpu, (void *)&msg, sizeof(msg));
|
|
mtk_vcodec_debug(vpu, "- ret=%d", err);
|
|
return err;
|
|
}
|
|
|
|
int vpu_dec_end(struct vdec_vpu_inst *vpu)
|
|
{
|
|
return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_END);
|
|
}
|
|
|
|
int vpu_dec_deinit(struct vdec_vpu_inst *vpu)
|
|
{
|
|
return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_DEINIT);
|
|
}
|
|
|
|
int vpu_dec_reset(struct vdec_vpu_inst *vpu)
|
|
{
|
|
return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_RESET);
|
|
}
|