Skip to contentSkip to conversation

drm/loongson: Introduce component framework support

PATCH Superseded Sui Jingfeng 1 participant 2 messages Jul 11, 2024

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover drm/loongson: Introduce component framework support

In some display subsystems, the functionality of a PCIe device may too complex to be managed by a single driver. A split of the functionality into child devices can help to achieve better modularity. For example, KMS drivers who has a dependency on external modules will suffer from the deferral probe problem of those modules. The problem is that the DRM driver has to tear down everything when it receives '-EPROBE_DEFER', even though the independent part of the entire driver is not very closely related.

For Loongson Graphics, the GPU and the display controller are two distinct PCIe devices. Despite hardware units that come along with PCIe are actually all ready to be driven, DRM driver still need to wait all of its dependency ready before it can register the service to userspace.

The idea is to migrate(offload) the dependency to submodule, creating submodule by creating platform device manually. Such submodules are functional as agents, which will be responsible for attaching needed external modules for the main body of entire KMS drive. It's also for better modularity, as output hardware units are relatively standalone IPs.

Add dummy GPU driver as a subcomponent, use the component framework to bind those scatter software/hardware entities into one. Move DRM-related codes into the loongson_drm_master_bind() function. Move output-related things into the submodule, since the encoder/connector/ transcoder are sometimes depend on external module. The display controller and GPIO-I2Cs go with the PCIe master, as they have no dependency on external modules.

Make lsdc PCI driver as a subcomponent as well, creating a platform device as proxy. The proxy will responsible attach the common drm routines to our hardware, which keep the whole drm driver balanced (and fair) enough for both the DC and GPU.

The lsdc PCI device is the haidden(implicit) parent, while the proxy is the explicit master, which deal with drm related affairs for its parent. The master won't bound until all submodules are ready, submodules are responsible to return '-EPROBE_DEFER' back to the driver core if it needs to do so.

v1 -> v2:
* Squash patch 0002 and patch 0003 into one
* Fill typos and improve commit message

v2 -> v3:
* Squash all patch into one
* Create another platform device as drm proxy master.
* Make LSDC PCI driver as a subcomponent as well.

Tested with ls3a6000+ls7a2000:

[   11.307887] loongson 0000:00:06.1: Found LS7A2000 bridge chipset, revision: 2
[   11.316701] loongson 0000:00:06.1: i2c-6(sda pin mask=1, scl pin mask=2) created
[   11.325318] loongson 0000:00:06.1: i2c-7(sda pin mask=4, scl pin mask=8) created
[   12.644855] loongson 0000:00:06.1: lsdc-output.0 probed, type: HDMI-or-VGA
[   12.654461] loongson 0000:00:06.1: lsdc-output.1 probed, type: HDMI
[   12.661175] loongson 0000:00:06.1: [drm] dc: 400MHz, gmc: 1200MHz, gpu: 480MHz
[   12.669027] loongson loongson: bound lsdc-output.0 (ops lsdc_output_component_ops [loongson])
[   12.677968] loongson loongson: bound lsdc-output.1 (ops lsdc_output_component_ops [loongson])
[   12.686578] loongson 0000:00:06.1: [drm] Dedicated vram start: 0xe0020000000, size: 256MiB
[   12.700799] loongson 0000:00:06.1: lsdc irq: 61
[   12.700802] loongson loongson: bound 0000:00:06.1 (ops lsdc_component_ops [loongson])
[   12.700825] loongson 0000:00:06.1: [drm] LoongGPU(TM): LG110, revision: 0, Host: LS7A2000
[   12.700835] loongson 0000:00:06.1: [drm] LoongGPU irq: 62
[   12.700837] loongson loongson: bound 0000:00:06.0 (ops loonggpu_component_ops [loongson])
[   12.700870] loongson 0000:00:06.1: [drm] Total 2 outputs
[   12.706489] loongson 0000:00:06.1: [drm] VRAM: 16384 pages ready
[   12.746614] loongson 0000:00:06.1: [drm] GTT: 32768 pages ready
[   12.792895] [drm] Initialized loongson 1.0.0 for 0000:00:06.1 on minor 0
[   12.879707] loongson 0000:00:06.1: [drm] fb0: loongsondrmfb frame buffer device
[   16.952830] loongson 0000:00:06.1: vgaarb: VGA decodes changed: olddecodes=io+mem,decodes=none:owns=io+mem

Tested with ls3a5000+ls7a1000:

[   10.603678] loongson 0000:00:06.1: Found LS7A1000 bridge chipset, revision: 1
[   10.616429] loongson 0000:00:06.1: i2c-6(sda pin mask=1, scl pin mask=2) created
[   10.631678] loongson 0000:00:06.1: i2c-7(sda pin mask=4, scl pin mask=8) created
[   10.651926] loongson 0000:00:06.1: lsdc-output.0 probed, type: DVO
[   10.668396] loongson 0000:00:06.1: lsdc-output.1 probed, type: DVO
[   10.705771] loongson 0000:00:06.1: [drm] dc: 264MHz, gmc: 529MHz, gpu: 529MHz
[   10.755928] loongson loongson: bound lsdc-output.0 (ops lsdc_output_component_ops [loongson])
[   10.859777] loongson loongson: bound lsdc-output.1 (ops lsdc_output_component_ops [loongson])
[   10.873062] loongson 0000:00:06.1: [drm] Dedicated vram start: 0xe0030000000, size: 64MiB
[   10.891791] loongson 0000:00:06.1: lsdc irq: 57
[   10.891798] loongson loongson: bound 0000:00:06.1 (ops lsdc_component_ops [loongson])
[   10.891851] loongson 0000:00:06.1: [drm] Total 2 outputs
[   10.910159] loongson 0000:00:06.1: [drm] VRAM: 4096 pages ready
[   10.916131] loongson 0000:00:06.1: [drm] GTT: 32768 pages ready
[   10.922391] [drm] Initialized loongson 1.0.0 for 0000:00:06.1 on minor 0
[  379.378990] Console: switching to colour frame buffer device 128x37
[  379.385261] loongson 0000:00:06.1: [drm] fb0: loongsondrmfb frame buffer device

Sui Jingfeng (1):
drm/loongson: Introduce component framework support

 drivers/gpu/drm/loongson/Makefile             |   5 +
 drivers/gpu/drm/loongson/loonggpu_pci_drv.c   | 156 ++++++++++++
 drivers/gpu/drm/loongson/loonggpu_pci_drv.h   |  33 +++
 drivers/gpu/drm/loongson/loongson_device.c    |   1 +
 drivers/gpu/drm/loongson/loongson_drv.c       | 157 ++++++++++++
 drivers/gpu/drm/loongson/loongson_module.c    |  38 ++-
 drivers/gpu/drm/loongson/loongson_module.h    |  17 ++
 drivers/gpu/drm/loongson/lsdc_drv.c           | 235 ++++++++----------
 drivers/gpu/drm/loongson/lsdc_drv.h           |  56 ++---
 drivers/gpu/drm/loongson/lsdc_i2c.c           |  43 ++--
 drivers/gpu/drm/loongson/lsdc_i2c.h           |  11 +-
 drivers/gpu/drm/loongson/lsdc_irq.c           |  21 +-
 drivers/gpu/drm/loongson/lsdc_output.c        | 208 ++++++++++++++++
 drivers/gpu/drm/loongson/lsdc_output.h        |  36 ++-
 drivers/gpu/drm/loongson/lsdc_output_7a1000.c |   7 +-
 drivers/gpu/drm/loongson/lsdc_output_7a2000.c |  17 +-
 drivers/gpu/drm/loongson/lsdc_ttm.c           |   4 +-
 drivers/gpu/drm/loongson/lsdc_ttm.h           |   2 +-
 18 files changed, 832 insertions(+), 215 deletions(-)
 create mode 100644 drivers/gpu/drm/loongson/loonggpu_pci_drv.c
 create mode 100644 drivers/gpu/drm/loongson/loonggpu_pci_drv.h
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c
 create mode 100644 drivers/gpu/drm/loongson/lsdc_output.c
Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/1 drm/loongson: Introduce component framework support

