Linux Audio

Check our new training course

Embedded Linux Audio

Check our new training course
with Creative Commons CC-BY-SA
lecture materials

Bootlin logo

Elixir Cross Referencer

Loading...
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
// SPDX-License-Identifier: GPL-2.0
/*
 * Contains the virtual decoder logic. The functions here control the
 * tracing/TPG on a per-frame basis
 */

#include "visl.h"
#include "visl-debugfs.h"
#include "visl-dec.h"
#include "visl-trace-fwht.h"
#include "visl-trace-mpeg2.h"
#include "visl-trace-vp8.h"
#include "visl-trace-vp9.h"
#include "visl-trace-h264.h"
#include "visl-trace-hevc.h"

#include <linux/delay.h>
#include <linux/workqueue.h>
#include <media/v4l2-mem2mem.h>
#include <media/tpg/v4l2-tpg.h>

static void *plane_vaddr(struct tpg_data *tpg, struct vb2_buffer *buf,
			 u32 p, u32 bpl[TPG_MAX_PLANES], u32 h)
{
	u32 i;
	void *vbuf;

	if (p == 0 || tpg_g_buffers(tpg) > 1)
		return vb2_plane_vaddr(buf, p);
	vbuf = vb2_plane_vaddr(buf, 0);
	for (i = 0; i < p; i++)
		vbuf += bpl[i] * h / tpg->vdownsampling[i];
	return vbuf;
}

static void visl_get_ref_frames(struct visl_ctx *ctx, u8 *buf,
				__kernel_size_t buflen, struct visl_run *run)
{
	struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q;
	char header[] = "Reference frames:\n";
	u32 i;
	u32 len;

	len = scnprintf(buf, buflen, header);
	buf += len;
	buflen -= len;

	switch (ctx->current_codec) {
	case VISL_CODEC_NONE:
		break;

	case VISL_CODEC_FWHT: {
		struct vb2_buffer *vb2_buf;

		vb2_buf = vb2_find_buffer(cap_q, run->fwht.params->backward_ref_ts);

		scnprintf(buf, buflen, "backwards_ref_ts: %lld, vb2_idx: %d",
			  run->fwht.params->backward_ref_ts,
			  vb2_buf ? vb2_buf->index : -1);
		break;
	}

	case VISL_CODEC_MPEG2: {
		struct vb2_buffer *b_ref;
		struct vb2_buffer *f_ref;

		b_ref = vb2_find_buffer(cap_q, run->mpeg2.pic->backward_ref_ts);
		f_ref = vb2_find_buffer(cap_q, run->mpeg2.pic->forward_ref_ts);

		scnprintf(buf, buflen,
			  "backward_ref_ts: %llu, vb2_idx: %d\n"
			  "forward_ref_ts: %llu, vb2_idx: %d\n",
			  run->mpeg2.pic->backward_ref_ts,
			  b_ref ? b_ref->index : -1,
			  run->mpeg2.pic->forward_ref_ts,
			  f_ref ? f_ref->index : -1);
		break;
	}

	case VISL_CODEC_VP8: {
		struct vb2_buffer *last;
		struct vb2_buffer *golden;
		struct vb2_buffer *alt;

		last = vb2_find_buffer(cap_q, run->vp8.frame->last_frame_ts);
		golden = vb2_find_buffer(cap_q, run->vp8.frame->golden_frame_ts);
		alt = vb2_find_buffer(cap_q, run->vp8.frame->alt_frame_ts);

		scnprintf(buf, buflen,
			  "last_ref_ts: %llu, vb2_idx: %d\n"
			  "golden_ref_ts: %llu, vb2_idx: %d\n"
			  "alt_ref_ts: %llu, vb2_idx: %d\n",
			  run->vp8.frame->last_frame_ts,
			  last ? last->index : -1,
			  run->vp8.frame->golden_frame_ts,
			  golden ? golden->index : -1,
			  run->vp8.frame->alt_frame_ts,
			  alt ? alt->index : -1);
		break;
	}

	case VISL_CODEC_VP9: {
		struct vb2_buffer *last;
		struct vb2_buffer *golden;
		struct vb2_buffer *alt;

		last = vb2_find_buffer(cap_q, run->vp9.frame->last_frame_ts);
		golden = vb2_find_buffer(cap_q, run->vp9.frame->golden_frame_ts);
		alt = vb2_find_buffer(cap_q, run->vp9.frame->alt_frame_ts);

		scnprintf(buf, buflen,
			  "last_ref_ts: %llu, vb2_idx: %d\n"
			  "golden_ref_ts: %llu, vb2_idx: %d\n"
			  "alt_ref_ts: %llu, vb2_idx: %d\n",
			  run->vp9.frame->last_frame_ts,
			  last ? last->index : -1,
			  run->vp9.frame->golden_frame_ts,
			  golden ? golden->index : -1,
			  run->vp9.frame->alt_frame_ts,
			  alt ? alt->index : -1);
		break;
	}

	case VISL_CODEC_H264: {
		char entry[] = "dpb[%d]:%u, vb2_index: %d\n";
		struct vb2_buffer *vb2_buf;

		for (i = 0; i < ARRAY_SIZE(run->h264.dpram->dpb); i++) {
			vb2_buf = vb2_find_buffer(cap_q, run->h264.dpram->dpb[i].reference_ts);
			len = scnprintf(buf, buflen, entry, i,
					run->h264.dpram->dpb[i].reference_ts,
					vb2_buf ? vb2_buf->index : -1);
			buf += len;
			buflen -= len;
		}

		break;
	}

	case VISL_CODEC_HEVC: {
		char entry[] = "dpb[%d]:%u, vb2_index: %d\n";
		struct vb2_buffer *vb2_buf;

		for (i = 0; i < ARRAY_SIZE(run->hevc.dpram->dpb); i++) {
			vb2_buf = vb2_find_buffer(cap_q, run->hevc.dpram->dpb[i].timestamp);
			len = scnprintf(buf, buflen, entry, i,
					run->hevc.dpram->dpb[i].timestamp,
					vb2_buf ? vb2_buf->index : -1);
			buf += len;
			buflen -= len;
		}

		break;
	}
	}
}

