mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-05 16:32:25 -04:00
Basic MSI support.
This commit is contained in:
parent
bce4aff21d
commit
95fe79650c
@ -122,7 +122,8 @@ const QString& V4LInput::getDeviceDescription() const
|
|||||||
|
|
||||||
int V4LInput::getSampleRate() const
|
int V4LInput::getSampleRate() const
|
||||||
{
|
{
|
||||||
int result = SAMPLERATE / 4;
|
// The output rate is lower than the device rate
|
||||||
|
int result = SAMPLERATE / 2;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,8 +154,7 @@ void V4LInput::applySettings(const GeneralSettings& generalSettings, const Setti
|
|||||||
}
|
}
|
||||||
|
|
||||||
if((m_generalSettings.m_centerFrequency != generalSettings.m_centerFrequency) || force) {
|
if((m_generalSettings.m_centerFrequency != generalSettings.m_centerFrequency) || force) {
|
||||||
m_V4LThread->set_center_freq( (double)(generalSettings.m_centerFrequency
|
m_V4LThread->set_center_freq( (double)generalSettings.m_centerFrequency );
|
||||||
+ (SAMPLERATE / 4) ));
|
|
||||||
}
|
}
|
||||||
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
|
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#define V4L2_PIX_FMT_SDR_U8 v4l2_fourcc('C', 'U', '0', '8') /* unsigned 8-bit Complex*/
|
#define V4L2_PIX_FMT_SDR_U8 v4l2_fourcc('C', 'U', '0', '8') /* unsigned 8-bit Complex*/
|
||||||
#define V4L2_PIX_FMT_SDR_U16LE v4l2_fourcc('C', 'U', '1', '6') /* unsigned 16-bit Complex*/
|
#define V4L2_PIX_FMT_SDR_U16LE v4l2_fourcc('C', 'U', '1', '6') /* unsigned 16-bit Complex*/
|
||||||
|
#define V4L2_PIX_FMT_SDR_CS14LE v4l2_fourcc('C', 'S', '1', '4') /* signed 14-bit Complex*/
|
||||||
|
|
||||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
||||||
|
|
||||||
@ -78,9 +79,8 @@ V4LThread::OpenSource(const char *filename)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixelformat = V4L2_PIX_FMT_SDR_U8;
|
pixelformat = V4L2_PIX_FMT_SDR_CS14LE;
|
||||||
// RTLSDR has limited ioctls in 3.18, expect fail.
|
qCritical("Want Pixelformat : S14");
|
||||||
qCritical("Want Pixelformat : CU08");
|
|
||||||
CLEAR(fmt);
|
CLEAR(fmt);
|
||||||
fmt.type = V4L2_BUF_TYPE_SDR_CAPTURE;
|
fmt.type = V4L2_BUF_TYPE_SDR_CAPTURE;
|
||||||
fmt.fmt.sdr.pixelformat = pixelformat;
|
fmt.fmt.sdr.pixelformat = pixelformat;
|
||||||
@ -120,7 +120,7 @@ V4LThread::OpenSource(const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_sample_rate((double)SAMPLERATE);
|
set_sample_rate((double)SAMPLERATE);
|
||||||
set_center_freq( centerFreq + (SAMPLERATE / 4) );
|
set_center_freq( (double)centerFreq );
|
||||||
// start streaming
|
// start streaming
|
||||||
type = V4L2_BUF_TYPE_SDR_CAPTURE;
|
type = V4L2_BUF_TYPE_SDR_CAPTURE;
|
||||||
xioctl(fd, VIDIOC_STREAMON, &type);
|
xioctl(fd, VIDIOC_STREAMON, &type);
|
||||||
@ -151,7 +151,7 @@ V4LThread::set_sample_rate(double samp_rate)
|
|||||||
memset (&frequency, 0, sizeof(frequency));
|
memset (&frequency, 0, sizeof(frequency));
|
||||||
frequency.tuner = 0;
|
frequency.tuner = 0;
|
||||||
frequency.type = V4L2_TUNER_ADC;
|
frequency.type = V4L2_TUNER_ADC;
|
||||||
frequency.frequency = samp_rate / 1;
|
frequency.frequency = samp_rate;
|
||||||
|
|
||||||
xioctl(fd, VIDIOC_S_FREQUENCY, &frequency);
|
xioctl(fd, VIDIOC_S_FREQUENCY, &frequency);
|
||||||
|
|
||||||
@ -225,33 +225,36 @@ V4LThread::work(int noutput_items)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct v4l2_buffer buf;
|
struct v4l2_buffer buf;
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
qint16 xreal, yimag;
|
int xreal, yimag;
|
||||||
uint8_t* b;
|
uint16_t* b;
|
||||||
SampleVector::iterator it;
|
SampleVector::iterator it;
|
||||||
|
|
||||||
unsigned int pos = 0;
|
unsigned int pos = 0;
|
||||||
// in is 4*8bit*2(IQ), 8 bytes; out is 1*16bit*2(IQ) , 4bytes
|
// MSI format is 252 sample pairs : 63 * 4
|
||||||
it = m_convertBuffer.begin();
|
it = m_convertBuffer.begin();
|
||||||
if (recebuf_len > 0) {
|
if (recebuf_len >= 8) { // in bytes
|
||||||
b = (uint8_t *) recebuf_ptr;
|
b = (uint16_t *) recebuf_ptr;
|
||||||
unsigned int len = noutput_items * 8;
|
unsigned int len = 4 * noutput_items; // decimation (i+q * 2 : cmplx)
|
||||||
if (len > recebuf_len)
|
if (len * 2 > recebuf_len)
|
||||||
len = recebuf_len;
|
len = recebuf_len / 2;
|
||||||
for (pos = 0; pos < len - 7; pos += 8) {
|
// Decimate by two for lower cpu usage
|
||||||
xreal = b[pos+0] - b[pos+3] + b[pos+7] - b[pos+4];
|
for (pos = 0; pos < len - 3; pos += 4) {
|
||||||
yimag = b[pos+1] - b[pos+5] + b[pos+2] - b[pos+6];
|
xreal = (qint16)(b[pos+0]<<2) + (qint16)(b[pos+2]<<2);
|
||||||
Sample s( xreal << 3, yimag << 3 );
|
// + (qint16)(b[pos+4]<<2) + (qint16)(b[pos+6]<<2);
|
||||||
|
yimag = (qint16)(b[pos+1]<<2) + (qint16)(b[pos+3]<<2);
|
||||||
|
// + (int)(b[pos+5]<<2) + (int)(b[pos+7]<<2);
|
||||||
|
Sample s( (qint16)(xreal >> 2) , (qint16)(yimag>>2) );
|
||||||
*it = s;
|
*it = s;
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
m_sampleFifo->write(m_convertBuffer.begin(), it);
|
m_sampleFifo->write(m_convertBuffer.begin(), it);
|
||||||
recebuf_len -= pos;
|
recebuf_len -= pos * 2; // size of int16
|
||||||
recebuf_ptr = (void*)(b + pos);
|
recebuf_ptr = (void*)(b + pos);
|
||||||
}
|
}
|
||||||
// return now if there is still data in buffer, else free buffer and get another.
|
// return now if there is still data in buffer, else free buffer and get another.
|
||||||
if (recebuf_len >= 8)
|
if (recebuf_len >= 8)
|
||||||
return pos / 8;
|
return pos / 4;
|
||||||
{ // frre buffer, if there was one.
|
{ // free buffer, if there was one.
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
CLEAR(buf);
|
CLEAR(buf);
|
||||||
buf.type = V4L2_BUF_TYPE_SDR_CAPTURE;
|
buf.type = V4L2_BUF_TYPE_SDR_CAPTURE;
|
||||||
@ -287,5 +290,5 @@ V4LThread::work(int noutput_items)
|
|||||||
recebuf_len = buf.bytesused;
|
recebuf_len = buf.bytesused;
|
||||||
recebuf_mmap_index = buf.index;
|
recebuf_mmap_index = buf.index;
|
||||||
}
|
}
|
||||||
return pos / 8;
|
return pos / 4;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,9 @@
|
|||||||
#include "dsp/samplefifo.h"
|
#include "dsp/samplefifo.h"
|
||||||
#include "dsp/inthalfbandfilter.h"
|
#include "dsp/inthalfbandfilter.h"
|
||||||
|
|
||||||
#define SAMPLERATE 1024000
|
// lowest samplerate in the kernel is 1.2M, but this works better
|
||||||
#define BLOCKSIZE 4096
|
#define SAMPLERATE 1536000
|
||||||
|
#define BLOCKSIZE 8192
|
||||||
|
|
||||||
class V4LThread : public QThread {
|
class V4LThread : public QThread {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user