In some display subsystems, the functionality of a PCIe device may too complex to be managed by a single driver. A split of the functionality into child devices can help to achieve better modularity. For example, KMS drivers who has a dependency on external modules will suffer from the deferral probe problem of those modules. The problem is that the DRM driver has to tear down everything when it receives '-EPROBE_DEFER', even though the independent part of the entire driver is not very closely related.

For Loongson Graphics, the GPU and the display controller are two distinct PCIe devices. Despite hardware units that come along with PCIe are actually all ready to be driven, DRM driver still need to wait all of its dependency ready before it can register the service to userspace.

The idea is to migrate(offload) the dependency to submodule, creating submodule by creating platform device manually. Such submodules are functional as agents, which will be responsible for attaching needed external modules for the main body of entire KMS drive. It's also for better modularity, as output hardware units are relatively standalone IPs.

Add dummy GPU driver as a subcomponent, use the component framework to bind those scatter software/hardware entities into one. Move DRM-related codes into the loongson_drm_master_bind() function. Move output-related things into the submodule, since the encoder/connector/ transcoder are sometimes depend on external module. The display controller and GPIO-I2Cs go with the PCIe master, as they have no dependency on external modules.

Make lsdc PCI driver as a subcomponent as well, creating a platform device as proxy. The proxy will responsible attach the common drm routines to our hardware, which keep the whole drm driver balanced (and fair) enough for both the DC and GPU.

The lsdc PCI device is the haidden(implicit) parent, while the proxy is the explicit master, which deal with drm related affairs for its parent. The master won't bound until all submodules are ready, submodules are responsible to return '-EPROBE_DEFER' back to the driver core if it needs to do so.

---
 drivers/gpu/drm/loongson/Makefile             |   5 +
 drivers/gpu/drm/loongson/loonggpu_pci_drv.c   | 156 ++++++++++++
 drivers/gpu/drm/loongson/loonggpu_pci_drv.h   |  33 +++
 drivers/gpu/drm/loongson/loongson_device.c    |   1 +
 drivers/gpu/drm/loongson/loongson_drv.c       | 157 ++++++++++++
 drivers/gpu/drm/loongson/loongson_module.c    |  38 ++-
 drivers/gpu/drm/loongson/loongson_module.h    |  17 ++
 drivers/gpu/drm/loongson/lsdc_drv.c           | 235 ++++++++----------
 drivers/gpu/drm/loongson/lsdc_drv.h           |  56 ++---
 drivers/gpu/drm/loongson/lsdc_i2c.c           |  43 ++--
 drivers/gpu/drm/loongson/lsdc_i2c.h           |  11 +-
 drivers/gpu/drm/loongson/lsdc_irq.c           |  21 +-
 drivers/gpu/drm/loongson/lsdc_output.c        | 208 ++++++++++++++++
 drivers/gpu/drm/loongson/lsdc_output.h        |  36 ++-
 drivers/gpu/drm/loongson/lsdc_output_7a1000.c |   7 +-
 drivers/gpu/drm/loongson/lsdc_output_7a2000.c |  17 +-
 drivers/gpu/drm/loongson/lsdc_ttm.c           |   4 +-
 drivers/gpu/drm/loongson/lsdc_ttm.h           |   2 +-
 18 files changed, 832 insertions(+), 215 deletions(-)
 create mode 100644 drivers/gpu/drm/loongson/loonggpu_pci_drv.c
 create mode 100644 drivers/gpu/drm/loongson/loonggpu_pci_drv.h
 create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c
 create mode 100644 drivers/gpu/drm/loongson/lsdc_output.c
drivers/gpu/drm/loongson/Makefile +5 -0
index 91e72bd900c1..cdc60ec975e4 100644
@@ -9,6 +9,7 @@ loongson-y := \
 	lsdc_gfxpll.o \
 	lsdc_i2c.o \
 	lsdc_irq.o \
+	lsdc_output.o \
 	lsdc_output_7a1000.o \
 	lsdc_output_7a2000.o \
 	lsdc_plane.o \
