Skip to contentSkip to conversation

Test pixel blend mode

PATCH In review Takanari Hayama 3 participants 13 messages Jul 4, 2022 – Aug 1, 2022

lore
Share & tools
lore
#0 lore raw

cover Test pixel blend mode

Hello,

This patch series extends the kms-test scripts to test pixel blend mode.

The patches are based on series of patches posted by Laurent ([1]).

[1] https://lore.kernel.org/linux-renesas-soc/[email protected]/T/#t

Takanari Hayama (3):
tests: Support enum property type
kmstest: Support specifying pixel blend mode for planes
tests: Add pixel blend mode test

 tests/kms-test-plane-blendmode.py | 100 ++++++++++++++++++++++++++++++
 tests/kmstest.py                  |  16 ++++-
 2 files changed, 114 insertions(+), 2 deletions(-)
 create mode 100755 tests/kms-test-plane-blendmode.py
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 tests: Support enum property type

Add a support for enum property type to AtomicRequest.

---
 tests/kmstest.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
tests/kmstest.py +11 -1
index 11cc328b5b32..224c160e32fa 100755
@@ -269,8 +269,18 @@ class AtomicRequest(pykms.AtomicReq):
 
                     min, max = prop.values
                     v = min + int((max - min) * int(v[:-1]) / 100)
-                else:
+                elif v.isnumeric():
                     v = int(v)
+                else:
+                    prop = obj.get_prop(k)
+                    if prop.type != pykms.PropertyType.Enum:
+                        raise RuntimeError(f'Unsupported property type {prop.type} for value {v}')
+                    for value, mode in prop.enums.items():
+                        if mode == v:
+                            v = value
+                            break
+                    else:
+                        raise RuntimeError(f'Enum value with name "{v}" not found in property {k}')
 
             if not isinstance(v, int):
                 raise RuntimeError(f'Unsupported value type {type(v)} for property {k}')
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/3] tests: Support enum property type

Hello!

Quoted 17 lines · Takanari Hayama

Add a support for enum property type to AtomicRequest.

---
 tests/kmstest.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
tests/kmstest.py +1 -1
index 11cc328b5b32..224c160e32fa 100755
@@ -269,8 +269,18 @@ class AtomicRequest(pykms.AtomicReq):
 
                     min, max = prop.values
                     v = min + int((max - min) * int(v[:-1]) / 100)
-                else:
+                elif v.isnumeric():

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 282

Quoted 10 lines
tests/kmstest.py +9 -0
                     v = int(v)
+                else:
+                    prop = obj.get_prop(k)
+                    if prop.type != pykms.PropertyType.Enum:
+                        raise RuntimeError(f'Unsupported property type {prop.type} for value {v}')
+                    for value, mode in prop.enums.items():
+                        if mode == v:
+                            v = value
+                            break
+                    else:

Hm, doesn't seem to be correctly aligned?

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 286

Quoted 4 lines
tests/kmstest.py +1 -0
+                        raise RuntimeError(f'Enum value with name "{v}" not found in property {k}')
 
             if not isinstance(v, int):
                 raise RuntimeError(f'Unsupported value type {type(v)} for property {k}')

MBR, Sergey

#3 lore raw

Re: [PATCH 1/3] tests: Support enum property type

Hi Sergei,

Quoted 19 lines

2022/07/04 17:43、Sergei Shtylyov <[email protected]>のメール:

Hello!

Quoted 13 lines · Takanari Hayama

Add a support for enum property type to AtomicRequest.

---
tests/kmstest.py | 12 +++++++++++-

1 file changed, 11 insertions(+), 1 deletion(-)
tests/kmstest.py +0 -0
index 11cc328b5b32..224c160e32fa 100755
@@ -269,8 +269,18 @@ class AtomicRequest(pykms.AtomicReq):
 
Quoted 16 lines
Quoted 4 lines
tests/kmstest.py +1 -1
                    min, max = prop.values
                    v = min + int((max - min) * int(v[:-1]) / 100)
-                else:
+                elif v.isnumeric():

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 282

Quoted 10 lines
tests/kmstest.py +9 -0
                    v = int(v)
