forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/gpu/drm/panel/panel-lvds.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0+
12 /*
23 * Generic LVDS panel driver
34 *
....@@ -5,14 +6,8 @@
56 * Copyright (C) 2016 Renesas Electronics Corporation
67 *
78 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
139 */
1410
15
-#include <linux/backlight.h>
1611 #include <linux/gpio/consumer.h>
1712 #include <linux/module.h>
1813 #include <linux/of_platform.h>
....@@ -20,13 +15,12 @@
2015 #include <linux/regulator/consumer.h>
2116 #include <linux/slab.h>
2217
23
-#include <drm/drmP.h>
24
-#include <drm/drm_crtc.h>
25
-#include <drm/drm_panel.h>
26
-
2718 #include <video/display_timing.h>
2819 #include <video/of_display_timing.h>
2920 #include <video/videomode.h>
21
+
22
+#include <drm/drm_crtc.h>
23
+#include <drm/drm_panel.h>
3024
3125 struct panel_lvds {
3226 struct drm_panel panel;
....@@ -39,29 +33,17 @@
3933 unsigned int bus_format;
4034 bool data_mirror;
4135
42
- struct backlight_device *backlight;
4336 struct regulator *supply;
4437
4538 struct gpio_desc *enable_gpio;
4639 struct gpio_desc *reset_gpio;
40
+
41
+ enum drm_panel_orientation orientation;
4742 };
4843
4944 static inline struct panel_lvds *to_panel_lvds(struct drm_panel *panel)
5045 {
5146 return container_of(panel, struct panel_lvds, panel);
52
-}
53
-
54
-static int panel_lvds_disable(struct drm_panel *panel)
55
-{
56
- struct panel_lvds *lvds = to_panel_lvds(panel);
57
-
58
- if (lvds->backlight) {
59
- lvds->backlight->props.power = FB_BLANK_POWERDOWN;
60
- lvds->backlight->props.state |= BL_CORE_FBBLANK;
61
- backlight_update_status(lvds->backlight);
62
- }
63
-
64
- return 0;
6547 }
6648
6749 static int panel_lvds_unprepare(struct drm_panel *panel)
....@@ -98,26 +80,13 @@
9880 return 0;
9981 }
10082
101
-static int panel_lvds_enable(struct drm_panel *panel)
83
+static int panel_lvds_get_modes(struct drm_panel *panel,
84
+ struct drm_connector *connector)
10285 {
10386 struct panel_lvds *lvds = to_panel_lvds(panel);
104
-
105
- if (lvds->backlight) {
106
- lvds->backlight->props.state &= ~BL_CORE_FBBLANK;
107
- lvds->backlight->props.power = FB_BLANK_UNBLANK;
108
- backlight_update_status(lvds->backlight);
109
- }
110
-
111
- return 0;
112
-}
113
-
114
-static int panel_lvds_get_modes(struct drm_panel *panel)
115
-{
116
- struct panel_lvds *lvds = to_panel_lvds(panel);
117
- struct drm_connector *connector = lvds->panel.connector;
11887 struct drm_display_mode *mode;
11988
120
- mode = drm_mode_create(lvds->panel.drm);
89
+ mode = drm_mode_create(connector->dev);
12190 if (!mode)
12291 return 0;
12392
....@@ -132,15 +101,14 @@
132101 connector->display_info.bus_flags = lvds->data_mirror
133102 ? DRM_BUS_FLAG_DATA_LSB_TO_MSB
134103 : DRM_BUS_FLAG_DATA_MSB_TO_LSB;
104
+ drm_connector_set_panel_orientation(connector, lvds->orientation);
135105
136106 return 1;
137107 }
138108
139109 static const struct drm_panel_funcs panel_lvds_funcs = {
140
- .disable = panel_lvds_disable,
141110 .unprepare = panel_lvds_unprepare,
142111 .prepare = panel_lvds_prepare,
143
- .enable = panel_lvds_enable,
144112 .get_modes = panel_lvds_get_modes,
145113 };
146114
....@@ -151,9 +119,18 @@
151119 const char *mapping;
152120 int ret;
153121
154
- ret = of_get_display_timing(np, "panel-timing", &timing);
155
- if (ret < 0)
122
+ ret = of_drm_get_panel_orientation(np, &lvds->orientation);
123
+ if (ret < 0) {
124
+ dev_err(lvds->dev, "%pOF: failed to get orientation %d\n", np, ret);
156125 return ret;
126
+ }
127
+
128
+ ret = of_get_display_timing(np, "panel-timing", &timing);
129
+ if (ret < 0) {
130
+ dev_err(lvds->dev, "%pOF: problems parsing panel-timing (%d)\n",
131
+ np, ret);
132
+ return ret;
133
+ }
157134
158135 videomode_from_timing(&timing, &lvds->video_mode);
159136
....@@ -244,10 +221,6 @@
244221 return ret;
245222 }
246223
247
- lvds->backlight = devm_of_find_backlight(lvds->dev);
248
- if (IS_ERR(lvds->backlight))
249
- return PTR_ERR(lvds->backlight);
250
-
251224 /*
252225 * TODO: Handle all power supplies specified in the DT node in a generic
253226 * way for panels that don't care about power supply ordering. LVDS
....@@ -256,13 +229,14 @@
256229 */
257230
258231 /* Register the panel. */
259
- drm_panel_init(&lvds->panel);
260
- lvds->panel.dev = lvds->dev;
261
- lvds->panel.funcs = &panel_lvds_funcs;
232
+ drm_panel_init(&lvds->panel, lvds->dev, &panel_lvds_funcs,
233
+ DRM_MODE_CONNECTOR_LVDS);
262234
263
- ret = drm_panel_add(&lvds->panel);
264
- if (ret < 0)
235
+ ret = drm_panel_of_backlight(&lvds->panel);
236
+ if (ret)
265237 return ret;
238
+
239
+ drm_panel_add(&lvds->panel);
266240
267241 dev_set_drvdata(lvds->dev, lvds);
268242 return 0;
....@@ -274,7 +248,7 @@
274248
275249 drm_panel_remove(&lvds->panel);
276250
277
- panel_lvds_disable(&lvds->panel);
251
+ drm_panel_disable(&lvds->panel);
278252
279253 return 0;
280254 }