@@ -16,7 +17,11 @@ loongson-y := \
 	lsdc_probe.o \
 	lsdc_ttm.o
 
+loongson-y += \
+	loonggpu_pci_drv.o
+
 loongson-y += loongson_device.o \
+	      loongson_drv.o \
 	      loongson_module.o
 
 obj-$(CONFIG_DRM_LOONGSON) += loongson.o
drivers/gpu/drm/loongson/loonggpu_pci_drv.c new file +156 -0

156 lines not on this page · raw message

drivers/gpu/drm/loongson/loonggpu_pci_drv.h new file +33 -0
new file mode 100644
index 000000000000..35b176ff01d0
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef __LOONGGPU_PCI_DRV_H__
+#define __LOONGGPU_PCI_DRV_H__
+
+#include <linux/component.h>
+#include <linux/pci.h>
+
+struct loonggpu_device {
+	struct pci_dev *pdev;
+	struct drm_device *drm;
+
+	void __iomem *reg_base;
+
+	u32 ver_major;
+	u32 ver_minor;
+	u32 revision;
+};
+
+static inline u32 loong_rreg32(struct loonggpu_device *ldev, u32 offset)
+{
+	return readl(ldev->reg_base + offset);
+}
+
+static inline void loong_wreg32(struct loonggpu_device *ldev, u32 offset, u32 val)
+{
+	writel(val, ldev->reg_base + offset);
+}
+
+void loonggpu_pci_match_add(struct device *master,
+			    struct component_match **matchptr);
+
+#endif
drivers/gpu/drm/loongson/loongson_device.c +1 -0
index 9986c8a2a255..f0e3d6544291 100644
@@ -4,6 +4,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/platform_device.h>
 
 #include "lsdc_drv.h"
 
drivers/gpu/drm/loongson/loongson_drv.c new file +157 -0

157 lines not on this page · raw message

drivers/gpu/drm/loongson/loongson_module.c +37 -1
index d2a51bd395f6..836b6a40a9f1 100644
@@ -4,6 +4,7 @@
  */
 
 #include <linux/pci.h>
+#include <linux/platform_device.h>
 
 #include <video/nomodeset.h>
 
@@ -19,15 +20,50 @@ module_param_named(vblank, loongson_vblank, int, 0400);
 
 static int __init loongson_module_init(void)
 {
+	int ret;
+
 	if (!loongson_modeset || video_firmware_drivers_only())
 		return -ENODEV;
 
-	return pci_register_driver(&lsdc_pci_driver);
+	ret = pci_register_driver(&lsdc_pci_driver);
+	if (ret)
+		return ret;
+
+	ret = pci_register_driver(&loonggpu_pci_driver);
+	if (ret)
+		goto unregister_lsdc_pci_driver;
+
+	ret = platform_driver_register(&loongson_drm_platform_driver);
+	if (ret)
+		goto unregister_loonggpu_pci_driver;
+
+	ret = platform_driver_register(&lsdc_output_platform_driver);
+	if (ret)
+		goto unregister_loongson_drm_platform_driver;
+
+	return 0;
+
+unregister_loongson_drm_platform_driver:
+	platform_driver_unregister(&loongson_drm_platform_driver);
+
+unregister_loonggpu_pci_driver:
+	pci_unregister_driver(&loonggpu_pci_driver);
+
+unregister_lsdc_pci_driver:
+	pci_unregister_driver(&lsdc_pci_driver);
+
+	return ret;
 }
 module_init(loongson_module_init);
 
 static void __exit loongson_module_exit(void)
 {
+	platform_driver_unregister(&loongson_drm_platform_driver);
+
 	pci_unregister_driver(&lsdc_pci_driver);
+
+	pci_unregister_driver(&loonggpu_pci_driver);
+
+	platform_driver_unregister(&lsdc_output_platform_driver);
 }
 module_exit(loongson_module_exit);
drivers/gpu/drm/loongson/loongson_module.h +17 -0
index 931c17521bf0..ba29eba2e7ef 100644
@@ -6,7 +6,24 @@
 #ifndef __LOONGSON_MODULE_H__
 #define __LOONGSON_MODULE_H__
 
