Skip to content

Commit 76c8eeb

Browse files
committed
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 <[email protected]>
1 parent 88beb8c commit 76c8eeb

File tree

4 files changed

+93
-41
lines changed

4 files changed

+93
-41
lines changed

drivers/gpu/drm/xlnx/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
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
22
obj-$(CONFIG_DRM_ZYNQMP_DPSUB) += zynqmp-dpsub.o

drivers/gpu/drm/xlnx/zynqmp_dpsub.c

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
#include <linux/pm_runtime.h>
1818

1919
#include <drm/drm_atomic_helper.h>
20-
#include <drm/drm_bridge.h>
2120
#include <drm/drm_bridge_connector.h>
22-
#include <drm/drm_connector.h>
2321
#include <drm/drm_device.h>
2422
#include <drm/drm_drv.h>
2523
#include <drm/drm_fb_helper.h>
@@ -30,12 +28,12 @@
3028
#include <drm/drm_mode_config.h>
3129
#include <drm/drm_module.h>
3230
#include <drm/drm_probe_helper.h>
33-
#include <drm/drm_simple_kms_helper.h>
3431
#include <drm/drm_vblank.h>
3532

3633
#include "zynqmp_disp.h"
3734
#include "zynqmp_dp.h"
3835
#include "zynqmp_dpsub.h"
36+
#include "zynqmp_kms.h"
3937

4038
/* -----------------------------------------------------------------------------
4139
* Dumb Buffer & Framebuffer Allocation
@@ -98,8 +96,6 @@ static const struct drm_driver zynqmp_dpsub_drm_driver = {
9896

9997
static int zynqmp_dpsub_drm_init(struct zynqmp_dpsub *dpsub)
10098
{
101-
struct drm_encoder *encoder = &dpsub->encoder;
102-
struct drm_connector *connector;
10399
struct drm_device *drm = &dpsub->drm;
104100
int ret;
105101

@@ -120,42 +116,9 @@ static int zynqmp_dpsub_drm_init(struct zynqmp_dpsub *dpsub)
120116

121117
drm_kms_helper_poll_init(drm);
122118

123-
/*
124-
* Initialize the DISP and DP components. This will creates planes,
125-
* CRTC, and a bridge for the DP encoder.
126-
*/
127-
ret = zynqmp_disp_drm_init(dpsub);
128-
if (ret)
129-
goto err_poll_fini;
130-
131-
ret = zynqmp_dp_drm_init(dpsub);
132-
if (ret)
133-
goto err_poll_fini;
134-
135-
/* Create the encoder and attach the bridge. */
136-
encoder->possible_crtcs |= zynqmp_disp_get_crtc_mask(dpsub->disp);
137-
drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_NONE);
138-
139-
ret = drm_bridge_attach(encoder, dpsub->bridge, NULL,
140-
DRM_BRIDGE_ATTACH_NO_CONNECTOR);
141-
if (ret) {
142-
dev_err(dpsub->dev, "failed to attach bridge to encoder\n");
143-
goto err_poll_fini;
144-
}
145-
146-
/* Create the connector for the chain of bridges. */
147-
connector = drm_bridge_connector_init(drm, encoder);
148-
if (IS_ERR(connector)) {
149-
dev_err(dpsub->dev, "failed to created connector\n");
150-
ret = PTR_ERR(connector);
151-
goto err_poll_fini;
152-
}
153-
154-
ret = drm_connector_attach_encoder(connector, encoder);
155-
if (ret < 0) {
156-
dev_err(dpsub->dev, "failed to attach connector to encoder\n");
119+
ret = zynqmp_dpsub_kms_init(dpsub);
120+
if (ret < 0)
157121
goto err_poll_fini;
158-
}
159122

160123
/* Reset all components and register the DRM device. */
161124
drm_mode_config_reset(drm);

drivers/gpu/drm/xlnx/zynqmp_kms.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 <[email protected]>
9+
* - Laurent Pinchart <[email protected]>
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+
}

drivers/gpu/drm/xlnx/zynqmp_kms.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 <[email protected]>
9+
* - Laurent Pinchart <[email protected]>
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_ */

0 commit comments

Comments
 (0)