mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-21 23:55:13 -05:00
Settings.
This commit is contained in:
parent
86f256dbc4
commit
a476f8a6f0
@ -95,7 +95,7 @@ bool V4LGui::handleMessage(Message* message)
|
||||
void V4LGui::displaySettings()
|
||||
{
|
||||
ui->centerFrequency->setValue(m_generalSettings.m_centerFrequency / 1000);
|
||||
ui->decimation->setValue(m_settings.m_decimation);
|
||||
ui->samplerate->setValue(m_settings.m_samplerate);
|
||||
|
||||
if(m_gains.size() > 0) {
|
||||
int dist = abs(m_settings.m_gain - m_gains[0]);
|
||||
@ -139,10 +139,12 @@ void V4LGui::on_gain_valueChanged(int value)
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void V4LGui::on_decimation_valueChanged(int value)
|
||||
void V4LGui::on_samplerate_valueChanged(int value)
|
||||
{
|
||||
ui->decimationText->setText(tr("1:%1").arg(1 << value));
|
||||
m_settings.m_decimation = value;
|
||||
int Rates[] = { 2500, 1536, 3072, 288, 1000, 0};
|
||||
int newrate = Rates[value];
|
||||
ui->samplerateText->setText(tr("%1kHz").arg(newrate));
|
||||
m_settings.m_samplerate = 1000 * newrate;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ private:
|
||||
private slots:
|
||||
void on_centerFrequency_changed(quint64 value);
|
||||
void on_gain_valueChanged(int value);
|
||||
void on_decimation_valueChanged(int value);
|
||||
void on_samplerate_valueChanged(int value);
|
||||
|
||||
void updateHardware();
|
||||
};
|
||||
|
@ -106,9 +106,9 @@
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSlider" name="decimation">
|
||||
<widget class="QSlider" name="samplerate">
|
||||
<property name="toolTip">
|
||||
<string>Signal decimation factor</string>
|
||||
<string>Device Samplerate</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>4</number>
|
||||
@ -130,12 +130,12 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zoom Out</string>
|
||||
<string>Samplerate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="decimationText">
|
||||
<widget class="QLabel" name="samplerateText">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <errno.h>
|
||||
#include "v4linput.h"
|
||||
#include "v4lthread.h"
|
||||
#include "v4lsource.h"
|
||||
#include "v4lgui.h"
|
||||
#include "util/simpleserializer.h"
|
||||
|
||||
@ -28,21 +27,21 @@ MESSAGE_CLASS_DEFINITION(V4LInput::MsgReportV4L, Message)
|
||||
|
||||
V4LInput::Settings::Settings() :
|
||||
m_gain(0),
|
||||
m_decimation(0)
|
||||
m_samplerate(2500000)
|
||||
{
|
||||
}
|
||||
|
||||
void V4LInput::Settings::resetToDefaults()
|
||||
{
|
||||
m_gain = 0;
|
||||
m_decimation = 0;
|
||||
m_samplerate = 2500000;
|
||||
}
|
||||
|
||||
QByteArray V4LInput::Settings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
s.writeS32(1, m_gain);
|
||||
s.writeS32(2, m_decimation);
|
||||
s.writeS32(2, m_samplerate);
|
||||
return s.final();
|
||||
}
|
||||
|
||||
@ -57,7 +56,7 @@ bool V4LInput::Settings::deserialize(const QByteArray& data)
|
||||
|
||||
if(d.getVersion() == 1) {
|
||||
d.readS32(1, &m_gain, 0);
|
||||
d.readS32(2, &m_decimation, 0);
|
||||
d.readS32(2, &m_samplerate, 0);
|
||||
return true;
|
||||
} else {
|
||||
resetToDefaults();
|
||||
@ -187,7 +186,9 @@ const QString& V4LInput::getDeviceDescription() const
|
||||
|
||||
int V4LInput::getSampleRate() const
|
||||
{
|
||||
return 96000 * (1 << m_settings.m_decimation);
|
||||
int result = m_settings.m_samplerate / 4;
|
||||
if (result > 200000) result /= 4;
|
||||
return result;
|
||||
}
|
||||
|
||||
quint64 V4LInput::getCenterFrequency() const
|
||||
@ -215,18 +216,18 @@ bool V4LInput::applySettings(const GeneralSettings& generalSettings, const Setti
|
||||
if((m_generalSettings.m_centerFrequency != generalSettings.m_centerFrequency) || force) {
|
||||
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
|
||||
if(m_dev > 0)
|
||||
V4LInput::set_center_freq( (double)(m_generalSettings.m_centerFrequency
|
||||
+ 384000) ); // samplerate/4
|
||||
V4LInput::set_center_freq( (double)(generalSettings.m_centerFrequency
|
||||
+ (settings.m_samplerate / 4) ));
|
||||
}
|
||||
if((m_settings.m_gain != settings.m_gain) || force) {
|
||||
m_settings.m_gain = settings.m_gain;
|
||||
if(m_dev > 0)
|
||||
V4LInput::set_tuner_gain((double)m_settings.m_gain);
|
||||
}
|
||||
if((m_settings.m_decimation != settings.m_decimation) || force) {
|
||||
m_settings.m_decimation = settings.m_decimation;
|
||||
if((m_settings.m_samplerate != settings.m_samplerate) || force) {
|
||||
m_settings.m_samplerate = settings.m_samplerate;
|
||||
if(m_dev > 0)
|
||||
m_V4LThread->setDecimation(m_settings.m_decimation);
|
||||
m_V4LThread->setSamplerate((double)settings.m_samplerate);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -20,7 +20,11 @@
|
||||
|
||||
#include "dsp/samplesource/samplesource.h"
|
||||
#include <QString>
|
||||
#include "v4lsource.h"
|
||||
|
||||
struct v4l_buffer {
|
||||
void *start;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
class V4LThread;
|
||||
|
||||
@ -28,7 +32,7 @@ class V4LInput : public SampleSource {
|
||||
public:
|
||||
struct Settings {
|
||||
qint32 m_gain;
|
||||
qint32 m_decimation;
|
||||
qint32 m_samplerate;
|
||||
|
||||
Settings();
|
||||
void resetToDefaults();
|
||||
@ -96,9 +100,7 @@ public:
|
||||
void set_center_freq(double freq);
|
||||
void set_bandwidth(double bandwidth);
|
||||
void set_tuner_gain(double gain);
|
||||
int work(int noutput_items,
|
||||
void* input_items,
|
||||
void* output_items);
|
||||
int work(int noutput_items, qint16* output_items);
|
||||
private:
|
||||
int fd;
|
||||
quint32 pixelformat;
|
||||
|
@ -35,7 +35,7 @@ void V4LPlugin::initPlugin(PluginAPI* pluginAPI)
|
||||
PluginInterface::SampleSourceDevices V4LPlugin::enumSampleSources()
|
||||
{
|
||||
SampleSourceDevices result;
|
||||
int count = rtlsdr_get_device_count();
|
||||
int count = 1; //rtlsdr_get_device_count();
|
||||
char vendor[256];
|
||||
char product[256];
|
||||
char serial[256];
|
||||
@ -45,9 +45,9 @@ PluginInterface::SampleSourceDevices V4LPlugin::enumSampleSources()
|
||||
product[0] = '\0';
|
||||
serial[0] = '\0';
|
||||
|
||||
if(rtlsdr_get_device_usb_strings((uint32_t)i, vendor, product, serial) != 0)
|
||||
continue;
|
||||
QString displayedName(QString("SDR #%1 (%2 #%3)").arg(i + 1).arg(product).arg(serial));
|
||||
// if(rtlsdr_get_device_usb_strings((uint32_t)i, vendor, product, serial) != 0)
|
||||
// continue;
|
||||
QString displayedName(QString("SDR #%1").arg(i + 1));
|
||||
SimpleSerializer s(1);
|
||||
s.writeS32(1, i);
|
||||
result.append(SampleSourceDevice(displayedName, "org.osmocom.sdr.samplesource.v4l", s.final()));
|
||||
|
@ -17,8 +17,16 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "v4lsource.h"
|
||||
#include "v4linput.h"
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <uapi/linux/videodev2.h>
|
||||
#include "/usr/local/include/libv4l2.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
/* Control classes */
|
||||
#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */
|
||||
@ -47,7 +55,7 @@ static void xioctl(int fh, unsigned long int request, void *arg)
|
||||
ret = v4l2_ioctl(fh, request, arg);
|
||||
} while (ret == -1 && ((errno == EINTR) || (errno == EAGAIN)));
|
||||
if (ret == -1) {
|
||||
fprintf(stderr, "error %d\n", errno);
|
||||
qCritical("error %d\n", errno);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +85,7 @@ V4LInput::OpenSource(const char *filename)
|
||||
fmt.fmt.sdr.pixelformat = pixelformat;
|
||||
xioctl(fd, VIDIOC_S_FMT, &fmt);
|
||||
if (fmt.fmt.sdr.pixelformat != pixelformat) {
|
||||
printf("Libv4l didn't accept FLOAT format. Cannot proceed. Pixelformat %4.4s\n",
|
||||
qCritical("Libv4l didn't accept FLOAT format. Cannot proceed. Pixelformat %4.4s\n",
|
||||
(char *)&fmt.fmt.sdr.pixelformat);
|
||||
}
|
||||
|
||||
@ -211,9 +219,7 @@ V4LInput::set_tuner_gain(double gain)
|
||||
}
|
||||
|
||||
int
|
||||
V4LInput::work(int noutput_items,
|
||||
void* input_items,
|
||||
void* output_items)
|
||||
V4LInput::work(int noutput_items, int16_t* output_items)
|
||||
{
|
||||
//complex *out = (complex *) output_items;
|
||||
int ret;
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Antti Palosaari <crope@iki.fi>
|
||||
*
|
||||
* This 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.
|
||||
*
|
||||
* This software 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_KERNEL_LIBV4L2_X_IMPL_H
|
||||
#define INCLUDED_KERNEL_LIBV4L2_X_IMPL_H
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <uapi/linux/videodev2.h>
|
||||
#include "/usr/local/include/libv4l2.h"
|
||||
#include "fcntl.h"
|
||||
#include <sys/mman.h>
|
||||
|
||||
struct v4l_buffer {
|
||||
void *start;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
|
||||
#endif /* INCLUDED_KERNEL_LIBV4L2_X_IMPL_H */
|
||||
|
@ -27,10 +27,9 @@ V4LThread::V4LThread(SampleFifo* sampleFifo, QObject* parent) :
|
||||
m_running(false),
|
||||
m_dev(1),
|
||||
m_convertBuffer(BLOCKSIZE),
|
||||
m_sampleFifo(sampleFifo),
|
||||
m_decimation(2)
|
||||
m_sampleFifo(sampleFifo)
|
||||
{
|
||||
m_localdecimation = 0;
|
||||
m_samplerate = 2500000;
|
||||
}
|
||||
|
||||
V4LThread::~V4LThread()
|
||||
@ -53,9 +52,9 @@ void V4LThread::stopWork()
|
||||
wait();
|
||||
}
|
||||
|
||||
void V4LThread::setDecimation(int decimation)
|
||||
void V4LThread::setSamplerate(int samplerate)
|
||||
{
|
||||
m_decimation = decimation;
|
||||
m_samplerate = samplerate;
|
||||
}
|
||||
|
||||
void V4LThread::run()
|
||||
@ -140,12 +139,8 @@ void V4LThread::callback(const quint8* buf, qint32 len)
|
||||
{
|
||||
qint16 xreal, yimag, phase;
|
||||
SampleVector::iterator it = m_convertBuffer.begin();
|
||||
int decimationFactor[] = {1, 1, 1, 2, 4, 0};
|
||||
|
||||
if (++m_localdecimation < decimationFactor[m_decimation]) return;
|
||||
m_localdecimation = 0;
|
||||
|
||||
switch(4 - m_decimation) {
|
||||
switch(4) {
|
||||
case 0: // 1:1 = no decimation
|
||||
// just rotation
|
||||
phase = -(1<<2);
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
void startWork();
|
||||
void stopWork();
|
||||
|
||||
void setDecimation(int decimation);
|
||||
void setSamplerate(int samplerate);
|
||||
|
||||
private:
|
||||
QMutex m_startWaitMutex;
|
||||
@ -44,9 +44,7 @@ private:
|
||||
int m_dev;
|
||||
SampleVector m_convertBuffer;
|
||||
SampleFifo* m_sampleFifo;
|
||||
|
||||
int m_decimation;
|
||||
int m_localdecimation;
|
||||
int m_samplerate;
|
||||
|
||||
void run();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user