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