summaryrefslogtreecommitdiff
path: root/tests/kms-test-legacy-modeset.py
blob: 4b560534539175684698faa8a06e2826bdd2d94c (plain)
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
#!/usr/bin/python3
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2018-2019 Renesas Electronics Corporation

import kmstest
import pykms

class LegacyModeSetTest(kmstest.KMSTest):
    """Test mode setting on all connectors in sequence with the default mode through the legacy mode set API."""

    def handle_page_flip(self, frame, time):
        self.logger.log("Page flip complete")

    def main(self):
        for connector in self.output_connectors():
            self.start("legacy mode set on connector %s" % connector.fullname)

            # Skip disconnected connectors
            if not connector.connected():
                self.skip("unconnected connector")
                continue

            # Find a CRTC suitable for the connector
            crtc = connector.get_current_crtc()
            if not crtc:
                crtcs = connector.get_possible_crtcs()
                if len(crtcs) == 0:
                    pass

                crtc = crtcs[0]

            # Get the default mode for the connector
            try:
                mode = connector.get_default_mode()
            except ValueError:
                self.skip("no mode available")
                continue

            self.logger.log("Testing connector %s on CRTC %u with mode %s" % \
                  (connector.fullname, crtc.id, mode.name))

            # Create a frame buffer
            fb = pykms.DumbFramebuffer(self.card, mode.hdisplay, mode.vdisplay, "XR24")
            pykms.draw_test_pattern(fb)

            # Perform a mode set
            ret = crtc.set_mode(connector, fb, mode)
            if ret < 0:
                self.fail("legacy mode set failed with %d" % ret)
                continue

            self.logger.log("Legacy mode set complete")
            self.run(5)

            ret = crtc.disable_mode()
            if ret < 0:
                self.fail("legacy mode set disable failed with %d" % ret)
                continue

            self.success()

LegacyModeSetTest().execute()