v4l2.h 8.7 KB

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