xref: /linux/drivers/media/platform/raspberrypi/rp1-cfe/cfe-trace.h (revision fcc79e1714e8c2b8e216dc3149812edd37884eef)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2024 Raspberry Pi Ltd.
4  * Copyright (c) 2024 Ideas on Board Oy
5  */
6 
7 #undef TRACE_SYSTEM
8 #define TRACE_SYSTEM cfe
9 
10 #if !defined(_CFE_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
11 #define _CFE_TRACE_H
12 
13 #include <linux/tracepoint.h>
14 #include <media/videobuf2-v4l2.h>
15 
16 TRACE_EVENT(cfe_return_buffer,
17 	TP_PROTO(u32 node_id, u32 buf_idx, u32 queue_id),
18 	TP_ARGS(node_id, buf_idx, queue_id),
19 	TP_STRUCT__entry(
20 		__field(u32, node_id)
21 		__field(u32, buf_idx)
22 		__field(u32, queue_id)
23 	),
24 	TP_fast_assign(
25 		__entry->node_id = node_id;
26 		__entry->buf_idx = buf_idx;
27 		__entry->queue_id = queue_id;
28 	),
29 	TP_printk("node=%u buf=%u, queue=%u", __entry->node_id,
30 		  __entry->buf_idx, __entry->queue_id)
31 );
32 
33 DECLARE_EVENT_CLASS(cfe_buffer_template,
34 	TP_PROTO(u32 node_id, struct vb2_buffer *buf),
35 	TP_ARGS(node_id, buf),
36 	TP_STRUCT__entry(
37 		__field(u32, node_id)
38 		__field(u32, buf_idx)
39 	),
40 	TP_fast_assign(
41 		__entry->node_id = node_id;
42 		__entry->buf_idx = buf->index;
43 	),
44 	TP_printk("node=%u buf=%u", __entry->node_id, __entry->buf_idx)
45 );
46 
47 DEFINE_EVENT(cfe_buffer_template, cfe_buffer_prepare,
48 	TP_PROTO(u32 node_id, struct vb2_buffer *buf),
49 	TP_ARGS(node_id, buf));
50 
51 TRACE_EVENT(cfe_buffer_queue,
52 	TP_PROTO(u32 node_id, struct vb2_buffer *buf, bool schedule_now),
53 	TP_ARGS(node_id, buf, schedule_now),
54 	TP_STRUCT__entry(
55 		__field(u32, node_id)
56 		__field(u32, buf_idx)
57 		__field(bool, schedule_now)
58 	),
59 	TP_fast_assign(
60 		__entry->node_id = node_id;
61 		__entry->buf_idx = buf->index;
62 		__entry->schedule_now = schedule_now;
63 	),
64 	TP_printk("node=%u buf=%u%s", __entry->node_id, __entry->buf_idx,
65 		  __entry->schedule_now ? " schedule immediately" : "")
66 );
67 
68 DEFINE_EVENT(cfe_buffer_template, cfe_csi2_schedule,
69 	TP_PROTO(u32 node_id, struct vb2_buffer *buf),
70 	TP_ARGS(node_id, buf));
71 
72 DEFINE_EVENT(cfe_buffer_template, cfe_fe_schedule,
73 	TP_PROTO(u32 node_id, struct vb2_buffer *buf),
74 	TP_ARGS(node_id, buf));
75 
76 TRACE_EVENT(cfe_buffer_complete,
77 	TP_PROTO(u32 node_id, struct vb2_v4l2_buffer *buf),
78 	TP_ARGS(node_id, buf),
79 	TP_STRUCT__entry(
80 		__field(u32, node_id)
81 		__field(u32, buf_idx)
82 		__field(u32, seq)
83 		__field(u64, ts)
84 	),
85 	TP_fast_assign(
86 		__entry->node_id = node_id;
87 		__entry->buf_idx = buf->vb2_buf.index;
88 		__entry->seq = buf->sequence;
89 		__entry->ts = buf->vb2_buf.timestamp;
90 	),
91 	TP_printk("node=%u buf=%u seq=%u ts=%llu", __entry->node_id,
92 		  __entry->buf_idx, __entry->seq, __entry->ts)
93 );
94 
95 TRACE_EVENT(cfe_frame_start,
96 	TP_PROTO(u32 node_id, u32 fs_count),
97 	TP_ARGS(node_id, fs_count),
98 	TP_STRUCT__entry(
99 		__field(u32, node_id)
100 		__field(u32, fs_count)
101 	),
102 	TP_fast_assign(
103 		__entry->node_id = node_id;
104 		__entry->fs_count = fs_count;
105 	),
106 	TP_printk("node=%u fs_count=%u", __entry->node_id, __entry->fs_count)
107 );
108 
109 TRACE_EVENT(cfe_frame_end,
110 	TP_PROTO(u32 node_id, u32 fs_count),
111 	TP_ARGS(node_id, fs_count),
112 	TP_STRUCT__entry(
113 		__field(u32, node_id)
114 		__field(u32, fs_count)
115 	),
116 	TP_fast_assign(
117 		__entry->node_id = node_id;
118 		__entry->fs_count = fs_count;
119 	),
120 	TP_printk("node=%u fs_count=%u", __entry->node_id, __entry->fs_count)
121 );
122 
123 TRACE_EVENT(cfe_prepare_next_job,
124 	TP_PROTO(bool fe_enabled),
125 	TP_ARGS(fe_enabled),
126 	TP_STRUCT__entry(
127 		__field(bool, fe_enabled)
128 	),
129 	TP_fast_assign(
130 		__entry->fe_enabled = fe_enabled;
131 	),
132 	TP_printk("fe_enabled=%u", __entry->fe_enabled)
133 );
134 
135 /* These are copied from csi2.c */
136 #define CSI2_STATUS_IRQ_FS(x)			(BIT(0) << (x))
137 #define CSI2_STATUS_IRQ_FE(x)			(BIT(4) << (x))
138 #define CSI2_STATUS_IRQ_FE_ACK(x)		(BIT(8) << (x))
139 #define CSI2_STATUS_IRQ_LE(x)			(BIT(12) << (x))
140 #define CSI2_STATUS_IRQ_LE_ACK(x)		(BIT(16) << (x))
141 
142 TRACE_EVENT(csi2_irq,
143 	TP_PROTO(u32 channel, u32 status, u32 dbg),
144 	TP_ARGS(channel, status, dbg),
145 	TP_STRUCT__entry(
146 		__field(u32, channel)
147 		__field(u32, status)
148 		__field(u32, dbg)
149 	),
150 	TP_fast_assign(
151 		__entry->channel = channel;
152 		__entry->status = status;
153 		__entry->dbg = dbg;
154 	),
155 	TP_printk("ch=%u flags=[ %s%s%s%s%s] frame=%u line=%u\n",
156 		  __entry->channel,
157 		  (__entry->status & CSI2_STATUS_IRQ_FS(__entry->channel)) ?
158 			"FS " : "",
159 		  (__entry->status & CSI2_STATUS_IRQ_FE(__entry->channel)) ?
160 			"FE " : "",
161 		  (__entry->status & CSI2_STATUS_IRQ_FE_ACK(__entry->channel)) ?
162 			"FE_ACK " : "",
163 		  (__entry->status & CSI2_STATUS_IRQ_LE(__entry->channel)) ?
164 			"LE " : "",
165 		  (__entry->status & CSI2_STATUS_IRQ_LE_ACK(__entry->channel)) ?
166 			"LE_ACK " : "",
167 		  __entry->dbg >> 16, __entry->dbg & 0xffff)
168 );
169 
170 TRACE_EVENT(fe_irq,
171 	TP_PROTO(u32 status, u32 output_status, u32 frame_status,
172 		 u32 error_status, u32 int_status),
173 	TP_ARGS(status, output_status, frame_status, error_status, int_status),
174 	TP_STRUCT__entry(
175 		__field(u32, status)
176 		__field(u32, output_status)
177 		__field(u32, frame_status)
178 		__field(u32, error_status)
179 		__field(u32, int_status)
180 	),
181 	TP_fast_assign(
182 		__entry->status = status;
183 		__entry->output_status = output_status;
184 		__entry->frame_status = frame_status;
185 		__entry->error_status = error_status;
186 		__entry->int_status = int_status;
187 	),
188 	TP_printk("status 0x%x out_status 0x%x frame_status 0x%x error_status 0x%x int_status 0x%x",
189 		  __entry->status,
190 		  __entry->output_status,
191 		  __entry->frame_status,
192 		  __entry->error_status,
193 		  __entry->int_status)
194 );
195 
196 #endif /* _CFE_TRACE_H */
197 
198 /* This part must be outside protection */
199 #undef TRACE_INCLUDE_PATH
200 #define TRACE_INCLUDE_PATH .
201 #define TRACE_INCLUDE_FILE ../../drivers/media/platform/raspberrypi/rp1-cfe/cfe-trace
202 #include <trace/define_trace.h>
203