All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-04-06 13:49 ` Angelo Ribeiro
  0 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-04-06 13:49 UTC (permalink / raw)
  To: yannick.fertre, philippe.cornu, benjamin.gaignard, airlied,
	daniel, mcoquelin.stm32, alexandre.torgue, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Angelo Ribeiro, Gustavo Pimentel, Joao Pinto, Jose Abreu

Add support for the video pattern generator (VPG) BER pattern mode and
configuration in runtime.

This enables using the debugfs interface to manipulate the VPG after
the pipeline is set.
Also, enables the usage of the VPG BER pattern.

Changes in v2:
  - Added VID_MODE_VPG_MODE
  - Solved incompatible return type on __get and __set

Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Adrian Pop <pop.adrian61@gmail.com>
Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jose Abreu <jose.abreu@synopsys.com>
Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
 1 file changed, 90 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
index b18351b..9de3645 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
@@ -91,6 +91,7 @@
 #define VID_MODE_TYPE_BURST			0x2
 #define VID_MODE_TYPE_MASK			0x3
 #define VID_MODE_VPG_ENABLE		BIT(16)
+#define VID_MODE_VPG_MODE		BIT(20)
 #define VID_MODE_VPG_HORIZONTAL		BIT(24)
 
 #define DSI_VID_PKT_SIZE		0x3c
@@ -221,6 +222,21 @@
 #define PHY_STATUS_TIMEOUT_US		10000
 #define CMD_PKT_STATUS_TIMEOUT_US	20000
 
+#ifdef CONFIG_DEBUG_FS
+#define VPG_DEFS(name, dsi) \
+	((void __force *)&((*dsi).vpg_defs.name))
+
+#define REGISTER(name, mask, dsi) \
+	{ #name, VPG_DEFS(name, dsi), mask, dsi }
+
+struct debugfs_entries {
+	const char				*name;
+	bool					*reg;
+	u32					mask;
+	struct dw_mipi_dsi			*dsi;
+};
+#endif /* CONFIG_DEBUG_FS */
+
 struct dw_mipi_dsi {
 	struct drm_bridge bridge;
 	struct mipi_dsi_host dsi_host;
@@ -238,9 +254,12 @@ struct dw_mipi_dsi {
 
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *debugfs;
-
-	bool vpg;
-	bool vpg_horizontal;
+	struct debugfs_entries *debugfs_vpg;
+	struct {
+		bool vpg;
+		bool vpg_horizontal;
+		bool vpg_ber_pattern;
+	} vpg_defs;
 #endif /* CONFIG_DEBUG_FS */
 
 	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
@@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
 		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
 
 #ifdef CONFIG_DEBUG_FS
-	if (dsi->vpg) {
+	if (dsi->vpg_defs.vpg) {
 		val |= VID_MODE_VPG_ENABLE;
-		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
+		val |= dsi->vpg_defs.vpg_horizontal ?
+		       VID_MODE_VPG_HORIZONTAL : 0;
+		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
 	}
 #endif /* CONFIG_DEBUG_FS */
 
@@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
 
 #ifdef CONFIG_DEBUG_FS
 
+int dw_mipi_dsi_debugfs_write(void *data, u64 val)
+{
+	struct debugfs_entries *vpg = data;
+	struct dw_mipi_dsi *dsi;
+	u32 mode_cfg;
+
+	if (!vpg)
+		return -ENODEV;
+
+	dsi = vpg->dsi;
+
+	*vpg->reg = (bool)val;
+
+	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
+
+	if (*vpg->reg)
+		mode_cfg |= vpg->mask;
+	else
+		mode_cfg &= ~vpg->mask;
+
+	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
+
+	return 0;
+}
+
+int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
+{
+	struct debugfs_entries *vpg = data;
+
+	if (!vpg)
+		return -ENODEV;
+
+	*val = *vpg->reg;
+
+	return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
+			 dw_mipi_dsi_debugfs_write, "%llu\n");
+
+static void debugfs_create_files(void *data)
+{
+	struct dw_mipi_dsi *dsi = data;
+	struct debugfs_entries debugfs[] = {
+		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
+		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
+		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
+	};
+	int i;
+
+	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
+	if (!dsi->debugfs_vpg)
+		return;
+
+	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
+
+	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
+		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
+				    dsi->debugfs, &dsi->debugfs_vpg[i],
+				    &fops_x32);
+}
+
 static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
 {
 	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
@@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
 		return;
 	}
 
-	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
-	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
-			    &dsi->vpg_horizontal);
+	debugfs_create_files(dsi);
 }
 
 static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
 {
 	debugfs_remove_recursive(dsi->debugfs);
+	kfree(dsi->debugfs_vpg);
 }
 
 #else
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-04-06 13:49 ` Angelo Ribeiro
  0 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-04-06 13:49 UTC (permalink / raw)
  To: yannick.fertre, philippe.cornu, benjamin.gaignard, airlied,
	daniel, mcoquelin.stm32, alexandre.torgue, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto, Angelo Ribeiro

Add support for the video pattern generator (VPG) BER pattern mode and
configuration in runtime.

This enables using the debugfs interface to manipulate the VPG after
the pipeline is set.
Also, enables the usage of the VPG BER pattern.

Changes in v2:
  - Added VID_MODE_VPG_MODE
  - Solved incompatible return type on __get and __set

Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Adrian Pop <pop.adrian61@gmail.com>
Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jose Abreu <jose.abreu@synopsys.com>
Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
 1 file changed, 90 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
index b18351b..9de3645 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
@@ -91,6 +91,7 @@
 #define VID_MODE_TYPE_BURST			0x2
 #define VID_MODE_TYPE_MASK			0x3
 #define VID_MODE_VPG_ENABLE		BIT(16)
+#define VID_MODE_VPG_MODE		BIT(20)
 #define VID_MODE_VPG_HORIZONTAL		BIT(24)
 
 #define DSI_VID_PKT_SIZE		0x3c
@@ -221,6 +222,21 @@
 #define PHY_STATUS_TIMEOUT_US		10000
 #define CMD_PKT_STATUS_TIMEOUT_US	20000
 
