diff options
author | Adrian Knoth <adi@drcomp.erfurt.thur.de> | 2013-05-31 14:57:10 +0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-05-31 17:05:41 +0400 |
commit | a8a729fa06164889da4cacaecebe48370329716b (patch) | |
tree | 1cb87b544f5441099535dcd51597982e579f49f9 /sound/pci/rme9652/hdspm.c | |
parent | a8cd7148045bd6a14adb15985dda806d17e9cab2 (diff) | |
download | linux-a8a729fa06164889da4cacaecebe48370329716b.tar.xz |
ALSA: hdspm - Refactor SS/DS/QS clock multiplier into function
When the DoubleSpeed or QuadSpeed bit is set, the SingleSpeed frequency
has to be multiplied accordingly. Since this functionality will be
required at least twice, refactor it into a separate function.
The second reference to the newly introduced hdspm_rate_multiplier()
will be in a separate commit.
Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/rme9652/hdspm.c')
-rw-r--r-- | sound/pci/rme9652/hdspm.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index e070ea85c30a..8eb2070fd258 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -1091,6 +1091,26 @@ static int hdspm_round_frequency(int rate) return 48000; } +/* QS and DS rates normally can not be detected + * automatically by the card. Only exception is MADI + * in 96k frame mode. + * + * So if we read SS values (32 .. 48k), check for + * user-provided DS/QS bits in the control register + * and multiply the base frequency accordingly. + */ +static int hdspm_rate_multiplier(struct hdspm *hdspm, int rate) +{ + if (rate <= 48000) { + if (hdspm->control_register & HDSPM_QuadSpeed) + return rate * 4; + else if (hdspm->control_register & + HDSPM_DoubleSpeed) + return rate * 2; + }; + return rate; +} + static int hdspm_tco_sync_check(struct hdspm *hdspm); static int hdspm_sync_in_sync_check(struct hdspm *hdspm); @@ -1268,21 +1288,8 @@ static int hdspm_external_sample_rate(struct hdspm *hdspm) } } - /* QS and DS rates normally can not be detected - * automatically by the card. Only exception is MADI - * in 96k frame mode. - * - * So if we read SS values (32 .. 48k), check for - * user-provided DS/QS bits in the control register - * and multiply the base frequency accordingly. - */ - if (rate <= 48000) { - if (hdspm->control_register & HDSPM_QuadSpeed) - rate *= 4; - else if (hdspm->control_register & - HDSPM_DoubleSpeed) - rate *= 2; - } + rate = hdspm_rate_multiplier(hdspm, rate); + break; } |