Skip to contentSkip to conversation

drm/mediatek: mtk_dpi: Open-code drm_simple_encoder_init()

PATCH Applied Shivam Kalra 4 participants 4 messages Apr 3 – May 13

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/mediatek: mtk_dpi: Open-code drm_simple_encoder_init()

The helper drm_simple_encoder_init() is a trivial wrapper around drm_encoder_init() that only provides a static drm_encoder_funcs with .destroy set to drm_encoder_cleanup(). Open-code the initialization with a driver-specific instance of drm_encoder_funcs and remove the dependency on drm_simple_kms_helper.

---
Addresses the "Open-code drm_simple_encoder_init()" task from Documentation/gpu/todo.rst.

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +7 -3
index 53360b5d12ba..5b83ca6aecb2 100644
@@ -25,8 +25,8 @@
 #include <drm/drm_bridge_connector.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_encoder.h>
 #include <drm/drm_of.h>
-#include <drm/drm_simple_kms_helper.h>
 
 #include "mtk_ddp_comp.h"
 #include "mtk_disp_drv.h"
@@ -993,6 +993,10 @@ static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
 	.debugfs_init = mtk_dpi_debugfs_init,
 };
 
+static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
 void mtk_dpi_start(struct device *dev)
 {
 	struct mtk_dpi *dpi = dev_get_drvdata(dev);
@@ -1026,8 +1030,8 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
 	int ret;
 
 	dpi->mmsys_dev = priv->mmsys_dev;
-	ret = drm_simple_encoder_init(drm_dev, &dpi->encoder,
-				      DRM_MODE_ENCODER_TMDS);
+	ret = drm_encoder_init(drm_dev, &dpi->encoder, &mtk_dpi_encoder_funcs,
+			       DRM_MODE_ENCODER_TMDS, NULL);
 	if (ret) {
 		dev_err(dev, "Failed to initialize decoder: %d\n", ret);
 		return ret;

---
base-commit: 4b9c36c83b34f710da9573291404f6a2246251c1
change-id: 20260403-drm-mediatek-opencode-encoder-init-36336e4c4ff3

Best regards,

Signature · 1 line
Shivam Kalra <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw

Am 03.04.26 um 14:00 schrieb Shivam Kalra via B4 Relay:

Quoted 10 lines

From: Shivam Kalra <[email protected]>

The helper drm_simple_encoder_init() is a trivial wrapper around drm_encoder_init() that only provides a static drm_encoder_funcs with .destroy set to drm_encoder_cleanup(). Open-code the initialization with a driver-specific instance of drm_encoder_funcs and remove the dependency on drm_simple_kms_helper.

Looks good.

Quoted 53 lines

---
Addresses the "Open-code drm_simple_encoder_init()" task from Documentation/gpu/todo.rst.

---
  drivers/gpu/drm/mediatek/mtk_dpi.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +7 -4
index 53360b5d12ba..5b83ca6aecb2 100644
@@ -25,8 +25,8 @@
  #include <drm/drm_bridge_connector.h>
  #include <drm/drm_crtc.h>
  #include <drm/drm_edid.h>
+#include <drm/drm_encoder.h>
  #include <drm/drm_of.h>
-#include <drm/drm_simple_kms_helper.h>
 
  #include "mtk_ddp_comp.h"
  #include "mtk_disp_drv.h"
@@ -993,6 +993,10 @@ static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
  	.debugfs_init = mtk_dpi_debugfs_init,
  };
 
+static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
  void mtk_dpi_start(struct device *dev)
  {
  	struct mtk_dpi *dpi = dev_get_drvdata(dev);
@@ -1026,8 +1030,8 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
  	int ret;
 
  	dpi->mmsys_dev = priv->mmsys_dev;
-	ret = drm_simple_encoder_init(drm_dev, &dpi->encoder,
-				      DRM_MODE_ENCODER_TMDS);
+	ret = drm_encoder_init(drm_dev, &dpi->encoder, &mtk_dpi_encoder_funcs,
+			       DRM_MODE_ENCODER_TMDS, NULL);
  	if (ret) {
  		dev_err(dev, "Failed to initialize decoder: %d\n", ret);
  		return ret;
 
---

base-commit: 4b9c36c83b34f710da9573291404f6a2246251c1
change-id: 20260403-drm-mediatek-opencode-encoder-init-36336e4c4ff3

Best regards,
--
Shivam Kalra <[email protected]>

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Shivam Kalra
Quoted 7 lines · On Fri, 2026-04-03 at 17:30 +0530, Shivam Kalra via B4 Relay wrote:

From: Shivam Kalra <[email protected]>

The helper drm_simple_encoder_init() is a trivial wrapper around drm_encoder_init() that only provides a static drm_encoder_funcs with .destroy set to drm_encoder_cleanup(). Open-code the initialization with a driver-specific instance of drm_encoder_funcs and remove the dependency on drm_simple_kms_helper.

Quoted 56 lines

---
Addresses the "Open-code drm_simple_encoder_init()" task from Documentation/gpu/todo.rst.

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +7 -4
index 53360b5d12ba..5b83ca6aecb2 100644
@@ -25,8 +25,8 @@
 #include <drm/drm_bridge_connector.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_encoder.h>
 #include <drm/drm_of.h>
-#include <drm/drm_simple_kms_helper.h>
 
 #include "mtk_ddp_comp.h"
 #include "mtk_disp_drv.h"
@@ -993,6 +993,10 @@ static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
 	.debugfs_init = mtk_dpi_debugfs_init,
 };
 
+static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
 void mtk_dpi_start(struct device *dev)
 {
 	struct mtk_dpi *dpi = dev_get_drvdata(dev);
@@ -1026,8 +1030,8 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
 	int ret;
 
 	dpi->mmsys_dev = priv->mmsys_dev;
-	ret = drm_simple_encoder_init(drm_dev, &dpi->encoder,
-				      DRM_MODE_ENCODER_TMDS);
+	ret = drm_encoder_init(drm_dev, &dpi->encoder, &mtk_dpi_encoder_funcs,
+			       DRM_MODE_ENCODER_TMDS, NULL);
 	if (ret) {
 		dev_err(dev, "Failed to initialize decoder: %d\n", ret);
 		return ret;
 
---

base-commit: 4b9c36c83b34f710da9573291404f6a2246251c1
change-id: 20260403-drm-mediatek-opencode-encoder-init-36336e4c4ff3

Best regards,

Signature · 1 line
Shivam Kalra <[email protected]>
maintainer Applied
#3 lore raw
In reply to Shivam Kalra

Hi, Shivam:

Shivam Kalra via B4 Relay <[email protected]> 於 2026年4月3日週五 下午12:00寫道:

Quoted 8 lines

From: Shivam Kalra <[email protected]>

The helper drm_simple_encoder_init() is a trivial wrapper around drm_encoder_init() that only provides a static drm_encoder_funcs with .destroy set to drm_encoder_cleanup(). Open-code the initialization with a driver-specific instance of drm_encoder_funcs and remove the dependency on drm_simple_kms_helper.

Applied to mediatek-drm-next [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

Quoted 56 lines

---
Addresses the "Open-code drm_simple_encoder_init()" task from Documentation/gpu/todo.rst.

---
 drivers/gpu/drm/mediatek/mtk_dpi.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +7 -4
index 53360b5d12ba..5b83ca6aecb2 100644
@@ -25,8 +25,8 @@
 #include <drm/drm_bridge_connector.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_encoder.h>
 #include <drm/drm_of.h>
-#include <drm/drm_simple_kms_helper.h>
 
 #include "mtk_ddp_comp.h"
 #include "mtk_disp_drv.h"
@@ -993,6 +993,10 @@ static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
        .debugfs_init = mtk_dpi_debugfs_init,
 };
 
+static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = {
+       .destroy = drm_encoder_cleanup,
+};
+
 void mtk_dpi_start(struct device *dev)
 {
        struct mtk_dpi *dpi = dev_get_drvdata(dev);
@@ -1026,8 +1030,8 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
        int ret;
 
        dpi->mmsys_dev = priv->mmsys_dev;
-       ret = drm_simple_encoder_init(drm_dev, &dpi->encoder,
-                                     DRM_MODE_ENCODER_TMDS);
+       ret = drm_encoder_init(drm_dev, &dpi->encoder, &mtk_dpi_encoder_funcs,
+                              DRM_MODE_ENCODER_TMDS, NULL);
        if (ret) {
                dev_err(dev, "Failed to initialize decoder: %d\n", ret);
                return ret;
 
---

base-commit: 4b9c36c83b34f710da9573291404f6a2246251c1
change-id: 20260403-drm-mediatek-opencode-encoder-init-36336e4c4ff3

Best regards,
--
Shivam Kalra <[email protected]>