+#ifdef CONFIG_DEBUG_FS
+#define VPG_DEFS(name, dsi) \
+	((void __force *)&((*dsi).vpg_defs.name))
+
+#define REGISTER(name, mask, dsi) \
+	{ #name, VPG_DEFS(name, dsi), mask, dsi }
+
+struct debugfs_entries {
+	const char				*name;
+	bool					*reg;
+	u32					mask;
+	struct dw_mipi_dsi			*dsi;
+};
+#endif /* CONFIG_DEBUG_FS */
+
 struct dw_mipi_dsi {
 	struct drm_bridge bridge;
 	struct mipi_dsi_host dsi_host;
@@ -238,9 +254,12 @@ struct dw_mipi_dsi {
 
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *debugfs;
-
-	bool vpg;
-	bool vpg_horizontal;
+	struct debugfs_entries *debugfs_vpg;
+	struct {
+		bool vpg;
+		bool vpg_horizontal;
+		bool vpg_ber_pattern;
+	} vpg_defs;
 #endif /* CONFIG_DEBUG_FS */
 
 	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
@@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
 		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
 
 #ifdef CONFIG_DEBUG_FS
-	if (dsi->vpg) {
+	if (dsi->vpg_defs.vpg) {
 		val |= VID_MODE_VPG_ENABLE;
-		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
+		val |= dsi->vpg_defs.vpg_horizontal ?
+		       VID_MODE_VPG_HORIZONTAL : 0;
+		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
 	}
 #endif /* CONFIG_DEBUG_FS */
 
@@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
 
 #ifdef CONFIG_DEBUG_FS
 
+int dw_mipi_dsi_debugfs_write(void *data, u64 val)
+{
+	struct debugfs_entries *vpg = data;
+	struct dw_mipi_dsi *dsi;
+	u32 mode_cfg;
+
+	if (!vpg)
+		return -ENODEV;
+
+	dsi = vpg->dsi;
+
+	*vpg->reg = (bool)val;
+
+	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
+
+	if (*vpg->reg)
+		mode_cfg |= vpg->mask;
+	else
+		mode_cfg &= ~vpg->mask;
+
+	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
+
+	return 0;
+}
+
+int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
+{
+	struct debugfs_entries *vpg = data;
+
+	if (!vpg)
+		return -ENODEV;
+
+	*val = *vpg->reg;
+
+	return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
+			 dw_mipi_dsi_debugfs_write, "%llu\n");
+
+static void debugfs_create_files(void *data)
+{
+	struct dw_mipi_dsi *dsi = data;
+	struct debugfs_entries debugfs[] = {
+		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
+		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
+		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
+	};
+	int i;
+
+	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
+	if (!dsi->debugfs_vpg)
+		return;
+
+	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
+
+	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
+		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
+				    dsi->debugfs, &dsi->debugfs_vpg[i],
+				    &fops_x32);
+}
+
 static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
 {
 	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
@@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
 		return;
 	}
 
-	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
-	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
-			    &dsi->vpg_horizontal);
+	debugfs_create_files(dsi);
 }
 
 static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
 {
 	debugfs_remove_recursive(dsi->debugfs);
+	kfree(dsi->debugfs_vpg);
 }
 
 #else
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-04-06 13:49 ` Angelo Ribeiro
  0 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-04-06 13:49 UTC (permalink / raw)
  To: yannick.fertre, philippe.cornu, benjamin.gaignard, airlied,
	daniel, mcoquelin.stm32, alexandre.torgue, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto, Angelo Ribeiro

Add support for the video pattern generator (VPG) BER pattern mode and
configuration in runtime.

This enables using the debugfs interface to manipulate the VPG after
the pipeline is set.
Also, enables the usage of the VPG BER pattern.

Changes in v2:
  - Added VID_MODE_VPG_MODE
  - Solved incompatible return type on __get and __set

Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Adrian Pop <pop.adrian61@gmail.com>
Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Jose Abreu <jose.abreu@synopsys.com>
Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
 1 file changed, 90 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
index b18351b..9de3645 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
@@ -91,6 +91,7 @@
 #define VID_MODE_TYPE_BURST			0x2
 #define VID_MODE_TYPE_MASK			0x3
 #define VID_MODE_VPG_ENABLE		BIT(16)
+#define VID_MODE_VPG_MODE		BIT(20)
 #define VID_MODE_VPG_HORIZONTAL		BIT(24)
 
 #define DSI_VID_PKT_SIZE		0x3c
@@ -221,6 +222,21 @@
 #define PHY_STATUS_TIMEOUT_US		10000
 #define CMD_PKT_STATUS_TIMEOUT_US	20000
 
+#ifdef CONFIG_DEBUG_FS
+#define VPG_DEFS(name, dsi) \
+	((void __force *)&((*dsi).vpg_defs.name))
+
+#define REGISTER(name, mask, dsi) \
+	{ #name, VPG_DEFS(name, dsi), mask, dsi }
+
+struct debugfs_entries {
+	const char				*name;
+	bool					*reg;
+	u32					mask;
+	struct dw_mipi_dsi			*dsi;
+};
+#endif /* CONFIG_DEBUG_FS */
+
 struct dw_mipi_dsi {
 	struct drm_bridge bridge;
 	struct mipi_dsi_host dsi_host;
@@ -238,9 +254,12 @@ struct dw_mipi_dsi {
 
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *debugfs;
-
-	bool vpg;
-	bool vpg_horizontal;
+	struct debugfs_entries *debugfs_vpg;
+	struct {
+		bool vpg;
+		bool vpg_horizontal;
+		bool vpg_ber_pattern;
+	} vpg_defs;
 #endif /* CONFIG_DEBUG_FS */
 
 	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
@@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
 		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
 
 #ifdef CONFIG_DEBUG_FS
-	if (dsi->vpg) {
+	if (dsi->vpg_defs.vpg) {
 		val |= VID_MODE_VPG_ENABLE;
-		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
+		val |= dsi->vpg_defs.vpg_horizontal ?
+		       VID_MODE_VPG_HORIZONTAL : 0;
+		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
 	}
 #endif /* CONFIG_DEBUG_FS */
 
@@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
 
 #ifdef CONFIG_DEBUG_FS
 
+int dw_mipi_dsi_debugfs_write(void *data, u64 val)
+{
+	struct debugfs_entries *vpg = data;
+	struct dw_mipi_dsi *dsi;
+	u32 mode_cfg;
+
+	if (!vpg)
+		return -ENODEV;
+
+	dsi = vpg->dsi;
+
+	*vpg->reg = (bool)val;
+
+	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
+
+	if (*vpg->reg)
+		mode_cfg |= vpg->mask;
+	else
+		mode_cfg &= ~vpg->mask;
+
+	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
+
+	return 0;
+}
+
+int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
+{
+	struct debugfs_entries *vpg = data;
+
+	if (!vpg)
+		return -ENODEV;
+
+	*val = *vpg->reg;
+
+	return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
+			 dw_mipi_dsi_debugfs_write, "%llu\n");
+
+static void debugfs_create_files(void *data)
+{
+	struct dw_mipi_dsi *dsi = data;
+	struct debugfs_entries debugfs[] = {
+		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
+		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
+		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
+	};
+	int i;
+
+	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
+	if (!dsi->debugfs_vpg)
+		return;
+
+	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
+
+	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
+		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
+				    dsi->debugfs, &dsi->debugfs_vpg[i],
+				    &fops_x32);
+}
+
 static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
 {
 	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
@@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
 		return;
 	}
 
-	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
-	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
-			    &dsi->vpg_horizontal);
+	debugfs_create_files(dsi);
 }
 
 static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
 {
 	debugfs_remove_recursive(dsi->debugfs);
+	kfree(dsi->debugfs_vpg);
 }
 
 #else
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
  2020-04-06 13:49 ` Angelo Ribeiro
  (?)
@ 2020-04-06 17:45   ` Adrian Pop
  -1 siblings, 0 replies; 30+ messages in thread
From: Adrian Pop @ 2020-04-06 17:45 UTC (permalink / raw)
  To: Angelo Ribeiro
  Cc: yannick.fertre, philippe.cornu, benjamin.gaignard, airlied,
	Daniel Vetter, mcoquelin.stm32, alexandre.torgue, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, Gustavo Pimentel,
	Joao Pinto, Jose Abreu

Hello Angelo,

Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. I guess
there is no horizontal for BER.

Regards,
Adrian

On Mon, Apr 6, 2020 at 4:49 PM Angelo Ribeiro
<Angelo.Ribeiro@synopsys.com> wrote:
>
> Add support for the video pattern generator (VPG) BER pattern mode and
> configuration in runtime.
>
> This enables using the debugfs interface to manipulate the VPG after
> the pipeline is set.
> Also, enables the usage of the VPG BER pattern.
>
> Changes in v2:
>   - Added VID_MODE_VPG_MODE
>   - Solved incompatible return type on __get and __set
>
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> Cc: Joao Pinto <jpinto@synopsys.com>
> Cc: Jose Abreu <jose.abreu@synopsys.com>
> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>  1 file changed, 90 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index b18351b..9de3645 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -91,6 +91,7 @@
>  #define VID_MODE_TYPE_BURST                    0x2
>  #define VID_MODE_TYPE_MASK                     0x3
>  #define VID_MODE_VPG_ENABLE            BIT(16)
> +#define VID_MODE_VPG_MODE              BIT(20)
>  #define VID_MODE_VPG_HORIZONTAL                BIT(24)
>
>  #define DSI_VID_PKT_SIZE               0x3c
> @@ -221,6 +222,21 @@
>  #define PHY_STATUS_TIMEOUT_US          10000
>  #define CMD_PKT_STATUS_TIMEOUT_US      20000
>
> +#ifdef CONFIG_DEBUG_FS
> +#define VPG_DEFS(name, dsi) \
> +       ((void __force *)&((*dsi).vpg_defs.name))
> +
> +#define REGISTER(name, mask, dsi) \
> +       { #name, VPG_DEFS(name, dsi), mask, dsi }
> +
> +struct debugfs_entries {
> +       const char                              *name;
> +       bool                                    *reg;
> +       u32                                     mask;
> +       struct dw_mipi_dsi                      *dsi;
> +};
> +#endif /* CONFIG_DEBUG_FS */
> +
>  struct dw_mipi_dsi {
>         struct drm_bridge bridge;
>         struct mipi_dsi_host dsi_host;
> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>
>  #ifdef CONFIG_DEBUG_FS
>         struct dentry *debugfs;
> -
> -       bool vpg;
> -       bool vpg_horizontal;
> +       struct debugfs_entries *debugfs_vpg;
> +       struct {
> +               bool vpg;
> +               bool vpg_horizontal;
> +               bool vpg_ber_pattern;
> +       } vpg_defs;
>  #endif /* CONFIG_DEBUG_FS */
>
>         struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>                 val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>
>  #ifdef CONFIG_DEBUG_FS
> -       if (dsi->vpg) {
> +       if (dsi->vpg_defs.vpg) {
>                 val |= VID_MODE_VPG_ENABLE;
> -               val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> +               val |= dsi->vpg_defs.vpg_horizontal ?
> +                      VID_MODE_VPG_HORIZONTAL : 0;
> +               val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>         }
>  #endif /* CONFIG_DEBUG_FS */
>
> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>
>  #ifdef CONFIG_DEBUG_FS
>
> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> +{
> +       struct debugfs_entries *vpg = data;
> +       struct dw_mipi_dsi *dsi;
> +       u32 mode_cfg;
> +
> +       if (!vpg)
> +               return -ENODEV;
> +
> +       dsi = vpg->dsi;
> +
> +       *vpg->reg = (bool)val;
> +
> +       mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> +
> +       if (*vpg->reg)
> +               mode_cfg |= vpg->mask;
> +       else
> +               mode_cfg &= ~vpg->mask;
> +
> +       dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> +
> +       return 0;
> +}
> +
> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> +{
> +       struct debugfs_entries *vpg = data;
> +
> +       if (!vpg)
> +               return -ENODEV;
> +
> +       *val = *vpg->reg;
> +
> +       return 0;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> +                        dw_mipi_dsi_debugfs_write, "%llu\n");
> +
> +static void debugfs_create_files(void *data)
> +{
> +       struct dw_mipi_dsi *dsi = data;
> +       struct debugfs_entries debugfs[] = {
> +               REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> +               REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> +               REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> +       };
> +       int i;
> +
> +       dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> +       if (!dsi->debugfs_vpg)
> +               return;
> +
> +       memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> +
> +       for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> +               debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> +                                   dsi->debugfs, &dsi->debugfs_vpg[i],
> +                                   &fops_x32);
> +}
> +
>  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>  {
>         dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>                 return;
>         }
>
> -       debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> -       debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> -                           &dsi->vpg_horizontal);
> +       debugfs_create_files(dsi);
>  }
>
>  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>  {
>         debugfs_remove_recursive(dsi->debugfs);
> +       kfree(dsi->debugfs_vpg);
>  }
>
>  #else
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-04-06 17:45   ` Adrian Pop
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Pop @ 2020-04-06 17:45 UTC (permalink / raw)
  To: Angelo Ribeiro
  Cc: Jose Abreu, Joao Pinto, Daniel Vetter, airlied, Gustavo Pimentel,
	philippe.cornu, dri-devel, linux-kernel, yannick.fertre,
	alexandre.torgue, mcoquelin.stm32, linux-stm32, linux-arm-kernel,
	benjamin.gaignard

Hello Angelo,

Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. I guess
there is no horizontal for BER.

Regards,
Adrian

On Mon, Apr 6, 2020 at 4:49 PM Angelo Ribeiro
<Angelo.Ribeiro@synopsys.com> wrote:
>
> Add support for the video pattern generator (VPG) BER pattern mode and
> configuration in runtime.
>
> This enables using the debugfs interface to manipulate the VPG after
> the pipeline is set.
> Also, enables the usage of the VPG BER pattern.
>
> Changes in v2:
>   - Added VID_MODE_VPG_MODE
>   - Solved incompatible return type on __get and __set
>
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> Cc: Joao Pinto <jpinto@synopsys.com>
> Cc: Jose Abreu <jose.abreu@synopsys.com>
> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>  1 file changed, 90 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index b18351b..9de3645 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -91,6 +91,7 @@
>  #define VID_MODE_TYPE_BURST                    0x2
>  #define VID_MODE_TYPE_MASK                     0x3
>  #define VID_MODE_VPG_ENABLE            BIT(16)
> +#define VID_MODE_VPG_MODE              BIT(20)
>  #define VID_MODE_VPG_HORIZONTAL                BIT(24)
>
>  #define DSI_VID_PKT_SIZE               0x3c
> @@ -221,6 +222,21 @@
>  #define PHY_STATUS_TIMEOUT_US          10000
>  #define CMD_PKT_STATUS_TIMEOUT_US      20000
>
> +#ifdef CONFIG_DEBUG_FS
> +#define VPG_DEFS(name, dsi) \
> +       ((void __force *)&((*dsi).vpg_defs.name))
> +
> +#define REGISTER(name, mask, dsi) \
> +       { #name, VPG_DEFS(name, dsi), mask, dsi }
> +
> +struct debugfs_entries {
> +       const char                              *name;
> +       bool                                    *reg;
> +       u32                                     mask;
> +       struct dw_mipi_dsi                      *dsi;
> +};
> +#endif /* CONFIG_DEBUG_FS */
> +
>  struct dw_mipi_dsi {
>         struct drm_bridge bridge;
>         struct mipi_dsi_host dsi_host;
> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>
>  #ifdef CONFIG_DEBUG_FS
>         struct dentry *debugfs;
> -
> -       bool vpg;
> -       bool vpg_horizontal;
> +       struct debugfs_entries *debugfs_vpg;
> +       struct {
> +               bool vpg;
> +               bool vpg_horizontal;
> +               bool vpg_ber_pattern;
> +       } vpg_defs;
>  #endif /* CONFIG_DEBUG_FS */
>
>         struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>                 val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>
>  #ifdef CONFIG_DEBUG_FS
> -       if (dsi->vpg) {
> +       if (dsi->vpg_defs.vpg) {
>                 val |= VID_MODE_VPG_ENABLE;
> -               val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> +               val |= dsi->vpg_defs.vpg_horizontal ?
> +                      VID_MODE_VPG_HORIZONTAL : 0;
> +               val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>         }
>  #endif /* CONFIG_DEBUG_FS */
>
> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>
>  #ifdef CONFIG_DEBUG_FS
>
> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> +{
> +       struct debugfs_entries *vpg = data;
> +       struct dw_mipi_dsi *dsi;
> +       u32 mode_cfg;
> +
> +       if (!vpg)
> +               return -ENODEV;
> +
> +       dsi = vpg->dsi;
> +
> +       *vpg->reg = (bool)val;
> +
> +       mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> +
> +       if (*vpg->reg)
> +               mode_cfg |= vpg->mask;
> +       else
> +               mode_cfg &= ~vpg->mask;
> +
> +       dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> +
> +       return 0;
> +}
> +
> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> +{
> +       struct debugfs_entries *vpg = data;
> +
> +       if (!vpg)
> +               return -ENODEV;
> +
> +       *val = *vpg->reg;
> +
> +       return 0;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> +                        dw_mipi_dsi_debugfs_write, "%llu\n");
> +
> +static void debugfs_create_files(void *data)
> +{
> +       struct dw_mipi_dsi *dsi = data;
> +       struct debugfs_entries debugfs[] = {
> +               REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> +               REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> +               REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> +       };
> +       int i;
> +
> +       dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> +       if (!dsi->debugfs_vpg)
> +               return;
> +
> +       memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> +
> +       for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> +               debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> +                                   dsi->debugfs, &dsi->debugfs_vpg[i],
> +                                   &fops_x32);
> +}
> +
>  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>  {
>         dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>                 return;
>         }
>
> -       debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> -       debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> -                           &dsi->vpg_horizontal);
> +       debugfs_create_files(dsi);
>  }
>
>  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>  {
>         debugfs_remove_recursive(dsi->debugfs);
> +       kfree(dsi->debugfs_vpg);
>  }
>
>  #else
> --
> 2.7.4
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-04-06 17:45   ` Adrian Pop
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Pop @ 2020-04-06 17:45 UTC (permalink / raw)
  To: Angelo Ribeiro
  Cc: Jose Abreu, Joao Pinto, airlied, Gustavo Pimentel,
	philippe.cornu, dri-devel, linux-kernel, yannick.fertre,
	alexandre.torgue, mcoquelin.stm32, linux-stm32, linux-arm-kernel,
	benjamin.gaignard

Hello Angelo,

Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. I guess
there is no horizontal for BER.

Regards,
Adrian

On Mon, Apr 6, 2020 at 4:49 PM Angelo Ribeiro
<Angelo.Ribeiro@synopsys.com> wrote:
>
> Add support for the video pattern generator (VPG) BER pattern mode and
> configuration in runtime.
>
> This enables using the debugfs interface to manipulate the VPG after
> the pipeline is set.
> Also, enables the usage of the VPG BER pattern.
>
> Changes in v2:
>   - Added VID_MODE_VPG_MODE
>   - Solved incompatible return type on __get and __set
>
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> Cc: Joao Pinto <jpinto@synopsys.com>
> Cc: Jose Abreu <jose.abreu@synopsys.com>
> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>  1 file changed, 90 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index b18351b..9de3645 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -91,6 +91,7 @@
>  #define VID_MODE_TYPE_BURST                    0x2
>  #define VID_MODE_TYPE_MASK                     0x3
>  #define VID_MODE_VPG_ENABLE            BIT(16)
> +#define VID_MODE_VPG_MODE              BIT(20)
>  #define VID_MODE_VPG_HORIZONTAL                BIT(24)
>
>  #define DSI_VID_PKT_SIZE               0x3c
> @@ -221,6 +222,21 @@
>  #define PHY_STATUS_TIMEOUT_US          10000
>  #define CMD_PKT_STATUS_TIMEOUT_US      20000
>
> +#ifdef CONFIG_DEBUG_FS
> +#define VPG_DEFS(name, dsi) \
> +       ((void __force *)&((*dsi).vpg_defs.name))
> +
> +#define REGISTER(name, mask, dsi) \
> +       { #name, VPG_DEFS(name, dsi), mask, dsi }
> +
> +struct debugfs_entries {
> +       const char                              *name;
> +       bool                                    *reg;
> +       u32                                     mask;
> +       struct dw_mipi_dsi                      *dsi;
> +};
> +#endif /* CONFIG_DEBUG_FS */
> +
>  struct dw_mipi_dsi {
>         struct drm_bridge bridge;
>         struct mipi_dsi_host dsi_host;
> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>
>  #ifdef CONFIG_DEBUG_FS
>         struct dentry *debugfs;
> -
> -       bool vpg;
> -       bool vpg_horizontal;
> +       struct debugfs_entries *debugfs_vpg;
> +       struct {
> +               bool vpg;
> +               bool vpg_horizontal;
> +               bool vpg_ber_pattern;
> +       } vpg_defs;
>  #endif /* CONFIG_DEBUG_FS */
>
>         struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>                 val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>
>  #ifdef CONFIG_DEBUG_FS
> -       if (dsi->vpg) {
> +       if (dsi->vpg_defs.vpg) {
>                 val |= VID_MODE_VPG_ENABLE;
> -               val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> +               val |= dsi->vpg_defs.vpg_horizontal ?
> +                      VID_MODE_VPG_HORIZONTAL : 0;
> +               val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>         }
>  #endif /* CONFIG_DEBUG_FS */
>
> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>
>  #ifdef CONFIG_DEBUG_FS
>
> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> +{
> +       struct debugfs_entries *vpg = data;
> +       struct dw_mipi_dsi *dsi;
> +       u32 mode_cfg;
> +
> +       if (!vpg)
> +               return -ENODEV;
> +
> +       dsi = vpg->dsi;
> +
> +       *vpg->reg = (bool)val;
> +
> +       mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> +
> +       if (*vpg->reg)
> +               mode_cfg |= vpg->mask;
> +       else
> +               mode_cfg &= ~vpg->mask;
> +
> +       dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> +
> +       return 0;
> +}
> +
> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> +{
> +       struct debugfs_entries *vpg = data;
> +
> +       if (!vpg)
> +               return -ENODEV;
> +
> +       *val = *vpg->reg;
> +
> +       return 0;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> +                        dw_mipi_dsi_debugfs_write, "%llu\n");
> +
> +static void debugfs_create_files(void *data)
> +{
> +       struct dw_mipi_dsi *dsi = data;
> +       struct debugfs_entries debugfs[] = {
> +               REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> +               REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> +               REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> +       };
> +       int i;
> +
> +       dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> +       if (!dsi->debugfs_vpg)
> +               return;
> +
> +       memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> +
> +       for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> +               debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> +                                   dsi->debugfs, &dsi->debugfs_vpg[i],
> +                                   &fops_x32);
> +}
> +
>  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>  {
>         dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>                 return;
>         }
>
> -       debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> -       debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> -                           &dsi->vpg_horizontal);
> +       debugfs_create_files(dsi);
>  }
>
>  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>  {
>         debugfs_remove_recursive(dsi->debugfs);
> +       kfree(dsi->debugfs_vpg);
>  }
>
>  #else
> --
> 2.7.4
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
  2020-04-06 17:45   ` Adrian Pop
  (?)
@ 2020-04-07  6:58     ` Adrian Pop
  -1 siblings, 0 replies; 30+ messages in thread
From: Adrian Pop @ 2020-04-07  6:58 UTC (permalink / raw)
  To: Angelo Ribeiro
  Cc: yannick.fertre, philippe.cornu, benjamin.gaignard, airlied,
	Daniel Vetter, mcoquelin.stm32, alexandre.torgue, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, Gustavo Pimentel,
	Joao Pinto, Jose Abreu

Tested-by: Adrian Pop <pop.adrian61@gmail.com>
Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406.

On Mon, Apr 6, 2020 at 8:45 PM Adrian Pop <pop.adrian61@gmail.com> wrote:
>
> Hello Angelo,
>
> Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. I guess
> there is no horizontal for BER.
>
> Regards,
> Adrian
>
> On Mon, Apr 6, 2020 at 4:49 PM Angelo Ribeiro
> <Angelo.Ribeiro@synopsys.com> wrote:
> >
> > Add support for the video pattern generator (VPG) BER pattern mode and
> > configuration in runtime.
> >
> > This enables using the debugfs interface to manipulate the VPG after
> > the pipeline is set.
> > Also, enables the usage of the VPG BER pattern.
> >
> > Changes in v2:
> >   - Added VID_MODE_VPG_MODE
> >   - Solved incompatible return type on __get and __set
> >
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> > Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> > Cc: Joao Pinto <jpinto@synopsys.com>
> > Cc: Jose Abreu <jose.abreu@synopsys.com>
> > Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> > ---
> >  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
> >  1 file changed, 90 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > index b18351b..9de3645 100644
> > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > @@ -91,6 +91,7 @@
> >  #define VID_MODE_TYPE_BURST                    0x2
> >  #define VID_MODE_TYPE_MASK                     0x3
> >  #define VID_MODE_VPG_ENABLE            BIT(16)
> > +#define VID_MODE_VPG_MODE              BIT(20)
> >  #define VID_MODE_VPG_HORIZONTAL                BIT(24)
> >
> >  #define DSI_VID_PKT_SIZE               0x3c
> > @@ -221,6 +222,21 @@
> >  #define PHY_STATUS_TIMEOUT_US          10000
> >  #define CMD_PKT_STATUS_TIMEOUT_US      20000
> >
> > +#ifdef CONFIG_DEBUG_FS
> > +#define VPG_DEFS(name, dsi) \
> > +       ((void __force *)&((*dsi).vpg_defs.name))
> > +
> > +#define REGISTER(name, mask, dsi) \
> > +       { #name, VPG_DEFS(name, dsi), mask, dsi }
> > +
> > +struct debugfs_entries {
> > +       const char                              *name;
> > +       bool                                    *reg;
> > +       u32                                     mask;
> > +       struct dw_mipi_dsi                      *dsi;
> > +};
> > +#endif /* CONFIG_DEBUG_FS */
> > +
> >  struct dw_mipi_dsi {
> >         struct drm_bridge bridge;
> >         struct mipi_dsi_host dsi_host;
> > @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> >
> >  #ifdef CONFIG_DEBUG_FS
> >         struct dentry *debugfs;
> > -
> > -       bool vpg;
> > -       bool vpg_horizontal;
> > +       struct debugfs_entries *debugfs_vpg;
> > +       struct {
> > +               bool vpg;
> > +               bool vpg_horizontal;
> > +               bool vpg_ber_pattern;
> > +       } vpg_defs;
> >  #endif /* CONFIG_DEBUG_FS */
> >
> >         struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> > @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
> >                 val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> >
> >  #ifdef CONFIG_DEBUG_FS
> > -       if (dsi->vpg) {
> > +       if (dsi->vpg_defs.vpg) {
> >                 val |= VID_MODE_VPG_ENABLE;
> > -               val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> > +               val |= dsi->vpg_defs.vpg_horizontal ?
> > +                      VID_MODE_VPG_HORIZONTAL : 0;
> > +               val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> >         }
> >  #endif /* CONFIG_DEBUG_FS */
> >
> > @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
> >
> >  #ifdef CONFIG_DEBUG_FS
> >
> > +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> > +{
> > +       struct debugfs_entries *vpg = data;
> > +       struct dw_mipi_dsi *dsi;
> > +       u32 mode_cfg;
> > +
> > +       if (!vpg)
> > +               return -ENODEV;
> > +
> > +       dsi = vpg->dsi;
> > +
> > +       *vpg->reg = (bool)val;
> > +
> > +       mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> > +
> > +       if (*vpg->reg)
> > +               mode_cfg |= vpg->mask;
> > +       else
> > +               mode_cfg &= ~vpg->mask;
> > +
> > +       dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> > +
> > +       return 0;
> > +}
> > +
> > +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> > +{
> > +       struct debugfs_entries *vpg = data;
> > +
> > +       if (!vpg)
> > +               return -ENODEV;
> > +
> > +       *val = *vpg->reg;
> > +
> > +       return 0;
> > +}
> > +
> > +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> > +                        dw_mipi_dsi_debugfs_write, "%llu\n");
> > +
> > +static void debugfs_create_files(void *data)
> > +{
> > +       struct dw_mipi_dsi *dsi = data;
> > +       struct debugfs_entries debugfs[] = {
> > +               REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> > +               REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> > +               REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> > +       };
> > +       int i;
> > +
> > +       dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> > +       if (!dsi->debugfs_vpg)
> > +               return;
> > +
> > +       memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> > +
> > +       for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> > +               debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> > +                                   dsi->debugfs, &dsi->debugfs_vpg[i],
> > +                                   &fops_x32);
> > +}
> > +
> >  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >  {
> >         dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> > @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >                 return;
> >         }
> >
> > -       debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> > -       debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> > -                           &dsi->vpg_horizontal);
> > +       debugfs_create_files(dsi);
> >  }
> >
> >  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> >  {
> >         debugfs_remove_recursive(dsi->debugfs);
> > +       kfree(dsi->debugfs_vpg);
> >  }
> >
> >  #else
> > --
> > 2.7.4
> >

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-04-07  6:58     ` Adrian Pop
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Pop @ 2020-04-07  6:58 UTC (permalink / raw)
  To: Angelo Ribeiro
  Cc: Jose Abreu, Joao Pinto, Daniel Vetter, airlied, Gustavo Pimentel,
	philippe.cornu, dri-devel, linux-kernel, yannick.fertre,
	alexandre.torgue, mcoquelin.stm32, linux-stm32, linux-arm-kernel,
	benjamin.gaignard

Tested-by: Adrian Pop <pop.adrian61@gmail.com>
Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406.

On Mon, Apr 6, 2020 at 8:45 PM Adrian Pop <pop.adrian61@gmail.com> wrote:
>
> Hello Angelo,
>
> Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. I guess
> there is no horizontal for BER.
>
> Regards,
> Adrian
>
> On Mon, Apr 6, 2020 at 4:49 PM Angelo Ribeiro
> <Angelo.Ribeiro@synopsys.com> wrote:
> >
> > Add support for the video pattern generator (VPG) BER pattern mode and
> > configuration in runtime.
> >
> > This enables using the debugfs interface to manipulate the VPG after
> > the pipeline is set.
> > Also, enables the usage of the VPG BER pattern.
> >
> > Changes in v2:
> >   - Added VID_MODE_VPG_MODE
> >   - Solved incompatible return type on __get and __set
> >
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> > Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> > Cc: Joao Pinto <jpinto@synopsys.com>
> > Cc: Jose Abreu <jose.abreu@synopsys.com>
> > Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> > ---
> >  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
> >  1 file changed, 90 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > index b18351b..9de3645 100644
> > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > @@ -91,6 +91,7 @@
> >  #define VID_MODE_TYPE_BURST                    0x2
> >  #define VID_MODE_TYPE_MASK                     0x3
> >  #define VID_MODE_VPG_ENABLE            BIT(16)
> > +#define VID_MODE_VPG_MODE              BIT(20)
> >  #define VID_MODE_VPG_HORIZONTAL                BIT(24)
> >
> >  #define DSI_VID_PKT_SIZE               0x3c
> > @@ -221,6 +222,21 @@
> >  #define PHY_STATUS_TIMEOUT_US          10000
> >  #define CMD_PKT_STATUS_TIMEOUT_US      20000
> >
> > +#ifdef CONFIG_DEBUG_FS
> > +#define VPG_DEFS(name, dsi) \
> > +       ((void __force *)&((*dsi).vpg_defs.name))
> > +
> > +#define REGISTER(name, mask, dsi) \
> > +       { #name, VPG_DEFS(name, dsi), mask, dsi }
> > +
> > +struct debugfs_entries {
> > +       const char                              *name;
> > +       bool                                    *reg;
> > +       u32                                     mask;
> > +       struct dw_mipi_dsi                      *dsi;
> > +};
> > +#endif /* CONFIG_DEBUG_FS */
> > +
> >  struct dw_mipi_dsi {
> >         struct drm_bridge bridge;
> >         struct mipi_dsi_host dsi_host;
> > @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> >
> >  #ifdef CONFIG_DEBUG_FS
> >         struct dentry *debugfs;
> > -
> > -       bool vpg;
> > -       bool vpg_horizontal;
> > +       struct debugfs_entries *debugfs_vpg;
> > +       struct {
> > +               bool vpg;
> > +               bool vpg_horizontal;
> > +               bool vpg_ber_pattern;
> > +       } vpg_defs;
> >  #endif /* CONFIG_DEBUG_FS */
> >
> >         struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> > @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
> >                 val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> >
> >  #ifdef CONFIG_DEBUG_FS
> > -       if (dsi->vpg) {
> > +       if (dsi->vpg_defs.vpg) {
> >                 val |= VID_MODE_VPG_ENABLE;
> > -               val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> > +               val |= dsi->vpg_defs.vpg_horizontal ?
> > +                      VID_MODE_VPG_HORIZONTAL : 0;
> > +               val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> >         }
> >  #endif /* CONFIG_DEBUG_FS */
> >
> > @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
> >
> >  #ifdef CONFIG_DEBUG_FS
> >
> > +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> > +{
> > +       struct debugfs_entries *vpg = data;
> > +       struct dw_mipi_dsi *dsi;
> > +       u32 mode_cfg;
> > +
> > +       if (!vpg)
> > +               return -ENODEV;
> > +
> > +       dsi = vpg->dsi;
> > +
> > +       *vpg->reg = (bool)val;
> > +
> > +       mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> > +
> > +       if (*vpg->reg)
> > +               mode_cfg |= vpg->mask;
> > +       else
> > +               mode_cfg &= ~vpg->mask;
> > +
> > +       dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> > +
> > +       return 0;
> > +}
> > +
> > +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> > +{
> > +       struct debugfs_entries *vpg = data;
> > +
> > +       if (!vpg)
> > +               return -ENODEV;
> > +
> > +       *val = *vpg->reg;
> > +
> > +       return 0;
> > +}
> > +
> > +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> > +                        dw_mipi_dsi_debugfs_write, "%llu\n");
> > +
> > +static void debugfs_create_files(void *data)
> > +{
> > +       struct dw_mipi_dsi *dsi = data;
> > +       struct debugfs_entries debugfs[] = {
> > +               REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> > +               REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> > +               REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> > +       };
> > +       int i;
> > +
> > +       dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> > +       if (!dsi->debugfs_vpg)
> > +               return;
> > +
> > +       memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> > +
> > +       for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> > +               debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> > +                                   dsi->debugfs, &dsi->debugfs_vpg[i],
> > +                                   &fops_x32);
> > +}
> > +
> >  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >  {
> >         dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> > @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >                 return;
> >         }
> >
> > -       debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> > -       debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> > -                           &dsi->vpg_horizontal);
> > +       debugfs_create_files(dsi);
> >  }
> >
> >  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> >  {
> >         debugfs_remove_recursive(dsi->debugfs);
> > +       kfree(dsi->debugfs_vpg);
> >  }
> >
> >  #else
> > --
> > 2.7.4
> >

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-04-07  6:58     ` Adrian Pop
  0 siblings, 0 replies; 30+ messages in thread
From: Adrian Pop @ 2020-04-07  6:58 UTC (permalink / raw)
  To: Angelo Ribeiro
  Cc: Jose Abreu, Joao Pinto, airlied, Gustavo Pimentel,
	philippe.cornu, dri-devel, linux-kernel, yannick.fertre,
	alexandre.torgue, mcoquelin.stm32, linux-stm32, linux-arm-kernel,
	benjamin.gaignard

Tested-by: Adrian Pop <pop.adrian61@gmail.com>
Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406.

On Mon, Apr 6, 2020 at 8:45 PM Adrian Pop <pop.adrian61@gmail.com> wrote:
>
> Hello Angelo,
>
> Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. I guess
> there is no horizontal for BER.
>
> Regards,
> Adrian
>
> On Mon, Apr 6, 2020 at 4:49 PM Angelo Ribeiro
> <Angelo.Ribeiro@synopsys.com> wrote:
> >
> > Add support for the video pattern generator (VPG) BER pattern mode and
> > configuration in runtime.
> >
> > This enables using the debugfs interface to manipulate the VPG after
> > the pipeline is set.
> > Also, enables the usage of the VPG BER pattern.
> >
> > Changes in v2:
> >   - Added VID_MODE_VPG_MODE
> >   - Solved incompatible return type on __get and __set
> >
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> > Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> > Cc: Joao Pinto <jpinto@synopsys.com>
> > Cc: Jose Abreu <jose.abreu@synopsys.com>
> > Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> > ---
> >  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
> >  1 file changed, 90 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > index b18351b..9de3645 100644
> > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > @@ -91,6 +91,7 @@
> >  #define VID_MODE_TYPE_BURST                    0x2
> >  #define VID_MODE_TYPE_MASK                     0x3
> >  #define VID_MODE_VPG_ENABLE            BIT(16)
> > +#define VID_MODE_VPG_MODE              BIT(20)
> >  #define VID_MODE_VPG_HORIZONTAL                BIT(24)
> >
> >  #define DSI_VID_PKT_SIZE               0x3c
> > @@ -221,6 +222,21 @@
> >  #define PHY_STATUS_TIMEOUT_US          10000
> >  #define CMD_PKT_STATUS_TIMEOUT_US      20000
> >
> > +#ifdef CONFIG_DEBUG_FS
> > +#define VPG_DEFS(name, dsi) \
> > +       ((void __force *)&((*dsi).vpg_defs.name))
> > +
> > +#define REGISTER(name, mask, dsi) \
> > +       { #name, VPG_DEFS(name, dsi), mask, dsi }
> > +
> > +struct debugfs_entries {
> > +       const char                              *name;
> > +       bool                                    *reg;
> > +       u32                                     mask;
> > +       struct dw_mipi_dsi                      *dsi;
> > +};
> > +#endif /* CONFIG_DEBUG_FS */
> > +
> >  struct dw_mipi_dsi {
> >         struct drm_bridge bridge;
> >         struct mipi_dsi_host dsi_host;
> > @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> >
> >  #ifdef CONFIG_DEBUG_FS
> >         struct dentry *debugfs;
> > -
> > -       bool vpg;
> > -       bool vpg_horizontal;
> > +       struct debugfs_entries *debugfs_vpg;
> > +       struct {
> > +               bool vpg;
> > +               bool vpg_horizontal;
> > +               bool vpg_ber_pattern;
> > +       } vpg_defs;
> >  #endif /* CONFIG_DEBUG_FS */
> >
> >         struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> > @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
> >                 val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> >
> >  #ifdef CONFIG_DEBUG_FS
> > -       if (dsi->vpg) {
> > +       if (dsi->vpg_defs.vpg) {
> >                 val |= VID_MODE_VPG_ENABLE;
> > -               val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> > +               val |= dsi->vpg_defs.vpg_horizontal ?
> > +                      VID_MODE_VPG_HORIZONTAL : 0;
> > +               val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> >         }
> >  #endif /* CONFIG_DEBUG_FS */
> >
> > @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
> >
> >  #ifdef CONFIG_DEBUG_FS
> >
> > +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> > +{
> > +       struct debugfs_entries *vpg = data;
> > +       struct dw_mipi_dsi *dsi;
> > +       u32 mode_cfg;
> > +
> > +       if (!vpg)
> > +               return -ENODEV;
> > +
> > +       dsi = vpg->dsi;
> > +
> > +       *vpg->reg = (bool)val;
> > +
> > +       mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> > +
> > +       if (*vpg->reg)
> > +               mode_cfg |= vpg->mask;
> > +       else
> > +               mode_cfg &= ~vpg->mask;
> > +
> > +       dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> > +
> > +       return 0;
> > +}
> > +
> > +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> > +{
> > +       struct debugfs_entries *vpg = data;
> > +
> > +       if (!vpg)
> > +               return -ENODEV;
> > +
> > +       *val = *vpg->reg;
> > +
> > +       return 0;
> > +}
> > +
> > +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> > +                        dw_mipi_dsi_debugfs_write, "%llu\n");
> > +
> > +static void debugfs_create_files(void *data)
> > +{
> > +       struct dw_mipi_dsi *dsi = data;
> > +       struct debugfs_entries debugfs[] = {
> > +               REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> > +               REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> > +               REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> > +       };
> > +       int i;
> > +
> > +       dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> > +       if (!dsi->debugfs_vpg)
> > +               return;
> > +
> > +       memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> > +
> > +       for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> > +               debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> > +                                   dsi->debugfs, &dsi->debugfs_vpg[i],
> > +                                   &fops_x32);
> > +}
> > +
> >  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >  {
> >         dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> > @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >                 return;
> >         }
> >
> > -       debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> > -       debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> > -                           &dsi->vpg_horizontal);
> > +       debugfs_create_files(dsi);
> >  }
> >
> >  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> >  {
> >         debugfs_remove_recursive(dsi->debugfs);
> > +       kfree(dsi->debugfs_vpg);
> >  }
> >
> >  #else
> > --
> > 2.7.4
> >
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
  2020-04-07  6:58     ` Adrian Pop
  (?)