+#define DRIVER_AUTHOR               "Sui Jingfeng <[email protected]>"
+#define DRIVER_NAME                 "loongson"
+#define DRIVER_DESC                 "drm driver for loongson graphics"
+#define DRIVER_DATE                 "20220701"
+#define DRIVER_MAJOR                1
+#define DRIVER_MINOR                0
+#define DRIVER_PATCHLEVEL           0
+
+enum loongson_chip_id {
+	CHIP_LS7A1000 = 0,
+	CHIP_LS7A2000 = 1,
+	CHIP_LS_LAST,
+};
+
 extern int loongson_vblank;
 extern struct pci_driver lsdc_pci_driver;
+extern struct pci_driver loonggpu_pci_driver;
+extern struct platform_driver lsdc_output_platform_driver;
+extern struct platform_driver loongson_drm_platform_driver;
 
 #endif
drivers/gpu/drm/loongson/lsdc_drv.c +105 -130

349 lines not on this page · raw message

drivers/gpu/drm/loongson/lsdc_drv.h +21 -35

101 lines not on this page · raw message

drivers/gpu/drm/loongson/lsdc_i2c.c +29 -14

95 lines not on this page · raw message

drivers/gpu/drm/loongson/lsdc_i2c.h +6 -5
index 88cd1a1817a5..59ed7f90beac 100644
@@ -9,10 +9,12 @@
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
 
+struct lsdc_device;
+
 struct lsdc_i2c {
 	struct i2c_adapter adapter;
 	struct i2c_algo_bit_data bit;
-	struct drm_device *ddev;
+	struct lsdc_device *lsdc;
 	void __iomem *dir_reg;
 	void __iomem *dat_reg;
 	/* pin bit mask */
@@ -20,10 +22,9 @@ struct lsdc_i2c {
 	u8 scl;
 };
 
-struct lsdc_display_pipe;
+int lsdc_create_i2c_chan(struct device *parent, unsigned int index,
+			 struct i2c_adapter **ppadapter);
 
-int lsdc_create_i2c_chan(struct drm_device *ddev,
-			 struct lsdc_display_pipe *dispipe,
-			 unsigned int index);
+int lsdc_i2c_preinit(struct device *parent);
 
 #endif
drivers/gpu/drm/loongson/lsdc_irq.c +13 -8
index efdc4d10792d..c41b82a6e5cf 100644
@@ -5,6 +5,7 @@
 
 #include <drm/drm_vblank.h>
 
+#include "loongson_module.h"
 #include "lsdc_irq.h"
 
 /*
@@ -35,11 +36,13 @@ irqreturn_t ls7a2000_dc_irq_handler(int irq, void *arg)
 	/* write "1" to clear the interrupt status */
 	lsdc_wreg32(ldev, LSDC_INT_REG, val);
 
-	if (ldev->irq_status & INT_CRTC0_VSYNC)
-		drm_handle_vblank(ddev, 0);
+	if (loongson_vblank) {
+		if (ldev->irq_status & INT_CRTC0_VSYNC)
+			drm_handle_vblank(ddev, 0);
 
-	if (ldev->irq_status & INT_CRTC1_VSYNC)
-		drm_handle_vblank(ddev, 1);
+		if (ldev->irq_status & INT_CRTC1_VSYNC)
+			drm_handle_vblank(ddev, 1);
+	}
 
 	return IRQ_HANDLED;
 }
@@ -64,11 +67,13 @@ irqreturn_t ls7a1000_dc_irq_handler(int irq, void *arg)
 	val &= ~(INT_CRTC0_VSYNC | INT_CRTC1_VSYNC);
 	lsdc_wreg32(ldev, LSDC_INT_REG, val);
 
