xref: /linux/include/trace/events/v4l2.h (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM v4l2
3 
4 #if !defined(_TRACE_V4L2_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_V4L2_H
6 
7 #include <linux/tracepoint.h>
8 
9 /* Enums require being exported to userspace, for user tool parsing */
10 #undef EM
11 #undef EMe
12 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
13 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
14 
15 #define show_type(type)							\
16 	__print_symbolic(type, SHOW_TYPE)
17 
18 #define SHOW_TYPE							\
19 	EM( V4L2_BUF_TYPE_VIDEO_CAPTURE,	"VIDEO_CAPTURE" )	\
20 	EM( V4L2_BUF_TYPE_VIDEO_OUTPUT,		"VIDEO_OUTPUT" )	\
21 	EM( V4L2_BUF_TYPE_VIDEO_OVERLAY,	"VIDEO_OVERLAY" )	\
22 	EM( V4L2_BUF_TYPE_VBI_CAPTURE,		"VBI_CAPTURE" )		\
23 	EM( V4L2_BUF_TYPE_VBI_OUTPUT,		"VBI_OUTPUT" )		\
24 	EM( V4L2_BUF_TYPE_SLICED_VBI_CAPTURE,   "SLICED_VBI_CAPTURE" )	\
25 	EM( V4L2_BUF_TYPE_SLICED_VBI_OUTPUT,    "SLICED_VBI_OUTPUT" )	\
26 	EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" ) \
27 	EM( V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" ) \
28 	EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,  "VIDEO_OUTPUT_MPLANE" )	\
29 	EM( V4L2_BUF_TYPE_SDR_CAPTURE,          "SDR_CAPTURE" )		\
30 	EMe(V4L2_BUF_TYPE_PRIVATE,		"PRIVATE" )
31 
32 SHOW_TYPE
33 
34 #define show_field(field)						\
35 	__print_symbolic(field, SHOW_FIELD)
36 
37 #define SHOW_FIELD							\
38 	EM( V4L2_FIELD_ANY,		"ANY" )				\
39 	EM( V4L2_FIELD_NONE,		"NONE" )			\
40 	EM( V4L2_FIELD_TOP,		"TOP" )				\
41 	EM( V4L2_FIELD_BOTTOM,		"BOTTOM" )			\
42 	EM( V4L2_FIELD_INTERLACED,	"INTERLACED" )			\
43 	EM( V4L2_FIELD_SEQ_TB,		"SEQ_TB" )			\
44 	EM( V4L2_FIELD_SEQ_BT,		"SEQ_BT" )			\
45 	EM( V4L2_FIELD_ALTERNATE,	"ALTERNATE" )			\
46 	EM( V4L2_FIELD_INTERLACED_TB,	"INTERLACED_TB" )		\
47 	EMe( V4L2_FIELD_INTERLACED_BT,	"INTERLACED_BT" )
48 
49 SHOW_FIELD
50 
51 /*
52  * Now redefine the EM() and EMe() macros to map the enums to the strings
53  * that will be printed in the output.
54  */
55 #undef EM
56 #undef EMe
57 #define EM(a, b)	{a, b},
58 #define EMe(a, b)	{a, b}
59 
60 /* V4L2_TC_TYPE_* are macros, not defines, they do not need processing */
61 
62 #define show_timecode_type(type)					\
63 	__print_symbolic(type,						\
64 		{ V4L2_TC_TYPE_24FPS,		"24FPS" },		\
65 		{ V4L2_TC_TYPE_25FPS,		"25FPS" },		\
66 		{ V4L2_TC_TYPE_30FPS,		"30FPS" },		\
67 		{ V4L2_TC_TYPE_50FPS,		"50FPS" },		\
68 		{ V4L2_TC_TYPE_60FPS,		"60FPS" })
69 
70 #define show_flags(flags)						      \
71 	__print_flags(flags, "|",					      \
72 		{ V4L2_BUF_FLAG_MAPPED,		     "MAPPED" },	      \
73 		{ V4L2_BUF_FLAG_QUEUED,		     "QUEUED" },	      \
74 		{ V4L2_BUF_FLAG_DONE,		     "DONE" },		      \
75 		{ V4L2_BUF_FLAG_KEYFRAME,	     "KEYFRAME" },	      \
76 		{ V4L2_BUF_FLAG_PFRAME,		     "PFRAME" },	      \
77 		{ V4L2_BUF_FLAG_BFRAME,		     "BFRAME" },	      \
78 		{ V4L2_BUF_FLAG_ERROR,		     "ERROR" },		      \
79 		{ V4L2_BUF_FLAG_TIMECODE,	     "TIMECODE" },	      \
80 		{ V4L2_BUF_FLAG_PREPARED,	     "PREPARED" },	      \
81 		{ V4L2_BUF_FLAG_NO_CACHE_INVALIDATE, "NO_CACHE_INVALIDATE" }, \
82 		{ V4L2_BUF_FLAG_NO_CACHE_CLEAN,	     "NO_CACHE_CLEAN" },      \
83 		{ V4L2_BUF_FLAG_TIMESTAMP_MASK,	     "TIMESTAMP_MASK" },      \
84 		{ V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN,   "TIMESTAMP_UNKNOWN" },   \
85 		{ V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC, "TIMESTAMP_MONOTONIC" }, \
86 		{ V4L2_BUF_FLAG_TIMESTAMP_COPY,	     "TIMESTAMP_COPY" },      \
87 		{ V4L2_BUF_FLAG_LAST,                "LAST" })
88 
89 #define show_timecode_flags(flags)					  \
90 	__print_flags(flags, "|",					  \
91 		{ V4L2_TC_FLAG_DROPFRAME,       "DROPFRAME" },		  \
92 		{ V4L2_TC_FLAG_COLORFRAME,      "COLORFRAME" },		  \
93 		{ V4L2_TC_USERBITS_USERDEFINED,	"USERBITS_USERDEFINED" }, \
94 		{ V4L2_TC_USERBITS_8BITCHARS,	"USERBITS_8BITCHARS" })
95 
96 DECLARE_EVENT_CLASS(v4l2_event_class,
97 	TP_PROTO(int minor, struct v4l2_buffer *buf),
98 
99 	TP_ARGS(minor, buf),
100 
101 	TP_STRUCT__entry(
102 		__field(int, minor)
103 		__field(u32, index)
104 		__field(u32, type)
105 		__field(u32, bytesused)
106 		__field(u32, flags)
107 		__field(u32, field)
108 		__field(s64, timestamp)
109 		__field(u32, timecode_type)
110 		__field(u32, timecode_flags)
111 		__field(u8, timecode_frames)
112 		__field(u8, timecode_seconds)
113 		__field(u8, timecode_minutes)
114 		__field(u8, timecode_hours)
115 		__field(u8, timecode_userbits0)
116 		__field(u8, timecode_userbits1)
117 		__field(u8, timecode_userbits2)
118 		__field(u8, timecode_userbits3)
119 		__field(u32, sequence)
120 	),
121 
122 	TP_fast_assign(
123 		__entry->minor = minor;
124 		__entry->index = buf->index;
125 		__entry->type = buf->type;
126 		__entry->bytesused = buf->bytesused;
127 		__entry->flags = buf->flags;
128 		__entry->field = buf->field;
129 		__entry->timestamp = timeval_to_ns(&buf->timestamp);
130 		__entry->timecode_type = buf->timecode.type;
131 		__entry->timecode_flags = buf->timecode.flags;
132 		__entry->timecode_frames = buf->timecode.frames;
133 		__entry->timecode_seconds = buf->timecode.seconds;
134 		__entry->timecode_minutes = buf->timecode.minutes;
135 		__entry->timecode_hours = buf->timecode.hours;
136 		__entry->timecode_userbits0 = buf->timecode.userbits[0];
137 		__entry->timecode_userbits1 = buf->timecode.userbits[1];
138 		__entry->timecode_userbits2 = buf->timecode.userbits[2];
139 		__entry->timecode_userbits3 = buf->timecode.userbits[3];
140 		__entry->sequence = buf->sequence;
141 	),
142 
143 	TP_printk("minor = %d, index = %u, type = %s, bytesused = %u, "
144 		  "flags = %s, field = %s, timestamp = %llu, "
145 		  "timecode = { type = %s, flags = %s, frames = %u, "
146 		  "seconds = %u, minutes = %u, hours = %u, "
147 		  "userbits = { %u %u %u %u } }, sequence = %u", __entry->minor,
148 		  __entry->index, show_type(__entry->type),
149 		  __entry->bytesused,
150 		  show_flags(__entry->flags),
151 		  show_field(__entry->field),
152 		  __entry->timestamp,
153 		  show_timecode_type(__entry->timecode_type),
154 		  show_timecode_flags(__entry->timecode_flags),
155 		  __entry->timecode_frames,
156 		  __entry->timecode_seconds,
157 		  __entry->timecode_minutes,
158 		  __entry->timecode_hours,
159 		  __entry->timecode_userbits0,
160 		  __entry->timecode_userbits1,
161 		  __entry->timecode_userbits2,
162 		  __entry->timecode_userbits3,
163 		  __entry->sequence
164 	)
165 )
166 
167 DEFINE_EVENT(v4l2_event_class, v4l2_dqbuf,
168 	TP_PROTO(int minor, struct v4l2_buffer *buf),
169 	TP_ARGS(minor, buf)
170 );
171 
172 DEFINE_EVENT(v4l2_event_class, v4l2_qbuf,
173 	TP_PROTO(int minor, struct v4l2_buffer *buf),
174 	TP_ARGS(minor, buf)
175 );
176 
177 DECLARE_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 
254 DEFINE_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 
259 DEFINE_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 
264 DEFINE_EVENT(vb2_event_class, vb2_dqbuf,
265 	TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
266 	TP_ARGS(q, vb)
267 );
268 
269 DEFINE_EVENT(vb2_event_class, vb2_qbuf,
270 	TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
271 	TP_ARGS(q, vb)
272 );
273 
274 #endif /* if !defined(_TRACE_V4L2_H) || defined(TRACE_HEADER_MULTI_READ) */
275 
276 /* This part must be outside protection */
277 #include <trace/define_trace.h>
278