hc
2023-02-13 e440ec23c5a540cdd3f7464e8779219be6fd3d95
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
From e3d2463418b3e400b10e2248434389eb8e9c4b9b Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Fri, 14 Aug 2020 14:28:31 +0800
Subject: [PATCH 25/31] linuxfbdrm: Delay setMode to swapBuffers()
 
To avoid blank screen during setup.
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 .../platforms/linuxfb/qlinuxfbdrmscreen.cpp   | 29 ++++++++++---------
 1 file changed, 16 insertions(+), 13 deletions(-)
 
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp
index 5745ef06..b6e3960d 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp
@@ -102,8 +102,8 @@ public:
 
     void createFramebuffers();
     void destroyFramebuffers();
-    void setMode();
 
+    void setMode(Output *output);
     void swapBuffers(Output *output);
     void waitForFlip(Output *output);
 
@@ -339,19 +339,21 @@ void QLinuxFbDevice::destroyFramebuffers()
     }
 }
 
-void QLinuxFbDevice::setMode()
+void QLinuxFbDevice::setMode(Output *output)
 {
-    for (Output &output : m_outputs) {
-        drmModeModeInfo &modeInfo(output.kmsOutput.modes[output.kmsOutput.mode]);
-        if (drmModeSetCrtc(fd(), output.kmsOutput.crtc_id, output.fb[0].fb, 0, 0,
-                           &output.kmsOutput.connector_id, 1, &modeInfo) == -1) {
-            qErrnoWarning(errno, "Failed to set mode");
-            return;
-        }
+    drmModeModeInfo &modeInfo(output->kmsOutput.modes[output->kmsOutput.mode]);
+
+    if (output->kmsOutput.mode_set)
+        return;
 
-        output.kmsOutput.mode_set = true; // have cleanup() to restore the mode
-        output.kmsOutput.setPowerState(this, QPlatformScreen::PowerStateOn);
+    if (drmModeSetCrtc(fd(), output->kmsOutput.crtc_id, output->fb[0].fb, 0, 0,
+                       &output->kmsOutput.connector_id, 1, &modeInfo) == -1) {
+        qErrnoWarning(errno, "Failed to set mode");
+        return;
     }
+
+    output->kmsOutput.mode_set = true; // have cleanup() to restore the mode
+    output->kmsOutput.setPowerState(this, QPlatformScreen::PowerStateOn);
 }
 
 void QLinuxFbDevice::pageFlipHandler(int fd, unsigned int sequence,
@@ -394,7 +396,10 @@ void QLinuxFbDevice::swapBuffers(Output *output)
     waitForFlip(output);
 #endif
 
+    setMode(output);
+
     Framebuffer &fb(output->fb[output->backFb]);
+
     if (drmModePageFlip(fd(), output->kmsOutput.crtc_id, fb.fb, DRM_MODE_PAGE_FLIP_EVENT, output) == -1) {
         qErrnoWarning(errno, "Page flip failed");
         return;
@@ -443,8 +448,6 @@ bool QLinuxFbDrmScreen::initialize()
     m_device->createScreens();
     // Now off to dumb buffer specifics.
     m_device->createFramebuffers();
-    // Do the modesetting.
-    m_device->setMode();
 
     QLinuxFbDevice::Output *output(m_device->output(0));
 
-- 
2.20.1