-	if (ldev->irq_status & INT_CRTC0_VSYNC)
-		drm_handle_vblank(ddev, 0);
+	if (loongson_vblank) {
+		if (ldev->irq_status & INT_CRTC0_VSYNC)
+			drm_handle_vblank(ddev, 0);
 
-	if (ldev->irq_status & INT_CRTC1_VSYNC)
-		drm_handle_vblank(ddev, 1);
+		if (ldev->irq_status & INT_CRTC1_VSYNC)
+			drm_handle_vblank(ddev, 1);
+	}
 
 	return IRQ_HANDLED;
 }
drivers/gpu/drm/loongson/lsdc_output.c new file +208 -0

208 lines not on this page · raw message

drivers/gpu/drm/loongson/lsdc_output.h +33 -3
index 097789051a1d..c7f0933695af 100644
@@ -6,16 +6,46 @@
 #ifndef __LSDC_OUTPUT_H__
 #define __LSDC_OUTPUT_H__
 
-#include "lsdc_drv.h"
+#include <linux/component.h>
+
+#include <drm/drm_encoder.h>
+#include <drm/drm_connector.h>
+
+struct lsdc_desc;
+
+struct lsdc_output {
+	struct device *dev;
+	struct drm_encoder encoder;
+	struct drm_connector connector;
+	unsigned int pipe;
+};
+
+static inline struct lsdc_output *
+connector_to_lsdc_output(struct drm_connector *connector)
+{
+	return container_of(connector, struct lsdc_output, connector);
+}
+
+static inline struct lsdc_output *
+encoder_to_lsdc_output(struct drm_encoder *encoder)
+{
+	return container_of(encoder, struct lsdc_output, encoder);
+}
 
 int ls7a1000_output_init(struct drm_device *ddev,
-			 struct lsdc_display_pipe *dispipe,
+			 struct lsdc_output *output,
 			 struct i2c_adapter *ddc,
 			 unsigned int index);
 
 int ls7a2000_output_init(struct drm_device *ldev,
-			 struct lsdc_display_pipe *dispipe,
+			 struct lsdc_output *output,
 			 struct i2c_adapter *ddc,
 			 unsigned int index);
 
+int lsdc_output_preinit(struct device *parent,
+			const struct lsdc_desc *descp);
+
+void lsdc_output_match_add(struct device *parent,
+			   struct component_match **matchptr);
+
 #endif
drivers/gpu/drm/loongson/lsdc_output_7a1000.c +3 -4
index 6fc8dd1c7d9a..edb78a19949f 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2023 Loongson Technology Corporation Limited
  */
 
