From 85507dc377186cfef0f27c99f67434dd3efae9e6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 10 Jun 2022 01:09:49 +0300 Subject: tests: Add plane zpos test Add a test that enables multiple planes with different zpos values. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- tests/kms-test-plane-zpos.py | 102 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 tests/kms-test-plane-zpos.py diff --git a/tests/kms-test-plane-zpos.py b/tests/kms-test-plane-zpos.py new file mode 100755 index 0000000..052eea5 --- /dev/null +++ b/tests/kms-test-plane-zpos.py @@ -0,0 +1,102 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# SPDX-FileCopyrightText: 2022 Renesas Electronics Corporation + +import kmstest +import pykms + +class PlaneZPosTest(kmstest.KMSTest): + """Test composition with multiple planes and custom z-pos.""" + + def handle_page_flip(self, frame, time): + self.logger.log('Page flip complete') + + def find_pipeline(self): + # Find a CRTC that has multiple planes with a connected connector + for connector in self.output_connectors(): + # Skip disconnected connectors + if not connector.connected(): + continue + + # Add the connector to the map + for crtc in connector.get_possible_crtcs(): + planes = [] + for plane in self.card.planes: + if plane.supports_crtc(crtc) and plane != crtc.primary_plane: + planes.append(plane) + + if len(planes): + return crtc, connector, planes + + return None, None, None + + def main(self): + self.start('composition with z-pos control') + + crtc, connector, planes = self.find_pipeline() + if crtc is None: + self.skip('no suitable pipeline') + return + + # Get the default mode + try: + mode = connector.get_default_mode() + except KeyError: + self.skip('no mode available') + return + + self.logger.log(f'Testing connector {connector.fullname}, CRTC {crtc.id}, ' + f'mode {mode.name} with {len(planes)} planes ' + f'(P: {crtc.primary_plane.id}, O: {[plane.id for plane in planes]})') + + # Create a frame buffer + fb = pykms.DumbFramebuffer(self.card, mode.hdisplay, mode.vdisplay, 'XR24') + pykms.draw_test_pattern(fb) + + # Set the mode with a primary plane, and position it on top of the + # stack. Make it transparent to visualize the overlay planes that will + # be positioned underneath. + zpos = len(planes) + ret = self.atomic_crtc_mode_set(crtc, connector, mode, fb) + if ret < 0: + self.fail(f'atomic mode set failed with {ret}') + return + + req = kmstest.AtomicRequest(self) + req.add(crtc.primary_plane, 'alpha', '50%') + req.add(crtc.primary_plane, 'zpos', zpos) + ret = req.commit_sync(True) + if ret < 0: + self.fail(f'failed to set properties for primary plane: {ret}') + return + + self.run(3) + + # Add all other planes one by one + offset = 100 + 50 * (len(planes) - 1) + + for plane in planes: + zpos -= 1 + + source = kmstest.Rect(0, 0, fb.width, fb.height) + destination = kmstest.Rect(offset, offset, fb.width, fb.height) + ret = self.atomic_plane_set(plane, crtc, source, destination, fb, alpha='100%', zpos=zpos) + if ret < 0: + self.fail(f'atomic plane set failed with {ret}') + break + + self.logger.log(f'Adding plane {plane.id}') + self.run(1) + + if self.flips == 0: + self.fail('No page flip registered') + break + + offset -= 50 + + else: + self.success() + + self.atomic_crtc_disable(crtc) + +PlaneZPosTest().execute() -- cgit v1.2.3