@ 2020-04-07 16:38       ` Angelo Ribeiro
  -1 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-04-07 16:38 UTC (permalink / raw)
  To: Adrian Pop
  Cc: yannick.fertre, philippe.cornu, benjamin.gaignard, airlied,
	Daniel Vetter, mcoquelin.stm32, alexandre.torgue, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, Gustavo Pimentel,
	Joao Pinto, Jose Abreu

Hi Adrian,

> -----Original Message-----
> From: Adrian Pop <pop.adrian61@gmail.com>
> Sent: Tuesday, April 7, 2020 7:58 AM
> To: Angelo Ribeiro <angelor@synopsys.com>
> Cc: yannick.fertre@st.com; philippe.cornu@st.com;
> benjamin.gaignard@st.com; airlied@linux.ie; Daniel Vetter
> <daniel@ffwll.ch>; mcoquelin.stm32@gmail.com; alexandre.torgue@st.com;
> dri-devel@lists.freedesktop.org; linux-stm32@st-md-mailman.stormreply.com;
> linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
> Gustavo Pimentel <gustavo@synopsys.com>; Joao Pinto <jpinto@synopsys.com>;
> Jose Abreu <joabreu@synopsys.com>
> Subject: Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config
> through debugfs
> 
> Tested-by: Adrian Pop <pop.adrian61@gmail.com>
> Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406.
> 
> On Mon, Apr 6, 2020 at 8:45 PM Adrian Pop <pop.adrian61@gmail.com> wrote:
> >
> > Hello Angelo,
> >
> > Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. I guess
> > there is no horizontal for BER.

Yes, there is no horizontal for BER.
Thank you for testing the patch.

> >
> > Regards,
> > Adrian
> >
> > On Mon, Apr 6, 2020 at 4:49 PM Angelo Ribeiro
> > <Angelo.Ribeiro@synopsys.com> wrote:
> > >
> > > Add support for the video pattern generator (VPG) BER pattern mode and
> > > configuration in runtime.
> > >
> > > This enables using the debugfs interface to manipulate the VPG after
> > > the pipeline is set.
> > > Also, enables the usage of the VPG BER pattern.
> > >
> > > Changes in v2:
> > >   - Added VID_MODE_VPG_MODE
> > >   - Solved incompatible return type on __get and __set
> > >
> > > Reported-by: kbuild test robot <lkp@intel.com>
> > > Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> > > Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> > > Cc: Joao Pinto <jpinto@synopsys.com>
> > > Cc: Jose Abreu <jose.abreu@synopsys.com>
> > > Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> > > ---
> > >  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98
> ++++++++++++++++++++++++---
> > >  1 file changed, 90 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > > index b18351b..9de3645 100644
> > > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > > @@ -91,6 +91,7 @@
> > >  #define VID_MODE_TYPE_BURST                    0x2
> > >  #define VID_MODE_TYPE_MASK                     0x3
> > >  #define VID_MODE_VPG_ENABLE            BIT(16)
> > > +#define VID_MODE_VPG_MODE              BIT(20)
> > >  #define VID_MODE_VPG_HORIZONTAL                BIT(24)
> > >
> > >  #define DSI_VID_PKT_SIZE               0x3c
> > > @@ -221,6 +222,21 @@
> > >  #define PHY_STATUS_TIMEOUT_US          10000
> > >  #define CMD_PKT_STATUS_TIMEOUT_US      20000
> > >
> > > +#ifdef CONFIG_DEBUG_FS
> > > +#define VPG_DEFS(name, dsi) \
> > > +       ((void __force *)&((*dsi).vpg_defs.name))
> > > +
> > > +#define REGISTER(name, mask, dsi) \
> > > +       { #name, VPG_DEFS(name, dsi), mask, dsi }
> > > +
> > > +struct debugfs_entries {
> > > +       const char                              *name;
> > > +       bool                                    *reg;
> > > +       u32                                     mask;
> > > +       struct dw_mipi_dsi                      *dsi;
> > > +};
> > > +#endif /* CONFIG_DEBUG_FS */
> > > +
> > >  struct dw_mipi_dsi {
> > >         struct drm_bridge bridge;
> > >         struct mipi_dsi_host dsi_host;
> > > @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> > >
> > >  #ifdef CONFIG_DEBUG_FS
> > >         struct dentry *debugfs;
> > > -
> > > -       bool vpg;
> > > -       bool vpg_horizontal;
> > > +       struct debugfs_entries *debugfs_vpg;
> > > +       struct {
> > > +               bool vpg;
> > > +               bool vpg_horizontal;
> > > +               bool vpg_ber_pattern;
> > > +       } vpg_defs;
> > >  #endif /* CONFIG_DEBUG_FS */
> > >
> > >         struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> > > @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct
> dw_mipi_dsi *dsi)
> > >                 val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> > >
> > >  #ifdef CONFIG_DEBUG_FS
> > > -       if (dsi->vpg) {
> > > +       if (dsi->vpg_defs.vpg) {
> > >                 val |= VID_MODE_VPG_ENABLE;
> > > -               val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL :
> 0;
> > > +               val |= dsi->vpg_defs.vpg_horizontal ?
> > > +                      VID_MODE_VPG_HORIZONTAL : 0;
> > > +               val |= dsi->vpg_defs.vpg_ber_pattern ?
> VID_MODE_VPG_MODE : 0;
> > >         }
> > >  #endif /* CONFIG_DEBUG_FS */
> > >
> > > @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs
> dw_mipi_dsi_bridge_funcs = {
> > >
> > >  #ifdef CONFIG_DEBUG_FS
> > >
> > > +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> > > +{
> > > +       struct debugfs_entries *vpg = data;
> > > +       struct dw_mipi_dsi *dsi;
> > > +       u32 mode_cfg;
> > > +
> > > +       if (!vpg)
> > > +               return -ENODEV;
> > > +
> > > +       dsi = vpg->dsi;
> > > +
> > > +       *vpg->reg = (bool)val;
> > > +
> > > +       mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> > > +
> > > +       if (*vpg->reg)
> > > +               mode_cfg |= vpg->mask;
> > > +       else
> > > +               mode_cfg &= ~vpg->mask;
> > > +
> > > +       dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> > > +{
> > > +       struct debugfs_entries *vpg = data;
> > > +
> > > +       if (!vpg)
> > > +               return -ENODEV;
> > > +
> > > +       *val = *vpg->reg;
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> > > +                        dw_mipi_dsi_debugfs_write, "%llu\n");
> > > +
> > > +static void debugfs_create_files(void *data)
> > > +{
> > > +       struct dw_mipi_dsi *dsi = data;
> > > +       struct debugfs_entries debugfs[] = {
> > > +               REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> > > +               REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL,
> dsi),
> > > +               REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> > > +       };
> > > +       int i;
> > > +
> > > +       dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> > > +       if (!dsi->debugfs_vpg)
> > > +               return;
> > > +
> > > +       memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> > > +
> > > +       for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> > > +               debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> > > +                                   dsi->debugfs, &dsi-
> >debugfs_vpg[i],
> > > +                                   &fops_x32);
> > > +}
> > > +
> > >  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> > >  {
> > >         dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> > > @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct
> dw_mipi_dsi *dsi)
> > >                 return;
> > >         }
> > >
> > > -       debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> > > -       debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> > > -                           &dsi->vpg_horizontal);
> > > +       debugfs_create_files(dsi);
> > >  }
> > >
> > >  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> > >  {
> > >         debugfs_remove_recursive(dsi->debugfs);
> > > +       kfree(dsi->debugfs_vpg);
> > >  }
> > >
> > >  #else
> > > --
> > > 2.7.4
> > >


Thanks,
Angelo

^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-04-07 16:38       ` Angelo Ribeiro
  0 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-04-07 16:38 UTC (permalink / raw)
  To: Adrian Pop
  Cc: Jose Abreu, Joao Pinto, Daniel Vetter, airlied, Gustavo Pimentel,
	philippe.cornu, dri-devel, linux-kernel, yannick.fertre,
	alexandre.torgue, mcoquelin.stm32, linux-stm32, linux-arm-kernel,
	benjamin.gaignard

Hi Adrian,

> -----Original Message-----
> From: Adrian Pop <pop.adrian61@gmail.com>
> Sent: Tuesday, April 7, 2020 7:58 AM
> To: Angelo Ribeiro <angelor@synopsys.com>
> Cc: yannick.fertre@st.com; philippe.cornu@st.com;
> benjamin.gaignard@st.com; airlied@linux.ie; Daniel Vetter
> <daniel@ffwll.ch>; mcoquelin.stm32@gmail.com; alexandre.torgue@st.com;
> dri-devel@lists.freedesktop.org; linux-stm32@st-md-mailman.stormreply.com;
> linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
> Gustavo Pimentel <gustavo@synopsys.com>; Joao Pinto <jpinto@synopsys.com>;
> Jose Abreu <joabreu@synopsys.com>
> Subject: Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config
> through debugfs
> 
> Tested-by: Adrian Pop <pop.adrian61@gmail.com>
> Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406.
> 
> On Mon, Apr 6, 2020 at 8:45 PM Adrian Pop <pop.adrian61@gmail.com> wrote:
> >
> > Hello Angelo,
> >
> > Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. I guess
> > there is no horizontal for BER.

Yes, there is no horizontal for BER.
Thank you for testing the patch.

> >
> > Regards,
> > Adrian
> >
> > On Mon, Apr 6, 2020 at 4:49 PM Angelo Ribeiro
> > <Angelo.Ribeiro@synopsys.com> wrote:
> > >
> > > Add support for the video pattern generator (VPG) BER pattern mode and
> > > configuration in runtime.
> > >
> > > This enables using the debugfs interface to manipulate the VPG after
> > > the pipeline is set.
> > > Also, enables the usage of the VPG BER pattern.
> > >
> > > Changes in v2:
> > >   - Added VID_MODE_VPG_MODE
> > >   - Solved incompatible return type on __get and __set
> > >
> > > Reported-by: kbuild test robot <lkp@intel.com>
> > > Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> > > Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> > > Cc: Joao Pinto <jpinto@synopsys.com>
> > > Cc: Jose Abreu <jose.abreu@synopsys.com>
> > > Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> > > ---
> > >  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98
> ++++++++++++++++++++++++---
> > >  1 file changed, 90 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > > index b18351b..9de3645 100644
> > > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > > @@ -91,6 +91,7 @@
> > >  #define VID_MODE_TYPE_BURST                    0x2
> > >  #define VID_MODE_TYPE_MASK                     0x3
> > >  #define VID_MODE_VPG_ENABLE            BIT(16)
> > > +#define VID_MODE_VPG_MODE              BIT(20)
> > >  #define VID_MODE_VPG_HORIZONTAL                BIT(24)
> > >
> > >  #define DSI_VID_PKT_SIZE               0x3c
> > > @@ -221,6 +222,21 @@
> > >  #define PHY_STATUS_TIMEOUT_US          10000
> > >  #define CMD_PKT_STATUS_TIMEOUT_US      20000
> > >
> > > +#ifdef CONFIG_DEBUG_FS
> > > +#define VPG_DEFS(name, dsi) \
> > > +       ((void __force *)&((*dsi).vpg_defs.name))
> > > +
> > > +#define REGISTER(name, mask, dsi) \
> > > +       { #name, VPG_DEFS(name, dsi), mask, dsi }
> > > +
> > > +struct debugfs_entries {
> > > +       const char                              *name;
> > > +       bool                                    *reg;
> > > +       u32                                     mask;
> > > +       struct dw_mipi_dsi                      *dsi;
> > > +};
> > > +#endif /* CONFIG_DEBUG_FS */
> > > +
> > >  struct dw_mipi_dsi {
> > >         struct drm_bridge bridge;
> > >         struct mipi_dsi_host dsi_host;
> > > @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> > >
> > >  #ifdef CONFIG_DEBUG_FS
> > >         struct dentry *debugfs;
> > > -
> > > -       bool vpg;
> > > -       bool vpg_horizontal;
> > > +       struct debugfs_entries *debugfs_vpg;
> > > +       struct {
> > > +               bool vpg;
> > > +               bool vpg_horizontal;
> > > +               bool vpg_ber_pattern;
> > > +       } vpg_defs;
> > >  #endif /* CONFIG_DEBUG_FS */
> > >
> > >         struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> > > @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct
> dw_mipi_dsi *dsi)
> > >                 val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> > >
> > >  #ifdef CONFIG_DEBUG_FS
> > > -       if (dsi->vpg) {
> > > +       if (dsi->vpg_defs.vpg) {
> > >                 val |= VID_MODE_VPG_ENABLE;
> > > -               val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL :
> 0;
> > > +               val |= dsi->vpg_defs.vpg_horizontal ?
> > > +                      VID_MODE_VPG_HORIZONTAL : 0;
> > > +               val |= dsi->vpg_defs.vpg_ber_pattern ?
> VID_MODE_VPG_MODE : 0;
> > >         }
> > >  #endif /* CONFIG_DEBUG_FS */
> > >
> > > @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs
> dw_mipi_dsi_bridge_funcs = {
> > >
> > >  #ifdef CONFIG_DEBUG_FS
> > >
> > > +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> > > +{
> > > +       struct debugfs_entries *vpg = data;
> > > +       struct dw_mipi_dsi *dsi;
> > > +       u32 mode_cfg;
> > > +
> > > +       if (!vpg)
> > > +               return -ENODEV;
> > > +
> > > +       dsi = vpg->dsi;
> > > +
> > > +       *vpg->reg = (bool)val;
> > > +
> > > +       mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> > > +
> > > +       if (*vpg->reg)
> > > +               mode_cfg |= vpg->mask;
> > > +       else
> > > +               mode_cfg &= ~vpg->mask;
> > > +
> > > +       dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> > > +{
> > > +       struct debugfs_entries *vpg = data;
> > > +
> > > +       if (!vpg)
> > > +               return -ENODEV;
> > > +
> > > +       *val = *vpg->reg;
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> > > +                        dw_mipi_dsi_debugfs_write, "%llu\n");
> > > +
> > > +static void debugfs_create_files(void *data)
> > > +{
> > > +       struct dw_mipi_dsi *dsi = data;
> > > +       struct debugfs_entries debugfs[] = {
> > > +               REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> > > +               REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL,
> dsi),
> > > +               REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> > > +       };
> > > +       int i;
> > > +
> > > +       dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> > > +       if (!dsi->debugfs_vpg)
> > > +               return;
> > > +
> > > +       memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> > > +
> > > +       for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> > > +               debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> > > +                                   dsi->debugfs, &dsi-
> >debugfs_vpg[i],
> > > +                                   &fops_x32);
> > > +}
> > > +
> > >  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> > >  {
> > >         dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> > > @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct
> dw_mipi_dsi *dsi)
> > >                 return;
> > >         }
> > >
> > > -       debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> > > -       debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> > > -                           &dsi->vpg_horizontal);
> > > +       debugfs_create_files(dsi);
> > >  }
> > >
> > >  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> > >  {
> > >         debugfs_remove_recursive(dsi->debugfs);
> > > +       kfree(dsi->debugfs_vpg);
> > >  }
> > >
> > >  #else
> > > --
> > > 2.7.4
> > >


