From 9c5d153cb996ca44f5ef92cd4646ce612b175261 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 8 Aug 2020 01:37:30 +0300 Subject: tests: crc: Introduce Composer class The Composer gathers the computation of planes position. It is currently only used to configure the planes. Signed-off-by: Laurent Pinchart --- tests/kms-test-crc.py | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/tests/kms-test-crc.py b/tests/kms-test-crc.py index e3e31b3..8876c88 100755 --- a/tests/kms-test-crc.py +++ b/tests/kms-test-crc.py @@ -2,9 +2,43 @@ # SPDX-License-Identifier: GPL-2.0-or-later # SPDX-FileCopyrightText: 2017-2019 Renesas Electronics Corporation +import copy import kmstest import pykms + +class Composer(object): + # Manage the composition of planes on the screen by computing the source + # and destination rectangles of each plane. + # + # Stack the plane, starting at START_POINT, with a fixed INCREMENT. + # + + START_POINT = kmstest.Point(0, 0) + INCREMENT = kmstest.Dist(50, 50) + + def __init__(self, crtc, planes, fb): + self.__fb_size = kmstest.Size(fb.width, fb.height) + self.__planes_positions = {} + + position = copy.copy(Composer.START_POINT) + for plane in planes: + self.__planes_positions[plane] = copy.copy(position) + position.move(Composer.INCREMENT) + + def source(self, plane): + pos = self.__planes_positions[plane] + return kmstest.Rect(0, 0, + max(0, self.__fb_size.width - pos.x), + max(0, self.__fb_size.height - pos.y)) + + def destination(self, plane): + pos = self.__planes_positions[plane] + return kmstest.Rect(pos.x, pos.y, + max(0, self.__fb_size.width - pos.x), + max(0, self.__fb_size.height - pos.y)) + + class CRCTest(kmstest.KMSTest): """Test CRC calculation on pipeline output.""" @@ -48,10 +82,13 @@ class CRCTest(kmstest.KMSTest): self.logger.log("Testing connector %s, CRTC %u, mode %s with %u planes" % \ (connector.fullname, crtc.id, mode.name, len(planes))) - # Create a frame buffer + # Create a frame buffer and draw a test pattern. fb = pykms.DumbFramebuffer(self.card, mode.hdisplay, mode.vdisplay, "XR24") pykms.draw_test_pattern(fb) + # Create a composer. + composer = Composer(crtc, planes, fb) + # Set the mode and add all planes ret = self.atomic_crtc_mode_set(crtc, connector, mode, sync=True) if ret < 0: @@ -60,10 +97,9 @@ class CRCTest(kmstest.KMSTest): req = kmstest.AtomicRequest(self) - offset = 100 for plane in planes: - source = kmstest.Rect(0, 0, fb.width, fb.height) - destination = kmstest.Rect(offset, offset, fb.width, fb.height) + source = composer.source(plane) + destination = composer.destination(plane) req.add(plane, { 'FB_ID': fb.id, 'CRTC_ID': crtc.id, @@ -76,7 +112,6 @@ class CRCTest(kmstest.KMSTest): 'CRTC_W': destination.width, 'CRTC_H': destination.height, }) - offset += 50 ret = req.commit(0) if ret < 0: -- cgit v1.2.3