hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c
....@@ -1,41 +1,29 @@
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/gpio/consumer.h>
2312 #include <linux/module.h>
2413 #include <linux/of.h>
2514 #include <linux/regulator/consumer.h>
2615
27
-#include <drm/drmP.h>
16
+#include <video/mipi_display.h>
17
+
2818 #include <drm/drm_crtc.h>
19
+#include <drm/drm_device.h>
2920 #include <drm/drm_mipi_dsi.h>
3021 #include <drm/drm_panel.h>
31
-
32
-#include <video/mipi_display.h>
3322
3423 struct sharp_nt_panel {
3524 struct drm_panel base;
3625 struct mipi_dsi_device *dsi;
3726
38
- struct backlight_device *backlight;
3927 struct regulator *supply;
4028 struct gpio_desc *reset_gpio;
4129
....@@ -116,8 +104,6 @@
116104
117105 if (!sharp_nt->enabled)
118106 return 0;
119
-
120
- backlight_disable(sharp_nt->backlight);
121107
122108 sharp_nt->enabled = false;
123109
....@@ -200,44 +186,42 @@
200186 if (sharp_nt->enabled)
201187 return 0;
202188
203
- backlight_enable(sharp_nt->backlight);
204
-
205189 sharp_nt->enabled = true;
206190
207191 return 0;
208192 }
209193
210194 static const struct drm_display_mode default_mode = {
211
- .clock = 41118,
195
+ .clock = (540 + 48 + 32 + 80) * (960 + 3 + 10 + 15) * 60 / 1000,
212196 .hdisplay = 540,
213197 .hsync_start = 540 + 48,
214
- .hsync_end = 540 + 48 + 80,
215
- .htotal = 540 + 48 + 80 + 32,
198
+ .hsync_end = 540 + 48 + 32,
199
+ .htotal = 540 + 48 + 32 + 80,
216200 .vdisplay = 960,
217201 .vsync_start = 960 + 3,
218
- .vsync_end = 960 + 3 + 15,
219
- .vtotal = 960 + 3 + 15 + 1,
220
- .vrefresh = 60,
202
+ .vsync_end = 960 + 3 + 10,
203
+ .vtotal = 960 + 3 + 10 + 15,
221204 };
222205
223
-static int sharp_nt_panel_get_modes(struct drm_panel *panel)
206
+static int sharp_nt_panel_get_modes(struct drm_panel *panel,
207
+ struct drm_connector *connector)
224208 {
225209 struct drm_display_mode *mode;
226210
227
- mode = drm_mode_duplicate(panel->drm, &default_mode);
211
+ mode = drm_mode_duplicate(connector->dev, &default_mode);
228212 if (!mode) {
229
- dev_err(panel->drm->dev, "failed to add mode %ux%ux@%u\n",
230
- default_mode.hdisplay, default_mode.vdisplay,
231
- default_mode.vrefresh);
213
+ dev_err(panel->dev, "failed to add mode %ux%u@%u\n",
214
+ default_mode.hdisplay, default_mode.vdisplay,
215
+ drm_mode_vrefresh(&default_mode));
232216 return -ENOMEM;
233217 }
234218
235219 drm_mode_set_name(mode);
236220
237
- drm_mode_probed_add(panel->connector, mode);
221
+ drm_mode_probed_add(connector, mode);
238222
239
- panel->connector->display_info.width_mm = 54;
240
- panel->connector->display_info.height_mm = 95;
223
+ connector->display_info.width_mm = 54;
224
+ connector->display_info.height_mm = 95;
241225
242226 return 1;
243227 }
....@@ -253,6 +237,7 @@
253237 static int sharp_nt_panel_add(struct sharp_nt_panel *sharp_nt)
254238 {
255239 struct device *dev = &sharp_nt->dsi->dev;
240
+ int ret;
256241
257242 sharp_nt->mode = &default_mode;
258243
....@@ -269,16 +254,16 @@
269254 gpiod_set_value(sharp_nt->reset_gpio, 0);
270255 }
271256
272
- sharp_nt->backlight = devm_of_find_backlight(dev);
257
+ drm_panel_init(&sharp_nt->base, &sharp_nt->dsi->dev,
258
+ &sharp_nt_panel_funcs, DRM_MODE_CONNECTOR_DSI);
273259
274
- if (IS_ERR(sharp_nt->backlight))
275
- return PTR_ERR(sharp_nt->backlight);
260
+ ret = drm_panel_of_backlight(&sharp_nt->base);
261
+ if (ret)
262
+ return ret;
276263
277
- drm_panel_init(&sharp_nt->base);
278
- sharp_nt->base.funcs = &sharp_nt_panel_funcs;
279
- sharp_nt->base.dev = &sharp_nt->dsi->dev;
264
+ drm_panel_add(&sharp_nt->base);
280265
281
- return drm_panel_add(&sharp_nt->base);
266
+ return 0;
282267 }
283268
284269 static void sharp_nt_panel_del(struct sharp_nt_panel *sharp_nt)
....@@ -295,6 +280,7 @@
295280 dsi->lanes = 2;
296281 dsi->format = MIPI_DSI_FMT_RGB888;
297282 dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
283
+ MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
298284 MIPI_DSI_MODE_VIDEO_HSE |
299285 MIPI_DSI_CLOCK_NON_CONTINUOUS |
300286 MIPI_DSI_MODE_EOT_PACKET;
....@@ -319,7 +305,7 @@
319305 struct sharp_nt_panel *sharp_nt = mipi_dsi_get_drvdata(dsi);
320306 int ret;
321307
322
- ret = sharp_nt_panel_disable(&sharp_nt->base);
308
+ ret = drm_panel_disable(&sharp_nt->base);
323309 if (ret < 0)
324310 dev_err(&dsi->dev, "failed to disable panel: %d\n", ret);
325311
....@@ -336,7 +322,7 @@
336322 {
337323 struct sharp_nt_panel *sharp_nt = mipi_dsi_get_drvdata(dsi);
338324
339
- sharp_nt_panel_disable(&sharp_nt->base);
325
+ drm_panel_disable(&sharp_nt->base);
340326 }
341327
342328 static const struct of_device_id sharp_nt_of_match[] = {