From e71c232660a7480c2b56f6e76e83fad4c7e9da8a Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Fri, 24 Mar 2017 22:47:53 +0200 Subject: Add ctm_test.py test for testing CRTC's CTM color matrix property. --- py/tests/ctm_test.py | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 py/tests/ctm_test.py (limited to 'py') diff --git a/py/tests/ctm_test.py b/py/tests/ctm_test.py new file mode 100755 index 0000000..7ceed6f --- /dev/null +++ b/py/tests/ctm_test.py @@ -0,0 +1,86 @@ +#!/usr/bin/python3 + +import sys +import pykms + +def ctm_to_blob(ctm, card): + len=9 + arr = bytearray(len*8) + view = memoryview(arr).cast("I") + + for x in range(len): + i, d = divmod(ctm[x], 1) + if i < 0: + i = -i + sign = 1 << 31 + else: + sign = 0 + view[x * 2 + 0] = int(d * ((2 ** 32) - 1)) + view[x * 2 + 1] = int(i) | sign + #print("%f = %08x.%08x" % (ctm[x], view[x * 2 + 1], view[x * 2 + 0])) + + return pykms.Blob(card, arr); + + +if len(sys.argv) > 1: + conn_name = sys.argv[1] +else: + conn_name = "" + +card = pykms.Card() +res = pykms.ResourceManager(card) +conn = res.reserve_connector(conn_name) +crtc = res.reserve_crtc(conn) +mode = conn.get_default_mode() + +fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); +pykms.draw_test_pattern(fb); + +crtc.set_mode(conn, fb, mode) + +input("press enter to set normal ctm\n") + +ctm = [ 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 ] + +ctmb = ctm_to_blob(ctm, card) + +crtc.set_prop("CTM", ctmb.id) + +input("press enter to set new ctm\n") + +ctm = [ 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0, + 1.0, 0.0, 0.0 ] + +ctmb = ctm_to_blob(ctm, card) + +crtc.set_prop("CTM", ctmb.id) + +print("r->b g->r b->g ctm active\n") + +input("press enter to set new ctm\n") + +ctm = [ 0.0, 0.0, 1.0, + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0 ] + +ctmb = ctm_to_blob(ctm, card) + +crtc.set_prop("CTM", ctmb.id) +input("r->g g->b b->r ctm active\n") + +input("press enter to turn off the crtc\n") + +crtc.disable_mode() + +input("press enter to enable crtc again\n") + +crtc.set_mode(conn, fb, mode) + +input("press enter to remove ctm\n") + +crtc.set_prop("CTM", 0) + +input("press enter to exit\n") -- cgit v1.2.3 From b39260b2775cfc101fae418810c46cec7aa6cf9f Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Fri, 24 Mar 2017 22:45:31 +0200 Subject: Add Crtc::disable_mode() to pykmsbase.cpp. --- py/pykms/pykmsbase.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'py') diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp index d013f1f..49b0a19 100644 --- a/py/pykms/pykmsbase.cpp +++ b/py/pykms/pykmsbase.cpp @@ -50,6 +50,7 @@ void init_pykmsbase(py::module &m) py::class_(m, "Crtc", py::base()) .def("set_mode", &Crtc::set_mode) + .def("disable_mode", &Crtc::disable_mode) .def("page_flip", [](Crtc* self, Framebuffer& fb, py::object ob) { -- cgit v1.2.3 From 7adbef59143af49fb153812d1d0368522e70dcaf Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 9 May 2017 17:37:15 +0300 Subject: Add different YCbCr encodings. --- py/pykms/pykmsutil.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'py') diff --git a/py/pykms/pykmsutil.cpp b/py/pykms/pykmsutil.cpp index cb09dea..a5a6041 100644 --- a/py/pykms/pykmsutil.cpp +++ b/py/pykms/pykmsutil.cpp @@ -40,9 +40,17 @@ void init_pykmstest(py::module &m) py::arg("crtc"), py::arg("format") = PixelFormat::Undefined) ; + py::enum_(m, "YUVType") + .value("BT601_Lim", YUVType::BT601_Lim) + .value("BT601_Full", YUVType::BT601_Full) + .value("BT709_Lim", YUVType::BT709_Lim) + .value("BT709_Full", YUVType::BT709_Full) + ; // Use lambdas to handle IMappedFramebuffer - m.def("draw_test_pattern", [](MappedFramebuffer& fb) { draw_test_pattern(fb); } ); + m.def("draw_test_pattern", [](MappedFramebuffer& fb, YUVType yuvt) { draw_test_pattern(fb, yuvt); }, + py::arg("fb"), + py::arg("yuvt") = YUVType::BT601_Lim); m.def("draw_color_bar", [](MappedFramebuffer& fb, int old_xpos, int xpos, int width) { draw_color_bar(fb, old_xpos, xpos, width); } ); -- cgit v1.2.3 From 5f7d6c85666af7429e45d206e518d50099016d41 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Wed, 31 May 2017 17:48:52 +0300 Subject: Add DrmPropObject.get_prop() and Property.enums to pykmsbase.cpp. --- py/pykms/pykmsbase.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'py') diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp index 49b0a19..604e07c 100644 --- a/py/pykms/pykmsbase.cpp +++ b/py/pykms/pykmsbase.cpp @@ -33,6 +33,7 @@ void init_pykmsbase(py::module &m) .def("get_prop_value", (uint64_t (DrmPropObject::*)(const string&) const)&DrmPropObject::get_prop_value) .def("set_prop_value",(int (DrmPropObject::*)(const string&, uint64_t)) &DrmPropObject::set_prop_value) .def("get_prop_value_as_blob", &DrmPropObject::get_prop_value_as_blob) + .def("get_prop", &DrmPropObject::get_prop) ; py::class_(m, "Connector", py::base()) @@ -87,6 +88,7 @@ void init_pykmsbase(py::module &m) py::class_(m, "Property", py::base()) .def_property_readonly("name", &Property::name) + .def_property_readonly("enums", &Property::get_enums) ; py::class_(m, "Blob", py::base()) -- cgit v1.2.3 From 7450c364a57ec7d9e2abd61ac6e025c53e9e7a42 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Fri, 12 May 2017 10:44:21 +0300 Subject: plane_csc.py: Test for different YCbCr encodings --- py/tests/plane_csc.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 py/tests/plane_csc.py (limited to 'py') diff --git a/py/tests/plane_csc.py b/py/tests/plane_csc.py new file mode 100755 index 0000000..be92c00 --- /dev/null +++ b/py/tests/plane_csc.py @@ -0,0 +1,66 @@ +#!/usr/bin/python3 + +import pykms + +card = pykms.Card() +res = pykms.ResourceManager(card) +conn = res.reserve_connector("HDMI") +crtc = res.reserve_crtc(conn) +mode = conn.get_default_mode() +modeb = mode.to_blob(card) +plane = res.reserve_generic_plane(crtc, pykms.PixelFormat.UYVY) +#plane = res.reserve_generic_plane(crtc, pykms.PixelFormat.Undefined) + +print("Got plane %d %d" % (plane.idx, plane.id)) + +fb = pykms.DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "UYVY"); +pykms.draw_test_pattern(fb); + +req = pykms.AtomicReq(card) +req.add(conn, "CRTC_ID", crtc.id) +req.add(crtc, {"ACTIVE": 1, + "MODE_ID": modeb.id}) + +input("Press enter to enable crtc idx %d at %s" % (crtc.idx, conn.fullname)) +r = req.commit_sync(allow_modeset = True) + +input("Press enter to enable plane idx %d at %s" % (plane.idx, conn.fullname)) + +req = pykms.AtomicReq(card) +req.add(plane, {"FB_ID": fb.id, + "CRTC_ID": crtc.id, + "SRC_X": 0 << 16, + "SRC_Y": 0 << 16, + "SRC_W": fb.width << 16, + "SRC_H": fb.height << 16, + "CRTC_X": 0, + "CRTC_Y": 0, + "CRTC_W": fb.width, + "CRTC_H": fb.height, + "zorder": 0}) +r = req.commit_sync() +print("Plane enable request returned %d\n" % r) + +yuv_types = [pykms.YUVType.BT601_Lim, + pykms.YUVType.BT601_Full, + pykms.YUVType.BT709_Lim, + pykms.YUVType.BT709_Full] + +encoding_enums = plane.get_prop("COLOR_ENCODING").enums +range_enums = plane.get_prop("COLOR_RANGE").enums + +for i in range(0, 2): + for j in range(0, 2): + input("press enter to for encoding: \"%s\" range: \"%s\"\n" % + (encoding_enums[i], range_enums[j])) + + req = pykms.AtomicReq(card) + req.add(plane, {"COLOR_ENCODING": i, + "COLOR_RANGE": j}) + req.commit_sync() + + for t in yuv_types: + input("press enter to redraw with yuv_type %s\n" % t) + pykms.draw_test_pattern(fb, t); + +input("press enter to exit\n") -- cgit v1.2.3