media: coda: normalise debug output

Consistently add the context index to debug output, which otherwise is
impossible to make sense of when two contexts are running concurrently.
For this purpose, add a convenience macro coda_dbg(). Use the function
name with the coda_ prefix stripped as keyword where applicable, and
consistently use vid-out and vid-cap names for the queues. Add sequence
counters to the decoder job finished message and correctly indicate B
frames. Add a start streaming message to complement the stop streaming
message and a start encoding message to complement the existing start
decoding message.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Philipp Zabel 2018-11-05 10:25:12 -05:00 committed by Mauro Carvalho Chehab
parent 299cc3181b
commit 8f90d15e6d
3 changed files with 65 additions and 76 deletions

View File

@ -725,8 +725,7 @@ static void coda_setup_iram(struct coda_ctx *ctx)
out: out:
if (!(iram_info->axi_sram_use & CODA7_USE_HOST_IP_ENABLE)) if (!(iram_info->axi_sram_use & CODA7_USE_HOST_IP_ENABLE))
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "IRAM smaller than needed\n");
"IRAM smaller than needed\n");
if (dev->devtype->product == CODA_HX4 || if (dev->devtype->product == CODA_HX4 ||
dev->devtype->product == CODA_7541) { dev->devtype->product == CODA_7541) {
@ -1213,6 +1212,12 @@ static int coda_start_encoding(struct coda_ctx *ctx)
goto out; goto out;
} }
coda_dbg(1, ctx, "start encoding %dx%d %4.4s->%4.4s @ %d/%d Hz\n",
q_data_src->rect.width, q_data_src->rect.height,
(char *)&ctx->codec->src_fourcc, (char *)&dst_fourcc,
ctx->params.framerate & 0xffff,
(ctx->params.framerate >> 16) + 1);
/* Save stream headers */ /* Save stream headers */
buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
switch (dst_fourcc) { switch (dst_fourcc) {
@ -1474,8 +1479,7 @@ static void coda_finish_encode(struct coda_ctx *ctx)
vb2_set_plane_payload(&dst_buf->vb2_buf, 0, wr_ptr - start_ptr); vb2_set_plane_payload(&dst_buf->vb2_buf, 0, wr_ptr - start_ptr);
} }
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, "frame size = %u\n", coda_dbg(1, ctx, "frame size = %u\n", wr_ptr - start_ptr);
wr_ptr - start_ptr);
coda_read(dev, CODA_RET_ENC_PIC_SLICE_NUM); coda_read(dev, CODA_RET_ENC_PIC_SLICE_NUM);
coda_read(dev, CODA_RET_ENC_PIC_FLAG); coda_read(dev, CODA_RET_ENC_PIC_FLAG);
@ -1504,11 +1508,9 @@ static void coda_finish_encode(struct coda_ctx *ctx)
if (ctx->gopcounter < 0) if (ctx->gopcounter < 0)
ctx->gopcounter = ctx->params.gop_size - 1; ctx->gopcounter = ctx->params.gop_size - 1;
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, coda_dbg(1, ctx, "job finished: encoded %c frame (%d)\n",
"job finished: encoding frame (%d) (%s)\n", (dst_buf->flags & V4L2_BUF_FLAG_KEYFRAME) ? 'I' : 'P',
dst_buf->sequence, dst_buf->sequence);
(dst_buf->flags & V4L2_BUF_FLAG_KEYFRAME) ?
"KEYFRAME" : "PFRAME");
} }
static void coda_seq_end_work(struct work_struct *work) static void coda_seq_end_work(struct work_struct *work)
@ -1522,9 +1524,7 @@ static void coda_seq_end_work(struct work_struct *work)
if (ctx->initialized == 0) if (ctx->initialized == 0)
goto out; goto out;
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, coda_dbg(1, ctx, "%s: sent command 'SEQ_END' to coda\n", __func__);
"%d: %s: sent command 'SEQ_END' to coda\n", ctx->idx,
__func__);
if (coda_command_sync(ctx, CODA_COMMAND_SEQ_END)) { if (coda_command_sync(ctx, CODA_COMMAND_SEQ_END)) {
v4l2_err(&dev->v4l2_dev, v4l2_err(&dev->v4l2_dev,
"CODA_COMMAND_SEQ_END failed\n"); "CODA_COMMAND_SEQ_END failed\n");
@ -1667,8 +1667,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
u32 val; u32 val;
int ret; int ret;
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, coda_dbg(1, ctx, "Video Data Order Adapter: %s\n",
"Video Data Order Adapter: %s\n",
ctx->use_vdoa ? "Enabled" : "Disabled"); ctx->use_vdoa ? "Enabled" : "Disabled");
/* Start decoding */ /* Start decoding */
@ -1772,8 +1771,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
width = round_up(width, 16); width = round_up(width, 16);
height = round_up(height, 16); height = round_up(height, 16);
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, "%s instance %d now: %dx%d\n", coda_dbg(1, ctx, "start decoding: %dx%d\n", width, height);
__func__, ctx->idx, width, height);
ctx->num_internal_frames = coda_read(dev, CODA_RET_DEC_SEQ_FRAME_NEED); ctx->num_internal_frames = coda_read(dev, CODA_RET_DEC_SEQ_FRAME_NEED);
/* /*
@ -1904,8 +1902,7 @@ static int coda_prepare_decode(struct coda_ctx *ctx)
if (coda_get_bitstream_payload(ctx) < 512 && if (coda_get_bitstream_payload(ctx) < 512 &&
(!(ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG))) { (!(ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG))) {
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, coda_dbg(1, ctx, "bitstream payload: %d, skipping\n",
"bitstream payload: %d, skipping\n",
coda_get_bitstream_payload(ctx)); coda_get_bitstream_payload(ctx));
v4l2_m2m_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx); v4l2_m2m_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx);
return -EAGAIN; return -EAGAIN;
@ -2109,8 +2106,7 @@ static void coda_finish_decode(struct coda_ctx *ctx)
val = coda_read(dev, CODA_RET_DEC_PIC_OPTION); val = coda_read(dev, CODA_RET_DEC_PIC_OPTION);
if (val == 0) { if (val == 0) {
/* not enough bitstream data */ /* not enough bitstream data */
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, coda_dbg(1, ctx, "prescan failed: %d\n", val);
"prescan failed: %d\n", val);
ctx->hold = true; ctx->hold = true;
return; return;
} }
@ -2252,14 +2248,13 @@ static void coda_finish_decode(struct coda_ctx *ctx)
else else
coda_m2m_buf_done(ctx, dst_buf, VB2_BUF_STATE_DONE); coda_m2m_buf_done(ctx, dst_buf, VB2_BUF_STATE_DONE);
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, coda_dbg(1, ctx, "job finished: decoded %c frame (%u/%u)\n",
"job finished: decoding frame (%d) (%s)\n", (dst_buf->flags & V4L2_BUF_FLAG_KEYFRAME) ? 'I' :
dst_buf->sequence, ((dst_buf->flags & V4L2_BUF_FLAG_PFRAME) ? 'P' : 'B'),
(dst_buf->flags & V4L2_BUF_FLAG_KEYFRAME) ? dst_buf->sequence, ctx->qsequence);
"KEYFRAME" : "PFRAME");
} else { } else {
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, coda_dbg(1, ctx, "job finished: no frame decoded (%u/%u)\n",
"job finished: no frame decoded\n"); ctx->osequence, ctx->qsequence);
} }
/* The rotator will copy the current display frame next time */ /* The rotator will copy the current display frame next time */
@ -2328,13 +2323,11 @@ irqreturn_t coda_irq_handler(int irq, void *data)
trace_coda_bit_done(ctx); trace_coda_bit_done(ctx);
if (ctx->aborting) { if (ctx->aborting) {
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "task has been aborted\n");
"task has been aborted\n");
} }
if (coda_isbusy(ctx->dev)) { if (coda_isbusy(ctx->dev)) {
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "coda is still busy!!!!\n");
"coda is still busy!!!!\n");
return IRQ_NONE; return IRQ_NONE;
} }

