Commit 6496617b authored by Ming Qian's avatar Ming Qian Committed by Hans Verkuil

media: amphion: handle firmware debug message

decoder firmware may notify host some debug message,
it can help analyze the state of the firmware in case of error

Fixes: 9f599f35 ("media: amphion: add vpu core driver")
Signed-off-by: default avatarMing Qian <ming.qian@nxp.com>
Reviewed-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent f910d3ba
...@@ -71,6 +71,7 @@ enum { ...@@ -71,6 +71,7 @@ enum {
VPU_MSG_ID_TIMESTAMP_INFO, VPU_MSG_ID_TIMESTAMP_INFO,
VPU_MSG_ID_FIRMWARE_XCPT, VPU_MSG_ID_FIRMWARE_XCPT,
VPU_MSG_ID_PIC_SKIPPED, VPU_MSG_ID_PIC_SKIPPED,
VPU_MSG_ID_DBG_MSG,
}; };
enum VPU_ENC_MEMORY_RESOURSE { enum VPU_ENC_MEMORY_RESOURSE {
......
...@@ -489,6 +489,7 @@ const char *vpu_id_name(u32 id) ...@@ -489,6 +489,7 @@ const char *vpu_id_name(u32 id)
case VPU_MSG_ID_UNSUPPORTED: return "unsupported"; case VPU_MSG_ID_UNSUPPORTED: return "unsupported";
case VPU_MSG_ID_FIRMWARE_XCPT: return "exception"; case VPU_MSG_ID_FIRMWARE_XCPT: return "exception";
case VPU_MSG_ID_PIC_SKIPPED: return "skipped"; case VPU_MSG_ID_PIC_SKIPPED: return "skipped";
case VPU_MSG_ID_DBG_MSG: return "debug msg";
} }
return "<unknown>"; return "<unknown>";
} }
......
...@@ -745,6 +745,7 @@ static struct vpu_pair malone_msgs[] = { ...@@ -745,6 +745,7 @@ static struct vpu_pair malone_msgs[] = {
{VPU_MSG_ID_UNSUPPORTED, VID_API_EVENT_UNSUPPORTED_STREAM}, {VPU_MSG_ID_UNSUPPORTED, VID_API_EVENT_UNSUPPORTED_STREAM},
{VPU_MSG_ID_FIRMWARE_XCPT, VID_API_EVENT_FIRMWARE_XCPT}, {VPU_MSG_ID_FIRMWARE_XCPT, VID_API_EVENT_FIRMWARE_XCPT},
{VPU_MSG_ID_PIC_SKIPPED, VID_API_EVENT_PIC_SKIPPED}, {VPU_MSG_ID_PIC_SKIPPED, VID_API_EVENT_PIC_SKIPPED},
{VPU_MSG_ID_DBG_MSG, VID_API_EVENT_DBG_MSG_DEC},
}; };
static void vpu_malone_pack_fs_alloc(struct vpu_rpc_event *pkt, static void vpu_malone_pack_fs_alloc(struct vpu_rpc_event *pkt,
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
struct vpu_msg_handler { struct vpu_msg_handler {
u32 id; u32 id;
void (*done)(struct vpu_inst *inst, struct vpu_rpc_event *pkt); void (*done)(struct vpu_inst *inst, struct vpu_rpc_event *pkt);
u32 is_str;
}; };
static void vpu_session_handle_start_done(struct vpu_inst *inst, struct vpu_rpc_event *pkt) static void vpu_session_handle_start_done(struct vpu_inst *inst, struct vpu_rpc_event *pkt)
...@@ -154,7 +155,7 @@ static void vpu_session_handle_error(struct vpu_inst *inst, struct vpu_rpc_event ...@@ -154,7 +155,7 @@ static void vpu_session_handle_error(struct vpu_inst *inst, struct vpu_rpc_event
{ {
char *str = (char *)pkt->data; char *str = (char *)pkt->data;
if (strlen(str)) if (*str)
dev_err(inst->dev, "instance %d firmware error : %s\n", inst->id, str); dev_err(inst->dev, "instance %d firmware error : %s\n", inst->id, str);
else else
dev_err(inst->dev, "instance %d is unsupported stream\n", inst->id); dev_err(inst->dev, "instance %d is unsupported stream\n", inst->id);
...@@ -180,6 +181,21 @@ static void vpu_session_handle_pic_skipped(struct vpu_inst *inst, struct vpu_rpc ...@@ -180,6 +181,21 @@ static void vpu_session_handle_pic_skipped(struct vpu_inst *inst, struct vpu_rpc
vpu_inst_unlock(inst); vpu_inst_unlock(inst);
} }
static void vpu_session_handle_dbg_msg(struct vpu_inst *inst, struct vpu_rpc_event *pkt)
{
char *str = (char *)pkt->data;
if (*str)
dev_info(inst->dev, "instance %d firmware dbg msg : %s\n", inst->id, str);
}
static void vpu_terminate_string_msg(struct vpu_rpc_event *pkt)
{
if (pkt->hdr.num == ARRAY_SIZE(pkt->data))
pkt->hdr.num--;
pkt->data[pkt->hdr.num] = 0;
}
static struct vpu_msg_handler handlers[] = { static struct vpu_msg_handler handlers[] = {
{VPU_MSG_ID_START_DONE, vpu_session_handle_start_done}, {VPU_MSG_ID_START_DONE, vpu_session_handle_start_done},
{VPU_MSG_ID_STOP_DONE, vpu_session_handle_stop_done}, {VPU_MSG_ID_STOP_DONE, vpu_session_handle_stop_done},
...@@ -193,9 +209,10 @@ static struct vpu_msg_handler handlers[] = { ...@@ -193,9 +209,10 @@ static struct vpu_msg_handler handlers[] = {
{VPU_MSG_ID_PIC_DECODED, vpu_session_handle_pic_decoded}, {VPU_MSG_ID_PIC_DECODED, vpu_session_handle_pic_decoded},
{VPU_MSG_ID_DEC_DONE, vpu_session_handle_pic_done}, {VPU_MSG_ID_DEC_DONE, vpu_session_handle_pic_done},
{VPU_MSG_ID_PIC_EOS, vpu_session_handle_eos}, {VPU_MSG_ID_PIC_EOS, vpu_session_handle_eos},
{VPU_MSG_ID_UNSUPPORTED, vpu_session_handle_error}, {VPU_MSG_ID_UNSUPPORTED, vpu_session_handle_error, true},
{VPU_MSG_ID_FIRMWARE_XCPT, vpu_session_handle_firmware_xcpt}, {VPU_MSG_ID_FIRMWARE_XCPT, vpu_session_handle_firmware_xcpt, true},
{VPU_MSG_ID_PIC_SKIPPED, vpu_session_handle_pic_skipped}, {VPU_MSG_ID_PIC_SKIPPED, vpu_session_handle_pic_skipped},
{VPU_MSG_ID_DBG_MSG, vpu_session_handle_dbg_msg, true},
}; };
static int vpu_session_handle_msg(struct vpu_inst *inst, struct vpu_rpc_event *msg) static int vpu_session_handle_msg(struct vpu_inst *inst, struct vpu_rpc_event *msg)
...@@ -219,8 +236,12 @@ static int vpu_session_handle_msg(struct vpu_inst *inst, struct vpu_rpc_event *m ...@@ -219,8 +236,12 @@ static int vpu_session_handle_msg(struct vpu_inst *inst, struct vpu_rpc_event *m
} }
} }
if (handler && handler->done) if (handler) {
handler->done(inst, msg); if (handler->is_str)
vpu_terminate_string_msg(msg);
if (handler->done)
handler->done(inst, msg);
}
vpu_response_cmd(inst, msg_id, 1); vpu_response_cmd(inst, msg_id, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment