forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c
....@@ -1,23 +1,20 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2014 NVIDIA Corporation
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 as
6
- * published by the Free Software Foundation.
74 */
85
9
-#include <linux/backlight.h>
6
+#include <linux/delay.h>
107 #include <linux/gpio/consumer.h>
118 #include <linux/module.h>
129 #include <linux/of.h>
1310 #include <linux/regulator/consumer.h>
1411
15
-#include <drm/drmP.h>
12
+#include <video/mipi_display.h>
13
+
1614 #include <drm/drm_crtc.h>
15
+#include <drm/drm_device.h>
1716 #include <drm/drm_mipi_dsi.h>
1817 #include <drm/drm_panel.h>
19
-
20
-#include <video/mipi_display.h>
2118
2219 struct sharp_panel {
2320 struct drm_panel base;
....@@ -25,7 +22,6 @@
2522 struct mipi_dsi_device *link1;
2623 struct mipi_dsi_device *link2;
2724
28
- struct backlight_device *backlight;
2925 struct regulator *supply;
3026
3127 bool prepared;
....@@ -95,8 +91,6 @@
9591
9692 if (!sharp->enabled)
9793 return 0;
98
-
99
- backlight_disable(sharp->backlight);
10094
10195 sharp->enabled = false;
10296
....@@ -260,8 +254,6 @@
260254 if (sharp->enabled)
261255 return 0;
262256
263
- backlight_enable(sharp->backlight);
264
-
265257 sharp->enabled = true;
266258
267259 return 0;
....@@ -277,27 +269,27 @@
277269 .vsync_start = 1600 + 4,
278270 .vsync_end = 1600 + 4 + 8,
279271 .vtotal = 1600 + 4 + 8 + 32,
280
- .vrefresh = 60,
281272 };
282273
283
-static int sharp_panel_get_modes(struct drm_panel *panel)
274
+static int sharp_panel_get_modes(struct drm_panel *panel,
275
+ struct drm_connector *connector)
284276 {
285277 struct drm_display_mode *mode;
286278
287
- mode = drm_mode_duplicate(panel->drm, &default_mode);
279
+ mode = drm_mode_duplicate(connector->dev, &default_mode);
288280 if (!mode) {
289
- dev_err(panel->drm->dev, "failed to add mode %ux%ux@%u\n",
281
+ dev_err(panel->dev, "failed to add mode %ux%ux@%u\n",
290282 default_mode.hdisplay, default_mode.vdisplay,
291
- default_mode.vrefresh);
283
+ drm_mode_vrefresh(&default_mode));
292284 return -ENOMEM;
293285 }
294286
295287 drm_mode_set_name(mode);
296288
297
- drm_mode_probed_add(panel->connector, mode);
289
+ drm_mode_probed_add(connector, mode);
298290
299
- panel->connector->display_info.width_mm = 217;
300
- panel->connector->display_info.height_mm = 136;
291
+ connector->display_info.width_mm = 217;
292
+ connector->display_info.height_mm = 136;
301293
302294 return 1;
303295 }
....@@ -318,7 +310,7 @@
318310
319311 static int sharp_panel_add(struct sharp_panel *sharp)
320312 {
321
- struct device *dev = &sharp->link1->dev;
313
+ int ret;
322314
323315 sharp->mode = &default_mode;
324316
....@@ -326,16 +318,16 @@
326318 if (IS_ERR(sharp->supply))
327319 return PTR_ERR(sharp->supply);
328320
329
- sharp->backlight = devm_of_find_backlight(dev);
321
+ drm_panel_init(&sharp->base, &sharp->link1->dev, &sharp_panel_funcs,
322
+ DRM_MODE_CONNECTOR_DSI);
330323
331
- if (IS_ERR(sharp->backlight))
332
- return PTR_ERR(sharp->backlight);
324
+ ret = drm_panel_of_backlight(&sharp->base);
325
+ if (ret)
326
+ return ret;
333327
334
- drm_panel_init(&sharp->base);
335
- sharp->base.funcs = &sharp_panel_funcs;
336
- sharp->base.dev = &sharp->link1->dev;
328
+ drm_panel_add(&sharp->base);
337329
338
- return drm_panel_add(&sharp->base);
330
+ return 0;
339331 }
340332
341333 static void sharp_panel_del(struct sharp_panel *sharp)
....@@ -410,7 +402,7 @@
410402 return 0;
411403 }
412404
413
- err = sharp_panel_disable(&sharp->base);
405
+ err = drm_panel_disable(&sharp->base);
414406 if (err < 0)
415407 dev_err(&dsi->dev, "failed to disable panel: %d\n", err);
416408
....@@ -431,7 +423,7 @@
431423 if (!sharp)
432424 return;
433425
434
- sharp_panel_disable(&sharp->base);
426
+ drm_panel_disable(&sharp->base);
435427 }
436428
437429 static struct mipi_dsi_driver sharp_panel_driver = {