1 From b1922615aca680275e52b5abd00b49851f35eea4 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 15 Sep 2021 17:54:11 +0100
4 Subject: [PATCH 0307/1085] staging/mmal-vchiq: Add module parameter to enable
7 Adds a module parameter "debug" to enable various logging levels.
9 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
11 .../vc04_services/vchiq-mmal/mmal-vchiq.c | 139 ++++++++++--------
12 1 file changed, 77 insertions(+), 62 deletions(-)
14 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
15 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
18 #include "../vc-sm-cma/vc_sm_knl.h"
20 +#define pr_dbg_lvl(__level, __debug, __fmt, __arg...) \
22 + if (__debug >= (__level)) \
23 + printk(KERN_DEBUG __fmt, ##__arg); \
26 +static unsigned int debug;
27 +module_param(debug, uint, 0644);
28 +MODULE_PARM_DESC(debug, "activates debug info (0-3)");
31 * maximum number of components supported.
32 * This matches the maximum permitted by default on the VPU
33 @@ -380,7 +390,8 @@ buffer_from_host(struct vchiq_mmal_insta
37 - pr_debug("instance:%u buffer:%p\n", instance->service_handle, buf);
38 + pr_dbg_lvl(3, debug, "instance:%u buffer:%p\n",
39 + instance->service_handle, buf);
42 if (!buf->msg_context) {
43 @@ -548,11 +559,11 @@ static void event_to_host_cb(struct vchi
44 msg_context->u.bulk.pts = MMAL_TIME_UNKNOWN;
45 msg_context->u.bulk.cmd = msg->u.event_to_host.cmd;
47 - pr_debug("event component:%u port type:%d num:%d cmd:0x%x length:%d\n",
48 - msg->u.event_to_host.client_component,
49 - msg->u.event_to_host.port_type,
50 - msg->u.event_to_host.port_num,
51 - msg->u.event_to_host.cmd, msg->u.event_to_host.length);
52 + pr_dbg_lvl(3, debug, "event component:%u port type:%d num:%d cmd:0x%x length:%d\n",
53 + msg->u.event_to_host.client_component,
54 + msg->u.event_to_host.port_type,
55 + msg->u.event_to_host.port_num,
56 + msg->u.event_to_host.cmd, msg->u.event_to_host.length);
59 schedule_work(&msg_context->u.bulk.work);
60 @@ -565,8 +576,8 @@ static void buffer_to_host_cb(struct vch
61 struct mmal_msg_context *msg_context;
64 - pr_debug("%s: instance:%p msg:%p msg_len:%d\n",
65 - __func__, instance, msg, msg_len);
66 + pr_dbg_lvl(3, debug, "%s: instance:%p msg:%p msg_len:%d\n",
67 + __func__, instance, msg, msg_len);
69 if (msg->u.buffer_from_host.drvbuf.magic == MMAL_MAGIC) {
70 handle = msg->u.buffer_from_host.drvbuf.client_context;
71 @@ -836,39 +847,42 @@ static int send_synchronous_mmal_msg(str
73 static void dump_port_info(struct vchiq_mmal_port *port)
75 - pr_debug("port handle:0x%x enabled:%d\n", port->handle, port->enabled);
76 + pr_dbg_lvl(3, debug, "port handle:0x%x enabled:%d\n", port->handle,
79 - pr_debug("buffer minimum num:%d size:%d align:%d\n",
80 - port->minimum_buffer.num,
81 - port->minimum_buffer.size, port->minimum_buffer.alignment);
83 - pr_debug("buffer recommended num:%d size:%d align:%d\n",
84 - port->recommended_buffer.num,
85 - port->recommended_buffer.size,
86 - port->recommended_buffer.alignment);
88 - pr_debug("buffer current values num:%d size:%d align:%d\n",
89 - port->current_buffer.num,
90 - port->current_buffer.size, port->current_buffer.alignment);
92 - pr_debug("elementary stream: type:%d encoding:0x%x variant:0x%x\n",
94 - port->format.encoding, port->format.encoding_variant);
95 + pr_dbg_lvl(3, debug, "buffer minimum num:%d size:%d align:%d\n",
96 + port->minimum_buffer.num,
97 + port->minimum_buffer.size, port->minimum_buffer.alignment);
99 + pr_dbg_lvl(3, debug, "buffer recommended num:%d size:%d align:%d\n",
100 + port->recommended_buffer.num,
101 + port->recommended_buffer.size,
102 + port->recommended_buffer.alignment);
104 + pr_dbg_lvl(3, debug, "buffer current values num:%d size:%d align:%d\n",
105 + port->current_buffer.num,
106 + port->current_buffer.size, port->current_buffer.alignment);
108 + pr_dbg_lvl(3, debug, "elementary stream: type:%d encoding:0x%x variant:0x%x\n",
110 + port->format.encoding, port->format.encoding_variant);
112 - pr_debug(" bitrate:%d flags:0x%x\n",
113 - port->format.bitrate, port->format.flags);
114 + pr_dbg_lvl(3, debug, " bitrate:%d flags:0x%x\n",
115 + port->format.bitrate, port->format.flags);
117 if (port->format.type == MMAL_ES_TYPE_VIDEO) {
119 - ("es video format: width:%d height:%d colourspace:0x%x\n",
120 + pr_dbg_lvl(3, debug,
121 + "es video format: width:%d height:%d colourspace:0x%x\n",
122 port->es.video.width, port->es.video.height,
123 port->es.video.color_space);
125 - pr_debug(" : crop xywh %d,%d,%d,%d\n",
126 + pr_dbg_lvl(3, debug,
127 + " : crop xywh %d,%d,%d,%d\n",
128 port->es.video.crop.x,
129 port->es.video.crop.y,
130 port->es.video.crop.width, port->es.video.crop.height);
131 - pr_debug(" : framerate %d/%d aspect %d/%d\n",
132 + pr_dbg_lvl(3, debug,
133 + " : framerate %d/%d aspect %d/%d\n",
134 port->es.video.frame_rate.numerator,
135 port->es.video.frame_rate.denominator,
136 port->es.video.par.numerator, port->es.video.par.denominator);
137 @@ -902,7 +916,7 @@ static int port_info_set(struct vchiq_mm
138 struct mmal_msg *rmsg;
139 struct vchiq_header *rmsg_handle;
141 - pr_debug("setting port info port %p\n", port);
142 + pr_dbg_lvl(1, debug, "setting port info port %p\n", port);
145 dump_port_info(port);
146 @@ -945,8 +959,8 @@ static int port_info_set(struct vchiq_mm
147 /* return operation status */
148 ret = -rmsg->u.port_info_get_reply.status;
150 - pr_debug("%s:result:%d component:0x%x port:%d\n", __func__, ret,
151 - port->component->handle, port->handle);
152 + pr_dbg_lvl(1, debug, "%s:result:%d component:0x%x port:%d\n", __func__,
153 + ret, port->component->handle, port->handle);
156 vchiq_release_message(instance->vchiq_instance, instance->service_handle, rmsg_handle);
157 @@ -1036,13 +1050,13 @@ static int port_info_get(struct vchiq_mm
158 rmsg->u.port_info_get_reply.extradata,
159 port->format.extradata_size);
161 - pr_debug("received port info\n");
162 + pr_dbg_lvl(1, debug, "received port info\n");
163 dump_port_info(port);
167 - pr_debug("%s:result:%d component:0x%x port:%d\n",
168 - __func__, ret, port->component->handle, port->handle);
169 + pr_dbg_lvl(1, debug, "%s:result:%d component:0x%x port:%d\n",
170 + __func__, ret, port->component->handle, port->handle);
172 vchiq_release_message(instance->vchiq_instance, instance->service_handle, rmsg_handle);
174 @@ -1088,9 +1102,9 @@ static int create_component(struct vchiq
175 component->outputs = rmsg->u.component_create_reply.output_num;
176 component->clocks = rmsg->u.component_create_reply.clock_num;
178 - pr_debug("Component handle:0x%x in:%d out:%d clock:%d\n",
180 - component->inputs, component->outputs, component->clocks);
181 + pr_dbg_lvl(2, debug, "Component handle:0x%x in:%d out:%d clock:%d\n",
183 + component->inputs, component->outputs, component->clocks);
186 vchiq_release_message(instance->vchiq_instance, instance->service_handle, rmsg_handle);
187 @@ -1259,10 +1273,9 @@ static int port_action_port(struct vchiq
189 ret = -rmsg->u.port_action_reply.status;
191 - pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d)\n",
193 - ret, port->component->handle, port->handle,
194 - port_action_type_names[action_type], action_type);
195 + pr_dbg_lvl(2, debug, "%s:result:%d component:0x%x port:%d action:%s(%d)\n",
196 + __func__, ret, port->component->handle, port->handle,
197 + port_action_type_names[action_type], action_type);
200 vchiq_release_message(instance->vchiq_instance, instance->service_handle, rmsg_handle);
201 @@ -1306,11 +1319,11 @@ static int port_action_handle(struct vch
203 ret = -rmsg->u.port_action_reply.status;
205 - pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d) connect component:0x%x connect port:%d\n",
207 - ret, port->component->handle, port->handle,
208 - port_action_type_names[action_type],
209 - action_type, connect_component_handle, connect_port_handle);
210 + pr_dbg_lvl(2, debug,
211 + "%s:result:%d component:0x%x port:%d action:%s(%d) connect component:0x%x connect port:%d\n",
212 + __func__, ret, port->component->handle, port->handle,
213 + port_action_type_names[action_type],
214 + action_type, connect_component_handle, connect_port_handle);
217 vchiq_release_message(instance->vchiq_instance, instance->service_handle, rmsg_handle);
218 @@ -1349,9 +1362,9 @@ static int port_parameter_set(struct vch
220 ret = -rmsg->u.port_parameter_set_reply.status;
222 - pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n",
224 - ret, port->component->handle, port->handle, parameter_id);
225 + pr_dbg_lvl(1, debug, "%s:result:%d component:0x%x port:%d parameter:%d\n",
226 + __func__, ret, port->component->handle, port->handle,
230 vchiq_release_message(instance->vchiq_instance, instance->service_handle, rmsg_handle);
231 @@ -1409,8 +1422,9 @@ static int port_parameter_get(struct vch
232 /* Always report the size of the returned parameter to the caller */
233 *value_size = rmsg->u.port_parameter_get_reply.size;
235 - pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", __func__,
236 - ret, port->component->handle, port->handle, parameter_id);
237 + pr_dbg_lvl(1, debug, "%s:result:%d component:0x%x port:%d parameter:%d\n",
238 + __func__, ret, port->component->handle, port->handle,
242 vchiq_release_message(instance->vchiq_instance, instance->service_handle, rmsg_handle);
243 @@ -1667,7 +1681,7 @@ int vchiq_mmal_port_connect_tunnel(struc
245 /* do not make new connection */
247 - pr_debug("not making new connection\n");
248 + pr_dbg_lvl(3, debug, "not making new connection\n");
252 @@ -1685,14 +1699,14 @@ int vchiq_mmal_port_connect_tunnel(struc
254 ret = port_info_set(instance, dst);
256 - pr_debug("setting port info failed\n");
257 + pr_dbg_lvl(1, debug, "setting port info failed\n");
261 /* read what has actually been set */
262 ret = port_info_get(instance, dst);
264 - pr_debug("read back port info failed\n");
265 + pr_dbg_lvl(1, debug, "read back port info failed\n");
269 @@ -1701,9 +1715,9 @@ int vchiq_mmal_port_connect_tunnel(struc
270 MMAL_MSG_PORT_ACTION_TYPE_CONNECT,
271 dst->component->handle, dst->handle);
273 - pr_debug("connecting port %d:%d to %d:%d failed\n",
274 - src->component->handle, src->handle,
275 - dst->component->handle, dst->handle);
276 + pr_dbg_lvl(2, debug, "connecting port %d:%d to %d:%d failed\n",
277 + src->component->handle, src->handle,
278 + dst->component->handle, dst->handle);
281 src->connected = dst;
282 @@ -1728,7 +1742,8 @@ int vchiq_mmal_submit_buffer(struct vchi
283 * videobuf2 won't let us have the dmabuf there.
285 if (port->zero_copy && buffer->dma_buf && !buffer->vcsm_handle) {
286 - pr_debug("%s: import dmabuf %p\n", __func__, buffer->dma_buf);
287 + pr_dbg_lvl(2, debug, "%s: import dmabuf %p\n",
288 + __func__, buffer->dma_buf);
289 ret = vc_sm_cma_import_dmabuf(buffer->dma_buf,
290 &buffer->vcsm_handle);
292 @@ -1744,8 +1759,8 @@ int vchiq_mmal_submit_buffer(struct vchi
293 vc_sm_cma_free(buffer->vcsm_handle);
296 - pr_debug("%s: import dmabuf %p - got vc handle %08X\n",
297 - __func__, buffer->dma_buf, buffer->vc_handle);
298 + pr_dbg_lvl(2, debug, "%s: import dmabuf %p - got vc handle %08X\n",
299 + __func__, buffer->dma_buf, buffer->vc_handle);
302 ret = buffer_from_host(instance, port, buffer);
303 @@ -1784,8 +1799,8 @@ int mmal_vchi_buffer_cleanup(struct mmal
304 if (buf->vcsm_handle) {
307 - pr_debug("%s: vc_sm_cma_free on handle %p\n", __func__,
309 + pr_dbg_lvl(2, debug, "%s: vc_sm_cma_free on handle %p\n", __func__,
311 ret = vc_sm_cma_free(buf->vcsm_handle);
313 pr_err("%s: vcsm_free failed, ret %d\n", __func__, ret);