Re: [PATCH v1 4/7] drm: sti: make connectors use atomic_print_state instead of debugfs

2018-06-18 Thread Philippe CORNU
Hi Benjamin,

Reviewed-by: Philippe Cornu 
Many thanks
Philippe

On 06/05/2018 03:54 PM, Benjamin Gaignard wrote:
> Convert all sti connectors to atomic_print_state usage rather than
> use a debugfs entry.
> 
> Signed-off-by: Benjamin Gaignard 
> ---
>   drivers/gpu/drm/sti/sti_dvo.c  |  60 +--
>   drivers/gpu/drm/sti/sti_hda.c  |  75 +++
>   drivers/gpu/drm/sti/sti_hdmi.c | 132 
> -
>   3 files changed, 90 insertions(+), 177 deletions(-)
> 
> diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
> index a5979cd25cc7..5662613ae6e0 100644
> --- a/drivers/gpu/drm/sti/sti_dvo.c
> +++ b/drivers/gpu/drm/sti/sti_dvo.c
> @@ -6,7 +6,6 @@
>   
>   #include 
>   #include 
> -#include 
>   #include 
>   #include 
>   #include 
> @@ -158,52 +157,37 @@ static void dvo_awg_configure(struct sti_dvo *dvo, u32 
> *awg_ram_code, int nb)
>   writel(DVO_AWG_CTRL_EN, dvo->regs + DVO_AWG_DIGSYNC_CTRL);
>   }
>   
> -#define DBGFS_DUMP(reg) seq_printf(s, "\n  %-25s 0x%08X", #reg, \
> +#define DBGFS_DUMP(reg) drm_printf(p, "\n\t\t%-25s 0x%08X", #reg, \
>  readl(dvo->regs + reg))
>   
> -static void dvo_dbg_awg_microcode(struct seq_file *s, void __iomem *reg)
> +static void dvo_dbg_awg_microcode(struct drm_printer *p, void __iomem *reg)
>   {
>   unsigned int i;
>   
> - seq_puts(s, "\n\n");
> - seq_puts(s, "  DVO AWG microcode:");
> + drm_printf(p, "\n\n");
> + drm_printf(p, "  DVO AWG microcode:");
>   for (i = 0; i < AWG_MAX_INST; i++) {
>   if (i % 8 == 0)
> - seq_printf(s, "\n  %04X:", i);
> - seq_printf(s, " %04X", readl(reg + i * 4));
> + drm_printf(p, "\n  %04X:", i);
> + drm_printf(p, " %04X", readl(reg + i * 4));
>   }
>   }
>   
> -static int dvo_dbg_show(struct seq_file *s, void *data)
> +static void sti_dvo_print_state(struct drm_printer *p,
> + const struct drm_connector_state *state)
>   {
> - struct drm_info_node *node = s->private;
> - struct sti_dvo *dvo = (struct sti_dvo *)node->info_ent->data;
> + struct sti_dvo_connector *dvo_connector
> + = to_sti_dvo_connector(state->connector);
> + struct sti_dvo *dvo = dvo_connector->dvo;
>   
> - seq_printf(s, "DVO: (vaddr = 0x%p)", dvo->regs);
> + drm_printf(p, "DVO: (vaddr = 0x%p)", dvo->regs);
>   DBGFS_DUMP(DVO_AWG_DIGSYNC_CTRL);
>   DBGFS_DUMP(DVO_DOF_CFG);
>   DBGFS_DUMP(DVO_LUT_PROG_LOW);
>   DBGFS_DUMP(DVO_LUT_PROG_MID);
>   DBGFS_DUMP(DVO_LUT_PROG_HIGH);
> - dvo_dbg_awg_microcode(s, dvo->regs + DVO_DIGSYNC_INSTR_I);
> - seq_putc(s, '\n');
> - return 0;
> -}
> -
> -static struct drm_info_list dvo_debugfs_files[] = {
> - { "dvo", dvo_dbg_show, 0, NULL },
> -};
> -
> -static int dvo_debugfs_init(struct sti_dvo *dvo, struct drm_minor *minor)
> -{
> - unsigned int i;
> -
> - for (i = 0; i < ARRAY_SIZE(dvo_debugfs_files); i++)
> - dvo_debugfs_files[i].data = dvo;
> -
> - return drm_debugfs_create_files(dvo_debugfs_files,
> - ARRAY_SIZE(dvo_debugfs_files),
> - minor->debugfs_root, minor);
> + dvo_dbg_awg_microcode(p, dvo->regs + DVO_DIGSYNC_INSTR_I);
> + drm_printf(p, "\n");
>   }
>   
>   static void sti_dvo_disable(struct drm_bridge *bridge)
> @@ -397,20 +381,6 @@ sti_dvo_connector_detect(struct drm_connector 
> *connector, bool force)
>   return connector_status_disconnected;
>   }
>   
> -static int sti_dvo_late_register(struct drm_connector *connector)
> -{
> - struct sti_dvo_connector *dvo_connector
> - = to_sti_dvo_connector(connector);
> - struct sti_dvo *dvo = dvo_connector->dvo;
> -
> - if (dvo_debugfs_init(dvo, dvo->drm_dev->primary)) {
> - DRM_ERROR("DVO debugfs setup failed\n");
> - return -EINVAL;
> - }
> -
> - return 0;
> -}
> -
>   static const struct drm_connector_funcs sti_dvo_connector_funcs = {
>   .fill_modes = drm_helper_probe_single_connector_modes,
>   .detect = sti_dvo_connector_detect,
> @@ -418,7 +388,7 @@ static const struct drm_connector_funcs 
> sti_dvo_connector_funcs = {
>   .reset = drm_atomic_helper_connector_reset,
>   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
>   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> - .late_register = sti_dvo_late_register,
> + .atomic_print_state = sti_dvo_print_state,
>   };
>   
>   static struct drm_encoder *sti_dvo_find_encoder(struct drm_device *dev)
> diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
> index 67bbdb49fffc..0734f2751505 100644
> --- a/drivers/gpu/drm/sti/sti_hda.c
> +++ b/drivers/gpu/drm/sti/sti_hda.c
> @@ -307,71 +307,56 @@ static void hda_enable_hd_dacs(struct sti_hda *hda, 
> bool enable)

[PATCH v1 4/7] drm: sti: make connectors use atomic_print_state instead of debugfs

2018-06-05 Thread Benjamin Gaignard
Convert all sti connectors to atomic_print_state usage rather than
use a debugfs entry.

Signed-off-by: Benjamin Gaignard 
---
 drivers/gpu/drm/sti/sti_dvo.c  |  60 +--
 drivers/gpu/drm/sti/sti_hda.c  |  75 +++
 drivers/gpu/drm/sti/sti_hdmi.c | 132 -
 3 files changed, 90 insertions(+), 177 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_dvo.c b/drivers/gpu/drm/sti/sti_dvo.c
index a5979cd25cc7..5662613ae6e0 100644
--- a/drivers/gpu/drm/sti/sti_dvo.c
+++ b/drivers/gpu/drm/sti/sti_dvo.c
@@ -6,7 +6,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -158,52 +157,37 @@ static void dvo_awg_configure(struct sti_dvo *dvo, u32 
*awg_ram_code, int nb)
writel(DVO_AWG_CTRL_EN, dvo->regs + DVO_AWG_DIGSYNC_CTRL);
 }
 