+                else:
+                    prop = obj.get_prop(k)
+                    if prop.type != pykms.PropertyType.Enum:
+                        raise RuntimeError(f'Unsupported property type {prop.type} for value {v}')
+                    for value, mode in prop.enums.items():
+                        if mode == v:
+                            v = value
+                            break
+                    else:

Hm, doesn't seem to be correctly aligned?

That ‘else’ is for ‘for’-loop. Am I missing something here?

Quoted 6 lines

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 286

Quoted 4 lines
tests/kmstest.py +1 -0
+                        raise RuntimeError(f'Enum value with name "{v}" not found in property {k}')
 
            if not isinstance(v, int):
                raise RuntimeError(f'Unsupported value type {type(v)} for property {k}')

MBR, Sergey

Many Thanks,
Takanari Hayama, Ph.D. <[email protected]>
IGEL Co., Ltd.
https://www.igel.co.jp/

#4 lore raw

Re: [PATCH 1/3] tests: Support enum property type

On 7/4/22 11:53 AM, Takanari Hayama wrote:
[...]

Quoted 30 lines
Quoted 13 lines
Quoted 13 lines

Add a support for enum property type to AtomicRequest.

---
tests/kmstest.py | 12 +++++++++++-

1 file changed, 11 insertions(+), 1 deletion(-)
tests/kmstest.py +0 -0
index 11cc328b5b32..224c160e32fa 100755
@@ -269,8 +269,18 @@ class AtomicRequest(pykms.AtomicReq):
 
Quoted 16 lines
Quoted 4 lines
tests/kmstest.py +1 -1
                    min, max = prop.values
                    v = min + int((max - min) * int(v[:-1]) / 100)
-                else:
+                elif v.isnumeric():

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 282

Quoted 10 lines
tests/kmstest.py +9 -0
                    v = int(v)
+                else:
+                    prop = obj.get_prop(k)
+                    if prop.type != pykms.PropertyType.Enum:
+                        raise RuntimeError(f'Unsupported property type {prop.type} for value {v}')
+                    for value, mode in prop.enums.items():
+                        if mode == v:
+                            v = value
+                            break
+                    else:

Hm, doesn't seem to be correctly aligned?

Quoted 1 line

That ‘else’ is for ‘for’-loop. Am I missing something here?

Hm, I don't really know Python, can it actually have else for
a loop?

Quoted 4 lines
Quoted 4 lines

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 286

Quoted 4 lines
tests/kmstest.py +1 -0
+                        raise RuntimeError(f'Enum value with name "{v}" not found in property {k}')
 
            if not isinstance(v, int):
                raise RuntimeError(f'Unsupported value type {type(v)} for property {k}')

MBR, Sergey

[...]

#5 lore raw

Re: [PATCH 1/3] tests: Support enum property type

Hi,

Quoted 34 lines

2022/07/04 18:00、Sergei Shtylyov <[email protected]>のメール:

On 7/4/22 11:53 AM, Takanari Hayama wrote:
[...]

Quoted 30 lines
Quoted 29 lines
Quoted 17 lines

Add a support for enum property type to AtomicRequest.

---
tests/kmstest.py | 12 +++++++++++-

1 file changed, 11 insertions(+), 1 deletion(-)
tests/kmstest.py +1 -1
index 11cc328b5b32..224c160e32fa 100755
@@ -269,8 +269,18 @@ class AtomicRequest(pykms.AtomicReq):
 
                   min, max = prop.values
                   v = min + int((max - min) * int(v[:-1]) / 100)
-                else:
+                elif v.isnumeric():

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 282

Quoted 10 lines
tests/kmstest.py +9 -0
                   v = int(v)
+                else:
+                    prop = obj.get_prop(k)
+                    if prop.type != pykms.PropertyType.Enum:
+                        raise RuntimeError(f'Unsupported property type {prop.type} for value {v}')
+                    for value, mode in prop.enums.items():
+                        if mode == v:
+                            v = value
+                            break
+                    else:

Hm, doesn't seem to be correctly aligned?

Quoted 4 lines
Quoted 1 line

That ‘else’ is for ‘for’-loop. Am I missing something here?

Hm, I don't really know Python, can it actually have else for
a loop?

Yes. :)

Quoted 1 line

