From b047aa218b5ccfd37e216f09870d4786cccd1876 Mon Sep 17 00:00:00 2001 From: Maxim Sobolev Date: Tue, 30 Jul 2002 10:54:19 +0000 Subject: [PATCH] Add a quick check that device actually has sound capabilities. The problem is that some cards built around fm801 chip have the same device ID, only have radio tuner onboard, but no sound capabilities. Therefore, with such card inserted and `device pcm' in kernel the user has a big problem, as the fm801 driver effectively hangs the machine when trying to initialise nonexistent ac97 codecs (it does 500 retries with 1 second interval!). It would be better if MediaForte's engeneers were smart enough to put different device ID into such cards, but it isn't an option. MFC after: 2 weeks --- sys/dev/sound/pci/fm801.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/dev/sound/pci/fm801.c b/sys/dev/sound/pci/fm801.c index 639200a1a1f..1293687968e 100644 --- a/sys/dev/sound/pci/fm801.c +++ b/sys/dev/sound/pci/fm801.c @@ -223,7 +223,7 @@ fm801_rdcd(kobj_t obj, void *devinfo, int regno) } if (i >= TIMO) { printf("fm801 rdcd: write codec invalid\n"); - return 0; + return -1; } return fm801_rd(fm801,FM_CODEC_DATA,2); @@ -613,6 +613,13 @@ fm801_pci_attach(device_t dev) codec = AC97_CREATE(dev, fm801, fm801_ac97); if (codec == NULL) goto oops; + /* + * XXX: quick check that device actually has sound capabilities. + * The problem is that some cards built around fm801 chip only + * have radio tuner onboard, but no sound capabilities. + */ + if (fm801_rdcd(NULL, fm801, AC97_REG_POWER) == -1) goto oops; + if (mixer_init(dev, ac97_getmixerclass(), codec) == -1) goto oops; fm801->irqid = 0;