Thanks,
Angelo
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-04-07 16:38       ` Angelo Ribeiro
  0 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-04-07 16:38 UTC (permalink / raw)
  To: Adrian Pop
  Cc: Jose Abreu, Joao Pinto, airlied, Gustavo Pimentel,
	philippe.cornu, dri-devel, linux-kernel, yannick.fertre,
	alexandre.torgue, mcoquelin.stm32, linux-stm32, linux-arm-kernel,
	benjamin.gaignard

Hi Adrian,

> -----Original Message-----
> From: Adrian Pop <pop.adrian61@gmail.com>
> Sent: Tuesday, April 7, 2020 7:58 AM
> To: Angelo Ribeiro <angelor@synopsys.com>
> Cc: yannick.fertre@st.com; philippe.cornu@st.com;
> benjamin.gaignard@st.com; airlied@linux.ie; Daniel Vetter
> <daniel@ffwll.ch>; mcoquelin.stm32@gmail.com; alexandre.torgue@st.com;
> dri-devel@lists.freedesktop.org; linux-stm32@st-md-mailman.stormreply.com;
> linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
> Gustavo Pimentel <gustavo@synopsys.com>; Joao Pinto <jpinto@synopsys.com>;
> Jose Abreu <joabreu@synopsys.com>
> Subject: Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config
> through debugfs
> 
> Tested-by: Adrian Pop <pop.adrian61@gmail.com>
> Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406.
> 
> On Mon, Apr 6, 2020 at 8:45 PM Adrian Pop <pop.adrian61@gmail.com> wrote:
> >
> > Hello Angelo,
> >
> > Tested OK on STM32F769i-DISCO, DSI v1.30, on next-20200406. I guess
> > there is no horizontal for BER.

Yes, there is no horizontal for BER.
Thank you for testing the patch.

> >
> > Regards,
> > Adrian
> >
> > On Mon, Apr 6, 2020 at 4:49 PM Angelo Ribeiro
> > <Angelo.Ribeiro@synopsys.com> wrote:
> > >
> > > Add support for the video pattern generator (VPG) BER pattern mode and
> > > configuration in runtime.
> > >
> > > This enables using the debugfs interface to manipulate the VPG after
> > > the pipeline is set.
> > > Also, enables the usage of the VPG BER pattern.
> > >
> > > Changes in v2:
> > >   - Added VID_MODE_VPG_MODE
> > >   - Solved incompatible return type on __get and __set
> > >
> > > Reported-by: kbuild test robot <lkp@intel.com>
> > > Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> > > Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> > > Cc: Joao Pinto <jpinto@synopsys.com>
> > > Cc: Jose Abreu <jose.abreu@synopsys.com>
> > > Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> > > ---
> > >  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98
> ++++++++++++++++++++++++---
> > >  1 file changed, 90 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > > index b18351b..9de3645 100644
> > > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > > @@ -91,6 +91,7 @@
> > >  #define VID_MODE_TYPE_BURST                    0x2
> > >  #define VID_MODE_TYPE_MASK                     0x3
> > >  #define VID_MODE_VPG_ENABLE            BIT(16)
> > > +#define VID_MODE_VPG_MODE              BIT(20)
> > >  #define VID_MODE_VPG_HORIZONTAL                BIT(24)
> > >
> > >  #define DSI_VID_PKT_SIZE               0x3c
> > > @@ -221,6 +222,21 @@
> > >  #define PHY_STATUS_TIMEOUT_US          10000
> > >  #define CMD_PKT_STATUS_TIMEOUT_US      20000
> > >
> > > +#ifdef CONFIG_DEBUG_FS
> > > +#define VPG_DEFS(name, dsi) \
> > > +       ((void __force *)&((*dsi).vpg_defs.name))
> > > +
> > > +#define REGISTER(name, mask, dsi) \
> > > +       { #name, VPG_DEFS(name, dsi), mask, dsi }
> > > +
> > > +struct debugfs_entries {
> > > +       const char                              *name;
> > > +       bool                                    *reg;
> > > +       u32                                     mask;
> > > +       struct dw_mipi_dsi                      *dsi;
> > > +};
> > > +#endif /* CONFIG_DEBUG_FS */
> > > +
> > >  struct dw_mipi_dsi {
> > >         struct drm_bridge bridge;
> > >         struct mipi_dsi_host dsi_host;
> > > @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> > >
> > >  #ifdef CONFIG_DEBUG_FS
> > >         struct dentry *debugfs;
> > > -
> > > -       bool vpg;
> > > -       bool vpg_horizontal;
> > > +       struct debugfs_entries *debugfs_vpg;
> > > +       struct {
> > > +               bool vpg;
> > > +               bool vpg_horizontal;
> > > +               bool vpg_ber_pattern;
> > > +       } vpg_defs;
> > >  #endif /* CONFIG_DEBUG_FS */
> > >
> > >         struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> > > @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct
> dw_mipi_dsi *dsi)
> > >                 val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> > >
> > >  #ifdef CONFIG_DEBUG_FS
> > > -       if (dsi->vpg) {
> > > +       if (dsi->vpg_defs.vpg) {
> > >                 val |= VID_MODE_VPG_ENABLE;
> > > -               val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL :
> 0;
> > > +               val |= dsi->vpg_defs.vpg_horizontal ?
> > > +                      VID_MODE_VPG_HORIZONTAL : 0;
> > > +               val |= dsi->vpg_defs.vpg_ber_pattern ?
> VID_MODE_VPG_MODE : 0;
> > >         }
> > >  #endif /* CONFIG_DEBUG_FS */
> > >
> > > @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs
> dw_mipi_dsi_bridge_funcs = {
> > >
> > >  #ifdef CONFIG_DEBUG_FS
> > >
> > > +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> > > +{
> > > +       struct debugfs_entries *vpg = data;
> > > +       struct dw_mipi_dsi *dsi;
> > > +       u32 mode_cfg;
> > > +
> > > +       if (!vpg)
> > > +               return -ENODEV;
> > > +
> > > +       dsi = vpg->dsi;
> > > +
> > > +       *vpg->reg = (bool)val;
> > > +
> > > +       mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> > > +
> > > +       if (*vpg->reg)
> > > +               mode_cfg |= vpg->mask;
> > > +       else
> > > +               mode_cfg &= ~vpg->mask;
> > > +
> > > +       dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> > > +{
> > > +       struct debugfs_entries *vpg = data;
> > > +
> > > +       if (!vpg)
> > > +               return -ENODEV;
> > > +
> > > +       *val = *vpg->reg;
> > > +
> > > +       return 0;
> > > +}
> > > +
> > > +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> > > +                        dw_mipi_dsi_debugfs_write, "%llu\n");
> > > +
> > > +static void debugfs_create_files(void *data)
> > > +{
> > > +       struct dw_mipi_dsi *dsi = data;
> > > +       struct debugfs_entries debugfs[] = {
> > > +               REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> > > +               REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL,
> dsi),
> > > +               REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> > > +       };
> > > +       int i;
> > > +
> > > +       dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> > > +       if (!dsi->debugfs_vpg)
> > > +               return;
> > > +
> > > +       memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> > > +
> > > +       for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> > > +               debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> > > +                                   dsi->debugfs, &dsi-
> >debugfs_vpg[i],
> > > +                                   &fops_x32);
> > > +}
> > > +
> > >  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> > >  {
> > >         dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> > > @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct
> dw_mipi_dsi *dsi)
> > >                 return;
> > >         }
> > >
> > > -       debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> > > -       debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> > > -                           &dsi->vpg_horizontal);
> > > +       debugfs_create_files(dsi);
> > >  }
> > >
> > >  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> > >  {
> > >         debugfs_remove_recursive(dsi->debugfs);
> > > +       kfree(dsi->debugfs_vpg);
> > >  }
> > >
> > >  #else
> > > --
> > > 2.7.4
> > >


Thanks,
Angelo
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
  2020-04-06 13:49 ` Angelo Ribeiro
  (?)
@ 2020-06-24 15:35   ` Yannick FERTRE
  -1 siblings, 0 replies; 30+ messages in thread
From: Yannick FERTRE @ 2020-06-24 15:35 UTC (permalink / raw)
  To: Angelo Ribeiro, Philippe CORNU, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Gustavo Pimentel, Joao Pinto, Jose Abreu

Hello Angelo,
thanks for the patch.
Tested-by: Yannick Fertre <yannick.fertre@st.com>
Tested OK on STM32MP1-DISCO, DSI v1.31

Best regards


On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
> Add support for the video pattern generator (VPG) BER pattern mode and
> configuration in runtime.
> 
> This enables using the debugfs interface to manipulate the VPG after
> the pipeline is set.
> Also, enables the usage of the VPG BER pattern.
> 
> Changes in v2:
>    - Added VID_MODE_VPG_MODE
>    - Solved incompatible return type on __get and __set
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> Cc: Joao Pinto <jpinto@synopsys.com>
> Cc: Jose Abreu <jose.abreu@synopsys.com>
> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> ---
>   drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>   1 file changed, 90 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index b18351b..9de3645 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -91,6 +91,7 @@
>   #define VID_MODE_TYPE_BURST			0x2
>   #define VID_MODE_TYPE_MASK			0x3
>   #define VID_MODE_VPG_ENABLE		BIT(16)
> +#define VID_MODE_VPG_MODE		BIT(20)
>   #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>   
>   #define DSI_VID_PKT_SIZE		0x3c
> @@ -221,6 +222,21 @@
>   #define PHY_STATUS_TIMEOUT_US		10000
>   #define CMD_PKT_STATUS_TIMEOUT_US	20000
>   
> +#ifdef CONFIG_DEBUG_FS
> +#define VPG_DEFS(name, dsi) \
> +	((void __force *)&((*dsi).vpg_defs.name))
> +
> +#define REGISTER(name, mask, dsi) \
> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> +
> +struct debugfs_entries {
> +	const char				*name;
> +	bool					*reg;
> +	u32					mask;
> +	struct dw_mipi_dsi			*dsi;
> +};
> +#endif /* CONFIG_DEBUG_FS */
> +
>   struct dw_mipi_dsi {
>   	struct drm_bridge bridge;
>   	struct mipi_dsi_host dsi_host;
> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>   
>   #ifdef CONFIG_DEBUG_FS
>   	struct dentry *debugfs;
> -
> -	bool vpg;
> -	bool vpg_horizontal;
> +	struct debugfs_entries *debugfs_vpg;
> +	struct {
> +		bool vpg;
> +		bool vpg_horizontal;
> +		bool vpg_ber_pattern;
> +	} vpg_defs;
>   #endif /* CONFIG_DEBUG_FS */
>   
>   	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>   		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>   
>   #ifdef CONFIG_DEBUG_FS
> -	if (dsi->vpg) {
> +	if (dsi->vpg_defs.vpg) {
>   		val |= VID_MODE_VPG_ENABLE;
> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_horizontal ?
> +		       VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>   	}
>   #endif /* CONFIG_DEBUG_FS */
>   
> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>   
>   #ifdef CONFIG_DEBUG_FS
>   
> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> +{
> +	struct debugfs_entries *vpg = data;
> +	struct dw_mipi_dsi *dsi;
> +	u32 mode_cfg;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	dsi = vpg->dsi;
> +
> +	*vpg->reg = (bool)val;
> +
> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> +
> +	if (*vpg->reg)
> +		mode_cfg |= vpg->mask;
> +	else
> +		mode_cfg &= ~vpg->mask;
> +
> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> +
> +	return 0;
> +}
> +
> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> +{
> +	struct debugfs_entries *vpg = data;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	*val = *vpg->reg;
> +
> +	return 0;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> +
> +static void debugfs_create_files(void *data)
> +{
> +	struct dw_mipi_dsi *dsi = data;
> +	struct debugfs_entries debugfs[] = {
> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> +	};
> +	int i;
> +
> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> +	if (!dsi->debugfs_vpg)
> +		return;
> +
> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> +
> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> +				    &fops_x32);
> +}
> +
>   static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>   {
>   	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>   		return;
>   	}
>   
> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> -			    &dsi->vpg_horizontal);
> +	debugfs_create_files(dsi);
>   }
>   
>   static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>   {
>   	debugfs_remove_recursive(dsi->debugfs);
> +	kfree(dsi->debugfs_vpg);
>   }
>   
>   #else
> 

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-06-24 15:35   ` Yannick FERTRE
  0 siblings, 0 replies; 30+ messages in thread
From: Yannick FERTRE @ 2020-06-24 15:35 UTC (permalink / raw)
  To: Angelo Ribeiro, Philippe CORNU, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hello Angelo,
thanks for the patch.
Tested-by: Yannick Fertre <yannick.fertre@st.com>
Tested OK on STM32MP1-DISCO, DSI v1.31

Best regards


On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
> Add support for the video pattern generator (VPG) BER pattern mode and
> configuration in runtime.
> 
> This enables using the debugfs interface to manipulate the VPG after
> the pipeline is set.
> Also, enables the usage of the VPG BER pattern.
> 
> Changes in v2:
>    - Added VID_MODE_VPG_MODE
>    - Solved incompatible return type on __get and __set
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> Cc: Joao Pinto <jpinto@synopsys.com>
> Cc: Jose Abreu <jose.abreu@synopsys.com>
> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> ---
>   drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>   1 file changed, 90 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index b18351b..9de3645 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -91,6 +91,7 @@
>   #define VID_MODE_TYPE_BURST			0x2
>   #define VID_MODE_TYPE_MASK			0x3
>   #define VID_MODE_VPG_ENABLE		BIT(16)
> +#define VID_MODE_VPG_MODE		BIT(20)
>   #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>   
>   #define DSI_VID_PKT_SIZE		0x3c
> @@ -221,6 +222,21 @@
>   #define PHY_STATUS_TIMEOUT_US		10000
>   #define CMD_PKT_STATUS_TIMEOUT_US	20000
>   
> +#ifdef CONFIG_DEBUG_FS
> +#define VPG_DEFS(name, dsi) \
> +	((void __force *)&((*dsi).vpg_defs.name))
> +
> +#define REGISTER(name, mask, dsi) \
> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> +
> +struct debugfs_entries {
> +	const char				*name;
> +	bool					*reg;
> +	u32					mask;
> +	struct dw_mipi_dsi			*dsi;
> +};
> +#endif /* CONFIG_DEBUG_FS */
> +
>   struct dw_mipi_dsi {
>   	struct drm_bridge bridge;
>   	struct mipi_dsi_host dsi_host;
> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>   
>   #ifdef CONFIG_DEBUG_FS
>   	struct dentry *debugfs;
> -
> -	bool vpg;
> -	bool vpg_horizontal;
> +	struct debugfs_entries *debugfs_vpg;
> +	struct {
> +		bool vpg;
> +		bool vpg_horizontal;
> +		bool vpg_ber_pattern;
> +	} vpg_defs;
>   #endif /* CONFIG_DEBUG_FS */
>   
>   	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>   		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>   
>   #ifdef CONFIG_DEBUG_FS
> -	if (dsi->vpg) {
> +	if (dsi->vpg_defs.vpg) {
>   		val |= VID_MODE_VPG_ENABLE;
> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_horizontal ?
> +		       VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>   	}
>   #endif /* CONFIG_DEBUG_FS */
>   
> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>   
>   #ifdef CONFIG_DEBUG_FS
>   
> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> +{
> +	struct debugfs_entries *vpg = data;
> +	struct dw_mipi_dsi *dsi;
> +	u32 mode_cfg;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	dsi = vpg->dsi;
> +
> +	*vpg->reg = (bool)val;
> +
> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> +
> +	if (*vpg->reg)
> +		mode_cfg |= vpg->mask;
> +	else
> +		mode_cfg &= ~vpg->mask;
> +
> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> +
> +	return 0;
> +}
> +
> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> +{
> +	struct debugfs_entries *vpg = data;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	*val = *vpg->reg;
> +
> +	return 0;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> +
> +static void debugfs_create_files(void *data)
> +{
> +	struct dw_mipi_dsi *dsi = data;
> +	struct debugfs_entries debugfs[] = {
> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> +	};
> +	int i;
> +
> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> +	if (!dsi->debugfs_vpg)
> +		return;
> +
> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> +
> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> +				    &fops_x32);
> +}
> +
>   static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>   {
>   	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>   		return;
>   	}
>   
> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> -			    &dsi->vpg_horizontal);
> +	debugfs_create_files(dsi);
>   }
>   
>   static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>   {
>   	debugfs_remove_recursive(dsi->debugfs);
> +	kfree(dsi->debugfs_vpg);
>   }
>   
>   #else
> 
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-06-24 15:35   ` Yannick FERTRE
  0 siblings, 0 replies; 30+ messages in thread
From: Yannick FERTRE @ 2020-06-24 15:35 UTC (permalink / raw)
  To: Angelo Ribeiro, Philippe CORNU, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hello Angelo,
thanks for the patch.
Tested-by: Yannick Fertre <yannick.fertre@st.com>
Tested OK on STM32MP1-DISCO, DSI v1.31

Best regards


On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
> Add support for the video pattern generator (VPG) BER pattern mode and
> configuration in runtime.
> 
> This enables using the debugfs interface to manipulate the VPG after
> the pipeline is set.
> Also, enables the usage of the VPG BER pattern.
> 
> Changes in v2:
>    - Added VID_MODE_VPG_MODE
>    - Solved incompatible return type on __get and __set
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> Cc: Joao Pinto <jpinto@synopsys.com>
> Cc: Jose Abreu <jose.abreu@synopsys.com>
> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> ---
>   drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>   1 file changed, 90 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index b18351b..9de3645 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -91,6 +91,7 @@
>   #define VID_MODE_TYPE_BURST			0x2
>   #define VID_MODE_TYPE_MASK			0x3
>   #define VID_MODE_VPG_ENABLE		BIT(16)
> +#define VID_MODE_VPG_MODE		BIT(20)
>   #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>   
>   #define DSI_VID_PKT_SIZE		0x3c
> @@ -221,6 +222,21 @@
>   #define PHY_STATUS_TIMEOUT_US		10000
>   #define CMD_PKT_STATUS_TIMEOUT_US	20000
>   
> +#ifdef CONFIG_DEBUG_FS
> +#define VPG_DEFS(name, dsi) \
> +	((void __force *)&((*dsi).vpg_defs.name))
> +
> +#define REGISTER(name, mask, dsi) \
> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> +
> +struct debugfs_entries {
> +	const char				*name;
> +	bool					*reg;
> +	u32					mask;
> +	struct dw_mipi_dsi			*dsi;
> +};
> +#endif /* CONFIG_DEBUG_FS */
> +
>   struct dw_mipi_dsi {
>   	struct drm_bridge bridge;
>   	struct mipi_dsi_host dsi_host;
> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>   
>   #ifdef CONFIG_DEBUG_FS
>   	struct dentry *debugfs;
> -
> -	bool vpg;
> -	bool vpg_horizontal;
> +	struct debugfs_entries *debugfs_vpg;
> +	struct {
> +		bool vpg;
> +		bool vpg_horizontal;
> +		bool vpg_ber_pattern;
> +	} vpg_defs;
>   #endif /* CONFIG_DEBUG_FS */
>   
>   	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>   		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>   
>   #ifdef CONFIG_DEBUG_FS
> -	if (dsi->vpg) {
> +	if (dsi->vpg_defs.vpg) {
>   		val |= VID_MODE_VPG_ENABLE;
> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_horizontal ?
> +		       VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>   	}
>   #endif /* CONFIG_DEBUG_FS */
>   
> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>   
>   #ifdef CONFIG_DEBUG_FS
>   
> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> +{
> +	struct debugfs_entries *vpg = data;
> +	struct dw_mipi_dsi *dsi;
> +	u32 mode_cfg;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	dsi = vpg->dsi;
> +
> +	*vpg->reg = (bool)val;
> +
> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> +
> +	if (*vpg->reg)
> +		mode_cfg |= vpg->mask;
> +	else
> +		mode_cfg &= ~vpg->mask;
> +
> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> +
> +	return 0;
> +}
> +
> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> +{
> +	struct debugfs_entries *vpg = data;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	*val = *vpg->reg;
> +
> +	return 0;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> +
> +static void debugfs_create_files(void *data)
> +{
> +	struct dw_mipi_dsi *dsi = data;
> +	struct debugfs_entries debugfs[] = {
> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> +	};
> +	int i;
> +
> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> +	if (!dsi->debugfs_vpg)
> +		return;
> +
> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> +
> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> +				    &fops_x32);
> +}
> +
>   static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>   {
>   	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>   		return;
>   	}
>   
> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> -			    &dsi->vpg_horizontal);
> +	debugfs_create_files(dsi);
>   }
>   
>   static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>   {
>   	debugfs_remove_recursive(dsi->debugfs);
> +	kfree(dsi->debugfs_vpg);
>   }
>   
>   #else
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
  2020-06-24 15:35   ` Yannick FERTRE
  (?)
@ 2020-07-08 17:08     ` Angelo Ribeiro
  -1 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-07-08 17:08 UTC (permalink / raw)
  To: Yannick FERTRE, Philippe CORNU, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi,

Is this patch good to go? 
@daniel@ffwll.ch, @Philippe CORNU

Was already tested by @Yannick FERTRE 
and @Adrian Pop
on https://lkml.org/lkml/2020/4/6/691 .

Thanks,
Angelo

From: Yannick 
FERTRE <yannick.fertre@st.com>
Date: Wed, Jun 24, 2020 at 16:35:04

> Hello Angelo,
> thanks for the patch.
> Tested-by: Yannick Fertre <yannick.fertre@st.com>
> Tested OK on STM32MP1-DISCO, DSI v1.31
> 
> Best regards
> 
> 
> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
> > Add support for the video pattern generator (VPG) BER pattern mode and
> > configuration in runtime.
> > 
> > This enables using the debugfs interface to manipulate the VPG after
> > the pipeline is set.
> > Also, enables the usage of the VPG BER pattern.
> > 
> > Changes in v2:
> >    - Added VID_MODE_VPG_MODE
> >    - Solved incompatible return type on __get and __set
> > 
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> > Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> > Cc: Joao Pinto <jpinto@synopsys.com>
> > Cc: Jose Abreu <jose.abreu@synopsys.com>
> > Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> > ---
> >   drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
> >   1 file changed, 90 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > index b18351b..9de3645 100644
> > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > @@ -91,6 +91,7 @@
> >   #define VID_MODE_TYPE_BURST			0x2
> >   #define VID_MODE_TYPE_MASK			0x3
> >   #define VID_MODE_VPG_ENABLE		BIT(16)
> > +#define VID_MODE_VPG_MODE		BIT(20)
> >   #define VID_MODE_VPG_HORIZONTAL		BIT(24)
> >   
> >   #define DSI_VID_PKT_SIZE		0x3c
> > @@ -221,6 +222,21 @@
> >   #define PHY_STATUS_TIMEOUT_US		10000
> >   #define CMD_PKT_STATUS_TIMEOUT_US	20000
> >   
> > +#ifdef CONFIG_DEBUG_FS
> > +#define VPG_DEFS(name, dsi) \
> > +	((void __force *)&((*dsi).vpg_defs.name))
> > +
> > +#define REGISTER(name, mask, dsi) \
> > +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> > +
> > +struct debugfs_entries {
> > +	const char				*name;
> > +	bool					*reg;
> > +	u32					mask;
> > +	struct dw_mipi_dsi			*dsi;
> > +};
> > +#endif /* CONFIG_DEBUG_FS */
> > +
> >   struct dw_mipi_dsi {
> >   	struct drm_bridge bridge;
> >   	struct mipi_dsi_host dsi_host;
> > @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> >   
> >   #ifdef CONFIG_DEBUG_FS
> >   	struct dentry *debugfs;
> > -
> > -	bool vpg;
> > -	bool vpg_horizontal;
> > +	struct debugfs_entries *debugfs_vpg;
> > +	struct {
> > +		bool vpg;
> > +		bool vpg_horizontal;
> > +		bool vpg_ber_pattern;
> > +	} vpg_defs;
> >   #endif /* CONFIG_DEBUG_FS */
> >   
> >   	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> > @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
> >   		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> >   
> >   #ifdef CONFIG_DEBUG_FS
> > -	if (dsi->vpg) {
> > +	if (dsi->vpg_defs.vpg) {
> >   		val |= VID_MODE_VPG_ENABLE;
> > -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> > +		val |= dsi->vpg_defs.vpg_horizontal ?
> > +		       VID_MODE_VPG_HORIZONTAL : 0;
> > +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> >   	}
> >   #endif /* CONFIG_DEBUG_FS */
> >   
> > @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
> >   
> >   #ifdef CONFIG_DEBUG_FS
> >   
> > +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> > +{
> > +	struct debugfs_entries *vpg = data;
> > +	struct dw_mipi_dsi *dsi;
> > +	u32 mode_cfg;
> > +
> > +	if (!vpg)
> > +		return -ENODEV;
> > +
> > +	dsi = vpg->dsi;
> > +
> > +	*vpg->reg = (bool)val;
> > +
> > +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> > +
> > +	if (*vpg->reg)
> > +		mode_cfg |= vpg->mask;
> > +	else
> > +		mode_cfg &= ~vpg->mask;
> > +
> > +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> > +
> > +	return 0;
> > +}
> > +
> > +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> > +{
> > +	struct debugfs_entries *vpg = data;
> > +
> > +	if (!vpg)
> > +		return -ENODEV;
> > +
> > +	*val = *vpg->reg;
> > +
> > +	return 0;
> > +}
> > +
> > +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> > +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> > +
> > +static void debugfs_create_files(void *data)
> > +{
> > +	struct dw_mipi_dsi *dsi = data;
> > +	struct debugfs_entries debugfs[] = {
> > +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> > +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> > +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> > +	};
> > +	int i;
> > +
> > +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> > +	if (!dsi->debugfs_vpg)
> > +		return;
> > +
> > +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> > +
> > +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> > +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> > +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> > +				    &fops_x32);
> > +}
> > +
> >   static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >   {
> >   	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> > @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >   		return;
> >   	}
> >   
> > -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> > -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> > -			    &dsi->vpg_horizontal);
> > +	debugfs_create_files(dsi);
> >   }
> >   
> >   static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> >   {
> >   	debugfs_remove_recursive(dsi->debugfs);
> > +	kfree(dsi->debugfs_vpg);
> >   }
> >   
> >   #else
> > 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$ 



^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-07-08 17:08     ` Angelo Ribeiro
  0 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-07-08 17:08 UTC (permalink / raw)
  To: Yannick FERTRE, Philippe CORNU, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi,

