diff --git a/plugins/samplesource/v4l-msi/v4lgui.cpp b/plugins/samplesource/v4l-msi/v4lgui.cpp index 802764536..e1f13b5b9 100644 --- a/plugins/samplesource/v4l-msi/v4lgui.cpp +++ b/plugins/samplesource/v4l-msi/v4lgui.cpp @@ -10,7 +10,7 @@ V4LGui::V4LGui(PluginAPI* pluginAPI, QWidget* parent) : m_sampleSource(NULL) { ui->setupUi(this); - ui->centerFrequency->setValueRange(7, 20000U, 2200000U); + ui->centerFrequency->setValueRange(7, 50000U, 1999000U); connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); displaySettings(); @@ -82,37 +82,15 @@ bool V4LGui::deserialize(const QByteArray& data) bool V4LGui::handleMessage(Message* message) { - if(V4LInput::MsgReportV4L::match(message)) { - m_gains = ((V4LInput::MsgReportV4L*)message)->getGains(); - displaySettings(); - message->completed(); - return true; - } else { - return false; - } + return false; } void V4LGui::displaySettings() { ui->centerFrequency->setValue(m_generalSettings.m_centerFrequency / 1000); - if(m_gains.size() > 0) { - int dist = abs(m_settings.m_gain - m_gains[0]); - int pos = 0; - for(uint i = 1; i < m_gains.size(); i++) { - if(abs(m_settings.m_gain - m_gains[i]) < dist) { - dist = abs(m_settings.m_gain - m_gains[i]); - pos = i; - } - } - ui->gainText->setText(tr("%1.%2").arg(m_gains[pos] / 10).arg(abs(m_gains[pos] % 10))); - ui->gain->setMaximum(m_gains.size() - 1); - ui->gain->setEnabled(true); - ui->gain->setValue(pos); - } else { - ui->gain->setMaximum(0); - ui->gain->setEnabled(false); - ui->gain->setValue(0); - } + ui->ifgain->setValue(1); + ui->checkBoxL->setChecked(m_settings.m_lna); + ui->checkBoxM->setChecked(m_settings.m_mix); } void V4LGui::sendSettings() @@ -127,12 +105,12 @@ void V4LGui::on_centerFrequency_changed(quint64 value) sendSettings(); } -void V4LGui::on_gain_valueChanged(int value) +void V4LGui::on_ifgain_valueChanged(int value) { - if(value > (int)m_gains.size()) + if(value > 8) return; - int gain = m_gains[value]; - ui->gainText->setText(tr("%1.%2").arg(gain / 10).arg(abs(gain % 10))); + int gain = value * 6; + ui->gainText->setText( tr("%1").arg(gain) ); m_settings.m_gain = gain; sendSettings(); } @@ -143,3 +121,21 @@ void V4LGui::updateHardware() message->submit(m_pluginAPI->getDSPEngineMessageQueue()); m_updateTimer.stop(); } + +void V4LGui::on_checkBoxL_stateChanged(int state) +{ + if (state == Qt::Checked) + m_settings.m_lna = 1; + else + m_settings.m_lna = 0; + sendSettings(); +} + +void V4LGui::on_checkBoxM_stateChanged(int state) +{ + if (state == Qt::Checked) + m_settings.m_mix = 1; + else + m_settings.m_mix = 0; + sendSettings(); +} diff --git a/plugins/samplesource/v4l-msi/v4lgui.h b/plugins/samplesource/v4l-msi/v4lgui.h index 448c97dee..c443ac424 100644 --- a/plugins/samplesource/v4l-msi/v4lgui.h +++ b/plugins/samplesource/v4l-msi/v4lgui.h @@ -44,7 +44,9 @@ private: private slots: void on_centerFrequency_changed(quint64 value); - void on_gain_valueChanged(int value); + void on_ifgain_valueChanged(int value); + void on_checkBoxL_stateChanged(int state); + void on_checkBoxM_stateChanged(int state); void updateHardware(); }; diff --git a/plugins/samplesource/v4l-msi/v4lgui.ui b/plugins/samplesource/v4l-msi/v4lgui.ui index 9254a4a50..6ecfdaa85 100644 --- a/plugins/samplesource/v4l-msi/v4lgui.ui +++ b/plugins/samplesource/v4l-msi/v4lgui.ui @@ -107,6 +107,24 @@ + + + + + + LNA AMP + + + + + + + Mix AMP + + + + + @@ -126,18 +144,12 @@ - - - false - + - LNA amplification + IF amplification - 0 - - - 1 + 8 Qt::Horizontal diff --git a/plugins/samplesource/v4l-msi/v4linput.cpp b/plugins/samplesource/v4l-msi/v4linput.cpp index 58c8894d1..57584b894 100644 --- a/plugins/samplesource/v4l-msi/v4linput.cpp +++ b/plugins/samplesource/v4l-msi/v4linput.cpp @@ -23,16 +23,19 @@ #include "util/simpleserializer.h" MESSAGE_CLASS_DEFINITION(V4LInput::MsgConfigureV4L, Message) -MESSAGE_CLASS_DEFINITION(V4LInput::MsgReportV4L, Message) V4LInput::Settings::Settings() : - m_gain(6) + m_gain(1), + m_lna(0), + m_mix(0) { } void V4LInput::Settings::resetToDefaults() { - m_gain = 6; + m_gain = 1; + m_lna = 0; + m_mix = 0; } QByteArray V4LInput::Settings::serialize() const @@ -53,7 +56,7 @@ bool V4LInput::Settings::deserialize(const QByteArray& data) } if(d.getVersion() == 1) { - d.readS32(1, &m_gain, 6); + d.readS32(1, &m_gain, 1); //d.readS32(2, &m_samplerate, 0); return true; } else { @@ -155,13 +158,19 @@ void V4LInput::applySettings(const GeneralSettings& generalSettings, const Setti if((m_generalSettings.m_centerFrequency != generalSettings.m_centerFrequency) || force) { m_V4LThread->set_center_freq( (double)generalSettings.m_centerFrequency ); + m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency; } - m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency; -#if 0 + if((m_settings.m_gain != settings.m_gain) || force) { m_settings.m_gain = settings.m_gain; m_V4LThread->set_tuner_gain((double)m_settings.m_gain); } -#endif + + if((m_settings.m_lna != settings.m_lna) || (m_settings.m_mix != settings.m_mix) || force) { + m_settings.m_lna = settings.m_lna; + m_settings.m_mix = settings.m_mix; + m_V4LThread->set_amps(1, m_settings.m_lna); + m_V4LThread->set_amps(0, m_settings.m_mix); + } } diff --git a/plugins/samplesource/v4l-msi/v4linput.h b/plugins/samplesource/v4l-msi/v4linput.h index 680d65c53..a56f2bf4c 100644 --- a/plugins/samplesource/v4l-msi/v4linput.h +++ b/plugins/samplesource/v4l-msi/v4linput.h @@ -31,7 +31,7 @@ class V4LThread; class V4LInput : public SampleSource { public: struct Settings { - qint32 m_gain; + qint32 m_gain, m_lna, m_mix; Settings(); void resetToDefaults(); @@ -62,26 +62,6 @@ public: { } }; - class MsgReportV4L : public Message { - MESSAGE_CLASS_DECLARATION - - public: - const std::vector& getGains() const { return m_gains; } - - static MsgReportV4L* create(const std::vector& gains) - { - return new MsgReportV4L(gains); - } - - protected: - std::vector m_gains; - - MsgReportV4L(const std::vector& gains) : - Message(), - m_gains(gains) - { } - }; - V4LInput(MessageQueue* msgQueueToGUI); ~V4LInput(); @@ -98,7 +78,6 @@ private: Settings m_settings; V4LThread* m_V4LThread; QString m_deviceDescription; - std::vector m_gains; void applySettings(const GeneralSettings& generalSettings, const Settings& settings, bool force); }; diff --git a/plugins/samplesource/v4l-msi/v4lplugin.cpp b/plugins/samplesource/v4l-msi/v4lplugin.cpp index 6525dbd39..1d9546075 100644 --- a/plugins/samplesource/v4l-msi/v4lplugin.cpp +++ b/plugins/samplesource/v4l-msi/v4lplugin.cpp @@ -6,9 +6,9 @@ #include "v4lgui.h" const PluginDescriptor V4LPlugin::m_pluginDescriptor = { - QString("V4L Input"), + QString("V4L SDRplay Input"), QString("4.0"), - QString("(c) 2014 John Greb"), + QString("(c) 2015 John Greb"), QString("http://palosaari.fi/linux/"), true, QString("github.com/hexameron/rtl-sdrangelove") diff --git a/plugins/samplesource/v4l-msi/v4lsource.cpp b/plugins/samplesource/v4l-msi/v4lsource.cpp index f3b6b896a..7e1b8fc31 100644 --- a/plugins/samplesource/v4l-msi/v4lsource.cpp +++ b/plugins/samplesource/v4l-msi/v4lsource.cpp @@ -146,10 +146,7 @@ V4LThread::set_sample_rate(double samp_rate) frequency.tuner = 0; frequency.type = V4L2_TUNER_ADC; frequency.frequency = samp_rate; - xioctl(fd, VIDIOC_S_FREQUENCY, &frequency); - - return; } // Cannot change freq while streaming @@ -164,10 +161,7 @@ V4LThread::set_center_freq(double freq) frequency.tuner = 1; frequency.type = V4L2_TUNER_RF; frequency.frequency = freq; - xioctl(fd, VIDIOC_S_FREQUENCY, &frequency); - - return; } void @@ -196,8 +190,6 @@ V4LThread::set_bandwidth(double bandwidth) ext_ctrls.count = 1; ext_ctrls.controls = &ext_ctrl; xioctl(fd, VIDIOC_S_EXT_CTRLS, &ext_ctrls); - - return; } void @@ -216,7 +208,29 @@ V4LThread::set_tuner_gain(double gain) ext_ctrls.count = 1; ext_ctrls.controls = &ext_ctrl; xioctl(fd, VIDIOC_S_EXT_CTRLS, &ext_ctrls); + } + + +void +V4LThread::set_amps(bool lna, bool on) + { + struct v4l2_ext_controls ext_ctrls; + struct v4l2_ext_control ext_ctrl; + + if (fd <= 0) return; + + memset (&ext_ctrl, 0, sizeof(ext_ctrl)); + memset (&ext_ctrls, 0, sizeof(ext_ctrls)); + if (lna) + ext_ctrl.id = CID_TUNER_LNA_GAIN; + else + ext_ctrl.id = CID_TUNER_MIXER_GAIN; + ext_ctrl.value = on; + ext_ctrls.ctrl_class = CID_CLASS_RF; + ext_ctrls.count = 1; + ext_ctrls.controls = &ext_ctrl; + xioctl(fd, VIDIOC_S_EXT_CTRLS, &ext_ctrls); } #define CASTUP (int)(qint16) diff --git a/plugins/samplesource/v4l-msi/v4lthread.h b/plugins/samplesource/v4l-msi/v4lthread.h index 746242b71..834e98460 100644 --- a/plugins/samplesource/v4l-msi/v4lthread.h +++ b/plugins/samplesource/v4l-msi/v4lthread.h @@ -43,6 +43,7 @@ public: void set_center_freq(double freq); void set_bandwidth(double bandwidth); void set_tuner_gain(double gain); + void set_amps(bool lna, bool on); int work(int n_items); private: int fd;