Skip to content

Commit a5f8107

Browse files
committed
drm/sti: add debugfs entries for MIXER crtc
Signed-off-by: Vincent Abriou <vincent.abriou@st.com> Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
1 parent 90dffef commit a5f8107

File tree

3 files changed

+149
-3
lines changed

3 files changed

+149
-3
lines changed

drivers/gpu/drm/sti/sti_compositor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static int sti_compositor_bind(struct device *dev,
8181
case STI_MIXER_MAIN_SUBDEV:
8282
case STI_MIXER_AUX_SUBDEV:
8383
compo->mixer[mixer_id++] =
84-
sti_mixer_create(compo->dev, desc[i].id,
84+
sti_mixer_create(compo->dev, drm_dev, desc[i].id,
8585
compo->regs + desc[i].offset);
8686
break;
8787
case STI_GPD_SUBDEV:

drivers/gpu/drm/sti/sti_mixer.c

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,145 @@ static inline void sti_mixer_reg_write(struct sti_mixer *mixer,
7575
writel(val, mixer->regs + reg_id);
7676
}
7777

78+
#define DBGFS_DUMP(reg) seq_printf(s, "\n %-25s 0x%08X", #reg, \
79+
sti_mixer_reg_read(mixer, reg))
80+
81+
static void mixer_dbg_ctl(struct seq_file *s, int val)
82+
{
83+
unsigned int i;
84+
int count = 0;
85+
char *const disp_layer[] = {"BKG", "VID0", "VID1", "GDP0",
86+
"GDP1", "GDP2", "GDP3"};
87+
88+
seq_puts(s, "\tEnabled: ");
89+
for (i = 0; i < 7; i++) {
90+
if (val & 1) {
91+
seq_printf(s, "%s ", disp_layer[i]);
92+
count++;
93+
}
94+
val = val >> 1;
95+
}
96+
97+
val = val >> 2;
98+
if (val & 1) {
99+
seq_puts(s, "CURS ");
100+
count++;
101+
}
102+
if (!count)
103+
seq_puts(s, "Nothing");
104+
}
105+
106+
static void mixer_dbg_crb(struct seq_file *s, int val)
107+
{
108+
int i;
109+
110+
seq_puts(s, "\tDepth: ");
111+
for (i = 0; i < GAM_MIXER_NB_DEPTH_LEVEL; i++) {
112+
switch (val & GAM_DEPTH_MASK_ID) {
113+
case GAM_DEPTH_VID0_ID:
114+
seq_puts(s, "VID0");
115+
break;
116+
case GAM_DEPTH_VID1_ID:
117+
seq_puts(s, "VID1");
118+
break;
119+
case GAM_DEPTH_GDP0_ID:
120+
seq_puts(s, "GDP0");
121+
break;
122+
case GAM_DEPTH_GDP1_ID:
123+
seq_puts(s, "GDP1");
124+
break;
125+
case GAM_DEPTH_GDP2_ID:
126+
seq_puts(s, "GDP2");
127+
break;
128+
case GAM_DEPTH_GDP3_ID:
129+
seq_puts(s, "GDP3");
130+
break;
131+
default:
132+
seq_puts(s, "---");
133+
}
134+
135+
if (i < GAM_MIXER_NB_DEPTH_LEVEL - 1)
136+
seq_puts(s, " < ");
137+
val = val >> 3;
138+
}
139+
}
140+
141+
static void mixer_dbg_mxn(struct seq_file *s, void *addr)
142+
{
143+
int i;
144+
145+
for (i = 1; i < 8; i++)
146+
seq_printf(s, "-0x%08X", (int)readl(addr + i * 4));
147+
}
148+
149+
static int mixer_dbg_show(struct seq_file *s, void *arg)
150+
{
151+
struct drm_info_node *node = s->private;
152+
struct sti_mixer *mixer = (struct sti_mixer *)node->info_ent->data;
153+
struct drm_device *dev = node->minor->dev;
154+
int ret;
155+
156+
ret = mutex_lock_interruptible(&dev->struct_mutex);
157+
if (ret)
158+
return ret;
159+
160+
seq_printf(s, "%s: (vaddr = 0x%p)",
161+
sti_mixer_to_str(mixer), mixer->regs);
162+
163+
DBGFS_DUMP(GAM_MIXER_CTL);
164+
mixer_dbg_ctl(s, sti_mixer_reg_read(mixer, GAM_MIXER_CTL));
165+
DBGFS_DUMP(GAM_MIXER_BKC);
166+
DBGFS_DUMP(GAM_MIXER_BCO);
167+
DBGFS_DUMP(GAM_MIXER_BCS);
168+
DBGFS_DUMP(GAM_MIXER_AVO);
169+
DBGFS_DUMP(GAM_MIXER_AVS);
170+
DBGFS_DUMP(GAM_MIXER_CRB);
171+
mixer_dbg_crb(s, sti_mixer_reg_read(mixer, GAM_MIXER_CRB));
172+
DBGFS_DUMP(GAM_MIXER_ACT);
173+
DBGFS_DUMP(GAM_MIXER_MBP);
174+
DBGFS_DUMP(GAM_MIXER_MX0);
175+
mixer_dbg_mxn(s, mixer->regs + GAM_MIXER_MX0);
176+
seq_puts(s, "\n");
177+
178+
mutex_unlock(&dev->struct_mutex);
179+
return 0;
180+
}
181+
182+
static struct drm_info_list mixer0_debugfs_files[] = {
183+
{ "mixer_main", mixer_dbg_show, 0, NULL },
184+
};
185+
186+
static struct drm_info_list mixer1_debugfs_files[] = {
187+
{ "mixer_aux", mixer_dbg_show, 0, NULL },
188+
};
189+
190+
static int mixer_debugfs_init(struct sti_mixer *mixer, struct drm_minor *minor)
191+
{
192+
unsigned int i;
193+
struct drm_info_list *mixer_debugfs_files;
194+
int nb_files;
195+
196+
switch (mixer->id) {
197+
case STI_MIXER_MAIN:
198+
mixer_debugfs_files = mixer0_debugfs_files;
199+
nb_files = ARRAY_SIZE(mixer0_debugfs_files);
200+
break;
201+
case STI_MIXER_AUX:
202+
mixer_debugfs_files = mixer1_debugfs_files;
203+
nb_files = ARRAY_SIZE(mixer1_debugfs_files);
204+
break;
205+
default:
206+
return -EINVAL;
207+
}
208+
209+
for (i = 0; i < nb_files; i++)
210+
mixer_debugfs_files[i].data = mixer;
211+
212+
return drm_debugfs_create_files(mixer_debugfs_files,
213+
nb_files,
214+
minor->debugfs_root, minor);
215+
}
216+
78217
void sti_mixer_set_background_status(struct sti_mixer *mixer, bool enable)
79218
{
80219
u32 val = sti_mixer_reg_read(mixer, GAM_MIXER_CTL);
@@ -237,7 +376,9 @@ void sti_mixer_set_matrix(struct sti_mixer *mixer)
237376
mixerColorSpaceMatIdentity[i]);
238377
}
239378

