forked from sdr/rtl-sdr
1
0
Fork 0

fix: round gain input to nearest value

This commit is contained in:
Ethan Halsall 2023-03-12 12:55:14 -05:00 committed by Steve Markgraf
parent e04c42c019
commit d81ef9a9d9
1 changed files with 5 additions and 17 deletions

View File

@ -321,23 +321,11 @@ int fc0012_set_gain(void *dev, int gain)
/* mask bits off */
tmp &= 0xe0;
switch (gain) {
case -99: /* -9.9 dB */
tmp |= 0x02;
break;
case -40: /* -4 dB */
break;
case 71:
tmp |= 0x08; /* 7.1 dB */
break;
case 179:
tmp |= 0x17; /* 17.9 dB */
break;
case 192:
default:
tmp |= 0x10; /* 19.2 dB */
break;
}
if (gain < -40) tmp |= 0x02; /* -9.9 dB */
else if (gain < 71) tmp |= 0x00; /* -4.0 dB */
else if (gain < 179) tmp |= 0x08; /* 7.1 dB */
else if (gain < 192) tmp |= 0x17; /* 17.9 dB */
else tmp |= 0x10; /* 19.2 dB */
ret = fc0012_writereg(dev, 0x13, tmp);