Skip to content

Commit

Permalink
kernel: sun4i_drm: Add alpha-related tests
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
  • Loading branch information
rsglobal committed Jun 2, 2022
1 parent 1345536 commit 57b82c2
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 0 deletions.
74 changes: 74 additions & 0 deletions kernel/sun4i_drm_kmsxx/MostBottomAlpha_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/python3

# SPDX-FileCopyrightText: https://github.com/tomba/kmsxx project authors
# SPDX-FileCopyrightText: 2022 Roman Stratiienko <r.stratiienko@gmail.com>
# SPDX-License-Identifier: MPL-2.0

import pykms
import time
import numpy as np

card = pykms.Card()
res = pykms.ResourceManager(card)
conn = res.reserve_connector('')
crtc = res.reserve_crtc(conn)

format = pykms.PixelFormat.ARGB8888
magenta = pykms.RGB(255, 0, 255)
grey = pykms.RGB(128, 255, 255, 255)

card.disable_planes()

mode = conn.get_default_mode()
modeb = mode.to_blob(card)
req = pykms.AtomicReq(card)
req.add(conn, "CRTC_ID", crtc.id)
req.add(crtc, {"ACTIVE": 1,
"MODE_ID": modeb.id})
r = req.commit_sync(allow_modeset = True)
assert r == 0, "Initial commit failed: %d" % r

planes=[]

max_planes=16

for i in range(max_planes):
p = res.reserve_generic_plane(crtc)
if p == None:
break
planes.append(p)

fbX = int(mode.hdisplay / len(planes))
fbY = int(mode.vdisplay)

fb = pykms.DumbFramebuffer(card, fbX, fbY, format);
pykms.draw_rect(fb, 0, 0, int(fbX), int(fbY), grey)
pykms.draw_rect(fb, int(fbX*0.1), int(fbY*0.1), int(fbX*0.8), int(fbY*0.8), magenta)

def PlaneAlphaTest(plane_index):
print("Plane {} is the most bottom".format(plane_index))
req = pykms.AtomicReq(card)

for p in range(0,len(planes)):
req.add_plane(planes[p], fb, crtc, dst=(fbX * p, 0, fbX, fbY), zpos=(p-plane_index)%len(planes))
r = req.commit_sync()

for a in np.linspace(65535, 0, num=100):
req = pykms.AtomicReq(card)

for p in range(0,len(planes)):
req.add(planes[p], {"alpha": int(a) })

r = req.commit_sync()
assert r == 0, "Plane commit failed: %d" % r

print("Press enter to continue")
input()

req = pykms.AtomicReq(card)
for p in range(0,len(planes)):
req.add(planes[p], {"alpha": 65535 })
r = req.commit_sync()

for i in range(0, len(planes)):
PlaneAlphaTest(i)
78 changes: 78 additions & 0 deletions kernel/sun4i_drm_kmsxx/OverlappingAlpha_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/python3

# SPDX-FileCopyrightText: https://github.com/tomba/kmsxx project authors
# SPDX-FileCopyrightText: 2022 Roman Stratiienko <r.stratiienko@gmail.com>
# SPDX-License-Identifier: MPL-2.0

import pykms
import time
import numpy as np

card = pykms.Card()
res = pykms.ResourceManager(card)
conn = res.reserve_connector('')
crtc = res.reserve_crtc(conn)

format = pykms.PixelFormat.ARGB8888
magenta = pykms.RGB(255, 255, 0, 255)
magenta_tr = pykms.RGB(128, 128, 0, 128)

grey = pykms.RGB(128, 128, 128)
grey_tr = pykms.RGB(128, 128, 128, 128)

card.disable_planes()

mode = conn.get_default_mode()
modeb = mode.to_blob(card)
req = pykms.AtomicReq(card)
req.add(conn, "CRTC_ID", crtc.id)
req.add(crtc, {"ACTIVE": 1,
"MODE_ID": modeb.id})
r = req.commit_sync(allow_modeset = True)
assert r == 0, "Initial commit failed: %d" % r

planes=[]

max_planes=16

for i in range(max_planes):
p = res.reserve_generic_plane(crtc)
if p == None:
break
planes.append(p)

fbX = int(mode.hdisplay / len(planes))
fbY = int(mode.vdisplay)

fb = pykms.DumbFramebuffer(card, fbX, fbY, format);
pykms.draw_rect(fb, 0, 0, int(fbX), int(fbY), magenta)
pykms.draw_rect(fb, 0, int(fbY/2), int(fbX), int(fbY/2), magenta_tr)

def PlaneAlphaTest(plane_index):
print("Plane {} is the most bottom".format(plane_index))
req = pykms.AtomicReq(card)

for p in range(0,len(planes)):
req.add_plane(planes[p], fb, crtc, dst=(0, 0, fbX*(p+1), fbY), zpos=(p-plane_index)%len(planes))
r = req.commit_sync()

for a in np.linspace(65535, 32768, num=100):
req = pykms.AtomicReq(card)

for p in range(0,len(planes)):
req.add(planes[p], {"alpha": int(a) })

r = req.commit_sync()
assert r == 0, "Plane commit failed: %d" % r

print("Press enter to continue")
input()

req = pykms.AtomicReq(card)
for p in range(0,len(planes)):
req.add(planes[p], {"alpha": 65535 })
r = req.commit_sync()


for i in range(0, len(planes)):
PlaneAlphaTest(i)
21 changes: 21 additions & 0 deletions kernel/sun4i_drm_kmsxx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# drmkms-python-tests
DRM/KMS manual validation scripts

## Motivation
Android UI performance relies on DRM/KMS quality a lot.

Mainline kernel drivers still have bugs that make FULL DRM/KMS support impossible
and we have to limit or disable using HW overlay planes for such drivers/boards.

In addition to that some of the kernel DRM drivers do not expose full hardware capabilities.
Improving such drivers is much faster when easy-to-run test procedures are available.

Also it is nice to have the ability to test any change in driver code for regression with existing tests.

## Running
Scripts depends on kmsxx library: https://github.com/tomba/kmsxx

## Contributing
Contributions are welcome.

Feel free to add any new / fix existing tests by opening a pull request.

0 comments on commit 57b82c2

Please sign in to comment.