media: amphion: add helper function to get id name
[ Upstream commit 12cd8b8ac02525977b2e860a877add10e8ce7468 ]
convert numbers into meaningful names,
then it can improve the log readability
Fixes: 9f599f351e
("media: amphion: add vpu core driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
745f40a96c
commit
62ea218a7e
@ -249,7 +249,8 @@ static int vdec_update_state(struct vpu_inst *inst, enum vpu_codec_state state,
|
||||
vdec->state = VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE;
|
||||
|
||||
if (inst->state != pre_state)
|
||||
vpu_trace(inst->dev, "[%d] %d -> %d\n", inst->id, pre_state, inst->state);
|
||||
vpu_trace(inst->dev, "[%d] %s -> %s\n", inst->id,
|
||||
vpu_codec_state_name(pre_state), vpu_codec_state_name(inst->state));
|
||||
|
||||
if (inst->state == VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE)
|
||||
vdec_handle_resolution_change(inst);
|
||||
@ -994,8 +995,8 @@ static int vdec_response_frame(struct vpu_inst *inst, struct vb2_v4l2_buffer *vb
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(inst->dev, "[%d] state = %d, alloc fs %d, tag = 0x%x\n",
|
||||
inst->id, inst->state, vbuf->vb2_buf.index, vdec->seq_tag);
|
||||
dev_dbg(inst->dev, "[%d] state = %s, alloc fs %d, tag = 0x%x\n",
|
||||
inst->id, vpu_codec_state_name(inst->state), vbuf->vb2_buf.index, vdec->seq_tag);
|
||||
vpu_buf = to_vpu_vb2_buffer(vbuf);
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
@ -1354,7 +1355,7 @@ static void vdec_abort(struct vpu_inst *inst)
|
||||
struct vpu_rpc_buffer_desc desc;
|
||||
int ret;
|
||||
|
||||
vpu_trace(inst->dev, "[%d] state = %d\n", inst->id, inst->state);
|
||||
vpu_trace(inst->dev, "[%d] state = %s\n", inst->id, vpu_codec_state_name(inst->state));
|
||||
|
||||
vdec->aborting = true;
|
||||
vpu_iface_add_scode(inst, SCODE_PADDING_ABORT);
|
||||
|
@ -353,6 +353,9 @@ void vpu_inst_record_flow(struct vpu_inst *inst, u32 flow);
|
||||
int vpu_core_driver_init(void);
|
||||
void vpu_core_driver_exit(void);
|
||||
|
||||
const char *vpu_id_name(u32 id);
|
||||
const char *vpu_codec_state_name(enum vpu_codec_state state);
|
||||
|
||||
extern bool debug;
|
||||
#define vpu_trace(dev, fmt, arg...) \
|
||||
do { \
|
||||
|
@ -98,7 +98,7 @@ static struct vpu_cmd_t *vpu_alloc_cmd(struct vpu_inst *inst, u32 id, void *data
|
||||
cmd->id = id;
|
||||
ret = vpu_iface_pack_cmd(inst->core, cmd->pkt, inst->id, id, data);
|
||||
if (ret) {
|
||||
dev_err(inst->dev, "iface pack cmd(%d) fail\n", id);
|
||||
dev_err(inst->dev, "iface pack cmd %s fail\n", vpu_id_name(id));
|
||||
vfree(cmd->pkt);
|
||||
vfree(cmd);
|
||||
return NULL;
|
||||
@ -125,14 +125,14 @@ static int vpu_session_process_cmd(struct vpu_inst *inst, struct vpu_cmd_t *cmd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
dev_dbg(inst->dev, "[%d]send cmd(0x%x)\n", inst->id, cmd->id);
|
||||
dev_dbg(inst->dev, "[%d]send cmd %s\n", inst->id, vpu_id_name(cmd->id));
|
||||
vpu_iface_pre_send_cmd(inst);
|
||||
ret = vpu_cmd_send(inst->core, cmd->pkt);
|
||||
if (!ret) {
|
||||
vpu_iface_post_send_cmd(inst);
|
||||
vpu_inst_record_flow(inst, cmd->id);
|
||||
} else {
|
||||
dev_err(inst->dev, "[%d] iface send cmd(0x%x) fail\n", inst->id, cmd->id);
|
||||
dev_err(inst->dev, "[%d] iface send cmd %s fail\n", inst->id, vpu_id_name(cmd->id));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -149,7 +149,8 @@ static void vpu_process_cmd_request(struct vpu_inst *inst)
|
||||
list_for_each_entry_safe(cmd, tmp, &inst->cmd_q, list) {
|
||||
list_del_init(&cmd->list);
|
||||
if (vpu_session_process_cmd(inst, cmd))
|
||||
dev_err(inst->dev, "[%d] process cmd(%d) fail\n", inst->id, cmd->id);
|
||||
dev_err(inst->dev, "[%d] process cmd %s fail\n",
|
||||
inst->id, vpu_id_name(cmd->id));
|
||||
if (cmd->request) {
|
||||
inst->pending = (void *)cmd;
|
||||
break;
|
||||
@ -339,7 +340,7 @@ static int vpu_session_send_cmd(struct vpu_inst *inst, u32 id, void *data)
|
||||
|
||||
exit:
|
||||
if (ret)
|
||||
dev_err(inst->dev, "[%d] send cmd(0x%x) fail\n", inst->id, id);
|
||||
dev_err(inst->dev, "[%d] send cmd %s fail\n", inst->id, vpu_id_name(id));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ static int vpu_dbg_instance(struct seq_file *s, void *data)
|
||||
num = scnprintf(str, sizeof(str), "tgig = %d,pid = %d\n", inst->tgid, inst->pid);
|
||||
if (seq_write(s, str, num))
|
||||
return 0;
|
||||
num = scnprintf(str, sizeof(str), "state = %d\n", inst->state);
|
||||
num = scnprintf(str, sizeof(str), "state = %s\n", vpu_codec_state_name(inst->state));
|
||||
if (seq_write(s, str, num))
|
||||
return 0;
|
||||
num = scnprintf(str, sizeof(str),
|
||||
@ -188,9 +188,9 @@ static int vpu_dbg_instance(struct seq_file *s, void *data)
|
||||
|
||||
if (!inst->flows[idx])
|
||||
continue;
|
||||
num = scnprintf(str, sizeof(str), "\t[%s]0x%x\n",
|
||||
num = scnprintf(str, sizeof(str), "\t[%s] %s\n",
|
||||
inst->flows[idx] >= VPU_MSG_ID_NOOP ? "M" : "C",
|
||||
inst->flows[idx]);
|
||||
vpu_id_name(inst->flows[idx]));
|
||||
if (seq_write(s, str, num)) {
|
||||
mutex_unlock(&inst->core->cmd_lock);
|
||||
return 0;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include "vpu.h"
|
||||
#include "vpu_defs.h"
|
||||
#include "vpu_core.h"
|
||||
#include "vpu_rpc.h"
|
||||
#include "vpu_helpers.h"
|
||||
@ -412,3 +413,63 @@ int vpu_find_src_by_dst(struct vpu_pair *pairs, u32 cnt, u32 dst)
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
const char *vpu_id_name(u32 id)
|
||||
{
|
||||
switch (id) {
|
||||
case VPU_CMD_ID_NOOP: return "noop";
|
||||
case VPU_CMD_ID_CONFIGURE_CODEC: return "configure codec";
|
||||
case VPU_CMD_ID_START: return "start";
|
||||
case VPU_CMD_ID_STOP: return "stop";
|
||||
case VPU_CMD_ID_ABORT: return "abort";
|
||||
case VPU_CMD_ID_RST_BUF: return "reset buf";
|
||||
case VPU_CMD_ID_SNAPSHOT: return "snapshot";
|
||||
case VPU_CMD_ID_FIRM_RESET: return "reset firmware";
|
||||
case VPU_CMD_ID_UPDATE_PARAMETER: return "update parameter";
|
||||
case VPU_CMD_ID_FRAME_ENCODE: return "encode frame";
|
||||
case VPU_CMD_ID_SKIP: return "skip";
|
||||
case VPU_CMD_ID_FS_ALLOC: return "alloc fb";
|
||||
case VPU_CMD_ID_FS_RELEASE: return "release fb";
|
||||
case VPU_CMD_ID_TIMESTAMP: return "timestamp";
|
||||
case VPU_CMD_ID_DEBUG: return "debug";
|
||||
case VPU_MSG_ID_RESET_DONE: return "reset done";
|
||||
case VPU_MSG_ID_START_DONE: return "start done";
|
||||
case VPU_MSG_ID_STOP_DONE: return "stop done";
|
||||
case VPU_MSG_ID_ABORT_DONE: return "abort done";
|
||||
case VPU_MSG_ID_BUF_RST: return "buf reset done";
|
||||
case VPU_MSG_ID_MEM_REQUEST: return "mem request";
|
||||
case VPU_MSG_ID_PARAM_UPD_DONE: return "param upd done";
|
||||
case VPU_MSG_ID_FRAME_INPUT_DONE: return "frame input done";
|
||||
case VPU_MSG_ID_ENC_DONE: return "encode done";
|
||||
case VPU_MSG_ID_DEC_DONE: return "frame display";
|
||||
case VPU_MSG_ID_FRAME_REQ: return "fb request";
|
||||
case VPU_MSG_ID_FRAME_RELEASE: return "fb release";
|
||||
case VPU_MSG_ID_SEQ_HDR_FOUND: return "seq hdr found";
|
||||
case VPU_MSG_ID_RES_CHANGE: return "resolution change";
|
||||
case VPU_MSG_ID_PIC_HDR_FOUND: return "pic hdr found";
|
||||
case VPU_MSG_ID_PIC_DECODED: return "picture decoded";
|
||||
case VPU_MSG_ID_PIC_EOS: return "eos";
|
||||
case VPU_MSG_ID_FIFO_LOW: return "fifo low";
|
||||
case VPU_MSG_ID_BS_ERROR: return "bs error";
|
||||
case VPU_MSG_ID_UNSUPPORTED: return "unsupported";
|
||||
case VPU_MSG_ID_FIRMWARE_XCPT: return "exception";
|
||||
case VPU_MSG_ID_PIC_SKIPPED: return "skipped";
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
const char *vpu_codec_state_name(enum vpu_codec_state state)
|
||||
{
|
||||
switch (state) {
|
||||
case VPU_CODEC_STATE_DEINIT: return "initialization";
|
||||
case VPU_CODEC_STATE_CONFIGURED: return "configured";
|
||||
case VPU_CODEC_STATE_START: return "start";
|
||||
case VPU_CODEC_STATE_STARTED: return "started";
|
||||
case VPU_CODEC_STATE_ACTIVE: return "active";
|
||||
case VPU_CODEC_STATE_SEEK: return "seek";
|
||||
case VPU_CODEC_STATE_STOP: return "stop";
|
||||
case VPU_CODEC_STATE_DRAIN: return "drain";
|
||||
case VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE: return "resolution change";
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ static int vpu_session_handle_msg(struct vpu_inst *inst, struct vpu_rpc_event *m
|
||||
return -EINVAL;
|
||||
|
||||
msg_id = ret;
|
||||
dev_dbg(inst->dev, "[%d] receive event(0x%x)\n", inst->id, msg_id);
|
||||
dev_dbg(inst->dev, "[%d] receive event(%s)\n", inst->id, vpu_id_name(msg_id));
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(handlers); i++) {
|
||||
if (handlers[i].id == msg_id) {
|
||||
|
Loading…
Reference in New Issue
Block a user