-#define DBGFS_DUMP(reg) seq_printf(s, "\n  %-25s 0x%08X", #reg, \
+#define DBGFS_DUMP(reg) drm_printf(p, "\n\t\t%-25s 0x%08X", #reg, \
   readl(dvo->regs + reg))
 
-static void dvo_dbg_awg_microcode(struct seq_file *s, void __iomem *reg)
+static void dvo_dbg_awg_microcode(struct drm_printer *p, void __iomem *reg)
 {
unsigned int i;
 
-   seq_puts(s, "\n\n");
-   seq_puts(s, "  DVO AWG microcode:");
+   drm_printf(p, "\n\n");
+   drm_printf(p, "  DVO AWG microcode:");
for (i = 0; i < AWG_MAX_INST; i++) {
if (i % 8 == 0)
-   seq_printf(s, "\n  %04X:", i);
-   seq_printf(s, " %04X", readl(reg + i * 4));
+   drm_printf(p, "\n  %04X:", i);
+   drm_printf(p, " %04X", readl(reg + i * 4));
}
 }
 
-static int dvo_dbg_show(struct seq_file *s, void *data)
+static void sti_dvo_print_state(struct drm_printer *p,
+   const struct drm_connector_state *state)
 {
-   struct drm_info_node *node = s->private;
-   struct sti_dvo *dvo = (struct sti_dvo *)node->info_ent->data;
+   struct sti_dvo_connector *dvo_connector
+   = to_sti_dvo_connector(state->connector);
+   struct sti_dvo *dvo = dvo_connector->dvo;
 
-   seq_printf(s, "DVO: (vaddr = 0x%p)", dvo->regs);
+   drm_printf(p, "DVO: (vaddr = 0x%p)", dvo->regs);
DBGFS_DUMP(DVO_AWG_DIGSYNC_CTRL);
DBGFS_DUMP(DVO_DOF_CFG);
DBGFS_DUMP(DVO_LUT_PROG_LOW);
DBGFS_DUMP(DVO_LUT_PROG_MID);
DBGFS_DUMP(DVO_LUT_PROG_HIGH);
-   dvo_dbg_awg_microcode(s, dvo->regs + DVO_DIGSYNC_INSTR_I);
-   seq_putc(s, '\n');
-   return 0;
-}
-
-static struct drm_info_list dvo_debugfs_files[] = {
-   { "dvo", dvo_dbg_show, 0, NULL },
-};
-
-static int dvo_debugfs_init(struct sti_dvo *dvo, struct drm_minor *minor)
-{
-   unsigned int i;
-
-   for (i = 0; i < ARRAY_SIZE(dvo_debugfs_files); i++)
-   dvo_debugfs_files[i].data = dvo;
-
-   return drm_debugfs_create_files(dvo_debugfs_files,
-   ARRAY_SIZE(dvo_debugfs_files),
-   minor->debugfs_root, minor);
+   dvo_dbg_awg_microcode(p, dvo->regs + DVO_DIGSYNC_INSTR_I);
+   drm_printf(p, "\n");
 }
 
 static void sti_dvo_disable(struct drm_bridge *bridge)