Is this patch good to go? 
@daniel@ffwll.ch, @Philippe CORNU

Was already tested by @Yannick FERTRE 
and @Adrian Pop
on https://lkml.org/lkml/2020/4/6/691 .

Thanks,
Angelo

From: Yannick 
FERTRE <yannick.fertre@st.com>
Date: Wed, Jun 24, 2020 at 16:35:04

> Hello Angelo,
> thanks for the patch.
> Tested-by: Yannick Fertre <yannick.fertre@st.com>
> Tested OK on STM32MP1-DISCO, DSI v1.31
> 
> Best regards
> 
> 
> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
> > Add support for the video pattern generator (VPG) BER pattern mode and
> > configuration in runtime.
> > 
> > This enables using the debugfs interface to manipulate the VPG after
> > the pipeline is set.
> > Also, enables the usage of the VPG BER pattern.
> > 
> > Changes in v2:
> >    - Added VID_MODE_VPG_MODE
> >    - Solved incompatible return type on __get and __set
> > 
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> > Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> > Cc: Joao Pinto <jpinto@synopsys.com>
> > Cc: Jose Abreu <jose.abreu@synopsys.com>
> > Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> > ---
> >   drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
> >   1 file changed, 90 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > index b18351b..9de3645 100644
> > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > @@ -91,6 +91,7 @@
> >   #define VID_MODE_TYPE_BURST			0x2
> >   #define VID_MODE_TYPE_MASK			0x3
> >   #define VID_MODE_VPG_ENABLE		BIT(16)
> > +#define VID_MODE_VPG_MODE		BIT(20)
> >   #define VID_MODE_VPG_HORIZONTAL		BIT(24)
> >   
> >   #define DSI_VID_PKT_SIZE		0x3c
> > @@ -221,6 +222,21 @@
> >   #define PHY_STATUS_TIMEOUT_US		10000
> >   #define CMD_PKT_STATUS_TIMEOUT_US	20000
> >   
> > +#ifdef CONFIG_DEBUG_FS
> > +#define VPG_DEFS(name, dsi) \
> > +	((void __force *)&((*dsi).vpg_defs.name))
> > +
> > +#define REGISTER(name, mask, dsi) \
> > +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> > +
> > +struct debugfs_entries {
> > +	const char				*name;
> > +	bool					*reg;
> > +	u32					mask;
> > +	struct dw_mipi_dsi			*dsi;
> > +};
> > +#endif /* CONFIG_DEBUG_FS */
> > +
> >   struct dw_mipi_dsi {
> >   	struct drm_bridge bridge;
> >   	struct mipi_dsi_host dsi_host;
> > @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> >   
> >   #ifdef CONFIG_DEBUG_FS
> >   	struct dentry *debugfs;
> > -
> > -	bool vpg;
> > -	bool vpg_horizontal;
> > +	struct debugfs_entries *debugfs_vpg;
> > +	struct {
> > +		bool vpg;
> > +		bool vpg_horizontal;
> > +		bool vpg_ber_pattern;
> > +	} vpg_defs;
> >   #endif /* CONFIG_DEBUG_FS */
> >   
> >   	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> > @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
> >   		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> >   
> >   #ifdef CONFIG_DEBUG_FS
> > -	if (dsi->vpg) {
> > +	if (dsi->vpg_defs.vpg) {
> >   		val |= VID_MODE_VPG_ENABLE;
> > -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> > +		val |= dsi->vpg_defs.vpg_horizontal ?
> > +		       VID_MODE_VPG_HORIZONTAL : 0;
> > +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> >   	}
> >   #endif /* CONFIG_DEBUG_FS */
> >   
> > @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
> >   
> >   #ifdef CONFIG_DEBUG_FS
> >   
> > +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> > +{
> > +	struct debugfs_entries *vpg = data;
> > +	struct dw_mipi_dsi *dsi;
> > +	u32 mode_cfg;
> > +
> > +	if (!vpg)
> > +		return -ENODEV;
> > +
> > +	dsi = vpg->dsi;
> > +
> > +	*vpg->reg = (bool)val;
> > +
> > +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> > +
> > +	if (*vpg->reg)
> > +		mode_cfg |= vpg->mask;
> > +	else
> > +		mode_cfg &= ~vpg->mask;
> > +
> > +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> > +
> > +	return 0;
> > +}
> > +
> > +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> > +{
> > +	struct debugfs_entries *vpg = data;
> > +
> > +	if (!vpg)
> > +		return -ENODEV;
> > +
> > +	*val = *vpg->reg;
> > +
> > +	return 0;
> > +}
> > +
> > +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> > +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> > +
> > +static void debugfs_create_files(void *data)
> > +{
> > +	struct dw_mipi_dsi *dsi = data;
> > +	struct debugfs_entries debugfs[] = {
> > +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> > +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> > +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> > +	};
> > +	int i;
> > +
> > +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> > +	if (!dsi->debugfs_vpg)
> > +		return;
> > +
> > +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> > +
> > +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> > +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> > +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> > +				    &fops_x32);
> > +}
> > +
> >   static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >   {
> >   	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> > @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >   		return;
> >   	}
> >   
> > -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> > -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> > -			    &dsi->vpg_horizontal);
> > +	debugfs_create_files(dsi);
> >   }
> >   
> >   static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> >   {
> >   	debugfs_remove_recursive(dsi->debugfs);
> > +	kfree(dsi->debugfs_vpg);
> >   }
> >   
> >   #else
> > 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$ 



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-07-08 17:08     ` Angelo Ribeiro
  0 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-07-08 17:08 UTC (permalink / raw)
  To: Yannick FERTRE, Philippe CORNU, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi,

Is this patch good to go? 
@daniel@ffwll.ch, @Philippe CORNU

Was already tested by @Yannick FERTRE 
and @Adrian Pop
on https://lkml.org/lkml/2020/4/6/691 .

Thanks,
Angelo

From: Yannick 
FERTRE <yannick.fertre@st.com>
Date: Wed, Jun 24, 2020 at 16:35:04

> Hello Angelo,
> thanks for the patch.
> Tested-by: Yannick Fertre <yannick.fertre@st.com>
> Tested OK on STM32MP1-DISCO, DSI v1.31
> 
> Best regards
> 
> 
> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
> > Add support for the video pattern generator (VPG) BER pattern mode and
> > configuration in runtime.
> > 
> > This enables using the debugfs interface to manipulate the VPG after
> > the pipeline is set.
> > Also, enables the usage of the VPG BER pattern.
> > 
> > Changes in v2:
> >    - Added VID_MODE_VPG_MODE
> >    - Solved incompatible return type on __get and __set
> > 
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> > Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> > Cc: Joao Pinto <jpinto@synopsys.com>
> > Cc: Jose Abreu <jose.abreu@synopsys.com>
> > Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> > ---
> >   drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
> >   1 file changed, 90 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > index b18351b..9de3645 100644
> > --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> > @@ -91,6 +91,7 @@
> >   #define VID_MODE_TYPE_BURST			0x2
> >   #define VID_MODE_TYPE_MASK			0x3
> >   #define VID_MODE_VPG_ENABLE		BIT(16)
> > +#define VID_MODE_VPG_MODE		BIT(20)
> >   #define VID_MODE_VPG_HORIZONTAL		BIT(24)
> >   
> >   #define DSI_VID_PKT_SIZE		0x3c
> > @@ -221,6 +222,21 @@
> >   #define PHY_STATUS_TIMEOUT_US		10000
> >   #define CMD_PKT_STATUS_TIMEOUT_US	20000
> >   
> > +#ifdef CONFIG_DEBUG_FS
> > +#define VPG_DEFS(name, dsi) \
> > +	((void __force *)&((*dsi).vpg_defs.name))
> > +
> > +#define REGISTER(name, mask, dsi) \
> > +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> > +
> > +struct debugfs_entries {
> > +	const char				*name;
> > +	bool					*reg;
> > +	u32					mask;
> > +	struct dw_mipi_dsi			*dsi;
> > +};
> > +#endif /* CONFIG_DEBUG_FS */
> > +
> >   struct dw_mipi_dsi {
> >   	struct drm_bridge bridge;
> >   	struct mipi_dsi_host dsi_host;
> > @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> >   
> >   #ifdef CONFIG_DEBUG_FS
> >   	struct dentry *debugfs;
> > -
> > -	bool vpg;
> > -	bool vpg_horizontal;
> > +	struct debugfs_entries *debugfs_vpg;
> > +	struct {
> > +		bool vpg;
> > +		bool vpg_horizontal;
> > +		bool vpg_ber_pattern;
> > +	} vpg_defs;
> >   #endif /* CONFIG_DEBUG_FS */
> >   
> >   	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> > @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
> >   		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> >   
> >   #ifdef CONFIG_DEBUG_FS
> > -	if (dsi->vpg) {
> > +	if (dsi->vpg_defs.vpg) {
> >   		val |= VID_MODE_VPG_ENABLE;
> > -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> > +		val |= dsi->vpg_defs.vpg_horizontal ?
> > +		       VID_MODE_VPG_HORIZONTAL : 0;
> > +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> >   	}
> >   #endif /* CONFIG_DEBUG_FS */
> >   
> > @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
> >   
> >   #ifdef CONFIG_DEBUG_FS
> >   
> > +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> > +{
> > +	struct debugfs_entries *vpg = data;
> > +	struct dw_mipi_dsi *dsi;
> > +	u32 mode_cfg;
> > +
> > +	if (!vpg)
> > +		return -ENODEV;
> > +
> > +	dsi = vpg->dsi;
> > +
> > +	*vpg->reg = (bool)val;
> > +
> > +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> > +
> > +	if (*vpg->reg)
> > +		mode_cfg |= vpg->mask;
> > +	else
> > +		mode_cfg &= ~vpg->mask;
> > +
> > +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> > +
> > +	return 0;
> > +}
> > +
> > +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> > +{
> > +	struct debugfs_entries *vpg = data;
> > +
> > +	if (!vpg)
> > +		return -ENODEV;
> > +
> > +	*val = *vpg->reg;
> > +
> > +	return 0;
> > +}
> > +
> > +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> > +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> > +
> > +static void debugfs_create_files(void *data)
> > +{
> > +	struct dw_mipi_dsi *dsi = data;
> > +	struct debugfs_entries debugfs[] = {
> > +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> > +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> > +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> > +	};
> > +	int i;
> > +
> > +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> > +	if (!dsi->debugfs_vpg)
> > +		return;
> > +
> > +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> > +
> > +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> > +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> > +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> > +				    &fops_x32);
> > +}
> > +
> >   static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >   {
> >   	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> > @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >   		return;
> >   	}
> >   
> > -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> > -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> > -			    &dsi->vpg_horizontal);
> > +	debugfs_create_files(dsi);
> >   }
> >   
> >   static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> >   {
> >   	debugfs_remove_recursive(dsi->debugfs);
> > +	kfree(dsi->debugfs_vpg);
> >   }
> >   
> >   #else
> > 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$ 


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
  2020-07-08 17:08     ` Angelo Ribeiro
  (?)
@ 2020-07-08 20:29       ` Neil Armstrong
  -1 siblings, 0 replies; 30+ messages in thread
From: Neil Armstrong @ 2020-07-08 20:29 UTC (permalink / raw)
  To: Angelo Ribeiro, Yannick FERTRE, Philippe CORNU,
	Benjamin GAIGNARD, airlied, daniel, mcoquelin.stm32,
	Alexandre TORGUE, dri-devel, linux-stm32, linux-arm-kernel,
	linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi,

Le 08/07/2020 à 19:08, Angelo Ribeiro a écrit :
> Hi,
> 
> Is this patch good to go? 
> @daniel@ffwll.ch, @Philippe CORNU
> 
> Was already tested by @Yannick FERTRE 
> and @Adrian Pop
> on https://lkml.org/lkml/2020/4/6/691 .

It would be great to have a review or an ack before applying.

Neil

> 
> Thanks,
> Angelo
> 
> From: Yannick 
> FERTRE <yannick.fertre@st.com>
> Date: Wed, Jun 24, 2020 at 16:35:04
> 
>> Hello Angelo,
>> thanks for the patch.
>> Tested-by: Yannick Fertre <yannick.fertre@st.com>
>> Tested OK on STM32MP1-DISCO, DSI v1.31
>>
>> Best regards
>>
>>
>> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
>>> Add support for the video pattern generator (VPG) BER pattern mode and
>>> configuration in runtime.
>>>
>>> This enables using the debugfs interface to manipulate the VPG after
>>> the pipeline is set.
>>> Also, enables the usage of the VPG BER pattern.
>>>
>>> Changes in v2:
>>>    - Added VID_MODE_VPG_MODE
>>>    - Solved incompatible return type on __get and __set
>>>
>>> Reported-by: kbuild test robot <lkp@intel.com>
>>> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
>>> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
>>> Cc: Joao Pinto <jpinto@synopsys.com>
>>> Cc: Jose Abreu <jose.abreu@synopsys.com>
>>> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
>>> ---
>>>   drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>>>   1 file changed, 90 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> index b18351b..9de3645 100644
>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> @@ -91,6 +91,7 @@
>>>   #define VID_MODE_TYPE_BURST			0x2
>>>   #define VID_MODE_TYPE_MASK			0x3
>>>   #define VID_MODE_VPG_ENABLE		BIT(16)
>>> +#define VID_MODE_VPG_MODE		BIT(20)
>>>   #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>>>   
>>>   #define DSI_VID_PKT_SIZE		0x3c
>>> @@ -221,6 +222,21 @@
>>>   #define PHY_STATUS_TIMEOUT_US		10000
>>>   #define CMD_PKT_STATUS_TIMEOUT_US	20000
>>>   
>>> +#ifdef CONFIG_DEBUG_FS
>>> +#define VPG_DEFS(name, dsi) \
>>> +	((void __force *)&((*dsi).vpg_defs.name))
>>> +
>>> +#define REGISTER(name, mask, dsi) \
>>> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
>>> +
>>> +struct debugfs_entries {
>>> +	const char				*name;
>>> +	bool					*reg;
>>> +	u32					mask;
>>> +	struct dw_mipi_dsi			*dsi;
>>> +};
>>> +#endif /* CONFIG_DEBUG_FS */
>>> +
>>>   struct dw_mipi_dsi {
>>>   	struct drm_bridge bridge;
>>>   	struct mipi_dsi_host dsi_host;
>>> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>>>   
>>>   #ifdef CONFIG_DEBUG_FS
>>>   	struct dentry *debugfs;
>>> -
>>> -	bool vpg;
>>> -	bool vpg_horizontal;
>>> +	struct debugfs_entries *debugfs_vpg;
>>> +	struct {
>>> +		bool vpg;
>>> +		bool vpg_horizontal;
>>> +		bool vpg_ber_pattern;
>>> +	} vpg_defs;
>>>   #endif /* CONFIG_DEBUG_FS */
>>>   
>>>   	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
>>> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>>>   		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>>>   
>>>   #ifdef CONFIG_DEBUG_FS
>>> -	if (dsi->vpg) {
>>> +	if (dsi->vpg_defs.vpg) {
>>>   		val |= VID_MODE_VPG_ENABLE;
>>> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_horizontal ?
>>> +		       VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>>>   	}
>>>   #endif /* CONFIG_DEBUG_FS */
>>>   
>>> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>>>   
>>>   #ifdef CONFIG_DEBUG_FS
>>>   
>>> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +	struct dw_mipi_dsi *dsi;
>>> +	u32 mode_cfg;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	dsi = vpg->dsi;
>>> +
>>> +	*vpg->reg = (bool)val;
>>> +
>>> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
>>> +
>>> +	if (*vpg->reg)
>>> +		mode_cfg |= vpg->mask;
>>> +	else
>>> +		mode_cfg &= ~vpg->mask;
>>> +
>>> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	*val = *vpg->reg;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
>>> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
>>> +
>>> +static void debugfs_create_files(void *data)
>>> +{
>>> +	struct dw_mipi_dsi *dsi = data;
>>> +	struct debugfs_entries debugfs[] = {
>>> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
>>> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
>>> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
>>> +	};
>>> +	int i;
>>> +
>>> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
>>> +	if (!dsi->debugfs_vpg)
>>> +		return;
>>> +
>>> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
>>> +
>>> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
>>> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
>>> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
>>> +				    &fops_x32);
>>> +}
>>> +
>>>   static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>   {
>>>   	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
>>> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>   		return;
>>>   	}
>>>   
>>> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
>>> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
>>> -			    &dsi->vpg_horizontal);
>>> +	debugfs_create_files(dsi);
>>>   }
>>>   
>>>   static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>>>   {
>>>   	debugfs_remove_recursive(dsi->debugfs);
>>> +	kfree(dsi->debugfs_vpg);
>>>   }
>>>   
>>>   #else
>>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$ 
> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-07-08 20:29       ` Neil Armstrong
  0 siblings, 0 replies; 30+ messages in thread
From: Neil Armstrong @ 2020-07-08 20:29 UTC (permalink / raw)
  To: Angelo Ribeiro, Yannick FERTRE, Philippe CORNU,
	Benjamin GAIGNARD, airlied, daniel, mcoquelin.stm32,
	Alexandre TORGUE, dri-devel, linux-stm32, linux-arm-kernel,
	linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi,

Le 08/07/2020 à 19:08, Angelo Ribeiro a écrit :
> Hi,
> 
> Is this patch good to go? 
> @daniel@ffwll.ch, @Philippe CORNU
> 
> Was already tested by @Yannick FERTRE 
> and @Adrian Pop
> on https://lkml.org/lkml/2020/4/6/691 .

It would be great to have a review or an ack before applying.

Neil

