blob: 83860de120e30fc9e9464263666f22d2dbc8322d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Wade Farnsworth2d012372013-11-22 16:48:28 -03002#undef TRACE_SYSTEM
3#define TRACE_SYSTEM v4l2
4
5#if !defined(_TRACE_V4L2_H) || defined(TRACE_HEADER_MULTI_READ)
6#define _TRACE_V4L2_H
7
8#include <linux/tracepoint.h>
Junghak Sungbed04f92015-10-06 06:37:47 -03009#include <media/videobuf2-v4l2.h>
Wade Farnsworth2d012372013-11-22 16:48:28 -030010
Steven Rostedt (Red Hat)43d0f712015-03-27 17:04:45 -040011/* Enums require being exported to userspace, for user tool parsing */
12#undef EM
13#undef EMe
14#define EM(a, b) TRACE_DEFINE_ENUM(a);
15#define EMe(a, b) TRACE_DEFINE_ENUM(a);
16
17#define show_type(type) \
18 __print_symbolic(type, SHOW_TYPE)
19
20#define SHOW_TYPE \
21 EM( V4L2_BUF_TYPE_VIDEO_CAPTURE, "VIDEO_CAPTURE" ) \
22 EM( V4L2_BUF_TYPE_VIDEO_OUTPUT, "VIDEO_OUTPUT" ) \
23 EM( V4L2_BUF_TYPE_VIDEO_OVERLAY, "VIDEO_OVERLAY" ) \
24 EM( V4L2_BUF_TYPE_VBI_CAPTURE, "VBI_CAPTURE" ) \
25 EM( V4L2_BUF_TYPE_VBI_OUTPUT, "VBI_OUTPUT" ) \
26 EM( V4L2_BUF_TYPE_SLICED_VBI_CAPTURE, "SLICED_VBI_CAPTURE" ) \
27 EM( V4L2_BUF_TYPE_SLICED_VBI_OUTPUT, "SLICED_VBI_OUTPUT" ) \
28 EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" ) \
29 EM( V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" ) \
30 EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, "VIDEO_OUTPUT_MPLANE" ) \
31 EM( V4L2_BUF_TYPE_SDR_CAPTURE, "SDR_CAPTURE" ) \
Antti Palosaari9effc722015-10-10 13:51:00 -030032 EM( V4L2_BUF_TYPE_SDR_OUTPUT, "SDR_OUTPUT" ) \
Laurent Pinchartfb9ffa62016-04-12 19:40:46 -030033 EM( V4L2_BUF_TYPE_META_CAPTURE, "META_CAPTURE" ) \
Steven Rostedt (Red Hat)43d0f712015-03-27 17:04:45 -040034 EMe(V4L2_BUF_TYPE_PRIVATE, "PRIVATE" )
35
36SHOW_TYPE
Wade Farnsworth2d012372013-11-22 16:48:28 -030037
38#define show_field(field) \
Steven Rostedt (Red Hat)43d0f712015-03-27 17:04:45 -040039 __print_symbolic(field, SHOW_FIELD)
40
41#define SHOW_FIELD \
42 EM( V4L2_FIELD_ANY, "ANY" ) \
43 EM( V4L2_FIELD_NONE, "NONE" ) \
44 EM( V4L2_FIELD_TOP, "TOP" ) \
45 EM( V4L2_FIELD_BOTTOM, "BOTTOM" ) \
46 EM( V4L2_FIELD_INTERLACED, "INTERLACED" ) \
47 EM( V4L2_FIELD_SEQ_TB, "SEQ_TB" ) \
48 EM( V4L2_FIELD_SEQ_BT, "SEQ_BT" ) \
49 EM( V4L2_FIELD_ALTERNATE, "ALTERNATE" ) \
50 EM( V4L2_FIELD_INTERLACED_TB, "INTERLACED_TB" ) \
51 EMe( V4L2_FIELD_INTERLACED_BT, "INTERLACED_BT" )
52
53SHOW_FIELD
54
55/*
56 * Now redefine the EM() and EMe() macros to map the enums to the strings
57 * that will be printed in the output.
58 */
59#undef EM
60#undef EMe
61#define EM(a, b) {a, b},
62#define EMe(a, b) {a, b}
63
64/* V4L2_TC_TYPE_* are macros, not defines, they do not need processing */
Wade Farnsworth2d012372013-11-22 16:48:28 -030065
66#define show_timecode_type(type) \
67 __print_symbolic(type, \
68 { V4L2_TC_TYPE_24FPS, "24FPS" }, \
69 { V4L2_TC_TYPE_25FPS, "25FPS" }, \
70 { V4L2_TC_TYPE_30FPS, "30FPS" }, \
71 { V4L2_TC_TYPE_50FPS, "50FPS" }, \
72 { V4L2_TC_TYPE_60FPS, "60FPS" })
73
74#define show_flags(flags) \
75 __print_flags(flags, "|", \
76 { V4L2_BUF_FLAG_MAPPED, "MAPPED" }, \
77 { V4L2_BUF_FLAG_QUEUED, "QUEUED" }, \
78 { V4L2_BUF_FLAG_DONE, "DONE" }, \
79 { V4L2_BUF_FLAG_KEYFRAME, "KEYFRAME" }, \
80 { V4L2_BUF_FLAG_PFRAME, "PFRAME" }, \
81 { V4L2_BUF_FLAG_BFRAME, "BFRAME" }, \
82 { V4L2_BUF_FLAG_ERROR, "ERROR" }, \
83 { V4L2_BUF_FLAG_TIMECODE, "TIMECODE" }, \
84 { V4L2_BUF_FLAG_PREPARED, "PREPARED" }, \
85 { V4L2_BUF_FLAG_NO_CACHE_INVALIDATE, "NO_CACHE_INVALIDATE" }, \
86 { V4L2_BUF_FLAG_NO_CACHE_CLEAN, "NO_CACHE_CLEAN" }, \
87 { V4L2_BUF_FLAG_TIMESTAMP_MASK, "TIMESTAMP_MASK" }, \
88 { V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN, "TIMESTAMP_UNKNOWN" }, \
89 { V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC, "TIMESTAMP_MONOTONIC" }, \
Peter Seidererdc199242015-05-04 07:51:05 -030090 { V4L2_BUF_FLAG_TIMESTAMP_COPY, "TIMESTAMP_COPY" }, \
91 { V4L2_BUF_FLAG_LAST, "LAST" })
Wade Farnsworth2d012372013-11-22 16:48:28 -030092
93#define show_timecode_flags(flags) \
94 __print_flags(flags, "|", \
95 { V4L2_TC_FLAG_DROPFRAME, "DROPFRAME" }, \
96 { V4L2_TC_FLAG_COLORFRAME, "COLORFRAME" }, \
97 { V4L2_TC_USERBITS_USERDEFINED, "USERBITS_USERDEFINED" }, \
98 { V4L2_TC_USERBITS_8BITCHARS, "USERBITS_8BITCHARS" })
99
Philipp Zabel85efe4e2015-07-10 10:49:24 -0300100DECLARE_EVENT_CLASS(v4l2_event_class,
101 TP_PROTO(int minor, struct v4l2_buffer *buf),
Wade Farnsworth2d012372013-11-22 16:48:28 -0300102
Philipp Zabel85efe4e2015-07-10 10:49:24 -0300103 TP_ARGS(minor, buf),
104
105 TP_STRUCT__entry(
106 __field(int, minor)
107 __field(u32, index)
108 __field(u32, type)
109 __field(u32, bytesused)
110 __field(u32, flags)
111 __field(u32, field)
112 __field(s64, timestamp)
113 __field(u32, timecode_type)
114 __field(u32, timecode_flags)
115 __field(u8, timecode_frames)
116 __field(u8, timecode_seconds)
117 __field(u8, timecode_minutes)
118 __field(u8, timecode_hours)
119 __field(u8, timecode_userbits0)
120 __field(u8, timecode_userbits1)
121 __field(u8, timecode_userbits2)
122 __field(u8, timecode_userbits3)
123 __field(u32, sequence)
124 ),
125
126 TP_fast_assign(
127 __entry->minor = minor;
128 __entry->index = buf->index;
129 __entry->type = buf->type;
130 __entry->bytesused = buf->bytesused;
131 __entry->flags = buf->flags;
132 __entry->field = buf->field;
133 __entry->timestamp = timeval_to_ns(&buf->timestamp);
134 __entry->timecode_type = buf->timecode.type;
135 __entry->timecode_flags = buf->timecode.flags;
136 __entry->timecode_frames = buf->timecode.frames;
137 __entry->timecode_seconds = buf->timecode.seconds;
138 __entry->timecode_minutes = buf->timecode.minutes;
139 __entry->timecode_hours = buf->timecode.hours;
140 __entry->timecode_userbits0 = buf->timecode.userbits[0];
141 __entry->timecode_userbits1 = buf->timecode.userbits[1];
142 __entry->timecode_userbits2 = buf->timecode.userbits[2];
143 __entry->timecode_userbits3 = buf->timecode.userbits[3];
144 __entry->sequence = buf->sequence;
145 ),
146
147 TP_printk("minor = %d, index = %u, type = %s, bytesused = %u, "
148 "flags = %s, field = %s, timestamp = %llu, "
149 "timecode = { type = %s, flags = %s, frames = %u, "
150 "seconds = %u, minutes = %u, hours = %u, "
151 "userbits = { %u %u %u %u } }, sequence = %u", __entry->minor,
152 __entry->index, show_type(__entry->type),
153 __entry->bytesused,
154 show_flags(__entry->flags),
155 show_field(__entry->field),
156 __entry->timestamp,
157 show_timecode_type(__entry->timecode_type),
158 show_timecode_flags(__entry->timecode_flags),
159 __entry->timecode_frames,
160 __entry->timecode_seconds,
161 __entry->timecode_minutes,
162 __entry->timecode_hours,
163 __entry->timecode_userbits0,
164 __entry->timecode_userbits1,
165 __entry->timecode_userbits2,
166 __entry->timecode_userbits3,
167 __entry->sequence
168 )
169)
170
171DEFINE_EVENT(v4l2_event_class, v4l2_dqbuf,
172 TP_PROTO(int minor, struct v4l2_buffer *buf),
173 TP_ARGS(minor, buf)
174);
175
176DEFINE_EVENT(v4l2_event_class, v4l2_qbuf,
177 TP_PROTO(int minor, struct v4l2_buffer *buf),
178 TP_ARGS(minor, buf)
179);
Wade Farnsworth2d012372013-11-22 16:48:28 -0300180
Junghak Sungb0e0e1f2015-10-06 06:37:48 -0300181DECLARE_EVENT_CLASS(vb2_v4l2_event_class,
Philipp Zabel2091f512015-07-10 10:49:26 -0300182 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
183 TP_ARGS(q, vb),
184
185 TP_STRUCT__entry(
186 __field(int, minor)
Philipp Zabel2091f512015-07-10 10:49:26 -0300187 __field(u32, flags)
188 __field(u32, field)
Junghak Sungd6dd6452015-11-03 08:16:37 -0200189 __field(u64, timestamp)
Philipp Zabel2091f512015-07-10 10:49:26 -0300190 __field(u32, timecode_type)
191 __field(u32, timecode_flags)
192 __field(u8, timecode_frames)
193 __field(u8, timecode_seconds)
194 __field(u8, timecode_minutes)
195 __field(u8, timecode_hours)
196 __field(u8, timecode_userbits0)
197 __field(u8, timecode_userbits1)
198 __field(u8, timecode_userbits2)
199 __field(u8, timecode_userbits3)
200 __field(u32, sequence)
201 ),
202
203 TP_fast_assign(
Junghak Sung2d700712015-09-22 10:30:30 -0300204 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
Junghak Sungbed04f92015-10-06 06:37:47 -0300205 struct v4l2_fh *owner = q->owner;
206
207 __entry->minor = owner ? owner->vdev->minor : -1;
Junghak Sung2d700712015-09-22 10:30:30 -0300208 __entry->flags = vbuf->flags;
209 __entry->field = vbuf->field;
Junghak Sungd6dd6452015-11-03 08:16:37 -0200210 __entry->timestamp = vb->timestamp;
Junghak Sung2d700712015-09-22 10:30:30 -0300211 __entry->timecode_type = vbuf->timecode.type;
212 __entry->timecode_flags = vbuf->timecode.flags;
213 __entry->timecode_frames = vbuf->timecode.frames;
214 __entry->timecode_seconds = vbuf->timecode.seconds;
215 __entry->timecode_minutes = vbuf->timecode.minutes;
216 __entry->timecode_hours = vbuf->timecode.hours;
217 __entry->timecode_userbits0 = vbuf->timecode.userbits[0];
218 __entry->timecode_userbits1 = vbuf->timecode.userbits[1];
219 __entry->timecode_userbits2 = vbuf->timecode.userbits[2];
220 __entry->timecode_userbits3 = vbuf->timecode.userbits[3];
221 __entry->sequence = vbuf->sequence;
Philipp Zabel2091f512015-07-10 10:49:26 -0300222 ),
223
Junghak Sungb0e0e1f2015-10-06 06:37:48 -0300224 TP_printk("minor=%d flags = %s, field = %s, "
Philipp Zabel2091f512015-07-10 10:49:26 -0300225 "timestamp = %llu, timecode = { type = %s, flags = %s, "
226 "frames = %u, seconds = %u, minutes = %u, hours = %u, "
227 "userbits = { %u %u %u %u } }, sequence = %u", __entry->minor,
Philipp Zabel2091f512015-07-10 10:49:26 -0300228 show_flags(__entry->flags),
229 show_field(__entry->field),
230 __entry->timestamp,
231 show_timecode_type(__entry->timecode_type),
232 show_timecode_flags(__entry->timecode_flags),
233 __entry->timecode_frames,
234 __entry->timecode_seconds,
235 __entry->timecode_minutes,
236 __entry->timecode_hours,
237 __entry->timecode_userbits0,
238 __entry->timecode_userbits1,
239 __entry->timecode_userbits2,
240 __entry->timecode_userbits3,
241 __entry->sequence
242 )
243)
244
Junghak Sungb0e0e1f2015-10-06 06:37:48 -0300245DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_buf_done,
Philipp Zabel2091f512015-07-10 10:49:26 -0300246 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
247 TP_ARGS(q, vb)
248);
249
Junghak Sungb0e0e1f2015-10-06 06:37:48 -0300250DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_buf_queue,
Philipp Zabel2091f512015-07-10 10:49:26 -0300251 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
252 TP_ARGS(q, vb)
253);
254
Junghak Sungb0e0e1f2015-10-06 06:37:48 -0300255DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_dqbuf,
Philipp Zabel2091f512015-07-10 10:49:26 -0300256 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
257 TP_ARGS(q, vb)
258);
259
Junghak Sungb0e0e1f2015-10-06 06:37:48 -0300260DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_qbuf,
Philipp Zabel2091f512015-07-10 10:49:26 -0300261 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb),
262 TP_ARGS(q, vb)
263);
264
Wade Farnsworth2d012372013-11-22 16:48:28 -0300265#endif /* if !defined(_TRACE_V4L2_H) || defined(TRACE_HEADER_MULTI_READ) */
266
267/* This part must be outside protection */
268#include <trace/define_trace.h>