static char *visl_get_vb2_state(enum vb2_buffer_state state)
{
	switch (state) {
	case VB2_BUF_STATE_DEQUEUED:
		return "Dequeued";
	case VB2_BUF_STATE_IN_REQUEST:
		return "In request";
	case VB2_BUF_STATE_PREPARING:
		return "Preparing";
	case VB2_BUF_STATE_QUEUED:
		return "Queued";
	case VB2_BUF_STATE_ACTIVE:
		return "Active";
	case VB2_BUF_STATE_DONE:
		return "Done";
	case VB2_BUF_STATE_ERROR:
		return "Error";
	default:
		return "";
	}
}

static int visl_fill_bytesused(struct vb2_v4l2_buffer *v4l2_vb2_buf, char *buf, size_t bufsz)
{
	int len = 0;
	u32 i;

	for (i = 0; i < v4l2_vb2_buf->vb2_buf.num_planes; i++)
		len += scnprintf(buf, bufsz,
				"bytesused[%u]: %u length[%u]: %u data_offset[%u]: %u",
				i, v4l2_vb2_buf->planes[i].bytesused,
				i, v4l2_vb2_buf->planes[i].length,
				i, v4l2_vb2_buf->planes[i].data_offset);

	return len;
}

static void visl_tpg_fill_sequence(struct visl_ctx *ctx,
				   struct visl_run *run, char buf[], size_t bufsz)
{
	u32 stream_ms;

	stream_ms = jiffies_to_msecs(get_jiffies_64() - ctx->capture_streamon_jiffies);

	scnprintf(buf, bufsz,
		  "stream time: %02d:%02d:%02d:%03d sequence:%u timestamp:%lld field:%s",
		  (stream_ms / (60 * 60 * 1000)) % 24,
		  (stream_ms / (60 * 1000)) % 60,
		  (stream_ms / 1000) % 60,
		  stream_ms % 1000,
		  run->dst->sequence,
		  run->dst->vb2_buf.timestamp,
		  (run->dst->field == V4L2_FIELD_ALTERNATE) ?
		  (run->dst->field == V4L2_FIELD_TOP ?
		  " top" : " bottom") : "none");
}