> 
> Thanks,
> Angelo
> 
> From: Yannick 
> FERTRE <yannick.fertre@st.com>
> Date: Wed, Jun 24, 2020 at 16:35:04
> 
>> Hello Angelo,
>> thanks for the patch.
>> Tested-by: Yannick Fertre <yannick.fertre@st.com>
>> Tested OK on STM32MP1-DISCO, DSI v1.31
>>
>> Best regards
>>
>>
>> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
>>> Add support for the video pattern generator (VPG) BER pattern mode and
>>> configuration in runtime.
>>>
>>> This enables using the debugfs interface to manipulate the VPG after
>>> the pipeline is set.
>>> Also, enables the usage of the VPG BER pattern.
>>>
>>> Changes in v2:
>>>    - Added VID_MODE_VPG_MODE
>>>    - Solved incompatible return type on __get and __set
>>>
>>> Reported-by: kbuild test robot <lkp@intel.com>
>>> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
>>> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
>>> Cc: Joao Pinto <jpinto@synopsys.com>
>>> Cc: Jose Abreu <jose.abreu@synopsys.com>
>>> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
>>> ---
>>>   drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>>>   1 file changed, 90 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> index b18351b..9de3645 100644
>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> @@ -91,6 +91,7 @@
>>>   #define VID_MODE_TYPE_BURST			0x2
>>>   #define VID_MODE_TYPE_MASK			0x3
>>>   #define VID_MODE_VPG_ENABLE		BIT(16)
>>> +#define VID_MODE_VPG_MODE		BIT(20)
>>>   #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>>>   
>>>   #define DSI_VID_PKT_SIZE		0x3c
>>> @@ -221,6 +222,21 @@
>>>   #define PHY_STATUS_TIMEOUT_US		10000
>>>   #define CMD_PKT_STATUS_TIMEOUT_US	20000
>>>   
>>> +#ifdef CONFIG_DEBUG_FS
>>> +#define VPG_DEFS(name, dsi) \
>>> +	((void __force *)&((*dsi).vpg_defs.name))
>>> +
>>> +#define REGISTER(name, mask, dsi) \
>>> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
>>> +
>>> +struct debugfs_entries {
>>> +	const char				*name;
>>> +	bool					*reg;
>>> +	u32					mask;
>>> +	struct dw_mipi_dsi			*dsi;
>>> +};
>>> +#endif /* CONFIG_DEBUG_FS */
>>> +
>>>   struct dw_mipi_dsi {
>>>   	struct drm_bridge bridge;
>>>   	struct mipi_dsi_host dsi_host;
>>> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>>>   
>>>   #ifdef CONFIG_DEBUG_FS
>>>   	struct dentry *debugfs;
>>> -
>>> -	bool vpg;
>>> -	bool vpg_horizontal;
>>> +	struct debugfs_entries *debugfs_vpg;
>>> +	struct {
>>> +		bool vpg;
>>> +		bool vpg_horizontal;
>>> +		bool vpg_ber_pattern;
>>> +	} vpg_defs;
>>>   #endif /* CONFIG_DEBUG_FS */
>>>   
>>>   	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
>>> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>>>   		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>>>   
>>>   #ifdef CONFIG_DEBUG_FS
>>> -	if (dsi->vpg) {
>>> +	if (dsi->vpg_defs.vpg) {
>>>   		val |= VID_MODE_VPG_ENABLE;
>>> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_horizontal ?
>>> +		       VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>>>   	}
>>>   #endif /* CONFIG_DEBUG_FS */
>>>   
>>> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>>>   
>>>   #ifdef CONFIG_DEBUG_FS
>>>   
>>> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +	struct dw_mipi_dsi *dsi;
>>> +	u32 mode_cfg;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	dsi = vpg->dsi;
>>> +
>>> +	*vpg->reg = (bool)val;
>>> +
>>> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
>>> +
>>> +	if (*vpg->reg)
>>> +		mode_cfg |= vpg->mask;
>>> +	else
>>> +		mode_cfg &= ~vpg->mask;
>>> +
>>> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	*val = *vpg->reg;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
>>> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
>>> +
>>> +static void debugfs_create_files(void *data)
>>> +{
>>> +	struct dw_mipi_dsi *dsi = data;
>>> +	struct debugfs_entries debugfs[] = {
>>> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
>>> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
>>> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
>>> +	};
>>> +	int i;
>>> +
>>> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
>>> +	if (!dsi->debugfs_vpg)
>>> +		return;
>>> +
>>> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
>>> +
>>> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
>>> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
>>> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
>>> +				    &fops_x32);
>>> +}
>>> +
>>>   static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>   {
>>>   	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
>>> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>   		return;
>>>   	}
>>>   
>>> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
>>> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
>>> -			    &dsi->vpg_horizontal);
>>> +	debugfs_create_files(dsi);
>>>   }
>>>   
>>>   static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>>>   {
>>>   	debugfs_remove_recursive(dsi->debugfs);
>>> +	kfree(dsi->debugfs_vpg);
>>>   }
>>>   
>>>   #else
>>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$ 
> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-07-08 20:29       ` Neil Armstrong
  0 siblings, 0 replies; 30+ messages in thread
From: Neil Armstrong @ 2020-07-08 20:29 UTC (permalink / raw)
  To: Angelo Ribeiro, Yannick FERTRE, Philippe CORNU,
	Benjamin GAIGNARD, airlied, daniel, mcoquelin.stm32,
	Alexandre TORGUE, dri-devel, linux-stm32, linux-arm-kernel,
	linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi,

Le 08/07/2020 à 19:08, Angelo Ribeiro a écrit :
> Hi,
> 
> Is this patch good to go? 
> @daniel@ffwll.ch, @Philippe CORNU
> 
> Was already tested by @Yannick FERTRE 
> and @Adrian Pop
> on https://lkml.org/lkml/2020/4/6/691 .

It would be great to have a review or an ack before applying.

Neil

> 
> Thanks,
> Angelo
> 
> From: Yannick 
> FERTRE <yannick.fertre@st.com>
> Date: Wed, Jun 24, 2020 at 16:35:04
> 
>> Hello Angelo,
>> thanks for the patch.
>> Tested-by: Yannick Fertre <yannick.fertre@st.com>
>> Tested OK on STM32MP1-DISCO, DSI v1.31
>>
>> Best regards
>>
>>
>> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
>>> Add support for the video pattern generator (VPG) BER pattern mode and
>>> configuration in runtime.
>>>
>>> This enables using the debugfs interface to manipulate the VPG after
>>> the pipeline is set.
>>> Also, enables the usage of the VPG BER pattern.
>>>
>>> Changes in v2:
>>>    - Added VID_MODE_VPG_MODE
>>>    - Solved incompatible return type on __get and __set
>>>
>>> Reported-by: kbuild test robot <lkp@intel.com>
>>> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
>>> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
>>> Cc: Joao Pinto <jpinto@synopsys.com>
>>> Cc: Jose Abreu <jose.abreu@synopsys.com>
>>> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
>>> ---
>>>   drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>>>   1 file changed, 90 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> index b18351b..9de3645 100644
>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> @@ -91,6 +91,7 @@
>>>   #define VID_MODE_TYPE_BURST			0x2
>>>   #define VID_MODE_TYPE_MASK			0x3
>>>   #define VID_MODE_VPG_ENABLE		BIT(16)
>>> +#define VID_MODE_VPG_MODE		BIT(20)
>>>   #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>>>   
>>>   #define DSI_VID_PKT_SIZE		0x3c
>>> @@ -221,6 +222,21 @@
>>>   #define PHY_STATUS_TIMEOUT_US		10000
>>>   #define CMD_PKT_STATUS_TIMEOUT_US	20000
>>>   
>>> +#ifdef CONFIG_DEBUG_FS
>>> +#define VPG_DEFS(name, dsi) \
>>> +	((void __force *)&((*dsi).vpg_defs.name))
>>> +
>>> +#define REGISTER(name, mask, dsi) \
>>> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
>>> +
>>> +struct debugfs_entries {
>>> +	const char				*name;
>>> +	bool					*reg;
>>> +	u32					mask;
>>> +	struct dw_mipi_dsi			*dsi;
>>> +};
>>> +#endif /* CONFIG_DEBUG_FS */
>>> +
>>>   struct dw_mipi_dsi {
>>>   	struct drm_bridge bridge;
>>>   	struct mipi_dsi_host dsi_host;
>>> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>>>   
>>>   #ifdef CONFIG_DEBUG_FS
>>>   	struct dentry *debugfs;
>>> -
>>> -	bool vpg;
>>> -	bool vpg_horizontal;
>>> +	struct debugfs_entries *debugfs_vpg;
>>> +	struct {
>>> +		bool vpg;
>>> +		bool vpg_horizontal;
>>> +		bool vpg_ber_pattern;
>>> +	} vpg_defs;
>>>   #endif /* CONFIG_DEBUG_FS */
>>>   
>>>   	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
>>> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>>>   		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>>>   
>>>   #ifdef CONFIG_DEBUG_FS
>>> -	if (dsi->vpg) {
>>> +	if (dsi->vpg_defs.vpg) {
>>>   		val |= VID_MODE_VPG_ENABLE;
>>> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_horizontal ?
>>> +		       VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>>>   	}
>>>   #endif /* CONFIG_DEBUG_FS */
>>>   
>>> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>>>   
>>>   #ifdef CONFIG_DEBUG_FS
>>>   
>>> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +	struct dw_mipi_dsi *dsi;
>>> +	u32 mode_cfg;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	dsi = vpg->dsi;
>>> +
>>> +	*vpg->reg = (bool)val;
>>> +
>>> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
>>> +
>>> +	if (*vpg->reg)
>>> +		mode_cfg |= vpg->mask;
>>> +	else
>>> +		mode_cfg &= ~vpg->mask;
>>> +
>>> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	*val = *vpg->reg;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
>>> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
>>> +
>>> +static void debugfs_create_files(void *data)
>>> +{
>>> +	struct dw_mipi_dsi *dsi = data;
>>> +	struct debugfs_entries debugfs[] = {
>>> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
>>> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
>>> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
>>> +	};
>>> +	int i;
>>> +
>>> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
>>> +	if (!dsi->debugfs_vpg)
>>> +		return;
>>> +
>>> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
>>> +
>>> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
>>> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
>>> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
>>> +				    &fops_x32);
>>> +}
>>> +
>>>   static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>   {
>>>   	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
>>> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>   		return;
>>>   	}
>>>   
>>> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
>>> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
>>> -			    &dsi->vpg_horizontal);
>>> +	debugfs_create_files(dsi);
>>>   }
>>>   
>>>   static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>>>   {
>>>   	debugfs_remove_recursive(dsi->debugfs);
>>> +	kfree(dsi->debugfs_vpg);
>>>   }
>>>   
>>>   #else
>>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$ 
> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
  2020-07-08 17:08     ` Angelo Ribeiro
  (?)
@ 2020-07-09  7:56       ` Philippe CORNU
  -1 siblings, 0 replies; 30+ messages in thread
From: Philippe CORNU @ 2020-07-09  7:56 UTC (permalink / raw)
  To: Angelo Ribeiro, Yannick FERTRE, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto


On 7/8/20 7:08 PM, Angelo Ribeiro wrote:
> Hi,
> 
> Is this patch good to go?
> @daniel@ffwll.ch, @Philippe CORNU
> 
> Was already tested by @Yannick FERTRE
> and @Adrian Pop
> on https://lkml.org/lkml/2020/4/6/691 .
> 
> Thanks,
> Angelo
> 
> From: Yannick
> FERTRE <yannick.fertre@st.com>
> Date: Wed, Jun 24, 2020 at 16:35:04
> 
>> Hello Angelo,
>> thanks for the patch.
>> Tested-by: Yannick Fertre <yannick.fertre@st.com>
>> Tested OK on STM32MP1-DISCO, DSI v1.31
>>
>> Best regards
>>
>>
>> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
>>> Add support for the video pattern generator (VPG) BER pattern mode and
>>> configuration in runtime.
>>>
>>> This enables using the debugfs interface to manipulate the VPG after
>>> the pipeline is set.
>>> Also, enables the usage of the VPG BER pattern.
>>>
>>> Changes in v2:
>>>     - Added VID_MODE_VPG_MODE
>>>     - Solved incompatible return type on __get and __set
>>>
>>> Reported-by: kbuild test robot <lkp@intel.com>
>>> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
>>> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
>>> Cc: Joao Pinto <jpinto@synopsys.com>
>>> Cc: Jose Abreu <jose.abreu@synopsys.com>
>>> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
>>> ---
>>>    drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>>>    1 file changed, 90 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> index b18351b..9de3645 100644
>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> @@ -91,6 +91,7 @@
>>>    #define VID_MODE_TYPE_BURST			0x2
>>>    #define VID_MODE_TYPE_MASK			0x3
>>>    #define VID_MODE_VPG_ENABLE		BIT(16)
>>> +#define VID_MODE_VPG_MODE		BIT(20)
>>>    #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>>>    
>>>    #define DSI_VID_PKT_SIZE		0x3c
>>> @@ -221,6 +222,21 @@
>>>    #define PHY_STATUS_TIMEOUT_US		10000
>>>    #define CMD_PKT_STATUS_TIMEOUT_US	20000
>>>    
>>> +#ifdef CONFIG_DEBUG_FS
>>> +#define VPG_DEFS(name, dsi) \
>>> +	((void __force *)&((*dsi).vpg_defs.name))
>>> +
>>> +#define REGISTER(name, mask, dsi) \
>>> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
>>> +
>>> +struct debugfs_entries {
>>> +	const char				*name;
>>> +	bool					*reg;
>>> +	u32					mask;
>>> +	struct dw_mipi_dsi			*dsi;
>>> +};
>>> +#endif /* CONFIG_DEBUG_FS */
>>> +
>>>    struct dw_mipi_dsi {
>>>    	struct drm_bridge bridge;
>>>    	struct mipi_dsi_host dsi_host;
>>> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>>>    
>>>    #ifdef CONFIG_DEBUG_FS
>>>    	struct dentry *debugfs;
>>> -
>>> -	bool vpg;
>>> -	bool vpg_horizontal;
>>> +	struct debugfs_entries *debugfs_vpg;
>>> +	struct {
>>> +		bool vpg;
>>> +		bool vpg_horizontal;
>>> +		bool vpg_ber_pattern;
>>> +	} vpg_defs;
>>>    #endif /* CONFIG_DEBUG_FS */
>>>    
>>>    	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
>>> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>>>    		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>>>    
>>>    #ifdef CONFIG_DEBUG_FS
>>> -	if (dsi->vpg) {
>>> +	if (dsi->vpg_defs.vpg) {
>>>    		val |= VID_MODE_VPG_ENABLE;
>>> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_horizontal ?
>>> +		       VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>>>    	}
>>>    #endif /* CONFIG_DEBUG_FS */
>>>    
>>> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>>>    
>>>    #ifdef CONFIG_DEBUG_FS
>>>    
>>> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +	struct dw_mipi_dsi *dsi;
>>> +	u32 mode_cfg;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	dsi = vpg->dsi;
>>> +
>>> +	*vpg->reg = (bool)val;
>>> +
>>> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
>>> +
>>> +	if (*vpg->reg)
>>> +		mode_cfg |= vpg->mask;
>>> +	else
>>> +		mode_cfg &= ~vpg->mask;
>>> +
>>> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	*val = *vpg->reg;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
>>> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
>>> +
>>> +static void debugfs_create_files(void *data)
>>> +{
>>> +	struct dw_mipi_dsi *dsi = data;
>>> +	struct debugfs_entries debugfs[] = {
>>> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
>>> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
>>> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
>>> +	};
>>> +	int i;
>>> +
>>> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
>>> +	if (!dsi->debugfs_vpg)
>>> +		return;
>>> +
>>> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
>>> +
>>> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
>>> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
>>> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
>>> +				    &fops_x32);
>>> +}
>>> +
>>>    static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>    {
>>>    	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
>>> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>    		return;
>>>    	}
>>>    
>>> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
>>> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
>>> -			    &dsi->vpg_horizontal);
>>> +	debugfs_create_files(dsi);

Hi Angelo,
And thank you for your patch.
Could you please explain why you have "so many lines" for adding the ber 
pattern, instead of these 4 lines :

+#define VID_MODE_VPG_MODE		BIT(20)
+bool vpg_ber_pattern;
+val |= dsi->vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
+debugfs_create_bool("vpg_ber_pattern", 0660, dsi->debugfs, 
&dsi->vpg_ber_pattern);

Many thanks
Philippe :-)

>>>    }
>>>    
>>>    static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>>>    {
>>>    	debugfs_remove_recursive(dsi->debugfs);
>>> +	kfree(dsi->debugfs_vpg);
>>>    }
>>>    
>>>    #else
>>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$
> 
> 

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-07-09  7:56       ` Philippe CORNU
  0 siblings, 0 replies; 30+ messages in thread
From: Philippe CORNU @ 2020-07-09  7:56 UTC (permalink / raw)
  To: Angelo Ribeiro, Yannick FERTRE, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto


On 7/8/20 7:08 PM, Angelo Ribeiro wrote:
> Hi,
> 
> Is this patch good to go?
> @daniel@ffwll.ch, @Philippe CORNU
> 
> Was already tested by @Yannick FERTRE
> and @Adrian Pop
> on https://lkml.org/lkml/2020/4/6/691 .
> 
> Thanks,
> Angelo
> 
> From: Yannick
> FERTRE <yannick.fertre@st.com>
> Date: Wed, Jun 24, 2020 at 16:35:04
> 
>> Hello Angelo,
>> thanks for the patch.
>> Tested-by: Yannick Fertre <yannick.fertre@st.com>
>> Tested OK on STM32MP1-DISCO, DSI v1.31
>>
>> Best regards
>>
>>
>> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
>>> Add support for the video pattern generator (VPG) BER pattern mode and
>>> configuration in runtime.
>>>
>>> This enables using the debugfs interface to manipulate the VPG after
>>> the pipeline is set.
>>> Also, enables the usage of the VPG BER pattern.
>>>
>>> Changes in v2:
>>>     - Added VID_MODE_VPG_MODE
>>>     - Solved incompatible return type on __get and __set
>>>
>>> Reported-by: kbuild test robot <lkp@intel.com>
>>> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
>>> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
>>> Cc: Joao Pinto <jpinto@synopsys.com>
>>> Cc: Jose Abreu <jose.abreu@synopsys.com>
>>> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
>>> ---
>>>    drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>>>    1 file changed, 90 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> index b18351b..9de3645 100644
>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> @@ -91,6 +91,7 @@
>>>    #define VID_MODE_TYPE_BURST			0x2
>>>    #define VID_MODE_TYPE_MASK			0x3
>>>    #define VID_MODE_VPG_ENABLE		BIT(16)
>>> +#define VID_MODE_VPG_MODE		BIT(20)
>>>    #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>>>    
>>>    #define DSI_VID_PKT_SIZE		0x3c
>>> @@ -221,6 +222,21 @@
>>>    #define PHY_STATUS_TIMEOUT_US		10000
>>>    #define CMD_PKT_STATUS_TIMEOUT_US	20000
>>>    
>>> +#ifdef CONFIG_DEBUG_FS
>>> +#define VPG_DEFS(name, dsi) \
>>> +	((void __force *)&((*dsi).vpg_defs.name))
>>> +
>>> +#define REGISTER(name, mask, dsi) \
>>> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
>>> +
>>> +struct debugfs_entries {
>>> +	const char				*name;
>>> +	bool					*reg;
>>> +	u32					mask;
>>> +	struct dw_mipi_dsi			*dsi;
>>> +};
>>> +#endif /* CONFIG_DEBUG_FS */
>>> +
>>>    struct dw_mipi_dsi {
>>>    	struct drm_bridge bridge;
>>>    	struct mipi_dsi_host dsi_host;
>>> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>>>    
>>>    #ifdef CONFIG_DEBUG_FS
>>>    	struct dentry *debugfs;
>>> -
>>> -	bool vpg;
>>> -	bool vpg_horizontal;
>>> +	struct debugfs_entries *debugfs_vpg;
>>> +	struct {
>>> +		bool vpg;
>>> +		bool vpg_horizontal;
>>> +		bool vpg_ber_pattern;
>>> +	} vpg_defs;
>>>    #endif /* CONFIG_DEBUG_FS */
>>>    
>>>    	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
>>> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>>>    		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>>>    
>>>    #ifdef CONFIG_DEBUG_FS
>>> -	if (dsi->vpg) {
>>> +	if (dsi->vpg_defs.vpg) {
>>>    		val |= VID_MODE_VPG_ENABLE;
>>> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_horizontal ?
>>> +		       VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>>>    	}
>>>    #endif /* CONFIG_DEBUG_FS */
>>>    
>>> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>>>    
>>>    #ifdef CONFIG_DEBUG_FS
>>>    
>>> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +	struct dw_mipi_dsi *dsi;
>>> +	u32 mode_cfg;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	dsi = vpg->dsi;
>>> +
>>> +	*vpg->reg = (bool)val;
>>> +
>>> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
>>> +
>>> +	if (*vpg->reg)
>>> +		mode_cfg |= vpg->mask;
>>> +	else
>>> +		mode_cfg &= ~vpg->mask;
>>> +
>>> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	*val = *vpg->reg;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
>>> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
>>> +
>>> +static void debugfs_create_files(void *data)
>>> +{
>>> +	struct dw_mipi_dsi *dsi = data;
>>> +	struct debugfs_entries debugfs[] = {
>>> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
>>> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
>>> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
>>> +	};
>>> +	int i;
>>> +
>>> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
>>> +	if (!dsi->debugfs_vpg)
>>> +		return;
>>> +
>>> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
>>> +
>>> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
>>> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
>>> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
>>> +				    &fops_x32);
>>> +}
>>> +
>>>    static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>    {
>>>    	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
>>> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>    		return;
>>>    	}
>>>    
>>> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
>>> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
>>> -			    &dsi->vpg_horizontal);
>>> +	debugfs_create_files(dsi);

Hi Angelo,
And thank you for your patch.
Could you please explain why you have "so many lines" for adding the ber 
pattern, instead of these 4 lines :

+#define VID_MODE_VPG_MODE		BIT(20)
+bool vpg_ber_pattern;
+val |= dsi->vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
+debugfs_create_bool("vpg_ber_pattern", 0660, dsi->debugfs, 
&dsi->vpg_ber_pattern);

Many thanks
Philippe :-)

>>>    }
>>>    
>>>    static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>>>    {
>>>    	debugfs_remove_recursive(dsi->debugfs);
>>> +	kfree(dsi->debugfs_vpg);
>>>    }
>>>    
>>>    #else
>>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$
> 
> 
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-07-09  7:56       ` Philippe CORNU
  0 siblings, 0 replies; 30+ messages in thread
From: Philippe CORNU @ 2020-07-09  7:56 UTC (permalink / raw)
  To: Angelo Ribeiro, Yannick FERTRE, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto


On 7/8/20 7:08 PM, Angelo Ribeiro wrote:
> Hi,
> 
> Is this patch good to go?
> @daniel@ffwll.ch, @Philippe CORNU
> 
> Was already tested by @Yannick FERTRE
> and @Adrian Pop
> on https://lkml.org/lkml/2020/4/6/691 .
> 
> Thanks,
> Angelo
> 
> From: Yannick
> FERTRE <yannick.fertre@st.com>
> Date: Wed, Jun 24, 2020 at 16:35:04
> 
>> Hello Angelo,
>> thanks for the patch.
>> Tested-by: Yannick Fertre <yannick.fertre@st.com>
>> Tested OK on STM32MP1-DISCO, DSI v1.31
>>
>> Best regards
>>
>>
>> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
>>> Add support for the video pattern generator (VPG) BER pattern mode and
>>> configuration in runtime.
>>>
>>> This enables using the debugfs interface to manipulate the VPG after
>>> the pipeline is set.
>>> Also, enables the usage of the VPG BER pattern.
>>>
>>> Changes in v2:
>>>     - Added VID_MODE_VPG_MODE
>>>     - Solved incompatible return type on __get and __set
>>>
>>> Reported-by: kbuild test robot <lkp@intel.com>
>>> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
>>> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
>>> Cc: Joao Pinto <jpinto@synopsys.com>
>>> Cc: Jose Abreu <jose.abreu@synopsys.com>
>>> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
>>> ---
>>>    drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>>>    1 file changed, 90 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> index b18351b..9de3645 100644
>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>> @@ -91,6 +91,7 @@
>>>    #define VID_MODE_TYPE_BURST			0x2
>>>    #define VID_MODE_TYPE_MASK			0x3
>>>    #define VID_MODE_VPG_ENABLE		BIT(16)
>>> +#define VID_MODE_VPG_MODE		BIT(20)
>>>    #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>>>    
>>>    #define DSI_VID_PKT_SIZE		0x3c
>>> @@ -221,6 +222,21 @@
>>>    #define PHY_STATUS_TIMEOUT_US		10000
>>>    #define CMD_PKT_STATUS_TIMEOUT_US	20000
>>>    
>>> +#ifdef CONFIG_DEBUG_FS
>>> +#define VPG_DEFS(name, dsi) \
>>> +	((void __force *)&((*dsi).vpg_defs.name))
>>> +
>>> +#define REGISTER(name, mask, dsi) \
>>> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
>>> +
>>> +struct debugfs_entries {
>>> +	const char				*name;
>>> +	bool					*reg;
>>> +	u32					mask;
>>> +	struct dw_mipi_dsi			*dsi;
>>> +};
>>> +#endif /* CONFIG_DEBUG_FS */
>>> +
>>>    struct dw_mipi_dsi {
>>>    	struct drm_bridge bridge;
>>>    	struct mipi_dsi_host dsi_host;
>>> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>>>    
>>>    #ifdef CONFIG_DEBUG_FS
>>>    	struct dentry *debugfs;
>>> -
>>> -	bool vpg;
>>> -	bool vpg_horizontal;
>>> +	struct debugfs_entries *debugfs_vpg;
>>> +	struct {
>>> +		bool vpg;
>>> +		bool vpg_horizontal;
>>> +		bool vpg_ber_pattern;
>>> +	} vpg_defs;
>>>    #endif /* CONFIG_DEBUG_FS */
>>>    
>>>    	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
>>> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>>>    		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>>>    
>>>    #ifdef CONFIG_DEBUG_FS
>>> -	if (dsi->vpg) {
>>> +	if (dsi->vpg_defs.vpg) {
>>>    		val |= VID_MODE_VPG_ENABLE;
>>> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_horizontal ?
>>> +		       VID_MODE_VPG_HORIZONTAL : 0;
>>> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>>>    	}
>>>    #endif /* CONFIG_DEBUG_FS */
>>>    
>>> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>>>    
>>>    #ifdef CONFIG_DEBUG_FS
>>>    
>>> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +	struct dw_mipi_dsi *dsi;
>>> +	u32 mode_cfg;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	dsi = vpg->dsi;
>>> +
>>> +	*vpg->reg = (bool)val;
>>> +
>>> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
>>> +
>>> +	if (*vpg->reg)
>>> +		mode_cfg |= vpg->mask;
>>> +	else
>>> +		mode_cfg &= ~vpg->mask;
>>> +
>>> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
>>> +{
>>> +	struct debugfs_entries *vpg = data;
>>> +
>>> +	if (!vpg)
>>> +		return -ENODEV;
>>> +
>>> +	*val = *vpg->reg;
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
>>> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
>>> +
>>> +static void debugfs_create_files(void *data)
>>> +{
>>> +	struct dw_mipi_dsi *dsi = data;
>>> +	struct debugfs_entries debugfs[] = {
>>> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
>>> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
>>> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
>>> +	};
>>> +	int i;
>>> +
>>> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
>>> +	if (!dsi->debugfs_vpg)
>>> +		return;
>>> +
>>> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
>>> +
>>> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
>>> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
>>> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
>>> +				    &fops_x32);
>>> +}
>>> +
>>>    static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>    {
>>>    	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
>>> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>>>    		return;
>>>    	}
>>>    
>>> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
>>> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
>>> -			    &dsi->vpg_horizontal);
>>> +	debugfs_create_files(dsi);

Hi Angelo,
And thank you for your patch.
Could you please explain why you have "so many lines" for adding the ber 
pattern, instead of these 4 lines :

+#define VID_MODE_VPG_MODE		BIT(20)
+bool vpg_ber_pattern;
+val |= dsi->vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
+debugfs_create_bool("vpg_ber_pattern", 0660, dsi->debugfs, 
&dsi->vpg_ber_pattern);

Many thanks
Philippe :-)

>>>    }
>>>    
>>>    static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>>>    {
>>>    	debugfs_remove_recursive(dsi->debugfs);
>>> +	kfree(dsi->debugfs_vpg);
>>>    }
>>>    
>>>    #else
>>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$
> 
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
  2020-07-09  7:56       ` Philippe CORNU
  (?)
