drm: xlnx: zynqmp_dpsub: Move DRM/KMS initialization to separate file
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 28 Sep 2022 21:25:56 +0000 (00:25 +0300)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 19 Oct 2022 13:51:04 +0000 (16:51 +0300)
Start preparation for using the DPSUB as a standalone DisplayPort
encoder without a display controller by moving the DRM/KMS
initialization to a new zynqmp_kms.c file. No functional change
intended.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
drivers/gpu/drm/xlnx/Makefile
drivers/gpu/drm/xlnx/zynqmp_dpsub.c
drivers/gpu/drm/xlnx/zynqmp_kms.c [new file with mode: 0644]
drivers/gpu/drm/xlnx/zynqmp_kms.h [new file with mode: 0644]

index 51c24b7..ea1422a 100644 (file)
@@ -1,2 +1,2 @@
-zynqmp-dpsub-y := zynqmp_disp.o zynqmp_dpsub.o zynqmp_dp.o
+zynqmp-dpsub-y := zynqmp_disp.o zynqmp_dpsub.o zynqmp_dp.o zynqmp_kms.o
 obj-$(CONFIG_DRM_ZYNQMP_DPSUB) += zynqmp-dpsub.o
index 6d60efb..5d61f6c 100644 (file)
@@ -17,9 +17,7 @@
 #include <linux/pm_runtime.h>
 
 #include <drm/drm_atomic_helper.h>
-#include <drm/drm_bridge.h>
 #include <drm/drm_bridge_connector.h>
-#include <drm/drm_connector.h>
 #include <drm/drm_device.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_mode_config.h>
 #include <drm/drm_module.h>
 #include <drm/drm_probe_helper.h>
-#include <drm/drm_simple_kms_helper.h>
 #include <drm/drm_vblank.h>
 
 #include "zynqmp_disp.h"
 #include "zynqmp_dp.h"
 #include "zynqmp_dpsub.h"
+#include "zynqmp_kms.h"
 
 /* -----------------------------------------------------------------------------
  * Dumb Buffer & Framebuffer Allocation
@@ -98,8 +96,6 @@ static const struct drm_driver zynqmp_dpsub_drm_driver = {
 
 static int zynqmp_dpsub_drm_init(struct zynqmp_dpsub *dpsub)
 {
-       struct drm_encoder *encoder = &dpsub->encoder;
-       struct drm_connector *connector;
        struct drm_device *drm = &dpsub->drm;
        int ret;
 
@@ -120,42 +116,9 @@ static int zynqmp_dpsub_drm_init(struct zynqmp_dpsub *dpsub)
 
        drm_kms_helper_poll_init(drm);
 
-       /*
-        * Initialize the DISP and DP components. This will creates planes,
-        * CRTC, and a bridge for the DP encoder.
-        */
-       ret = zynqmp_disp_drm_init(dpsub);
-       if (ret)
-               goto err_poll_fini;
-
-       ret = zynqmp_dp_drm_init(dpsub);
-       if (ret)
-               goto err_poll_fini;
-
-       /* Create the encoder and attach the bridge. */
-       encoder->possible_crtcs |= zynqmp_disp_get_crtc_mask(dpsub->disp);
-       drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_NONE);
-
-       ret = drm_bridge_attach(encoder, dpsub->bridge, NULL,
-                               DRM_BRIDGE_ATTACH_NO_CONNECTOR);
-       if (ret) {
-               dev_err(dpsub->dev, "failed to attach bridge to encoder\n");
-               goto err_poll_fini;
-       }
-
-       /* Create the connector for the chain of bridges. */
-       connector = drm_bridge_connector_init(drm, encoder);
-       if (IS_ERR(connector)) {
-               dev_err(dpsub->dev, "failed to created connector\n");
-               ret = PTR_ERR(connector);
-               goto err_poll_fini;
-       }
-
-       ret = drm_connector_attach_encoder(connector, encoder);
-       if (ret < 0) {
-               dev_err(dpsub->dev, "failed to attach connector to encoder\n");
+       ret = zynqmp_dpsub_kms_init(dpsub);
+       if (ret < 0)
                goto err_poll_fini;
-       }
 
        /* Reset all components and register the DRM device. */
        drm_mode_config_reset(drm);
