Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] airspy: enhance sample rate debug calculation precision

Sample rate calculation gives a little bit too large results because
in real life there was around one milliseconds (~one usb packet) too
much data for given time. Calculate time more accurate in order to
provide better results.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Antti Palosaari and committed by
Mauro Carvalho Chehab
b8843c79 8880f2cb

+6 -4
+6 -4
drivers/media/usb/airspy/airspy.c
··· 250 250 dst_len = 0; 251 251 } 252 252 253 - /* calculate samping rate and output it in 10 seconds intervals */ 253 + /* calculate sample rate and output it in 10 seconds intervals */ 254 254 if (unlikely(time_is_before_jiffies(s->jiffies_next))) { 255 255 #define MSECS 10000UL 256 + unsigned int msecs = jiffies_to_msecs(jiffies - 257 + s->jiffies_next + msecs_to_jiffies(MSECS)); 256 258 unsigned int samples = s->sample - s->sample_measured; 257 259 258 260 s->jiffies_next = jiffies + msecs_to_jiffies(MSECS); 259 261 s->sample_measured = s->sample; 260 - dev_dbg(s->dev, "slen=%d samples=%u msecs=%lu sample rate=%lu\n", 261 - src_len, samples, MSECS, 262 - samples * 1000UL / MSECS); 262 + dev_dbg(s->dev, "slen=%u samples=%u msecs=%u sample rate=%lu\n", 263 + src_len, samples, msecs, 264 + samples * 1000UL / msecs); 263 265 } 264 266 265 267 /* total number of samples */