@ 2020-07-09  8:51         ` Angelo Ribeiro
  -1 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-07-09  8:51 UTC (permalink / raw)
  To: Philippe CORNU, Yannick FERTRE, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi Philippe,

From: Philippe CORNU <philippe.cornu@st.com>
Date: Thu, Jul 09, 2020 at 08:56:10

> 
> On 7/8/20 7:08 PM, Angelo Ribeiro wrote:
> > Hi,
> > 
> > Is this patch good to go?
> > @daniel@ffwll.ch, @Philippe CORNU
> > 
> > Was already tested by @Yannick FERTRE
> > and @Adrian Pop
> > on https://urldefense.com/v3/__https://lkml.org/lkml/2020/4/6/691__;!!A4F2R9G_pg!Kt4QZq004dTCJ3GJ6t6RIaJMBrP5tWWgTlboJo1ZICktSxRegGKtp1VxYM1i2PiM$  .
> > 
> > Thanks,
> > Angelo
> > 
> > From: Yannick
> > FERTRE <yannick.fertre@st.com>
> > Date: Wed, Jun 24, 2020 at 16:35:04
> > 
> >> Hello Angelo,
> >> thanks for the patch.
> >> Tested-by: Yannick Fertre <yannick.fertre@st.com>
> >> Tested OK on STM32MP1-DISCO, DSI v1.31
> >>
> >> Best regards
> >>
> >>
> >> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
> >>> Add support for the video pattern generator (VPG) BER pattern mode and
> >>> configuration in runtime.
> >>>
> >>> This enables using the debugfs interface to manipulate the VPG after
> >>> the pipeline is set.
> >>> Also, enables the usage of the VPG BER pattern.
> >>>
> >>> Changes in v2:
> >>>     - Added VID_MODE_VPG_MODE
> >>>     - Solved incompatible return type on __get and __set
> >>>
> >>> Reported-by: kbuild test robot <lkp@intel.com>
> >>> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> >>> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> >>> Cc: Joao Pinto <jpinto@synopsys.com>
> >>> Cc: Jose Abreu <jose.abreu@synopsys.com>
> >>> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> >>> ---
> >>>    drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
> >>>    1 file changed, 90 insertions(+), 8 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >>> index b18351b..9de3645 100644
> >>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >>> @@ -91,6 +91,7 @@
> >>>    #define VID_MODE_TYPE_BURST			0x2
> >>>    #define VID_MODE_TYPE_MASK			0x3
> >>>    #define VID_MODE_VPG_ENABLE		BIT(16)
> >>> +#define VID_MODE_VPG_MODE		BIT(20)
> >>>    #define VID_MODE_VPG_HORIZONTAL		BIT(24)
> >>>    
> >>>    #define DSI_VID_PKT_SIZE		0x3c
> >>> @@ -221,6 +222,21 @@
> >>>    #define PHY_STATUS_TIMEOUT_US		10000
> >>>    #define CMD_PKT_STATUS_TIMEOUT_US	20000
> >>>    
> >>> +#ifdef CONFIG_DEBUG_FS
> >>> +#define VPG_DEFS(name, dsi) \
> >>> +	((void __force *)&((*dsi).vpg_defs.name))
> >>> +
> >>> +#define REGISTER(name, mask, dsi) \
> >>> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> >>> +
> >>> +struct debugfs_entries {
> >>> +	const char				*name;
> >>> +	bool					*reg;
> >>> +	u32					mask;
> >>> +	struct dw_mipi_dsi			*dsi;
> >>> +};
> >>> +#endif /* CONFIG_DEBUG_FS */
> >>> +
> >>>    struct dw_mipi_dsi {
> >>>    	struct drm_bridge bridge;
> >>>    	struct mipi_dsi_host dsi_host;
> >>> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> >>>    
> >>>    #ifdef CONFIG_DEBUG_FS
> >>>    	struct dentry *debugfs;
> >>> -
> >>> -	bool vpg;
> >>> -	bool vpg_horizontal;
> >>> +	struct debugfs_entries *debugfs_vpg;
> >>> +	struct {
> >>> +		bool vpg;
> >>> +		bool vpg_horizontal;
> >>> +		bool vpg_ber_pattern;
> >>> +	} vpg_defs;
> >>>    #endif /* CONFIG_DEBUG_FS */
> >>>    
> >>>    	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> >>> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
> >>>    		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> >>>    
> >>>    #ifdef CONFIG_DEBUG_FS
> >>> -	if (dsi->vpg) {
> >>> +	if (dsi->vpg_defs.vpg) {
> >>>    		val |= VID_MODE_VPG_ENABLE;
> >>> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> >>> +		val |= dsi->vpg_defs.vpg_horizontal ?
> >>> +		       VID_MODE_VPG_HORIZONTAL : 0;
> >>> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> >>>    	}
> >>>    #endif /* CONFIG_DEBUG_FS */
> >>>    
> >>> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
> >>>    
> >>>    #ifdef CONFIG_DEBUG_FS
> >>>    
> >>> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> >>> +{
> >>> +	struct debugfs_entries *vpg = data;
> >>> +	struct dw_mipi_dsi *dsi;
> >>> +	u32 mode_cfg;
> >>> +
> >>> +	if (!vpg)
> >>> +		return -ENODEV;
> >>> +
> >>> +	dsi = vpg->dsi;
> >>> +
> >>> +	*vpg->reg = (bool)val;
> >>> +
> >>> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> >>> +
> >>> +	if (*vpg->reg)
> >>> +		mode_cfg |= vpg->mask;
> >>> +	else
> >>> +		mode_cfg &= ~vpg->mask;
> >>> +
> >>> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> >>> +{
> >>> +	struct debugfs_entries *vpg = data;
> >>> +
> >>> +	if (!vpg)
> >>> +		return -ENODEV;
> >>> +
> >>> +	*val = *vpg->reg;
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> >>> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> >>> +
> >>> +static void debugfs_create_files(void *data)
> >>> +{
> >>> +	struct dw_mipi_dsi *dsi = data;
> >>> +	struct debugfs_entries debugfs[] = {
> >>> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> >>> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> >>> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> >>> +	};
> >>> +	int i;
> >>> +
> >>> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> >>> +	if (!dsi->debugfs_vpg)
> >>> +		return;
> >>> +
> >>> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> >>> +
> >>> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> >>> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> >>> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> >>> +				    &fops_x32);
> >>> +}
> >>> +
> >>>    static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >>>    {
> >>>    	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> >>> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >>>    		return;
> >>>    	}
> >>>    
> >>> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> >>> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> >>> -			    &dsi->vpg_horizontal);
> >>> +	debugfs_create_files(dsi);
> 
> Hi Angelo,
> And thank you for your patch.
> Could you please explain why you have "so many lines" for adding the ber 
> pattern, instead of these 4 lines :
> 
> +#define VID_MODE_VPG_MODE		BIT(20)
> +bool vpg_ber_pattern;
> +val |= dsi->vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> +debugfs_create_bool("vpg_ber_pattern", 0660, dsi->debugfs, 
> &dsi->vpg_ber_pattern);
> 
> Many thanks
> Philippe :-)

Thank you for the review.

With this implementation you only need to set the debugfs file
to control the VPG. Since the internal VPG is used for debug 
purposes it eases the use during your development.

Thanks,
Angelo

> 
> >>>    }
> >>>    
> >>>    static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> >>>    {
> >>>    	debugfs_remove_recursive(dsi->debugfs);
> >>> +	kfree(dsi->debugfs_vpg);
> >>>    }
> >>>    
> >>>    #else
> >>>
> >> _______________________________________________
> >> dri-devel mailing list
> >> dri-devel@lists.freedesktop.org
> >> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$
> > 
> > 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!Kt4QZq004dTCJ3GJ6t6RIaJMBrP5tWWgTlboJo1ZICktSxRegGKtp1VxYH7H4Xjz$ 



^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-07-09  8:51         ` Angelo Ribeiro
  0 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-07-09  8:51 UTC (permalink / raw)
  To: Philippe CORNU, Yannick FERTRE, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi Philippe,

From: Philippe CORNU <philippe.cornu@st.com>
Date: Thu, Jul 09, 2020 at 08:56:10

> 
> On 7/8/20 7:08 PM, Angelo Ribeiro wrote:
> > Hi,
> > 
> > Is this patch good to go?
> > @daniel@ffwll.ch, @Philippe CORNU
> > 
> > Was already tested by @Yannick FERTRE
> > and @Adrian Pop
> > on https://urldefense.com/v3/__https://lkml.org/lkml/2020/4/6/691__;!!A4F2R9G_pg!Kt4QZq004dTCJ3GJ6t6RIaJMBrP5tWWgTlboJo1ZICktSxRegGKtp1VxYM1i2PiM$  .
> > 
> > Thanks,
> > Angelo
> > 
> > From: Yannick
> > FERTRE <yannick.fertre@st.com>
> > Date: Wed, Jun 24, 2020 at 16:35:04
> > 
> >> Hello Angelo,
> >> thanks for the patch.
> >> Tested-by: Yannick Fertre <yannick.fertre@st.com>
> >> Tested OK on STM32MP1-DISCO, DSI v1.31
> >>
> >> Best regards
> >>
> >>
> >> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
> >>> Add support for the video pattern generator (VPG) BER pattern mode and
> >>> configuration in runtime.
> >>>
> >>> This enables using the debugfs interface to manipulate the VPG after
> >>> the pipeline is set.
> >>> Also, enables the usage of the VPG BER pattern.
> >>>
> >>> Changes in v2:
> >>>     - Added VID_MODE_VPG_MODE
> >>>     - Solved incompatible return type on __get and __set
> >>>
> >>> Reported-by: kbuild test robot <lkp@intel.com>
> >>> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> >>> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> >>> Cc: Joao Pinto <jpinto@synopsys.com>
> >>> Cc: Jose Abreu <jose.abreu@synopsys.com>
> >>> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> >>> ---
> >>>    drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
> >>>    1 file changed, 90 insertions(+), 8 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >>> index b18351b..9de3645 100644
> >>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >>> @@ -91,6 +91,7 @@
> >>>    #define VID_MODE_TYPE_BURST			0x2
> >>>    #define VID_MODE_TYPE_MASK			0x3
> >>>    #define VID_MODE_VPG_ENABLE		BIT(16)
> >>> +#define VID_MODE_VPG_MODE		BIT(20)
> >>>    #define VID_MODE_VPG_HORIZONTAL		BIT(24)
> >>>    
> >>>    #define DSI_VID_PKT_SIZE		0x3c
> >>> @@ -221,6 +222,21 @@
> >>>    #define PHY_STATUS_TIMEOUT_US		10000
> >>>    #define CMD_PKT_STATUS_TIMEOUT_US	20000
> >>>    
> >>> +#ifdef CONFIG_DEBUG_FS
> >>> +#define VPG_DEFS(name, dsi) \
> >>> +	((void __force *)&((*dsi).vpg_defs.name))
> >>> +
> >>> +#define REGISTER(name, mask, dsi) \
> >>> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> >>> +
> >>> +struct debugfs_entries {
> >>> +	const char				*name;
> >>> +	bool					*reg;
> >>> +	u32					mask;
> >>> +	struct dw_mipi_dsi			*dsi;
> >>> +};
> >>> +#endif /* CONFIG_DEBUG_FS */
> >>> +
> >>>    struct dw_mipi_dsi {
> >>>    	struct drm_bridge bridge;
> >>>    	struct mipi_dsi_host dsi_host;
> >>> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> >>>    
> >>>    #ifdef CONFIG_DEBUG_FS
> >>>    	struct dentry *debugfs;
> >>> -
> >>> -	bool vpg;
> >>> -	bool vpg_horizontal;
> >>> +	struct debugfs_entries *debugfs_vpg;
> >>> +	struct {
> >>> +		bool vpg;
> >>> +		bool vpg_horizontal;
> >>> +		bool vpg_ber_pattern;
> >>> +	} vpg_defs;
> >>>    #endif /* CONFIG_DEBUG_FS */
> >>>    
> >>>    	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> >>> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
> >>>    		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> >>>    
> >>>    #ifdef CONFIG_DEBUG_FS
> >>> -	if (dsi->vpg) {
> >>> +	if (dsi->vpg_defs.vpg) {
> >>>    		val |= VID_MODE_VPG_ENABLE;
> >>> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> >>> +		val |= dsi->vpg_defs.vpg_horizontal ?
> >>> +		       VID_MODE_VPG_HORIZONTAL : 0;
> >>> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> >>>    	}
> >>>    #endif /* CONFIG_DEBUG_FS */
> >>>    
> >>> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
> >>>    
> >>>    #ifdef CONFIG_DEBUG_FS
> >>>    
> >>> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> >>> +{
> >>> +	struct debugfs_entries *vpg = data;
> >>> +	struct dw_mipi_dsi *dsi;
> >>> +	u32 mode_cfg;
> >>> +
> >>> +	if (!vpg)
> >>> +		return -ENODEV;
> >>> +
> >>> +	dsi = vpg->dsi;
> >>> +
> >>> +	*vpg->reg = (bool)val;
> >>> +
> >>> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> >>> +
> >>> +	if (*vpg->reg)
> >>> +		mode_cfg |= vpg->mask;
> >>> +	else
> >>> +		mode_cfg &= ~vpg->mask;
> >>> +
> >>> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> >>> +{
> >>> +	struct debugfs_entries *vpg = data;
> >>> +
> >>> +	if (!vpg)
> >>> +		return -ENODEV;
> >>> +
> >>> +	*val = *vpg->reg;
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> >>> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> >>> +
> >>> +static void debugfs_create_files(void *data)
> >>> +{
> >>> +	struct dw_mipi_dsi *dsi = data;
> >>> +	struct debugfs_entries debugfs[] = {
> >>> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> >>> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> >>> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> >>> +	};
> >>> +	int i;
> >>> +
> >>> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> >>> +	if (!dsi->debugfs_vpg)
> >>> +		return;
> >>> +
> >>> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> >>> +
> >>> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> >>> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> >>> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> >>> +				    &fops_x32);
> >>> +}
> >>> +
> >>>    static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >>>    {
> >>>    	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> >>> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >>>    		return;
> >>>    	}
> >>>    
> >>> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> >>> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> >>> -			    &dsi->vpg_horizontal);
> >>> +	debugfs_create_files(dsi);
> 
> Hi Angelo,
> And thank you for your patch.
> Could you please explain why you have "so many lines" for adding the ber 
> pattern, instead of these 4 lines :
> 
> +#define VID_MODE_VPG_MODE		BIT(20)
> +bool vpg_ber_pattern;
> +val |= dsi->vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> +debugfs_create_bool("vpg_ber_pattern", 0660, dsi->debugfs, 
> &dsi->vpg_ber_pattern);
> 
> Many thanks
> Philippe :-)

Thank you for the review.

With this implementation you only need to set the debugfs file
to control the VPG. Since the internal VPG is used for debug 
purposes it eases the use during your development.

Thanks,
Angelo

> 
> >>>    }
> >>>    
> >>>    static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> >>>    {
> >>>    	debugfs_remove_recursive(dsi->debugfs);
> >>> +	kfree(dsi->debugfs_vpg);
> >>>    }
> >>>    
> >>>    #else
> >>>
> >> _______________________________________________
> >> dri-devel mailing list
> >> dri-devel@lists.freedesktop.org
> >> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$
> > 
> > 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!Kt4QZq004dTCJ3GJ6t6RIaJMBrP5tWWgTlboJo1ZICktSxRegGKtp1VxYH7H4Xjz$ 



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* RE: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-07-09  8:51         ` Angelo Ribeiro
  0 siblings, 0 replies; 30+ messages in thread
From: Angelo Ribeiro @ 2020-07-09  8:51 UTC (permalink / raw)
  To: Philippe CORNU, Yannick FERTRE, Benjamin GAIGNARD, airlied,
	daniel, mcoquelin.stm32, Alexandre TORGUE, dri-devel,
	linux-stm32, linux-arm-kernel, linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi Philippe,

From: Philippe CORNU <philippe.cornu@st.com>
Date: Thu, Jul 09, 2020 at 08:56:10

> 
> On 7/8/20 7:08 PM, Angelo Ribeiro wrote:
> > Hi,
> > 
> > Is this patch good to go?
> > @daniel@ffwll.ch, @Philippe CORNU
> > 
> > Was already tested by @Yannick FERTRE
> > and @Adrian Pop
> > on https://urldefense.com/v3/__https://lkml.org/lkml/2020/4/6/691__;!!A4F2R9G_pg!Kt4QZq004dTCJ3GJ6t6RIaJMBrP5tWWgTlboJo1ZICktSxRegGKtp1VxYM1i2PiM$  .
> > 
> > Thanks,
> > Angelo
> > 
> > From: Yannick
> > FERTRE <yannick.fertre@st.com>
> > Date: Wed, Jun 24, 2020 at 16:35:04
> > 
> >> Hello Angelo,
> >> thanks for the patch.
> >> Tested-by: Yannick Fertre <yannick.fertre@st.com>
> >> Tested OK on STM32MP1-DISCO, DSI v1.31
> >>
> >> Best regards
> >>
> >>
> >> On 4/6/20 3:49 PM, Angelo Ribeiro wrote:
> >>> Add support for the video pattern generator (VPG) BER pattern mode and
> >>> configuration in runtime.
> >>>
> >>> This enables using the debugfs interface to manipulate the VPG after
> >>> the pipeline is set.
> >>> Also, enables the usage of the VPG BER pattern.
> >>>
> >>> Changes in v2:
> >>>     - Added VID_MODE_VPG_MODE
> >>>     - Solved incompatible return type on __get and __set
> >>>
> >>> Reported-by: kbuild test robot <lkp@intel.com>
> >>> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> >>> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> >>> Cc: Joao Pinto <jpinto@synopsys.com>
> >>> Cc: Jose Abreu <jose.abreu@synopsys.com>
> >>> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> >>> ---
> >>>    drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
> >>>    1 file changed, 90 insertions(+), 8 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >>> index b18351b..9de3645 100644
> >>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >>> @@ -91,6 +91,7 @@
> >>>    #define VID_MODE_TYPE_BURST			0x2
> >>>    #define VID_MODE_TYPE_MASK			0x3
> >>>    #define VID_MODE_VPG_ENABLE		BIT(16)
> >>> +#define VID_MODE_VPG_MODE		BIT(20)
> >>>    #define VID_MODE_VPG_HORIZONTAL		BIT(24)
> >>>    
> >>>    #define DSI_VID_PKT_SIZE		0x3c
> >>> @@ -221,6 +222,21 @@
> >>>    #define PHY_STATUS_TIMEOUT_US		10000
> >>>    #define CMD_PKT_STATUS_TIMEOUT_US	20000
> >>>    
> >>> +#ifdef CONFIG_DEBUG_FS
> >>> +#define VPG_DEFS(name, dsi) \
> >>> +	((void __force *)&((*dsi).vpg_defs.name))
> >>> +
> >>> +#define REGISTER(name, mask, dsi) \
> >>> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> >>> +
> >>> +struct debugfs_entries {
> >>> +	const char				*name;
> >>> +	bool					*reg;
> >>> +	u32					mask;
> >>> +	struct dw_mipi_dsi			*dsi;
> >>> +};
> >>> +#endif /* CONFIG_DEBUG_FS */
> >>> +
> >>>    struct dw_mipi_dsi {
> >>>    	struct drm_bridge bridge;
> >>>    	struct mipi_dsi_host dsi_host;
> >>> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
> >>>    
> >>>    #ifdef CONFIG_DEBUG_FS
> >>>    	struct dentry *debugfs;
> >>> -
> >>> -	bool vpg;
> >>> -	bool vpg_horizontal;
> >>> +	struct debugfs_entries *debugfs_vpg;
> >>> +	struct {
> >>> +		bool vpg;
> >>> +		bool vpg_horizontal;
> >>> +		bool vpg_ber_pattern;
> >>> +	} vpg_defs;
> >>>    #endif /* CONFIG_DEBUG_FS */
> >>>    
> >>>    	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> >>> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
> >>>    		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
> >>>    
> >>>    #ifdef CONFIG_DEBUG_FS
> >>> -	if (dsi->vpg) {
> >>> +	if (dsi->vpg_defs.vpg) {
> >>>    		val |= VID_MODE_VPG_ENABLE;
> >>> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> >>> +		val |= dsi->vpg_defs.vpg_horizontal ?
> >>> +		       VID_MODE_VPG_HORIZONTAL : 0;
> >>> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> >>>    	}
> >>>    #endif /* CONFIG_DEBUG_FS */
> >>>    
> >>> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
> >>>    
> >>>    #ifdef CONFIG_DEBUG_FS
> >>>    
> >>> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> >>> +{
> >>> +	struct debugfs_entries *vpg = data;
> >>> +	struct dw_mipi_dsi *dsi;
> >>> +	u32 mode_cfg;
> >>> +
> >>> +	if (!vpg)
> >>> +		return -ENODEV;
> >>> +
> >>> +	dsi = vpg->dsi;
> >>> +
> >>> +	*vpg->reg = (bool)val;
> >>> +
> >>> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> >>> +
> >>> +	if (*vpg->reg)
> >>> +		mode_cfg |= vpg->mask;
> >>> +	else
> >>> +		mode_cfg &= ~vpg->mask;
> >>> +
> >>> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> >>> +{
> >>> +	struct debugfs_entries *vpg = data;
> >>> +
> >>> +	if (!vpg)
> >>> +		return -ENODEV;
> >>> +
> >>> +	*val = *vpg->reg;
> >>> +
> >>> +	return 0;
> >>> +}
> >>> +
> >>> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> >>> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> >>> +
> >>> +static void debugfs_create_files(void *data)
> >>> +{
> >>> +	struct dw_mipi_dsi *dsi = data;
> >>> +	struct debugfs_entries debugfs[] = {
> >>> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> >>> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> >>> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> >>> +	};
> >>> +	int i;
> >>> +
> >>> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> >>> +	if (!dsi->debugfs_vpg)
> >>> +		return;
> >>> +
> >>> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> >>> +
> >>> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> >>> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> >>> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> >>> +				    &fops_x32);
> >>> +}
> >>> +
> >>>    static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >>>    {
> >>>    	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> >>> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
> >>>    		return;
> >>>    	}
> >>>    
> >>> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> >>> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> >>> -			    &dsi->vpg_horizontal);
> >>> +	debugfs_create_files(dsi);
> 
> Hi Angelo,
> And thank you for your patch.
> Could you please explain why you have "so many lines" for adding the ber 
> pattern, instead of these 4 lines :
> 
> +#define VID_MODE_VPG_MODE		BIT(20)
> +bool vpg_ber_pattern;
> +val |= dsi->vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
> +debugfs_create_bool("vpg_ber_pattern", 0660, dsi->debugfs, 
> &dsi->vpg_ber_pattern);
> 
> Many thanks
> Philippe :-)

Thank you for the review.

With this implementation you only need to set the debugfs file
to control the VPG. Since the internal VPG is used for debug 
purposes it eases the use during your development.

Thanks,
Angelo

> 
> >>>    }
> >>>    
> >>>    static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
> >>>    {
> >>>    	debugfs_remove_recursive(dsi->debugfs);
> >>> +	kfree(dsi->debugfs_vpg);
> >>>    }
> >>>    
> >>>    #else
> >>>
> >> _______________________________________________
> >> dri-devel mailing list
> >> dri-devel@lists.freedesktop.org
> >> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!PaD758-TpCHJcJG4biB5oM3WJXd1mTbLitD8K1qzSVQ4Z06nc__06MR_sz-ITMIl$
> > 
> > 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/dri-devel__;!!A4F2R9G_pg!Kt4QZq004dTCJ3GJ6t6RIaJMBrP5tWWgTlboJo1ZICktSxRegGKtp1VxYH7H4Xjz$ 


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
  2020-04-06 13:49 ` Angelo Ribeiro
  (?)
