forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/imx/dw_hdmi-imx.c
....@@ -1,24 +1,24 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /* Copyright (C) 2011-2013 Freescale Semiconductor, Inc.
23 *
34 * derived from imx-hdmi.c(renamed to bridge/dw_hdmi.c now)
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License version 2 as
7
- * published by the Free Software Foundation.
85 */
9
-#include <linux/module.h>
10
-#include <linux/platform_device.h>
6
+
117 #include <linux/component.h>
128 #include <linux/mfd/syscon.h>
139 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
14
-#include <drm/bridge/dw_hdmi.h>
15
-#include <video/imx-ipu-v3.h>
10
+#include <linux/module.h>
11
+#include <linux/platform_device.h>
1612 #include <linux/regmap.h>
17
-#include <drm/drm_of.h>
18
-#include <drm/drmP.h>
19
-#include <drm/drm_crtc_helper.h>
13
+
14
+#include <video/imx-ipu-v3.h>
15
+
16
+#include <drm/bridge/dw_hdmi.h>
17
+#include <drm/drm_atomic_helper.h>
2018 #include <drm/drm_edid.h>
21
-#include <drm/drm_encoder_slave.h>
19
+#include <drm/drm_encoder.h>
20
+#include <drm/drm_of.h>
21
+#include <drm/drm_simple_kms_helper.h>
2222
2323 #include "imx-drm.h"
2424
....@@ -111,10 +111,6 @@
111111 return 0;
112112 }
113113
114
-static void dw_hdmi_imx_encoder_disable(struct drm_encoder *encoder)
115
-{
116
-}
117
-
118114 static void dw_hdmi_imx_encoder_enable(struct drm_encoder *encoder)
119115 {
120116 struct imx_hdmi *hdmi = enc_to_imx_hdmi(encoder);
....@@ -140,16 +136,12 @@
140136
141137 static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs = {
142138 .enable = dw_hdmi_imx_encoder_enable,
143
- .disable = dw_hdmi_imx_encoder_disable,
144139 .atomic_check = dw_hdmi_imx_atomic_check,
145140 };
146141
147
-static const struct drm_encoder_funcs dw_hdmi_imx_encoder_funcs = {
148
- .destroy = drm_encoder_cleanup,
149
-};
150
-
151142 static enum drm_mode_status
152
-imx6q_hdmi_mode_valid(struct drm_connector *con,
143
+imx6q_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
144
+ const struct drm_display_info *info,
153145 const struct drm_display_mode *mode)
154146 {
155147 if (mode->clock < 13500)
....@@ -162,7 +154,8 @@
162154 }
163155
164156 static enum drm_mode_status
165
-imx6dl_hdmi_mode_valid(struct drm_connector *con,
157
+imx6dl_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
158
+ const struct drm_display_info *info,
166159 const struct drm_display_mode *mode)
167160 {
168161 if (mode->clock < 13500)
....@@ -213,34 +206,24 @@
213206 if (!pdev->dev.of_node)
214207 return -ENODEV;
215208
216
- hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
217
- if (!hdmi)
218
- return -ENOMEM;
209
+ hdmi = dev_get_drvdata(dev);
210
+ memset(hdmi, 0, sizeof(*hdmi));
219211
220212 match = of_match_node(dw_hdmi_imx_dt_ids, pdev->dev.of_node);
221213 plat_data = match->data;
222214 hdmi->dev = &pdev->dev;
223215 encoder = &hdmi->encoder;
224216
225
- encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);
226
- /*
227
- * If we failed to find the CRTC(s) which this encoder is
228
- * supposed to be connected to, it's because the CRTC has
229
- * not been registered yet. Defer probing, and hope that
230
- * the required CRTC is added later.
231
- */
232
- if (encoder->possible_crtcs == 0)
233
- return -EPROBE_DEFER;
217
+ ret = imx_drm_encoder_parse_of(drm, encoder, dev->of_node);
218
+ if (ret)
219
+ return ret;
234220
235221 ret = dw_hdmi_imx_parse_dt(hdmi);
236222 if (ret < 0)
237223 return ret;
238224
239225 drm_encoder_helper_add(encoder, &dw_hdmi_imx_encoder_helper_funcs);
240
- drm_encoder_init(drm, encoder, &dw_hdmi_imx_encoder_funcs,
241
- DRM_MODE_ENCODER_TMDS, NULL);
242
-
243
- platform_set_drvdata(pdev, hdmi);
226
+ drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);
244227
245228 hdmi->hdmi = dw_hdmi_bind(pdev, encoder, plat_data);
246229
....@@ -271,6 +254,14 @@
271254
272255 static int dw_hdmi_imx_probe(struct platform_device *pdev)
273256 {
257
+ struct imx_hdmi *hdmi;
258
+
259
+ hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
260
+ if (!hdmi)
261
+ return -ENOMEM;
262
+
263
+ platform_set_drvdata(pdev, hdmi);
264
+
274265 return component_add(&pdev->dev, &dw_hdmi_imx_ops);
275266 }
276267