From patchwork Fri Dec 15 13:48:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10115141 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 243C260231 for ; Fri, 15 Dec 2017 13:48:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CACB2906B for ; Fri, 15 Dec 2017 13:48:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB89829F6B; Fri, 15 Dec 2017 13:48:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 854BF2906B for ; Fri, 15 Dec 2017 13:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756333AbdLONsw (ORCPT ); Fri, 15 Dec 2017 08:48:52 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:53275 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756232AbdLONsv (ORCPT ); Fri, 15 Dec 2017 08:48:51 -0500 Received: from avalon.wireless.UGent.be (nata100.ugent.be [157.193.240.100]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id C392B20218; Fri, 15 Dec 2017 14:48:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1513345723; bh=xRTZTdcBOEW6E5ZDXyfID5cp5rB6BayY01YjX+0ZAEw=; h=From:To:Cc:Subject:Date:From; b=pBPkIKbSXR0NwTmaj/t2YMVpJ6GFT324/hzys97gCfbVZqgg9eoWT6KRYBBADf0GL R5+fr2ZJXOstP07Zn09E1w5E5B7lEPhPJG6I5ZAZkSzUTI/Op1naTci2Nz9Xdk1snv 2xznAB4TQoUm1dPkaaZFLE9pmgo9+G66FvEz4Zbo= From: Laurent Pinchart To: linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham Subject: [PATCH] [kms-tests] tests: Add colorkey test Date: Fri, 15 Dec 2017 15:48:48 +0200 Message-Id: <20171215134848.19680-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.13.6 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The test will display an overlay with large colored boxes on top of the root plane and turn the boxes translucent or transparent in sequence using color keying. Signed-off-by: Laurent Pinchart --- tests/kms-test-colorkey.py | 111 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100755 tests/kms-test-colorkey.py diff --git a/tests/kms-test-colorkey.py b/tests/kms-test-colorkey.py new file mode 100755 index 000000000000..310165f83b1e --- /dev/null +++ b/tests/kms-test-colorkey.py @@ -0,0 +1,111 @@ +#!/usr/bin/python3 + +import kmstest +import pykms +import time + +class ColorKeyTest(kmstest.KMSTest): + """Test color keying with two planes.""" + + def main(self): + self.start("color keying") + + # Find a CRTC with a connected connector and at least one overlay plane + for connector in self.card.connectors: + if not connector.connected(): + continue + + try: + mode = connector.get_default_mode() + except ValueError: + continue + + crtcs = connector.get_possible_crtcs() + for crtc in crtcs: + overlay = None + for plane in self.card.planes: + if plane.supports_crtc(crtc) and plane != crtc.primary_plane: + overlay = plane + + if overlay: + break + else: + crtc = None + + if crtc: + break + + else: + self.skip("no CRTC available with connector and at least one overlay plane") + return + + self.logger.log("Testing connector %s, CRTC %u, mode %s" % \ + (connector.fullname, crtc.id, mode.name)) + + # Create the frame buffers + colors = ((255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 255)) + width = mode.hdisplay + height = mode.vdisplay + fbs = [] + + fb = pykms.DumbFramebuffer(self.card, width, height, "XR24") + pykms.draw_test_pattern(fb) + fbs.append(fb) + + fb = pykms.DumbFramebuffer(self.card, width, height, "XR24") + pykms.draw_rect(fb, 0, 0, width // 2, height // 2, pykms.RGB(*colors[0])) + pykms.draw_rect(fb, width // 2, 0, width // 2, height // 2, pykms.RGB(*colors[1])) + pykms.draw_rect(fb, 0, height // 2, width // 2, height // 2, pykms.RGB(*colors[2])) + pykms.draw_rect(fb, width // 2, height // 2, width // 2, height // 2, pykms.RGB(*colors[3])) + fbs.append(fb) + + # Set the mode with the primary plane and add an overlay plane + ret = self.atomic_crtc_mode_set(crtc, connector, mode, fbs[0]) + if ret < 0: + self.fail("atomic mode set failed with %d" % ret) + return + + self.logger.log("Initial atomic mode set completed") + + # Add the overlay plane to cover the whole CRTC + source = kmstest.Rect(0, 0, fbs[1].width, fbs[1].height) + destination = kmstest.Rect(0, 0, fbs[1].width, fbs[1].height) + ret = self.atomic_plane_set(overlay, crtc, source, destination, fbs[1], sync=True) + if ret < 0: + self.fail("atomic plane set for overlay plane failed with %d" % ret) + return + + self.logger.log("Overlay plane enabled") + time.sleep(3) + + # Try to set different minimum and maximum values, this should be + # rejected. + req = pykms.AtomicReq(self.card) + req.add(plane, {"colorkey.min": 1, "colorkey.max": 2}) + ret = req.commit_sync() + if ret >= 0: + self.fail("Non-equal colorkey min and max not rejected") + return + + self.logger.log("Non-equal colorkey min and max correctly rejected") + + # Cycle over color keys to make the four rectangles in the overlay plane + # transparent in turn. + for i in range(len(colors)): + color = (colors[i][0] << 40) | (colors[i][1] << 24) | (colors[i][2] << 8) + + plane.set_props({ + "colorkey.mode": 1, + "colorkey.min": color, + "colorkey.max": color, + "colorkey.value": (255 * (len(colors) - i - 1) // 4) << 56, + }) + + self.logger.log("Color key set to %s" % repr(colors[i])) + time.sleep(3) + + plane.set_prop("colorkey.mode", 0) + self.atomic_crtc_disable(crtc) + self.success() + +ColorKeyTest().execute()