[packages/ustreamer] add patches for verbose build and libgpiod >= 2 support; rel 2
atler
atler at pld-linux.org
Tue Jan 2 11:16:40 CET 2024
commit 5ab1228d4cb62c8352d222aef370b32f573df943
Author: Jan Palus <atler at pld-linux.org>
Date: Tue Jan 2 11:13:12 2024 +0100
add patches for verbose build and libgpiod >= 2 support; rel 2
- verbose build already upstream - to be removed with upgrade to next
version (https://github.com/pikvm/ustreamer/pull/251)
- libgpiod >= 2 support rejected in favor of upstream implementation
although the latter is not committed yet. to be removed once it hits
release (https://github.com/pikvm/ustreamer/pull/249)
libgpiod2.patch | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++
ustreamer.spec | 12 +++-
verbose_build.patch | 111 +++++++++++++++++++++++++++++++++++++
3 files changed, 275 insertions(+), 3 deletions(-)
---
diff --git a/ustreamer.spec b/ustreamer.spec
index 4f83e17..d174761 100644
--- a/ustreamer.spec
+++ b/ustreamer.spec
@@ -6,16 +6,18 @@ Summary: Lightweight and fast MJPEG-HTTP streamer
Summary(pl.UTF-8): Lekki i szybki program do emisji strumieni MJPEG-HTTP
Name: ustreamer
Version: 5.46
-Release: 1
+Release: 2
License: GPL v3
Group: Applications/Multimedia
#Source0Download: https://github.com/pikvm/ustreamer/tags
Source0: https://github.com/pikvm/ustreamer/archive/v%{version}/%{name}-%{version}.tar.gz
# Source0-md5: 069c99f597d1b0dc72740b668baaaff6
+Patch0: verbose_build.patch
+Patch1: libgpiod2.patch
URL: https://github.com/pikvm/ustreamer
BuildRequires: libbsd-devel
BuildRequires: libevent-devel
-%{?with_libgpiod:BuildRequires: libgpiod-devel < 2}
+%{?with_libgpiod:BuildRequires: libgpiod-devel}
BuildRequires: libjpeg-devel
BuildRequires: systemd-devel
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -34,12 +36,15 @@ dowolnego urządzenia V4L2 do sieci.
%prep
%setup -q
+%patch0 -p1
+%patch1 -p1
%build
%{__make} \
CC="%{__cc}" \
CFLAGS="%{rpmcppflags} %{rpmcflags}" \
LDFLAGS="%{rpmldflags}" \
+ V=1 \
%{?with_libgpiod:WITH_GPIO=1} \
WITH_SYSTEMD=1
@@ -49,7 +54,8 @@ rm -rf $RPM_BUILD_ROOT
%{__make} install \
DESTDIR=$RPM_BUILD_ROOT \
PREFIX="%{_prefix}" \
- MANPREFIX="%{_mandir}"
+ MANPREFIX="%{_mandir}" \
+ V=1
%clean
rm -rf $RPM_BUILD_ROOT
diff --git a/libgpiod2.patch b/libgpiod2.patch
new file mode 100644
index 0000000..3aafb5c
--- /dev/null
+++ b/libgpiod2.patch
@@ -0,0 +1,155 @@
+From 605ece2ecad42e81008219a12cf2dd50bd35f3e0 Mon Sep 17 00:00:00 2001
+From: Jan Palus <jpalus at fastmail.com>
+Date: Mon, 1 Jan 2024 18:20:37 +0100
+Subject: [PATCH] gpio: add support for libgpiod 2.x
+
+---
+ src/Makefile | 2 +-
+ src/ustreamer/gpio/gpio.c | 100 ++++++++++++++++++++++++++++++++++++++
+ src/ustreamer/gpio/gpio.h | 4 ++
+ 3 files changed, 105 insertions(+), 1 deletion(-)
+
+diff --git a/src/Makefile b/src/Makefile
+index ac5897a7..76e8fa73 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -42,7 +42,7 @@ endef
+
+ ifneq ($(call optbool,$(WITH_GPIO)),)
+ _USTR_LIBS += -lgpiod
+-override _CFLAGS += -DWITH_GPIO
++override _CFLAGS += -DWITH_GPIO $(shell pkg-config --atleast-version=2 libgpiod 2> /dev/null && echo -DHAVE_GPIOD2)
+ _USTR_SRCS += $(shell ls ustreamer/gpio/*.c)
+ endif
+
+diff --git a/src/ustreamer/gpio/gpio.c b/src/ustreamer/gpio/gpio.c
+index cea40dc4..7c608517 100644
+--- a/src/ustreamer/gpio/gpio.c
++++ b/src/ustreamer/gpio/gpio.c
+@@ -80,6 +80,105 @@ void us_gpio_destroy(void) {
+ }
+ }
+
++#ifdef HAVE_GPIOD2
++int us_gpio_inner_set(us_gpio_output_s *output, bool state) {
++ int retval = 0;
++
++ assert(us_g_gpio.chip != NULL);
++ assert(output->line != NULL);
++ assert(output->state != state); // Must be checked in macro for the performance
++ US_MUTEX_LOCK(us_g_gpio.mutex);
++
++ if (gpiod_line_request_set_value(output->line, output->pin, state ? GPIOD_LINE_VALUE_ACTIVE : GPIOD_LINE_VALUE_INACTIVE) < 0) {
++ US_LOG_PERROR("GPIO: Can't write value %d to line %s (will be disabled)", state ? GPIOD_LINE_VALUE_ACTIVE : GPIOD_LINE_VALUE_INACTIVE, output->consumer);
++ _gpio_output_destroy(output);
++ retval = -1;
++ }
++
++ US_MUTEX_UNLOCK(us_g_gpio.mutex);
++ return retval;
++}
++
++static void _gpio_output_init(us_gpio_output_s *output) {
++ struct gpiod_line_settings *line_settings = NULL;
++ struct gpiod_line_config *line_config = NULL;
++ struct gpiod_request_config *request_config = NULL;
++
++ assert(us_g_gpio.chip != NULL);
++ assert(output->line == NULL);
++
++ US_ASPRINTF(output->consumer, "%s::%s", us_g_gpio.consumer_prefix, output->role);
++
++ if (output->pin >= 0) {
++ line_settings = gpiod_line_settings_new();
++ if (line_settings == NULL) {
++ US_LOG_PERROR("GPIO: Can't allocate line settings for pin=%d", output->pin);
++ goto output_destroy;
++ }
++
++ if (gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT) < 0) {
++ US_LOG_PERROR("GPIO: Can't set direction for pin=%d", output->pin);
++ goto free_settings;
++
++ }
++
++ if (gpiod_line_settings_set_output_value(line_settings, GPIOD_LINE_VALUE_INACTIVE) < 0) {
++ US_LOG_PERROR("GPIO: Can't set initial line value for pin=%d", output->pin);
++ goto free_settings;
++ }
++
++ line_config = gpiod_line_config_new();
++ if (line_config == NULL) {
++ US_LOG_PERROR("GPIO: Can't allocate line config for pin=%d", output->pin);
++ goto free_settings;
++ }
++
++ if (gpiod_line_config_add_line_settings(line_config, (const unsigned int *) &output->pin, 1, line_settings) < 0) {
++ US_LOG_PERROR("GPIO: Can't set initial line value for pin=%d", output->pin);
++ goto free_settings;
++ }
++
++ if (output->consumer != NULL) {
++ request_config = gpiod_request_config_new();
++ if (request_config == NULL) {
++ US_LOG_PERROR("GPIO: Can't allocate request config for pin=%d", output->pin);
++ goto free_settings;
++ }
++
++ gpiod_request_config_set_consumer(request_config, output->consumer);
++ }
++
++ if ((output->line = gpiod_chip_request_lines(us_g_gpio.chip, request_config, line_config)) == NULL) {
++ US_LOG_PERROR("GPIO: Can't request pin=%d as %s", output->pin, output->consumer);
++ goto free_config;
++ }
++ }
++
++free_config:
++ if (request_config != NULL) {
++ gpiod_request_config_free(request_config);
++ }
++ gpiod_line_config_free(line_config);
++free_settings:
++ gpiod_line_settings_free(line_settings);
++output_destroy:
++ if (output->line == NULL) {
++ _gpio_output_destroy(output);
++ }
++}
++
++static void _gpio_output_destroy(us_gpio_output_s *output) {
++ if (output->line != NULL) {
++ gpiod_line_request_release(output->line);
++ output->line = NULL;
++ }
++ if (output->consumer != NULL) {
++ free(output->consumer);
++ output->consumer = NULL;
++ }
++ output->state = false;
++}
++#else
+ int us_gpio_inner_set(us_gpio_output_s *output, bool state) {
+ int retval = 0;
+
+@@ -127,3 +226,4 @@ static void _gpio_output_destroy(us_gpio_output_s *output) {
+ }
+ output->state = false;
+ }
++#endif
+diff --git a/src/ustreamer/gpio/gpio.h b/src/ustreamer/gpio/gpio.h
+index 8bb86488..17a7e8f0 100644
+--- a/src/ustreamer/gpio/gpio.h
++++ b/src/ustreamer/gpio/gpio.h
+@@ -39,7 +39,11 @@ typedef struct {
+ int pin;
+ const char *role;
+ char *consumer;
++#ifdef HAVE_GPIOD2
++ struct gpiod_line_request *line;
++#else
+ struct gpiod_line *line;
++#endif
+ bool state;
+ } us_gpio_output_s;
+
diff --git a/verbose_build.patch b/verbose_build.patch
new file mode 100644
index 0000000..2191fe4
--- /dev/null
+++ b/verbose_build.patch
@@ -0,0 +1,111 @@
+From 6672cd87bfc51aa301da72a6303d9023fe75a566 Mon Sep 17 00:00:00 2001
+From: Jan Palus <jpalus at fastmail.com>
+Date: Mon, 1 Jan 2024 19:14:09 +0100
+Subject: [PATCH] add option to make verbose builds
+
+if V=1 is passed to make echo invoked command verbosely
+---
+ Makefile | 11 +++++++----
+ janus/Makefile | 6 +++---
+ python/Makefile | 2 +-
+ src/Makefile | 8 ++++----
+ 4 files changed, 15 insertions(+), 12 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 9f3ea84c..8dab4c77 100644
+--- a/Makefile
++++ b/Makefile
+@@ -22,6 +22,9 @@ define optbool
+ $(filter $(shell echo $(1) | tr A-Z a-z), yes on 1)
+ endef
+
++ifeq ($(V),)
++ ECHO = @
++endif
+
+ # =====
+ all:
+@@ -36,18 +39,18 @@ endif
+
+ apps:
+ $(MAKE) -C src
+- @ ln -sf src/ustreamer.bin ustreamer
+- @ ln -sf src/ustreamer-dump.bin ustreamer-dump
++ $(ECHO) ln -sf src/ustreamer.bin ustreamer
++ $(ECHO) ln -sf src/ustreamer-dump.bin ustreamer-dump
+
+
+ python:
+ $(MAKE) -C python
+- @ ln -sf python/build/lib.*/*.so .
++ $(ECHO) ln -sf python/build/lib.*/*.so .
+
+
+ janus:
+ $(MAKE) -C janus
+- @ ln -sf janus/*.so .
++ $(ECHO) ln -sf janus/*.so .
+
+
+ install: all
+diff --git a/janus/Makefile b/janus/Makefile
+index afbad3ee..90111830 100644
+--- a/janus/Makefile
++++ b/janus/Makefile
+@@ -31,13 +31,13 @@ endif
+ # =====
+ $(_PLUGIN): $(_SRCS:%.c=$(_BUILD)/%.o)
+ $(info == SO $@)
+- @ $(CC) $^ -o $@ $(_LDFLAGS)
++ $(ECHO) $(CC) $^ -o $@ $(_LDFLAGS)
+
+
+ $(_BUILD)/%.o: %.c
+ $(info -- CC $<)
+- @ mkdir -p $(dir $@) || true
+- @ $(CC) $< -o $@ $(_CFLAGS)
++ $(ECHO) mkdir -p $(dir $@) || true
++ $(ECHO) $(CC) $< -o $@ $(_CFLAGS)
+
+
+
+diff --git a/python/Makefile b/python/Makefile
+index b9e723c0..a8b60d54 100644
+--- a/python/Makefile
++++ b/python/Makefile
+@@ -9,7 +9,7 @@ PY ?= python3
+ # =====
+ all:
+ $(info == PY_BUILD ustreamer-*.so)
+- @ $(PY) setup.py build
++ $(ECHO) $(PY) setup.py build
+
+
+ install:
+diff --git a/src/Makefile b/src/Makefile
+index ac5897a7..a56ae9d4 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -86,18 +86,18 @@ install-strip: install
+
+ $(_USTR): $(_USTR_SRCS:%.c=$(_BUILD)/%.o)
+ $(info == LD $@)
+- @ $(CC) $^ -o $@ $(_LDFLAGS) $(_USTR_LIBS)
++ $(ECHO) $(CC) $^ -o $@ $(_LDFLAGS) $(_USTR_LIBS)
+
+
+ $(_DUMP): $(_DUMP_SRCS:%.c=$(_BUILD)/%.o)
+ $(info == LD $@)
+- @ $(CC) $^ -o $@ $(_LDFLAGS) $(_DUMP_LIBS)
++ $(ECHO) $(CC) $^ -o $@ $(_LDFLAGS) $(_DUMP_LIBS)
+
+
+ $(_BUILD)/%.o: %.c
+ $(info -- CC $<)
+- @ mkdir -p $(dir $@) || true
+- @ $(CC) $< -o $@ $(_CFLAGS)
++ $(ECHO) mkdir -p $(dir $@) || true
++ $(ECHO) $(CC) $< -o $@ $(_CFLAGS)
+
+
+ clean:
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/ustreamer.git/commitdiff/5ab1228d4cb62c8352d222aef370b32f573df943
More information about the pld-cvs-commit
mailing list