+#include <linux/property.h>
+
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_probe_helper.h>
@@ -140,11 +142,10 @@ static const struct drm_encoder_funcs ls7a1000_encoder_funcs[2] = {
 };
 
 int ls7a1000_output_init(struct drm_device *ddev,
-			 struct lsdc_display_pipe *dispipe,
+			 struct lsdc_output *output,
 			 struct i2c_adapter *ddc,
 			 unsigned int index)
 {
-	struct lsdc_output *output = &dispipe->output;
 	struct drm_encoder *encoder = &output->encoder;
 	struct drm_connector *connector = &output->connector;
 	int ret;
@@ -162,8 +163,6 @@ int ls7a1000_output_init(struct drm_device *ddev,
 	if (ret)
 		return ret;
 
-	drm_info(ddev, "display pipe-%u has a DVO\n", index);
-
 	drm_connector_helper_add(connector, &ls7a1000_dpi_connector_helpers);
 
 	drm_connector_attach_encoder(connector, encoder);
drivers/gpu/drm/loongson/lsdc_output_7a2000.c +5 -12
index ce3dabec887e..c0e18cf85f5b 100644
@@ -284,8 +284,7 @@ static int ls7a2000_hdmi_set_avi_infoframe(struct drm_encoder *encoder,
 					   struct drm_display_mode *mode)
 {
 	struct lsdc_output *output = encoder_to_lsdc_output(encoder);
-	struct lsdc_display_pipe *dispipe = output_to_display_pipe(output);
-	unsigned int index = dispipe->index;
+	unsigned int index = output->pipe;
 	struct drm_device *ddev = encoder->dev;
 	struct lsdc_device *ldev = to_lsdc(ddev);
 	struct hdmi_avi_infoframe infoframe;
@@ -335,8 +334,7 @@ static void ls7a2000_hdmi_atomic_disable(struct drm_encoder *encoder,
 					 struct drm_atomic_state *state)
 {
 	struct lsdc_output *output = encoder_to_lsdc_output(encoder);
-	struct lsdc_display_pipe *dispipe = output_to_display_pipe(output);
-	unsigned int index = dispipe->index;
+	unsigned int index = output->pipe;
 	struct drm_device *ddev = encoder->dev;
 	struct lsdc_device *ldev = to_lsdc(ddev);
 	u32 val;
@@ -360,8 +358,7 @@ static void ls7a2000_hdmi_atomic_enable(struct drm_encoder *encoder,
 	struct drm_device *ddev = encoder->dev;
 	struct lsdc_device *ldev = to_lsdc(ddev);
 	struct lsdc_output *output = encoder_to_lsdc_output(encoder);
-	struct lsdc_display_pipe *dispipe = output_to_display_pipe(output);
-	unsigned int index = dispipe->index;
+	unsigned int index = output->pipe;
 	u32 val;
 
 	/* datasheet say it should larger than 48 */
@@ -482,8 +479,7 @@ static void ls7a2000_hdmi_atomic_mode_set(struct drm_encoder *encoder,
 					  struct drm_connector_state *conn_state)
 {
 	struct lsdc_output *output = encoder_to_lsdc_output(encoder);
-	struct lsdc_display_pipe *dispipe = output_to_display_pipe(output);
-	unsigned int index = dispipe->index;
+	unsigned int index = output->pipe;
 	struct drm_device *ddev = encoder->dev;
 	struct lsdc_device *ldev = to_lsdc(ddev);
 	struct drm_display_mode *mode = &crtc_state->mode;
@@ -512,11 +508,10 @@ static const struct drm_encoder_helper_funcs ls7a2000_encoder_helper_funcs = {
  * writing hdmi register do no harms.
  */
 int ls7a2000_output_init(struct drm_device *ddev,
-			 struct lsdc_display_pipe *dispipe,
+			 struct lsdc_output *output,
 			 struct i2c_adapter *ddc,
 			 unsigned int pipe)
 {
-	struct lsdc_output *output = &dispipe->output;
 	struct drm_encoder *encoder = &output->encoder;
 	struct drm_connector *connector = &output->connector;
 	int ret;
@@ -536,8 +531,6 @@ int ls7a2000_output_init(struct drm_device *ddev,
 	if (ret)
 		return ret;
 
-	drm_info(ddev, "display pipe-%u has HDMI %s\n", pipe, pipe ? "" : "and/or VGA");
-
 	drm_connector_helper_add(connector, &ls7a2000_connector_helpers);
 
 	drm_connector_attach_encoder(connector, encoder);
drivers/gpu/drm/loongson/lsdc_ttm.c +2 -2
index 465f622ac05d..72f51993d678 100644
@@ -539,9 +539,9 @@ static void lsdc_ttm_fini(struct drm_device *ddev, void *data)
 	drm_dbg(ddev, "ttm finished\n");
 }
 
-int lsdc_ttm_init(struct lsdc_device *ldev)
+int lsdc_ttm_init(struct drm_device *ddev)
 {
-	struct drm_device *ddev = &ldev->base;
+	struct lsdc_device *ldev = to_lsdc(ddev);
 	unsigned long num_vram_pages;
 	unsigned long num_gtt_pages;
 	int ret;
drivers/gpu/drm/loongson/lsdc_ttm.h +1 -1
index 843e1475064e..064cf497e090 100644
@@ -93,7 +93,7 @@ void lsdc_bo_clear(struct lsdc_bo *lbo);
 
 int lsdc_bo_evict_vram(struct drm_device *ddev);
 
-int lsdc_ttm_init(struct lsdc_device *ldev);
+int lsdc_ttm_init(struct drm_device *ddev);
 void lsdc_ttm_debugfs_init(struct lsdc_device *ldev);
 
 #endif
Signature · 1 line
2.43.0