drm/sti: add debugfs entries for MIXER crtc
authorVincent Abriou <vincent.abriou@st.com>
Thu, 4 Feb 2016 16:44:50 +0000 (17:44 +0100)
committerVincent Abriou <vincent.abriou@st.com>
Fri, 26 Feb 2016 09:06:23 +0000 (10:06 +0100)
Signed-off-by: Vincent Abriou <vincent.abriou@st.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
drivers/gpu/drm/sti/sti_compositor.c
drivers/gpu/drm/sti/sti_mixer.c
drivers/gpu/drm/sti/sti_mixer.h

index 5b827a9..3d2fa3a 100644 (file)
@@ -81,7 +81,7 @@ static int sti_compositor_bind(struct device *dev,
                case STI_MIXER_MAIN_SUBDEV:
                case STI_MIXER_AUX_SUBDEV:
                        compo->mixer[mixer_id++] =
-                           sti_mixer_create(compo->dev, desc[i].id,
+                           sti_mixer_create(compo->dev, drm_dev, desc[i].id,
                                             compo->regs + desc[i].offset);
                        break;
                case STI_GPD_SUBDEV:
index 49db835..e7425c3 100644 (file)
@@ -75,6 +75,145 @@ static inline void sti_mixer_reg_write(struct sti_mixer *mixer,
        writel(val, mixer->regs + reg_id);
 }
 
+#define DBGFS_DUMP(reg) seq_printf(s, "\n  %-25s 0x%08X", #reg, \
+                                  sti_mixer_reg_read(mixer, reg))
+
+static void mixer_dbg_ctl(struct seq_file *s, int val)
+{
+       unsigned int i;
+       int count = 0;
+       char *const disp_layer[] = {"BKG", "VID0", "VID1", "GDP0",
+                                   "GDP1", "GDP2", "GDP3"};
+
+       seq_puts(s, "\tEnabled: ");
+       for (i = 0; i < 7; i++) {
+               if (val & 1) {
+                       seq_printf(s, "%s ", disp_layer[i]);
+                       count++;
+               }
+               val = val >> 1;
+       }
+
+       val = val >> 2;
+       if (val & 1) {
+               seq_puts(s, "CURS ");
+               count++;
+       }
+       if (!count)
+               seq_puts(s, "Nothing");
+}
+
+static void mixer_dbg_crb(struct seq_file *s, int val)
+{
+       int i;
+
+       seq_puts(s, "\tDepth: ");
+       for (i = 0; i < GAM_MIXER_NB_DEPTH_LEVEL; i++) {
+               switch (val & GAM_DEPTH_MASK_ID) {
+               case GAM_DEPTH_VID0_ID:
+                       seq_puts(s, "VID0");
+                       break;
+               case GAM_DEPTH_VID1_ID:
+                       seq_puts(s, "VID1");
+                       break;
+               case GAM_DEPTH_GDP0_ID:
+                       seq_puts(s, "GDP0");
+                       break;
+               case GAM_DEPTH_GDP1_ID:
+                       seq_puts(s, "GDP1");
+                       break;
+               case GAM_DEPTH_GDP2_ID:
+                       seq_puts(s, "GDP2");
+                       break;
+               case GAM_DEPTH_GDP3_ID:
+                       seq_puts(s, "GDP3");
+                       break;
+               default:
+                       seq_puts(s, "---");
+               }
+
+               if (i < GAM_MIXER_NB_DEPTH_LEVEL - 1)
+                       seq_puts(s, " < ");
+               val = val >> 3;
+       }
+}
+
+static void mixer_dbg_mxn(struct seq_file *s, void *addr)
+{
+       int i;
+
+       for (i = 1; i < 8; i++)
+               seq_printf(s, "-0x%08X", (int)readl(addr + i * 4));
+}
+
+static int mixer_dbg_show(struct seq_file *s, void *arg)
+{
+       struct drm_info_node *node = s->private;
+       struct sti_mixer *mixer = (struct sti_mixer *)node->info_ent->data;
+       struct drm_device *dev = node->minor->dev;
+       int ret;
+
+       ret = mutex_lock_interruptible(&dev->struct_mutex);
+       if (ret)
+               return ret;
+
+       seq_printf(s, "%s: (vaddr = 0x%p)",
+                  sti_mixer_to_str(mixer), mixer->regs);
+
+       DBGFS_DUMP(GAM_MIXER_CTL);
+       mixer_dbg_ctl(s, sti_mixer_reg_read(mixer, GAM_MIXER_CTL));
+       DBGFS_DUMP(GAM_MIXER_BKC);
+       DBGFS_DUMP(GAM_MIXER_BCO);
+       DBGFS_DUMP(GAM_MIXER_BCS);
+       DBGFS_DUMP(GAM_MIXER_AVO);
+       DBGFS_DUMP(GAM_MIXER_AVS);
+       DBGFS_DUMP(GAM_MIXER_CRB);
+       mixer_dbg_crb(s, sti_mixer_reg_read(mixer, GAM_MIXER_CRB));
+       DBGFS_DUMP(GAM_MIXER_ACT);
+       DBGFS_DUMP(GAM_MIXER_MBP);
+       DBGFS_DUMP(GAM_MIXER_MX0);
+       mixer_dbg_mxn(s, mixer->regs + GAM_MIXER_MX0);
+       seq_puts(s, "\n");
+
+       mutex_unlock(&dev->struct_mutex);
+       return 0;
+}
+
+static struct drm_info_list mixer0_debugfs_files[] = {
+       { "mixer_main", mixer_dbg_show, 0, NULL },
+};
+
+static struct drm_info_list mixer1_debugfs_files[] = {
+       { "mixer_aux", mixer_dbg_show, 0, NULL },
+};
+
+static int mixer_debugfs_init(struct sti_mixer *mixer, struct drm_minor *minor)
+{
+       unsigned int i;
+       struct drm_info_list *mixer_debugfs_files;
+       int nb_files;
+
+       switch (mixer->id) {
+       case STI_MIXER_MAIN:
+               mixer_debugfs_files = mixer0_debugfs_files;
+               nb_files = ARRAY_SIZE(mixer0_debugfs_files);
+               break;
+       case STI_MIXER_AUX:
+               mixer_debugfs_files = mixer1_debugfs_files;
+               nb_files = ARRAY_SIZE(mixer1_debugfs_files);
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       for (i = 0; i < nb_files; i++)
+               mixer_debugfs_files[i].data = mixer;
+
+       return drm_debugfs_create_files(mixer_debugfs_files,
+                                       nb_files,
+                                       minor->debugfs_root, minor);
+}
+
 void sti_mixer_set_background_status(struct sti_mixer *mixer, bool enable)
 {
        u32 val = sti_mixer_reg_read(mixer, GAM_MIXER_CTL);
@@ -237,7 +376,9 @@ void sti_mixer_set_matrix(struct sti_mixer *mixer)
                                    mixerColorSpaceMatIdentity[i]);
 }
 
-struct sti_mixer *sti_mixer_create(struct device *dev, int id,
+struct sti_mixer *sti_mixer_create(struct device *dev,
+                                  struct drm_device *drm_dev,
+                                  int id,
                                   void __iomem *baseaddr)
 {
        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,
        DRM_DEBUG_DRIVER("%s created. Regs=%p\n",
                         sti_mixer_to_str(mixer), mixer->regs);
 
+       if (mixer_debugfs_init(mixer, drm_dev->primary))
+               DRM_ERROR("MIXER debugfs setup failed\n");
+
        return mixer;
 }
index efb1a9a..6f35fc0 100644 (file)
@@ -42,7 +42,9 @@ struct sti_mixer {
 
 const char *sti_mixer_to_str(struct sti_mixer *mixer);
 
-struct sti_mixer *sti_mixer_create(struct device *dev, int id,
+struct sti_mixer *sti_mixer_create(struct device *dev,
+                                  struct drm_device *drm_dev,
+                                  int id,
                                   void __iomem *baseaddr);
 
 int sti_mixer_set_plane_status(struct sti_mixer *mixer,