static void visl_tpg_fill(struct visl_ctx *ctx, struct visl_run *run)
{
	u8 *basep[TPG_MAX_PLANES][2];
	char *buf = ctx->tpg_str_buf;
	char *tmp = buf;
	char *line_str;
	u32 line = 1;
	const u32 line_height = 16;
	u32 len;
	struct vb2_queue *out_q = &ctx->fh.m2m_ctx->out_q_ctx.q;
	struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q;
	struct v4l2_pix_format_mplane *coded_fmt = &ctx->coded_fmt.fmt.pix_mp;
	struct v4l2_pix_format_mplane *decoded_fmt = &ctx->decoded_fmt.fmt.pix_mp;
	u32 p;
	u32 i;

	for (p = 0; p < tpg_g_planes(&ctx->tpg); p++) {
		void *vbuf = plane_vaddr(&ctx->tpg,
					 &run->dst->vb2_buf, p,
					 ctx->tpg.bytesperline,
					 ctx->tpg.buf_height);

		tpg_calc_text_basep(&ctx->tpg, basep, p, vbuf);
		tpg_fill_plane_buffer(&ctx->tpg, 0, p, vbuf);
	}

	visl_tpg_fill_sequence(ctx, run, buf, TPG_STR_BUF_SZ);
	tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, buf);
	frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf);
	frame_dprintk(ctx->dev, run->dst->sequence, "");
	line++;

	visl_get_ref_frames(ctx, buf, TPG_STR_BUF_SZ, run);

	while ((line_str = strsep(&tmp, "\n")) && strlen(line_str)) {
		tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, line_str);
		frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", line_str);
	}

	frame_dprintk(ctx->dev, run->dst->sequence, "");
	line++;

	scnprintf(buf,
		  TPG_STR_BUF_SZ,
		  "OUTPUT pixelformat: %c%c%c%c, resolution: %dx%d, num_planes: %d",
		  coded_fmt->pixelformat,
		  (coded_fmt->pixelformat >> 8) & 0xff,
		  (coded_fmt->pixelformat >> 16) & 0xff,
		  (coded_fmt->pixelformat >> 24) & 0xff,
		  coded_fmt->width,
		  coded_fmt->height,
		  coded_fmt->num_planes);

	tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, buf);
	frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf);

	for (i = 0; i < coded_fmt->num_planes; i++) {
		scnprintf(buf,
			  TPG_STR_BUF_SZ,
			  "plane[%d]: bytesperline: %d, sizeimage: %d",
			  i,
			  coded_fmt->plane_fmt[i].bytesperline,
			  coded_fmt->plane_fmt[i].sizeimage);

		tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, buf);
		frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf);
	}

	line++;
	frame_dprintk(ctx->dev, run->dst->sequence, "");
	scnprintf(buf, TPG_STR_BUF_SZ, "Output queue status:");
	tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, buf);
	frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf);

	len = 0;
	for (i = 0; i < out_q->num_buffers; i++) {
		char entry[] = "index: %u, state: %s, request_fd: %d, ";
		u32 old_len = len;
		char *q_status = visl_get_vb2_state(out_q->bufs[i]->state);

		len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len,
				 entry, i, q_status,
				 to_vb2_v4l2_buffer(out_q->bufs[i])->request_fd);

		len += visl_fill_bytesused(to_vb2_v4l2_buffer(out_q->bufs[i]),
					   &buf[len],
					   TPG_STR_BUF_SZ - len);

		tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, &buf[old_len]);
		frame_dprintk(ctx->dev, run->dst->sequence, "%s", &buf[old_len]);
	}

	line++;
	frame_dprintk(ctx->dev, run->dst->sequence, "");

	scnprintf(buf,
		  TPG_STR_BUF_SZ,
		  "CAPTURE pixelformat: %c%c%c%c, resolution: %dx%d, num_planes: %d",
		  decoded_fmt->pixelformat,
		  (decoded_fmt->pixelformat >> 8) & 0xff,
		  (decoded_fmt->pixelformat >> 16) & 0xff,
		  (decoded_fmt->pixelformat >> 24) & 0xff,
		  decoded_fmt->width,
		  decoded_fmt->height,
		  decoded_fmt->num_planes);

	tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, buf);
	frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf);

	for (i = 0; i < decoded_fmt->num_planes; i++) {
		scnprintf(buf,
			  TPG_STR_BUF_SZ,
			  "plane[%d]: bytesperline: %d, sizeimage: %d",
			  i,
			  decoded_fmt->plane_fmt[i].bytesperline,
			  decoded_fmt->plane_fmt[i].sizeimage);

		tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, buf);
		frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf);
	}

	line++;
	frame_dprintk(ctx->dev, run->dst->sequence, "");
	scnprintf(buf, TPG_STR_BUF_SZ, "Capture queue status:");
	tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, buf);
	frame_dprintk(ctx->dev, run->dst->sequence, "%s\n", buf);

	len = 0;
	for (i = 0; i < cap_q->num_buffers; i++) {
		u32 old_len = len;
		char *q_status = visl_get_vb2_state(cap_q->bufs[i]->state);

		len += scnprintf(&buf[len], TPG_STR_BUF_SZ - len,
				 "index: %u, status: %s, timestamp: %llu, is_held: %d",
				 cap_q->bufs[i]->index, q_status,
				 cap_q->bufs[i]->timestamp,
				 to_vb2_v4l2_buffer(cap_q->bufs[i])->is_held);

		tpg_gen_text(&ctx->tpg, basep, line++ * line_height, 16, &buf[old_len]);
		frame_dprintk(ctx->dev, run->dst->sequence, "%s", &buf[old_len]);
	}
}

