diff options
| author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2022-10-04 09:58:09 +0300 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2022-10-04 11:02:26 +0300 |
| commit | 1bba3eca5ddbfa8fb7ed05994207b1c329ab58ee (patch) | |
| tree | 2243c741a22094f663337c124cca0f06d8c065ce /py | |
| parent | 2236a8ccacdfed5ff5f6873ed6618eccf570193d (diff) | |
py: kms: add pixelformat helpers
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Diffstat (limited to 'py')
| -rw-r--r-- | py/pykms/pykmsbase.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/py/pykms/pykmsbase.cpp b/py/pykms/pykmsbase.cpp index 088d267..79ddbf6 100644 --- a/py/pykms/pykmsbase.cpp +++ b/py/pykms/pykmsbase.cpp @@ -247,6 +247,7 @@ void init_pykmsbase(py::module& m) .value("BGRA1010102", PixelFormat::BGRA1010102); m.def("fourcc_to_pixelformat", &FourCCToPixelFormat); + m.def("pixelformat_to_fourcc", &PixelFormatToFourCC); py::enum_<SyncPolarity>(m, "SyncPolarity") .value("Undefined", SyncPolarity::Undefined) @@ -301,4 +302,22 @@ void init_pykmsbase(py::module& m) }, py::arg("data") = 0, py::arg("allow_modeset") = false) .def("commit_sync", &AtomicReq::commit_sync, py::arg("allow_modeset") = false); + + py::class_<PixelFormatPlaneInfo>(m, "PixelFormatPlaneInfo") + .def_readonly("bitspp", &PixelFormatPlaneInfo::bitspp) + .def_readonly("xsub", &PixelFormatPlaneInfo::xsub) + .def_readonly("ysub", &PixelFormatPlaneInfo::ysub) + ; + + py::class_<PixelFormatInfo>(m, "PixelFormatInfo") + .def_readonly("num_planes", &PixelFormatInfo::num_planes) + .def("plane", [](const PixelFormatInfo& self, uint32_t idx) { + if (idx >= self.num_planes) + throw runtime_error("invalid plane number"); + return self.planes[idx]; + }, py::return_value_policy::reference_internal) + ; + + m.def("get_pixel_format_info", &get_pixel_format_info, + py::return_value_policy::reference_internal); } |
