1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #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> 9 #include <media/videobuf2-v4l2.h> 10 11 /* 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" ) \ 32 EM( V4L2_BUF_TYPE_SDR_OUTPUT, "SDR_OUTPUT" ) \ 33 EM( V4L2_BUF_TYPE_META_CAPTURE, "META_CAPTURE" ) \ 34 EMe(V4L2_BUF_TYPE_PRIVATE, "PRIVATE" ) 35 36 SHOW_TYPE 37 38 #define show_field(field) \ 39 __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 53 SHOW_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 */ 65 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" }, \ 90 { V4L2_BUF_FLAG_TIMESTAMP_COPY, "TIMESTAMP_COPY" }, \ 91 { V4L2_BUF_FLAG_LAST, "LAST" }) 92 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 100 DECLARE_EVENT_CLASS(v4l2_event_class, 101 TP_PROTO(int minor, struct v4l2_buffer *buf), 102 103 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 = v4l2_buffer_get_timestamp(buf); 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 171 DEFINE_EVENT(v4l2_event_class, v4l2_dqbuf, 172 TP_PROTO(int minor, struct v4l2_buffer *buf), 173 TP_ARGS(minor, buf) 174 ); 175 176 DEFINE_EVENT(v4l2_event_class, v4l2_qbuf, 177 TP_PROTO(int minor, struct v4l2_buffer *buf), 178 TP_ARGS(minor, buf) 179 ); 180 181 DECLARE_EVENT_CLASS(vb2_v4l2_event_class, 182 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb), 183 TP_ARGS(q, vb), 184 185 TP_STRUCT__entry( 186 __field(int, minor) 187 __field(u32, flags) 188 __field(u32, field) 189 __field(u64, timestamp) 190 __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( 204 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 205 struct v4l2_fh *owner = q->owner; 206 207 __entry->minor = owner ? owner->vdev->minor : -1; 208 __entry->flags = vbuf->flags; 209 __entry->field = vbuf->field; 210 __entry->timestamp = vb->timestamp; 211 __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; 222 ), 223 224 TP_printk("minor=%d flags = %s, field = %s, " 225 "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, 228 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 245 DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_buf_done, 246 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb), 247 TP_ARGS(q, vb) 248 ); 249 250 DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_buf_queue, 251 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb), 252 TP_ARGS(q, vb) 253 ); 254 255 DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_dqbuf, 256 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb), 257 TP_ARGS(q, vb) 258 ); 259 260 DEFINE_EVENT(vb2_v4l2_event_class, vb2_v4l2_qbuf, 261 TP_PROTO(struct vb2_queue *q, struct vb2_buffer *vb), 262 TP_ARGS(q, vb) 263 ); 264 265 #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> 269