forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/gpu/drm/panel/panel-panasonic-vvx10f034n00.c
....@@ -1,34 +1,23 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2015 Red Hat
34 * Copyright (C) 2015 Sony Mobile Communications Inc.
45 * Author: Werner Johansson <werner.johansson@sonymobile.com>
56 *
67 * Based on AUO panel driver by Rob Clark <robdclark@gmail.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License version 2 as published by
10
- * the Free Software Foundation.
11
- *
12
- * This program is distributed in the hope that it will be useful, but WITHOUT
13
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15
- * more details.
16
- *
17
- * You should have received a copy of the GNU General Public License along with
18
- * this program. If not, see <http://www.gnu.org/licenses/>.
198 */
209
21
-#include <linux/backlight.h>
10
+#include <linux/delay.h>
2211 #include <linux/module.h>
2312 #include <linux/of.h>
2413 #include <linux/regulator/consumer.h>
2514
26
-#include <drm/drmP.h>
15
+#include <video/mipi_display.h>
16
+
2717 #include <drm/drm_crtc.h>
18
+#include <drm/drm_device.h>
2819 #include <drm/drm_mipi_dsi.h>
2920 #include <drm/drm_panel.h>
30
-
31
-#include <video/mipi_display.h>
3221
3322 /*
3423 * When power is turned off to this panel a minimum off time of 500ms has to be
....@@ -41,7 +30,6 @@
4130 struct drm_panel base;
4231 struct mipi_dsi_device *dsi;
4332
44
- struct backlight_device *backlight;
4533 struct regulator *supply;
4634
4735 bool prepared;
....@@ -71,12 +59,6 @@
7159 return 0;
7260
7361 mipi_ret = mipi_dsi_shutdown_peripheral(wuxga_nt->dsi);
74
-
75
- if (wuxga_nt->backlight) {
76
- wuxga_nt->backlight->props.power = FB_BLANK_POWERDOWN;
77
- wuxga_nt->backlight->props.state |= BL_CORE_FBBLANK;
78
- bl_ret = backlight_update_status(wuxga_nt->backlight);
79
- }
8062
8163 wuxga_nt->enabled = false;
8264
....@@ -152,12 +134,6 @@
152134 if (wuxga_nt->enabled)
153135 return 0;
154136
155
- if (wuxga_nt->backlight) {
156
- wuxga_nt->backlight->props.power = FB_BLANK_UNBLANK;
157
- wuxga_nt->backlight->props.state &= ~BL_CORE_FBBLANK;
158
- backlight_update_status(wuxga_nt->backlight);
159
- }
160
-
161137 wuxga_nt->enabled = true;
162138
163139 return 0;
....@@ -173,27 +149,27 @@
173149 .vsync_start = 1200 + 24,
174150 .vsync_end = 1200 + 24 + 6,
175151 .vtotal = 1200 + 24 + 6 + 48,
176
- .vrefresh = 60,
177152 };
178153
179
-static int wuxga_nt_panel_get_modes(struct drm_panel *panel)
154
+static int wuxga_nt_panel_get_modes(struct drm_panel *panel,
155
+ struct drm_connector *connector)
180156 {
181157 struct drm_display_mode *mode;
182158
183
- mode = drm_mode_duplicate(panel->drm, &default_mode);
159
+ mode = drm_mode_duplicate(connector->dev, &default_mode);
184160 if (!mode) {
185
- dev_err(panel->drm->dev, "failed to add mode %ux%ux@%u\n",
186
- default_mode.hdisplay, default_mode.vdisplay,
187
- default_mode.vrefresh);
161
+ dev_err(panel->dev, "failed to add mode %ux%u@%u\n",
162
+ default_mode.hdisplay, default_mode.vdisplay,
163
+ drm_mode_vrefresh(&default_mode));
188164 return -ENOMEM;
189165 }
190166
191167 drm_mode_set_name(mode);
192168
193
- drm_mode_probed_add(panel->connector, mode);
169
+ drm_mode_probed_add(connector, mode);
194170
195
- panel->connector->display_info.width_mm = 217;
196
- panel->connector->display_info.height_mm = 136;
171
+ connector->display_info.width_mm = 217;
172
+ connector->display_info.height_mm = 136;
197173
198174 return 1;
199175 }
....@@ -215,7 +191,6 @@
215191 static int wuxga_nt_panel_add(struct wuxga_nt_panel *wuxga_nt)
216192 {
217193 struct device *dev = &wuxga_nt->dsi->dev;
218
- struct device_node *np;
219194 int ret;
220195
221196 wuxga_nt->mode = &default_mode;
....@@ -224,39 +199,22 @@
224199 if (IS_ERR(wuxga_nt->supply))
225200 return PTR_ERR(wuxga_nt->supply);
226201
227
- np = of_parse_phandle(dev->of_node, "backlight", 0);
228
- if (np) {
229
- wuxga_nt->backlight = of_find_backlight_by_node(np);
230
- of_node_put(np);
202
+ drm_panel_init(&wuxga_nt->base, &wuxga_nt->dsi->dev,
203
+ &wuxga_nt_panel_funcs, DRM_MODE_CONNECTOR_DSI);
231204
232
- if (!wuxga_nt->backlight)
233
- return -EPROBE_DEFER;
234
- }
205
+ ret = drm_panel_of_backlight(&wuxga_nt->base);
206
+ if (ret)
207
+ return ret;
235208
236
- drm_panel_init(&wuxga_nt->base);
237
- wuxga_nt->base.funcs = &wuxga_nt_panel_funcs;
238
- wuxga_nt->base.dev = &wuxga_nt->dsi->dev;
239
-
240
- ret = drm_panel_add(&wuxga_nt->base);
241
- if (ret < 0)
242
- goto put_backlight;
209
+ drm_panel_add(&wuxga_nt->base);
243210
244211 return 0;
245
-
246
-put_backlight:
247
- if (wuxga_nt->backlight)
248
- put_device(&wuxga_nt->backlight->dev);
249
-
250
- return ret;
251212 }
252213
253214 static void wuxga_nt_panel_del(struct wuxga_nt_panel *wuxga_nt)
254215 {
255216 if (wuxga_nt->base.dev)
256217 drm_panel_remove(&wuxga_nt->base);
257
-
258
- if (wuxga_nt->backlight)
259
- put_device(&wuxga_nt->backlight->dev);
260218 }
261219
262220 static int wuxga_nt_panel_probe(struct mipi_dsi_device *dsi)
....@@ -291,7 +249,7 @@
291249 struct wuxga_nt_panel *wuxga_nt = mipi_dsi_get_drvdata(dsi);
292250 int ret;
293251
294
- ret = wuxga_nt_panel_disable(&wuxga_nt->base);
252
+ ret = drm_panel_disable(&wuxga_nt->base);
295253 if (ret < 0)
296254 dev_err(&dsi->dev, "failed to disable panel: %d\n", ret);
297255
....@@ -308,7 +266,7 @@
308266 {
309267 struct wuxga_nt_panel *wuxga_nt = mipi_dsi_get_drvdata(dsi);
310268
311
- wuxga_nt_panel_disable(&wuxga_nt->base);
269
+ drm_panel_disable(&wuxga_nt->base);
312270 }
313271
314272 static struct mipi_dsi_driver wuxga_nt_panel_driver = {