summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-06-09 23:55:01 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-06-29 21:15:53 +0300
commit11404d7162f0e164fa4a3dcd68337cd3a23dcf6b (patch)
tree9b68c064fd44d9cf4f699fb6e1c350d894d7ce4f /tests
parent2c679688f5077ac0ba61ab534ebcbb133248e605 (diff)
kmstest: Move props value formatting to AtomicRequest
Centralize props value formatting in the AtomicRequest.add() function to avoid having to call it manually through the code base. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/kmstest.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/tests/kmstest.py b/tests/kmstest.py
index 14e28cd..cecaaaf 100755
--- a/tests/kmstest.py
+++ b/tests/kmstest.py
@@ -258,15 +258,22 @@ class AtomicRequest(pykms.AtomicReq):
self.__test = test
self.__props = {}
+ def __format_props(self, props):
+ # Convert negative values to a 64-bit unsigned integer as required
+ # by the bindings for AtomicRequest::add().
+ return {k: v & ((1 << 64) - 1) for k, v in props.items()}
+
def add(self, obj, *kwargs):
if obj.id not in self.__props:
self.__props[obj.id] = {}
- props = self.__props[obj.id]
+ obj_props = self.__props[obj.id]
if len(kwargs) == 1 and isinstance(kwargs[0], collections.abc.Mapping):
- props.update(kwargs[0])
+ props = self.__format_props(kwargs[0])
elif len(kwargs) == 2:
- props[kwargs[0]] = kwargs[1]
+ props = self.__format_props({ kwargs[0]: = kwargs[1] })
+
+ obj_props.update(props)
super().add(obj, *kwargs)
@@ -309,9 +316,6 @@ class KMSTest(object):
def __del__(self):
self.logger.close()
- def __format_props(self, props):
- return {k: v & ((1 << 64) - 1) for k, v in props.items()}
-
def atomic_crtc_disable(self, crtc, sync=True):
req = AtomicRequest(self)
req.add(crtc, {'ACTIVE': 0, 'MODE_ID': 0})
@@ -368,7 +372,7 @@ class KMSTest(object):
def atomic_plane_set(self, plane, crtc, source, destination, fb, sync=False):
req = AtomicRequest(self)
- req.add(plane, self.__format_props({
+ req.add(plane, {
'FB_ID': fb.id,
'CRTC_ID': crtc.id,
'SRC_X': int(source.left * 65536),
@@ -379,7 +383,7 @@ class KMSTest(object):
'CRTC_Y': destination.top,
'CRTC_W': destination.width,
'CRTC_H': destination.height,
- }))
+ })
if sync:
return req.commit_sync()
else: