mirror of
https://github.com/torvalds/linux.git
synced 2024-12-23 11:21:33 +00: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>
228 lines
5.2 KiB
C
228 lines
5.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (c) 2016 MediaTek Inc.
|
|
* Author: PoChun Lin <pochun.lin@mediatek.com>
|
|
*/
|
|
|
|
#include "mtk_vpu.h"
|
|
#include "venc_ipi_msg.h"
|
|
#include "venc_vpu_if.h"
|
|
|
|
static void handle_enc_init_msg(struct venc_vpu_inst *vpu, void *data)
|
|
{
|
|
struct venc_vpu_ipi_msg_init *msg = data;
|
|
|
|
vpu->inst_addr = msg->vpu_inst_addr;
|
|
vpu->vsi = vpu_mapping_dm_addr(vpu->dev, msg->vpu_inst_addr);
|
|
}
|
|
|
|
static void handle_enc_encode_msg(struct venc_vpu_inst *vpu, void *data)
|
|
{
|
|
struct venc_vpu_ipi_msg_enc *msg = data;
|
|
|
|
vpu->state = msg->state;
|
|
vpu->bs_size = msg->bs_size;
|
|
vpu->is_key_frm = msg->is_key_frm;
|
|
}
|
|
|
|
static void vpu_enc_ipi_handler(void *data, unsigned int len, void *priv)
|
|
{
|
|
struct venc_vpu_ipi_msg_common *msg = data;
|
|
struct venc_vpu_inst *vpu =
|
|
(struct venc_vpu_inst *)(unsigned long)msg->venc_inst;
|
|
|
|
mtk_vcodec_debug(vpu, "msg_id %x inst %p status %d",
|
|
msg->msg_id, vpu, msg->status);
|
|
|
|
switch (msg->msg_id) {
|
|
case VPU_IPIMSG_ENC_INIT_DONE:
|
|
handle_enc_init_msg(vpu, data);
|
|
break;
|
|
case VPU_IPIMSG_ENC_SET_PARAM_DONE:
|
|
break;
|
|
case VPU_IPIMSG_ENC_ENCODE_DONE:
|
|
handle_enc_encode_msg(vpu, data);
|
|
break;
|
|
case VPU_IPIMSG_ENC_DEINIT_DONE:
|
|
break;
|
|
default:
|
|
mtk_vcodec_err(vpu, "unknown msg id %x", msg->msg_id);
|
|
break;
|
|
}
|
|
|
|
vpu->signaled = 1;
|
|
vpu->failure = (msg->status != VENC_IPI_MSG_STATUS_OK);
|
|
|
|
mtk_vcodec_debug_leave(vpu);
|
|
}
|
|
|
|
static int vpu_enc_send_msg(struct venc_vpu_inst *vpu, void *msg,
|
|
int len)
|
|
{
|
|
int status;
|
|
|
|
mtk_vcodec_debug_enter(vpu);
|
|
|
|
if (!vpu->dev) {
|
|
mtk_vcodec_err(vpu, "inst dev is NULL");
|
|
return -EINVAL;
|
|
}
|
|
|
|
status = vpu_ipi_send(vpu->dev, vpu->id, msg, len);
|
|
if (status) {
|
|
mtk_vcodec_err(vpu, "vpu_ipi_send msg_id %x len %d fail %d",
|
|
*(uint32_t *)msg, len, status);
|
|
return -EINVAL;
|
|
}
|
|
if (vpu->failure)
|
|
return -EINVAL;
|
|
|
|
mtk_vcodec_debug_leave(vpu);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int vpu_enc_init(struct venc_vpu_inst *vpu)
|
|
{
|
|
int status;
|
|
struct venc_ap_ipi_msg_init out;
|
|
|
|
mtk_vcodec_debug_enter(vpu);
|
|
|
|
init_waitqueue_head(&vpu->wq_hd);
|
|
vpu->signaled = 0;
|
|
vpu->failure = 0;
|
|
|
|
status = vpu_ipi_register(vpu->dev, vpu->id, vpu_enc_ipi_handler,
|
|
NULL, NULL);
|
|
if (status) {
|
|
mtk_vcodec_err(vpu, "vpu_ipi_register fail %d", status);
|
|
return -EINVAL;
|
|
}
|
|
|
|
memset(&out, 0, sizeof(out));
|
|
out.msg_id = AP_IPIMSG_ENC_INIT;
|
|
out.venc_inst = (unsigned long)vpu;
|
|
if (vpu_enc_send_msg(vpu, &out, sizeof(out))) {
|
|
mtk_vcodec_err(vpu, "AP_IPIMSG_ENC_INIT fail");
|
|
return -EINVAL;
|
|
}
|
|
|
|
mtk_vcodec_debug_leave(vpu);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int vpu_enc_set_param(struct venc_vpu_inst *vpu,
|
|
enum venc_set_param_type id,
|
|
struct venc_enc_param *enc_param)
|
|
{
|
|
struct venc_ap_ipi_msg_set_param out;
|
|
|
|
mtk_vcodec_debug(vpu, "id %d ->", id);
|
|
|
|
memset(&out, 0, sizeof(out));
|
|
out.msg_id = AP_IPIMSG_ENC_SET_PARAM;
|
|
out.vpu_inst_addr = vpu->inst_addr;
|
|
out.param_id = id;
|
|
switch (id) {
|
|
case VENC_SET_PARAM_ENC:
|
|
out.data_item = 0;
|
|
break;
|
|
case VENC_SET_PARAM_FORCE_INTRA:
|
|
out.data_item = 0;
|
|
break;
|
|
case VENC_SET_PARAM_ADJUST_BITRATE:
|
|
out.data_item = 1;
|
|
out.data[0] = enc_param->bitrate;
|
|
break;
|
|
case VENC_SET_PARAM_ADJUST_FRAMERATE:
|
|
out.data_item = 1;
|
|
out.data[0] = enc_param->frm_rate;
|
|
break;
|
|
case VENC_SET_PARAM_GOP_SIZE:
|
|
out.data_item = 1;
|
|
out.data[0] = enc_param->gop_size;
|
|
break;
|
|
case VENC_SET_PARAM_INTRA_PERIOD:
|
|
out.data_item = 1;
|
|
out.data[0] = enc_param->intra_period;
|
|
break;
|
|
case VENC_SET_PARAM_SKIP_FRAME:
|
|
out.data_item = 0;
|
|
break;
|
|
default:
|
|
mtk_vcodec_err(vpu, "id %d not supported", id);
|
|
return -EINVAL;
|
|
}
|
|
if (vpu_enc_send_msg(vpu, &out, sizeof(out))) {
|
|
mtk_vcodec_err(vpu,
|
|
"AP_IPIMSG_ENC_SET_PARAM %d fail", id);
|
|
return -EINVAL;
|
|
}
|
|
|
|
mtk_vcodec_debug(vpu, "id %d <-", id);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int vpu_enc_encode(struct venc_vpu_inst *vpu, unsigned int bs_mode,
|
|
struct venc_frm_buf *frm_buf,
|
|
struct mtk_vcodec_mem *bs_buf,
|
|
unsigned int *bs_size)
|
|
{
|
|
struct venc_ap_ipi_msg_enc out;
|
|
|
|
mtk_vcodec_debug(vpu, "bs_mode %d ->", bs_mode);
|
|
|
|
memset(&out, 0, sizeof(out));
|
|
out.msg_id = AP_IPIMSG_ENC_ENCODE;
|
|
out.vpu_inst_addr = vpu->inst_addr;
|
|
out.bs_mode = bs_mode;
|
|
if (frm_buf) {
|
|
if ((frm_buf->fb_addr[0].dma_addr % 16 == 0) &&
|
|
(frm_buf->fb_addr[1].dma_addr % 16 == 0) &&
|
|
(frm_buf->fb_addr[2].dma_addr % 16 == 0)) {
|
|
out.input_addr[0] = frm_buf->fb_addr[0].dma_addr;
|
|
out.input_addr[1] = frm_buf->fb_addr[1].dma_addr;
|
|
out.input_addr[2] = frm_buf->fb_addr[2].dma_addr;
|
|
} else {
|
|
mtk_vcodec_err(vpu, "dma_addr not align to 16");
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
if (bs_buf) {
|
|
out.bs_addr = bs_buf->dma_addr;
|
|
out.bs_size = bs_buf->size;
|
|
}
|
|
if (vpu_enc_send_msg(vpu, &out, sizeof(out))) {
|
|
mtk_vcodec_err(vpu, "AP_IPIMSG_ENC_ENCODE %d fail",
|
|
bs_mode);
|
|
return -EINVAL;
|
|
}
|
|
|
|
mtk_vcodec_debug(vpu, "bs_mode %d state %d size %d key_frm %d <-",
|
|
bs_mode, vpu->state, vpu->bs_size, vpu->is_key_frm);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int vpu_enc_deinit(struct venc_vpu_inst *vpu)
|
|
{
|
|
struct venc_ap_ipi_msg_deinit out;
|
|
|
|
mtk_vcodec_debug_enter(vpu);
|
|
|
|
memset(&out, 0, sizeof(out));
|
|
out.msg_id = AP_IPIMSG_ENC_DEINIT;
|
|
out.vpu_inst_addr = vpu->inst_addr;
|
|
if (vpu_enc_send_msg(vpu, &out, sizeof(out))) {
|
|
mtk_vcodec_err(vpu, "AP_IPIMSG_ENC_DEINIT fail");
|
|
return -EINVAL;
|
|
}
|
|
|
|
mtk_vcodec_debug_leave(vpu);
|
|
|
|
return 0;
|
|
}
|