240-
struct sti_mixer *sti_mixer_create(struct device *dev, int id,
379+
struct sti_mixer *sti_mixer_create(struct device *dev,
380+
struct drm_device *drm_dev,
381+
int id,
241382
void __iomem *baseaddr)
242383
{
243384
struct sti_mixer *mixer = devm_kzalloc(dev, sizeof(*mixer), GFP_KERNEL);
@@ -258,5 +399,8 @@ struct sti_mixer *sti_mixer_create(struct device *dev, int id,
258399
DRM_DEBUG_DRIVER("%s created. Regs=%p\n",
259400
sti_mixer_to_str(mixer), mixer->regs);
260401

402+
if (mixer_debugfs_init(mixer, drm_dev->primary))
403+
DRM_ERROR("MIXER debugfs setup failed\n");
404+
261405
return mixer;
262406
}

drivers/gpu/drm/sti/sti_mixer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ struct sti_mixer {
4242

4343
const char *sti_mixer_to_str(struct sti_mixer *mixer);
4444

45-
struct sti_mixer *sti_mixer_create(struct device *dev, int id,
45+
struct sti_mixer *sti_mixer_create(struct device *dev,
46+
struct drm_device *drm_dev,
47+
int id,
4648
void __iomem *baseaddr);
4749

4850
int sti_mixer_set_plane_status(struct sti_mixer *mixer,

0 commit comments

Comments
 (0)