@ 2020-09-07  8:09   ` Neil Armstrong
  -1 siblings, 0 replies; 30+ messages in thread
From: Neil Armstrong @ 2020-09-07  8:09 UTC (permalink / raw)
  To: Angelo Ribeiro, yannick.fertre, philippe.cornu,
	benjamin.gaignard, airlied, daniel, mcoquelin.stm32,
	alexandre.torgue, dri-devel, linux-stm32, linux-arm-kernel,
	linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi,

On 06/04/2020 15:49, Angelo Ribeiro wrote:
> Add support for the video pattern generator (VPG) BER pattern mode and
> configuration in runtime.
> 
> This enables using the debugfs interface to manipulate the VPG after
> the pipeline is set.
> Also, enables the usage of the VPG BER pattern.
> 
> Changes in v2:
>   - Added VID_MODE_VPG_MODE
>   - Solved incompatible return type on __get and __set
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> Cc: Joao Pinto <jpinto@synopsys.com>
> Cc: Jose Abreu <jose.abreu@synopsys.com>
> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>  1 file changed, 90 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index b18351b..9de3645 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -91,6 +91,7 @@
>  #define VID_MODE_TYPE_BURST			0x2
>  #define VID_MODE_TYPE_MASK			0x3
>  #define VID_MODE_VPG_ENABLE		BIT(16)
> +#define VID_MODE_VPG_MODE		BIT(20)
>  #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>  
>  #define DSI_VID_PKT_SIZE		0x3c
> @@ -221,6 +222,21 @@
>  #define PHY_STATUS_TIMEOUT_US		10000
>  #define CMD_PKT_STATUS_TIMEOUT_US	20000
>  
> +#ifdef CONFIG_DEBUG_FS
> +#define VPG_DEFS(name, dsi) \
> +	((void __force *)&((*dsi).vpg_defs.name))
> +
> +#define REGISTER(name, mask, dsi) \
> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> +
> +struct debugfs_entries {
> +	const char				*name;
> +	bool					*reg;
> +	u32					mask;
> +	struct dw_mipi_dsi			*dsi;
> +};
> +#endif /* CONFIG_DEBUG_FS */
> +
>  struct dw_mipi_dsi {
>  	struct drm_bridge bridge;
>  	struct mipi_dsi_host dsi_host;
> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>  
>  #ifdef CONFIG_DEBUG_FS
>  	struct dentry *debugfs;
> -
> -	bool vpg;
> -	bool vpg_horizontal;
> +	struct debugfs_entries *debugfs_vpg;
> +	struct {
> +		bool vpg;
> +		bool vpg_horizontal;
> +		bool vpg_ber_pattern;
> +	} vpg_defs;
>  #endif /* CONFIG_DEBUG_FS */
>  
>  	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>  		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>  
>  #ifdef CONFIG_DEBUG_FS
> -	if (dsi->vpg) {
> +	if (dsi->vpg_defs.vpg) {
>  		val |= VID_MODE_VPG_ENABLE;
> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_horizontal ?
> +		       VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>  	}
>  #endif /* CONFIG_DEBUG_FS */
>  
> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>  
>  #ifdef CONFIG_DEBUG_FS
>  
> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> +{
> +	struct debugfs_entries *vpg = data;
> +	struct dw_mipi_dsi *dsi;
> +	u32 mode_cfg;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	dsi = vpg->dsi;
> +
> +	*vpg->reg = (bool)val;
> +
> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> +
> +	if (*vpg->reg)
> +		mode_cfg |= vpg->mask;
> +	else
> +		mode_cfg &= ~vpg->mask;
> +
> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> +
> +	return 0;
> +}
> +
> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> +{
> +	struct debugfs_entries *vpg = data;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	*val = *vpg->reg;
> +
> +	return 0;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> +
> +static void debugfs_create_files(void *data)
> +{
> +	struct dw_mipi_dsi *dsi = data;
> +	struct debugfs_entries debugfs[] = {
> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> +	};
> +	int i;
> +
> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> +	if (!dsi->debugfs_vpg)
> +		return;
> +
> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> +
> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> +				    &fops_x32);
> +}
> +
>  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>  {
>  	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>  		return;
>  	}
>  
> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> -			    &dsi->vpg_horizontal);
> +	debugfs_create_files(dsi);
>  }
>  
>  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>  {
>  	debugfs_remove_recursive(dsi->debugfs);
> +	kfree(dsi->debugfs_vpg);
>  }
>  
>  #else
> 

Acked-by: Neil Armstrong <narmstrong@baylibre.com>

Applying to drm-misc-next

Thanks,
Neil

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-09-07  8:09   ` Neil Armstrong
  0 siblings, 0 replies; 30+ messages in thread
From: Neil Armstrong @ 2020-09-07  8:09 UTC (permalink / raw)
  To: Angelo Ribeiro, yannick.fertre, philippe.cornu,
	benjamin.gaignard, airlied, daniel, mcoquelin.stm32,
	alexandre.torgue, dri-devel, linux-stm32, linux-arm-kernel,
	linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi,

On 06/04/2020 15:49, Angelo Ribeiro wrote:
> Add support for the video pattern generator (VPG) BER pattern mode and
> configuration in runtime.
> 
> This enables using the debugfs interface to manipulate the VPG after
> the pipeline is set.
> Also, enables the usage of the VPG BER pattern.
> 
> Changes in v2:
>   - Added VID_MODE_VPG_MODE
>   - Solved incompatible return type on __get and __set
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> Cc: Joao Pinto <jpinto@synopsys.com>
> Cc: Jose Abreu <jose.abreu@synopsys.com>
> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>  1 file changed, 90 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index b18351b..9de3645 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -91,6 +91,7 @@
>  #define VID_MODE_TYPE_BURST			0x2
>  #define VID_MODE_TYPE_MASK			0x3
>  #define VID_MODE_VPG_ENABLE		BIT(16)
> +#define VID_MODE_VPG_MODE		BIT(20)
>  #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>  
>  #define DSI_VID_PKT_SIZE		0x3c
> @@ -221,6 +222,21 @@
>  #define PHY_STATUS_TIMEOUT_US		10000
>  #define CMD_PKT_STATUS_TIMEOUT_US	20000
>  
> +#ifdef CONFIG_DEBUG_FS
> +#define VPG_DEFS(name, dsi) \
> +	((void __force *)&((*dsi).vpg_defs.name))
> +
> +#define REGISTER(name, mask, dsi) \
> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> +
> +struct debugfs_entries {
> +	const char				*name;
> +	bool					*reg;
> +	u32					mask;
> +	struct dw_mipi_dsi			*dsi;
> +};
> +#endif /* CONFIG_DEBUG_FS */
> +
>  struct dw_mipi_dsi {
>  	struct drm_bridge bridge;
>  	struct mipi_dsi_host dsi_host;
> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>  
>  #ifdef CONFIG_DEBUG_FS
>  	struct dentry *debugfs;
> -
> -	bool vpg;
> -	bool vpg_horizontal;
> +	struct debugfs_entries *debugfs_vpg;
> +	struct {
> +		bool vpg;
> +		bool vpg_horizontal;
> +		bool vpg_ber_pattern;
> +	} vpg_defs;
>  #endif /* CONFIG_DEBUG_FS */
>  
>  	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>  		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>  
>  #ifdef CONFIG_DEBUG_FS
> -	if (dsi->vpg) {
> +	if (dsi->vpg_defs.vpg) {
>  		val |= VID_MODE_VPG_ENABLE;
> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_horizontal ?
> +		       VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>  	}
>  #endif /* CONFIG_DEBUG_FS */
>  
> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>  
>  #ifdef CONFIG_DEBUG_FS
>  
> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> +{
> +	struct debugfs_entries *vpg = data;
> +	struct dw_mipi_dsi *dsi;
> +	u32 mode_cfg;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	dsi = vpg->dsi;
> +
> +	*vpg->reg = (bool)val;
> +
> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> +
> +	if (*vpg->reg)
> +		mode_cfg |= vpg->mask;
> +	else
> +		mode_cfg &= ~vpg->mask;
> +
> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> +
> +	return 0;
> +}
> +
> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> +{
> +	struct debugfs_entries *vpg = data;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	*val = *vpg->reg;
> +
> +	return 0;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> +
> +static void debugfs_create_files(void *data)
> +{
> +	struct dw_mipi_dsi *dsi = data;
> +	struct debugfs_entries debugfs[] = {
> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> +	};
> +	int i;
> +
> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> +	if (!dsi->debugfs_vpg)
> +		return;
> +
> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> +
> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> +				    &fops_x32);
> +}
> +
>  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>  {
>  	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>  		return;
>  	}
>  
> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> -			    &dsi->vpg_horizontal);
> +	debugfs_create_files(dsi);
>  }
>  
>  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>  {
>  	debugfs_remove_recursive(dsi->debugfs);
> +	kfree(dsi->debugfs_vpg);
>  }
>  
>  #else
> 

Acked-by: Neil Armstrong <narmstrong@baylibre.com>

Applying to drm-misc-next

Thanks,
Neil

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs
@ 2020-09-07  8:09   ` Neil Armstrong
  0 siblings, 0 replies; 30+ messages in thread
From: Neil Armstrong @ 2020-09-07  8:09 UTC (permalink / raw)
  To: Angelo Ribeiro, yannick.fertre, philippe.cornu,
	benjamin.gaignard, airlied, daniel, mcoquelin.stm32,
	alexandre.torgue, dri-devel, linux-stm32, linux-arm-kernel,
	linux-kernel, pop.adrian61
  Cc: Jose Abreu, Gustavo Pimentel, Joao Pinto

Hi,

On 06/04/2020 15:49, Angelo Ribeiro wrote:
> Add support for the video pattern generator (VPG) BER pattern mode and
> configuration in runtime.
> 
> This enables using the debugfs interface to manipulate the VPG after
> the pipeline is set.
> Also, enables the usage of the VPG BER pattern.
> 
> Changes in v2:
>   - Added VID_MODE_VPG_MODE
>   - Solved incompatible return type on __get and __set
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Reported-by: Adrian Pop <pop.adrian61@gmail.com>
> Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
> Cc: Joao Pinto <jpinto@synopsys.com>
> Cc: Jose Abreu <jose.abreu@synopsys.com>
> Signed-off-by: Angelo Ribeiro <angelo.ribeiro@synopsys.com>
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---
>  1 file changed, 90 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index b18351b..9de3645 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -91,6 +91,7 @@
>  #define VID_MODE_TYPE_BURST			0x2
>  #define VID_MODE_TYPE_MASK			0x3
>  #define VID_MODE_VPG_ENABLE		BIT(16)
> +#define VID_MODE_VPG_MODE		BIT(20)
>  #define VID_MODE_VPG_HORIZONTAL		BIT(24)
>  
>  #define DSI_VID_PKT_SIZE		0x3c
> @@ -221,6 +222,21 @@
>  #define PHY_STATUS_TIMEOUT_US		10000
>  #define CMD_PKT_STATUS_TIMEOUT_US	20000
>  
> +#ifdef CONFIG_DEBUG_FS
> +#define VPG_DEFS(name, dsi) \
> +	((void __force *)&((*dsi).vpg_defs.name))
> +
> +#define REGISTER(name, mask, dsi) \
> +	{ #name, VPG_DEFS(name, dsi), mask, dsi }
> +
> +struct debugfs_entries {
> +	const char				*name;
> +	bool					*reg;
> +	u32					mask;
> +	struct dw_mipi_dsi			*dsi;
> +};
> +#endif /* CONFIG_DEBUG_FS */
> +
>  struct dw_mipi_dsi {
>  	struct drm_bridge bridge;
>  	struct mipi_dsi_host dsi_host;
> @@ -238,9 +254,12 @@ struct dw_mipi_dsi {
>  
>  #ifdef CONFIG_DEBUG_FS
>  	struct dentry *debugfs;
> -
> -	bool vpg;
> -	bool vpg_horizontal;
> +	struct debugfs_entries *debugfs_vpg;
> +	struct {
> +		bool vpg;
> +		bool vpg_horizontal;
> +		bool vpg_ber_pattern;
> +	} vpg_defs;
>  #endif /* CONFIG_DEBUG_FS */
>  
>  	struct dw_mipi_dsi *master; /* dual-dsi master ptr */
> @@ -530,9 +549,11 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
>  		val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
>  
>  #ifdef CONFIG_DEBUG_FS
> -	if (dsi->vpg) {
> +	if (dsi->vpg_defs.vpg) {
>  		val |= VID_MODE_VPG_ENABLE;
> -		val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_horizontal ?
> +		       VID_MODE_VPG_HORIZONTAL : 0;
> +		val |= dsi->vpg_defs.vpg_ber_pattern ? VID_MODE_VPG_MODE : 0;
>  	}
>  #endif /* CONFIG_DEBUG_FS */
>  
> @@ -961,6 +982,68 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
>  
>  #ifdef CONFIG_DEBUG_FS
>  
> +int dw_mipi_dsi_debugfs_write(void *data, u64 val)
> +{
> +	struct debugfs_entries *vpg = data;
> +	struct dw_mipi_dsi *dsi;
> +	u32 mode_cfg;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	dsi = vpg->dsi;
> +
> +	*vpg->reg = (bool)val;
> +
> +	mode_cfg = dsi_read(dsi, DSI_VID_MODE_CFG);
> +
> +	if (*vpg->reg)
> +		mode_cfg |= vpg->mask;
> +	else
> +		mode_cfg &= ~vpg->mask;
> +
> +	dsi_write(dsi, DSI_VID_MODE_CFG, mode_cfg);
> +
> +	return 0;
> +}
> +
> +int dw_mipi_dsi_debugfs_show(void *data, u64 *val)
> +{
> +	struct debugfs_entries *vpg = data;
> +
> +	if (!vpg)
> +		return -ENODEV;
> +
> +	*val = *vpg->reg;
> +
> +	return 0;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(fops_x32, dw_mipi_dsi_debugfs_show,
> +			 dw_mipi_dsi_debugfs_write, "%llu\n");
> +
> +static void debugfs_create_files(void *data)
> +{
> +	struct dw_mipi_dsi *dsi = data;
> +	struct debugfs_entries debugfs[] = {
> +		REGISTER(vpg, VID_MODE_VPG_ENABLE, dsi),
> +		REGISTER(vpg_horizontal, VID_MODE_VPG_HORIZONTAL, dsi),
> +		REGISTER(vpg_ber_pattern, VID_MODE_VPG_MODE, dsi),
> +	};
> +	int i;
> +
> +	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> +	if (!dsi->debugfs_vpg)
> +		return;
> +
> +	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> +
> +	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> +		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> +				    dsi->debugfs, &dsi->debugfs_vpg[i],
> +				    &fops_x32);
> +}
> +
>  static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>  {
>  	dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
> @@ -969,14 +1052,13 @@ static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
>  		return;
>  	}
>  
> -	debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
> -	debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
> -			    &dsi->vpg_horizontal);
> +	debugfs_create_files(dsi);
>  }
>  
>  static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
>  {
>  	debugfs_remove_recursive(dsi->debugfs);
> +	kfree(dsi->debugfs_vpg);
>  }
>  
>  #else
> 

Acked-by: Neil Armstrong <narmstrong@baylibre.com>

Applying to drm-misc-next

Thanks,
Neil
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2020-09-07  8:10 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 13:49 [PATCH v2] drm/bridge: dw-mipi-dsi.c: Add VPG runtime config through debugfs Angelo Ribeiro
2020-04-06 13:49 ` Angelo Ribeiro
2020-04-06 13:49 ` Angelo Ribeiro
2020-04-06 17:45 ` Adrian Pop
2020-04-06 17:45   ` Adrian Pop
2020-04-06 17:45   ` Adrian Pop
2020-04-07  6:58   ` Adrian Pop
2020-04-07  6:58     ` Adrian Pop
2020-04-07  6:58     ` Adrian Pop
2020-04-07 16:38     ` Angelo Ribeiro
2020-04-07 16:38       ` Angelo Ribeiro
2020-04-07 16:38       ` Angelo Ribeiro
2020-06-24 15:35 ` Yannick FERTRE
2020-06-24 15:35   ` Yannick FERTRE
2020-06-24 15:35   ` Yannick FERTRE
2020-07-08 17:08   ` Angelo Ribeiro
2020-07-08 17:08     ` Angelo Ribeiro
2020-07-08 17:08     ` Angelo Ribeiro
2020-07-08 20:29     ` Neil Armstrong
2020-07-08 20:29       ` Neil Armstrong
2020-07-08 20:29       ` Neil Armstrong
2020-07-09  7:56     ` Philippe CORNU
2020-07-09  7:56       ` Philippe CORNU
2020-07-09  7:56       ` Philippe CORNU
2020-07-09  8:51       ` Angelo Ribeiro
2020-07-09  8:51         ` Angelo Ribeiro
2020-07-09  8:51         ` Angelo Ribeiro
2020-09-07  8:09 ` Neil Armstrong
2020-09-07  8:09   ` Neil Armstrong
2020-09-07  8:09   ` Neil Armstrong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.