From: Takashi Iwai <tiwai@suse.de>
To: Gerd Knorr <kraxel@suse.de>
Cc: Clemens Ladisch <clemens@ladisch.de>,
Jaroslav Kysela <perex@suse.cz>,
Holger Waechtler <holger@qanu.de>,
dvb list <linux-dvb@linuxtv.org>,
alsa-devel@lists.sourceforge.net
Subject: Re: Problem with Avermedia 771
Date: Thu, 21 Oct 2004 14:11:44 +0200 [thread overview]
Message-ID: <s5hd5zcgtj3.wl@alsa2.suse.de> (raw)
In-Reply-To: <20041021114311.GA2190@bytesex>
[-- Attachment #1: Type: text/plain, Size: 646 bytes --]
At Thu, 21 Oct 2004 13:43:11 +0200,
Gerd Knorr wrote:
>
> > That's the reason why I suggested the second way in my earlier post:
> >
> > We prepare two pci_id tables, one for the whitelist and another for
> > the default ids. Only the former is exported.
> >
> > When the module option is given, the latter id is registered while
> > usually the fomer is used.
>
> Yep, that should make the correct ID list visible to hotplug ...
Ok, how about the attached patch?
We may have a certralized header file such as linux/bt_pci_id.h
containig the entries of known working boards so that this can be
included from different drivers...
Takashi
[-- Attachment #2: Type: text/plain, Size: 4903 bytes --]
Index: alsa-kernel/pci/bt87x.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/bt87x.c,v
retrieving revision 1.14
diff -u -r1.14 bt87x.c
--- alsa-kernel/pci/bt87x.c 29 Sep 2004 16:17:59 -0000 1.14
+++ alsa-kernel/pci/bt87x.c 21 Oct 2004 12:08:03 -0000
@@ -45,6 +45,7 @@
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
static int digital_rate[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 }; /* digital input rate */
+static int load_all; /* allow to load the non-whitelisted cards */
static int boot_devs;
module_param_array(index, int, boot_devs, 0444);
@@ -55,6 +56,8 @@
MODULE_PARM_DESC(enable, "Enable Bt87x soundcard");
module_param_array(digital_rate, int, boot_devs, 0444);
MODULE_PARM_DESC(digital_rate, "Digital input rate for Bt87x soundcard");
+module_param(load_all, bool, 0444);
+MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards");
#ifndef PCI_VENDOR_ID_BROOKTREE
@@ -738,13 +741,73 @@
return 0;
}
+#define BT_DEVICE(chip, subvend, subdev, rate) \
+ { .vendor = PCI_VENDOR_ID_BROOKTREE, \
+ .device = PCI_DEVICE_ID_BROOKTREE_##chip, \
+ .subvendor = subvend, .subdevice = subdev, \
+ .driver_data = rate }
+
+/* driver_data is the default digital_rate value for that device */
+static struct pci_device_id snd_bt87x_ids[] = {
+ BT_DEVICE(878, 0x0070, 0x13eb, 32000), /* Hauppauge WinTV series */
+ BT_DEVICE(879, 0x0070, 0x13eb, 32000), /* Hauppauge WinTV series */
+ BT_DEVICE(878, 0x0070, 0xff01, 44100), /* Viewcast Osprey 200 */
+ { }
+};
+MODULE_DEVICE_TABLE(pci, snd_bt87x_ids);
+
+/* cards known not to have audio
+ * (DVB cards use the audio function to transfer MPEG data) */
+static struct {
+ unsigned short subvendor, subdevice;
+} blacklist[] __devinitdata = {
+ {0x0071, 0x0101}, /* Nebula Electronics DigiTV */
+ {0x11bd, 0x0026}, /* Pinnacle PCTV SAT CI */
+ {0x1461, 0x0761}, /* AVermedia AverTV DVB-T */
+ {0x1461, 0x0771}, /* AVermedia DVB-T 771 */
+ {0x1822, 0x0001}, /* Twinhan VisionPlus DVB-T */
+ {0x270f, 0xfc00}, /* Chaintech Digitop DST-1000 DVB-S */
+};
+
+/* return the rate of the card, or a negative if it's blacklisted */
+static int
+__devinit snd_bt87x_detect_card(struct pci_dev *pci)
+{
+ int i;
+ const struct pci_device_id *supported;
+
+ supported = pci_match_device(snd_bt87x_ids, pci);
+ if (supported)
+ return supported->driver_data;
+
+ for (i = 0; i < ARRAY_SIZE(blacklist); ++i)
+ if (blacklist[i].subvendor == pci->subsystem_vendor &&
+ blacklist[i].subdevice == pci->subsystem_device) {
+ snd_printdd(KERN_INFO "card %#04x:%#04x has no audio\n",
+ pci->subsystem_vendor, pci->subsystem_device);
+ return -EBUSY;
+ }
+
+ snd_printk(KERN_INFO "unknown card %#04x:%#04x, using default rate 32000\n",
+ pci->subsystem_vendor, pci->subsystem_device);
+ snd_printk(KERN_DEBUG "please mail id, board name, and, "
+ "if it works, the correct digital_rate option to "
+ "<alsa-devel@lists.sf.net>\n");
+ return 32000; /* default rate */
+}
+
static int __devinit snd_bt87x_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
{
static int dev;
snd_card_t *card;
bt87x_t *chip;
- int err;
+ int err, rate;
+
+ rate = pci_id->driver_data;
+ if (! rate)
+ if ((rate = snd_bt87x_detect_card(pci)) <= 0)
+ return -ENODEV;
if (dev >= SNDRV_CARDS)
return -ENODEV;
@@ -764,7 +827,7 @@
if (digital_rate[dev] > 0)
chip->dig_rate = digital_rate[dev];
else
- chip->dig_rate = (int)pci_id->driver_data;
+ chip->dig_rate = rate;
err = snd_bt87x_pcm(chip, DEVICE_DIGITAL, "Bt87x Digital");
if (err < 0)
@@ -808,22 +871,13 @@
pci_set_drvdata(pci, NULL);
}
-#define BT_DEVICE(chip, subvend, subdev, rate) \
- { .vendor = PCI_VENDOR_ID_BROOKTREE, \
- .device = PCI_DEVICE_ID_BROOKTREE_##chip, \
- .subvendor = subvend, .subdevice = subdev, \
- .driver_data = rate }
-
-/* driver_data is the default digital_rate value for that device */
-static struct pci_device_id snd_bt87x_ids[] = {
- BT_DEVICE(878, 0x0070, 0xff01, 44100), /* Osprey 200 */
-
- /* default entries for 32kHz and generic Bt87x cards */
- BT_DEVICE(878, PCI_ANY_ID, PCI_ANY_ID, 32000),
- BT_DEVICE(879, PCI_ANY_ID, PCI_ANY_ID, 32000),
+/* default entries for 32kHz and generic Bt87x cards - it's not exported */
+/* driver_data is set to 0 to call detection */
+static struct pci_device_id snd_bt87x_default_ids[] = {
+ BT_DEVICE(878, PCI_ANY_ID, PCI_ANY_ID, 0),
+ BT_DEVICE(879, PCI_ANY_ID, PCI_ANY_ID, 0),
{ }
};
-MODULE_DEVICE_TABLE(pci, snd_bt87x_ids);
static struct pci_driver driver = {
.name = "Bt87x",
@@ -834,6 +888,8 @@
static int __init alsa_card_bt87x_init(void)
{
+ if (load_all)
+ driver.id_table = snd_bt87x_default_ids;
return pci_module_init(&driver);
}
next prev parent reply other threads:[~2004-10-21 12:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <416ED29A.7060200@qanu.de>
2004-10-15 10:11 ` Problem with Avermedia 771 Gerd Knorr
2004-10-15 11:03 ` Jaroslav Kysela
2004-10-15 11:58 ` [Alsa-devel] " Holger Waechtler
2004-10-18 13:01 ` Gerd Knorr
2004-10-18 14:50 ` Takashi Iwai
2004-10-19 16:13 ` Gerd Knorr
2004-10-20 13:06 ` Takashi Iwai
2004-10-20 13:17 ` Takashi Iwai
2004-10-20 15:02 ` Clemens Ladisch
2004-10-20 15:20 ` Takashi Iwai
2004-10-21 7:22 ` Clemens Ladisch
2004-10-21 8:59 ` [Alsa-devel] " Gerd Knorr
2004-10-21 10:05 ` Takashi Iwai
2004-10-21 10:18 ` Gerd Knorr
2004-10-21 10:38 ` Takashi Iwai
2004-10-21 11:43 ` Gerd Knorr
2004-10-21 12:11 ` Takashi Iwai [this message]
2004-10-21 16:36 ` Takashi Iwai
2004-10-25 9:36 ` Clemens Ladisch
2004-10-20 15:27 ` Gerd Knorr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hd5zcgtj3.wl@alsa2.suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@lists.sourceforge.net \
--cc=clemens@ladisch.de \
--cc=holger@qanu.de \
--cc=kraxel@suse.de \
--cc=linux-dvb@linuxtv.org \
--cc=perex@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.