aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorAdrian Knoth <adi@drcomp.erfurt.thur.de>2013-03-09 18:37:21 -0500
committerTakashi Iwai <tiwai@suse.de>2013-03-11 04:57:22 -0400
commit3f7bf918bfa2f4b8aa461ae82249e3c187bbff81 (patch)
tree9dcbb2debec87560cdc5d11da2215e3ac58fb14d /sound/pci
parent93c9d8ae0b25ab7845b26813da1a326d2b1fea43 (diff)
ALSA: hdspm - Refactor sample rate acquisition
This commit introduces hdspm_get_pll_freq() to avoid code duplication. Reading the sample rate from the DDS register will be required by upcoming code. Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/rme9652/hdspm.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 223c3d9cc69e..50cba5ce54fe 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -969,6 +969,7 @@ static int snd_hdspm_create_pcm(struct snd_card *card,
969 struct hdspm *hdspm); 969 struct hdspm *hdspm);
970 970
971static inline void snd_hdspm_initialize_midi_flush(struct hdspm *hdspm); 971static inline void snd_hdspm_initialize_midi_flush(struct hdspm *hdspm);
972static inline int hdspm_get_pll_freq(struct hdspm *hdspm);
972static int hdspm_update_simple_mixer_controls(struct hdspm *hdspm); 973static int hdspm_update_simple_mixer_controls(struct hdspm *hdspm);
973static int hdspm_autosync_ref(struct hdspm *hdspm); 974static int hdspm_autosync_ref(struct hdspm *hdspm);
974static int snd_hdspm_set_defaults(struct hdspm *hdspm); 975static int snd_hdspm_set_defaults(struct hdspm *hdspm);
@@ -1979,16 +1980,25 @@ static void hdspm_midi_tasklet(unsigned long arg)
1979/* get the system sample rate which is set */ 1980/* get the system sample rate which is set */
1980 1981
1981 1982
1983static inline int hdspm_get_pll_freq(struct hdspm *hdspm)
1984{
1985 unsigned int period, rate;
1986
1987 period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ);
1988 rate = hdspm_calc_dds_value(hdspm, period);
1989
1990 return rate;
1991}
1992
1982/** 1993/**
1983 * Calculate the real sample rate from the 1994 * Calculate the real sample rate from the
1984 * current DDS value. 1995 * current DDS value.
1985 **/ 1996 **/
1986static int hdspm_get_system_sample_rate(struct hdspm *hdspm) 1997static int hdspm_get_system_sample_rate(struct hdspm *hdspm)
1987{ 1998{
1988 unsigned int period, rate; 1999 unsigned int rate;
1989 2000
1990 period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ); 2001 rate = hdspm_get_pll_freq(hdspm);
1991 rate = hdspm_calc_dds_value(hdspm, period);
1992 2002
1993 if (rate > 207000) { 2003 if (rate > 207000) {
1994 /* Unreasonable high sample rate as seen on PCI MADI cards. */ 2004 /* Unreasonable high sample rate as seen on PCI MADI cards. */