forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/tilcdc/tilcdc_panel.c
....@@ -1,28 +1,22 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2012 Texas Instruments
34 * Author: Rob Clark <robdclark@gmail.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU General Public License version 2 as published by
7
- * the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program. If not, see <http://www.gnu.org/licenses/>.
165 */
176
18
-#include <linux/pinctrl/pinmux.h>
19
-#include <linux/pinctrl/consumer.h>
20
-#include <linux/backlight.h>
217 #include <linux/gpio/consumer.h>
8
+#include <linux/pinctrl/consumer.h>
9
+#include <linux/platform_device.h>
10
+
2211 #include <video/display_timing.h>
2312 #include <video/of_display_timing.h>
2413 #include <video/videomode.h>
25
-#include <drm/drm_atomic_helper.h>
14
+
15
+#include <drm/drm_atomic_state_helper.h>
16
+#include <drm/drm_connector.h>
17
+#include <drm/drm_modeset_helper_vtables.h>
18
+#include <drm/drm_probe_helper.h>
19
+#include <drm/drm_simple_kms_helper.h>
2620
2721 #include "tilcdc_drv.h"
2822 #include "tilcdc_panel.h"
....@@ -81,10 +75,6 @@
8175 /* nothing needed */
8276 }
8377
84
-static const struct drm_encoder_funcs panel_encoder_funcs = {
85
- .destroy = drm_encoder_cleanup,
86
-};
87
-
8878 static const struct drm_encoder_helper_funcs panel_encoder_helper_funcs = {
8979 .dpms = panel_encoder_dpms,
9080 .prepare = panel_encoder_prepare,
....@@ -109,8 +99,7 @@
10999 encoder = &panel_encoder->base;
110100 encoder->possible_crtcs = 1;
111101
112
- ret = drm_encoder_init(dev, encoder, &panel_encoder_funcs,
113
- DRM_MODE_ENCODER_LVDS, NULL);
102
+ ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_LVDS);
114103 if (ret < 0)
115104 goto fail;
116105
....@@ -174,14 +163,6 @@
174163 return i;
175164 }
176165
177
-static int panel_connector_mode_valid(struct drm_connector *connector,
178
- struct drm_display_mode *mode)
179
-{
180
- struct tilcdc_drm_private *priv = connector->dev->dev_private;
181
- /* our only constraints are what the crtc can generate: */
182
- return tilcdc_crtc_mode_valid(priv->crtc, mode);
183
-}
184
-
185166 static struct drm_encoder *panel_connector_best_encoder(
186167 struct drm_connector *connector)
187168 {
....@@ -199,7 +180,6 @@
199180
200181 static const struct drm_connector_helper_funcs panel_connector_helper_funcs = {
201182 .get_modes = panel_connector_get_modes,
202
- .mode_valid = panel_connector_mode_valid,
203183 .best_encoder = panel_connector_best_encoder,
204184 };
205185
....@@ -323,7 +303,8 @@
323303
324304 static int panel_probe(struct platform_device *pdev)
325305 {
326
- struct device_node *bl_node, *node = pdev->dev.of_node;
306
+ struct device_node *node = pdev->dev.of_node;
307
+ struct backlight_device *backlight;
327308 struct panel_module *panel_mod;
328309 struct tilcdc_module *mod;
329310 struct pinctrl *pinctrl;
....@@ -339,16 +320,10 @@
339320 if (!panel_mod)
340321 return -ENOMEM;
341322
342
- bl_node = of_parse_phandle(node, "backlight", 0);
343
- if (bl_node) {
344
- panel_mod->backlight = of_find_backlight_by_node(bl_node);
345
- of_node_put(bl_node);
346
-
347
- if (!panel_mod->backlight)
348
- return -EPROBE_DEFER;
349
-
350
- dev_info(&pdev->dev, "found backlight\n");
351
- }
323
+ backlight = devm_of_find_backlight(&pdev->dev);
324
+ if (IS_ERR(backlight))
325
+ return PTR_ERR(backlight);
326
+ panel_mod->backlight = backlight;
352327
353328 panel_mod->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
354329 GPIOD_OUT_LOW);
....@@ -420,7 +395,7 @@
420395 { },
421396 };
422397
423
-struct platform_driver panel_driver = {
398
+static struct platform_driver panel_driver = {
424399 .probe = panel_probe,
425400 .remove = panel_remove,
426401 .driver = {