xref: /openbmc/linux/include/trace/events/v4l2.h (revision 9cfc5c90)
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 #include <media/videobuf2-v4l2.h>
9 
10 /* Enums require being exported to userspace, for user tool parsing */
11 #undef EM
12 #undef EMe
13 #define EM(a, b)	TRACE_DEFINE_ENUM(a);
14 #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
15 
16 #define show_type(type)							\
17 	__print_symbolic(type, SHOW_TYPE)
18 
19 #define SHOW_TYPE							\
20 	EM( V4L2_BUF_TYPE_VIDEO_CAPTURE,	"VIDEO_CAPTURE" )	\
21 	EM( V4L2_BUF_TYPE_VIDEO_OUTPUT,		"VIDEO_OUTPUT" )	\
22 	EM( V4L2_BUF_TYPE_VIDEO_OVERLAY,	"VIDEO_OVERLAY" )	\
23 	EM( V4L2_BUF_TYPE_VBI_CAPTURE,		"VBI_CAPTURE" )		\
24 	EM( V4L2_BUF_TYPE_VBI_OUTPUT,		"VBI_OUTPUT" )		\
25 	EM( V4L2_BUF_TYPE_SLICED_VBI_CAPTURE,   "SLICED_VBI_CAPTURE" )	\
26 	EM( V4L2_BUF_TYPE_SLICED_VBI_OUTPUT,    "SLICED_VBI_OUTPUT" )	\
27 	EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" ) \
28 	EM( V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" ) \
29 	EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,  "VIDEO_OUTPUT_MPLANE" )	\
30 	EM( V4L2_BUF_TYPE_SDR_CAPTURE,          "SDR_CAPTURE" )		\
31 	EM( V4L2_BUF_TYPE_SDR_OUTPUT,           "SDR_OUTPUT" )		\
32 	EMe(V4L2_BUF_TYPE_PRIVATE,		"PRIVATE" )
33 
34 SHOW_TYPE
35 
36 #define show_field(field)						\
37 	__print_symbolic(field, SHOW_FIELD)
38 
39 #define SHOW_FIELD							\
40 	EM( V4L2_FIELD_ANY,		"ANY" )				\
41 	EM( V4L2_FIELD_NONE,		"NONE" )			\
42 	EM( V4L2_FIELD_TOP,		"TOP" )				\
43 	EM( V4L2_FIELD_BOTTOM,		"BOTTOM" )			\
44 	EM( V4L2_FIELD_INTERLACED,	"INTERLACED" )			\
45 	EM( V4L2_FIELD_SEQ_TB,		"SEQ_TB" )			\
46 	EM( V4L2_FIELD_SEQ_BT,		"SEQ_BT" )			\
47 	EM( V4L2_FIELD_ALTERNATE,	"ALTERNATE" )			\
48 	EM( V4L2_FIELD_INTERLACED_TB,	"INTERLACED_TB" )		\
49 	EMe( V4L2_FIELD_INTERLACED_BT,	"INTERLACED_BT" )
50 
51 SHOW_FIELD
52 
53 /*
54  * Now redefine the EM() and EMe() macros to map the enums to the strings
55  * that will be printed in the output.
56  */
57 #undef EM
58 #undef EMe
59 #define EM(a, b)	{a, b},
60 #define EMe(a, b)	{a, b}
61 
62 /* V4L2_TC_TYPE_* are macros, not defines, they do not need processing */
63 
64 #define show_timecode_type(type)					\
65 	__print_symbolic(type,						\
66 		{ V4L2_TC_TYPE_24FPS,		"24FPS" },		\
67 		{ V4L2_TC_TYPE_25FPS,		"25FPS" },		\
68 		{ V4L2_TC_TYPE_30FPS,		"30FPS" },		\
69 		{ V4L2_TC_TYPE_50FPS,		"50FPS" },		\
70 		{ V4L2_TC_TYPE_60FPS,		"60FPS" })
71 
72 #define show_flags(flags)						      \
73 	__print_flags(flags, "|",					      \
74 		{ V4L2_BUF_FLAG_MAPPED,		     "MAPPED" },	      \
75 		{ V4L2_BUF_FLAG_QUEUED,		     "QUEUED" },	      \
76 		{ V4L2_BUF_FLAG_DONE,		     "DONE" },		      \
77 		{ V4L2_BUF_FLAG_KEYFRAME,	     "KEYFRAME" },	      \
78 		{ V4L2_BUF_FLAG_PFRAME,		     "PFRAME" },	      \
79 		{ V4L2_BUF_FLAG_BFRAME,		     "BFRAME" },	      \
80 		{ V4L2_BUF_FLAG_ERROR,		     "ERROR" },		      \
81 		{ V4L2_BUF_FLAG_TIMECODE,	     "TIMECODE" },	      \
82 		{ V4L2_BUF_FLAG_PREPARED,	     "PREPARED" },	      \
83 		{ V4L2_BUF_FLAG_NO_CACHE_INVALIDATE, "NO_CACHE_INVALIDATE" }, \
84 		{ V4L2_BUF_FLAG_NO_CACHE_CLEAN,	     "NO_CACHE_CLEAN" },      \
85 		{ V4L2_BUF_FLAG_TIMESTAMP_MASK,	     "TIMESTAMP_MASK" },      \
86 		{ V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN,   "TIMESTAMP_UNKNOWN" },   \
87 		{ V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC, "TIMESTAMP_MONOTONIC" }, \
88 		{ V4L2_BUF_FLAG_TIMESTAMP_COPY,	     "TIMESTAMP_COPY" },      \
89 		{ V4L2_BUF_FLAG_LAST,                "LAST" })
90 
91 #define show_timecode_flags(flags)					  \
92 	__print_flags(flags, "|",					  \
93 		{ V4L2_TC_FLAG_DROPFRAME,       "DROPFRAME" },		  \
94 		{ V4L2_TC_FLAG_COLORFRAME,      "COLORFRAME" },		  \
95 		{ V4L2_TC_USERBITS_USERDEFINED,	"USERBITS_USERDEFINED" }, \
96 		{ V4L2_TC_USERBITS_8BITCHARS,	"USERBITS_8BITCHARS" })
97 
98 DECLARE_EVENT_CLASS(v4l2_event_class,
99 	TP_PROTO(int minor, struct v4l2_buffer *buf),
100 
101 	TP_ARGS(minor, buf),
102 
103 	TP_STRUCT__entry(
104 		__field(int, minor)
105 		__field(u32, index)
106 		__field(u32, type)
107 		__field(u32, bytesused)
108 		__field(u32, flags)
109 		__field(u32, field)
110 		__field(s64, timestamp)
111 		__field(u32, timecode_type)
112 		__field(u32, timecode_flags)
113 		__field(u8, timecode_frames)
114 		__field(u8, timecode_seconds)
115 		__field(u8, timecode_minutes)
116 		__field(u8, timecode_hours)
117 		__field(u8, timecode_userbits0)
118 		__field(u8, timecode_userbits1)
119 		__field(u8, timecode_userbits2)
120 		__field(u8, timecode_userbits3)
121 		__field(u32, sequence)
122 	),
123 
124 	TP_fast_assign(
125 		__entry->minor = minor;
126 		__entry->index = buf->index;
127 		__entry->type = buf->type;
128 		__entry->bytesused = buf->bytesused;
129 		__entry->flags = buf->flags;
130 		__entry->field = buf->field;
131 		__entry->timestamp = timeval_to_ns(&buf->timestamp);
132 		__entry->timecode_type = buf->timecode.type;
133 		__entry->timecode_flags = buf->timecode.flags;
134 		__entry->timecode_frames = buf->timecode.frames;
135 		__entry->timecode_seconds = buf->timecode.seconds;
136 		__entry->timecode_minutes = buf->timecode.minutes;
137 		__entry->timecode_hours = buf->timecode.hours;
138 		__entry->timecode_userbits0 = buf->timecode.userbits[0];
139 		__entry->timecode_userbits1 = buf->timecode.userbits[1];
140 		__entry->timecode_userbits2 = buf->timecode.userbits[2];
141 		__entry->timecode_userbits3 = buf->timecode.userbits[3];
142 		__entry->sequence = buf->sequence;
143 	),
144 
145 	TP_printk("minor = %d, index = %u, type = %s, bytesused = %u, "
146 		  "flags = %s, field = %s, timestamp = %llu, "
147 		  "timecode = { type = %s, flags = %s, frames = %u, "
148 		  "seconds = %u, minutes = %u, hours = %u, "
149 		  "userbits = { %u %u %u %u } }, sequence = %u", __entry->minor,
150 		  __entry->index, show_type(__entry->type),
151 		  __entry->bytesused,
152 		  show_flags(__entry->flags),
153 		  show_field(__entry->field),
154 		  __entry->timestamp,
155 		  show_timecode_type(__entry->timecode_type),
156 		  show_timecode_flags(__entry->timecode_flags),
157 		  __entry->timecode_frames,
158 		  __entry->timecode_seconds,
159 		  __entry->timecode_minutes,
160 		  __entry->timecode_hours,
161 		  __entry->timecode_userbits0,
162 		  __entry->timecode_userbits1,
163 		  __entry->timecode_userbits2,
164 		  __entry->timecode_userbits3,
165 		  __entry->sequence
166 	)
167 )
168 
169 DEFINE_EVENT(v4l2_event_class, v4l2_dqbuf,
170 	TP_PROTO(int minor, struct v4l2_buffer *buf),
171 	TP_ARGS(minor, buf)
172 );
173 
174 DEFINE_EVENT(v4l2_event_class, v4l2_qbuf,
175 	TP_PROTO(int minor, struct v4l2_buffer *buf),
176 	TP_ARGS(minor, buf)
177 );
178 
179 DECLARE_EVENT_CLASS(vb2_v4l2_event_class,
180 	TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
181 	TP_ARGS(q, vb),
182 
183 	TP_STRUCT__entry(
184 		__field(int, minor)
185 		__field(u32, flags)
186 		__field(u32, field)
187 		__field(s64, timestamp)
188 		__field(u32, timecode_type)
189 		__field(u32, timecode_flags)
190 		__field(u8, timecode_frames)
191 		__field(u8, timecode_seconds)
192 		__field(u8, timecode_minutes)
193 		__field(u8, timecode_hours)
194 		__field(u8, timecode_userbits0)
195 		__field(u8, timecode_userbits1)
196 		__field(u8, timecode_userbits2)
197 		__field(u8, timecode_userbits3)
198 		__field(u32, sequence)
199 	),
200 
201 	TP_fast_assign(
202 		struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
203 		struct v4l2_fh *owner = q->owner;
204 
205 		__entry->minor = owner ? owner->vdev->minor : -1;
206 		__entry->flags = vbuf->flags;
207 		__entry->field = vbuf->field;
208 		__entry->timestamp = timeval_to_ns(&vbuf->timestamp);
209 		__entry->timecode_type = vbuf->timecode.type;
210 		__entry->timecode_flags = vbuf->timecode.flags;
211 		__entry->timecode_frames = vbuf->timecode.frames;
212 		__entry->timecode_seconds = vbuf->timecode.seconds;
213 		__entry->timecode_minutes = vbuf->timecode.minutes;
214 		__entry->timecode_hours = vbuf->timecode.hours;
215 		__entry->timecode_userbits0 = vbuf->timecode.userbits[0];
216 		__entry->timecode_userbits1 = vbuf->timecode.userbits[1];
217 		__entry->timecode_userbits2 = vbuf->timecode.userbits[2];
218 		__entry->timecode_userbits3 = vbuf->timecode.userbits[3];
219 		__entry->sequence = vbuf->sequence;
220 	),
221 
222 	TP_printk("minor=%d flags = %s, field = %s, "
223 		  "timestamp = %llu, timecode = { type = %s, flags = %s, "
224 		  "frames = %u, seconds = %u, minutes = %u, hours = %u, "
225 		  "userbits = { %u %u %u %u } }, sequence = %u", __entry->minor,
226 		  show_flags(__entry->flags),
227 		  show_field(__entry->field),
228 		  __entry->timestamp,
229 		  show_timecode_type(__entry->timecode_type),
230 		  show_timecode_flags(__entry->timecode_flags),
231 		  __entry->timecode_frames,
232 		  __entry->timecode_seconds,
233 		  __entry->timecode_minutes,
234 		  __entry->timecode_hours,
235 		  __entry->timecode_userbits0,
236 		  __entry->timecode_userbits1,
237 		  __entry->timecode_userbits2,
238 		  __entry->timecode_userbits3,
239 		  __entry->sequence
240 	)
241 )
242 
243 DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_buf_done,
244 	TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
245 	TP_ARGS(q, vb)
246 );
247 
248 DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_buf_queue,
249 	TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
250 	TP_ARGS(q, vb)
251 );
252 
253 DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_dqbuf,
254 	TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
255 	TP_ARGS(q, vb)
256 );
257 
258 DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_qbuf,
259 	TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
260 	TP_ARGS(q, vb)
261 );
262 
263 #endif /* if !defined(_TRACE_V4L2_H) || defined(TRACE_HEADER_MULTI_READ) */
264 
265 /* This part must be outside protection */
266 #include <trace/define_trace.h>
267