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
32SHOW_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
49SHOW_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
88#define show_timecode_flags(flags)					  \
89	__print_flags(flags, "|",					  \
90		{ V4L2_TC_FLAG_DROPFRAME,       "DROPFRAME" },		  \
91		{ V4L2_TC_FLAG_COLORFRAME,      "COLORFRAME" },		  \
92		{ V4L2_TC_USERBITS_USERDEFINED,	"USERBITS_USERDEFINED" }, \
93		{ V4L2_TC_USERBITS_8BITCHARS,	"USERBITS_8BITCHARS" })
94
95#define V4L2_TRACE_EVENT(event_name)					\
96	TRACE_EVENT(event_name,						\
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 =				\
130				timeval_to_ns(&buf->timestamp);		\
131			__entry->timecode_type = buf->timecode.type;	\
132			__entry->timecode_flags = buf->timecode.flags;	\
133			__entry->timecode_frames =			\
134				buf->timecode.frames;			\
135			__entry->timecode_seconds =			\
136				buf->timecode.seconds;			\
137			__entry->timecode_minutes =			\
138				buf->timecode.minutes;			\
139			__entry->timecode_hours = buf->timecode.hours;	\
140			__entry->timecode_userbits0 =			\
141				buf->timecode.userbits[0];		\
142			__entry->timecode_userbits1 =			\
143				buf->timecode.userbits[1];		\
144			__entry->timecode_userbits2 =			\
145				buf->timecode.userbits[2];		\
146			__entry->timecode_userbits3 =			\
147				buf->timecode.userbits[3];		\
148			__entry->sequence = buf->sequence;		\
149		),							\
150									\
151		TP_printk("minor = %d, index = %u, type = %s, "		\
152			  "bytesused = %u, flags = %s, "		\
153			  "field = %s, timestamp = %llu, timecode = { "	\
154			  "type = %s, flags = %s, frames = %u, "	\
155			  "seconds = %u, minutes = %u, hours = %u, "	\
156			  "userbits = { %u %u %u %u } }, "		\
157			  "sequence = %u", __entry->minor,		\
158			  __entry->index, show_type(__entry->type),	\
159			  __entry->bytesused,				\
160			  show_flags(__entry->flags),			\
161			  show_field(__entry->field),			\
162			  __entry->timestamp,				\
163			  show_timecode_type(__entry->timecode_type),	\
164			  show_timecode_flags(__entry->timecode_flags),	\
165			  __entry->timecode_frames,			\
166			  __entry->timecode_seconds,			\
167			  __entry->timecode_minutes,			\
168			  __entry->timecode_hours,			\
169			  __entry->timecode_userbits0,			\
170			  __entry->timecode_userbits1,			\
171			  __entry->timecode_userbits2,			\
172			  __entry->timecode_userbits3,			\
173			  __entry->sequence				\
174		)							\
175	)
176
177V4L2_TRACE_EVENT(v4l2_dqbuf);
178V4L2_TRACE_EVENT(v4l2_qbuf);
179
180#endif /* if !defined(_TRACE_V4L2_H) || defined(TRACE_HEADER_MULTI_READ) */
181
182/* This part must be outside protection */
183#include <trace/define_trace.h>
184