public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: intel8x0: Add clock quirk entry for AD1981B on IBM ThinkPad X41.
@ 2016-03-13 21:19 Vittorio Gambaletta (VittGam)
  2016-03-14  7:30 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Vittorio Gambaletta (VittGam) @ 2016-03-13 21:19 UTC (permalink / raw)
  To: linux-sound, alsa-devel; +Cc: stable, Jaroslav Kysela, Takashi Iwai

The clock measurement on the AC'97 audio card found in the IBM ThinkPad X41
will often fail, so add a quirk entry to fix it.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?idD1087
Cc: <stable@vger.kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Vittorio Gambaletta <linuxbugs@vittgam.net>
---

When the clock measurement doesn't fail, the `pos` variable after line 2861
will be around 48367, but when it does fail it will be somewhere between
45000 and 47500. So the bus clock gets set between 48500 and 52000 (!),
resulting in faster audio for rates with final clocks below 48000, and
distorted audio for rates with final clocks above 48000.

The problem is always reproducible on kernel 4.4.5, but very rarely on 3.13.

This patch fixes the problem for my computer, and will also speed up module
loading a bit as said on Bugzilla, but I've got some questions regarding
other hardware...

Do we want to protect against overclock for all hardware, by never setting
the measured bus clock higher than 48000? Do we actually risk burning or
otherwise permanently ruining something here, or not? Does hardware clocked
above 48000 exist?

Also, is line 2874 actually correct? As `pos` gets higher, the bus clock gets
lower, and vice versa. Note that in this function the bus clock is always
48000 before it gets updated here; so the code first computes 48000 * 48000,
and then it divides the result by `pos`. It doesn't seem right to me... By the
way, the history of that line goes beyond Git (so before kernel 2.6.12-rc2).

--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -2879,6 +2879,7 @@
 
 static struct snd_pci_quirk intel8x0_clock_list[] = {
 	SND_PCI_QUIRK(0x0e11, 0x008a, "AD1885", 41000),
+	SND_PCI_QUIRK(0x1014, 0x0581, "AD1981B", 48000),
 	SND_PCI_QUIRK(0x1028, 0x00be, "AD1885", 44100),
 	SND_PCI_QUIRK(0x1028, 0x0177, "AD1980", 48000),
 	SND_PCI_QUIRK(0x1028, 0x01ad, "AD1981B", 48000),

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: intel8x0: Add clock quirk entry for AD1981B on IBM ThinkPad X41.
  2016-03-13 21:19 [PATCH] ALSA: intel8x0: Add clock quirk entry for AD1981B on IBM ThinkPad X41 Vittorio Gambaletta (VittGam)
@ 2016-03-14  7:30 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2016-03-14  7:30 UTC (permalink / raw)
  To: Vittorio Gambaletta (VittGam)
  Cc: linux-sound, alsa-devel, stable, Jaroslav Kysela

On Sun, 13 Mar 2016 22:19:34 +0100,
Vittorio Gambaletta (VittGam) wrote:
> 
> The clock measurement on the AC'97 audio card found in the IBM ThinkPad X41
> will often fail, so add a quirk entry to fix it.
> 
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?idD1087
> Cc: <stable@vger.kernel.org>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.de>
> Signed-off-by: Vittorio Gambaletta <linuxbugs@vittgam.net>
> ---
> 
> When the clock measurement doesn't fail, the `pos` variable after line 2861
> will be around 48367, but when it does fail it will be somewhere between
> 45000 and 47500. So the bus clock gets set between 48500 and 52000 (!),
> resulting in faster audio for rates with final clocks below 48000, and
> distorted audio for rates with final clocks above 48000.
> 
> The problem is always reproducible on kernel 4.4.5, but very rarely on 3.13.

Hrm, does this mean that the ktime() isn't accurate enough, or do we
sample too short time?  i.e. Is it improved if we enlarge the
measurement time?

> This patch fixes the problem for my computer, and will also speed up module
> loading a bit as said on Bugzilla, but I've got some questions regarding
> other hardware...
> 
> Do we want to protect against overclock for all hardware, by never setting
> the measured bus clock higher than 48000? Do we actually risk burning or
> otherwise permanently ruining something here, or not? Does hardware clocked
> above 48000 exist?
> 
> Also, is line 2874 actually correct? As `pos` gets higher, the bus clock gets
> lower, and vice versa. Note that in this function the bus clock is always
> 48000 before it gets updated here; so the code first computes 48000 * 48000,
> and then it divides the result by `pos`. It doesn't seem right to me... By the
> way, the history of that line goes beyond Git (so before kernel 2.6.12-rc2).

I don't remember of any machines with clock > 48k, so I guess the code
never hits on any real machines, and I'm not sure whether it's really
correct at a quick glance.

In anyway, I applied your patch now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-14  7:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-13 21:19 [PATCH] ALSA: intel8x0: Add clock quirk entry for AD1981B on IBM ThinkPad X41 Vittorio Gambaletta (VittGam)
2016-03-14  7:30 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox