1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
From 2787e876c661f4cec8d05de0e7cc2ec033a8a7bf Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.org>
Date: Tue, 21 May 2019 11:50:00 +0100
Subject: [PATCH 616/773] drm: vc4: Probe DPI/DSI timings from the firmware
For DPI and DSI displays query the firmware as to the configuration
and add it as the only mode for DRM.
In theory we can add plumbing for setting the DPI/DSI mode from
KMS, but this is not being added at present as the support frameworks
aren't present in the firmware.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
---
drivers/gpu/drm/vc4/vc4_firmware_kms.c | 60 ++++++++++++++++++----
include/soc/bcm2835/raspberrypi-firmware.h | 1 +
2 files changed, 51 insertions(+), 10 deletions(-)
--- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
@@ -280,7 +280,7 @@ static u32 vc4_get_display_type(u32 disp
/* The firmware display (DispmanX) IDs map to specific types in
* a fixed manner.
*/
- DRM_MODE_ENCODER_DSI, /* MAIN_LCD */
+ DRM_MODE_ENCODER_DSI, /* MAIN_LCD - DSI or DPI */
DRM_MODE_ENCODER_DSI, /* AUX_LCD */
DRM_MODE_ENCODER_TMDS, /* HDMI0 */
DRM_MODE_ENCODER_TVDAC, /* VEC */
@@ -362,7 +362,6 @@ static void vc4_plane_atomic_update(stru
vc4_get_vc_image_fmt(drm_fmt->format);
struct vc4_fkms_plane *vc4_plane = to_vc4_fkms_plane(plane);
struct mailbox_set_plane *mb = &vc4_plane->mb;
- struct vc4_crtc *vc4_crtc = to_vc4_crtc(state->crtc);
int num_planes = fb->format->num_planes;
struct drm_display_mode *mode = &state->crtc->mode;
unsigned int rotation = SUPPORTED_ROTATIONS;
@@ -997,7 +996,9 @@ static int vc4_fkms_connector_get_modes(
return ret;
}
-/* FIXME: Read LCD mode from the firmware. This is the DSI panel resolution. */
+/* This is the DSI panel resolution. Use this as a default should the firmware
+ * not respond to our request for the timings.
+ */
static const struct drm_display_mode lcd_mode = {
DRM_MODE("800x480", DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
25979400 / 1000,
@@ -1008,15 +1009,54 @@ static const struct drm_display_mode lcd
static int vc4_fkms_lcd_connector_get_modes(struct drm_connector *connector)
{
- //struct vc4_fkms_connector *fkms_connector =
- // to_vc4_fkms_connector(connector);
- //struct drm_encoder *encoder = fkms_connector->encoder;
- //struct vc4_fkms_encoder *vc4_encoder = to_vc4_fkms_encoder(encoder);
+ struct vc4_fkms_connector *fkms_connector =
+ to_vc4_fkms_connector(connector);
+ struct vc4_dev *vc4 = fkms_connector->vc4_dev;
struct drm_display_mode *mode;
- //int ret = 0;
+ struct mailbox_set_mode mb = {
+ .tag1 = { RPI_FIRMWARE_GET_DISPLAY_TIMING,
+ sizeof(struct set_timings), 0},
+ .timings = { .display = fkms_connector->display_number },
+ };
+ struct drm_display_mode fw_mode;
+ int ret = 0;
+
+ ret = rpi_firmware_property_list(vc4->firmware, &mb, sizeof(mb));
+ if (!ret) {
+ /* Equivalent to DRM_MODE macro. */
+ memset(&fw_mode, 0, sizeof(fw_mode));
+ strncpy(fw_mode.name, "LCD_MODE", sizeof(fw_mode.name));
+ fw_mode.status = 0;
+ fw_mode.type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+ fw_mode.clock = mb.timings.clock;
+ fw_mode.hdisplay = mb.timings.hdisplay;
+ fw_mode.hsync_start = mb.timings.hsync_start;
+ fw_mode.hsync_end = mb.timings.hsync_end;
+ fw_mode.htotal = mb.timings.htotal;
+ fw_mode.hskew = 0;
+ fw_mode.vdisplay = mb.timings.vdisplay;
+ fw_mode.vsync_start = mb.timings.vsync_start;
+ fw_mode.vsync_end = mb.timings.vsync_end;
+ fw_mode.vtotal = mb.timings.vtotal;
+ fw_mode.vscan = mb.timings.vscan;
+ if (mb.timings.flags & TIMINGS_FLAGS_H_SYNC_POS)
+ fw_mode.flags |= DRM_MODE_FLAG_PHSYNC;
+ else
+ fw_mode.flags |= DRM_MODE_FLAG_NHSYNC;
+ if (mb.timings.flags & TIMINGS_FLAGS_V_SYNC_POS)
+ fw_mode.flags |= DRM_MODE_FLAG_PVSYNC;
+ else
+ fw_mode.flags |= DRM_MODE_FLAG_NVSYNC;
+
+ fw_mode.base.type = DRM_MODE_OBJECT_MODE;
+
+ mode = drm_mode_duplicate(connector->dev,
+ &fw_mode);
+ } else {
+ mode = drm_mode_duplicate(connector->dev,
+ &lcd_mode);
+ }
- mode = drm_mode_duplicate(connector->dev,
- &lcd_mode);
if (!mode) {
DRM_ERROR("Failed to create a new display mode\n");
return -ENOMEM;
--- a/include/soc/bcm2835/raspberrypi-firmware.h
+++ b/include/soc/bcm2835/raspberrypi-firmware.h
@@ -151,6 +151,7 @@ enum rpi_firmware_property_tag {
RPI_FIRMWARE_VCHIQ_INIT = 0x00048010,
RPI_FIRMWARE_SET_PLANE = 0x00048015,
+ RPI_FIRMWARE_GET_DISPLAY_TIMING = 0x00040017,
RPI_FIRMWARE_SET_TIMING = 0x00048017,
RPI_FIRMWARE_GET_COMMAND_LINE = 0x00050001,
|