[18/22] drm/vc4: Use simple encoder
diff mbox series

Message ID 20200305155950.2705-19-tzimmermann@suse.de
State Not Applicable
Headers show
Series
  • drm: Convert drivers to drm_simple_encoder_init()
Related show

Commit Message

Thomas Zimmermann March 5, 2020, 3:59 p.m. UTC
The vc4 driver uses empty implementations for its encoders. Replace
the code with the generic simple encoder.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/vc4/vc4_dpi.c  |  8 ++------
 drivers/gpu/drm/vc4/vc4_dsi.c  | 15 +++------------
 drivers/gpu/drm/vc4/vc4_hdmi.c | 17 ++++-------------
 drivers/gpu/drm/vc4/vc4_vec.c  |  8 ++------
 4 files changed, 11 insertions(+), 37 deletions(-)

Comments

Eric Anholt March 5, 2020, 5:03 p.m. UTC | #1
On Thu, Mar 5, 2020 at 8:00 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> The vc4 driver uses empty implementations for its encoders. Replace
> the code with the generic simple encoder.

Acked-by: Eric Anholt <eric@anholt.net>
kbuild test robot March 6, 2020, 1:54 p.m. UTC | #2
Hi Thomas,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20200305]
[cannot apply to rockchip/for-next shawnguo/for-next sunxi/sunxi/for-next tegra/for-next linus/master v5.6-rc4 v5.6-rc3 v5.6-rc2 v5.6-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Convert-drivers-to-drm_simple_encoder_init/20200306-045931
base:    47466dcf84ee66a973ea7d2fca7e582fe9328932
config: arm64-defconfig (attached as .config)
compiler: clang version 11.0.0 (git://gitmirror/llvm_project a0cd413426479abb207381bdbab862f3dfb3ce7d)
reproduce:
        # FIXME the reproduce steps for clang is not ready yet

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/gpu//drm/vc4/vc4_dpi.c:309:2: error: implicit declaration of function 'drm_simple_encoder_init' [-Werror,-Wimplicit-function-declaration]
           drm_simple_encoder_init(drm, dpi->encoder, DRM_MODE_ENCODER_DPI);
           ^
   drivers/gpu//drm/vc4/vc4_dpi.c:309:2: note: did you mean 'drm_encoder_init'?
   include/drm/drm_encoder.h:189:5: note: 'drm_encoder_init' declared here
   int drm_encoder_init(struct drm_device *dev,
       ^
   1 error generated.
--
>> drivers/gpu//drm/vc4/vc4_dsi.c:1610:2: error: implicit declaration of function 'drm_simple_encoder_init' [-Werror,-Wimplicit-function-declaration]
           drm_simple_encoder_init(drm, dsi->encoder, DRM_MODE_ENCODER_DSI);
           ^
   drivers/gpu//drm/vc4/vc4_dsi.c:1610:2: note: did you mean 'drm_encoder_init'?
   include/drm/drm_encoder.h:189:5: note: 'drm_encoder_init' declared here
   int drm_encoder_init(struct drm_device *dev,
       ^
   1 error generated.
--
>> drivers/gpu//drm/vc4/vc4_hdmi.c:1389:2: error: implicit declaration of function 'drm_simple_encoder_init' [-Werror,-Wimplicit-function-declaration]
           drm_simple_encoder_init(drm, hdmi->encoder, DRM_MODE_ENCODER_TMDS);
           ^
   drivers/gpu//drm/vc4/vc4_hdmi.c:1389:2: note: did you mean 'drm_encoder_init'?
   include/drm/drm_encoder.h:189:5: note: 'drm_encoder_init' declared here
   int drm_encoder_init(struct drm_device *dev,
       ^
   1 error generated.
--
>> drivers/gpu//drm/vc4/vc4_vec.c:566:2: error: implicit declaration of function 'drm_simple_encoder_init' [-Werror,-Wimplicit-function-declaration]
           drm_simple_encoder_init(drm, vec->encoder, DRM_MODE_ENCODER_TVDAC);
           ^
   drivers/gpu//drm/vc4/vc4_vec.c:566:2: note: did you mean 'drm_encoder_init'?
   include/drm/drm_encoder.h:189:5: note: 'drm_encoder_init' declared here
   int drm_encoder_init(struct drm_device *dev,
       ^
   1 error generated.

vim +/drm_simple_encoder_init +309 drivers/gpu//drm/vc4/vc4_dpi.c

   254	
   255	static int vc4_dpi_bind(struct device *dev, struct device *master, void *data)
   256	{
   257		struct platform_device *pdev = to_platform_device(dev);
   258		struct drm_device *drm = dev_get_drvdata(master);
   259		struct vc4_dev *vc4 = to_vc4_dev(drm);
   260		struct vc4_dpi *dpi;
   261		struct vc4_dpi_encoder *vc4_dpi_encoder;
   262		int ret;
   263	
   264		dpi = devm_kzalloc(dev, sizeof(*dpi), GFP_KERNEL);
   265		if (!dpi)
   266			return -ENOMEM;
   267	
   268		vc4_dpi_encoder = devm_kzalloc(dev, sizeof(*vc4_dpi_encoder),
   269					       GFP_KERNEL);
   270		if (!vc4_dpi_encoder)
   271			return -ENOMEM;
   272		vc4_dpi_encoder->base.type = VC4_ENCODER_TYPE_DPI;
   273		vc4_dpi_encoder->dpi = dpi;
   274		dpi->encoder = &vc4_dpi_encoder->base.base;
   275	
   276		dpi->pdev = pdev;
   277		dpi->regs = vc4_ioremap_regs(pdev, 0);
   278		if (IS_ERR(dpi->regs))
   279			return PTR_ERR(dpi->regs);
   280		dpi->regset.base = dpi->regs;
   281		dpi->regset.regs = dpi_regs;
   282		dpi->regset.nregs = ARRAY_SIZE(dpi_regs);
   283	
   284		if (DPI_READ(DPI_ID) != DPI_ID_VALUE) {
   285			dev_err(dev, "Port returned 0x%08x for ID instead of 0x%08x\n",
   286				DPI_READ(DPI_ID), DPI_ID_VALUE);
   287			return -ENODEV;
   288		}
   289	
   290		dpi->core_clock = devm_clk_get(dev, "core");
   291		if (IS_ERR(dpi->core_clock)) {
   292			ret = PTR_ERR(dpi->core_clock);
   293			if (ret != -EPROBE_DEFER)
   294				DRM_ERROR("Failed to get core clock: %d\n", ret);
   295			return ret;
   296		}
   297		dpi->pixel_clock = devm_clk_get(dev, "pixel");
   298		if (IS_ERR(dpi->pixel_clock)) {
   299			ret = PTR_ERR(dpi->pixel_clock);
   300			if (ret != -EPROBE_DEFER)
   301				DRM_ERROR("Failed to get pixel clock: %d\n", ret);
   302			return ret;
   303		}
   304	
   305		ret = clk_prepare_enable(dpi->core_clock);
   306		if (ret)
   307			DRM_ERROR("Failed to turn on core clock: %d\n", ret);
   308	
 > 309		drm_simple_encoder_init(drm, dpi->encoder, DRM_MODE_ENCODER_DPI);
   310		drm_encoder_helper_add(dpi->encoder, &vc4_dpi_encoder_helper_funcs);
   311	
   312		ret = vc4_dpi_init_bridge(dpi);
   313		if (ret)
   314			goto err_destroy_encoder;
   315	
   316		dev_set_drvdata(dev, dpi);
   317	
   318		vc4->dpi = dpi;
   319	
   320		vc4_debugfs_add_regset32(drm, "dpi_regs", &dpi->regset);
   321	
   322		return 0;
   323	
   324	err_destroy_encoder:
   325		drm_encoder_cleanup(dpi->encoder);
   326		clk_disable_unprepare(dpi->core_clock);
   327		return ret;
   328	}
   329	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Patch
diff mbox series

diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index 6dfede03396e..a90f2545baee 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -17,6 +17,7 @@ 
 #include <drm/drm_of.h>
 #include <drm/drm_panel.h>
 #include <drm/drm_probe_helper.h>
+#include <drm/drm_simple_kms_helper.h>
 #include <linux/clk.h>
 #include <linux/component.h>
 #include <linux/of_graph.h>
@@ -114,10 +115,6 @@  static const struct debugfs_reg32 dpi_regs[] = {
 	VC4_REG32(DPI_ID),
 };
 
-static const struct drm_encoder_funcs vc4_dpi_encoder_funcs = {
-	.destroy = drm_encoder_cleanup,
-};
-
 static void vc4_dpi_encoder_disable(struct drm_encoder *encoder)
 {
 	struct vc4_dpi_encoder *vc4_encoder = to_vc4_dpi_encoder(encoder);
@@ -309,8 +306,7 @@  static int vc4_dpi_bind(struct device *dev, struct device *master, void *data)
 	if (ret)
 		DRM_ERROR("Failed to turn on core clock: %d\n", ret);
 
-	drm_encoder_init(drm, dpi->encoder, &vc4_dpi_encoder_funcs,
-			 DRM_MODE_ENCODER_DPI, NULL);
+	drm_simple_encoder_init(drm, dpi->encoder, DRM_MODE_ENCODER_DPI);
 	drm_encoder_helper_add(dpi->encoder, &vc4_dpi_encoder_helper_funcs);
 
 	ret = vc4_dpi_init_bridge(dpi);
diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
index d99b1d526651..eaf276978ee7 100644
--- a/drivers/gpu/drm/vc4/vc4_dsi.c
+++ b/drivers/gpu/drm/vc4/vc4_dsi.c
@@ -37,6 +37,7 @@ 
 #include <drm/drm_of.h>
 #include <drm/drm_panel.h>
 #include <drm/drm_probe_helper.h>
+#include <drm/drm_simple_kms_helper.h>
 
 #include "vc4_drv.h"
 #include "vc4_regs.h"
@@ -652,15 +653,6 @@  static const struct debugfs_reg32 dsi1_regs[] = {
 	VC4_REG32(DSI1_ID),
 };
 
-static void vc4_dsi_encoder_destroy(struct drm_encoder *encoder)
-{
-	drm_encoder_cleanup(encoder);
-}
-
-static const struct drm_encoder_funcs vc4_dsi_encoder_funcs = {
-	.destroy = vc4_dsi_encoder_destroy,
-};
-
 static void vc4_dsi_latch_ulps(struct vc4_dsi *dsi, bool latch)
 {
 	u32 afec0 = DSI_PORT_READ(PHY_AFEC0);
@@ -1615,8 +1607,7 @@  static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
 	if (dsi->port == 1)
 		vc4->dsi1 = dsi;
 
-	drm_encoder_init(drm, dsi->encoder, &vc4_dsi_encoder_funcs,
-			 DRM_MODE_ENCODER_DSI, NULL);
+	drm_simple_encoder_init(drm, dsi->encoder, DRM_MODE_ENCODER_DSI);
 	drm_encoder_helper_add(dsi->encoder, &vc4_dsi_encoder_helper_funcs);
 
 	ret = drm_bridge_attach(dsi->encoder, dsi->bridge, NULL, 0);
@@ -1656,7 +1647,7 @@  static void vc4_dsi_unbind(struct device *dev, struct device *master,
 	 * normally.
 	 */
 	list_splice_init(&dsi->bridge_chain, &dsi->encoder->bridge_chain);
-	vc4_dsi_encoder_destroy(dsi->encoder);
+	drm_encoder_cleanup(dsi->encoder);
 
 	if (dsi->port == 1)
 		vc4->dsi1 = NULL;
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index cea18dc15f77..8f956156eb8e 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -34,6 +34,7 @@ 
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_probe_helper.h>
+#include <drm/drm_simple_kms_helper.h>
 #include <linux/clk.h>
 #include <linux/component.h>
 #include <linux/i2c.h>
@@ -306,15 +307,6 @@  static struct drm_connector *vc4_hdmi_connector_init(struct drm_device *dev,
 	return connector;
 }
 
-static void vc4_hdmi_encoder_destroy(struct drm_encoder *encoder)
-{
-	drm_encoder_cleanup(encoder);
-}
-
-static const struct drm_encoder_funcs vc4_hdmi_encoder_funcs = {
-	.destroy = vc4_hdmi_encoder_destroy,
-};
-
 static int vc4_hdmi_stop_packet(struct drm_encoder *encoder,
 				enum hdmi_infoframe_type type)
 {
@@ -1394,8 +1386,7 @@  static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
 	}
 	pm_runtime_enable(dev);
 
-	drm_encoder_init(drm, hdmi->encoder, &vc4_hdmi_encoder_funcs,
-			 DRM_MODE_ENCODER_TMDS, NULL);
+	drm_simple_encoder_init(drm, hdmi->encoder, DRM_MODE_ENCODER_TMDS);
 	drm_encoder_helper_add(hdmi->encoder, &vc4_hdmi_encoder_helper_funcs);
 
 	hdmi->connector =
@@ -1453,7 +1444,7 @@  static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
 	vc4_hdmi_connector_destroy(hdmi->connector);
 #endif
 err_destroy_encoder:
-	vc4_hdmi_encoder_destroy(hdmi->encoder);
+	drm_encoder_cleanup(hdmi->encoder);
 err_unprepare_hsm:
 	clk_disable_unprepare(hdmi->hsm_clock);
 	pm_runtime_disable(dev);
@@ -1472,7 +1463,7 @@  static void vc4_hdmi_unbind(struct device *dev, struct device *master,
 
 	cec_unregister_adapter(hdmi->cec_adap);
 	vc4_hdmi_connector_destroy(hdmi->connector);
-	vc4_hdmi_encoder_destroy(hdmi->encoder);
+	drm_encoder_cleanup(hdmi->encoder);
 
 	clk_disable_unprepare(hdmi->hsm_clock);
 	pm_runtime_disable(dev);
diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c
index 7402bc768664..bd5b8eb58b18 100644
--- a/drivers/gpu/drm/vc4/vc4_vec.c
+++ b/drivers/gpu/drm/vc4/vc4_vec.c
@@ -17,6 +17,7 @@ 
 #include <drm/drm_edid.h>
 #include <drm/drm_panel.h>
 #include <drm/drm_probe_helper.h>
+#include <drm/drm_simple_kms_helper.h>
 #include <linux/clk.h>
 #include <linux/component.h>
 #include <linux/of_graph.h>
@@ -374,10 +375,6 @@  static struct drm_connector *vc4_vec_connector_init(struct drm_device *dev,
 	return connector;
 }
 
-static const struct drm_encoder_funcs vc4_vec_encoder_funcs = {
-	.destroy = drm_encoder_cleanup,
-};
-
 static void vc4_vec_encoder_disable(struct drm_encoder *encoder)
 {
 	struct vc4_vec_encoder *vc4_vec_encoder = to_vc4_vec_encoder(encoder);
@@ -566,8 +563,7 @@  static int vc4_vec_bind(struct device *dev, struct device *master, void *data)
 
 	pm_runtime_enable(dev);
 
-	drm_encoder_init(drm, vec->encoder, &vc4_vec_encoder_funcs,
-			 DRM_MODE_ENCODER_TVDAC, NULL);
+	drm_simple_encoder_init(drm, vec->encoder, DRM_MODE_ENCODER_TVDAC);
 	drm_encoder_helper_add(vec->encoder, &vc4_vec_encoder_helper_funcs);
 
 	vec->connector = vc4_vec_connector_init(drm, vec);