Accepting request 909511 from hardware:sdr

OBS-URL: https://build.opensuse.org/request/show/909511
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rtl-sdr?expand=0&rev=8
This commit is contained in:
Dominique Leuenberger 2021-07-31 16:51:27 +00:00 committed by Git OBS Bridge
commit 0c75571693
13 changed files with 1406 additions and 4 deletions

View File

@ -0,0 +1,51 @@
From f68bb2fa772ad94f58c59babd78353667570630b Mon Sep 17 00:00:00 2001
From: Steve Markgraf <steve@steve-m.de>
Date: Sun, 7 Oct 2018 01:16:07 +0200
Subject: [PATCH] lib: Add workaround for Linux usbfs mmap() bug
The Linux Kernel has a bug on ARM/ARM64 systems where the USB CMA
memory is incorrectly mapped to userspace, breaking zerocopy.
When the Kernel allocates the memory, it clears it with memset().
If the mapping worked correctly, we should have zeroed out buffers,
if it doesn't, we get random Kernel memory. We now check for this,
and fall back to buffers in userspace if that's the case.
Signed-off-by: Steve Markgraf <steve@steve-m.de>
---
src/librtlsdr.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index 433ed5b..89ec903 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -1755,11 +1755,26 @@ static int _rtlsdr_alloc_async_buffers(rtlsdr_dev_t *dev)
for (i = 0; i < dev->xfer_buf_num; ++i) {
dev->xfer_buf[i] = libusb_dev_mem_alloc(dev->devh, dev->xfer_buf_len);
- if (!dev->xfer_buf[i]) {
+ if (dev->xfer_buf[i]) {
+ /* Check if Kernel usbfs mmap() bug is present: if the
+ * mapping is correct, the buffers point to memory that
+ * was memset to 0 by the Kernel, otherwise, they point
+ * to random memory. We check if the buffers are zeroed
+ * and otherwise fall back to buffers in userspace.
+ */
+ if (dev->xfer_buf[i][0] || memcmp(dev->xfer_buf[i],
+ dev->xfer_buf[i] + 1,
+ dev->xfer_buf_len - 1)) {
+ fprintf(stderr, "Detected Kernel usbfs mmap() "
+ "bug, falling back to buffers "
+ "in userspace\n");
+ dev->use_zerocopy = 0;
+ break;
+ }
+ } else {
fprintf(stderr, "Failed to allocate zero-copy "
"buffer for transfer %d\nFalling "
"back to buffers in userspace\n", i);
-
dev->use_zerocopy = 0;
break;
}

View File

@ -0,0 +1,24 @@
From be1d1206bfb6e6c41f7d91b20b77e20f929fa6a7 Mon Sep 17 00:00:00 2001
From: Steve Markgraf <steve@steve-m.de>
Date: Tue, 16 Jul 2019 23:31:31 +0200
Subject: [PATCH] lib: fix memory leak in rtlsdr_open()
Thanks to Vincent Perrier for reporting the bug.
---
src/librtlsdr.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index 89ec903..d72a0f5 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -1628,6 +1628,9 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)
return 0;
err:
if (dev) {
+ if (dev->devh)
+ libusb_close(dev->devh);
+
if (dev->ctx)
libusb_exit(dev->ctx);

View File

@ -0,0 +1,39 @@
From 3c263b745121d9f4df95fd06910a00eba98a2f11 Mon Sep 17 00:00:00 2001
From: Steve Markgraf <steve@steve-m.de>
Date: Fri, 1 Nov 2019 02:18:54 +0100
Subject: [PATCH] rtl_eeprom: fix warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Account for \0 string terminator when calling strncpy().
Fixes the following GCC 9 warning:
warning: __builtin_strncpy specified
bound 256 equals destination size
---
src/rtl_eeprom.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/rtl_eeprom.c b/src/rtl_eeprom.c
index f562d73..24be900 100644
--- a/src/rtl_eeprom.c
+++ b/src/rtl_eeprom.c
@@ -370,14 +370,14 @@ int main(int argc, char **argv)
}
if (manuf_str)
- strncpy((char*)&conf.manufacturer, manuf_str, MAX_STR_SIZE);
+ strncpy((char*)&conf.manufacturer, manuf_str, MAX_STR_SIZE - 1);
if (product_str)
- strncpy((char*)&conf.product, product_str, MAX_STR_SIZE);
+ strncpy((char*)&conf.product, product_str, MAX_STR_SIZE - 1);
if (serial_str) {
conf.have_serial = 1;
- strncpy((char*)&conf.serial, serial_str, MAX_STR_SIZE);
+ strncpy((char*)&conf.serial, serial_str, MAX_STR_SIZE - 1);
}
if (ir_endpoint != 0)

View File

@ -0,0 +1,181 @@
diff --git a/include/rtl-sdr.h b/include/rtl-sdr.h
index 3ed13ae..d64701e 100644
--- a/include/rtl-sdr.h
+++ b/include/rtl-sdr.h
@@ -389,6 +389,17 @@ RTLSDR_API int rtlsdr_cancel_async(rtlsdr_dev_t *dev);
*/
RTLSDR_API int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on);
+/*!
+ * Enable or disable the bias tee on the given GPIO pin.
+ *
+ * \param dev the device handle given by rtlsdr_open()
+ * \param gpio the gpio pin to configure as a Bias T control.
+ * \param on 1 for Bias T on. 0 for Bias T off.
+ * \return -1 if device is not initialized. 0 otherwise.
+ */
+RTLSDR_API int rtlsdr_set_bias_tee_gpio(rtlsdr_dev_t *dev, int gpio, int on);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index 213e96c..0146298 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -2009,13 +2009,18 @@ int rtlsdr_i2c_read_fn(void *dev, uint8_t addr, uint8_t *buf, int len)
return -1;
}
-int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on)
+int rtlsdr_set_bias_tee_gpio(rtlsdr_dev_t *dev, int gpio, int on)
{
if (!dev)
return -1;
- rtlsdr_set_gpio_output(dev, 0);
- rtlsdr_set_gpio_bit(dev, 0, on);
+ rtlsdr_set_gpio_output(dev, gpio);
+ rtlsdr_set_gpio_bit(dev, gpio, on);
return 0;
}
+
+int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on)
+{
+ return rtlsdr_set_bias_tee_gpio(dev, 0, on);
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 015fd48..8713fba 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -91,7 +91,8 @@ add_executable(rtl_fm rtl_fm.c)
add_executable(rtl_eeprom rtl_eeprom.c)
add_executable(rtl_adsb rtl_adsb.c)
add_executable(rtl_power rtl_power.c)
-set(INSTALL_TARGETS rtlsdr_shared rtlsdr_static rtl_sdr rtl_tcp rtl_test rtl_fm rtl_eeprom rtl_adsb rtl_power)
+add_executable(rtl_biast rtl_biast.c)
+set(INSTALL_TARGETS rtlsdr_shared rtlsdr_static rtl_sdr rtl_tcp rtl_test rtl_fm rtl_eeprom rtl_adsb rtl_power rtl_biast)
target_link_libraries(rtl_sdr rtlsdr_shared convenience_static
${LIBUSB_LIBRARIES}
@@ -121,6 +122,11 @@ target_link_libraries(rtl_power rtlsdr_shared convenience_static
${LIBUSB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
+target_link_libraries(rtl_biast rtlsdr_shared convenience_static
+ ${LIBUSB_LIBRARIES}
+ ${CMAKE_THREAD_LIBS_INIT}
+)
+
if(UNIX)
target_link_libraries(rtl_fm m)
target_link_libraries(rtl_adsb m)
diff --git a/src/rtl_biast.c b/src/rtl_biast.c
new file mode 100644
index 0000000..185e838
--- /dev/null
+++ b/src/rtl_biast.c
@@ -0,0 +1,101 @@
+/*
+ * rtl-sdr, turns your Realtek RTL2832 based DVB dongle into a SDR receiver
+ * rtl_biast, tool to set bias tee gpio output
+ * Copyright (C) 2012 by Steve Markgraf <steve@steve-m.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef _WIN32
+#include <unistd.h>
+#else
+#include <windows.h>
+#include "getopt/getopt.h"
+#endif
+
+#include "rtl-sdr.h"
+#include "convenience/convenience.h"
+
+static rtlsdr_dev_t *dev = NULL;
+
+void usage(void)
+{
+ fprintf(stderr,
+ "rtl_biast, a tool for turning the RTL-SDR.com \n"
+ "bias tee or any GPIO ON and OFF. Example to turn on the \n"
+ "bias tee: rtl_biast -d 0 -b 1\n"
+ "Any GPIO: rtl_biast -d 0 -g 1 -b 1\n\n"
+ "Usage:\n"
+ "\t[-d device_index (default: 0)]\n"
+ "\t[-b bias_on (default: 0)]\n"
+ "\t[-g GPIO select (default: 0)]\n");
+ exit(1);
+}
+
+int main(int argc, char **argv)
+{
+ int i, r, opt;
+ int dev_index = 0;
+ int dev_given = 0;
+ uint32_t bias_on = 0;
+ uint32_t gpio_pin = 0;
+ int device_count;
+
+ while ((opt = getopt(argc, argv, "d:b:g:h?")) != -1) {
+ switch (opt) {
+ case 'd':
+ dev_index = verbose_device_search(optarg);
+ dev_given = 1;
+ break;
+ case 'b':
+ bias_on = atoi(optarg);
+ break;
+ case 'g':
+ gpio_pin = atoi(optarg);
+ break;
+ default:
+ usage();
+ break;
+ }
+ }
+
+ if (!dev_given) {
+ dev_index = verbose_device_search("0");
+ }
+
+ if (dev_index < 0) {
+ exit(1);
+ }
+
+ r = rtlsdr_open(&dev, dev_index);
+ rtlsdr_set_bias_tee_gpio(dev, gpio_pin, bias_on);
+
+exit:
+ /*
+ * Note - rtlsdr_close() in this tree does not clear the bias tee
+ * GPIO line, so it leaves the bias tee enabled if a client program
+ * doesn't explictly disable it.
+ *
+ * If that behaviour changes then another rtlsdr_close() will be
+ * needed that takes some extension flags, and one of them should
+ * be to either explicitly close the biast or leave it alone.
+ */
+ rtlsdr_close(dev);
+
+ return r >= 0 ? r : -r;
+}

View File

@ -0,0 +1,27 @@
From 1dff8e0b4c5681cf2cbc6d4ab0aa0bee30c5ed09 Mon Sep 17 00:00:00 2001
From: Benjamin Larsson <banan@ludd.ltu.se>
Date: Mon, 17 Feb 2020 01:20:24 +0100
Subject: [PATCH] lib: enable better UHF reception (>862MHz) for FC0013
---
src/tuner_fc0013.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/tuner_fc0013.c b/src/tuner_fc0013.c
index 78b696e..5984dfb 100644
--- a/src/tuner_fc0013.c
+++ b/src/tuner_fc0013.c
@@ -248,11 +248,11 @@ int fc0013_set_params(void *dev, uint32_t freq, uint32_t bandwidth)
if (ret)
goto exit;
- /* disable UHF & enable GPS */
+ /* enable UHF & disable GPS */
ret = fc0013_readreg(dev, 0x14, &tmp);
if (ret)
goto exit;
- ret = fc0013_writereg(dev, 0x14, (tmp & 0x1f) | 0x20);
+ ret = fc0013_writereg(dev, 0x14, (tmp & 0x1f) | 0x40);
if (ret)
goto exit;
}

View File

@ -0,0 +1,28 @@
From 222517b506278178ab93182d79ccf7eb04d107ce Mon Sep 17 00:00:00 2001
From: "A. Maitland Bottoms" <bottoms@debian.org>
Date: Sun, 8 May 2016 18:57:29 -0400
Subject: [PATCH] Improve librtlsdr.pc file
librtlsdr.pc should declare -lusb-1.0 in Libs.private section
to exclude usb library from dynamic linking.
References to libusb headers are not needed in Cflags, since these
headers are not used by external rtlsdr API, but this is optional.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=784912
---
librtlsdr.pc.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/librtlsdr.pc.in b/librtlsdr.pc.in
index 5e55049..e46519a 100644
--- a/librtlsdr.pc.in
+++ b/librtlsdr.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@
Name: RTL-SDR Library
Description: C Utility Library
Version: @VERSION@
-Cflags: -I${includedir}/ @RTLSDR_PC_CFLAGS@
-Libs: -L${libdir} -lrtlsdr -lusb-1.0
-Libs.private: @RTLSDR_PC_LIBS@
+Cflags: -I${includedir}/
+Libs: -L${libdir} -lrtlsdr
+Libs.private: -lusb-1.0 @RTLSDR_PC_LIBS@

View File

@ -0,0 +1,57 @@
From f2a9a81c4be95a6e9da97ec784f893d98a43f289 Mon Sep 17 00:00:00 2001
From: "A. Maitland Bottoms" <bottoms@debian.org>
Date: Thu, 24 Aug 2017 05:27:57 -0400
Subject: [PATCH] rtl_fm/rtl_power: Improve scanning range parsing
---
src/rtl_fm.c | 13 +++++++++++++
src/rtl_power.c | 8 ++++++++
2 files changed, 21 insertions(+)
diff --git a/src/rtl_fm.c b/src/rtl_fm.c
index b163979..283542d 100644
--- a/src/rtl_fm.c
+++ b/src/rtl_fm.c
@@ -926,8 +926,21 @@ void frequency_range(struct controller_state *s, char *arg)
int i;
start = arg;
stop = strchr(start, ':') + 1;
+ if (stop == (char *)1) { // no stop or step given
+ s->freqs[s->freq_len] = (uint32_t) atofs(start);
+ s->freq_len++;
+ return;
+ }
stop[-1] = '\0';
step = strchr(stop, ':') + 1;
+ if (step == (char *)1) { // no step given
+ s->freqs[s->freq_len] = (uint32_t) atofs(start);
+ s->freq_len++;
+ s->freqs[s->freq_len] = (uint32_t) atofs(stop);
+ s->freq_len++;
+ stop[-1] = ':';
+ return;
+ }
step[-1] = '\0';
for(i=(int)atofs(start); i<=(int)atofs(stop); i+=(int)atofs(step))
{
diff --git a/src/rtl_power.c b/src/rtl_power.c
index 625d818..6204de2 100644
--- a/src/rtl_power.c
+++ b/src/rtl_power.c
@@ -437,8 +437,16 @@ void frequency_range(char *arg, double crop)
/* hacky string parsing */
start = arg;
stop = strchr(start, ':') + 1;
+ if (stop == (char *)1) {
+ fprintf(stderr, "Bad frequency range specification: %s\n", arg);
+ exit(1);
+ }
stop[-1] = '\0';
step = strchr(stop, ':') + 1;
+ if (step == (char *)1) {
+ fprintf(stderr, "Bad frequency range specification: %s\n", arg);
+ exit(1);
+ }
step[-1] = '\0';
lower = (int)atofs(start);
upper = (int)atofs(stop);

View File

@ -0,0 +1,144 @@
From 8985b45e1fe1a5d50c5e1dc4c7c306705e602445 Mon Sep 17 00:00:00 2001
From: "A. Maitland Bottoms" <bottoms@debian.org>
Date: Sun, 3 Sep 2017 16:22:55 -0400
Subject: [PATCH] rtl_tcp: Add IPv6 support
I've prepared this patch in response to Debian bug #870804
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=870804
It passes the text from the -a and -p options through
getaddrinfo() and uses the first result that has a valid
socket with a successful bind.
While not a complete bind to all possible valid names, it
does appear to address the use case of the bug submitter
without completely changing the program flow.
---
src/rtl_tcp.c | 72 +++++++++++++++++++++++++++++++++++++++------------
1 file changed, 55 insertions(+), 17 deletions(-)
diff --git a/src/rtl_tcp.c b/src/rtl_tcp.c
index da6057b..42b90cb 100644
--- a/src/rtl_tcp.c
+++ b/src/rtl_tcp.c
@@ -30,6 +30,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
+#include <netdb.h>
#include <netinet/in.h>
#include <fcntl.h>
#else
@@ -371,10 +372,18 @@ static void *command_worker(void *arg)
int main(int argc, char **argv)
{
int r, opt, i;
- char* addr = "127.0.0.1";
- int port = 1234;
+ char *addr = "127.0.0.1";
+ char *port = "1234";
uint32_t frequency = 100000000, samp_rate = 2048000;
- struct sockaddr_in local, remote;
+ struct sockaddr_storage local, remote;
+ struct addrinfo *ai;
+ struct addrinfo *aiHead;
+ struct addrinfo hints;
+ char hostinfo[NI_MAXHOST];
+ char portinfo[NI_MAXSERV];
+ char remhostinfo[NI_MAXHOST];
+ char remportinfo[NI_MAXSERV];
+ int aiErr;
uint32_t buf_num = 0;
int dev_index = 0;
int dev_given = 0;
@@ -413,10 +422,10 @@ int main(int argc, char **argv)
samp_rate = (uint32_t)atofs(optarg);
break;
case 'a':
- addr = optarg;
+ addr = strdup(optarg);
break;
case 'p':
- port = atoi(optarg);
+ port = strdup(optarg);
break;
case 'b':
buf_num = atoi(optarg);
@@ -515,16 +524,42 @@ int main(int argc, char **argv)
pthread_cond_init(&cond, NULL);
pthread_cond_init(&exit_cond, NULL);
- memset(&local,0,sizeof(local));
- local.sin_family = AF_INET;
- local.sin_port = htons(port);
- local.sin_addr.s_addr = inet_addr(addr);
+ hints.ai_flags = AI_PASSIVE; /* Server mode. */
+ hints.ai_family = PF_UNSPEC; /* IPv4 or IPv6. */
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_protocol = IPPROTO_TCP;
+
+ if ((aiErr = getaddrinfo(addr,
+ port,
+ &hints,
+ &aiHead )) != 0)
+ {
+ fprintf(stderr, "local address %s ERROR - %s.\n",
+ addr, gai_strerror(aiErr));
+ return(-1);
+ }
+ memcpy(&local, aiHead->ai_addr, aiHead->ai_addrlen);
+
+ for (ai = aiHead; ai != NULL; ai = ai->ai_next) {
+ aiErr = getnameinfo((struct sockaddr *)ai->ai_addr, ai->ai_addrlen,
+ hostinfo, NI_MAXHOST,
+ portinfo, NI_MAXSERV, NI_NUMERICSERV | NI_NUMERICHOST);
+ if (aiErr)
+ fprintf( stderr, "getnameinfo ERROR - %s.\n",hostinfo);
+
+ listensocket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ if (listensocket < 0)
+ continue;
+
+ r = 1;
+ setsockopt(listensocket, SOL_SOCKET, SO_REUSEADDR, (char *)&r, sizeof(int));
+ setsockopt(listensocket, SOL_SOCKET, SO_LINGER, (char *)&ling, sizeof(ling));
- listensocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- r = 1;
- setsockopt(listensocket, SOL_SOCKET, SO_REUSEADDR, (char *)&r, sizeof(int));
- setsockopt(listensocket, SOL_SOCKET, SO_LINGER, (char *)&ling, sizeof(ling));
- bind(listensocket,(struct sockaddr *)&local,sizeof(local));
+ if (bind(listensocket, (struct sockaddr *)&local, sizeof(local)))
+ fprintf(stderr, "rtl_tcp bind error: %s", strerror(errno));
+ else
+ break;
+ }
#ifdef _WIN32
ioctlsocket(listensocket, FIONBIO, &blockmode);
@@ -535,11 +570,11 @@ int main(int argc, char **argv)
while(1) {
printf("listening...\n");
- printf("Use the device argument 'rtl_tcp=%s:%d' in OsmoSDR "
+ printf("Use the device argument 'rtl_tcp=%s:%s' in OsmoSDR "
"(gr-osmosdr) source\n"
"to receive samples in GRC and control "
"rtl_tcp parameters (frequency, gain, ...).\n",
- addr, port);
+ hostinfo, portinfo);
listen(listensocket,1);
while(1) {
@@ -559,7 +594,10 @@ int main(int argc, char **argv)
setsockopt(s, SOL_SOCKET, SO_LINGER, (char *)&ling, sizeof(ling));
- printf("client accepted!\n");
+ getnameinfo((struct sockaddr *)&remote, rlen,
+ remhostinfo, NI_MAXHOST,
+ remportinfo, NI_MAXSERV, NI_NUMERICSERV);
+ printf("client accepted! %s %s\n", remhostinfo, remportinfo);
memset(&dongle_info, 0, sizeof(dongle_info));
memcpy(&dongle_info.magic, "RTL0", 4);

View File

@ -0,0 +1,25 @@
From f427883320cbb65e254644717f5d7963e37bbd1d Mon Sep 17 00:00:00 2001
From: Steve Markgraf <steve@steve-m.de>
Date: Wed, 26 Feb 2020 23:52:02 +0100
Subject: [PATCH] rtl_tcp: Initialize listensocket
Older versions of GCC will complain that it can be used
uninitialized - which is not the case, but it breaks our Jenkins
build as we build with -Werror.
---
src/rtl_tcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rtl_tcp.c b/src/rtl_tcp.c
index 42b90cb..562198f 100644
--- a/src/rtl_tcp.c
+++ b/src/rtl_tcp.c
@@ -394,7 +394,7 @@ int main(int argc, char **argv)
void *status;
struct timeval tv = {1,0};
struct linger ling = {1,0};
- SOCKET listensocket;
+ SOCKET listensocket = 0;
socklen_t rlen;
fd_set readfds;
u_long blockmode = 1;

View File

@ -0,0 +1,714 @@
diff -up librtlsdr-0.6.0/CMakeLists.txt.aaaa librtlsdr-0.6.0/CMakeLists.txt
--- librtlsdr-0.6.0/CMakeLists.txt.aaaa 2018-08-26 14:54:51.000000000 +0200
+++ librtlsdr-0.6.0/CMakeLists.txt 2021-07-11 20:54:05.540782656 +0200
@@ -1,41 +1,44 @@
-# Copyright 2012 OSMOCOM Project
+# Copyright 2012-2020 Osmocom Project
#
# This file is part of rtl-sdr
#
-# GNU Radio is free software; you can redistribute it and/or modify
+# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
#
-# GNU Radio is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
########################################################################
# Project setup
########################################################################
-cmake_minimum_required(VERSION 2.6)
-project(rtlsdr C)
+cmake_minimum_required(VERSION 3.7.2)
+
+# workaround for https://gitlab.kitware.com/cmake/cmake/issues/16967
+if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
+ project(rtlsdr)
+else()
+ project(rtlsdr C)
+endif()
#select the release build type by default to get optimization flags
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: defaulting to release.")
endif(NOT CMAKE_BUILD_TYPE)
-set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
+list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
-if(NOT LIB_INSTALL_DIR)
- set(LIB_INSTALL_DIR lib)
-endif()
+include(GNUInstallDirs)
+include(GenerateExportHeader)
+include(CMakePackageConfigHelpers)
# Set the version information here
set(VERSION_INFO_MAJOR_VERSION 0) # increment major on api compatibility changes
@@ -63,12 +66,12 @@ endif()
########################################################################
# Find build dependencies
########################################################################
-find_package(PkgConfig)
-find_package(LibUSB)
if(WIN32 AND NOT MINGW)
set(THREADS_USE_PTHREADS_WIN32 true)
endif()
find_package(Threads)
+find_package(PkgConfig)
+pkg_check_modules(LIBUSB libusb-1.0 IMPORTED_TARGET)
if(NOT LIBUSB_FOUND)
message(FATAL_ERROR "LibUSB 1.0 required to compile rtl-sdr")
@@ -76,27 +79,12 @@ endif()
if(NOT THREADS_FOUND)
message(FATAL_ERROR "pthreads(-win32) required to compile rtl-sdr")
endif()
-########################################################################
-# Setup the include and linker paths
-########################################################################
-include_directories(
- ${CMAKE_SOURCE_DIR}/include
- ${LIBUSB_INCLUDE_DIR}
- ${THREADS_PTHREADS_INCLUDE_DIR}
-)
-
-#link_directories(
-# ...
-#)
-
-# Set component parameters
-#set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE INTERNAL "" FORCE)
########################################################################
# Create uninstall target
########################################################################
configure_file(
- ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
+ ${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
@ONLY)
@@ -126,10 +114,26 @@ else (DETACH_KERNEL_DRIVER)
message (STATUS "Building with kernel driver detaching disabled, use -DDETACH_KERNEL_DRIVER=ON to enable")
endif (DETACH_KERNEL_DRIVER)
+option(ENABLE_ZEROCOPY "Enable usbfs zero-copy support" OFF)
+if (ENABLE_ZEROCOPY)
+ message (STATUS "Building with usbfs zero-copy support enabled")
+ add_definitions(-DENABLE_ZEROCOPY=1)
+else (ENABLE_ZEROCOPY)
+ message (STATUS "Building with usbfs zero-copy support disabled, use -DENABLE_ZEROCOPY=ON to enable")
+endif (ENABLE_ZEROCOPY)
+
+########################################################################
+# Install public header files
+########################################################################
+install(FILES
+ include/rtl-sdr.h
+ include/rtl-sdr_export.h
+ DESTINATION include
+)
+
########################################################################
# Add subdirectories
########################################################################
-add_subdirectory(include)
add_subdirectory(src)
########################################################################
@@ -153,10 +157,10 @@ IF(CMAKE_CROSSCOMPILING)
UNSET(RTLSDR_PC_LIBS)
ENDIF(CMAKE_CROSSCOMPILING)
-set(prefix ${CMAKE_INSTALL_PREFIX})
+set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix \${prefix})
-set(libdir \${exec_prefix}/${LIB_INSTALL_DIR})
set(includedir \${prefix}/include)
+set(libdir \${exec_prefix}/lib)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/librtlsdr.pc.in
@@ -165,10 +169,38 @@ CONFIGURE_FILE(
INSTALL(
FILES ${CMAKE_CURRENT_BINARY_DIR}/librtlsdr.pc
- DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
########################################################################
+# Create CMake Config File
+########################################################################
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/rtlsdr/rtlsdrConfigVersion.cmake"
+ VERSION ${VERSION}
+ COMPATIBILITY AnyNewerVersion
+ )
+
+configure_file(cmake/rtlsdrConfig.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/rtlsdr/rtlsdrConfig.cmake"
+ COPYONLY
+ )
+
+set(ConfigPackageLocation lib/cmake/rtlsdr)
+install(EXPORT RTLSDR-export
+ FILE rtlsdrTargets.cmake
+ NAMESPACE rtlsdr::
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/rtlsdr/
+ )
+install(
+ FILES
+ cmake/rtlsdrConfig.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/rtlsdr/rtlsdrConfigVersion.cmake"
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/rtlsdr/
+ COMPONENT Devel
+ )
+
+########################################################################
# Print Summary
########################################################################
MESSAGE(STATUS "Building for version: ${VERSION} / ${LIBVER}")
diff --git a/cmake/Modules/FindLibUSB.cmake b/cmake/Modules/FindLibUSB.cmake
deleted file mode 100644
index abe6ee4..0000000
--- a/cmake/Modules/FindLibUSB.cmake
+++ /dev/null
@@ -1,55 +0,0 @@
-if(NOT LIBUSB_FOUND)
- pkg_check_modules (LIBUSB_PKG libusb-1.0)
- find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h
- PATHS
- ${LIBUSB_PKG_INCLUDE_DIRS}
- /usr/include/libusb-1.0
- /usr/include
- /usr/local/include
- )
-
-#standard library name for libusb-1.0
-set(libusb1_library_names usb-1.0)
-
-#libusb-1.0 compatible library on freebsd
-if((CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") OR (CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD"))
- list(APPEND libusb1_library_names usb)
-endif()
-
- find_library(LIBUSB_LIBRARIES
- NAMES ${libusb1_library_names}
- PATHS
- ${LIBUSB_PKG_LIBRARY_DIRS}
- /usr/lib
- /usr/local/lib
- )
-
-include(CheckFunctionExists)
-if(LIBUSB_INCLUDE_DIRS)
- set(CMAKE_REQUIRED_INCLUDES ${LIBUSB_INCLUDE_DIRS})
-endif()
-if(LIBUSB_LIBRARIES)
- set(CMAKE_REQUIRED_LIBRARIES ${LIBUSB_LIBRARIES})
-endif()
-
-CHECK_FUNCTION_EXISTS("libusb_handle_events_timeout_completed" HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED)
-if(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED)
- add_definitions(-DHAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED=1)
-endif(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED)
-
-CHECK_FUNCTION_EXISTS("libusb_error_name" HAVE_LIBUSB_ERROR_NAME)
-if(HAVE_LIBUSB_ERROR_NAME)
- add_definitions(-DHAVE_LIBUSB_ERROR_NAME=1)
-endif(HAVE_LIBUSB_ERROR_NAME)
-
-if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
- set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb-1.0 found")
- message(STATUS "Found libusb-1.0: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARIES}")
-else(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
- set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
- message(STATUS "libusb-1.0 not found.")
-endif(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
-
-mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)
-
-endif(NOT LIBUSB_FOUND)
diff --git a/cmake/Modules/FindThreads.cmake b/cmake/Modules/FindThreads.cmake
deleted file mode 100644
index 8028b15..0000000
--- a/cmake/Modules/FindThreads.cmake
+++ /dev/null
@@ -1,246 +0,0 @@
-# Updated FindThreads.cmake that supports pthread-win32
-# Downloaded from http://www.vtk.org/Bug/bug_view_advanced_page.php?bug_id=6399
-
-# - This module determines the thread library of the system.
-#
-# The following variables are set
-# CMAKE_THREAD_LIBS_INIT - the thread library
-# CMAKE_USE_SPROC_INIT - are we using sproc?
-# CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads?
-# CMAKE_USE_PTHREADS_INIT - are we using pthreads
-# CMAKE_HP_PTHREADS_INIT - are we using hp pthreads
-#
-# If use of pthreads-win32 is desired, the following variables
-# can be set.
-#
-# THREADS_USE_PTHREADS_WIN32 -
-# Setting this to true searches for the pthreads-win32
-# port (since CMake 2.8.0)
-#
-# THREADS_PTHREADS_WIN32_EXCEPTION_SCHEME
-# C = no exceptions (default)
-# (NOTE: This is the default scheme on most POSIX thread
-# implementations and what you should probably be using)
-# CE = C++ Exception Handling
-# SE = Structure Exception Handling (MSVC only)
-# (NOTE: Changing this option from the default may affect
-# the portability of your application. See pthreads-win32
-# documentation for more details.)
-#
-#======================================================
-# Example usage where threading library
-# is provided by the system:
-#
-# find_package(Threads REQUIRED)
-# add_executable(foo foo.cc)
-# target_link_libraries(foo ${CMAKE_THREAD_LIBS_INIT})
-#
-# Example usage if pthreads-win32 is desired on Windows
-# or a system provided thread library:
-#
-# set(THREADS_USE_PTHREADS_WIN32 true)
-# find_package(Threads REQUIRED)
-# include_directories(${THREADS_PTHREADS_INCLUDE_DIR})
-#
-# add_executable(foo foo.cc)
-# target_link_libraries(foo ${CMAKE_THREAD_LIBS_INIT})
-#
-
-INCLUDE (CheckIncludeFiles)
-INCLUDE (CheckLibraryExists)
-SET(Threads_FOUND FALSE)
-
-IF(WIN32 AND NOT CYGWIN AND THREADS_USE_PTHREADS_WIN32)
- SET(_Threads_ptwin32 true)
-ENDIF()
-
-# Do we have sproc?
-IF(CMAKE_SYSTEM MATCHES IRIX)
- CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H)
-ENDIF()
-
-IF(CMAKE_HAVE_SPROC_H)
- # We have sproc
- SET(CMAKE_USE_SPROC_INIT 1)
-
-ELSEIF(_Threads_ptwin32)
-
- IF(NOT DEFINED THREADS_PTHREADS_WIN32_EXCEPTION_SCHEME)
- # Assign the default scheme
- SET(THREADS_PTHREADS_WIN32_EXCEPTION_SCHEME "C")
- ELSE()
- # Validate the scheme specified by the user
- IF(NOT THREADS_PTHREADS_WIN32_EXCEPTION_SCHEME STREQUAL "C" AND
- NOT THREADS_PTHREADS_WIN32_EXCEPTION_SCHEME STREQUAL "CE" AND
- NOT THREADS_PTHREADS_WIN32_EXCEPTION_SCHEME STREQUAL "SE")
- MESSAGE(FATAL_ERROR "See documentation for FindPthreads.cmake, only C, CE, and SE modes are allowed")
- ENDIF()
- IF(NOT MSVC AND THREADS_PTHREADS_WIN32_EXCEPTION_SCHEME STREQUAL "SE")
- MESSAGE(FATAL_ERROR "Structured Exception Handling is only allowed for MSVC")
- ENDIF(NOT MSVC AND THREADS_PTHREADS_WIN32_EXCEPTION_SCHEME STREQUAL "SE")
- ENDIF()
-
- FIND_PATH(THREADS_PTHREADS_INCLUDE_DIR pthread.h)
-
- # Determine the library filename
- IF(MSVC)
- SET(_Threads_pthreads_libname
- pthreadV${THREADS_PTHREADS_WIN32_EXCEPTION_SCHEME}2)
- ELSEIF(MINGW)
- SET(_Threads_pthreads_libname
- pthreadG${THREADS_PTHREADS_WIN32_EXCEPTION_SCHEME}2)
- ELSE()
- MESSAGE(FATAL_ERROR "This should never happen")
- ENDIF()
-
- # Use the include path to help find the library if possible
- SET(_Threads_lib_paths "")
- IF(THREADS_PTHREADS_INCLUDE_DIR)
- GET_FILENAME_COMPONENT(_Threads_root_dir
- ${THREADS_PTHREADS_INCLUDE_DIR} PATH)
- SET(_Threads_lib_paths ${_Threads_root_dir}/lib)
- ENDIF()
- FIND_LIBRARY(THREADS_PTHREADS_WIN32_LIBRARY
- NAMES ${_Threads_pthreads_libname}
- PATHS ${_Threads_lib_paths}
- DOC "The Portable Threads Library for Win32"
- NO_SYSTEM_PATH
- )
-
- IF(THREADS_PTHREADS_INCLUDE_DIR AND THREADS_PTHREADS_WIN32_LIBRARY)
- MARK_AS_ADVANCED(THREADS_PTHREADS_INCLUDE_DIR)
- SET(CMAKE_THREAD_LIBS_INIT ${THREADS_PTHREADS_WIN32_LIBRARY})
- SET(CMAKE_HAVE_THREADS_LIBRARY 1)
- SET(Threads_FOUND TRUE)
- ENDIF()
-
- MARK_AS_ADVANCED(THREADS_PTHREADS_WIN32_LIBRARY)
-
-ELSE()
- # Do we have pthreads?
- CHECK_INCLUDE_FILES("pthread.h" CMAKE_HAVE_PTHREAD_H)
- IF(CMAKE_HAVE_PTHREAD_H)
-
- #
- # We have pthread.h
- # Let's check for the library now.
- #
- SET(CMAKE_HAVE_THREADS_LIBRARY)
- IF(NOT THREADS_HAVE_PTHREAD_ARG)
-
- # Do we have -lpthreads
- CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
- IF(CMAKE_HAVE_PTHREADS_CREATE)
- SET(CMAKE_THREAD_LIBS_INIT "-lpthreads")
- SET(CMAKE_HAVE_THREADS_LIBRARY 1)
- SET(Threads_FOUND TRUE)
- ENDIF()
-
- # Ok, how about -lpthread
- CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
- IF(CMAKE_HAVE_PTHREAD_CREATE)
- SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
- SET(Threads_FOUND TRUE)
- SET(CMAKE_HAVE_THREADS_LIBRARY 1)
- ENDIF()
-
- IF(CMAKE_SYSTEM MATCHES "SunOS.*")
- # On sun also check for -lthread
- CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
- IF(CMAKE_HAVE_THR_CREATE)
- SET(CMAKE_THREAD_LIBS_INIT "-lthread")
- SET(CMAKE_HAVE_THREADS_LIBRARY 1)
- SET(Threads_FOUND TRUE)
- ENDIF()
- ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
-
- ENDIF(NOT THREADS_HAVE_PTHREAD_ARG)
-
- IF(NOT CMAKE_HAVE_THREADS_LIBRARY)
- # If we did not found -lpthread, -lpthread, or -lthread, look for -pthread
- IF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
- MESSAGE(STATUS "Check if compiler accepts -pthread")
- TRY_RUN(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
- ${CMAKE_BINARY_DIR}
- ${CMAKE_ROOT}/Modules/CheckForPthreads.c
- CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread
- COMPILE_OUTPUT_VARIABLE OUTPUT)
-
- IF(THREADS_HAVE_PTHREAD_ARG)
- IF(THREADS_PTHREAD_ARG MATCHES "^2$")
- SET(Threads_FOUND TRUE)
- MESSAGE(STATUS "Check if compiler accepts -pthread - yes")
- ELSE()
- MESSAGE(STATUS "Check if compiler accepts -pthread - no")
- FILE(APPEND
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if compiler accepts -pthread returned ${THREADS_PTHREAD_ARG} instead of 2. The compiler had the following output:\n${OUTPUT}\n\n")
- ENDIF()
- ELSE()
- MESSAGE(STATUS "Check if compiler accepts -pthread - no")
- FILE(APPEND
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n")
- ENDIF()
-
- ENDIF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
-
- IF(THREADS_HAVE_PTHREAD_ARG)
- SET(Threads_FOUND TRUE)
- SET(CMAKE_THREAD_LIBS_INIT "-pthread")
- ENDIF()
-
- ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY)
- ENDIF(CMAKE_HAVE_PTHREAD_H)
-ENDIF()
-
-IF(CMAKE_THREAD_LIBS_INIT)
- SET(CMAKE_USE_PTHREADS_INIT 1)
- SET(Threads_FOUND TRUE)
-ENDIF()
-
-IF(CMAKE_SYSTEM MATCHES "Windows"
- AND NOT THREADS_USE_PTHREADS_WIN32)
- SET(CMAKE_USE_WIN32_THREADS_INIT 1)
- SET(Threads_FOUND TRUE)
-ENDIF()
-
-IF(CMAKE_USE_PTHREADS_INIT)
- IF(CMAKE_SYSTEM MATCHES "HP-UX-*")
- # Use libcma if it exists and can be used. It provides more
- # symbols than the plain pthread library. CMA threads
- # have actually been deprecated:
- # http://docs.hp.com/en/B3920-90091/ch12s03.html#d0e11395
- # http://docs.hp.com/en/947/d8.html
- # but we need to maintain compatibility here.
- # The CMAKE_HP_PTHREADS setting actually indicates whether CMA threads
- # are available.
- CHECK_LIBRARY_EXISTS(cma pthread_attr_create "" CMAKE_HAVE_HP_CMA)
- IF(CMAKE_HAVE_HP_CMA)
- SET(CMAKE_THREAD_LIBS_INIT "-lcma")
- SET(CMAKE_HP_PTHREADS_INIT 1)
- SET(Threads_FOUND TRUE)
- ENDIF(CMAKE_HAVE_HP_CMA)
- SET(CMAKE_USE_PTHREADS_INIT 1)
- ENDIF()
-
- IF(CMAKE_SYSTEM MATCHES "OSF1-V*")
- SET(CMAKE_USE_PTHREADS_INIT 0)
- SET(CMAKE_THREAD_LIBS_INIT )
- ENDIF()
-
- IF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*")
- SET(CMAKE_USE_PTHREADS_INIT 1)
- SET(Threads_FOUND TRUE)
- SET(CMAKE_THREAD_LIBS_INIT )
- SET(CMAKE_USE_WIN32_THREADS_INIT 0)
- ENDIF()
-ENDIF(CMAKE_USE_PTHREADS_INIT)
-
-INCLUDE(FindPackageHandleStandardArgs)
-IF(_Threads_ptwin32)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG
- THREADS_PTHREADS_WIN32_LIBRARY THREADS_PTHREADS_INCLUDE_DIR)
-ELSE()
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND)
-ENDIF()
diff -up librtlsdr-0.6.0/src/CMakeLists.txt.aaaa librtlsdr-0.6.0/src/CMakeLists.txt
--- librtlsdr-0.6.0/src/CMakeLists.txt.aaaa 2021-07-08 13:39:12.962332505 +0200
+++ librtlsdr-0.6.0/src/CMakeLists.txt 2021-07-08 13:42:22.587472144 +0200
@@ -1,69 +1,66 @@
-# Copyright 2012 OSMOCOM Project
+# Copyright 2012-2020 Osmocom Project
#
# This file is part of rtl-sdr
#
-# GNU Radio is free software; you can redistribute it and/or modify
+# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
#
-# GNU Radio is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-
-MACRO(RTLSDR_APPEND_SRCS)
- LIST(APPEND rtlsdr_srcs ${ARGV})
-ENDMACRO(RTLSDR_APPEND_SRCS)
-
-RTLSDR_APPEND_SRCS(
- librtlsdr.c
- tuner_e4k.c
- tuner_fc0012.c
- tuner_fc0013.c
- tuner_fc2580.c
- tuner_r82xx.c
-)
-
-########################################################################
-# Set up Windows DLL resource files
-########################################################################
-IF(MSVC)
- include(${CMAKE_SOURCE_DIR}/cmake/Modules/Version.cmake)
-
- configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/rtlsdr.rc.in
- ${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc
- @ONLY)
-
- RTLSDR_APPEND_SRCS(${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc)
-ENDIF(MSVC)
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
########################################################################
# Setup shared library variant
########################################################################
-add_library(rtlsdr_shared SHARED ${rtlsdr_srcs})
-target_link_libraries(rtlsdr_shared ${LIBUSB_LIBRARIES})
-set_target_properties(rtlsdr_shared PROPERTIES DEFINE_SYMBOL "rtlsdr_EXPORTS")
-set_target_properties(rtlsdr_shared PROPERTIES OUTPUT_NAME rtlsdr)
-set_target_properties(rtlsdr_shared PROPERTIES SOVERSION ${MAJOR_VERSION})
-set_target_properties(rtlsdr_shared PROPERTIES VERSION ${LIBVER})
+add_library(rtlsdr SHARED librtlsdr.c
+ tuner_e4k.c tuner_fc0012.c tuner_fc0013.c tuner_fc2580.c tuner_r82xx.c)
+target_link_libraries(rtlsdr PkgConfig::LIBUSB)
+target_include_directories(rtlsdr PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include> # <prefix>/include
+ )
+set_target_properties(rtlsdr PROPERTIES DEFINE_SYMBOL "rtlsdr_EXPORTS")
+set_target_properties(rtlsdr PROPERTIES OUTPUT_NAME rtlsdr)
+set_target_properties(rtlsdr PROPERTIES SOVERSION ${MAJOR_VERSION})
+set_target_properties(rtlsdr PROPERTIES VERSION ${LIBVER})
+generate_export_header(rtlsdr)
########################################################################
# Setup static library variant
########################################################################
-add_library(rtlsdr_static STATIC ${rtlsdr_srcs})
-target_link_libraries(rtlsdr_static ${LIBUSB_LIBRARIES})
+add_library(rtlsdr_static STATIC librtlsdr.c
+ tuner_e4k.c tuner_fc0012.c tuner_fc0013.c tuner_fc2580.c tuner_r82xx.c)
+target_link_libraries(rtlsdr_static PkgConfig::LIBUSB)
+target_include_directories(rtlsdr_static PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include> # <prefix>/include
+ )
set_property(TARGET rtlsdr_static APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
if(NOT WIN32)
# Force same library filename for static and shared variants of the library
set_target_properties(rtlsdr_static PROPERTIES OUTPUT_NAME rtlsdr)
endif()
+generate_export_header(rtlsdr_static)
+
+########################################################################
+# Set up Windows DLL resource files
+########################################################################
+IF(MSVC)
+ include(${CMAKE_SOURCE_DIR}/cmake/Modules/Version.cmake)
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/rtlsdr.rc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc
+ @ONLY)
+ target_sources(rtlsdr ${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc)
+ target_sources(rtlsdr_static ${CMAKE_CURRENT_BINARY_DIR}/rtlsdr.rc)
+ENDIF(MSVC)
########################################################################
# Setup libraries used in executables
@@ -71,13 +68,14 @@ endif()
add_library(convenience_static STATIC
convenience/convenience.c
)
-
+target_include_directories(convenience_static
+ PRIVATE ${CMAKE_SOURCE_DIR}/include)
if(WIN32)
add_library(libgetopt_static STATIC
getopt/getopt.c
)
target_link_libraries(convenience_static
- rtlsdr_shared
+ rtlsdr
)
endif()
@@ -92,41 +90,40 @@ add_executable(rtl_eeprom rtl_eeprom.c)
add_executable(rtl_adsb rtl_adsb.c)
add_executable(rtl_power rtl_power.c)
add_executable(rtl_biast rtl_biast.c)
-set(INSTALL_TARGETS rtlsdr_shared rtlsdr_static rtl_sdr rtl_tcp rtl_test rtl_fm rtl_eeprom rtl_adsb rtl_power rtl_biast)
+set(INSTALL_TARGETS rtlsdr rtlsdr_static rtl_sdr rtl_tcp rtl_test rtl_fm rtl_eeprom rtl_adsb rtl_power rtl_biast)
-target_link_libraries(rtl_sdr rtlsdr_shared convenience_static
+target_link_libraries(rtl_sdr rtlsdr convenience_static
${LIBUSB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
-target_link_libraries(rtl_tcp rtlsdr_shared convenience_static
+target_link_libraries(rtl_tcp rtlsdr convenience_static
${LIBUSB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
-target_link_libraries(rtl_test rtlsdr_shared convenience_static
+target_link_libraries(rtl_test rtlsdr convenience_static
${LIBUSB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
-target_link_libraries(rtl_fm rtlsdr_shared convenience_static
+target_link_libraries(rtl_fm rtlsdr convenience_static
${LIBUSB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
-target_link_libraries(rtl_eeprom rtlsdr_shared convenience_static
+target_link_libraries(rtl_eeprom rtlsdr convenience_static
${LIBUSB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
-target_link_libraries(rtl_adsb rtlsdr_shared convenience_static
+target_link_libraries(rtl_adsb rtlsdr convenience_static
${LIBUSB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
-target_link_libraries(rtl_power rtlsdr_shared convenience_static
+target_link_libraries(rtl_power rtlsdr convenience_static
${LIBUSB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
-target_link_libraries(rtl_biast rtlsdr_shared convenience_static
+target_link_libraries(rtl_biast rtlsdr convenience_static
${LIBUSB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
-
if(UNIX)
target_link_libraries(rtl_fm m)
target_link_libraries(rtl_adsb m)
@@ -157,8 +154,12 @@ endif()
########################################################################
# Install built library files & utilities
########################################################################
-install(TARGETS ${INSTALL_TARGETS}
- LIBRARY DESTINATION ${LIB_INSTALL_DIR} # .so/.dylib file
- ARCHIVE DESTINATION ${LIB_INSTALL_DIR} # .lib file
- RUNTIME DESTINATION bin # .dll file
-)
+install(TARGETS rtlsdr EXPORT RTLSDR-export
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # .so/.dylib file
+ )
+install(TARGETS rtlsdr_static EXPORT RTLSDR-export
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # .so/.dylib file
+ )
+install(TARGETS rtl_sdr rtl_tcp rtl_test rtl_fm rtl_eeprom rtl_adsb rtl_power rtl_biast
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
+ )
diff --git a/cmake/rtlsdrConfig.cmake b/cmake/rtlsdrConfig.cmake
new file mode 100644
index 0000000..eeff2f3
--- /dev/null
+++ b/cmake/rtlsdrConfig.cmake
@@ -0,0 +1,8 @@
+include(FindPkgConfig)
+pkg_check_modules(LIBUSB libusb-1.0 IMPORTED_TARGET)
+
+get_filename_component(RTLSDR_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+if(NOT TARGET rtlsdr::rtlsdr)
+ include("${RTLSDR_CMAKE_DIR}/rtlsdrTargets.cmake")
+endif()

View File

@ -0,0 +1,40 @@
From d794155ba65796a76cd0a436f9709f4601509320 Mon Sep 17 00:00:00 2001
From: Derrick Pallas <derrick@pallas.us>
Date: Wed, 18 Mar 2020 14:54:48 -0700
Subject: [PATCH] tuner_r82xx: fix short-write in r82xx_read
In r82xx_read, there is a 1-byte I2C write followed by the I2C read. If
this I2C write fails, r82xx_read correctly bails out but may return 0.
Callers that check whether (rc < 0) will assume that the buffer was written
when it has not been, e.g. in r82xx_set_tv_standard where
priv->fil_cal_code = data[4] & 0x0f;
consumes a garbage value for data[4].
This change resolves that issue by copying the error path from r82xx_write.
---
src/tuner_r82xx.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/tuner_r82xx.c b/src/tuner_r82xx.c
index fe52bd9..997abd7 100644
--- a/src/tuner_r82xx.c
+++ b/src/tuner_r82xx.c
@@ -330,8 +330,14 @@ static int r82xx_read(struct r82xx_priv *priv, uint8_t reg, uint8_t *val, int le
priv->buf[0] = reg;
rc = rtlsdr_i2c_write_fn(priv->rtl_dev, priv->cfg->i2c_addr, priv->buf, 1);
- if (rc < 1)
- return rc;
+
+ if (rc != 1) {
+ fprintf(stderr, "%s: i2c wr failed=%d reg=%02x len=%d\n",
+ __FUNCTION__, rc, reg, 1);
+ if (rc < 0)
+ return rc;
+ return -1;
+ }
rc = rtlsdr_i2c_read_fn(priv->rtl_dev, priv->cfg->i2c_addr, p, len);

View File

@ -1,3 +1,47 @@
-------------------------------------------------------------------
Thu Jul 22 09:07:26 UTC 2021 - Wojciech Kazubski <wk@ire.pw.edu.pl>
- patches:
rtl-sdr-0003-disable-zerocopy-by-default.patch
rtl-sdr-0007-allow-build-rtlsdr-as-subroject.patch
rtl-sdr-0008-add-CMP0075-policy.patch
rtl-sdr-0016-add-missing-rtlsdrConfig.patch
rtl-sdr-0017-add-rtl_biast-as-install-target.patch
rtl-sdr-0018-fix-for-older-cmake.patch
merged into rtl-sdr-0015-modernize-cmake-usage.patch
- patch rtl-sdr-0005-add-rtlsdr_set_bias_tee_gpio.patch
merged into rtl-sdr-0006-add-rtl_biast.patch
-------------------------------------------------------------------
Tue Jul 6 10:55:44 UTC 2021 - Wojciech Kazubski <wk@ire.pw.edu.pl>
- Added patches to upgrade to latest git head (only significant
changes), including:
+ rtl-sdr-0001-mmap-bug-arm.patch
+ rtl-sdr-0002-fix-rtlsdr_open-memory-leak.patch
+ rtl-sdr-0003-disable-zerocopy-by-default.patch
+ rtl-sdr-0004-fix-rtl_eeprom-warnings.patch
+ rtl-sdr-0005-add-rtlsdr_set_bias_tee_gpio.patch
+ rtl-sdr-0006-add-rtl_biast.patch
+ rtl-sdr-0007-allow-build-rtlsdr-as-subroject.patch
+ rtl-sdr-0008-add-CMP0075-policy.patch
+ rtl-sdr-0009-fix-FC0013-UHF-reception.patch
+ rtl-sdr-0010-improve-librtlsdr_pc.patch
+ rtl-sdr-0011-improve-rtl_power--scanning-range-parsing.patch
+ rtl-sdr-0012-use-udev-uaccess_rules.patch (not used)
+ rtl-sdr-0013-add-IPV6-for-rtl_tcp.patch
+ rtl-sdr-0014-initialize-listensocket_in-rtl_tcp.patch
+ rtl-sdr-0015-modernize-cmake-usage.patch
+ rtl-sdr-0016-add-missing-rtlsdrConfig.patch
+ rtl-sdr-0017-add-rtl_biast-as-install-target.patch
+ rtl-sdr-0018-fix-for-older-cmake.patch
+ rtl-sdr-0019-fix-short-write-in-r82xx_read.patch
+ rtl-sdr-0020-populate-pkgconfig-with-prefix.patch
* Full bias tee support for RTL-SDR v3 dongle
* Command line utility rtl_biast for controlling bias tee
* IPV-6 support for rtl_tcp
* Fixed some bugs and compile time issues
-------------------------------------------------------------------
Tue Aug 28 08:07:53 UTC 2018 - mpluskal@suse.com

View File

@ -1,6 +1,7 @@
#
# spec file for package rtl-sdr
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
@ -19,6 +20,7 @@
%define sover 0
%define libname librtlsdr%{sover}
%define rtlsdr_group rtlsdr
Name: rtl-sdr
Version: 0.6.0
Release: 0
@ -29,7 +31,19 @@ URL: http://sdr.osmocom.org/trac/wiki/rtl-sdr
#Git-Clone: https://git.osmocom.org/rtl-sdr
Source: https://github.com/steve-m/librtlsdr/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch0: 0001-Better-udev-handling.patch
BuildRequires: cmake
Patch1: rtl-sdr-0001-mmap-bug-arm.patch
Patch2: rtl-sdr-0002-fix-rtlsdr_open-memory-leak.patch
Patch4: rtl-sdr-0004-fix-rtl_eeprom-warnings.patch
Patch6: rtl-sdr-0006-add-rtl_biast.patch
Patch9: rtl-sdr-0009-fix-FC0013-UHF-reception.patch
Patch10: rtl-sdr-0010-improve-librtlsdr_pc.patch
Patch11: rtl-sdr-0011-improve-rtl_power--scanning-range-parsing.patch
Patch13: rtl-sdr-0013-add-IPV6-for-rtl_tcp.patch
Patch14: rtl-sdr-0014-initialize-listensocket_in-rtl_tcp.patch
Patch15: rtl-sdr-0015-modernize-cmake-usage.patch
Patch19: rtl-sdr-0019-fix-short-write-in-r82xx_read.patch
BuildRequires: cmake >= 3.7.2
BuildRequires: gcc-c++
BuildRequires: pkgconfig
BuildRequires: pkgconfig(libusb-1.0)
BuildRequires: pkgconfig(udev)
@ -64,6 +78,17 @@ Library headers for rtl-sdr driver.
%prep
%setup -q -n librtlsdr-%{version}
%patch1 -p1
%patch2 -p1
%patch4 -p1
%patch6 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch19 -p1
%patch0 -p1
%build
@ -72,6 +97,7 @@ Library headers for rtl-sdr driver.
-DUDEV_RULES_PATH=%{_udevrulesdir} \
-DUDEV_RULES_GROUP=%{rtlsdr_group} \
-DDETACH_KERNEL_DRIVER=ON \
-DENABLE_ZEROCOPY=ON \
-Wno-dev
%make_jobs
@ -95,6 +121,7 @@ getent group %{rtlsdr_group} >/dev/null || groupadd -r %{rtlsdr_group}
%license COPYING
%doc AUTHORS README
%{_bindir}/rtl_adsb
%{_bindir}/rtl_biast
%{_bindir}/rtl_eeprom
%{_bindir}/rtl_fm
%{_bindir}/rtl_power
@ -113,5 +140,6 @@ getent group %{rtlsdr_group} >/dev/null || groupadd -r %{rtlsdr_group}
%{_includedir}/rtl-sdr.h
%{_includedir}/rtl-sdr_export.h
%{_libdir}/pkgconfig/librtlsdr.pc
%{_libdir}/cmake/rtlsdr
%changelog