diff -Nru bmusb-0.7.4/70-bmusb.rules bmusb-0.7.5/70-bmusb.rules --- bmusb-0.7.4/70-bmusb.rules 1970-01-01 00:00:00.000000000 +0000 +++ bmusb-0.7.5/70-bmusb.rules 2020-04-07 20:11:30.000000000 +0000 @@ -0,0 +1,7 @@ + +# Blackmagic Intensity Shuttle. +SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="1edb", ENV{ID_MODEL_ID}=="bd3b", TAG+="uaccess" + +# Blackmagic UltraStudio SDI. +SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="1edb", ENV{ID_MODEL_ID}=="bd4f", TAG+="uaccess" + diff -Nru bmusb-0.7.4/bmusb.cpp bmusb-0.7.5/bmusb.cpp --- bmusb-0.7.4/bmusb.cpp 2019-03-29 21:32:49.000000000 +0000 +++ bmusb-0.7.5/bmusb.cpp 2020-04-07 20:11:30.000000000 +0000 @@ -1,4 +1,4 @@ -// Intensity Shuttle USB3 capture driver, v0.7.4 +// Intensity Shuttle USB3 capture driver, v0.7.5 // Can download 8-bit and 10-bit UYVY/v210-ish frames from HDMI, quite stable // (can do captures for hours at a time with no drops), except during startup // 576p60/720p60/1080i60 works, 1080p60 does not work (firmware limitation) diff -Nru bmusb-0.7.4/debian/changelog bmusb-0.7.5/debian/changelog --- bmusb-0.7.4/debian/changelog 2020-03-22 15:35:07.000000000 +0000 +++ bmusb-0.7.5/debian/changelog 2020-04-07 19:29:27.000000000 +0000 @@ -1,8 +1,10 @@ -bmusb (0.7.4-4build1) focal; urgency=medium +bmusb (0.7.5-1) unstable; urgency=medium - * No-change rebuild for libgcc-s1 package name change. + * New upstream release. + * Ship udev rules file to automatically grant access to local users. + * Incorporates (and thus obsoletes) support-external-pkg-config.diff. - -- Matthias Klose Sun, 22 Mar 2020 16:35:07 +0100 + -- Steinar H. Gunderson Tue, 07 Apr 2020 21:29:27 +0200 bmusb (0.7.4-4) unstable; urgency=medium diff -Nru bmusb-0.7.4/debian/copyright bmusb-0.7.5/debian/copyright --- bmusb-0.7.4/debian/copyright 2018-04-29 11:11:31.000000000 +0000 +++ bmusb-0.7.5/debian/copyright 2020-04-07 19:29:27.000000000 +0000 @@ -1,6 +1,6 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: bmusb -Source: https://storage.sesse.net/bmusb-0.7.2.tar.gz +Source: https://storage.sesse.net/bmusb-0.7.5.tar.gz Files: * Copyright: 2015 Steinar H. Gunderson diff -Nru bmusb-0.7.4/debian/libbmusb6.install bmusb-0.7.5/debian/libbmusb6.install --- bmusb-0.7.4/debian/libbmusb6.install 2016-09-29 16:37:42.000000000 +0000 +++ bmusb-0.7.5/debian/libbmusb6.install 2020-04-07 19:29:27.000000000 +0000 @@ -1 +1,2 @@ usr/lib/*/*.so.* +lib/udev/rules.d/* diff -Nru bmusb-0.7.4/debian/patches/debian-multiarch.diff bmusb-0.7.5/debian/patches/debian-multiarch.diff --- bmusb-0.7.4/debian/patches/debian-multiarch.diff 2019-04-19 08:00:48.000000000 +0000 +++ bmusb-0.7.5/debian/patches/debian-multiarch.diff 2020-04-07 19:29:27.000000000 +0000 @@ -3,11 +3,11 @@ place to give in --libdir. Hard-code the destination given by dpkg instead. -Index: bmusb-0.7.4/Makefile +Index: bmusb-0.7.5/Makefile =================================================================== ---- bmusb-0.7.4.orig/Makefile -+++ bmusb-0.7.4/Makefile -@@ -5,6 +5,8 @@ LN := ln +--- bmusb-0.7.5.orig/Makefile ++++ bmusb-0.7.5/Makefile +@@ -6,6 +6,8 @@ LN := ln RANLIB := ranlib INSTALL := install PREFIX := /usr @@ -16,7 +16,7 @@ LIB := libbmusb.a SODEV := libbmusb.so SONAME := libbmusb.so.6 -@@ -32,12 +34,15 @@ clean: +@@ -36,14 +38,16 @@ clean: install: all $(INSTALL) -m 755 -o root -g root -d \ @@ -24,7 +24,8 @@ - $(DESTDIR)$(PREFIX)/lib/pkgconfig \ + $(DESTDIR)$(LIBDIR) \ + $(DESTDIR)$(LIBDIR)/pkgconfig \ - $(DESTDIR)$(PREFIX)/include/bmusb + $(DESTDIR)$(PREFIX)/include/bmusb \ + $(DESTDIR)/lib/udev/rules.d - $(INSTALL) -m 755 -o root -g root $(LIB) $(SOLIB) $(DESTDIR)$(PREFIX)/lib - $(LN) -sf $(SOLIB) $(DESTDIR)$(PREFIX)/lib/$(SONAME) - $(LN) -sf $(SOLIB) $(DESTDIR)$(PREFIX)/lib/$(SODEV) @@ -33,16 +34,16 @@ + $(LN) -sf $(SOLIB) $(DESTDIR)$(LIBDIR)/$(SODEV) $(INSTALL) -m 755 -o root -g root bmusb/bmusb.h bmusb/fake_capture.h $(DESTDIR)$(PREFIX)/include/bmusb - $(INSTALL) -m 644 -o root -g root bmusb.pc $(DESTDIR)$(PREFIX)/lib/pkgconfig -- + $(INSTALL) -m 644 -o root -g root bmusb.pc $(DESTDIR)$(LIBDIR)/pkgconfig -+ + $(INSTALL) -m 644 -o root -g root 70-bmusb.rules $(DESTDIR)/lib/udev/rules.d +- + sed 's/@DEB_MULTIARCH_TRIPLET@/$(DEB_MULTIARCH_TRIPLET)/' < bmusb.pc > $(DESTDIR)$(LIBDIR)/pkgconfig/bmusb.pc + chmod 0644 $(DESTDIR)$(LIBDIR)/pkgconfig/bmusb.pc + chown root:root $(DESTDIR)$(LIBDIR)/pkgconfig/bmusb.pc -Index: bmusb-0.7.4/bmusb.pc +Index: bmusb-0.7.5/bmusb.pc =================================================================== ---- bmusb-0.7.4.orig/bmusb.pc -+++ bmusb-0.7.4/bmusb.pc +--- bmusb-0.7.5.orig/bmusb.pc ++++ bmusb-0.7.5/bmusb.pc @@ -1,6 +1,6 @@ prefix=/usr exec_prefix=${prefix} diff -Nru bmusb-0.7.4/debian/patches/series bmusb-0.7.5/debian/patches/series --- bmusb-0.7.4/debian/patches/series 2019-07-25 21:02:29.000000000 +0000 +++ bmusb-0.7.5/debian/patches/series 2020-04-07 19:29:27.000000000 +0000 @@ -1,3 +1,2 @@ usr-prefix.diff debian-multiarch.diff -support-external-pkg-config.diff diff -Nru bmusb-0.7.4/debian/patches/support-external-pkg-config.diff bmusb-0.7.5/debian/patches/support-external-pkg-config.diff --- bmusb-0.7.4/debian/patches/support-external-pkg-config.diff 2019-07-25 21:02:34.000000000 +0000 +++ bmusb-0.7.5/debian/patches/support-external-pkg-config.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -Index: bmusb-0.7.4/Makefile -=================================================================== ---- bmusb-0.7.4.orig/Makefile -+++ bmusb-0.7.4/Makefile -@@ -1,5 +1,6 @@ --CXXFLAGS := -std=gnu++14 -O2 -Wall -I. -g $(shell pkg-config libusb-1.0 --cflags) -pthread --LDFLAGS := $(shell pkg-config libusb-1.0 --libs) -pthread -+PKG_CONFIG ?= pkg-config -+CXXFLAGS := -std=gnu++14 -O2 -Wall -I. -g $(shell $(PKG_CONFIG) libusb-1.0 --cflags) -pthread -+LDFLAGS := $(shell $(PKG_CONFIG) libusb-1.0 --libs) -pthread - AR := ar - LN := ln - RANLIB := ranlib diff -Nru bmusb-0.7.4/debian/patches/usr-prefix.diff bmusb-0.7.5/debian/patches/usr-prefix.diff --- bmusb-0.7.4/debian/patches/usr-prefix.diff 2019-04-19 08:00:41.000000000 +0000 +++ bmusb-0.7.5/debian/patches/usr-prefix.diff 2020-04-07 19:29:27.000000000 +0000 @@ -1,11 +1,11 @@ Description: Set prefix to /usr instead of /usr/local Author: Steinar H. Gunderson -Index: bmusb-0.7.4/Makefile +Index: bmusb-0.7.5/Makefile =================================================================== ---- bmusb-0.7.4.orig/Makefile -+++ bmusb-0.7.4/Makefile -@@ -4,7 +4,7 @@ AR := ar +--- bmusb-0.7.5.orig/Makefile ++++ bmusb-0.7.5/Makefile +@@ -5,7 +5,7 @@ AR := ar LN := ln RANLIB := ranlib INSTALL := install @@ -14,10 +14,10 @@ LIB := libbmusb.a SODEV := libbmusb.so SONAME := libbmusb.so.6 -Index: bmusb-0.7.4/bmusb.pc +Index: bmusb-0.7.5/bmusb.pc =================================================================== ---- bmusb-0.7.4.orig/bmusb.pc -+++ bmusb-0.7.4/bmusb.pc +--- bmusb-0.7.5.orig/bmusb.pc ++++ bmusb-0.7.5/bmusb.pc @@ -1,4 +1,4 @@ -prefix=/usr/local +prefix=/usr diff -Nru bmusb-0.7.4/Makefile bmusb-0.7.5/Makefile --- bmusb-0.7.4/Makefile 2019-03-29 21:32:49.000000000 +0000 +++ bmusb-0.7.5/Makefile 2020-04-07 20:11:30.000000000 +0000 @@ -1,5 +1,6 @@ -CXXFLAGS := -std=gnu++14 -O2 -Wall -I. -g $(shell pkg-config libusb-1.0 --cflags) -pthread -LDFLAGS := $(shell pkg-config libusb-1.0 --libs) -pthread +PKG_CONFIG ?= pkg-config +CXXFLAGS := -std=gnu++14 -O2 -Wall -I. -g $(shell $(PKG_CONFIG) libusb-1.0 --cflags) -pthread +LDFLAGS := $(shell $(PKG_CONFIG) libusb-1.0 --libs) -pthread AR := ar LN := ln RANLIB := ranlib @@ -8,15 +9,18 @@ LIB := libbmusb.a SODEV := libbmusb.so SONAME := libbmusb.so.6 -SOLIB := libbmusb.so.6.0.0 +SOLIB := libbmusb.so.6.0.1 -all: $(LIB) $(SOLIB) main +all: $(LIB) $(SOLIB) main bmusb-v4l2proxy %.pic.o : %.cpp $(CXX) $(CPPFLAGS) $(CXXFLAGS) -fPIC -o $@ -c $^ main: bmusb.o main.o - $(CXX) -o main $^ $(LDFLAGS) + $(CXX) -o $@ $^ $(LDFLAGS) + +bmusb-v4l2proxy: bmusb.o v4l2proxy.o + $(CXX) -o $@ $^ $(LDFLAGS) # Static library. $(LIB): bmusb.o fake_capture.o @@ -28,16 +32,18 @@ $(CXX) -shared -Wl,-soname,$(SONAME) -o $@ $^ $(LDFLAGS) clean: - $(RM) bmusb.o main.o fake_capture.o bmusb.pic.o fake_capture.pic.o $(LIB) $(SOLIB) main + $(RM) bmusb.o main.o v4l2proxy.o fake_capture.o bmusb.pic.o fake_capture.pic.o $(LIB) $(SOLIB) main bmusb-v4l2proxy install: all $(INSTALL) -m 755 -o root -g root -d \ $(DESTDIR)$(PREFIX)/lib \ $(DESTDIR)$(PREFIX)/lib/pkgconfig \ - $(DESTDIR)$(PREFIX)/include/bmusb + $(DESTDIR)$(PREFIX)/include/bmusb \ + $(DESTDIR)/lib/udev/rules.d $(INSTALL) -m 755 -o root -g root $(LIB) $(SOLIB) $(DESTDIR)$(PREFIX)/lib $(LN) -sf $(SOLIB) $(DESTDIR)$(PREFIX)/lib/$(SONAME) $(LN) -sf $(SOLIB) $(DESTDIR)$(PREFIX)/lib/$(SODEV) $(INSTALL) -m 755 -o root -g root bmusb/bmusb.h bmusb/fake_capture.h $(DESTDIR)$(PREFIX)/include/bmusb $(INSTALL) -m 644 -o root -g root bmusb.pc $(DESTDIR)$(PREFIX)/lib/pkgconfig + $(INSTALL) -m 644 -o root -g root 70-bmusb.rules $(DESTDIR)/lib/udev/rules.d diff -Nru bmusb-0.7.4/v4l2proxy.cpp bmusb-0.7.5/v4l2proxy.cpp --- bmusb-0.7.4/v4l2proxy.cpp 1970-01-01 00:00:00.000000000 +0000 +++ bmusb-0.7.5/v4l2proxy.cpp 2020-04-07 20:11:30.000000000 +0000 @@ -0,0 +1,110 @@ +// +// A helper proxy to send data from bmusb to a V4L2 output. +// To get it as a V4L2 _input_, you can use v4l2loopback: +// +// sudo apt install v4l2loopback-dkms v4l2loopback-utils +// sudo modprobe v4l2loopback video_nr=2 card_label='Intensity Shuttle (bmusb)' max_width=1280 max_height=720 exclusive_caps=1 +// ./bmusb-v4l2proxy /dev/video2 +// +// There is currently no audio support. + +#include +#include +#include +#include +#include +#include +#include +#if __SSE2__ +#include +#endif +#include + +using namespace std; +using namespace bmusb; + +BMUSBCapture *usb; +int video_fd; + +void frame_callback(uint16_t timecode, + FrameAllocator::Frame video_frame, size_t video_offset, VideoFormat video_format, + FrameAllocator::Frame audio_frame, size_t audio_offset, AudioFormat audio_format) +{ + printf("0x%04x: %zu video bytes (format 0x%04x, %d x %d)\n", + timecode, + video_frame.len - video_offset, video_format.id, video_format.width, video_format.height); + + static unsigned last_width = 0, last_height = 0, last_stride = 0; + + if (video_format.width != last_width || + video_format.height != last_height || + video_format.stride != last_stride) { + v4l2_format fmt; + memset(&fmt, 0, sizeof(fmt)); + fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + fmt.fmt.pix.width = video_format.width; + fmt.fmt.pix.height = video_format.height; + + // Chrome accepts YUYV, but not our native UYVY. We byteswap below. + fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; + + fmt.fmt.pix.field = V4L2_FIELD_NONE; + fmt.fmt.pix.bytesperline = video_format.stride; + fmt.fmt.pix.sizeimage = video_format.stride * video_format.height; + fmt.fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; + int err = ioctl(video_fd, VIDIOC_S_FMT, &fmt); + if (err == -1) { + perror("ioctl(VIDIOC_S_FMT)"); + usb->get_video_frame_allocator()->release_frame(video_frame); + usb->get_audio_frame_allocator()->release_frame(audio_frame); + return; + } else { + last_width = video_format.width; + last_height = video_format.height; + last_stride = video_format.stride; + } + } + + if (video_frame.data != nullptr) { + uint8_t *origptr = video_frame.data + video_offset + video_format.extra_lines_top * video_format.stride; +#if __SSE2__ + __m128i *ptr = (__m128i *)origptr; + for (unsigned i = 0; i < video_format.stride * video_format.height / 16; ++i) { + __m128i val = _mm_loadu_si128(ptr); + val = _mm_slli_epi16(val, 8) | _mm_srli_epi16(val, 8); + _mm_storeu_si128(ptr, val); + ++ptr; + } +#else + uint8_t *ptr = origptr; + for (unsigned i = 0; i < video_format.stride * video_format.height / 4; ++i) { + swap(ptr[0], ptr[1]); + swap(ptr[2], ptr[3]); + ptr += 4; + } +#endif + + write(video_fd, origptr, video_frame.len); + } + + usb->get_video_frame_allocator()->release_frame(video_frame); + usb->get_audio_frame_allocator()->release_frame(audio_frame); +} + +int main(int argc, char **argv) +{ + const char *filename = (argc >= 2) ? argv[1] : "/dev/video2"; + video_fd = open(filename, O_RDWR); + if (video_fd == -1) { + perror(filename); + exit(1); + } + + usb = new BMUSBCapture(0); // First card. + usb->set_frame_callback(frame_callback); + usb->configure_card(); + BMUSBCapture::start_bm_thread(); + usb->start_bm_capture(); + sleep(1000000); +} +