forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/gpu/drm/sun4i/sun4i_lvds.c
....@@ -6,11 +6,13 @@
66
77 #include <linux/clk.h>
88
9
-#include <drm/drmP.h>
109 #include <drm/drm_atomic_helper.h>
11
-#include <drm/drm_crtc_helper.h>
10
+#include <drm/drm_bridge.h>
1211 #include <drm/drm_of.h>
1312 #include <drm/drm_panel.h>
13
+#include <drm/drm_print.h>
14
+#include <drm/drm_probe_helper.h>
15
+#include <drm/drm_simple_kms_helper.h>
1416
1517 #include "sun4i_crtc.h"
1618 #include "sun4i_tcon.h"
....@@ -20,7 +22,7 @@
2022 struct drm_connector connector;
2123 struct drm_encoder encoder;
2224
23
- struct sun4i_tcon *tcon;
25
+ struct drm_panel *panel;
2426 };
2527
2628 static inline struct sun4i_lvds *
....@@ -41,22 +43,17 @@
4143 {
4244 struct sun4i_lvds *lvds =
4345 drm_connector_to_sun4i_lvds(connector);
44
- struct sun4i_tcon *tcon = lvds->tcon;
4546
46
- return drm_panel_get_modes(tcon->panel);
47
+ return drm_panel_get_modes(lvds->panel, connector);
4748 }
4849
49
-static struct drm_connector_helper_funcs sun4i_lvds_con_helper_funcs = {
50
+static const struct drm_connector_helper_funcs sun4i_lvds_con_helper_funcs = {
5051 .get_modes = sun4i_lvds_get_modes,
5152 };
5253
5354 static void
5455 sun4i_lvds_connector_destroy(struct drm_connector *connector)
5556 {
56
- struct sun4i_lvds *lvds = drm_connector_to_sun4i_lvds(connector);
57
- struct sun4i_tcon *tcon = lvds->tcon;
58
-
59
- drm_panel_detach(tcon->panel);
6057 drm_connector_cleanup(connector);
6158 }
6259
....@@ -71,36 +68,30 @@
7168 static void sun4i_lvds_encoder_enable(struct drm_encoder *encoder)
7269 {
7370 struct sun4i_lvds *lvds = drm_encoder_to_sun4i_lvds(encoder);
74
- struct sun4i_tcon *tcon = lvds->tcon;
7571
7672 DRM_DEBUG_DRIVER("Enabling LVDS output\n");
7773
78
- if (!IS_ERR(tcon->panel)) {
79
- drm_panel_prepare(tcon->panel);
80
- drm_panel_enable(tcon->panel);
74
+ if (lvds->panel) {
75
+ drm_panel_prepare(lvds->panel);
76
+ drm_panel_enable(lvds->panel);
8177 }
8278 }
8379
8480 static void sun4i_lvds_encoder_disable(struct drm_encoder *encoder)
8581 {
8682 struct sun4i_lvds *lvds = drm_encoder_to_sun4i_lvds(encoder);
87
- struct sun4i_tcon *tcon = lvds->tcon;
8883
8984 DRM_DEBUG_DRIVER("Disabling LVDS output\n");
9085
91
- if (!IS_ERR(tcon->panel)) {
92
- drm_panel_disable(tcon->panel);
93
- drm_panel_unprepare(tcon->panel);
86
+ if (lvds->panel) {
87
+ drm_panel_disable(lvds->panel);
88
+ drm_panel_unprepare(lvds->panel);
9489 }
9590 }
9691
9792 static const struct drm_encoder_helper_funcs sun4i_lvds_enc_helper_funcs = {
9893 .disable = sun4i_lvds_encoder_disable,
9994 .enable = sun4i_lvds_encoder_enable,
100
-};
101
-
102
-static const struct drm_encoder_funcs sun4i_lvds_enc_funcs = {
103
- .destroy = drm_encoder_cleanup,
10495 };
10596
10697 int sun4i_lvds_init(struct drm_device *drm, struct sun4i_tcon *tcon)
....@@ -113,11 +104,10 @@
113104 lvds = devm_kzalloc(drm->dev, sizeof(*lvds), GFP_KERNEL);
114105 if (!lvds)
115106 return -ENOMEM;
116
- lvds->tcon = tcon;
117107 encoder = &lvds->encoder;
118108
119109 ret = drm_of_find_panel_or_bridge(tcon->dev->of_node, 1, 0,
120
- &tcon->panel, &bridge);
110
+ &lvds->panel, &bridge);
121111 if (ret) {
122112 dev_info(drm->dev, "No panel or bridge found... LVDS output disabled\n");
123113 return 0;
....@@ -125,11 +115,8 @@
125115
126116 drm_encoder_helper_add(&lvds->encoder,
127117 &sun4i_lvds_enc_helper_funcs);
128
- ret = drm_encoder_init(drm,
129
- &lvds->encoder,
130
- &sun4i_lvds_enc_funcs,
131
- DRM_MODE_ENCODER_LVDS,
132
- NULL);
118
+ ret = drm_simple_encoder_init(drm, &lvds->encoder,
119
+ DRM_MODE_ENCODER_LVDS);
133120 if (ret) {
134121 dev_err(drm->dev, "Couldn't initialise the lvds encoder\n");
135122 goto err_out;
....@@ -138,7 +125,7 @@
138125 /* The LVDS encoder can only work with the TCON channel 0 */
139126 lvds->encoder.possible_crtcs = drm_crtc_mask(&tcon->crtc->crtc);
140127
141
- if (tcon->panel) {
128
+ if (lvds->panel) {
142129 drm_connector_helper_add(&lvds->connector,
143130 &sun4i_lvds_con_helper_funcs);
144131 ret = drm_connector_init(drm, &lvds->connector,
....@@ -151,16 +138,10 @@
151138
152139 drm_connector_attach_encoder(&lvds->connector,
153140 &lvds->encoder);
154
-
155
- ret = drm_panel_attach(tcon->panel, &lvds->connector);
156
- if (ret) {
157
- dev_err(drm->dev, "Couldn't attach our panel\n");
158
- goto err_cleanup_connector;
159
- }
160141 }
161142
162143 if (bridge) {
163
- ret = drm_bridge_attach(encoder, bridge, NULL);
144
+ ret = drm_bridge_attach(encoder, bridge, NULL, 0);
164145 if (ret) {
165146 dev_err(drm->dev, "Couldn't attach our bridge\n");
166147 goto err_cleanup_connector;