When the items are exhausted (which is immediately when the sequence is empty or an iterator raises a StopIteration exception), the suite in the else clause, if present, is executed, and the loop terminates.

From https://docs.python.org/3/reference/compound_stmts.html#the-for-statement

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 286

Quoted 5 lines
tests/kmstest.py +1 -0
+                        raise RuntimeError(f'Enum value with name "{v}" not found in property {k}')
 
           if not isinstance(v, int):
               raise RuntimeError(f'Unsupported value type {type(v)} for property {k}')

MBR, Sergey

Many Thanks,
Takanari Hayama, Ph.D. <[email protected]>
IGEL Co., Ltd.
https://www.igel.co.jp/

Reviewed-by on v1 1/3
#6 lore raw

Re: [PATCH 1/3] tests: Support enum property type

In reply to Takanari Hayama

Hi Hayama-san,

Thank you for the patch.

Quoted 13 lines · Takanari Hayama

Add a support for enum property type to AtomicRequest.

---
 tests/kmstest.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
tests/kmstest.py +0 -0
index 11cc328b5b32..224c160e32fa 100755
@@ -269,8 +269,18 @@ class AtomicRequest(pykms.AtomicReq):
 

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 278

Quoted 10 lines
tests/kmstest.py +6 -1
                     min, max = prop.values
                     v = min + int((max - min) * int(v[:-1]) / 100)
-                else:
+                elif v.isnumeric():
                     v = int(v)
+                else:
+                    prop = obj.get_prop(k)
+                    if prop.type != pykms.PropertyType.Enum:
+                        raise RuntimeError(f'Unsupported property type {prop.type} for value {v}')
+                    for value, mode in prop.enums.items():

I'd replace "mode" with "name" here. Apart from that,

I'll change this when applying the patch.

Quoted 8 lines
tests/kmstest.py +5 -0
+                        if mode == v:
+                            v = value
+                            break
+                    else:
+                        raise RuntimeError(f'Enum value with name "{v}" not found in property {k}')
 
             if not isinstance(v, int):
                 raise RuntimeError(f'Unsupported value type {type(v)} for property {k}')
Signature · 3 lines
Regards,

Laurent Pinchart
#7 lore raw

Re: [PATCH 1/3] tests: Support enum property type

One more comment.

Quoted 18 lines · Laurent Pinchart

Hi Hayama-san,

Thank you for the patch.

Quoted 13 lines · Takanari Hayama

Add a support for enum property type to AtomicRequest.

---
 tests/kmstest.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
tests/kmstest.py +0 -0
index 11cc328b5b32..224c160e32fa 100755
@@ -269,8 +269,18 @@ class AtomicRequest(pykms.AtomicReq):
 
Quoted 7 lines

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 275

Quoted 7 lines
tests/kmstest.py +3 -1
                     min, max = prop.values
                     v = min + int((max - min) * int(v[:-1]) / 100)
-                else:
+                elif v.isnumeric():
                     v = int(v)
+                else:
+                    prop = obj.get_prop(k)

I've run this test on a kernel that doesn't support the blend mode property, and the prop.type access below raised an exception that isn't very nice to read. If that's fine with you, I'll add

if not prop:
raise RuntimeError(f'Property {k} not supported by object {obj}')

here to make error messages more readable.

Quoted 18 lines

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 278

Quoted 3 lines
tests/kmstest.py +3 -0
+                    if prop.type != pykms.PropertyType.Enum:
+                        raise RuntimeError(f'Unsupported property type {prop.type} for value {v}')
+                    for value, mode in prop.enums.items():

I'd replace "mode" with "name" here. Apart from that,

I'll change this when applying the patch.

Quoted 8 lines
tests/kmstest.py +5 -0
+                        if mode == v:
+                            v = value
+                            break
+                    else:
+                        raise RuntimeError(f'Enum value with name "{v}" not found in property {k}')
 
             if not isinstance(v, int):
                 raise RuntimeError(f'Unsupported value type {type(v)} for property {k}')
Signature · 3 lines
Regards,

Laurent Pinchart
#8 lore raw

Re: [PATCH 1/3] tests: Support enum property type

Hi Laurent,

Thank you for reviewing the patches.

Quoted 35 lines

