Skip to content

Commit 5e83b1a

Browse files
committed
Add rtlsdr_set_tuner_bandwidth
1 parent 73fddd2 commit 5e83b1a

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ include(CMakePackageConfigHelpers)
3838

3939
# Set the version information here
4040
set(VERSION_INFO_MAJOR_VERSION 2022) # increment major on api compatibility changes
41-
set(VERSION_INFO_MINOR_VERSION 6) # increment minor on feature-level changes
41+
set(VERSION_INFO_MINOR_VERSION 12) # increment minor on feature-level changes
4242
set(VERSION_INFO_PATCH_VERSION git) # increment patch for bug fixes and docs
4343
include(Version) # setup version info
4444

include/rtl-sdr.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ RTLSDR_API int rtlsdr_get_tuner_gains(rtlsdr_dev_t *dev, int *gains);
215215
*/
216216
RTLSDR_API int rtlsdr_set_tuner_gain(rtlsdr_dev_t *dev, int gain);
217217

218+
/*!
219+
* Set the bandwidth for the device.
220+
*
221+
* \param dev the device handle given by rtlsdr_open()
222+
* \param bw bandwidth in Hz. Zero means automatic BW selection.
223+
* \return 0 on success
224+
*/
225+
RTLSDR_API int rtlsdr_set_tuner_bandwidth(rtlsdr_dev_t *dev, uint32_t bw);
226+
218227
/*!
219228
* Get actual gain the device is configured to.
220229
*

src/librtlsdr.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct rtlsdr_dev {
114114
rtlsdr_tuner_iface_t *tuner;
115115
uint32_t tun_xtal; /* Hz */
116116
uint32_t freq; /* Hz */
117+
uint32_t bw;
117118
uint32_t offs_freq; /* Hz */
118119
uint32_t effective_freq; /* Hz */
119120
int corr; /* ppm */
@@ -1063,6 +1064,24 @@ int rtlsdr_get_tuner_gains(rtlsdr_dev_t *dev, int *gains)
10631064
}
10641065
}
10651066

1067+
int rtlsdr_set_tuner_bandwidth(rtlsdr_dev_t *dev, uint32_t bw)
1068+
{
1069+
int r = 0;
1070+
1071+
if (!dev || !dev->tuner)
1072+
return -1;
1073+
1074+
if (dev->tuner->set_bw) {
1075+
rtlsdr_set_i2c_repeater(dev, 1);
1076+
r = dev->tuner->set_bw(dev, bw > 0 ? bw : dev->rate);
1077+
rtlsdr_set_i2c_repeater(dev, 0);
1078+
if (r)
1079+
return r;
1080+
dev->bw = bw;
1081+
}
1082+
return r;
1083+
}
1084+
10661085
int rtlsdr_set_tuner_gain(rtlsdr_dev_t *dev, int gain)
10671086
{
10681087
int r = 0;

0 commit comments

Comments
 (0)