Hello!
I have noticed, that fm801.c calculates wrong timeout for some of its
timeout values.
This is actual line from fm801.c source:
timeout = jiffies + (4 * HZ) / 3; /* 75ms */
Actually, this timeouts after 1.33 second!! If HZ = 100, then every
jiffie takes 10ms. Proper timeout would be:
timeout = jiffies + 0.075 * HZ ----> jiffies + 7 (better, 8)
Because of this, I would suggest new macro called for example snd_mwait,
defined as:
snd_mwait(x) (((int)(x) * HZ + 999) / 1000) /* x[ms] */
Timeouts would then be written as:
timeout = jiffies + snd_mwait(75);
Because of low HZ resolution, wait times are limited to n*10ms, when HZ
is defined as 100. There are problems for wait times lower than 100ms:
if somebody wants to timeout at 75ms (as it is in our example), then he
means "not sooner than 75ms". That is, why we round to the ceiling,
except for n*10ms wait times, which usualy mean exact times.
(And, we don't want floating-point instructions for any input parameter,
that is what (int) is doing in macro)
More examples:
HZ = 100:
mwait(1) = 1
mwait(70) = 7
mwait(75) = 8
mwait(100) = 10
HZ = 1000:
mwait(1) = 1
mwait(70) = 70
mwait(75) = 75
mwait(100) = 100
HZ = 20
mwait(1) = 1
mwait(70) = 2
mwait(75) = 2
mwait(100) = 2 (exact)
mwait(101) = 3
This macro would allow us to change code like
timeout = 3 * (HZ >> 2);
timeout = HZ / 10;
...
to
timeout = snd_mwait(750);
timeout = snd_mwait(100);
...
Uros.
_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel