hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/gpu/drm/exynos/exynos_dp.c
....@@ -1,33 +1,31 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Samsung SoC DP (Display Port) interface driver.
34 *
45 * Copyright (C) 2012 Samsung Electronics Co., Ltd.
56 * Author: Jingoo Han <jg1.han@samsung.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License as published by the
9
- * Free Software Foundation; either version 2 of the License, or (at your
10
- * option) any later version.
117 */
128
13
-#include <linux/module.h>
14
-#include <linux/platform_device.h>
15
-#include <linux/err.h>
169 #include <linux/clk.h>
17
-#include <linux/of_graph.h>
1810 #include <linux/component.h>
11
+#include <linux/err.h>
12
+#include <linux/module.h>
13
+#include <linux/of_graph.h>
14
+#include <linux/platform_device.h>
1915 #include <linux/pm_runtime.h>
2016 #include <video/of_display_timing.h>
2117 #include <video/of_videomode.h>
2218 #include <video/videomode.h>
2319
24
-#include <drm/drmP.h>
20
+#include <drm/bridge/analogix_dp.h>
21
+#include <drm/drm_atomic_helper.h>
22
+#include <drm/drm_bridge.h>
2523 #include <drm/drm_crtc.h>
26
-#include <drm/drm_crtc_helper.h>
2724 #include <drm/drm_of.h>
2825 #include <drm/drm_panel.h>
29
-
30
-#include <drm/bridge/analogix_dp.h>
26
+#include <drm/drm_print.h>
27
+#include <drm/drm_probe_helper.h>
28
+#include <drm/drm_simple_kms_helper.h>
3129 #include <drm/exynos_drm.h>
3230
3331 #include "exynos_drm_crtc.h"
....@@ -82,7 +80,8 @@
8280
8381 mode = drm_mode_create(connector->dev);
8482 if (!mode) {
85
- DRM_ERROR("failed to create a new display mode.\n");
83
+ DRM_DEV_ERROR(dp->dev,
84
+ "failed to create a new display mode.\n");
8685 return num_modes;
8786 }
8887
....@@ -108,10 +107,11 @@
108107
109108 /* Pre-empt DP connector creation if there's a bridge */
110109 if (dp->ptn_bridge) {
111
- ret = drm_bridge_attach(&dp->encoder, dp->ptn_bridge, bridge);
110
+ ret = drm_bridge_attach(&dp->encoder, dp->ptn_bridge, bridge,
111
+ 0);
112112 if (ret) {
113
- DRM_ERROR("Failed to attach bridge to drm\n");
114
- bridge->next = NULL;
113
+ DRM_DEV_ERROR(dp->dev,
114
+ "Failed to attach bridge to drm\n");
115115 return ret;
116116 }
117117 }
....@@ -136,17 +136,14 @@
136136 .disable = exynos_dp_nop,
137137 };
138138
139
-static const struct drm_encoder_funcs exynos_dp_encoder_funcs = {
140
- .destroy = drm_encoder_cleanup,
141
-};
142
-
143139 static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp)
144140 {
145141 int ret;
146142
147143 ret = of_get_videomode(dp->dev->of_node, &dp->vm, OF_USE_NATIVE_MODE);
148144 if (ret) {
149
- DRM_ERROR("failed: of_get_videomode() : %d\n", ret);
145
+ DRM_DEV_ERROR(dp->dev,
146
+ "failed: of_get_videomode() : %d\n", ret);
150147 return ret;
151148 }
152149 return 0;
....@@ -159,14 +156,7 @@
159156 struct drm_device *drm_dev = data;
160157 int ret;
161158
162
- dp->dev = dev;
163159 dp->drm_dev = drm_dev;
164
-
165
- dp->plat_data.dev_type = EXYNOS_DP;
166
- dp->plat_data.power_on_start = exynos_dp_poweron;
167
- dp->plat_data.power_off = exynos_dp_poweroff;
168
- dp->plat_data.attach = exynos_dp_bridge_attach;
169
- dp->plat_data.get_modes = exynos_dp_get_modes;
170160
171161 if (!dp->plat_data.panel && !dp->ptn_bridge) {
172162 ret = exynos_dp_dt_parse_panel(dp);
....@@ -174,8 +164,7 @@
174164 return ret;
175165 }
176166
177
- drm_encoder_init(drm_dev, encoder, &exynos_dp_encoder_funcs,
178
- DRM_MODE_ENCODER_TMDS, NULL);
167
+ drm_simple_encoder_init(drm_dev, encoder, DRM_MODE_ENCODER_TMDS);
179168
180169 drm_encoder_helper_add(encoder, &exynos_dp_encoder_helper_funcs);
181170
....@@ -185,13 +174,11 @@
185174
186175 dp->plat_data.encoder = encoder;
187176
188
- dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
189
- if (IS_ERR(dp->adp)) {
177
+ ret = analogix_dp_bind(dp->adp, dp->drm_dev);
178
+ if (ret)
190179 dp->encoder.funcs->destroy(&dp->encoder);
191
- return PTR_ERR(dp->adp);
192
- }
193180
194
- return 0;
181
+ return ret;
195182 }
196183
197184 static void exynos_dp_unbind(struct device *dev, struct device *master,
....@@ -222,6 +209,7 @@
222209 if (!dp)
223210 return -ENOMEM;
224211
212
+ dp->dev = dev;
225213 /*
226214 * We just use the drvdata until driver run into component
227215 * add function, and then we would set drvdata to null, so
....@@ -247,16 +235,29 @@
247235
248236 /* The remote port can be either a panel or a bridge */
249237 dp->plat_data.panel = panel;
238
+ dp->plat_data.dev_type = EXYNOS_DP;
239
+ dp->plat_data.power_on_start = exynos_dp_poweron;
240
+ dp->plat_data.power_off = exynos_dp_poweroff;
241
+ dp->plat_data.attach = exynos_dp_bridge_attach;
242
+ dp->plat_data.get_modes = exynos_dp_get_modes;
250243 dp->plat_data.skip_connector = !!bridge;
244
+
251245 dp->ptn_bridge = bridge;
252246
253247 out:
248
+ dp->adp = analogix_dp_probe(dev, &dp->plat_data);
249
+ if (IS_ERR(dp->adp))
250
+ return PTR_ERR(dp->adp);
251
+
254252 return component_add(&pdev->dev, &exynos_dp_ops);
255253 }
256254
257255 static int exynos_dp_remove(struct platform_device *pdev)
258256 {
257
+ struct exynos_dp_device *dp = platform_get_drvdata(pdev);
258
+
259259 component_del(&pdev->dev, &exynos_dp_ops);
260
+ analogix_dp_remove(dp->adp);
260261
261262 return 0;
262263 }