2022/08/01 1:18、Laurent Pinchart <[email protected]>のメール:

One more comment.

Quoted 18 lines · Laurent Pinchart

Hi Hayama-san,

Thank you for the patch.

Quoted 13 lines · Takanari Hayama

Add a support for enum property type to AtomicRequest.

---
tests/kmstest.py | 12 +++++++++++-

1 file changed, 11 insertions(+), 1 deletion(-)
tests/kmstest.py +0 -0
index 11cc328b5b32..224c160e32fa 100755
@@ -269,8 +269,18 @@ class AtomicRequest(pykms.AtomicReq):
 
Quoted 7 lines

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 275

Quoted 7 lines
tests/kmstest.py +3 -1
                    min, max = prop.values
                    v = min + int((max - min) * int(v[:-1]) / 100)
-                else:
+                elif v.isnumeric():
                    v = int(v)
+                else:
+                    prop = obj.get_prop(k)

I've run this test on a kernel that doesn't support the blend mode property, and the prop.type access below raised an exception that isn't very nice to read. If that's fine with you, I'll add

Quoted 4 lines

if not prop:
raise RuntimeError(f'Property {k} not supported by object {obj}')

here to make error messages more readable.

Right. That makes more sense.

Quoted 10 lines
Quoted 10 lines

tests/kmstest.py class AtomicRequest(pykms.AtomicReq): · line 278

Quoted 4 lines
tests/kmstest.py +3 -0
+                    if prop.type != pykms.PropertyType.Enum:
+                        raise RuntimeError(f'Unsupported property type {prop.type} for value {v}')
+                    for value, mode in prop.enums.items():

I'd replace "mode" with "name" here. Apart from that,

I'll change this when applying the patch.

Thank you.

Quoted 14 lines
Quoted 9 lines
Quoted 9 lines
tests/kmstest.py +5 -0
+                        if mode == v:
+                            v = value
+                            break
+                    else:
+                        raise RuntimeError(f'Enum value with name "{v}" not found in property {k}')
 
            if not isinstance(v, int):
                raise RuntimeError(f'Unsupported value type {type(v)} for property {k}')
Signature · 3 lines
Regards,

Laurent Pinchart

Cheers,
Takanari Hayama, Ph.D. <[email protected]>
IGEL Co., Ltd.
https://www.igel.co.jp/

#9 lore raw

PATCH 2/3 kmstest: Support specifying pixel blend mode for planes

In reply to Takanari Hayama

Add an optional pixel blend mode argument to the atomic_plane_set() function to specify the pixel blend mode for the plane.

---
 tests/kmstest.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/kmstest.py +3 -1
index 224c160e32fa..a39ceab3891b 100755
@@ -395,7 +395,7 @@ class KMSTest(object):
         else:
             return req.commit(0, True)
 