diff --git a/drivers/gpu/drm/xlnx/zynqmp_kms.c b/drivers/gpu/drm/xlnx/zynqmp_kms.c
new file mode 100644 (file)
index 0000000..e4e7f8f
--- /dev/null
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ZynqMP DisplayPort Subsystem - KMS API
+ *
+ * Copyright (C) 2017 - 2021 Xilinx, Inc.
+ *
+ * Authors:
+ * - Hyun Woo Kwon <hyun.kwon@xilinx.com>
+ * - Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ */
+
+#include <drm/drm_bridge.h>
+#include <drm/drm_bridge_connector.h>
+#include <drm/drm_connector.h>
+#include <drm/drm_encoder.h>
+#include <drm/drm_simple_kms_helper.h>
+
+#include "zynqmp_disp.h"
+#include "zynqmp_dp.h"
+#include "zynqmp_dpsub.h"
+#include "zynqmp_kms.h"
+
+/* -----------------------------------------------------------------------------
+ * Initialization
+ */
+
+int zynqmp_dpsub_kms_init(struct zynqmp_dpsub *dpsub)
+{
+       struct drm_encoder *encoder = &dpsub->encoder;
+       struct drm_connector *connector;
+       int ret;
+
+       /*
+        * Initialize the DISP and DP components. This will creates planes,
+        * CRTC, and a bridge for the DP encoder.
+        */
+       ret = zynqmp_disp_drm_init(dpsub);
+       if (ret)
+               return ret;
+
+       ret = zynqmp_dp_drm_init(dpsub);
+       if (ret)
+               return ret;
+
+       /* Create the encoder and attach the bridge. */
+       encoder->possible_crtcs |= zynqmp_disp_get_crtc_mask(dpsub->disp);
+       drm_simple_encoder_init(&dpsub->drm, encoder, DRM_MODE_ENCODER_NONE);
+
+       ret = drm_bridge_attach(encoder, dpsub->bridge, NULL,
+                               DRM_BRIDGE_ATTACH_NO_CONNECTOR);
+       if (ret) {
+               dev_err(dpsub->dev, "failed to attach bridge to encoder\n");
+               return ret;
+       }
+
+       /* Create the connector for the chain of bridges. */
+       connector = drm_bridge_connector_init(&dpsub->drm, encoder);
+       if (IS_ERR(connector)) {
+               dev_err(dpsub->dev, "failed to created connector\n");
+               return PTR_ERR(connector);
+       }
+
+       ret = drm_connector_attach_encoder(connector, encoder);
+       if (ret < 0) {
+               dev_err(dpsub->dev, "failed to attach connector to encoder\n");
+               return ret;
+       }
+
+       return 0;
+}
diff --git a/drivers/gpu/drm/xlnx/zynqmp_kms.h b/drivers/gpu/drm/xlnx/zynqmp_kms.h
new file mode 100644 (file)
index 0000000..a6729d9
--- /dev/null
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * ZynqMP DisplayPort Subsystem - KMS API
+ *
+ * Copyright (C) 2017 - 2021 Xilinx, Inc.
+ *
+ * Authors:
+ * - Hyun Woo Kwon <hyun.kwon@xilinx.com>
+ * - Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ */
+
+#ifndef _ZYNQMP_KMS_H_
+#define _ZYNQMP_KMS_H_
+
+struct zynqmp_dpsub;
+
+int zynqmp_dpsub_kms_init(struct zynqmp_dpsub *dpsub);
+
+#endif /* _ZYNQMP_KMS_H_ */