.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2015 Red Hat |
---|
3 | 4 | * Copyright (C) 2015 Sony Mobile Communications Inc. |
---|
4 | 5 | * Author: Werner Johansson <werner.johansson@sonymobile.com> |
---|
5 | 6 | * |
---|
6 | 7 | * 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/>. |
---|
19 | 8 | */ |
---|
20 | 9 | |
---|
21 | | -#include <linux/backlight.h> |
---|
| 10 | +#include <linux/delay.h> |
---|
22 | 11 | #include <linux/gpio/consumer.h> |
---|
23 | 12 | #include <linux/module.h> |
---|
24 | 13 | #include <linux/of.h> |
---|
25 | 14 | #include <linux/regulator/consumer.h> |
---|
26 | 15 | |
---|
27 | | -#include <drm/drmP.h> |
---|
| 16 | +#include <video/mipi_display.h> |
---|
| 17 | + |
---|
28 | 18 | #include <drm/drm_crtc.h> |
---|
| 19 | +#include <drm/drm_device.h> |
---|
29 | 20 | #include <drm/drm_mipi_dsi.h> |
---|
30 | 21 | #include <drm/drm_panel.h> |
---|
31 | | - |
---|
32 | | -#include <video/mipi_display.h> |
---|
33 | 22 | |
---|
34 | 23 | struct sharp_nt_panel { |
---|
35 | 24 | struct drm_panel base; |
---|
36 | 25 | struct mipi_dsi_device *dsi; |
---|
37 | 26 | |
---|
38 | | - struct backlight_device *backlight; |
---|
39 | 27 | struct regulator *supply; |
---|
40 | 28 | struct gpio_desc *reset_gpio; |
---|
41 | 29 | |
---|
.. | .. |
---|
116 | 104 | |
---|
117 | 105 | if (!sharp_nt->enabled) |
---|
118 | 106 | return 0; |
---|
119 | | - |
---|
120 | | - backlight_disable(sharp_nt->backlight); |
---|
121 | 107 | |
---|
122 | 108 | sharp_nt->enabled = false; |
---|
123 | 109 | |
---|
.. | .. |
---|
200 | 186 | if (sharp_nt->enabled) |
---|
201 | 187 | return 0; |
---|
202 | 188 | |
---|
203 | | - backlight_enable(sharp_nt->backlight); |
---|
204 | | - |
---|
205 | 189 | sharp_nt->enabled = true; |
---|
206 | 190 | |
---|
207 | 191 | return 0; |
---|
208 | 192 | } |
---|
209 | 193 | |
---|
210 | 194 | static const struct drm_display_mode default_mode = { |
---|
211 | | - .clock = 41118, |
---|
| 195 | + .clock = (540 + 48 + 32 + 80) * (960 + 3 + 10 + 15) * 60 / 1000, |
---|
212 | 196 | .hdisplay = 540, |
---|
213 | 197 | .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, |
---|
216 | 200 | .vdisplay = 960, |
---|
217 | 201 | .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, |
---|
221 | 204 | }; |
---|
222 | 205 | |
---|
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) |
---|
224 | 208 | { |
---|
225 | 209 | struct drm_display_mode *mode; |
---|
226 | 210 | |
---|
227 | | - mode = drm_mode_duplicate(panel->drm, &default_mode); |
---|
| 211 | + mode = drm_mode_duplicate(connector->dev, &default_mode); |
---|
228 | 212 | 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)); |
---|
232 | 216 | return -ENOMEM; |
---|
233 | 217 | } |
---|
234 | 218 | |
---|
235 | 219 | drm_mode_set_name(mode); |
---|
236 | 220 | |
---|
237 | | - drm_mode_probed_add(panel->connector, mode); |
---|
| 221 | + drm_mode_probed_add(connector, mode); |
---|
238 | 222 | |
---|
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; |
---|
241 | 225 | |
---|
242 | 226 | return 1; |
---|
243 | 227 | } |
---|
.. | .. |
---|
253 | 237 | static int sharp_nt_panel_add(struct sharp_nt_panel *sharp_nt) |
---|
254 | 238 | { |
---|
255 | 239 | struct device *dev = &sharp_nt->dsi->dev; |
---|
| 240 | + int ret; |
---|
256 | 241 | |
---|
257 | 242 | sharp_nt->mode = &default_mode; |
---|
258 | 243 | |
---|
.. | .. |
---|
269 | 254 | gpiod_set_value(sharp_nt->reset_gpio, 0); |
---|
270 | 255 | } |
---|
271 | 256 | |
---|
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); |
---|
273 | 259 | |
---|
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; |
---|
276 | 263 | |
---|
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); |
---|
280 | 265 | |
---|
281 | | - return drm_panel_add(&sharp_nt->base); |
---|
| 266 | + return 0; |
---|
282 | 267 | } |
---|
283 | 268 | |
---|
284 | 269 | static void sharp_nt_panel_del(struct sharp_nt_panel *sharp_nt) |
---|
.. | .. |
---|
295 | 280 | dsi->lanes = 2; |
---|
296 | 281 | dsi->format = MIPI_DSI_FMT_RGB888; |
---|
297 | 282 | dsi->mode_flags = MIPI_DSI_MODE_VIDEO | |
---|
| 283 | + MIPI_DSI_MODE_VIDEO_SYNC_PULSE | |
---|
298 | 284 | MIPI_DSI_MODE_VIDEO_HSE | |
---|
299 | 285 | MIPI_DSI_CLOCK_NON_CONTINUOUS | |
---|
300 | 286 | MIPI_DSI_MODE_EOT_PACKET; |
---|
.. | .. |
---|
319 | 305 | struct sharp_nt_panel *sharp_nt = mipi_dsi_get_drvdata(dsi); |
---|
320 | 306 | int ret; |
---|
321 | 307 | |
---|
322 | | - ret = sharp_nt_panel_disable(&sharp_nt->base); |
---|
| 308 | + ret = drm_panel_disable(&sharp_nt->base); |
---|
323 | 309 | if (ret < 0) |
---|
324 | 310 | dev_err(&dsi->dev, "failed to disable panel: %d\n", ret); |
---|
325 | 311 | |
---|
.. | .. |
---|
336 | 322 | { |
---|
337 | 323 | struct sharp_nt_panel *sharp_nt = mipi_dsi_get_drvdata(dsi); |
---|
338 | 324 | |
---|
339 | | - sharp_nt_panel_disable(&sharp_nt->base); |
---|
| 325 | + drm_panel_disable(&sharp_nt->base); |
---|
340 | 326 | } |
---|
341 | 327 | |
---|
342 | 328 | static const struct of_device_id sharp_nt_of_match[] = { |
---|