diff mbox series

[7/9] ALSA: emu10k1: fix timer for E-MU cards at 44.1 kHz word clock

Message ID 20230612191325.1315854-8-oswald.buddenhagen@gmx.de
State Accepted
Commit ca533448a0936cd1c9f8e158af36f0657ed4d66e
Headers show
Series ALSA: emu10k1: improvements related to the switchable word clock of E-MU cards | expand

Commit Message

Oswald Buddenhagen June 12, 2023, 7:13 p.m. UTC
The timer was presuming a fixed 48 kHz word clock, like the rest of the
code.

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
---
 sound/pci/emu10k1/timer.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/sound/pci/emu10k1/timer.c b/sound/pci/emu10k1/timer.c
index 993663fef885..f3c78adf3248 100644
--- a/sound/pci/emu10k1/timer.c
+++ b/sound/pci/emu10k1/timer.c
@@ -38,20 +38,36 @@  static int snd_emu10k1_timer_stop(struct snd_timer *timer)
 	return 0;
 }
 
+static unsigned long snd_emu10k1_timer_c_resolution(struct snd_timer *timer)
+{
+	struct snd_emu10k1 *emu = snd_timer_chip(timer);
+
+	if (emu->card_capabilities->emu_model &&
+	    emu->emu1010.word_clock == 44100)
+		return 22676;  // 1 sample @ 44.1 kHz = 22.675736...us
+	else
+		return 20833;  // 1 sample @ 48 kHz = 20.833...us
+}
+
 static int snd_emu10k1_timer_precise_resolution(struct snd_timer *timer,
 					       unsigned long *num, unsigned long *den)
 {
+	struct snd_emu10k1 *emu = snd_timer_chip(timer);
+
 	*num = 1;
-	*den = 48000;
+	if (emu->card_capabilities->emu_model)
+		*den = emu->emu1010.word_clock;
+	else
+		*den = 48000;
 	return 0;
 }
 
 static const struct snd_timer_hardware snd_emu10k1_timer_hw = {
 	.flags = SNDRV_TIMER_HW_AUTO,
-	.resolution = 20833, /* 1 sample @ 48KHZ = 20.833...us */
 	.ticks = 1024,
 	.start = snd_emu10k1_timer_start,
 	.stop = snd_emu10k1_timer_stop,
+	.c_resolution = snd_emu10k1_timer_c_resolution,
 	.precise_resolution = snd_emu10k1_timer_precise_resolution,
 };