@@ -397,20 +381,6 @@ sti_dvo_connector_detect(struct drm_connector *connector, 
bool force)
return connector_status_disconnected;
 }
 
-static int sti_dvo_late_register(struct drm_connector *connector)
-{
-   struct sti_dvo_connector *dvo_connector
-   = to_sti_dvo_connector(connector);
-   struct sti_dvo *dvo = dvo_connector->dvo;
-
-   if (dvo_debugfs_init(dvo, dvo->drm_dev->primary)) {
-   DRM_ERROR("DVO debugfs setup failed\n");
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
 static const struct drm_connector_funcs sti_dvo_connector_funcs = {
.fill_modes = drm_helper_probe_single_connector_modes,
.detect = sti_dvo_connector_detect,
@@ -418,7 +388,7 @@ static const struct drm_connector_funcs 
sti_dvo_connector_funcs = {
.reset = drm_atomic_helper_connector_reset,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
-   .late_register = sti_dvo_late_register,
+   .atomic_print_state = sti_dvo_print_state,
 };
 
 static struct drm_encoder *sti_dvo_find_encoder(struct drm_device *dev)
diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c
index 67bbdb49fffc..0734f2751505 100644
--- a/drivers/gpu/drm/sti/sti_hda.c
+++ b/drivers/gpu/drm/sti/sti_hda.c
@@ -307,71 +307,56 @@ static void hda_enable_hd_dacs(struct sti_hda *hda, bool 
enable)
}
 }
 
-#define DBGFS_DUMP(reg) seq_printf(s, "\n  %-25s 0x%08X", #reg, \
+#define DBGFS_DUMP(reg) drm_printf(p, "\n\t\t%-25s 0x%08X", #reg, \
   readl(hda->regs + reg))
 
-static void hda_dbg_cfg(struct seq_file *s, int val)
+static void