hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
....@@ -44,8 +44,6 @@
4444 #include <linux/delay.h>
4545 #include <linux/err.h>
4646 #include <linux/fb.h>
47
-#include <linux/gpio.h>
48
-#include <linux/gpio/consumer.h>
4947 #include <linux/i2c.h>
5048 #include <linux/module.h>
5149 #include <linux/of.h>
....@@ -53,9 +51,8 @@
5351 #include <linux/of_graph.h>
5452 #include <linux/pm.h>
5553
56
-#include <drm/drm_panel.h>
57
-#include <drm/drmP.h>
5854 #include <drm/drm_crtc.h>
55
+#include <drm/drm_device.h>
5956 #include <drm/drm_mipi_dsi.h>
6057 #include <drm/drm_panel.h>
6158
....@@ -212,7 +209,6 @@
212209 .vsync_start = 480 + 7,
213210 .vsync_end = 480 + 7 + 2,
214211 .vtotal = 480 + 7 + 2 + 21,
215
- .vrefresh = 60,
216212 },
217213 };
218214
....@@ -233,7 +229,7 @@
233229
234230 ret = i2c_smbus_write_byte_data(ts->i2c, reg, val);
235231 if (ret)
236
- dev_err(&ts->dsi->dev, "I2C write failed: %d\n", ret);
232
+ dev_err(&ts->i2c->dev, "I2C write failed: %d\n", ret);
237233 }
238234
239235 static int rpi_touchscreen_write(struct rpi_touchscreen *ts, u16 reg, u32 val)
....@@ -269,7 +265,7 @@
269265 return 0;
270266 }
271267
272
-static int rpi_touchscreen_enable(struct drm_panel *panel)
268
+static int rpi_touchscreen_prepare(struct drm_panel *panel)
273269 {
274270 struct rpi_touchscreen *ts = panel_to_ts(panel);
275271 int i;
....@@ -299,6 +295,13 @@
299295 rpi_touchscreen_write(ts, DSI_STARTDSI, 0x01);
300296 msleep(100);
301297
298
+ return 0;
299
+}
300
+
301
+static int rpi_touchscreen_enable(struct drm_panel *panel)
302
+{
303
+ struct rpi_touchscreen *ts = panel_to_ts(panel);
304
+
302305 /* Turn on the backlight. */
303306 rpi_touchscreen_i2c_write(ts, REG_PWM, 255);
304307
....@@ -312,10 +315,9 @@
312315 return 0;
313316 }
314317
315
-static int rpi_touchscreen_get_modes(struct drm_panel *panel)
318
+static int rpi_touchscreen_get_modes(struct drm_panel *panel,
319
+ struct drm_connector *connector)
316320 {
317
- struct drm_connector *connector = panel->connector;
318
- struct drm_device *drm = panel->drm;
319321 unsigned int i, num = 0;
320322 static const u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
321323
....@@ -323,10 +325,11 @@
323325 const struct drm_display_mode *m = &rpi_touchscreen_modes[i];
324326 struct drm_display_mode *mode;
325327
326
- mode = drm_mode_duplicate(drm, m);
328
+ mode = drm_mode_duplicate(connector->dev, m);
327329 if (!mode) {
328
- dev_err(drm->dev, "failed to add mode %ux%u@%u\n",
329
- m->hdisplay, m->vdisplay, m->vrefresh);
330
+ dev_err(panel->dev, "failed to add mode %ux%u@%u\n",
331
+ m->hdisplay, m->vdisplay,
332
+ drm_mode_vrefresh(m));
330333 continue;
331334 }
332335
....@@ -353,7 +356,7 @@
353356 static const struct drm_panel_funcs rpi_touchscreen_funcs = {
354357 .disable = rpi_touchscreen_disable,
355358 .unprepare = rpi_touchscreen_noop,
356
- .prepare = rpi_touchscreen_noop,
359
+ .prepare = rpi_touchscreen_prepare,
357360 .enable = rpi_touchscreen_enable,
358361 .get_modes = rpi_touchscreen_get_modes,
359362 };
....@@ -365,7 +368,7 @@
365368 struct rpi_touchscreen *ts;
366369 struct device_node *endpoint, *dsi_host_node;
367370 struct mipi_dsi_host *host;
368
- int ret, ver;
371
+ int ver;
369372 struct mipi_dsi_device_info info = {
370373 .type = RPI_DSI_DRIVER_NAME,
371374 .channel = 0,
....@@ -427,16 +430,13 @@
427430 return PTR_ERR(ts->dsi);
428431 }
429432
430
- drm_panel_init(&ts->base);
431
- ts->base.dev = dev;
432
- ts->base.funcs = &rpi_touchscreen_funcs;
433
+ drm_panel_init(&ts->base, dev, &rpi_touchscreen_funcs,
434
+ DRM_MODE_CONNECTOR_DSI);
433435
434436 /* This appears last, as it's what will unblock the DSI host
435437 * driver's component bind function.
436438 */
437
- ret = drm_panel_add(&ts->base);
438
- if (ret)
439
- return ret;
439
+ drm_panel_add(&ts->base);
440440
441441 return 0;
442442