Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: xlnx: zynqmp_dpsub: Move DRM/KMS initialization to separate file

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>

+93 -41
+1 -1
drivers/gpu/drm/xlnx/Makefile
··· 1 - zynqmp-dpsub-y := zynqmp_disp.o zynqmp_dpsub.o zynqmp_dp.o 1 + zynqmp-dpsub-y := zynqmp_disp.o zynqmp_dpsub.o zynqmp_dp.o zynqmp_kms.o 2 2 obj-$(CONFIG_DRM_ZYNQMP_DPSUB) += zynqmp-dpsub.o
+3 -40
drivers/gpu/drm/xlnx/zynqmp_dpsub.c
··· 17 17 #include <linux/pm_runtime.h> 18 18 19 19 #include <drm/drm_atomic_helper.h> 20 - #include <drm/drm_bridge.h> 21 20 #include <drm/drm_bridge_connector.h> 22 - #include <drm/drm_connector.h> 23 21 #include <drm/drm_device.h> 24 22 #include <drm/drm_drv.h> 25 23 #include <drm/drm_fb_helper.h> ··· 28 30 #include <drm/drm_mode_config.h> 29 31 #include <drm/drm_module.h> 30 32 #include <drm/drm_probe_helper.h> 31 - #include <drm/drm_simple_kms_helper.h> 32 33 #include <drm/drm_vblank.h> 33 34 34 35 #include "zynqmp_disp.h" 35 36 #include "zynqmp_dp.h" 36 37 #include "zynqmp_dpsub.h" 38 + #include "zynqmp_kms.h" 37 39 38 40 /* ----------------------------------------------------------------------------- 39 41 * Dumb Buffer & Framebuffer Allocation ··· 96 98 97 99 static int zynqmp_dpsub_drm_init(struct zynqmp_dpsub *dpsub) 98 100 { 99 - struct drm_encoder *encoder = &dpsub->encoder; 100 - struct drm_connector *connector; 101 101 struct drm_device *drm = &dpsub->drm; 102 102 int ret; 103 103 ··· 116 120 117 121 drm_kms_helper_poll_init(drm); 118 122 119 - /* 120 - * Initialize the DISP and DP components. This will creates planes, 121 - * CRTC, and a bridge for the DP encoder. 122 - */ 123 - ret = zynqmp_disp_drm_init(dpsub); 124 - if (ret) 123 + ret = zynqmp_dpsub_kms_init(dpsub); 124 + if (ret < 0) 125 125 goto err_poll_fini; 126 - 127 - ret = zynqmp_dp_drm_init(dpsub); 128 - if (ret) 129 - goto err_poll_fini; 130 - 131 - /* Create the encoder and attach the bridge. */ 132 - encoder->possible_crtcs |= zynqmp_disp_get_crtc_mask(dpsub->disp); 133 - drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_NONE); 134 - 135 - ret = drm_bridge_attach(encoder, dpsub->bridge, NULL, 136 - DRM_BRIDGE_ATTACH_NO_CONNECTOR); 137 - if (ret) { 138 - dev_err(dpsub->dev, "failed to attach bridge to encoder\n"); 139 - goto err_poll_fini; 140 - } 141 - 142 - /* Create the connector for the chain of bridges. */ 143 - connector = drm_bridge_connector_init(drm, encoder); 144 - if (IS_ERR(connector)) { 145 - dev_err(dpsub->dev, "failed to created connector\n"); 146 - ret = PTR_ERR(connector); 147 - goto err_poll_fini; 148 - } 149 - 150 - ret = drm_connector_attach_encoder(connector, encoder); 151 - if (ret < 0) { 152 - dev_err(dpsub->dev, "failed to attach connector to encoder\n"); 153 - goto err_poll_fini; 154 - } 155 126 156 127 /* Reset all components and register the DRM device. */ 157 128 drm_mode_config_reset(drm);
+70
drivers/gpu/drm/xlnx/zynqmp_kms.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * ZynqMP DisplayPort Subsystem - KMS API 4 + * 5 + * Copyright (C) 2017 - 2021 Xilinx, Inc. 6 + * 7 + * Authors: 8 + * - Hyun Woo Kwon <hyun.kwon@xilinx.com> 9 + * - Laurent Pinchart <laurent.pinchart@ideasonboard.com> 10 + */ 11 + 12 + #include <drm/drm_bridge.h> 13 + #include <drm/drm_bridge_connector.h> 14 + #include <drm/drm_connector.h> 15 + #include <drm/drm_encoder.h> 16 + #include <drm/drm_simple_kms_helper.h> 17 + 18 + #include "zynqmp_disp.h" 19 + #include "zynqmp_dp.h" 20 + #include "zynqmp_dpsub.h" 21 + #include "zynqmp_kms.h" 22 + 23 + /* ----------------------------------------------------------------------------- 24 + * Initialization 25 + */ 26 + 27 + int zynqmp_dpsub_kms_init(struct zynqmp_dpsub *dpsub) 28 + { 29 + struct drm_encoder *encoder = &dpsub->encoder; 30 + struct drm_connector *connector; 31 + int ret; 32 + 33 + /* 34 + * Initialize the DISP and DP components. This will creates planes, 35 + * CRTC, and a bridge for the DP encoder. 36 + */ 37 + ret = zynqmp_disp_drm_init(dpsub); 38 + if (ret) 39 + return ret; 40 + 41 + ret = zynqmp_dp_drm_init(dpsub); 42 + if (ret) 43 + return ret; 44 + 45 + /* Create the encoder and attach the bridge. */ 46 + encoder->possible_crtcs |= zynqmp_disp_get_crtc_mask(dpsub->disp); 47 + drm_simple_encoder_init(&dpsub->drm, encoder, DRM_MODE_ENCODER_NONE); 48 + 49 + ret = drm_bridge_attach(encoder, dpsub->bridge, NULL, 50 + DRM_BRIDGE_ATTACH_NO_CONNECTOR); 51 + if (ret) { 52 + dev_err(dpsub->dev, "failed to attach bridge to encoder\n"); 53 + return ret; 54 + } 55 + 56 + /* Create the connector for the chain of bridges. */ 57 + connector = drm_bridge_connector_init(&dpsub->drm, encoder); 58 + if (IS_ERR(connector)) { 59 + dev_err(dpsub->dev, "failed to created connector\n"); 60 + return PTR_ERR(connector); 61 + } 62 + 63 + ret = drm_connector_attach_encoder(connector, encoder); 64 + if (ret < 0) { 65 + dev_err(dpsub->dev, "failed to attach connector to encoder\n"); 66 + return ret; 67 + } 68 + 69 + return 0; 70 + }
+19
drivers/gpu/drm/xlnx/zynqmp_kms.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * ZynqMP DisplayPort Subsystem - KMS API 4 + * 5 + * Copyright (C) 2017 - 2021 Xilinx, Inc. 6 + * 7 + * Authors: 8 + * - Hyun Woo Kwon <hyun.kwon@xilinx.com> 9 + * - Laurent Pinchart <laurent.pinchart@ideasonboard.com> 10 + */ 11 + 12 + #ifndef _ZYNQMP_KMS_H_ 13 + #define _ZYNQMP_KMS_H_ 14 + 15 + struct zynqmp_dpsub; 16 + 17 + int zynqmp_dpsub_kms_init(struct zynqmp_dpsub *dpsub); 18 + 19 + #endif /* _ZYNQMP_KMS_H_ */