Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
[sfrench/cifs-2.6.git] / drivers / media / platform / sti / delta / delta-debug.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) STMicroelectronics SA 2015
4  * Authors: Hugues Fruchet <hugues.fruchet@st.com>
5  *          Fabrice Lecoultre <fabrice.lecoultre@st.com>
6  *          for STMicroelectronics.
7  */
8
9 #include "delta.h"
10 #include "delta-debug.h"
11
12 char *delta_streaminfo_str(struct delta_streaminfo *s, char *str,
13                            unsigned int len)
14 {
15         if (!s)
16                 return NULL;
17
18         snprintf(str, len,
19                  "%4.4s %dx%d %s %s dpb=%d %s %s %s%dx%d@(%d,%d) %s%d/%d",
20                  (char *)&s->streamformat, s->width, s->height,
21                  s->profile, s->level, s->dpb,
22                  (s->field == V4L2_FIELD_NONE) ? "progressive" : "interlaced",
23                  s->other,
24                  s->flags & DELTA_STREAMINFO_FLAG_CROP ? "crop=" : "",
25                  s->crop.width, s->crop.height,
26                  s->crop.left, s->crop.top,
27                  s->flags & DELTA_STREAMINFO_FLAG_PIXELASPECT ? "par=" : "",
28                  s->pixelaspect.numerator,
29                  s->pixelaspect.denominator);
30
31         return str;
32 }
33
34 char *delta_frameinfo_str(struct delta_frameinfo *f, char *str,
35                           unsigned int len)
36 {
37         if (!f)
38                 return NULL;
39
40         snprintf(str, len,
41                  "%4.4s %dx%d aligned %dx%d %s %s%dx%d@(%d,%d) %s%d/%d",
42                  (char *)&f->pixelformat, f->width, f->height,
43                  f->aligned_width, f->aligned_height,
44                  (f->field == V4L2_FIELD_NONE) ? "progressive" : "interlaced",
45                  f->flags & DELTA_STREAMINFO_FLAG_CROP ? "crop=" : "",
46                  f->crop.width, f->crop.height,
47                  f->crop.left, f->crop.top,
48                  f->flags & DELTA_STREAMINFO_FLAG_PIXELASPECT ? "par=" : "",
49                  f->pixelaspect.numerator,
50                  f->pixelaspect.denominator);
51
52         return str;
53 }
54
55 void delta_trace_summary(struct delta_ctx *ctx)
56 {
57         struct delta_dev *delta = ctx->dev;
58         struct delta_streaminfo *s = &ctx->streaminfo;
59         unsigned char str[100] = "";
60
61         if (!(ctx->flags & DELTA_FLAG_STREAMINFO))
62                 return;
63
64         dev_dbg(delta->dev, "%s %s, %d frames decoded, %d frames output, %d frames dropped, %d stream errors, %d decode errors",
65                 ctx->name,
66                 delta_streaminfo_str(s, str, sizeof(str)),
67                 ctx->decoded_frames,
68                 ctx->output_frames,
69                 ctx->dropped_frames,
70                 ctx->stream_errors,
71                 ctx->decode_errors);
72 }