ALSA: emu10k1: fix timer for E-MU cards at 44.1 kHz word clock
authorOswald Buddenhagen <oswald.buddenhagen@gmx.de>
Mon, 12 Jun 2023 19:13:23 +0000 (21:13 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 13 Jun 2023 05:46:58 +0000 (07:46 +0200)
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>
Link: https://lore.kernel.org/r/20230612191325.1315854-8-oswald.buddenhagen@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/emu10k1/timer.c

index 993663f..f3c78ad 100644 (file)
@@ -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,
 };