static void visl_trace_ctrls(struct visl_ctx *ctx, struct visl_run *run)
{
	int i;

	switch (ctx->current_codec) {
	default:
	case VISL_CODEC_NONE:
		break;
	case VISL_CODEC_FWHT:
		trace_v4l2_ctrl_fwht_params(run->fwht.params);
		break;
	case VISL_CODEC_MPEG2:
		trace_v4l2_ctrl_mpeg2_sequence(run->mpeg2.seq);
		trace_v4l2_ctrl_mpeg2_picture(run->mpeg2.pic);
		trace_v4l2_ctrl_mpeg2_quantisation(run->mpeg2.quant);
		break;
	case VISL_CODEC_VP8:
		trace_v4l2_ctrl_vp8_frame(run->vp8.frame);
		trace_v4l2_ctrl_vp8_entropy(run->vp8.frame);
		break;
	case VISL_CODEC_VP9:
		trace_v4l2_ctrl_vp9_frame(run->vp9.frame);
		trace_v4l2_ctrl_vp9_compressed_hdr(run->vp9.probs);
		trace_v4l2_ctrl_vp9_compressed_coeff(run->vp9.probs);
		trace_v4l2_vp9_mv_probs(&run->vp9.probs->mv);
		break;
	case VISL_CODEC_H264:
		trace_v4l2_ctrl_h264_sps(run->h264.sps);
		trace_v4l2_ctrl_h264_pps(run->h264.pps);
		trace_v4l2_ctrl_h264_scaling_matrix(run->h264.sm);
		trace_v4l2_ctrl_h264_slice_params(run->h264.spram);

		for (i = 0; i < ARRAY_SIZE(run->h264.spram->ref_pic_list0); i++)
			trace_v4l2_h264_ref_pic_list0(&run->h264.spram->ref_pic_list0[i], i);
		for (i = 0; i < ARRAY_SIZE(run->h264.spram->ref_pic_list0); i++)
			trace_v4l2_h264_ref_pic_list1(&run->h264.spram->ref_pic_list1[i], i);

		trace_v4l2_ctrl_h264_decode_params(run->h264.dpram);

		for (i = 0; i < ARRAY_SIZE(run->h264.dpram->dpb); i++)
			trace_v4l2_h264_dpb_entry(&run->h264.dpram->dpb[i], i);

		trace_v4l2_ctrl_h264_pred_weights(run->h264.pwht);
		break;
	case VISL_CODEC_HEVC:
		trace_v4l2_ctrl_hevc_sps(run->hevc.sps);
		trace_v4l2_ctrl_hevc_pps(run->hevc.pps);
		trace_v4l2_ctrl_hevc_slice_params(run->hevc.spram);
		trace_v4l2_ctrl_hevc_scaling_matrix(run->hevc.sm);
		trace_v4l2_ctrl_hevc_decode_params(run->hevc.dpram);

		for (i = 0; i < ARRAY_SIZE(run->hevc.dpram->dpb); i++)
			trace_v4l2_hevc_dpb_entry(&run->hevc.dpram->dpb[i]);

		trace_v4l2_hevc_pred_weight_table(&run->hevc.spram->pred_weight_table);
	break;
	}
}

