[media] st-hva: encoding summary at instance release
This patch adds a short summary about the encoding operation at each instance closing, for debug purpose (through dev_dbg()): - information about the frame (format, resolution) - information about the stream (format, profile, level, resolution) - number of encoded frames - potential (system, encoding...) errors Signed-off-by: Yannick Fertre <yannick.fertre@st.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Jean-Christophe Trotin <jean-christophe.trotin@st.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
parent
0df03379c5
commit
f7e1a6dba9
|
@ -607,6 +607,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx,
|
||||||
"%s width(%d) or height(%d) exceeds limits (%dx%d)\n",
|
"%s width(%d) or height(%d) exceeds limits (%dx%d)\n",
|
||||||
pctx->name, frame_width, frame_height,
|
pctx->name, frame_width, frame_height,
|
||||||
H264_MAX_SIZE_W, H264_MAX_SIZE_H);
|
H264_MAX_SIZE_W, H264_MAX_SIZE_H);
|
||||||
|
pctx->frame_errors++;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,6 +718,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx,
|
||||||
default:
|
default:
|
||||||
dev_err(dev, "%s invalid source pixel format\n",
|
dev_err(dev, "%s invalid source pixel format\n",
|
||||||
pctx->name);
|
pctx->name);
|
||||||
|
pctx->frame_errors++;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,6 +743,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx,
|
||||||
|
|
||||||
if (td->framerate_den == 0) {
|
if (td->framerate_den == 0) {
|
||||||
dev_err(dev, "%s invalid framerate\n", pctx->name);
|
dev_err(dev, "%s invalid framerate\n", pctx->name);
|
||||||
|
pctx->frame_errors++;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,6 +834,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx,
|
||||||
(payload > MAX_SPS_PPS_SIZE)) {
|
(payload > MAX_SPS_PPS_SIZE)) {
|
||||||
dev_err(dev, "%s invalid sps/pps size %d\n", pctx->name,
|
dev_err(dev, "%s invalid sps/pps size %d\n", pctx->name,
|
||||||
payload);
|
payload);
|
||||||
|
pctx->frame_errors++;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -842,6 +846,7 @@ static int hva_h264_prepare_task(struct hva_ctx *pctx,
|
||||||
(u8 *)stream->vaddr,
|
(u8 *)stream->vaddr,
|
||||||
&payload)) {
|
&payload)) {
|
||||||
dev_err(dev, "%s fail to get SEI nal\n", pctx->name);
|
dev_err(dev, "%s fail to get SEI nal\n", pctx->name);
|
||||||
|
pctx->frame_errors++;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -963,6 +968,7 @@ err_seq_info:
|
||||||
err_ctx:
|
err_ctx:
|
||||||
devm_kfree(dev, ctx);
|
devm_kfree(dev, ctx);
|
||||||
err:
|
err:
|
||||||
|
pctx->sys_errors++;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -470,6 +470,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
|
||||||
|
|
||||||
if (pm_runtime_get_sync(dev) < 0) {
|
if (pm_runtime_get_sync(dev) < 0) {
|
||||||
dev_err(dev, "%s failed to get pm_runtime\n", ctx->name);
|
dev_err(dev, "%s failed to get pm_runtime\n", ctx->name);
|
||||||
|
ctx->sys_errors++;
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -481,6 +482,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_dbg(dev, "%s unknown command 0x%x\n", ctx->name, cmd);
|
dev_dbg(dev, "%s unknown command 0x%x\n", ctx->name, cmd);
|
||||||
|
ctx->encode_errors++;
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -511,6 +513,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
|
||||||
msecs_to_jiffies(2000))) {
|
msecs_to_jiffies(2000))) {
|
||||||
dev_err(dev, "%s %s: time out on completion\n", ctx->name,
|
dev_err(dev, "%s %s: time out on completion\n", ctx->name,
|
||||||
__func__);
|
__func__);
|
||||||
|
ctx->encode_errors++;
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -518,6 +521,8 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
|
||||||
/* get encoding status */
|
/* get encoding status */
|
||||||
ret = ctx->hw_err ? -EFAULT : 0;
|
ret = ctx->hw_err ? -EFAULT : 0;
|
||||||
|
|
||||||
|
ctx->encode_errors += ctx->hw_err ? 1 : 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
disable_irq(hva->irq_its);
|
disable_irq(hva->irq_its);
|
||||||
disable_irq(hva->irq_err);
|
disable_irq(hva->irq_err);
|
||||||
|
|
|
@ -17,14 +17,17 @@ int hva_mem_alloc(struct hva_ctx *ctx, u32 size, const char *name,
|
||||||
void *base;
|
void *base;
|
||||||
|
|
||||||
b = devm_kzalloc(dev, sizeof(*b), GFP_KERNEL);
|
b = devm_kzalloc(dev, sizeof(*b), GFP_KERNEL);
|
||||||
if (!b)
|
if (!b) {
|
||||||
|
ctx->sys_errors++;
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA,
|
base = dma_alloc_attrs(dev, size, &paddr, GFP_KERNEL | GFP_DMA,
|
||||||
DMA_ATTR_WRITE_COMBINE);
|
DMA_ATTR_WRITE_COMBINE);
|
||||||
if (!base) {
|
if (!base) {
|
||||||
dev_err(dev, "%s %s : dma_alloc_attrs failed for %s (size=%d)\n",
|
dev_err(dev, "%s %s : dma_alloc_attrs failed for %s (size=%d)\n",
|
||||||
ctx->name, __func__, name, size);
|
ctx->name, __func__, name, size);
|
||||||
|
ctx->sys_errors++;
|
||||||
devm_kfree(dev, b);
|
devm_kfree(dev, b);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,28 @@ static int hva_open_encoder(struct hva_ctx *ctx, u32 streamformat,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hva_dbg_summary(struct hva_ctx *ctx)
|
||||||
|
{
|
||||||
|
struct device *dev = ctx_to_dev(ctx);
|
||||||
|
struct hva_streaminfo *stream = &ctx->streaminfo;
|
||||||
|
struct hva_frameinfo *frame = &ctx->frameinfo;
|
||||||
|
|
||||||
|
if (!(ctx->flags & HVA_FLAG_STREAMINFO))
|
||||||
|
return;
|
||||||
|
|
||||||
|
dev_dbg(dev, "%s %4.4s %dx%d > %4.4s %dx%d %s %s: %d frames encoded, %d system errors, %d encoding errors, %d frame errors\n",
|
||||||
|
ctx->name,
|
||||||
|
(char *)&frame->pixelformat,
|
||||||
|
frame->aligned_width, frame->aligned_height,
|
||||||
|
(char *)&stream->streamformat,
|
||||||
|
stream->width, stream->height,
|
||||||
|
stream->profile, stream->level,
|
||||||
|
ctx->encoded_frames,
|
||||||
|
ctx->sys_errors,
|
||||||
|
ctx->encode_errors,
|
||||||
|
ctx->frame_errors);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* V4L2 ioctl operations
|
* V4L2 ioctl operations
|
||||||
*/
|
*/
|
||||||
|
@ -614,19 +636,17 @@ static int hva_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||||
break;
|
break;
|
||||||
case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
|
case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
|
||||||
ctx->ctrls.profile = ctrl->val;
|
ctx->ctrls.profile = ctrl->val;
|
||||||
if (ctx->flags & HVA_FLAG_STREAMINFO)
|
snprintf(ctx->streaminfo.profile,
|
||||||
snprintf(ctx->streaminfo.profile,
|
sizeof(ctx->streaminfo.profile),
|
||||||
sizeof(ctx->streaminfo.profile),
|
"%s profile",
|
||||||
"%s profile",
|
v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]);
|
||||||
v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]);
|
|
||||||
break;
|
break;
|
||||||
case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
|
case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
|
||||||
ctx->ctrls.level = ctrl->val;
|
ctx->ctrls.level = ctrl->val;
|
||||||
if (ctx->flags & HVA_FLAG_STREAMINFO)
|
snprintf(ctx->streaminfo.level,
|
||||||
snprintf(ctx->streaminfo.level,
|
sizeof(ctx->streaminfo.level),
|
||||||
sizeof(ctx->streaminfo.level),
|
"level %s",
|
||||||
"level %s",
|
v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]);
|
||||||
v4l2_ctrl_get_menu(ctrl->id)[ctrl->val]);
|
|
||||||
break;
|
break;
|
||||||
case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE:
|
case V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE:
|
||||||
ctx->ctrls.entropy_mode = ctrl->val;
|
ctx->ctrls.entropy_mode = ctrl->val;
|
||||||
|
@ -812,6 +832,8 @@ static void hva_run_work(struct work_struct *work)
|
||||||
dst_buf->field = V4L2_FIELD_NONE;
|
dst_buf->field = V4L2_FIELD_NONE;
|
||||||
dst_buf->sequence = ctx->stream_num - 1;
|
dst_buf->sequence = ctx->stream_num - 1;
|
||||||
|
|
||||||
|
ctx->encoded_frames++;
|
||||||
|
|
||||||
v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
|
v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
|
||||||
v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE);
|
v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE);
|
||||||
}
|
}
|
||||||
|
@ -1026,6 +1048,8 @@ err:
|
||||||
v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_QUEUED);
|
v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_QUEUED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->sys_errors++;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1150,6 +1174,7 @@ static int hva_open(struct file *file)
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "%s [x:x] failed to setup controls\n",
|
dev_err(dev, "%s [x:x] failed to setup controls\n",
|
||||||
HVA_PREFIX);
|
HVA_PREFIX);
|
||||||
|
ctx->sys_errors++;
|
||||||
goto err_fh;
|
goto err_fh;
|
||||||
}
|
}
|
||||||
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
|
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
|
||||||
|
@ -1162,6 +1187,7 @@ static int hva_open(struct file *file)
|
||||||
ret = PTR_ERR(ctx->fh.m2m_ctx);
|
ret = PTR_ERR(ctx->fh.m2m_ctx);
|
||||||
dev_err(dev, "%s failed to initialize m2m context (%d)\n",
|
dev_err(dev, "%s failed to initialize m2m context (%d)\n",
|
||||||
HVA_PREFIX, ret);
|
HVA_PREFIX, ret);
|
||||||
|
ctx->sys_errors++;
|
||||||
goto err_ctrls;
|
goto err_ctrls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1206,6 +1232,9 @@ static int hva_release(struct file *file)
|
||||||
hva->nb_of_instances--;
|
hva->nb_of_instances--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* trace a summary of instance before closing (debug purpose) */
|
||||||
|
hva_dbg_summary(ctx);
|
||||||
|
|
||||||
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
|
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
|
||||||
|
|
||||||
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
|
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
|
||||||
|
|
|
@ -182,6 +182,10 @@ struct hva_enc;
|
||||||
* @priv: private codec data for this instance, allocated
|
* @priv: private codec data for this instance, allocated
|
||||||
* by encoder @open time
|
* by encoder @open time
|
||||||
* @hw_err: true if hardware error detected
|
* @hw_err: true if hardware error detected
|
||||||
|
* @encoded_frames: number of encoded frames
|
||||||
|
* @sys_errors: number of system errors (memory, resource, pm...)
|
||||||
|
* @encode_errors: number of encoding errors (hw/driver errors)
|
||||||
|
* @frame_errors: number of frame errors (format, size, header...)
|
||||||
*/
|
*/
|
||||||
struct hva_ctx {
|
struct hva_ctx {
|
||||||
struct hva_dev *hva_dev;
|
struct hva_dev *hva_dev;
|
||||||
|
@ -207,6 +211,10 @@ struct hva_ctx {
|
||||||
struct hva_enc *enc;
|
struct hva_enc *enc;
|
||||||
void *priv;
|
void *priv;
|
||||||
bool hw_err;
|
bool hw_err;
|
||||||
|
u32 encoded_frames;
|
||||||
|
u32 sys_errors;
|
||||||
|
u32 encode_errors;
|
||||||
|
u32 frame_errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define HVA_FLAG_STREAMINFO 0x0001
|
#define HVA_FLAG_STREAMINFO 0x0001
|
||||||
|
|
Loading…
Reference in New Issue