Lines Matching +full:avg +full:- +full:samples
1 // SPDX-License-Identifier: GPL-2.0
11 #include "hva-hw.h"
15 struct hva_streaminfo *stream = &ctx->streaminfo; in format_ctx()
16 struct hva_frameinfo *frame = &ctx->frameinfo; in format_ctx()
17 struct hva_controls *ctrls = &ctx->ctrls; in format_ctx()
18 struct hva_ctx_dbg *dbg = &ctx->dbg; in format_ctx()
21 seq_printf(s, "|-%s\n |\n", ctx->name); in format_ctx()
23 seq_printf(s, " |-[%sframe info]\n", in format_ctx()
24 ctx->flags & HVA_FLAG_FRAMEINFO ? "" : "default "); in format_ctx()
25 seq_printf(s, " | |- pixel format=%4.4s\n" in format_ctx()
26 " | |- wxh=%dx%d\n" in format_ctx()
27 " | |- wxh (w/ encoder alignment constraint)=%dx%d\n" in format_ctx()
29 (char *)&frame->pixelformat, in format_ctx()
30 frame->width, frame->height, in format_ctx()
31 frame->aligned_width, frame->aligned_height); in format_ctx()
33 seq_printf(s, " |-[%sstream info]\n", in format_ctx()
34 ctx->flags & HVA_FLAG_STREAMINFO ? "" : "default "); in format_ctx()
35 seq_printf(s, " | |- stream format=%4.4s\n" in format_ctx()
36 " | |- wxh=%dx%d\n" in format_ctx()
37 " | |- %s\n" in format_ctx()
38 " | |- %s\n" in format_ctx()
40 (char *)&stream->streamformat, in format_ctx()
41 stream->width, stream->height, in format_ctx()
42 stream->profile, stream->level); in format_ctx()
46 seq_puts(s, " |-[parameters]\n"); in format_ctx()
47 seq_printf(s, " | |- %s\n" in format_ctx()
48 " | |- bitrate=%d bps\n" in format_ctx()
49 " | |- GOP size=%d\n" in format_ctx()
50 " | |- video aspect=%s\n" in format_ctx()
51 " | |- framerate=%d/%d\n", in format_ctx()
52 v4l2_ctrl_get_menu(bitrate_mode)[ctrls->bitrate_mode], in format_ctx()
53 ctrls->bitrate, in format_ctx()
54 ctrls->gop_size, in format_ctx()
55 v4l2_ctrl_get_menu(aspect)[ctrls->aspect], in format_ctx()
56 ctrls->time_per_frame.denominator, in format_ctx()
57 ctrls->time_per_frame.numerator); in format_ctx()
62 if (stream->streamformat == V4L2_PIX_FMT_H264) { in format_ctx()
63 seq_printf(s, " | |- %s entropy mode\n" in format_ctx()
64 " | |- CPB size=%d kB\n" in format_ctx()
65 " | |- DCT8x8 enable=%s\n" in format_ctx()
66 " | |- qpmin=%d\n" in format_ctx()
67 " | |- qpmax=%d\n" in format_ctx()
68 " | |- PAR enable=%s\n" in format_ctx()
69 " | |- PAR id=%s\n" in format_ctx()
70 " | |- SEI frame packing enable=%s\n" in format_ctx()
71 " | |- SEI frame packing type=%s\n", in format_ctx()
72 v4l2_ctrl_get_menu(entropy)[ctrls->entropy_mode], in format_ctx()
73 ctrls->cpb_size, in format_ctx()
74 ctrls->dct8x8 ? "true" : "false", in format_ctx()
75 ctrls->qpmin, in format_ctx()
76 ctrls->qpmax, in format_ctx()
77 ctrls->vui_sar ? "true" : "false", in format_ctx()
78 v4l2_ctrl_get_menu(vui_sar)[ctrls->vui_sar_idc], in format_ctx()
79 ctrls->sei_fp ? "true" : "false", in format_ctx()
80 v4l2_ctrl_get_menu(sei_fp)[ctrls->sei_fp_type]); in format_ctx()
83 if (ctx->sys_errors || ctx->encode_errors || ctx->frame_errors) { in format_ctx()
84 seq_puts(s, " |\n |-[errors]\n"); in format_ctx()
85 seq_printf(s, " | |- system=%d\n" in format_ctx()
86 " | |- encoding=%d\n" in format_ctx()
87 " | |- frame=%d\n", in format_ctx()
88 ctx->sys_errors, in format_ctx()
89 ctx->encode_errors, in format_ctx()
90 ctx->frame_errors); in format_ctx()
93 seq_puts(s, " |\n |-[performances]\n"); in format_ctx()
94 seq_printf(s, " | |- frames encoded=%d\n" in format_ctx()
95 " | |- avg HW processing duration (0.1ms)=%d [min=%d, max=%d]\n" in format_ctx()
96 " | |- avg encoding period (0.1ms)=%d [min=%d, max=%d]\n" in format_ctx()
97 " | |- avg fps (0.1Hz)=%d\n" in format_ctx()
98 " | |- max reachable fps (0.1Hz)=%d\n" in format_ctx()
99 " | |- avg bitrate (kbps)=%d [min=%d, max=%d]\n" in format_ctx()
100 " | |- last bitrate (kbps)=%d\n", in format_ctx()
101 dbg->cnt_duration, in format_ctx()
102 dbg->avg_duration, in format_ctx()
103 dbg->min_duration, in format_ctx()
104 dbg->max_duration, in format_ctx()
105 dbg->avg_period, in format_ctx()
106 dbg->min_period, in format_ctx()
107 dbg->max_period, in format_ctx()
108 dbg->avg_fps, in format_ctx()
109 dbg->max_fps, in format_ctx()
110 dbg->avg_bitrate, in format_ctx()
111 dbg->min_bitrate, in format_ctx()
112 dbg->max_bitrate, in format_ctx()
113 dbg->last_bitrate); in format_ctx()
124 struct hva_ctx_dbg *dbg = &ctx->dbg; in hva_dbg_perf_begin()
125 ktime_t prev = dbg->begin; in hva_dbg_perf_begin()
127 dbg->begin = ktime_get(); in hva_dbg_perf_begin()
129 if (dbg->is_valid_period) { in hva_dbg_perf_begin()
131 div = (u64)ktime_us_delta(dbg->begin, prev); in hva_dbg_perf_begin()
134 dbg->min_period = min(period, dbg->min_period); in hva_dbg_perf_begin()
135 dbg->max_period = max(period, dbg->max_period); in hva_dbg_perf_begin()
136 dbg->total_period += period; in hva_dbg_perf_begin()
137 dbg->cnt_period++; in hva_dbg_perf_begin()
141 * encoding period values upon a window of 32 samples in hva_dbg_perf_begin()
143 dbg->window_duration += period; in hva_dbg_perf_begin()
144 dbg->cnt_window++; in hva_dbg_perf_begin()
145 if (dbg->cnt_window >= 32) { in hva_dbg_perf_begin()
151 if (dbg->window_duration > 0) { in hva_dbg_perf_begin()
152 div = (u64)dbg->window_stream_size * 80; in hva_dbg_perf_begin()
153 do_div(div, dbg->window_duration); in hva_dbg_perf_begin()
155 dbg->last_bitrate = bitrate; in hva_dbg_perf_begin()
156 dbg->min_bitrate = min(bitrate, in hva_dbg_perf_begin()
157 dbg->min_bitrate); in hva_dbg_perf_begin()
158 dbg->max_bitrate = max(bitrate, in hva_dbg_perf_begin()
159 dbg->max_bitrate); in hva_dbg_perf_begin()
161 dbg->window_stream_size = 0; in hva_dbg_perf_begin()
162 dbg->window_duration = 0; in hva_dbg_perf_begin()
163 dbg->cnt_window = 0; in hva_dbg_perf_begin()
169 * - begin/begin (no stream available) is an invalid sequence in hva_dbg_perf_begin()
170 * - begin/end is a valid sequence in hva_dbg_perf_begin()
172 dbg->is_valid_period = false; in hva_dbg_perf_begin()
182 struct hva_ctx_dbg *dbg = &ctx->dbg; in hva_dbg_perf_end()
186 bytesused = vb2_get_plane_payload(&stream->vbuf.vb2_buf, 0); in hva_dbg_perf_end()
187 div = stream->vbuf.vb2_buf.timestamp; in hva_dbg_perf_end()
192 div = (u64)ktime_us_delta(end, dbg->begin); in hva_dbg_perf_end()
196 ctx->name, in hva_dbg_perf_end()
197 stream->vbuf.sequence, in hva_dbg_perf_end()
204 dbg->min_duration = min(duration, dbg->min_duration); in hva_dbg_perf_end()
205 dbg->max_duration = max(duration, dbg->max_duration); in hva_dbg_perf_end()
206 dbg->total_duration += duration; in hva_dbg_perf_end()
207 dbg->cnt_duration++; in hva_dbg_perf_end()
213 dbg->total_stream_size += bytesused; in hva_dbg_perf_end()
214 dbg->window_stream_size += bytesused; in hva_dbg_perf_end()
216 dbg->is_valid_period = true; in hva_dbg_perf_end()
222 struct hva_ctx_dbg *dbg = &ctx->dbg; in hva_dbg_perf_compute()
224 if (dbg->cnt_duration > 0) { in hva_dbg_perf_compute()
225 div = (u64)dbg->total_duration; in hva_dbg_perf_compute()
226 do_div(div, dbg->cnt_duration); in hva_dbg_perf_compute()
227 dbg->avg_duration = (u32)div; in hva_dbg_perf_compute()
229 dbg->avg_duration = 0; in hva_dbg_perf_compute()
232 if (dbg->total_duration > 0) { in hva_dbg_perf_compute()
233 div = (u64)dbg->cnt_duration * 100000; in hva_dbg_perf_compute()
234 do_div(div, dbg->total_duration); in hva_dbg_perf_compute()
235 dbg->max_fps = (u32)div; in hva_dbg_perf_compute()
237 dbg->max_fps = 0; in hva_dbg_perf_compute()
240 if (dbg->cnt_period > 0) { in hva_dbg_perf_compute()
241 div = (u64)dbg->total_period; in hva_dbg_perf_compute()
242 do_div(div, dbg->cnt_period); in hva_dbg_perf_compute()
243 dbg->avg_period = (u32)div; in hva_dbg_perf_compute()
245 dbg->avg_period = 0; in hva_dbg_perf_compute()
248 if (dbg->total_period > 0) { in hva_dbg_perf_compute()
249 div = (u64)dbg->cnt_period * 100000; in hva_dbg_perf_compute()
250 do_div(div, dbg->total_period); in hva_dbg_perf_compute()
251 dbg->avg_fps = (u32)div; in hva_dbg_perf_compute()
253 dbg->avg_fps = 0; in hva_dbg_perf_compute()
256 if (dbg->total_period > 0) { in hva_dbg_perf_compute()
262 div = (u64)dbg->total_stream_size * 80; in hva_dbg_perf_compute()
263 do_div(div, dbg->total_period); in hva_dbg_perf_compute()
264 dbg->avg_bitrate = (u32)div; in hva_dbg_perf_compute()
266 dbg->avg_bitrate = 0; in hva_dbg_perf_compute()
276 struct hva_dev *hva = s->private; in device_show()
278 seq_printf(s, "[%s]\n", hva->v4l2_dev.name); in device_show()
279 seq_printf(s, "registered as /dev/video%d\n", hva->vdev->num); in device_show()
286 struct hva_dev *hva = s->private; in encoders_show()
289 seq_printf(s, "[encoders]\n|- %d registered encoders:\n", in encoders_show()
290 hva->nb_of_encoders); in encoders_show()
292 while (hva->encoders[i]) { in encoders_show()
293 seq_printf(s, "|- %s: %4.4s => %4.4s\n", hva->encoders[i]->name, in encoders_show()
294 (char *)&hva->encoders[i]->pixelformat, in encoders_show()
295 (char *)&hva->encoders[i]->streamformat); in encoders_show()
304 struct hva_dev *hva = s->private; in last_show()
305 struct hva_ctx *last_ctx = &hva->dbg.last_ctx; in last_show()
307 if (last_ctx->flags & HVA_FLAG_STREAMINFO) { in last_show()
321 struct hva_dev *hva = s->private; in regs_show()
329 debugfs_create_file(#name, 0444, hva->dbg.debugfs_entry, hva, \
339 hva->dbg.debugfs_entry = debugfs_create_dir(HVA_NAME, NULL); in hva_debugfs_create()
349 debugfs_remove_recursive(hva->dbg.debugfs_entry); in hva_debugfs_remove()
350 hva->dbg.debugfs_entry = NULL; in hva_debugfs_remove()
359 struct hva_ctx *ctx = s->private; in ctx_show()
361 seq_printf(s, "[running encoding %d]\n", ctx->id); in ctx_show()
373 struct hva_dev *hva = ctx->hva_dev; in hva_dbg_ctx_create()
376 ctx->dbg.min_duration = UINT_MAX; in hva_dbg_ctx_create()
377 ctx->dbg.min_period = UINT_MAX; in hva_dbg_ctx_create()
378 ctx->dbg.min_bitrate = UINT_MAX; in hva_dbg_ctx_create()
380 snprintf(name, sizeof(name), "%d", hva->instance_id); in hva_dbg_ctx_create()
382 ctx->dbg.debugfs_entry = debugfs_create_file(name, 0444, in hva_dbg_ctx_create()
383 hva->dbg.debugfs_entry, in hva_dbg_ctx_create()
389 struct hva_dev *hva = ctx->hva_dev; in hva_dbg_ctx_remove()
391 if (ctx->flags & HVA_FLAG_STREAMINFO) in hva_dbg_ctx_remove()
393 memcpy(&hva->dbg.last_ctx, ctx, sizeof(*ctx)); in hva_dbg_ctx_remove()
395 debugfs_remove(ctx->dbg.debugfs_entry); in hva_dbg_ctx_remove()