View File

@ -751,11 +751,10 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f,
else else
ctx->use_vdoa = false; ctx->use_vdoa = false;
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "Setting %s format, wxh: %dx%d, fmt: %4.4s %c\n",
"Setting format for type %d, wxh: %dx%d, fmt: %4.4s %c\n", v4l2_type_names[f->type], q_data->width, q_data->height,
f->type, q_data->width, q_data->height, (char *)&q_data->fourcc,
(char *)&q_data->fourcc, (ctx->tiled_map_type == GDI_LINEAR_FRAME_MAP) ? 'L' : 'T');
(ctx->tiled_map_type == GDI_LINEAR_FRAME_MAP) ? 'L' : 'T');
return 0; return 0;
} }
@ -1301,14 +1300,12 @@ static int coda_job_ready(void *m2m_priv)
* the compressed frame can be in the bitstream. * the compressed frame can be in the bitstream.
*/ */
if (!src_bufs && ctx->inst_type != CODA_INST_DECODER) { if (!src_bufs && ctx->inst_type != CODA_INST_DECODER) {
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "not ready: not enough vid-out buffers.\n");
"not ready: not enough video buffers.\n");
return 0; return 0;
} }
if (!v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx)) { if (!v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx)) {
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "not ready: not enough vid-cap buffers.\n");
"not ready: not enough video capture buffers.\n");
return 0; return 0;
} }
@ -1321,24 +1318,23 @@ static int coda_job_ready(void *m2m_priv)
count = hweight32(ctx->frm_dis_flg); count = hweight32(ctx->frm_dis_flg);
if (ctx->use_vdoa && count >= (ctx->num_internal_frames - 1)) { if (ctx->use_vdoa && count >= (ctx->num_internal_frames - 1)) {
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx,
"%d: not ready: all internal buffers in use: %d/%d (0x%x)", "not ready: all internal buffers in use: %d/%d (0x%x)",
ctx->idx, count, ctx->num_internal_frames, count, ctx->num_internal_frames,
ctx->frm_dis_flg); ctx->frm_dis_flg);
return 0; return 0;
} }
if (ctx->hold && !src_bufs) { if (ctx->hold && !src_bufs) {
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx,
"%d: not ready: on hold for more buffers.\n", "not ready: on hold for more buffers.\n");
ctx->idx);
return 0; return 0;
} }
if (!stream_end && (num_metas + src_bufs) < 2) { if (!stream_end && (num_metas + src_bufs) < 2) {
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx,
"%d: not ready: need 2 buffers available (queue:%d + bitstream:%d)\n", "not ready: need 2 buffers available (queue:%d + bitstream:%d)\n",
ctx->idx, num_metas, src_bufs); num_metas, src_bufs);
return 0; return 0;
} }
@ -1346,7 +1342,7 @@ static int coda_job_ready(void *m2m_priv)
struct coda_buffer_meta, list); struct coda_buffer_meta, list);
if (!coda_bitstream_can_fetch_past(ctx, meta->end) && if (!coda_bitstream_can_fetch_past(ctx, meta->end) &&
!stream_end) { !stream_end) {
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx,
"not ready: not enough bitstream data to read past %u (%u)\n", "not ready: not enough bitstream data to read past %u (%u)\n",
meta->end, ctx->bitstream_fifo.kfifo.in); meta->end, ctx->bitstream_fifo.kfifo.in);
return 0; return 0;
@ -1354,13 +1350,11 @@ static int coda_job_ready(void *m2m_priv)
} }
if (ctx->aborting) { if (ctx->aborting) {
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "not ready: aborting\n");
"not ready: aborting\n");
return 0; return 0;
} }
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "job ready\n");
"job ready\n");
return 1; return 1;
} }
@ -1371,8 +1365,7 @@ static void coda_job_abort(void *priv)
ctx->aborting = 1; ctx->aborting = 1;
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "job abort\n");
"Aborting task\n");
} }
static const struct v4l2_m2m_ops coda_m2m_ops = { static const struct v4l2_m2m_ops coda_m2m_ops = {
@ -1449,8 +1442,8 @@ static int coda_queue_setup(struct vb2_queue *vq,
*nplanes = 1; *nplanes = 1;
sizes[0] = size; sizes[0] = size;
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "get %d buffer(s) of size %d each.\n", *nbuffers,
"get %d buffer(s) of size %d each.\n", *nbuffers, size); size);
return 0; return 0;
} }
@ -1515,8 +1508,7 @@ static void coda_update_h264_profile_ctrl(struct coda_ctx *ctx)
profile_names = v4l2_ctrl_get_menu(V4L2_CID_MPEG_VIDEO_H264_PROFILE); profile_names = v4l2_ctrl_get_menu(V4L2_CID_MPEG_VIDEO_H264_PROFILE);
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, "Parsed H264 Profile: %s\n", coda_dbg(1, ctx, "Parsed H264 Profile: %s\n", profile_names[profile]);
profile_names[profile]);
} }
static void coda_update_h264_level_ctrl(struct coda_ctx *ctx) static void coda_update_h264_level_ctrl(struct coda_ctx *ctx)
@ -1535,8 +1527,7 @@ static void coda_update_h264_level_ctrl(struct coda_ctx *ctx)
level_names = v4l2_ctrl_get_menu(V4L2_CID_MPEG_VIDEO_H264_LEVEL); level_names = v4l2_ctrl_get_menu(V4L2_CID_MPEG_VIDEO_H264_LEVEL);
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, "Parsed H264 Level: %s\n", coda_dbg(1, ctx, "Parsed H264 Level: %s\n", level_names[level]);
level_names[level]);
} }
static void coda_buf_queue(struct vb2_buffer *vb) static void coda_buf_queue(struct vb2_buffer *vb)
@ -1641,6 +1632,8 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
if (count < 1) if (count < 1)
return -EINVAL; return -EINVAL;
coda_dbg(1, ctx, "start streaming %s\n", v4l2_type_names[q->type]);
INIT_LIST_HEAD(&list); INIT_LIST_HEAD(&list);
q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
@ -1737,9 +1730,9 @@ static void coda_stop_streaming(struct vb2_queue *q)
stop = ctx->streamon_out && ctx->streamon_cap; stop = ctx->streamon_out && ctx->streamon_cap;
coda_dbg(1, ctx, "stop streaming %s\n", v4l2_type_names[q->type]);
if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
v4l2_dbg(1, coda_debug, &dev->v4l2_dev,
"%s: output\n", __func__);
ctx->streamon_out = 0; ctx->streamon_out = 0;
coda_bit_stream_end_flag(ctx); coda_bit_stream_end_flag(ctx);
@ -1749,8 +1742,6 @@ static void coda_stop_streaming(struct vb2_queue *q)
while ((buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx))) while ((buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx)))
v4l2_m2m_buf_done(buf, VB2_BUF_STATE_ERROR); v4l2_m2m_buf_done(buf, VB2_BUF_STATE_ERROR);
} else { } else {
v4l2_dbg(1, coda_debug, &dev->v4l2_dev,
"%s: capture\n", __func__);
ctx->streamon_cap = 0; ctx->streamon_cap = 0;
ctx->osequence = 0; ctx->osequence = 0;
@ -1802,8 +1793,8 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl)
struct coda_ctx *ctx = struct coda_ctx *ctx =
container_of(ctrl->handler, struct coda_ctx, ctrls); container_of(ctrl->handler, struct coda_ctx, ctrls);
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "s_ctrl: id = 0x%x, name = \"%s\", val = %d\n",
"s_ctrl: id = %d, val = %d\n", ctrl->id, ctrl->val); ctrl->id, ctrl->name, ctrl->val);
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_HFLIP: case V4L2_CID_HFLIP:
@ -1894,9 +1885,8 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl)
ctx->params.vbv_size = min(ctrl->val * 8192, 0x7fffffff); ctx->params.vbv_size = min(ctrl->val * 8192, 0x7fffffff);
break; break;
default: default:
v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, coda_dbg(1, ctx, "Invalid control, id=%d, val=%d\n",
"Invalid control, id=%d, val=%d\n", ctrl->id, ctrl->val);
ctrl->id, ctrl->val);
return -EINVAL; return -EINVAL;
} }
@ -2192,6 +2182,9 @@ static int coda_open(struct file *file)
v4l2_fh_add(&ctx->fh); v4l2_fh_add(&ctx->fh);
ctx->dev = dev; ctx->dev = dev;
ctx->idx = idx; ctx->idx = idx;
coda_dbg(1, ctx, "open instance (%p)\n", ctx);
switch (dev->devtype->product) { switch (dev->devtype->product) {
case CODA_960: case CODA_960:
/* /*
@ -2257,9 +2250,6 @@ static int coda_open(struct file *file)
INIT_LIST_HEAD(&ctx->buffer_meta_list); INIT_LIST_HEAD(&ctx->buffer_meta_list);
spin_lock_init(&ctx->buffer_meta_lock); spin_lock_init(&ctx->buffer_meta_lock);
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, "Created instance %d (%p)\n",
ctx->idx, ctx);
return 0; return 0;
err_ctrls_setup: err_ctrls_setup:
@ -2285,8 +2275,7 @@ static int coda_release(struct file *file)
struct coda_dev *dev = video_drvdata(file); struct coda_dev *dev = video_drvdata(file);
struct coda_ctx *ctx = fh_to_ctx(file->private_data); struct coda_ctx *ctx = fh_to_ctx(file->private_data);
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, "Releasing instance %p\n", coda_dbg(1, ctx, "release instance (%p)\n", ctx);
ctx);
if (ctx->inst_type == CODA_INST_DECODER && ctx->use_bit) if (ctx->inst_type == CODA_INST_DECODER && ctx->use_bit)
coda_bit_stream_end_flag(ctx); coda_bit_stream_end_flag(ctx);

View File

@ -252,6 +252,13 @@ struct coda_ctx {
extern int coda_debug; extern int coda_debug;
#define coda_dbg(level, ctx, fmt, arg...) \
do { \
if (coda_debug >= (level)) \
v4l2_dbg((level), coda_debug, &(ctx)->dev->v4l2_dev, \
"%u: " fmt, (ctx)->idx, ##arg); \
} while (0)
void coda_write(struct coda_dev *dev, u32 data, u32 reg); void coda_write(struct coda_dev *dev, u32 data, u32 reg);
unsigned int coda_read(struct coda_dev *dev, u32 reg); unsigned int coda_read(struct coda_dev *dev, u32 reg);
void coda_write_base(struct coda_ctx *ctx, struct coda_q_data *q_data, void coda_write_base(struct coda_ctx *ctx, struct coda_q_data *q_data,