.. | .. |
---|
| 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/module.h> |
---|
23 | 12 | #include <linux/of.h> |
---|
24 | 13 | #include <linux/regulator/consumer.h> |
---|
25 | 14 | |
---|
26 | | -#include <drm/drmP.h> |
---|
| 15 | +#include <video/mipi_display.h> |
---|
| 16 | + |
---|
27 | 17 | #include <drm/drm_crtc.h> |
---|
| 18 | +#include <drm/drm_device.h> |
---|
28 | 19 | #include <drm/drm_mipi_dsi.h> |
---|
29 | 20 | #include <drm/drm_panel.h> |
---|
30 | | - |
---|
31 | | -#include <video/mipi_display.h> |
---|
32 | 21 | |
---|
33 | 22 | /* |
---|
34 | 23 | * When power is turned off to this panel a minimum off time of 500ms has to be |
---|
.. | .. |
---|
41 | 30 | struct drm_panel base; |
---|
42 | 31 | struct mipi_dsi_device *dsi; |
---|
43 | 32 | |
---|
44 | | - struct backlight_device *backlight; |
---|
45 | 33 | struct regulator *supply; |
---|
46 | 34 | |
---|
47 | 35 | bool prepared; |
---|
.. | .. |
---|
71 | 59 | return 0; |
---|
72 | 60 | |
---|
73 | 61 | 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 | | - } |
---|
80 | 62 | |
---|
81 | 63 | wuxga_nt->enabled = false; |
---|
82 | 64 | |
---|
.. | .. |
---|
152 | 134 | if (wuxga_nt->enabled) |
---|
153 | 135 | return 0; |
---|
154 | 136 | |
---|
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 | | - |
---|
161 | 137 | wuxga_nt->enabled = true; |
---|
162 | 138 | |
---|
163 | 139 | return 0; |
---|
.. | .. |
---|
173 | 149 | .vsync_start = 1200 + 24, |
---|
174 | 150 | .vsync_end = 1200 + 24 + 6, |
---|
175 | 151 | .vtotal = 1200 + 24 + 6 + 48, |
---|
176 | | - .vrefresh = 60, |
---|
177 | 152 | }; |
---|
178 | 153 | |
---|
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) |
---|
180 | 156 | { |
---|
181 | 157 | struct drm_display_mode *mode; |
---|
182 | 158 | |
---|
183 | | - mode = drm_mode_duplicate(panel->drm, &default_mode); |
---|
| 159 | + mode = drm_mode_duplicate(connector->dev, &default_mode); |
---|
184 | 160 | 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)); |
---|
188 | 164 | return -ENOMEM; |
---|
189 | 165 | } |
---|
190 | 166 | |
---|
191 | 167 | drm_mode_set_name(mode); |
---|
192 | 168 | |
---|
193 | | - drm_mode_probed_add(panel->connector, mode); |
---|
| 169 | + drm_mode_probed_add(connector, mode); |
---|
194 | 170 | |
---|
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; |
---|
197 | 173 | |
---|
198 | 174 | return 1; |
---|
199 | 175 | } |
---|
.. | .. |
---|
215 | 191 | static int wuxga_nt_panel_add(struct wuxga_nt_panel *wuxga_nt) |
---|
216 | 192 | { |
---|
217 | 193 | struct device *dev = &wuxga_nt->dsi->dev; |
---|
218 | | - struct device_node *np; |
---|
219 | 194 | int ret; |
---|
220 | 195 | |
---|
221 | 196 | wuxga_nt->mode = &default_mode; |
---|
.. | .. |
---|
224 | 199 | if (IS_ERR(wuxga_nt->supply)) |
---|
225 | 200 | return PTR_ERR(wuxga_nt->supply); |
---|
226 | 201 | |
---|
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); |
---|
231 | 204 | |
---|
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; |
---|
235 | 208 | |
---|
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); |
---|
243 | 210 | |
---|
244 | 211 | return 0; |
---|
245 | | - |
---|
246 | | -put_backlight: |
---|
247 | | - if (wuxga_nt->backlight) |
---|
248 | | - put_device(&wuxga_nt->backlight->dev); |
---|
249 | | - |
---|
250 | | - return ret; |
---|
251 | 212 | } |
---|
252 | 213 | |
---|
253 | 214 | static void wuxga_nt_panel_del(struct wuxga_nt_panel *wuxga_nt) |
---|
254 | 215 | { |
---|
255 | 216 | if (wuxga_nt->base.dev) |
---|
256 | 217 | drm_panel_remove(&wuxga_nt->base); |
---|
257 | | - |
---|
258 | | - if (wuxga_nt->backlight) |
---|
259 | | - put_device(&wuxga_nt->backlight->dev); |
---|
260 | 218 | } |
---|
261 | 219 | |
---|
262 | 220 | static int wuxga_nt_panel_probe(struct mipi_dsi_device *dsi) |
---|
.. | .. |
---|
291 | 249 | struct wuxga_nt_panel *wuxga_nt = mipi_dsi_get_drvdata(dsi); |
---|
292 | 250 | int ret; |
---|
293 | 251 | |
---|
294 | | - ret = wuxga_nt_panel_disable(&wuxga_nt->base); |
---|
| 252 | + ret = drm_panel_disable(&wuxga_nt->base); |
---|
295 | 253 | if (ret < 0) |
---|
296 | 254 | dev_err(&dsi->dev, "failed to disable panel: %d\n", ret); |
---|
297 | 255 | |
---|
.. | .. |
---|
308 | 266 | { |
---|
309 | 267 | struct wuxga_nt_panel *wuxga_nt = mipi_dsi_get_drvdata(dsi); |
---|
310 | 268 | |
---|
311 | | - wuxga_nt_panel_disable(&wuxga_nt->base); |
---|
| 269 | + drm_panel_disable(&wuxga_nt->base); |
---|
312 | 270 | } |
---|
313 | 271 | |
---|
314 | 272 | static struct mipi_dsi_driver wuxga_nt_panel_driver = { |
---|