aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/rme9652
diff options
context:
space:
mode:
authorAdrian Knoth <adi@drcomp.erfurt.thur.de>2011-08-14 18:22:53 -0400
committerTakashi Iwai <tiwai@suse.de>2011-08-15 04:25:32 -0400
commit7cb155ff3e4645188c42d707300e36cfce44e28a (patch)
treec31abbd9c8809bc93498856ed05409ae1a6c164e /sound/pci/rme9652
parent1ad5972f71f94d8a8b5b683dd5f81a52a4ddf54c (diff)
ALSA: hdspm - Introduce hdspm_get_latency() to harmonize latency calculation
Currently, hdspm_decode_latency is called several times, violating the DRY principle. Given that we need to distinguish between old and new cards when decoding the latency bits in the control register, introduce hdspm_get_latency() to provide the required functionality. Signed-off-by: Adrian Knoth <adi@drcomp.erfurt.thur.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/rme9652')
-rw-r--r--sound/pci/rme9652/hdspm.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 159133a14464..1a52a1ae1f4c 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -1241,10 +1241,30 @@ static int hdspm_external_sample_rate(struct hdspm *hdspm)
1241 return rate; 1241 return rate;
1242} 1242}
1243 1243
1244/* return latency in samples per period */
1245static int hdspm_get_latency(struct hdspm *hdspm)
1246{
1247 int n;
1248
1249 n = hdspm_decode_latency(hdspm->control_register);
1250
1251 /* Special case for new RME cards with 32 samples period size.
1252 * The three latency bits in the control register
1253 * (HDSP_LatencyMask) encode latency values of 64 samples as
1254 * 0, 128 samples as 1 ... 4096 samples as 6. For old cards, 7
1255 * denotes 8192 samples, but on new cards like RayDAT or AIO,
1256 * it corresponds to 32 samples.
1257 */
1258 if ((7 == n) && (RayDAT == hdspm->io_type || AIO == hdspm->io_type))
1259 n = -1;
1260
1261 return 1 << (n + 6);
1262}
1263
1244/* Latency function */ 1264/* Latency function */
1245static inline void hdspm_compute_period_size(struct hdspm *hdspm) 1265static inline void hdspm_compute_period_size(struct hdspm *hdspm)
1246{ 1266{
1247 hdspm->period_bytes = 1 << ((hdspm_decode_latency(hdspm->control_register) + 8)); 1267 hdspm->period_bytes = 4 * hdspm_get_latency(hdspm);
1248} 1268}
1249 1269
1250 1270
@@ -4801,8 +4821,7 @@ snd_hdspm_proc_read_madi(struct snd_info_entry * entry,
4801 4821
4802 snd_iprintf(buffer, "--- Settings ---\n"); 4822 snd_iprintf(buffer, "--- Settings ---\n");
4803 4823
4804 x = 1 << (6 + hdspm_decode_latency(hdspm->control_register & 4824 x = hdspm_get_latency(hdspm);
4805 HDSPM_LatencyMask));
4806 4825
4807 snd_iprintf(buffer, 4826 snd_iprintf(buffer,
4808 "Size (Latency): %d samples (2 periods of %lu bytes)\n", 4827 "Size (Latency): %d samples (2 periods of %lu bytes)\n",
@@ -4965,8 +4984,7 @@ snd_hdspm_proc_read_aes32(struct snd_info_entry * entry,
4965 4984
4966 snd_iprintf(buffer, "--- Settings ---\n"); 4985 snd_iprintf(buffer, "--- Settings ---\n");
4967 4986
4968 x = 1 << (6 + hdspm_decode_latency(hdspm->control_register & 4987 x = hdspm_get_latency(hdspm);
4969 HDSPM_LatencyMask));
4970 4988
4971 snd_iprintf(buffer, 4989 snd_iprintf(buffer,
4972 "Size (Latency): %d samples (2 periods of %lu bytes)\n", 4990 "Size (Latency): %d samples (2 periods of %lu bytes)\n",