summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/meson.build4
-rw-r--r--py/pyv4l2/__init__.py5
-rw-r--r--py/pyv4l2/meson.build38
-rw-r--r--py/pyv4l2/pyv4l2.cpp117
-rwxr-xr-xpy/tests/cam.py129
5 files changed, 0 insertions, 293 deletions
diff --git a/py/meson.build b/py/meson.build
index fcba3e5..3130bf2 100644
--- a/py/meson.build
+++ b/py/meson.build
@@ -1,5 +1 @@
subdir('pykms')
-
-if get_option('v4l2').enabled()
- subdir('pyv4l2')
-endif
diff --git a/py/pyv4l2/__init__.py b/py/pyv4l2/__init__.py
deleted file mode 100644
index 02541c5..0000000
--- a/py/pyv4l2/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from .pyv4l2 import *
-from enum import Enum
-import os
-import struct
-
diff --git a/py/pyv4l2/meson.build b/py/pyv4l2/meson.build
deleted file mode 100644
index 03b0dcc..0000000
--- a/py/pyv4l2/meson.build
+++ /dev/null
@@ -1,38 +0,0 @@
-py3_dep = dependency('python3', required : get_option('pyv4l2'))
-
-if py3_dep.found() == false
- subdir_done()
-endif
-
-pybind11_dep = dependency('pybind11', fallback : ['pybind11', 'pybind11_dep'],
- required : get_option('pyv4l2'))
-
-if pybind11_dep.found() == false
- subdir_done()
-endif
-
-pyv4l2_sources = files([
- 'pyv4l2.cpp',
-])
-
-pyv4l2_deps = [
- libv4l2xx_dep,
- py3_dep,
- pybind11_dep,
-]
-
-pyv4l2_args = [ '-fvisibility=hidden' ]
-
-destdir = get_option('libdir') / 'python' + py3_dep.version() / 'site-packages/pyv4l2'
-
-pyv4l2 = shared_module('pyv4l2',
- pyv4l2_sources,
- install : true,
- install_dir : destdir,
- name_prefix : '',
- dependencies : pyv4l2_deps,
- cpp_args : pyv4l2_args)
-
-# Copy __init__.py to build dir so that we can run without installing
-configure_file(input: '__init__.py', output: '__init__.py', copy: true,
- install : true, install_dir : destdir)
diff --git a/py/pyv4l2/pyv4l2.cpp b/py/pyv4l2/pyv4l2.cpp
deleted file mode 100644
index b88ab5e..0000000
--- a/py/pyv4l2/pyv4l2.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-#include <pybind11/pybind11.h>
-#include <pybind11/stl.h>
-#include <v4l2++/videodevice.h>
-#include <fmt/format.h>
-
-namespace py = pybind11;
-
-using namespace v4l2;
-using namespace std;
-
-PYBIND11_MODULE(pyv4l2, m)
-{
- py::class_<VideoDevice>(m, "VideoDevice")
- .def(py::init<const string&>())
- .def_property_readonly("fd", &VideoDevice::fd)
- .def_property_readonly("has_capture", &VideoDevice::has_capture)
- .def_property_readonly("has_output", &VideoDevice::has_output)
- .def_property_readonly("has_m2m", &VideoDevice::has_m2m)
- .def_property_readonly("capture_streamer", &VideoDevice::get_capture_streamer)
- .def_property_readonly("output_streamer", &VideoDevice::get_output_streamer)
- .def_property_readonly("meta_capture_streamer", &VideoDevice::get_meta_capture_streamer)
- .def_property_readonly("discrete_frame_sizes", &VideoDevice::get_discrete_frame_sizes)
- .def_property_readonly("frame_sizes", &VideoDevice::get_frame_sizes)
- .def("get_capture_devices", &VideoDevice::get_capture_devices);
-
- py::enum_<VideoMemoryType>(m, "VideoMemoryType")
- .value("MMAP", VideoMemoryType::MMAP)
- .value("DMABUF", VideoMemoryType::DMABUF);
-
- m.def("create_dmabuffer", [](int fd) {
- VideoBuffer buf{};
- buf.m_mem_type = VideoMemoryType::DMABUF;
- buf.m_fd = fd;
- return buf;
- });
-
- m.def("create_mmapbuffer", []() {
- VideoBuffer buf{};
- buf.m_mem_type = VideoMemoryType::MMAP;
- return buf;
- });
-
- py::class_<VideoBuffer>(m, "VideoBuffer")
- .def_readonly("index", &VideoBuffer::m_index)
- .def_readonly("offset", &VideoBuffer::m_offset)
- .def_readonly("fd", &VideoBuffer::m_fd)
- .def_readonly("length", &VideoBuffer::m_length);
-
- py::class_<VideoStreamer>(m, "VideoStreamer")
- .def_property_readonly("fd", &VideoStreamer::fd)
- .def_property_readonly("ports", &VideoStreamer::get_ports)
- .def("set_port", &VideoStreamer::set_port)
- .def_property_readonly("formats", &VideoStreamer::get_formats)
- .def("get_format", [](VideoStreamer* self) {
- PixelFormat fmt;
- uint32_t w, h;
-
- int r = self->get_format(fmt, w, h);
- if (r)
- throw std::system_error(errno, std::generic_category(), "get_format failed");
-
- return make_tuple(w, h, fmt);
- })
- .def("set_format", &VideoStreamer::set_format)
- .def("get_selection", [](VideoStreamer* self) {
- uint32_t left, top, width, height;
- self->get_selection(left, top, width, height);
- return make_tuple(left, top, width, height);
- })
- .def("set_selection", [](VideoStreamer* self, uint32_t left, uint32_t top, uint32_t width, uint32_t height) {
- self->set_selection(left, top, width, height);
- return make_tuple(left, top, width, height);
- })
- .def("set_queue_size", &VideoStreamer::set_queue_size)
- .def("queue", &VideoStreamer::queue)
- .def("dequeue", &VideoStreamer::dequeue)
- .def("stream_on", &VideoStreamer::stream_on)
- .def("stream_off", &VideoStreamer::stream_off)
- .def("export_buffer", &VideoStreamer::export_buffer);
-
- py::class_<MetaStreamer>(m, "MetaStreamer")
- .def_property_readonly("fd", &MetaStreamer::fd)
- .def("set_format", &MetaStreamer::set_format)
- .def("set_queue_size", &MetaStreamer::set_queue_size)
- .def("queue", &MetaStreamer::queue)
- .def("dequeue", &MetaStreamer::dequeue)
- .def("stream_on", &MetaStreamer::stream_on)
- .def("stream_off", &MetaStreamer::stream_off);
-
- py::enum_<PixelFormat>(m, "PixelFormat")
- .value("Undefined", PixelFormat::Undefined)
-
- .value("NV12", PixelFormat::NV12)
- .value("NV21", PixelFormat::NV21)
- .value("NV16", PixelFormat::NV16)
- .value("NV61", PixelFormat::NV61)
-
- .value("UYVY", PixelFormat::UYVY)
- .value("YUYV", PixelFormat::YUYV)
- .value("YVYU", PixelFormat::YVYU)
- .value("VYUY", PixelFormat::VYUY)
-
- .value("RGB888", PixelFormat::RGB888)
- .value("XRGB8888", PixelFormat::XRGB8888)
-
- .value("RGB565", PixelFormat::RGB565)
-
- .value("SBGGR12", PixelFormat::SBGGR12)
- .value("SRGGB12", PixelFormat::SRGGB12)
-
- .value("META_8", PixelFormat::META_8)
- .value("META_16", PixelFormat::META_16);
-
- m.def("fourcc_to_pixelformat", &FourCCToPixelFormat);
- m.def("pixelformat_to_fourcc", &PixelFormatToFourCC);
- m.def("drm_fourcc_to_pixelformat", &DRMFourCCToPixelFormat);
-}
diff --git a/py/tests/cam.py b/py/tests/cam.py
deleted file mode 100755
index b2d88c4..0000000
--- a/py/tests/cam.py
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/usr/bin/python3
-
-import sys
-import selectors
-import pykms
-import pyv4l2 as v4l2
-import argparse
-import time
-
-parser = argparse.ArgumentParser()
-parser.add_argument("width", type=int)
-parser.add_argument("height", type=int)
-parser.add_argument("fourcc", type=str, nargs="?", default="UYVY")
-parser.add_argument("-t", "--type", type=str, default="drm", help="buffer type (drm/v4l2)")
-args = parser.parse_args()
-
-if not args.type in ["drm", "v4l2"]:
- print("Bad buffer type", args.type)
- exit(-1)
-
-w = args.width
-h = args.height
-fmt = pykms.fourcc_to_pixelformat(args.fourcc)
-vfmt = v4l2.drm_fourcc_to_pixelformat(pykms.pixelformat_to_fourcc(fmt))
-
-print("Capturing in {}x{}, drm fmt {} ({}), v4l2 fmt {} ({})".format(w, h,
- fmt, pykms.pixelformat_to_fourcc(fmt), vfmt, v4l2.pixelformat_to_fourcc(vfmt)))
-
-card = pykms.Card()
-res = pykms.ResourceManager(card)
-conn = res.reserve_connector("hdmi")
-crtc = res.reserve_crtc(conn)
-plane = res.reserve_overlay_plane(crtc, fmt)
-
-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})
-req.commit_sync(allow_modeset = True)
-
-NUM_BUFS = 5
-
-vidpath = v4l2.VideoDevice.get_capture_devices()[0]
-
-vid = v4l2.VideoDevice(vidpath)
-cap = vid.capture_streamer
-cap.set_port(0)
-cap.set_format(vfmt, w, h)
-cap.set_queue_size(NUM_BUFS, v4l2.VideoMemoryType.DMABUF if args.type == "drm" else v4l2.VideoMemoryType.MMAP)
-
-fbs = []
-
-def export_v4l2_buf_to_drm(card, i, vfmt):
- finfo = pykms.get_pixel_format_info(fmt)
-
- if fmt == pykms.PixelFormat.NV12:
- fd = cap.export_buffer(i)
- buf_fds = [fd, fd]
- pitches = [w * finfo.plane(0).bitspp // 8, w * finfo.plane(1).bitspp // 8]
- offsets = [0, w * h * finfo.plane(0).bitspp // 8]
- else:
- buf_fds = [cap.export_buffer(i)]
- pitches = [w * finfo.plane(0).bitspp // 8]
- offsets = [0]
-
- fb = pykms.DmabufFramebuffer(card, w, h, fmt,
- buf_fds, pitches, offsets)
-
- return fb
-
-
-for i in range(NUM_BUFS):
- if args.type == "drm":
- fb = pykms.DumbFramebuffer(card, w, h, fmt)
- else:
- fb = export_v4l2_buf_to_drm(card, i, vfmt)
-
- print(fb)
-
- fbs.append(fb)
-
-for i in range(NUM_BUFS):
- if args.type == "drm":
- vbuf = v4l2.create_dmabuffer(fbs[i].fd(0))
- else:
- vbuf = v4l2.create_mmapbuffer()
- cap.queue(vbuf)
-
-cap.stream_on()
-
-
-def readvid(conn, mask):
- vbuf = cap.dequeue()
-
- fb = fbs[vbuf.index]
- assert(fb != None)
-
- if card.has_atomic:
- plane.set_props({
- "FB_ID": fb.id,
- "CRTC_ID": crtc.id,
- "SRC_W": fb.width << 16,
- "SRC_H": fb.height << 16,
- "CRTC_W": fb.width,
- "CRTC_H": fb.height,
- })
- else:
- crtc.set_plane(plane, fb, 0, 0, fb.width, fb.height,
- 0, 0, fb.width, fb.height)
-
- cap.queue(vbuf)
-
-def readkey(conn, mask):
- #print("KEY EVENT");
- sys.stdin.readline()
- exit(0)
-
-sel = selectors.DefaultSelector()
-sel.register(cap.fd, selectors.EVENT_READ, readvid)
-sel.register(sys.stdin, selectors.EVENT_READ, readkey)
-
-while True:
- events = sel.select()
- for key, mask in events:
- callback = key.data
- callback(key.fileobj, mask)