void visl_device_run(void *priv)
{
	struct visl_ctx *ctx = priv;
	struct visl_run run = {};
	struct media_request *src_req;

	run.src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
	run.dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);

	/* Apply request(s) controls if needed. */
	src_req = run.src->vb2_buf.req_obj.req;

	if (src_req)
		v4l2_ctrl_request_setup(src_req, &ctx->hdl);

	v4l2_m2m_buf_copy_metadata(run.src, run.dst, true);
	run.dst->sequence = ctx->q_data[V4L2_M2M_DST].sequence++;
	run.src->sequence = ctx->q_data[V4L2_M2M_SRC].sequence++;
	run.dst->field = ctx->decoded_fmt.fmt.pix.field;

	switch (ctx->current_codec) {
	default:
	case VISL_CODEC_NONE:
		break;
	case VISL_CODEC_FWHT:
		run.fwht.params = visl_find_control_data(ctx, V4L2_CID_STATELESS_FWHT_PARAMS);
		break;
	case VISL_CODEC_MPEG2:
		run.mpeg2.seq = visl_find_control_data(ctx, V4L2_CID_STATELESS_MPEG2_SEQUENCE);
		run.mpeg2.pic = visl_find_control_data(ctx, V4L2_CID_STATELESS_MPEG2_PICTURE);
		run.mpeg2.quant = visl_find_control_data(ctx,
							 V4L2_CID_STATELESS_MPEG2_QUANTISATION);
		break;
	case VISL_CODEC_VP8:
		run.vp8.frame = visl_find_control_data(ctx, V4L2_CID_STATELESS_VP8_FRAME);
		break;
	case VISL_CODEC_VP9:
		run.vp9.frame = visl_find_control_data(ctx, V4L2_CID_STATELESS_VP9_FRAME);
		run.vp9.probs = visl_find_control_data(ctx, V4L2_CID_STATELESS_VP9_COMPRESSED_HDR);
		break;
	case VISL_CODEC_H264:
		run.h264.sps = visl_find_control_data(ctx, V4L2_CID_STATELESS_H264_SPS);
		run.h264.pps = visl_find_control_data(ctx, V4L2_CID_STATELESS_H264_PPS);
		run.h264.sm = visl_find_control_data(ctx, V4L2_CID_STATELESS_H264_SCALING_MATRIX);
		run.h264.spram = visl_find_control_data(ctx, V4L2_CID_STATELESS_H264_SLICE_PARAMS);
		run.h264.dpram = visl_find_control_data(ctx, V4L2_CID_STATELESS_H264_DECODE_PARAMS);
		run.h264.pwht = visl_find_control_data(ctx, V4L2_CID_STATELESS_H264_PRED_WEIGHTS);
		break;
	case VISL_CODEC_HEVC:
		run.hevc.sps = visl_find_control_data(ctx, V4L2_CID_STATELESS_HEVC_SPS);
		run.hevc.pps = visl_find_control_data(ctx, V4L2_CID_STATELESS_HEVC_PPS);
		run.hevc.spram = visl_find_control_data(ctx, V4L2_CID_STATELESS_HEVC_SLICE_PARAMS);
		run.hevc.sm = visl_find_control_data(ctx, V4L2_CID_STATELESS_HEVC_SCALING_MATRIX);
		run.hevc.dpram = visl_find_control_data(ctx, V4L2_CID_STATELESS_HEVC_DECODE_PARAMS);
		break;
	}

	frame_dprintk(ctx->dev, run.dst->sequence,
		      "Got OUTPUT buffer sequence %d, timestamp %llu\n",
		      run.src->sequence, run.src->vb2_buf.timestamp);

	frame_dprintk(ctx->dev, run.dst->sequence,
		      "Got CAPTURE buffer sequence %d, timestamp %llu\n",
		      run.dst->sequence, run.dst->vb2_buf.timestamp);

	visl_tpg_fill(ctx, &run);
	visl_trace_ctrls(ctx, &run);

	if (bitstream_trace_frame_start > -1 &&
	    run.dst->sequence >= bitstream_trace_frame_start &&
	    run.dst->sequence < bitstream_trace_frame_start + bitstream_trace_nframes)
		visl_trace_bitstream(ctx, &run);

	/* Complete request(s) controls if needed. */
	if (src_req)
		v4l2_ctrl_request_complete(src_req, &ctx->hdl);

	if (visl_transtime_ms)
		usleep_range(visl_transtime_ms * 1000, 2 * visl_transtime_ms * 1000);

	v4l2_m2m_buf_done_and_job_finish(ctx->dev->m2m_dev,
					 ctx->fh.m2m_ctx, VB2_BUF_STATE_DONE);
}