1*e7b8153eSMauro Carvalho Chehab // SPDX-License-Identifier: GPL-2.0
2*e7b8153eSMauro Carvalho Chehab /*
3*e7b8153eSMauro Carvalho Chehab * Copyright (C) STMicroelectronics SA 2014
4*e7b8153eSMauro Carvalho Chehab * Authors: Fabien Dessenne <fabien.dessenne@st.com> for STMicroelectronics.
5*e7b8153eSMauro Carvalho Chehab */
6*e7b8153eSMauro Carvalho Chehab
7*e7b8153eSMauro Carvalho Chehab #include <linux/debugfs.h>
8*e7b8153eSMauro Carvalho Chehab #include <linux/pm_runtime.h>
9*e7b8153eSMauro Carvalho Chehab
10*e7b8153eSMauro Carvalho Chehab #include "bdisp.h"
11*e7b8153eSMauro Carvalho Chehab #include "bdisp-filter.h"
12*e7b8153eSMauro Carvalho Chehab #include "bdisp-reg.h"
13*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_perf_begin(struct bdisp_dev * bdisp)14*e7b8153eSMauro Carvalho Chehab void bdisp_dbg_perf_begin(struct bdisp_dev *bdisp)
15*e7b8153eSMauro Carvalho Chehab {
16*e7b8153eSMauro Carvalho Chehab bdisp->dbg.hw_start = ktime_get();
17*e7b8153eSMauro Carvalho Chehab }
18*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_perf_end(struct bdisp_dev * bdisp)19*e7b8153eSMauro Carvalho Chehab void bdisp_dbg_perf_end(struct bdisp_dev *bdisp)
20*e7b8153eSMauro Carvalho Chehab {
21*e7b8153eSMauro Carvalho Chehab s64 time_us;
22*e7b8153eSMauro Carvalho Chehab
23*e7b8153eSMauro Carvalho Chehab time_us = ktime_us_delta(ktime_get(), bdisp->dbg.hw_start);
24*e7b8153eSMauro Carvalho Chehab
25*e7b8153eSMauro Carvalho Chehab if (!bdisp->dbg.min_duration)
26*e7b8153eSMauro Carvalho Chehab bdisp->dbg.min_duration = time_us;
27*e7b8153eSMauro Carvalho Chehab else
28*e7b8153eSMauro Carvalho Chehab bdisp->dbg.min_duration = min(time_us, bdisp->dbg.min_duration);
29*e7b8153eSMauro Carvalho Chehab
30*e7b8153eSMauro Carvalho Chehab bdisp->dbg.last_duration = time_us;
31*e7b8153eSMauro Carvalho Chehab bdisp->dbg.max_duration = max(time_us, bdisp->dbg.max_duration);
32*e7b8153eSMauro Carvalho Chehab bdisp->dbg.tot_duration += time_us;
33*e7b8153eSMauro Carvalho Chehab }
34*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_dump_ins(struct seq_file * s,u32 val)35*e7b8153eSMauro Carvalho Chehab static void bdisp_dbg_dump_ins(struct seq_file *s, u32 val)
36*e7b8153eSMauro Carvalho Chehab {
37*e7b8153eSMauro Carvalho Chehab seq_printf(s, "INS\t0x%08X\t", val);
38*e7b8153eSMauro Carvalho Chehab
39*e7b8153eSMauro Carvalho Chehab switch (val & BLT_INS_S1_MASK) {
40*e7b8153eSMauro Carvalho Chehab case BLT_INS_S1_OFF:
41*e7b8153eSMauro Carvalho Chehab break;
42*e7b8153eSMauro Carvalho Chehab case BLT_INS_S1_MEM:
43*e7b8153eSMauro Carvalho Chehab seq_puts(s, "SRC1=mem - ");
44*e7b8153eSMauro Carvalho Chehab break;
45*e7b8153eSMauro Carvalho Chehab case BLT_INS_S1_CF:
46*e7b8153eSMauro Carvalho Chehab seq_puts(s, "SRC1=ColorFill - ");
47*e7b8153eSMauro Carvalho Chehab break;
48*e7b8153eSMauro Carvalho Chehab case BLT_INS_S1_COPY:
49*e7b8153eSMauro Carvalho Chehab seq_puts(s, "SRC1=copy - ");
50*e7b8153eSMauro Carvalho Chehab break;
51*e7b8153eSMauro Carvalho Chehab case BLT_INS_S1_FILL:
52*e7b8153eSMauro Carvalho Chehab seq_puts(s, "SRC1=fil - ");
53*e7b8153eSMauro Carvalho Chehab break;
54*e7b8153eSMauro Carvalho Chehab default:
55*e7b8153eSMauro Carvalho Chehab seq_puts(s, "SRC1=??? - ");
56*e7b8153eSMauro Carvalho Chehab break;
57*e7b8153eSMauro Carvalho Chehab }
58*e7b8153eSMauro Carvalho Chehab
59*e7b8153eSMauro Carvalho Chehab switch (val & BLT_INS_S2_MASK) {
60*e7b8153eSMauro Carvalho Chehab case BLT_INS_S2_OFF:
61*e7b8153eSMauro Carvalho Chehab break;
62*e7b8153eSMauro Carvalho Chehab case BLT_INS_S2_MEM:
63*e7b8153eSMauro Carvalho Chehab seq_puts(s, "SRC2=mem - ");
64*e7b8153eSMauro Carvalho Chehab break;
65*e7b8153eSMauro Carvalho Chehab case BLT_INS_S2_CF:
66*e7b8153eSMauro Carvalho Chehab seq_puts(s, "SRC2=ColorFill - ");
67*e7b8153eSMauro Carvalho Chehab break;
68*e7b8153eSMauro Carvalho Chehab default:
69*e7b8153eSMauro Carvalho Chehab seq_puts(s, "SRC2=??? - ");
70*e7b8153eSMauro Carvalho Chehab break;
71*e7b8153eSMauro Carvalho Chehab }
72*e7b8153eSMauro Carvalho Chehab
73*e7b8153eSMauro Carvalho Chehab if ((val & BLT_INS_S3_MASK) == BLT_INS_S3_MEM)
74*e7b8153eSMauro Carvalho Chehab seq_puts(s, "SRC3=mem - ");
75*e7b8153eSMauro Carvalho Chehab
76*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_IVMX)
77*e7b8153eSMauro Carvalho Chehab seq_puts(s, "IVMX - ");
78*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_CLUT)
79*e7b8153eSMauro Carvalho Chehab seq_puts(s, "CLUT - ");
80*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_SCALE)
81*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Scale - ");
82*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_FLICK)
83*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Flicker - ");
84*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_CLIP)
85*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Clip - ");
86*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_CKEY)
87*e7b8153eSMauro Carvalho Chehab seq_puts(s, "ColorKey - ");
88*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_OVMX)
89*e7b8153eSMauro Carvalho Chehab seq_puts(s, "OVMX - ");
90*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_DEI)
91*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Deint - ");
92*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_PMASK)
93*e7b8153eSMauro Carvalho Chehab seq_puts(s, "PlaneMask - ");
94*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_VC1R)
95*e7b8153eSMauro Carvalho Chehab seq_puts(s, "VC1R - ");
96*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_ROTATE)
97*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Rotate - ");
98*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_GRAD)
99*e7b8153eSMauro Carvalho Chehab seq_puts(s, "GradFill - ");
100*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_AQLOCK)
101*e7b8153eSMauro Carvalho Chehab seq_puts(s, "AQLock - ");
102*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_PACE)
103*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Pace - ");
104*e7b8153eSMauro Carvalho Chehab if (val & BLT_INS_IRQ)
105*e7b8153eSMauro Carvalho Chehab seq_puts(s, "IRQ - ");
106*e7b8153eSMauro Carvalho Chehab
107*e7b8153eSMauro Carvalho Chehab seq_putc(s, '\n');
108*e7b8153eSMauro Carvalho Chehab }
109*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_dump_tty(struct seq_file * s,u32 val)110*e7b8153eSMauro Carvalho Chehab static void bdisp_dbg_dump_tty(struct seq_file *s, u32 val)
111*e7b8153eSMauro Carvalho Chehab {
112*e7b8153eSMauro Carvalho Chehab seq_printf(s, "TTY\t0x%08X\t", val);
113*e7b8153eSMauro Carvalho Chehab seq_printf(s, "Pitch=%d - ", val & 0xFFFF);
114*e7b8153eSMauro Carvalho Chehab
115*e7b8153eSMauro Carvalho Chehab switch ((val & BLT_TTY_COL_MASK) >> BLT_TTY_COL_SHIFT) {
116*e7b8153eSMauro Carvalho Chehab case BDISP_RGB565:
117*e7b8153eSMauro Carvalho Chehab seq_puts(s, "RGB565 - ");
118*e7b8153eSMauro Carvalho Chehab break;
119*e7b8153eSMauro Carvalho Chehab case BDISP_RGB888:
120*e7b8153eSMauro Carvalho Chehab seq_puts(s, "RGB888 - ");
121*e7b8153eSMauro Carvalho Chehab break;
122*e7b8153eSMauro Carvalho Chehab case BDISP_XRGB8888:
123*e7b8153eSMauro Carvalho Chehab seq_puts(s, "xRGB888 - ");
124*e7b8153eSMauro Carvalho Chehab break;
125*e7b8153eSMauro Carvalho Chehab case BDISP_ARGB8888:
126*e7b8153eSMauro Carvalho Chehab seq_puts(s, "ARGB8888 - ");
127*e7b8153eSMauro Carvalho Chehab break;
128*e7b8153eSMauro Carvalho Chehab case BDISP_NV12:
129*e7b8153eSMauro Carvalho Chehab seq_puts(s, "NV12 - ");
130*e7b8153eSMauro Carvalho Chehab break;
131*e7b8153eSMauro Carvalho Chehab case BDISP_YUV_3B:
132*e7b8153eSMauro Carvalho Chehab seq_puts(s, "YUV420P - ");
133*e7b8153eSMauro Carvalho Chehab break;
134*e7b8153eSMauro Carvalho Chehab default:
135*e7b8153eSMauro Carvalho Chehab seq_puts(s, "ColorFormat ??? - ");
136*e7b8153eSMauro Carvalho Chehab break;
137*e7b8153eSMauro Carvalho Chehab }
138*e7b8153eSMauro Carvalho Chehab
139*e7b8153eSMauro Carvalho Chehab if (val & BLT_TTY_ALPHA_R)
140*e7b8153eSMauro Carvalho Chehab seq_puts(s, "AlphaRange - ");
141*e7b8153eSMauro Carvalho Chehab if (val & BLT_TTY_CR_NOT_CB)
142*e7b8153eSMauro Carvalho Chehab seq_puts(s, "CrNotCb - ");
143*e7b8153eSMauro Carvalho Chehab if (val & BLT_TTY_MB)
144*e7b8153eSMauro Carvalho Chehab seq_puts(s, "MB - ");
145*e7b8153eSMauro Carvalho Chehab if (val & BLT_TTY_HSO)
146*e7b8153eSMauro Carvalho Chehab seq_puts(s, "HSO inverse - ");
147*e7b8153eSMauro Carvalho Chehab if (val & BLT_TTY_VSO)
148*e7b8153eSMauro Carvalho Chehab seq_puts(s, "VSO inverse - ");
149*e7b8153eSMauro Carvalho Chehab if (val & BLT_TTY_DITHER)
150*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Dither - ");
151*e7b8153eSMauro Carvalho Chehab if (val & BLT_TTY_CHROMA)
152*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Write CHROMA - ");
153*e7b8153eSMauro Carvalho Chehab if (val & BLT_TTY_BIG_END)
154*e7b8153eSMauro Carvalho Chehab seq_puts(s, "BigEndian - ");
155*e7b8153eSMauro Carvalho Chehab
156*e7b8153eSMauro Carvalho Chehab seq_putc(s, '\n');
157*e7b8153eSMauro Carvalho Chehab }
158*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_dump_xy(struct seq_file * s,u32 val,char * name)159*e7b8153eSMauro Carvalho Chehab static void bdisp_dbg_dump_xy(struct seq_file *s, u32 val, char *name)
160*e7b8153eSMauro Carvalho Chehab {
161*e7b8153eSMauro Carvalho Chehab seq_printf(s, "%s\t0x%08X\t", name, val);
162*e7b8153eSMauro Carvalho Chehab seq_printf(s, "(%d,%d)\n", val & 0xFFFF, (val >> 16));
163*e7b8153eSMauro Carvalho Chehab }
164*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_dump_sz(struct seq_file * s,u32 val,char * name)165*e7b8153eSMauro Carvalho Chehab static void bdisp_dbg_dump_sz(struct seq_file *s, u32 val, char *name)
166*e7b8153eSMauro Carvalho Chehab {
167*e7b8153eSMauro Carvalho Chehab seq_printf(s, "%s\t0x%08X\t", name, val);
168*e7b8153eSMauro Carvalho Chehab seq_printf(s, "%dx%d\n", val & 0x1FFF, (val >> 16) & 0x1FFF);
169*e7b8153eSMauro Carvalho Chehab }
170*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_dump_sty(struct seq_file * s,u32 val,u32 addr,char * name)171*e7b8153eSMauro Carvalho Chehab static void bdisp_dbg_dump_sty(struct seq_file *s,
172*e7b8153eSMauro Carvalho Chehab u32 val, u32 addr, char *name)
173*e7b8153eSMauro Carvalho Chehab {
174*e7b8153eSMauro Carvalho Chehab bool s1, s2, s3;
175*e7b8153eSMauro Carvalho Chehab
176*e7b8153eSMauro Carvalho Chehab seq_printf(s, "%s\t0x%08X\t", name, val);
177*e7b8153eSMauro Carvalho Chehab
178*e7b8153eSMauro Carvalho Chehab if (!addr || !name || (strlen(name) < 2))
179*e7b8153eSMauro Carvalho Chehab goto done;
180*e7b8153eSMauro Carvalho Chehab
181*e7b8153eSMauro Carvalho Chehab s1 = name[strlen(name) - 1] == '1';
182*e7b8153eSMauro Carvalho Chehab s2 = name[strlen(name) - 1] == '2';
183*e7b8153eSMauro Carvalho Chehab s3 = name[strlen(name) - 1] == '3';
184*e7b8153eSMauro Carvalho Chehab
185*e7b8153eSMauro Carvalho Chehab seq_printf(s, "Pitch=%d - ", val & 0xFFFF);
186*e7b8153eSMauro Carvalho Chehab
187*e7b8153eSMauro Carvalho Chehab switch ((val & BLT_TTY_COL_MASK) >> BLT_TTY_COL_SHIFT) {
188*e7b8153eSMauro Carvalho Chehab case BDISP_RGB565:
189*e7b8153eSMauro Carvalho Chehab seq_puts(s, "RGB565 - ");
190*e7b8153eSMauro Carvalho Chehab break;
191*e7b8153eSMauro Carvalho Chehab case BDISP_RGB888:
192*e7b8153eSMauro Carvalho Chehab seq_puts(s, "RGB888 - ");
193*e7b8153eSMauro Carvalho Chehab break;
194*e7b8153eSMauro Carvalho Chehab case BDISP_XRGB8888:
195*e7b8153eSMauro Carvalho Chehab seq_puts(s, "xRGB888 - ");
196*e7b8153eSMauro Carvalho Chehab break;
197*e7b8153eSMauro Carvalho Chehab case BDISP_ARGB8888:
198*e7b8153eSMauro Carvalho Chehab seq_puts(s, "ARGB888 - ");
199*e7b8153eSMauro Carvalho Chehab break;
200*e7b8153eSMauro Carvalho Chehab case BDISP_NV12:
201*e7b8153eSMauro Carvalho Chehab seq_puts(s, "NV12 - ");
202*e7b8153eSMauro Carvalho Chehab break;
203*e7b8153eSMauro Carvalho Chehab case BDISP_YUV_3B:
204*e7b8153eSMauro Carvalho Chehab seq_puts(s, "YUV420P - ");
205*e7b8153eSMauro Carvalho Chehab break;
206*e7b8153eSMauro Carvalho Chehab default:
207*e7b8153eSMauro Carvalho Chehab seq_puts(s, "ColorFormat ??? - ");
208*e7b8153eSMauro Carvalho Chehab break;
209*e7b8153eSMauro Carvalho Chehab }
210*e7b8153eSMauro Carvalho Chehab
211*e7b8153eSMauro Carvalho Chehab if ((val & BLT_TTY_ALPHA_R) && !s3)
212*e7b8153eSMauro Carvalho Chehab seq_puts(s, "AlphaRange - ");
213*e7b8153eSMauro Carvalho Chehab if ((val & BLT_S1TY_A1_SUBSET) && !s3)
214*e7b8153eSMauro Carvalho Chehab seq_puts(s, "A1SubSet - ");
215*e7b8153eSMauro Carvalho Chehab if ((val & BLT_TTY_MB) && !s1)
216*e7b8153eSMauro Carvalho Chehab seq_puts(s, "MB - ");
217*e7b8153eSMauro Carvalho Chehab if (val & BLT_TTY_HSO)
218*e7b8153eSMauro Carvalho Chehab seq_puts(s, "HSO inverse - ");
219*e7b8153eSMauro Carvalho Chehab if (val & BLT_TTY_VSO)
220*e7b8153eSMauro Carvalho Chehab seq_puts(s, "VSO inverse - ");
221*e7b8153eSMauro Carvalho Chehab if ((val & BLT_S1TY_CHROMA_EXT) && (s1 || s2))
222*e7b8153eSMauro Carvalho Chehab seq_puts(s, "ChromaExt - ");
223*e7b8153eSMauro Carvalho Chehab if ((val & BLT_S3TY_BLANK_ACC) && s3)
224*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Blank Acc - ");
225*e7b8153eSMauro Carvalho Chehab if ((val & BTL_S1TY_SUBBYTE) && !s3)
226*e7b8153eSMauro Carvalho Chehab seq_puts(s, "SubByte - ");
227*e7b8153eSMauro Carvalho Chehab if ((val & BLT_S1TY_RGB_EXP) && !s3)
228*e7b8153eSMauro Carvalho Chehab seq_puts(s, "RGBExpand - ");
229*e7b8153eSMauro Carvalho Chehab if ((val & BLT_TTY_BIG_END) && !s3)
230*e7b8153eSMauro Carvalho Chehab seq_puts(s, "BigEndian - ");
231*e7b8153eSMauro Carvalho Chehab
232*e7b8153eSMauro Carvalho Chehab done:
233*e7b8153eSMauro Carvalho Chehab seq_putc(s, '\n');
234*e7b8153eSMauro Carvalho Chehab }
235*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_dump_fctl(struct seq_file * s,u32 val)236*e7b8153eSMauro Carvalho Chehab static void bdisp_dbg_dump_fctl(struct seq_file *s, u32 val)
237*e7b8153eSMauro Carvalho Chehab {
238*e7b8153eSMauro Carvalho Chehab seq_printf(s, "FCTL\t0x%08X\t", val);
239*e7b8153eSMauro Carvalho Chehab
240*e7b8153eSMauro Carvalho Chehab if ((val & BLT_FCTL_Y_HV_SCALE) == BLT_FCTL_Y_HV_SCALE)
241*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Resize Luma - ");
242*e7b8153eSMauro Carvalho Chehab else if ((val & BLT_FCTL_Y_HV_SCALE) == BLT_FCTL_Y_HV_SAMPLE)
243*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Sample Luma - ");
244*e7b8153eSMauro Carvalho Chehab
245*e7b8153eSMauro Carvalho Chehab if ((val & BLT_FCTL_HV_SCALE) == BLT_FCTL_HV_SCALE)
246*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Resize Chroma");
247*e7b8153eSMauro Carvalho Chehab else if ((val & BLT_FCTL_HV_SCALE) == BLT_FCTL_HV_SAMPLE)
248*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Sample Chroma");
249*e7b8153eSMauro Carvalho Chehab
250*e7b8153eSMauro Carvalho Chehab seq_putc(s, '\n');
251*e7b8153eSMauro Carvalho Chehab }
252*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_dump_rsf(struct seq_file * s,u32 val,char * name)253*e7b8153eSMauro Carvalho Chehab static void bdisp_dbg_dump_rsf(struct seq_file *s, u32 val, char *name)
254*e7b8153eSMauro Carvalho Chehab {
255*e7b8153eSMauro Carvalho Chehab u32 inc;
256*e7b8153eSMauro Carvalho Chehab
257*e7b8153eSMauro Carvalho Chehab seq_printf(s, "%s\t0x%08X\t", name, val);
258*e7b8153eSMauro Carvalho Chehab
259*e7b8153eSMauro Carvalho Chehab if (!val)
260*e7b8153eSMauro Carvalho Chehab goto done;
261*e7b8153eSMauro Carvalho Chehab
262*e7b8153eSMauro Carvalho Chehab inc = val & 0xFFFF;
263*e7b8153eSMauro Carvalho Chehab seq_printf(s, "H: %d(6.10) / scale~%dx0.1 - ", inc, 1024 * 10 / inc);
264*e7b8153eSMauro Carvalho Chehab
265*e7b8153eSMauro Carvalho Chehab inc = val >> 16;
266*e7b8153eSMauro Carvalho Chehab seq_printf(s, "V: %d(6.10) / scale~%dx0.1", inc, 1024 * 10 / inc);
267*e7b8153eSMauro Carvalho Chehab
268*e7b8153eSMauro Carvalho Chehab done:
269*e7b8153eSMauro Carvalho Chehab seq_putc(s, '\n');
270*e7b8153eSMauro Carvalho Chehab }
271*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_dump_rzi(struct seq_file * s,u32 val,char * name)272*e7b8153eSMauro Carvalho Chehab static void bdisp_dbg_dump_rzi(struct seq_file *s, u32 val, char *name)
273*e7b8153eSMauro Carvalho Chehab {
274*e7b8153eSMauro Carvalho Chehab seq_printf(s, "%s\t0x%08X\t", name, val);
275*e7b8153eSMauro Carvalho Chehab
276*e7b8153eSMauro Carvalho Chehab if (!val)
277*e7b8153eSMauro Carvalho Chehab goto done;
278*e7b8153eSMauro Carvalho Chehab
279*e7b8153eSMauro Carvalho Chehab seq_printf(s, "H: init=%d repeat=%d - ", val & 0x3FF, (val >> 12) & 7);
280*e7b8153eSMauro Carvalho Chehab val >>= 16;
281*e7b8153eSMauro Carvalho Chehab seq_printf(s, "V: init=%d repeat=%d", val & 0x3FF, (val >> 12) & 7);
282*e7b8153eSMauro Carvalho Chehab
283*e7b8153eSMauro Carvalho Chehab done:
284*e7b8153eSMauro Carvalho Chehab seq_putc(s, '\n');
285*e7b8153eSMauro Carvalho Chehab }
286*e7b8153eSMauro Carvalho Chehab
bdisp_dbg_dump_ivmx(struct seq_file * s,u32 c0,u32 c1,u32 c2,u32 c3)287*e7b8153eSMauro Carvalho Chehab static void bdisp_dbg_dump_ivmx(struct seq_file *s,
288*e7b8153eSMauro Carvalho Chehab u32 c0, u32 c1, u32 c2, u32 c3)
289*e7b8153eSMauro Carvalho Chehab {
290*e7b8153eSMauro Carvalho Chehab seq_printf(s, "IVMX0\t0x%08X\n", c0);
291*e7b8153eSMauro Carvalho Chehab seq_printf(s, "IVMX1\t0x%08X\n", c1);
292*e7b8153eSMauro Carvalho Chehab seq_printf(s, "IVMX2\t0x%08X\n", c2);
293*e7b8153eSMauro Carvalho Chehab seq_printf(s, "IVMX3\t0x%08X\t", c3);
294*e7b8153eSMauro Carvalho Chehab
295*e7b8153eSMauro Carvalho Chehab if (!c0 && !c1 && !c2 && !c3) {
296*e7b8153eSMauro Carvalho Chehab seq_putc(s, '\n');
297*e7b8153eSMauro Carvalho Chehab return;
298*e7b8153eSMauro Carvalho Chehab }
299*e7b8153eSMauro Carvalho Chehab
300*e7b8153eSMauro Carvalho Chehab if ((c0 == bdisp_rgb_to_yuv[0]) &&
301*e7b8153eSMauro Carvalho Chehab (c1 == bdisp_rgb_to_yuv[1]) &&
302*e7b8153eSMauro Carvalho Chehab (c2 == bdisp_rgb_to_yuv[2]) &&
303*e7b8153eSMauro Carvalho Chehab (c3 == bdisp_rgb_to_yuv[3])) {
304*e7b8153eSMauro Carvalho Chehab seq_puts(s, "RGB to YUV\n");
305*e7b8153eSMauro Carvalho Chehab return;
306*e7b8153eSMauro Carvalho Chehab }
307*e7b8153eSMauro Carvalho Chehab
308*e7b8153eSMauro Carvalho Chehab if ((c0 == bdisp_yuv_to_rgb[0]) &&
309*e7b8153eSMauro Carvalho Chehab (c1 == bdisp_yuv_to_rgb[1]) &&
310*e7b8153eSMauro Carvalho Chehab (c2 == bdisp_yuv_to_rgb[2]) &&
311*e7b8153eSMauro Carvalho Chehab (c3 == bdisp_yuv_to_rgb[3])) {
312*e7b8153eSMauro Carvalho Chehab seq_puts(s, "YUV to RGB\n");
313*e7b8153eSMauro Carvalho Chehab return;
314*e7b8153eSMauro Carvalho Chehab }
315*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Unknown conversion\n");
316*e7b8153eSMauro Carvalho Chehab }
317*e7b8153eSMauro Carvalho Chehab
last_nodes_show(struct seq_file * s,void * data)318*e7b8153eSMauro Carvalho Chehab static int last_nodes_show(struct seq_file *s, void *data)
319*e7b8153eSMauro Carvalho Chehab {
320*e7b8153eSMauro Carvalho Chehab /* Not dumping all fields, focusing on significant ones */
321*e7b8153eSMauro Carvalho Chehab struct bdisp_dev *bdisp = s->private;
322*e7b8153eSMauro Carvalho Chehab struct bdisp_node *node;
323*e7b8153eSMauro Carvalho Chehab int i = 0;
324*e7b8153eSMauro Carvalho Chehab
325*e7b8153eSMauro Carvalho Chehab if (!bdisp->dbg.copy_node[0]) {
326*e7b8153eSMauro Carvalho Chehab seq_puts(s, "No node built yet\n");
327*e7b8153eSMauro Carvalho Chehab return 0;
328*e7b8153eSMauro Carvalho Chehab }
329*e7b8153eSMauro Carvalho Chehab
330*e7b8153eSMauro Carvalho Chehab do {
331*e7b8153eSMauro Carvalho Chehab node = bdisp->dbg.copy_node[i];
332*e7b8153eSMauro Carvalho Chehab if (!node)
333*e7b8153eSMauro Carvalho Chehab break;
334*e7b8153eSMauro Carvalho Chehab seq_printf(s, "--------\nNode %d:\n", i);
335*e7b8153eSMauro Carvalho Chehab seq_puts(s, "-- General --\n");
336*e7b8153eSMauro Carvalho Chehab seq_printf(s, "NIP\t0x%08X\n", node->nip);
337*e7b8153eSMauro Carvalho Chehab seq_printf(s, "CIC\t0x%08X\n", node->cic);
338*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_ins(s, node->ins);
339*e7b8153eSMauro Carvalho Chehab seq_printf(s, "ACK\t0x%08X\n", node->ack);
340*e7b8153eSMauro Carvalho Chehab seq_puts(s, "-- Target --\n");
341*e7b8153eSMauro Carvalho Chehab seq_printf(s, "TBA\t0x%08X\n", node->tba);
342*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_tty(s, node->tty);
343*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_xy(s, node->txy, "TXY");
344*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_sz(s, node->tsz, "TSZ");
345*e7b8153eSMauro Carvalho Chehab /* Color Fill not dumped */
346*e7b8153eSMauro Carvalho Chehab seq_puts(s, "-- Source 1 --\n");
347*e7b8153eSMauro Carvalho Chehab seq_printf(s, "S1BA\t0x%08X\n", node->s1ba);
348*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_sty(s, node->s1ty, node->s1ba, "S1TY");
349*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_xy(s, node->s1xy, "S1XY");
350*e7b8153eSMauro Carvalho Chehab seq_puts(s, "-- Source 2 --\n");
351*e7b8153eSMauro Carvalho Chehab seq_printf(s, "S2BA\t0x%08X\n", node->s2ba);
352*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_sty(s, node->s2ty, node->s2ba, "S2TY");
353*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_xy(s, node->s2xy, "S2XY");
354*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_sz(s, node->s2sz, "S2SZ");
355*e7b8153eSMauro Carvalho Chehab seq_puts(s, "-- Source 3 --\n");
356*e7b8153eSMauro Carvalho Chehab seq_printf(s, "S3BA\t0x%08X\n", node->s3ba);
357*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_sty(s, node->s3ty, node->s3ba, "S3TY");
358*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_xy(s, node->s3xy, "S3XY");
359*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_sz(s, node->s3sz, "S3SZ");
360*e7b8153eSMauro Carvalho Chehab /* Clipping not dumped */
361*e7b8153eSMauro Carvalho Chehab /* CLUT not dumped */
362*e7b8153eSMauro Carvalho Chehab seq_puts(s, "-- Filter & Mask --\n");
363*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_fctl(s, node->fctl);
364*e7b8153eSMauro Carvalho Chehab /* PMK not dumped */
365*e7b8153eSMauro Carvalho Chehab seq_puts(s, "-- Chroma Filter --\n");
366*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_rsf(s, node->rsf, "RSF");
367*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_rzi(s, node->rzi, "RZI");
368*e7b8153eSMauro Carvalho Chehab seq_printf(s, "HFP\t0x%08X\n", node->hfp);
369*e7b8153eSMauro Carvalho Chehab seq_printf(s, "VFP\t0x%08X\n", node->vfp);
370*e7b8153eSMauro Carvalho Chehab seq_puts(s, "-- Luma Filter --\n");
371*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_rsf(s, node->y_rsf, "Y_RSF");
372*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_rzi(s, node->y_rzi, "Y_RZI");
373*e7b8153eSMauro Carvalho Chehab seq_printf(s, "Y_HFP\t0x%08X\n", node->y_hfp);
374*e7b8153eSMauro Carvalho Chehab seq_printf(s, "Y_VFP\t0x%08X\n", node->y_vfp);
375*e7b8153eSMauro Carvalho Chehab /* Flicker not dumped */
376*e7b8153eSMauro Carvalho Chehab /* Color key not dumped */
377*e7b8153eSMauro Carvalho Chehab /* Reserved not dumped */
378*e7b8153eSMauro Carvalho Chehab /* Static Address & User not dumped */
379*e7b8153eSMauro Carvalho Chehab seq_puts(s, "-- Input Versatile Matrix --\n");
380*e7b8153eSMauro Carvalho Chehab bdisp_dbg_dump_ivmx(s, node->ivmx0, node->ivmx1,
381*e7b8153eSMauro Carvalho Chehab node->ivmx2, node->ivmx3);
382*e7b8153eSMauro Carvalho Chehab /* Output Versatile Matrix not dumped */
383*e7b8153eSMauro Carvalho Chehab /* Pace not dumped */
384*e7b8153eSMauro Carvalho Chehab /* VC1R & DEI not dumped */
385*e7b8153eSMauro Carvalho Chehab /* Gradient Fill not dumped */
386*e7b8153eSMauro Carvalho Chehab } while ((++i < MAX_NB_NODE) && node->nip);
387*e7b8153eSMauro Carvalho Chehab
388*e7b8153eSMauro Carvalho Chehab return 0;
389*e7b8153eSMauro Carvalho Chehab }
390*e7b8153eSMauro Carvalho Chehab
last_nodes_raw_show(struct seq_file * s,void * data)391*e7b8153eSMauro Carvalho Chehab static int last_nodes_raw_show(struct seq_file *s, void *data)
392*e7b8153eSMauro Carvalho Chehab {
393*e7b8153eSMauro Carvalho Chehab struct bdisp_dev *bdisp = s->private;
394*e7b8153eSMauro Carvalho Chehab struct bdisp_node *node;
395*e7b8153eSMauro Carvalho Chehab u32 *val;
396*e7b8153eSMauro Carvalho Chehab int j, i = 0;
397*e7b8153eSMauro Carvalho Chehab
398*e7b8153eSMauro Carvalho Chehab if (!bdisp->dbg.copy_node[0]) {
399*e7b8153eSMauro Carvalho Chehab seq_puts(s, "No node built yet\n");
400*e7b8153eSMauro Carvalho Chehab return 0;
401*e7b8153eSMauro Carvalho Chehab }
402*e7b8153eSMauro Carvalho Chehab
403*e7b8153eSMauro Carvalho Chehab do {
404*e7b8153eSMauro Carvalho Chehab node = bdisp->dbg.copy_node[i];
405*e7b8153eSMauro Carvalho Chehab if (!node)
406*e7b8153eSMauro Carvalho Chehab break;
407*e7b8153eSMauro Carvalho Chehab
408*e7b8153eSMauro Carvalho Chehab seq_printf(s, "--------\nNode %d:\n", i);
409*e7b8153eSMauro Carvalho Chehab val = (u32 *)node;
410*e7b8153eSMauro Carvalho Chehab for (j = 0; j < sizeof(struct bdisp_node) / sizeof(u32); j++)
411*e7b8153eSMauro Carvalho Chehab seq_printf(s, "0x%08X\n", *val++);
412*e7b8153eSMauro Carvalho Chehab } while ((++i < MAX_NB_NODE) && node->nip);
413*e7b8153eSMauro Carvalho Chehab
414*e7b8153eSMauro Carvalho Chehab return 0;
415*e7b8153eSMauro Carvalho Chehab }
416*e7b8153eSMauro Carvalho Chehab
bdisp_fmt_to_str(struct bdisp_frame frame)417*e7b8153eSMauro Carvalho Chehab static const char *bdisp_fmt_to_str(struct bdisp_frame frame)
418*e7b8153eSMauro Carvalho Chehab {
419*e7b8153eSMauro Carvalho Chehab switch (frame.fmt->pixelformat) {
420*e7b8153eSMauro Carvalho Chehab case V4L2_PIX_FMT_YUV420:
421*e7b8153eSMauro Carvalho Chehab return "YUV420P";
422*e7b8153eSMauro Carvalho Chehab case V4L2_PIX_FMT_NV12:
423*e7b8153eSMauro Carvalho Chehab if (frame.field == V4L2_FIELD_INTERLACED)
424*e7b8153eSMauro Carvalho Chehab return "NV12 interlaced";
425*e7b8153eSMauro Carvalho Chehab else
426*e7b8153eSMauro Carvalho Chehab return "NV12";
427*e7b8153eSMauro Carvalho Chehab case V4L2_PIX_FMT_RGB565:
428*e7b8153eSMauro Carvalho Chehab return "RGB16";
429*e7b8153eSMauro Carvalho Chehab case V4L2_PIX_FMT_RGB24:
430*e7b8153eSMauro Carvalho Chehab return "RGB24";
431*e7b8153eSMauro Carvalho Chehab case V4L2_PIX_FMT_XBGR32:
432*e7b8153eSMauro Carvalho Chehab return "XRGB";
433*e7b8153eSMauro Carvalho Chehab case V4L2_PIX_FMT_ABGR32:
434*e7b8153eSMauro Carvalho Chehab return "ARGB";
435*e7b8153eSMauro Carvalho Chehab default:
436*e7b8153eSMauro Carvalho Chehab return "????";
437*e7b8153eSMauro Carvalho Chehab }
438*e7b8153eSMauro Carvalho Chehab }
439*e7b8153eSMauro Carvalho Chehab
last_request_show(struct seq_file * s,void * data)440*e7b8153eSMauro Carvalho Chehab static int last_request_show(struct seq_file *s, void *data)
441*e7b8153eSMauro Carvalho Chehab {
442*e7b8153eSMauro Carvalho Chehab struct bdisp_dev *bdisp = s->private;
443*e7b8153eSMauro Carvalho Chehab struct bdisp_request *request = &bdisp->dbg.copy_request;
444*e7b8153eSMauro Carvalho Chehab struct bdisp_frame src, dst;
445*e7b8153eSMauro Carvalho Chehab
446*e7b8153eSMauro Carvalho Chehab if (!request->nb_req) {
447*e7b8153eSMauro Carvalho Chehab seq_puts(s, "No request\n");
448*e7b8153eSMauro Carvalho Chehab return 0;
449*e7b8153eSMauro Carvalho Chehab }
450*e7b8153eSMauro Carvalho Chehab
451*e7b8153eSMauro Carvalho Chehab src = request->src;
452*e7b8153eSMauro Carvalho Chehab dst = request->dst;
453*e7b8153eSMauro Carvalho Chehab
454*e7b8153eSMauro Carvalho Chehab seq_printf(s, "\nRequest #%d\n", request->nb_req);
455*e7b8153eSMauro Carvalho Chehab
456*e7b8153eSMauro Carvalho Chehab seq_printf(s, "Format: %s\t\t\t%s\n",
457*e7b8153eSMauro Carvalho Chehab bdisp_fmt_to_str(src), bdisp_fmt_to_str(dst));
458*e7b8153eSMauro Carvalho Chehab seq_printf(s, "Crop area: %dx%d @ %d,%d ==>\t%dx%d @ %d,%d\n",
459*e7b8153eSMauro Carvalho Chehab src.crop.width, src.crop.height,
460*e7b8153eSMauro Carvalho Chehab src.crop.left, src.crop.top,
461*e7b8153eSMauro Carvalho Chehab dst.crop.width, dst.crop.height,
462*e7b8153eSMauro Carvalho Chehab dst.crop.left, dst.crop.top);
463*e7b8153eSMauro Carvalho Chehab seq_printf(s, "Buff size: %dx%d\t\t%dx%d\n\n",
464*e7b8153eSMauro Carvalho Chehab src.width, src.height, dst.width, dst.height);
465*e7b8153eSMauro Carvalho Chehab
466*e7b8153eSMauro Carvalho Chehab if (request->hflip)
467*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Horizontal flip\n\n");
468*e7b8153eSMauro Carvalho Chehab
469*e7b8153eSMauro Carvalho Chehab if (request->vflip)
470*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Vertical flip\n\n");
471*e7b8153eSMauro Carvalho Chehab
472*e7b8153eSMauro Carvalho Chehab return 0;
473*e7b8153eSMauro Carvalho Chehab }
474*e7b8153eSMauro Carvalho Chehab
475*e7b8153eSMauro Carvalho Chehab #define DUMP(reg) seq_printf(s, #reg " \t0x%08X\n", readl(bdisp->regs + reg))
476*e7b8153eSMauro Carvalho Chehab
regs_show(struct seq_file * s,void * data)477*e7b8153eSMauro Carvalho Chehab static int regs_show(struct seq_file *s, void *data)
478*e7b8153eSMauro Carvalho Chehab {
479*e7b8153eSMauro Carvalho Chehab struct bdisp_dev *bdisp = s->private;
480*e7b8153eSMauro Carvalho Chehab int ret;
481*e7b8153eSMauro Carvalho Chehab unsigned int i;
482*e7b8153eSMauro Carvalho Chehab
483*e7b8153eSMauro Carvalho Chehab ret = pm_runtime_resume_and_get(bdisp->dev);
484*e7b8153eSMauro Carvalho Chehab if (ret < 0) {
485*e7b8153eSMauro Carvalho Chehab seq_puts(s, "Cannot wake up IP\n");
486*e7b8153eSMauro Carvalho Chehab return 0;
487*e7b8153eSMauro Carvalho Chehab }
488*e7b8153eSMauro Carvalho Chehab
489*e7b8153eSMauro Carvalho Chehab seq_printf(s, "Reg @ = 0x%p\n", bdisp->regs);
490*e7b8153eSMauro Carvalho Chehab
491*e7b8153eSMauro Carvalho Chehab seq_puts(s, "\nStatic:\n");
492*e7b8153eSMauro Carvalho Chehab DUMP(BLT_CTL);
493*e7b8153eSMauro Carvalho Chehab DUMP(BLT_ITS);
494*e7b8153eSMauro Carvalho Chehab DUMP(BLT_STA1);
495*e7b8153eSMauro Carvalho Chehab DUMP(BLT_AQ1_CTL);
496*e7b8153eSMauro Carvalho Chehab DUMP(BLT_AQ1_IP);
497*e7b8153eSMauro Carvalho Chehab DUMP(BLT_AQ1_LNA);
498*e7b8153eSMauro Carvalho Chehab DUMP(BLT_AQ1_STA);
499*e7b8153eSMauro Carvalho Chehab DUMP(BLT_ITM0);
500*e7b8153eSMauro Carvalho Chehab
501*e7b8153eSMauro Carvalho Chehab seq_puts(s, "\nPlugs:\n");
502*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS1_OP2);
503*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS1_CHZ);
504*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS1_MSZ);
505*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS1_PGZ);
506*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS2_OP2);
507*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS2_CHZ);
508*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS2_MSZ);
509*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS2_PGZ);
510*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS3_OP2);
511*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS3_CHZ);
512*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS3_MSZ);
513*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGS3_PGZ);
514*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGT_OP2);
515*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGT_CHZ);
516*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGT_MSZ);
517*e7b8153eSMauro Carvalho Chehab DUMP(BLT_PLUGT_PGZ);
518*e7b8153eSMauro Carvalho Chehab
519*e7b8153eSMauro Carvalho Chehab seq_puts(s, "\nNode:\n");
520*e7b8153eSMauro Carvalho Chehab DUMP(BLT_NIP);
521*e7b8153eSMauro Carvalho Chehab DUMP(BLT_CIC);
522*e7b8153eSMauro Carvalho Chehab DUMP(BLT_INS);
523*e7b8153eSMauro Carvalho Chehab DUMP(BLT_ACK);
524*e7b8153eSMauro Carvalho Chehab DUMP(BLT_TBA);
525*e7b8153eSMauro Carvalho Chehab DUMP(BLT_TTY);
526*e7b8153eSMauro Carvalho Chehab DUMP(BLT_TXY);
527*e7b8153eSMauro Carvalho Chehab DUMP(BLT_TSZ);
528*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S1BA);
529*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S1TY);
530*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S1XY);
531*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S2BA);
532*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S2TY);
533*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S2XY);
534*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S2SZ);
535*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S3BA);
536*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S3TY);
537*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S3XY);
538*e7b8153eSMauro Carvalho Chehab DUMP(BLT_S3SZ);
539*e7b8153eSMauro Carvalho Chehab DUMP(BLT_FCTL);
540*e7b8153eSMauro Carvalho Chehab DUMP(BLT_RSF);
541*e7b8153eSMauro Carvalho Chehab DUMP(BLT_RZI);
542*e7b8153eSMauro Carvalho Chehab DUMP(BLT_HFP);
543*e7b8153eSMauro Carvalho Chehab DUMP(BLT_VFP);
544*e7b8153eSMauro Carvalho Chehab DUMP(BLT_Y_RSF);
545*e7b8153eSMauro Carvalho Chehab DUMP(BLT_Y_RZI);
546*e7b8153eSMauro Carvalho Chehab DUMP(BLT_Y_HFP);
547*e7b8153eSMauro Carvalho Chehab DUMP(BLT_Y_VFP);
548*e7b8153eSMauro Carvalho Chehab DUMP(BLT_IVMX0);
549*e7b8153eSMauro Carvalho Chehab DUMP(BLT_IVMX1);
550*e7b8153eSMauro Carvalho Chehab DUMP(BLT_IVMX2);
551*e7b8153eSMauro Carvalho Chehab DUMP(BLT_IVMX3);
552*e7b8153eSMauro Carvalho Chehab DUMP(BLT_OVMX0);
553*e7b8153eSMauro Carvalho Chehab DUMP(BLT_OVMX1);
554*e7b8153eSMauro Carvalho Chehab DUMP(BLT_OVMX2);
555*e7b8153eSMauro Carvalho Chehab DUMP(BLT_OVMX3);
556*e7b8153eSMauro Carvalho Chehab DUMP(BLT_DEI);
557*e7b8153eSMauro Carvalho Chehab
558*e7b8153eSMauro Carvalho Chehab seq_puts(s, "\nFilter:\n");
559*e7b8153eSMauro Carvalho Chehab for (i = 0; i < BLT_NB_H_COEF; i++) {
560*e7b8153eSMauro Carvalho Chehab seq_printf(s, "BLT_HFC%d \t0x%08X\n", i,
561*e7b8153eSMauro Carvalho Chehab readl(bdisp->regs + BLT_HFC_N + i * 4));
562*e7b8153eSMauro Carvalho Chehab }
563*e7b8153eSMauro Carvalho Chehab for (i = 0; i < BLT_NB_V_COEF; i++) {
564*e7b8153eSMauro Carvalho Chehab seq_printf(s, "BLT_VFC%d \t0x%08X\n", i,
565*e7b8153eSMauro Carvalho Chehab readl(bdisp->regs + BLT_VFC_N + i * 4));
566*e7b8153eSMauro Carvalho Chehab }
567*e7b8153eSMauro Carvalho Chehab
568*e7b8153eSMauro Carvalho Chehab seq_puts(s, "\nLuma filter:\n");
569*e7b8153eSMauro Carvalho Chehab for (i = 0; i < BLT_NB_H_COEF; i++) {
570*e7b8153eSMauro Carvalho Chehab seq_printf(s, "BLT_Y_HFC%d \t0x%08X\n", i,
571*e7b8153eSMauro Carvalho Chehab readl(bdisp->regs + BLT_Y_HFC_N + i * 4));
572*e7b8153eSMauro Carvalho Chehab }
573*e7b8153eSMauro Carvalho Chehab for (i = 0; i < BLT_NB_V_COEF; i++) {
574*e7b8153eSMauro Carvalho Chehab seq_printf(s, "BLT_Y_VFC%d \t0x%08X\n", i,
575*e7b8153eSMauro Carvalho Chehab readl(bdisp->regs + BLT_Y_VFC_N + i * 4));
576*e7b8153eSMauro Carvalho Chehab }
577*e7b8153eSMauro Carvalho Chehab
578*e7b8153eSMauro Carvalho Chehab pm_runtime_put(bdisp->dev);
579*e7b8153eSMauro Carvalho Chehab
580*e7b8153eSMauro Carvalho Chehab return 0;
581*e7b8153eSMauro Carvalho Chehab }
582*e7b8153eSMauro Carvalho Chehab
583*e7b8153eSMauro Carvalho Chehab #define SECOND 1000000
584*e7b8153eSMauro Carvalho Chehab
perf_show(struct seq_file * s,void * data)585*e7b8153eSMauro Carvalho Chehab static int perf_show(struct seq_file *s, void *data)
586*e7b8153eSMauro Carvalho Chehab {
587*e7b8153eSMauro Carvalho Chehab struct bdisp_dev *bdisp = s->private;
588*e7b8153eSMauro Carvalho Chehab struct bdisp_request *request = &bdisp->dbg.copy_request;
589*e7b8153eSMauro Carvalho Chehab s64 avg_time_us;
590*e7b8153eSMauro Carvalho Chehab int avg_fps, min_fps, max_fps, last_fps;
591*e7b8153eSMauro Carvalho Chehab
592*e7b8153eSMauro Carvalho Chehab if (!request->nb_req) {
593*e7b8153eSMauro Carvalho Chehab seq_puts(s, "No request\n");
594*e7b8153eSMauro Carvalho Chehab return 0;
595*e7b8153eSMauro Carvalho Chehab }
596*e7b8153eSMauro Carvalho Chehab
597*e7b8153eSMauro Carvalho Chehab avg_time_us = div64_s64(bdisp->dbg.tot_duration, request->nb_req);
598*e7b8153eSMauro Carvalho Chehab if (avg_time_us > SECOND)
599*e7b8153eSMauro Carvalho Chehab avg_fps = 0;
600*e7b8153eSMauro Carvalho Chehab else
601*e7b8153eSMauro Carvalho Chehab avg_fps = SECOND / (s32)avg_time_us;
602*e7b8153eSMauro Carvalho Chehab
603*e7b8153eSMauro Carvalho Chehab if (bdisp->dbg.min_duration > SECOND)
604*e7b8153eSMauro Carvalho Chehab min_fps = 0;
605*e7b8153eSMauro Carvalho Chehab else
606*e7b8153eSMauro Carvalho Chehab min_fps = SECOND / (s32)bdisp->dbg.min_duration;
607*e7b8153eSMauro Carvalho Chehab
608*e7b8153eSMauro Carvalho Chehab if (bdisp->dbg.max_duration > SECOND)
609*e7b8153eSMauro Carvalho Chehab max_fps = 0;
610*e7b8153eSMauro Carvalho Chehab else
611*e7b8153eSMauro Carvalho Chehab max_fps = SECOND / (s32)bdisp->dbg.max_duration;
612*e7b8153eSMauro Carvalho Chehab
613*e7b8153eSMauro Carvalho Chehab if (bdisp->dbg.last_duration > SECOND)
614*e7b8153eSMauro Carvalho Chehab last_fps = 0;
615*e7b8153eSMauro Carvalho Chehab else
616*e7b8153eSMauro Carvalho Chehab last_fps = SECOND / (s32)bdisp->dbg.last_duration;
617*e7b8153eSMauro Carvalho Chehab
618*e7b8153eSMauro Carvalho Chehab seq_printf(s, "HW processing (%d requests):\n", request->nb_req);
619*e7b8153eSMauro Carvalho Chehab seq_printf(s, " Average: %5lld us (%3d fps)\n",
620*e7b8153eSMauro Carvalho Chehab avg_time_us, avg_fps);
621*e7b8153eSMauro Carvalho Chehab seq_printf(s, " Min-Max: %5lld us (%3d fps) - %5lld us (%3d fps)\n",
622*e7b8153eSMauro Carvalho Chehab bdisp->dbg.min_duration, min_fps,
623*e7b8153eSMauro Carvalho Chehab bdisp->dbg.max_duration, max_fps);
624*e7b8153eSMauro Carvalho Chehab seq_printf(s, " Last: %5lld us (%3d fps)\n",
625*e7b8153eSMauro Carvalho Chehab bdisp->dbg.last_duration, last_fps);
626*e7b8153eSMauro Carvalho Chehab
627*e7b8153eSMauro Carvalho Chehab return 0;
628*e7b8153eSMauro Carvalho Chehab }
629*e7b8153eSMauro Carvalho Chehab
630*e7b8153eSMauro Carvalho Chehab #define bdisp_dbg_create_entry(name) \
631*e7b8153eSMauro Carvalho Chehab debugfs_create_file(#name, S_IRUGO, bdisp->dbg.debugfs_entry, bdisp, \
632*e7b8153eSMauro Carvalho Chehab &name##_fops)
633*e7b8153eSMauro Carvalho Chehab
634*e7b8153eSMauro Carvalho Chehab DEFINE_SHOW_ATTRIBUTE(regs);
635*e7b8153eSMauro Carvalho Chehab DEFINE_SHOW_ATTRIBUTE(last_nodes);
636*e7b8153eSMauro Carvalho Chehab DEFINE_SHOW_ATTRIBUTE(last_nodes_raw);
637*e7b8153eSMauro Carvalho Chehab DEFINE_SHOW_ATTRIBUTE(last_request);
638*e7b8153eSMauro Carvalho Chehab DEFINE_SHOW_ATTRIBUTE(perf);
639*e7b8153eSMauro Carvalho Chehab
bdisp_debugfs_create(struct bdisp_dev * bdisp)640*e7b8153eSMauro Carvalho Chehab void bdisp_debugfs_create(struct bdisp_dev *bdisp)
641*e7b8153eSMauro Carvalho Chehab {
642*e7b8153eSMauro Carvalho Chehab char dirname[16];
643*e7b8153eSMauro Carvalho Chehab
644*e7b8153eSMauro Carvalho Chehab snprintf(dirname, sizeof(dirname), "%s%d", BDISP_NAME, bdisp->id);
645*e7b8153eSMauro Carvalho Chehab bdisp->dbg.debugfs_entry = debugfs_create_dir(dirname, NULL);
646*e7b8153eSMauro Carvalho Chehab
647*e7b8153eSMauro Carvalho Chehab bdisp_dbg_create_entry(regs);
648*e7b8153eSMauro Carvalho Chehab bdisp_dbg_create_entry(last_nodes);
649*e7b8153eSMauro Carvalho Chehab bdisp_dbg_create_entry(last_nodes_raw);
650*e7b8153eSMauro Carvalho Chehab bdisp_dbg_create_entry(last_request);
651*e7b8153eSMauro Carvalho Chehab bdisp_dbg_create_entry(perf);
652*e7b8153eSMauro Carvalho Chehab }
653*e7b8153eSMauro Carvalho Chehab
bdisp_debugfs_remove(struct bdisp_dev * bdisp)654*e7b8153eSMauro Carvalho Chehab void bdisp_debugfs_remove(struct bdisp_dev *bdisp)
655*e7b8153eSMauro Carvalho Chehab {
656*e7b8153eSMauro Carvalho Chehab debugfs_remove_recursive(bdisp->dbg.debugfs_entry);
657*e7b8153eSMauro Carvalho Chehab bdisp->dbg.debugfs_entry = NULL;
658*e7b8153eSMauro Carvalho Chehab }
659