Skip to contentSkip to conversation

maximum tolerable sampling frequency difference for a driver

DISCUSSION chri 3 participants 5 messages Nov 11, 2008 – Nov 12, 2008

lore
Share & tools
lore

chri

author
#0 lore raw

Let's say that the driver cannot set the exact sampling frequency asked via hwparms but something near (because of the granularity of the result of the clock division). What is the maximum difference that should be accepted (in Hz or in %)? I guess that there are 2 factors playing a role:

1) if the frequency is too different then the upper layers report a undeflow/overflow

2) the sound just doesn't sound good (just a bit too presto or too adagio)

So what difference should be accepted instead of returning -EINVAL?

Thanks,

Signature · 5 lines
Christian Pellegrin, see http://www.evolware.org/chri/
"Real Programmers don't play tennis, or any other sport which requires
you to change clothes. Mountain climbing is OK, and Real Programmers
wear their climbing boots to work in case a mountain should suddenly
spring up in the middle of the computer room."
#1 lore raw
Quoted 5 lines · chri

Let's say that the driver cannot set the exact sampling frequency asked via hwparms but something near (because of the granularity of the result of the clock division). What is the maximum difference that should be accepted (in Hz or in %)? I guess that there are 2 factors playing a role:

It's relatively application-specific - it'll depend on things like how accurate the clocks were in the first place and what the sound is being used for (system beeps are going to tolerate a lot more than something doing audiophile quality stuff).

Quoted 1 line

So what difference should be accepted instead of returning -EINVAL?

If this is for the Samsung boards you've been posting patches for then a few percent should be OK most of the time.

#2 lore raw
In reply to chri
Quoted 2 lines · chri

Let's say that the driver cannot set the exact sampling frequency asked via hwparms ...

This never happens.

The driver tells the ALSA framework what frequencies it supports, either by setting individual bits in the .rates field, or by installing a constraint by calling snd_pcm_hw_constraint_list() or some other of the constraint functions when the device is opened. ALSA then makes sure that the driver always gets values in hw_params that meet these constraints.

When an application requests a frequency that is not supported by the device, it is the application that must decide whether the actual frequency is acceptable.

HTH
Clemens

#3 lore raw
Quoted 3 lines · Clemens Ladisch

When an application requests a frequency that is not supported by the device, it is the application that must decide whether the actual frequency is acceptable.

In theory. In practice few applications have substantial tolerance for this and in many situations the cost of dealing with it (such as doing soft conversion) is worse than a small error.

#4 lore raw
Quoted 10 lines · Mark Brown
Quoted 3 lines · Clemens Ladisch

When an application requests a frequency that is not supported by the device, it is the application that must decide whether the actual frequency is acceptable.

In theory. In practice few applications have substantial tolerance for this and in many situations the cost of dealing with it (such as doing soft conversion) is worse than a small error.

I see, thank you both for the answer.

Signature · 5 lines
Christian Pellegrin, see http://www.evolware.org/chri/
"Real Programmers don't play tennis, or any other sport which requires
you to change clothes. Mountain climbing is OK, and Real Programmers
wear their climbing boots to work in case a mountain should suddenly
spring up in the middle of the computer room."