Commit ca533448 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen Committed by Takashi Iwai
Browse files

ALSA: emu10k1: fix timer for E-MU cards at 44.1 kHz word clock



The timer was presuming a fixed 48 kHz word clock, like the rest of the
code.

Signed-off-by: default avatarOswald Buddenhagen <oswald.buddenhagen@gmx.de>
Link: https://lore.kernel.org/r/20230612191325.1315854-8-oswald.buddenhagen@gmx.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 6cc84450
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -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;
	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,
};