aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2015-07-10 09:49:26 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-07-17 11:04:12 -0400
commit2091f5181c66b3617a977e79843aba10e087be6c (patch)
tree69052ff35a8795ff3c17904ebe59ad5949f58d60
parentc13a5ccf5da86239213033214658b8a170eeab87 (diff)
[media] videobuf2: add trace events
Add videobuf2 specific vb2_qbuf and vb2_dqbuf trace events that mirror the v4l2_qbuf and v4l2_dqbuf trace events, only they include additional information about queue fill state and are emitted right before the buffer is enqueued in the driver or userspace is woken up. This allows to make sense of the timeline of trace events in combination with others that might be triggered by __enqueue_in_driver. Also two new trace events vb2_buf_queue and vb2_buf_done are added, allowing to trace the handover between videobuf2 framework and driver. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c11
-rw-r--r--include/trace/events/v4l2.h97
2 files changed, 108 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 93b315459098..b866a6becd99 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -30,6 +30,8 @@
30#include <media/v4l2-common.h> 30#include <media/v4l2-common.h>
31#include <media/videobuf2-core.h> 31#include <media/videobuf2-core.h>
32 32
33#include <trace/events/v4l2.h>
34
33static int debug; 35static int debug;
34module_param(debug, int, 0644); 36module_param(debug, int, 0644);
35 37
@@ -1207,6 +1209,8 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
1207 atomic_dec(&q->owned_by_drv_count); 1209 atomic_dec(&q->owned_by_drv_count);
1208 spin_unlock_irqrestore(&q->done_lock, flags); 1210 spin_unlock_irqrestore(&q->done_lock, flags);
1209 1211
1212 trace_vb2_buf_done(q, vb);
1213
1210 if (state == VB2_BUF_STATE_QUEUED) { 1214 if (state == VB2_BUF_STATE_QUEUED) {
1211 if (q->start_streaming_called) 1215 if (q->start_streaming_called)
1212 __enqueue_in_driver(vb); 1216 __enqueue_in_driver(vb);
@@ -1629,6 +1633,8 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
1629 vb->state = VB2_BUF_STATE_ACTIVE; 1633 vb->state = VB2_BUF_STATE_ACTIVE;
1630 atomic_inc(&q->owned_by_drv_count); 1634 atomic_inc(&q->owned_by_drv_count);
1631 1635
1636 trace_vb2_buf_queue(q, vb);
1637
1632 /* sync buffers */ 1638 /* sync buffers */
1633 for (plane = 0; plane < vb->num_planes; ++plane) 1639 for (plane = 0; plane < vb->num_planes; ++plane)
1634 call_void_memop(vb, prepare, vb->planes[plane].mem_priv); 1640 call_void_memop(vb, prepare, vb->planes[plane].mem_priv);
@@ -1878,6 +1884,8 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
1878 vb->v4l2_buf.timecode = b->timecode; 1884 vb->v4l2_buf.timecode = b->timecode;
1879 } 1885 }
1880 1886
1887 trace_vb2_qbuf(q, vb);
1888
1881 /* 1889 /*
1882 * If already streaming, give the buffer to driver for processing. 1890 * If already streaming, give the buffer to driver for processing.
1883 * If not, the buffer will be given to driver on next streamon. 1891 * If not, the buffer will be given to driver on next streamon.
@@ -2123,6 +2131,9 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n
2123 /* Remove from videobuf queue */ 2131 /* Remove from videobuf queue */
2124 list_del(&vb->queued_entry); 2132 list_del(&vb->queued_entry);
2125 q->queued_count--; 2133 q->queued_count--;
2134
2135 trace_vb2_dqbuf(q, vb);
2136
2126 if (!V4L2_TYPE_IS_OUTPUT(q->type) && 2137 if (!V4L2_TYPE_IS_OUTPUT(q->type) &&
2127 vb->v4l2_buf.flags & V4L2_BUF_FLAG_LAST) 2138 vb->v4l2_buf.flags & V4L2_BUF_FLAG_LAST)
2128 q->last_buffer_dequeued = true; 2139 q->last_buffer_dequeued = true;
diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
index 4c88a3241c18..dbf017bfddd9 100644
--- a/include/trace/events/v4l2.h
+++ b/include/trace/events/v4l2.h
@@ -174,6 +174,103 @@ DEFINE_EVENT(v4l2_event_class, v4l2_qbuf,
174 TP_ARGS(minor, buf) 174 TP_ARGS(minor, buf)
175); 175);
176 176
177DECLARE_EVENT_CLASS(vb2_event_class,
178 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
179 TP_ARGS(q, vb),
180
181 TP_STRUCT__entry(
182 __field(int, minor)
183 __field(u32, queued_count)
184 __field(int, owned_by_drv_count)
185 __field(u32, index)
186 __field(u32, type)
187 __field(u32, bytesused)
188 __field(u32, flags)
189 __field(u32, field)
190 __field(s64, timestamp)
191 __field(u32, timecode_type)
192 __field(u32, timecode_flags)
193 __field(u8, timecode_frames)
194 __field(u8, timecode_seconds)
195 __field(u8, timecode_minutes)
196 __field(u8, timecode_hours)
197 __field(u8, timecode_userbits0)
198 __field(u8, timecode_userbits1)
199 __field(u8, timecode_userbits2)
200 __field(u8, timecode_userbits3)
201 __field(u32, sequence)
202 ),
203
204 TP_fast_assign(
205 __entry->minor = q->owner ? q->owner->vdev->minor : -1;
206 __entry->queued_count = q->queued_count;
207 __entry->owned_by_drv_count =
208 atomic_read(&q->owned_by_drv_count);
209 __entry->index = vb->v4l2_buf.index;
210 __entry->type = vb->v4l2_buf.type;
211 __entry->bytesused = vb->v4l2_planes[0].bytesused;
212 __entry->flags = vb->v4l2_buf.flags;
213 __entry->field = vb->v4l2_buf.field;
214 __entry->timestamp = timeval_to_ns(&vb->v4l2_buf.timestamp);
215 __entry->timecode_type = vb->v4l2_buf.timecode.type;
216 __entry->timecode_flags = vb->v4l2_buf.timecode.flags;
217 __entry->timecode_frames = vb->v4l2_buf.timecode.frames;
218 __entry->timecode_seconds = vb->v4l2_buf.timecode.seconds;
219 __entry->timecode_minutes = vb->v4l2_buf.timecode.minutes;
220 __entry->timecode_hours = vb->v4l2_buf.timecode.hours;
221 __entry->timecode_userbits0 = vb->v4l2_buf.timecode.userbits[0];
222 __entry->timecode_userbits1 = vb->v4l2_buf.timecode.userbits[1];
223 __entry->timecode_userbits2 = vb->v4l2_buf.timecode.userbits[2];
224 __entry->timecode_userbits3 = vb->v4l2_buf.timecode.userbits[3];
225 __entry->sequence = vb->v4l2_buf.sequence;
226 ),
227
228 TP_printk("minor = %d, queued = %u, owned_by_drv = %d, index = %u, "
229 "type = %s, bytesused = %u, flags = %s, field = %s, "
230 "timestamp = %llu, timecode = { type = %s, flags = %s, "
231 "frames = %u, seconds = %u, minutes = %u, hours = %u, "
232 "userbits = { %u %u %u %u } }, sequence = %u", __entry->minor,
233 __entry->queued_count,
234 __entry->owned_by_drv_count,
235 __entry->index, show_type(__entry->type),
236 __entry->bytesused,
237 show_flags(__entry->flags),
238 show_field(__entry->field),
239 __entry->timestamp,
240 show_timecode_type(__entry->timecode_type),
241 show_timecode_flags(__entry->timecode_flags),
242 __entry->timecode_frames,
243 __entry->timecode_seconds,
244 __entry->timecode_minutes,
245 __entry->timecode_hours,
246 __entry->timecode_userbits0,
247 __entry->timecode_userbits1,
248 __entry->timecode_userbits2,
249 __entry->timecode_userbits3,
250 __entry->sequence
251 )
252)
253
254DEFINE_EVENT(vb2_event_class, vb2_buf_done,
255 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
256 TP_ARGS(q, vb)
257);
258
259DEFINE_EVENT(vb2_event_class, vb2_buf_queue,
260 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
261 TP_ARGS(q, vb)
262);
263
264DEFINE_EVENT(vb2_event_class, vb2_dqbuf,
265 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
266 TP_ARGS(q, vb)
267);
268
269DEFINE_EVENT(vb2_event_class, vb2_qbuf,
270 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
271 TP_ARGS(q, vb)
272);
273
177#endif /* if !defined(_TRACE_V4L2_H) || defined(TRACE_HEADER_MULTI_READ) */ 274#endif /* if !defined(_TRACE_V4L2_H) || defined(TRACE_HEADER_MULTI_READ) */
178 275
179/* This part must be outside protection */ 276/* This part must be outside protection */