v4l2.h 8.8 KB

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