hb9fxq / gr-osmosdr-fork-sdrplay

GNU General Public License v3.0
2 stars 4 forks source link

Sample frequency is static 2048000? #1

Closed spaivaras closed 8 years ago

spaivaras commented 8 years ago

Hi, we talked a bit in youtube. So the problem is: If I set a wide IF bandwidth of > 1.536 MHz, and no matter what sampling rate (for example 7e6 Hz) SDRPlay just stops sending events to sdrplay_source_c::streamCallback

I did some debugging and one thing stood out for me:

This is initial call, everything seems ok, default values.

before stream init
Samples per packet: 0
mir_sdr_StreamInit()
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=50dB fs=2,048MHz rf=96,800MHz bw=1,536MHz if=0,000MHz
DownConvert: Enable=0 DecM=1 OutScale=0 (fs=2,048000 bw=1536 if=0)
mir_sdr_usb_USB DLL: Revision 0.1.1
mir_sdr_2500_Init: fnaddr = 15
mir_sdr_2500_Init: adjusting squelch trim 0x1, rx gating enable 1, tx_trim 0, reg2 = 0x4801
initHw: Register7 = 0x000005
initHw: Tuner Register0 = 0x04f420
mir_sdr_SetFs: Sample Freq requested 2047999,978065

Next call is to set_sample_rate

set_sample_rate start
rate = 7e+06
diff = 4.952e+06
reinit_device started
reinit_device started
mir_sdr_Reinit: 0x202b760
mir_sdr_2500_Readback001Trim: readback = 0xd1c020f
mir_sdr_2500_Bypass001Trim: reg13=0x1ed reg14=0x47002e
mir_sdr_SetLoMode() 1
mir_sdr_SetPpm() 0,000000
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=50dB fs=2,048MHz rf=96,800MHz bw=1,536MHz if=0,000MHz
DownConvert: Enable=0 DecM=1 OutScale=0 (fs=2,048000 bw=1536 if=0)
mir_sdr_usb_USB DLL: Revision 0.1.1
mir_sdr_2500_Init: fnaddr = 15
mir_sdr_2500_Init: adjusting squelch trim 0x1, rx gating enable 1, tx_trim 0, reg2 = 0x4801
initHw: Register7 = 0x000005
initHw: Tuner Register0 = 0x04f420
mir_sdr_SetFs: Sample Freq requested 2047999,978065
mir_sdr_SetFs: Fs->FsNomHz+dFsHz=2048000,0+0,0Hz=2048000,0Hz FsToggle->1
mir_sdr_SetRf: f->96800000,000Hz (int=20 frac=320 afc=0) fSynth:3097600000,000
mir_sdr_SetRf: Rf->RfNomHz+dRfHz+LifHz+Lif1Hz=96800000,0+0,0+0,0Hz+0,0Hz=96800000,0Hz RfToggle->1
mir_sdr_SetGr: GR->50[26,24,0,0] gRset->0x21A DCCALmode=4 DCCALspd=1 GrToggle->1
setToggleStates: initialising sampNum=0x0001f802, gainSetting=0x21a, FsToggle=1, RfToggle=0, GrToggle=1
setToggleStates: initialising Fs=2047999,978, Rf=96800000,000, Gr=50
mir_sdr_SetGrAltMode: in: 50 0 (0) 1 1 0
mir_sdr_SetGrAltMode: GR->50[50,24,0,0] gRset->0x232 DCCALmode=4 DCCALspd=1 GrToggle->0
mir_sdr_SetGrAltMode: out: 50 0 74 1 0
mir_sdr_DCoffsetIQimbalanceControl: DC:1 IQ:1
mir_sdr_SetDcMode: DCCAL: mode->4 speedup->1
mir_sdr_AgcControl: 0 0 0 0 0 0 0
mir_sdr_DecimateControl: 0 1 0
mir_sdr_DecimateControl: DecimateEnable=0, DecimateDecM=1, DecimateOutScale=0, DecimateRound[0]=0x00000000, DecimateRound[1]=0x00000000
REINIT - FSHZ: 336, samples: 0, ifType: 1536, bwType: 952493824
reinit_device end
set_sample_rate end

Even so sample rate is requested 7e6 it seems mir_sdr is still using 2.048Mhz one setToggleStates: initialising Fs=2047999,978, Rf=96800000,000, Gr=50

And the last call for increased IF bandwidth stops everything:

set_bandwidth
Bandwith: 5000
set_bandwidth running
reinit_device started
mir_sdr_Reinit: 0x0008
mir_sdr_2500_Readback001Trim: readback = 0xe3c2010
mir_sdr_2500_Bypass001Trim: reg13=0x20d reg14=0x6f020e
mir_sdr_SetLoMode() 1
mir_sdr_SetPpm() 0,000000
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=50dB fs=2,048MHz rf=104,700MHz bw=5,000MHz if=0,000MHz
DownConvert: Enable=0 DecM=1 OutScale=0 (fs=2,048000 bw=5000 if=0)
mir_sdr_Init: Fs=2048000Hz is too low for Lif=0, Bw=5000000 and DecM=1 - minimum required 5000000
REINIT - FSHZ: 336, samples: 0, ifType: 5000, bwType: 1
reinit_device end
INFO: Audio sink arch: alsa

The response is indicating that 2.048Mhz sampling is stuck with mir_sdr mir_sdr_Init: Fs=2048000Hz is too low for Lif=0, Bw=5000000 and DecM=1 - minimum required 5000000

I hope this brings more information to the problem, I will try to fiddle with this. If my knowledge will be enough, I will make a PR here

hb9fxq commented 8 years ago

ups, didn't wanted to close the issue... think I see what's wrong

spaivaras commented 8 years ago

It closed automatically, because I referenced it in my PR. In any case after adding the reason for reinit, now it works beautifully for me, sampling rates are set properly. Maybe some error handling could be added. For example if Sampling freq is less than IF bandwidth.

hb9fxq commented 8 years ago

You motivated me to continue with this today! I'll implement an argument to control the LNA and try to tweak the gain limits... guess tonight I'll do some commits.

spaivaras commented 8 years ago

Nice!! I just glued LNA control via additional gain slider in gqrx for my self, its not the way how it should be implemented, so nothing to share :) Thx for your work. As now i can fully enjoy SDRPlay under linux. If i will see some small fixes I can contribute, I will send some PR's your way. Cheers.