Skip to content

Commit c89ee8e

Browse files
ezequielgarciamchehab
authored andcommitted
media: videobuf2: Print videobuf2 buffer state by name
For debugging purposes, seeing the state integer representation is really inconvenient. Improve this and be developer-friendly by printing the state name instead. Suggested-by: Nicolas Dufresne <[email protected]> Signed-off-by: Ezequiel Garcia <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 1c79e41 commit c89ee8e

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

drivers/media/common/videobuf2/videobuf2-core.c

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,23 @@ module_param(debug, int, 0644);
191191
static void __vb2_queue_cancel(struct vb2_queue *q);
192192
static void __enqueue_in_driver(struct vb2_buffer *vb);
193193

194+
static const char *vb2_state_name(enum vb2_buffer_state s)
195+
{
196+
static const char * const state_names[] = {
197+
[VB2_BUF_STATE_DEQUEUED] = "dequeued",
198+
[VB2_BUF_STATE_IN_REQUEST] = "in request",
199+
[VB2_BUF_STATE_PREPARING] = "preparing",
200+
[VB2_BUF_STATE_QUEUED] = "queued",
201+
[VB2_BUF_STATE_ACTIVE] = "active",
202+
[VB2_BUF_STATE_DONE] = "done",
203+
[VB2_BUF_STATE_ERROR] = "error",
204+
};
205+
206+
if ((unsigned int)(s) < ARRAY_SIZE(state_names))
207+
return state_names[s];
208+
return "unknown";
209+
}
210+
194211
/*
195212
* __vb2_buf_mem_alloc() - allocate video memory for the given buffer
196213
*/
@@ -1015,8 +1032,8 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
10151032
*/
10161033
vb->cnt_buf_done++;
10171034
#endif
1018-
dprintk(q, 4, "done processing on buffer %d, state: %d\n",
1019-
vb->index, state);
1035+
dprintk(q, 4, "done processing on buffer %d, state: %s\n",
1036+
vb->index, vb2_state_name(state));
10201037

10211038
if (state != VB2_BUF_STATE_QUEUED)
10221039
__vb2_buf_mem_finish(vb);
@@ -1490,8 +1507,8 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
14901507

14911508
vb = q->bufs[index];
14921509
if (vb->state != VB2_BUF_STATE_DEQUEUED) {
1493-
dprintk(q, 1, "invalid buffer state %d\n",
1494-
vb->state);
1510+
dprintk(q, 1, "invalid buffer state %s\n",
1511+
vb2_state_name(vb->state));
14951512
return -EINVAL;
14961513
}
14971514
if (vb->prepared) {
@@ -1670,7 +1687,8 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb,
16701687
dprintk(q, 1, "buffer still being prepared\n");
16711688
return -EINVAL;
16721689
default:
1673-
dprintk(q, 1, "invalid buffer state %d\n", vb->state);
1690+
dprintk(q, 1, "invalid buffer state %s\n",
1691+
vb2_state_name(vb->state));
16741692
return -EINVAL;
16751693
}
16761694

@@ -1884,7 +1902,8 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
18841902
dprintk(q, 3, "returning done buffer with errors\n");
18851903
break;
18861904
default:
1887-
dprintk(q, 1, "invalid buffer state\n");
1905+
dprintk(q, 1, "invalid buffer state %s\n",
1906+
vb2_state_name(vb->state));
18881907
return -EINVAL;
18891908
}
18901909

@@ -1915,8 +1934,8 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
19151934
media_request_put(vb->request);
19161935
vb->request = NULL;
19171936

1918-
dprintk(q, 2, "dqbuf of buffer %d, with state %d\n",
1919-
vb->index, vb->state);
1937+
dprintk(q, 2, "dqbuf of buffer %d, state: %s\n",
1938+
vb->index, vb2_state_name(vb->state));
19201939

19211940
return 0;
19221941

0 commit comments

Comments
 (0)