-    def atomic_plane_set(self, plane, crtc, source, destination, fb, alpha=None, zpos=None, sync=False):
+    def atomic_plane_set(self, plane, crtc, source, destination, fb, alpha=None, zpos=None, blendmode=None, sync=False):
         req = AtomicRequest(self)
         req.add(plane, {
                     'FB_ID': fb.id,
@@ -413,6 +413,8 @@ class KMSTest(object):
             req.add(plane, 'alpha', alpha)
         if zpos is not None:
             req.add(plane, 'zpos', zpos)
+        if blendmode is not None:
+            req.add(plane, 'pixel blend mode', blendmode)
         if sync:
             return req.commit_sync()
         else:
Signature · 1 line
2.25.1
Reviewed-by on v1 2/3
#10 lore raw

Re: [PATCH 2/3] kmstest: Support specifying pixel blend mode for planes

Hi Hayama-san,

Thank you for the patch.

Quoted 13 lines · Takanari Hayama

Add an optional pixel blend mode argument to the atomic_plane_set() function to specify the pixel blend mode for the plane.

---
 tests/kmstest.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/kmstest.py +0 -0
index 224c160e32fa..a39ceab3891b 100755

tests/kmstest.py class KMSTest(object): · line 398

Quoted 5 lines
tests/kmstest.py +1 -1
@@ -395,7 +395,7 @@ class KMSTest(object):
         else:
             return req.commit(0, True)
 
-    def atomic_plane_set(self, plane, crtc, source, destination, fb, alpha=None, zpos=None, sync=False):
+    def atomic_plane_set(self, plane, crtc, source, destination, fb, alpha=None, zpos=None, blendmode=None, sync=False):

I'll add a line break while at it as the line is getting long.

Quoted 12 lines
tests/kmstest.py +2 -0
         req = AtomicRequest(self)
         req.add(plane, {
                     'FB_ID': fb.id,
@@ -413,6 +413,8 @@ class KMSTest(object):
             req.add(plane, 'alpha', alpha)
         if zpos is not None:
             req.add(plane, 'zpos', zpos)
+        if blendmode is not None:
+            req.add(plane, 'pixel blend mode', blendmode)
         if sync:
             return req.commit_sync()
         else:
Signature · 3 lines
Regards,

Laurent Pinchart
#11 lore raw

PATCH 3/3 tests: Add pixel blend mode test

In reply to Takanari Hayama

Add a test that blends a plane with different pixel blend modes.

---
 tests/kms-test-plane-blendmode.py | 100 ++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
 create mode 100755 tests/kms-test-plane-blendmode.py
tests/kms-test-plane-blendmode.py new file +100 -0
new file mode 100755
index 000000000000..a9c009b74a8c
@@ -0,0 +1,100 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Renesas Electronics Corporation
+
+import kmstest
+import pykms
+
+class PlaneBlendModeTest(kmstest.KMSTest):
+    """Test composition in different blend modes."""
+
+    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 blend modes')
+
+        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 primary plane
+        primary = pykms.DumbFramebuffer(self.card, mode.hdisplay, mode.vdisplay, 'XR24')
+        pykms.draw_test_pattern(primary)
+        #pykms.draw_rect(primary, 0, 0, mode.hdisplay, mode.vdisplay, pykms.RGB(0, 0, 255))
+
+        # Set the mode with a primary plane
+        ret = self.atomic_crtc_mode_set(crtc, connector, mode, primary)
+        if ret < 0:
+            self.fail(f'atomic mode set failed with {ret}')
+            return
+
+	# Create a overlay plane (half of the screen size)
+        fb = pykms.DumbFramebuffer(self.card, mode.hdisplay // 2, mode.vdisplay, 'AR24')
+        self.logger.log(f'Create fb: {fb} ({fb.width}x{fb.height})')
+        width = mode.hdisplay // 4
+        height = mode.vdisplay // 5
+        for n in range(0, 5):
+            v = 255 - 63 * n
+            pykms.draw_rect(fb, 0, height * n, width, height, pykms.RGB(v, 255, 255, 255))
+            pykms.draw_rect(fb, width, height * n, width, height, pykms.RGB(v, v, v, v))
+
+        self.run(3)
+
+        # Add all other planes one by one
+        source = kmstest.Rect(0, 0, fb.width, fb.height)
+        destination = kmstest.Rect(fb.width, 0, fb.width, fb.height)
+        alpha = '50%'
+        for blendmode in ('Pre-multiplied', 'Coverage', 'None'):
+            pykms.draw_text(fb, 10, 10, f'alpha={alpha}, mode={blendmode}          ', pykms.white)
+            ret = self.atomic_plane_set(planes[1], crtc, source, destination, fb, alpha=alpha, blendmode=blendmode)
+            if ret < 0:
+                self.fail(f'atomic plane set failed with {ret}')
+                break
+
+            self.logger.log(f'Adding plane {planes[1].id} with blendmode {blendmode}')
+            self.run(1)
+
+            if self.flips == 0:
+                self.fail('No page flip registered')
+                break
+
+            self.run(3)
+
+        else:
+            self.success()
+
+        self.atomic_crtc_disable(crtc)
+
+PlaneBlendModeTest().execute()
Signature · 1 line
2.25.1
Reviewed-by on v1 3/3
#12 lore raw

Re: [PATCH 3/3] tests: Add pixel blend mode test

Hi Hayama-san,

Thank you for the patch.

Quoted 56 lines · Takanari Hayama

Add a test that blends a plane with different pixel blend modes.

---
 tests/kms-test-plane-blendmode.py | 100 ++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
 create mode 100755 tests/kms-test-plane-blendmode.py
tests/kms-test-plane-blendmode.py new file +42 -0
new file mode 100755
index 000000000000..a9c009b74a8c
@@ -0,0 +1,100 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022 Renesas Electronics Corporation
+
+import kmstest
+import pykms
+
+class PlaneBlendModeTest(kmstest.KMSTest):
+    """Test composition in different blend modes."""
+
+    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 blend modes')
+
+        crtc, connector, planes = self.find_pipeline()
+        if crtc is None:
+            self.skip('no suitable pipeline')
+            return
+
+        # Get the default mode
+        try:

tests/kms-test-plane-blendmode.py line 52

Quoted 10 lines
tests/kms-test-plane-blendmode.py new file +10 -0
+            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 primary plane

This only creates a framebuffer, not a plane, so I'd write

# Create a frame buffer for the primary plane

and name the variable fb_primary.

tests/kms-test-plane-blendmode.py line 55

Quoted 3 lines
tests/kms-test-plane-blendmode.py new file +3 -0
+        primary = pykms.DumbFramebuffer(self.card, mode.hdisplay, mode.vdisplay, 'XR24')
+        pykms.draw_test_pattern(primary)
+        #pykms.draw_rect(primary, 0, 0, mode.hdisplay, mode.vdisplay, pykms.RGB(0, 0, 255))

This line can be dropped.

tests/kms-test-plane-blendmode.py line 63

Quoted 8 lines
tests/kms-test-plane-blendmode.py new file +8 -0
+
+        # Set the mode with a primary plane
+        ret = self.atomic_crtc_mode_set(crtc, connector, mode, primary)
+        if ret < 0:
+            self.fail(f'atomic mode set failed with {ret}')
+            return
+
+	# Create a overlay plane (half of the screen size)

Small indentation issue, this should use spaces instead of tabs. As above, I'd write

# Create a frame buffer for the overlay planes (half of the screen size)

and name the variable fb_overlay.

I would also create both frame buffers before setting the mode.

tests/kms-test-plane-blendmode.py line 75

Quoted 12 lines
tests/kms-test-plane-blendmode.py new file +12 -0
+        fb = pykms.DumbFramebuffer(self.card, mode.hdisplay // 2, mode.vdisplay, 'AR24')
+        self.logger.log(f'Create fb: {fb} ({fb.width}x{fb.height})')
+        width = mode.hdisplay // 4
+        height = mode.vdisplay // 5
+        for n in range(0, 5):
+            v = 255 - 63 * n
+            pykms.draw_rect(fb, 0, height * n, width, height, pykms.RGB(v, 255, 255, 255))
+            pykms.draw_rect(fb, width, height * n, width, height, pykms.RGB(v, v, v, v))
+
+        self.run(3)
+
+        # Add all other planes one by one

You're only adding a second plane, so

# Add the overlay plane, testing all blend modes sequentially

tests/kms-test-plane-blendmode.py line 81

Quoted 6 lines
tests/kms-test-plane-blendmode.py new file +6 -0
+        source = kmstest.Rect(0, 0, fb.width, fb.height)
+        destination = kmstest.Rect(fb.width, 0, fb.width, fb.height)
+        alpha = '50%'
+        for blendmode in ('Pre-multiplied', 'Coverage', 'None'):
+            pykms.draw_text(fb, 10, 10, f'alpha={alpha}, mode={blendmode}          ', pykms.white)
+            ret = self.atomic_plane_set(planes[1], crtc, source, destination, fb, alpha=alpha, blendmode=blendmode)

A bit of line wrap would be nice.

I'll fix thse small issues when applying the patches.

Quoted 19 lines
tests/kms-test-plane-blendmode.py new file +19 -0
+            if ret < 0:
+                self.fail(f'atomic plane set failed with {ret}')
+                break
+
+            self.logger.log(f'Adding plane {planes[1].id} with blendmode {blendmode}')
+            self.run(1)
+
+            if self.flips == 0:
+                self.fail('No page flip registered')
+                break
+
+            self.run(3)
+
+        else:
+            self.success()
+
+        self.atomic_crtc_disable(crtc)
+
+PlaneBlendModeTest().execute()
Signature · 3 lines
Regards,

Laurent Pinchart