diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-06-08 12:10:32 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-06-08 12:10:32 -0400 |
commit | 9470195a9cd13e6d90221b8b5d897e9232da8d28 (patch) | |
tree | 12f57a49fe94310396f7108c267560c74189c0e0 /sound/pci/ctxfi/ctatc.c | |
parent | d362af62ed98f58c64a2b3dd58c79d25ad181b0b (diff) |
ALSA: ctxfi - Clean up probe routines
Clean up probe routines and model detection routines so that the driver
won't call and check the PCI subsystem id at each time.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/ctxfi/ctatc.c')
-rw-r--r-- | sound/pci/ctxfi/ctatc.c | 132 |
1 files changed, 59 insertions, 73 deletions
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 7898a375df0e..002a70e0b13a 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c | |||
@@ -39,29 +39,40 @@ | |||
39 | | (0x10 << 16) \ | 39 | | (0x10 << 16) \ |
40 | | ((IEC958_AES3_CON_FS_48000) << 24)) | 40 | | ((IEC958_AES3_CON_FS_48000) << 24)) |
41 | 41 | ||
42 | static const struct ct_atc_chip_sub_details atc_sub_details[NUM_CTCARDS] = { | 42 | static struct snd_pci_quirk __devinitdata subsys_20k1_list[] = { |
43 | [CTSB0760] = {.subsys = PCI_SUBDEVICE_ID_CREATIVE_SB0760, | 43 | SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, 0x0022, "SB055x", CTSB055X), |
44 | .nm_model = "SB076x"}, | 44 | SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, 0x002f, "SB055x", CTSB055X), |
45 | [CTHENDRIX] = {.subsys = PCI_SUBDEVICE_ID_CREATIVE_HENDRIX, | 45 | SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, 0x0029, "SB073x", CTSB073X), |
46 | .nm_model = "Hendrix"}, | 46 | SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, 0x0031, "SB073x", CTSB073X), |
47 | [CTSB08801] = {.subsys = PCI_SUBDEVICE_ID_CREATIVE_SB08801, | 47 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_CREATIVE, 0x6000, |
48 | .nm_model = "SB0880"}, | 48 | PCI_SUBDEVICE_ID_CREATIVE_HENDRIX, "UAA", CTUAA), |
49 | [CTSB08802] = {.subsys = PCI_SUBDEVICE_ID_CREATIVE_SB08802, | 49 | SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_CREATIVE, |
50 | .nm_model = "SB0880"}, | 50 | "Unknown", CT20K1_UNKNOWN), |
51 | [CTSB08803] = {.subsys = PCI_SUBDEVICE_ID_CREATIVE_SB08803, | 51 | { } /* terminator */ |
52 | .nm_model = "SB0880"} | ||
53 | }; | 52 | }; |
54 | 53 | ||
55 | static struct ct_atc_chip_details atc_chip_details[] = { | 54 | static struct snd_pci_quirk __devinitdata subsys_20k2_list[] = { |
56 | {.vendor = PCI_VENDOR_ID_CREATIVE, | 55 | SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, PCI_SUBDEVICE_ID_CREATIVE_SB0760, |
57 | .device = PCI_DEVICE_ID_CREATIVE_20K1, | 56 | "SB0760", CTSB0760), |
58 | .sub_details = NULL, | 57 | SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, PCI_SUBDEVICE_ID_CREATIVE_SB08801, |
59 | .nm_card = "X-Fi 20k1"}, | 58 | "SB0880", CTSB0880), |
60 | {.vendor = PCI_VENDOR_ID_CREATIVE, | 59 | SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, PCI_SUBDEVICE_ID_CREATIVE_SB08802, |
61 | .device = PCI_DEVICE_ID_CREATIVE_20K2, | 60 | "SB0880", CTSB0880), |
62 | .sub_details = atc_sub_details, | 61 | SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, PCI_SUBDEVICE_ID_CREATIVE_SB08803, |
63 | .nm_card = "X-Fi 20k2"}, | 62 | "SB0880", CTSB0880), |
64 | {} /* terminator */ | 63 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_CREATIVE, 0x6000, |
64 | PCI_SUBDEVICE_ID_CREATIVE_HENDRIX, "UAA", CTHENDRIX), | ||
65 | { } /* terminator */ | ||
66 | }; | ||
67 | |||
68 | static const char *ct_subsys_name[NUM_CTCARDS] = { | ||
69 | [CTSB055X] = "SB055x", | ||
70 | [CTSB073X] = "SB073x", | ||
71 | [CTSB0760] = "SB076x", | ||
72 | [CTUAA] = "UAA", | ||
73 | [CT20K1_UNKNOWN] = "Unknown", | ||
74 | [CTHENDRIX] = "Hendrix", | ||
75 | [CTSB0880] = "SB0880", | ||
65 | }; | 76 | }; |
66 | 77 | ||
67 | static struct { | 78 | static struct { |
@@ -1208,62 +1219,39 @@ static int atc_dev_free(struct snd_device *dev) | |||
1208 | 1219 | ||
1209 | static int __devinit atc_identify_card(struct ct_atc *atc) | 1220 | static int __devinit atc_identify_card(struct ct_atc *atc) |
1210 | { | 1221 | { |
1211 | u16 subsys; | 1222 | const struct snd_pci_quirk *p; |
1212 | u8 revision; | 1223 | const struct snd_pci_quirk *list; |
1213 | struct pci_dev *pci = atc->pci; | ||
1214 | const struct ct_atc_chip_details *d; | ||
1215 | enum CTCARDS i; | ||
1216 | |||
1217 | subsys = pci->subsystem_device; | ||
1218 | revision = pci->revision; | ||
1219 | atc->chip_details = NULL; | ||
1220 | atc->model = NUM_CTCARDS; | ||
1221 | for (d = atc_chip_details; d->vendor; d++) { | ||
1222 | if (d->vendor != pci->vendor || d->device != pci->device) | ||
1223 | continue; | ||
1224 | 1224 | ||
1225 | if (NULL == d->sub_details) { | 1225 | switch (atc->chip_type) { |
1226 | atc->chip_details = d; | 1226 | case ATC20K1: |
1227 | break; | 1227 | atc->chip_name = "20K1"; |
1228 | } | 1228 | list = subsys_20k1_list; |
1229 | for (i = 0; i < NUM_CTCARDS; i++) { | 1229 | break; |
1230 | if ((d->sub_details[i].subsys == subsys) || | 1230 | case ATC20K2: |
1231 | (((subsys & 0x6000) == 0x6000) && | 1231 | atc->chip_name = "20K2"; |
1232 | ((d->sub_details[i].subsys & 0x6000) == 0x6000))) { | 1232 | list = subsys_20k2_list; |
1233 | atc->model = i; | ||
1234 | break; | ||
1235 | } | ||
1236 | } | ||
1237 | if (i >= NUM_CTCARDS) | ||
1238 | continue; | ||
1239 | |||
1240 | atc->chip_details = d; | ||
1241 | break; | 1233 | break; |
1242 | /* not take revision into consideration now */ | 1234 | default: |
1235 | return -ENOENT; | ||
1243 | } | 1236 | } |
1244 | if (!d->vendor) | 1237 | p = snd_pci_quirk_lookup(atc->pci, list); |
1238 | if (!p) | ||
1245 | return -ENOENT; | 1239 | return -ENOENT; |
1246 | 1240 | atc->model = p->value; | |
1241 | atc->model_name = ct_subsys_name[atc->model]; | ||
1242 | snd_printd("ctxfi: chip %s model %s (%04x:%04x) is found\n", | ||
1243 | atc->chip_name, atc->model_name, | ||
1244 | atc->pci->subsystem_vendor, | ||
1245 | atc->pci->subsystem_device); | ||
1247 | return 0; | 1246 | return 0; |
1248 | } | 1247 | } |
1249 | 1248 | ||
1250 | int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc) | 1249 | int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc) |
1251 | { | 1250 | { |
1252 | enum CTALSADEVS i; | 1251 | enum CTALSADEVS i; |
1253 | struct hw *hw = atc->hw; | ||
1254 | int err; | 1252 | int err; |
1255 | 1253 | ||
1256 | switch (hw->get_chip_type(hw)) { | 1254 | alsa_dev_funcs[MIXER].public_name = atc->chip_name; |
1257 | case ATC20K1: | ||
1258 | alsa_dev_funcs[MIXER].public_name = "20K1"; | ||
1259 | break; | ||
1260 | case ATC20K2: | ||
1261 | alsa_dev_funcs[MIXER].public_name = "20K2"; | ||
1262 | break; | ||
1263 | default: | ||
1264 | alsa_dev_funcs[MIXER].public_name = "Unknown"; | ||
1265 | break; | ||
1266 | } | ||
1267 | 1255 | ||
1268 | for (i = 0; i < NUM_CTALSADEVS; i++) { | 1256 | for (i = 0; i < NUM_CTALSADEVS; i++) { |
1269 | if (NULL == alsa_dev_funcs[i].create) | 1257 | if (NULL == alsa_dev_funcs[i].create) |
@@ -1287,7 +1275,7 @@ static int __devinit atc_create_hw_devs(struct ct_atc *atc) | |||
1287 | struct card_conf info = {0}; | 1275 | struct card_conf info = {0}; |
1288 | int i, err; | 1276 | int i, err; |
1289 | 1277 | ||
1290 | err = create_hw_obj(atc->pci, &hw); | 1278 | err = create_hw_obj(atc->pci, atc->chip_type, atc->model, &hw); |
1291 | if (err) { | 1279 | if (err) { |
1292 | printk(KERN_ERR "Failed to create hw obj!!!\n"); | 1280 | printk(KERN_ERR "Failed to create hw obj!!!\n"); |
1293 | return err; | 1281 | return err; |
@@ -1328,7 +1316,6 @@ static int __devinit atc_get_resources(struct ct_atc *atc) | |||
1328 | struct sum_desc sum_dsc = {0}; | 1316 | struct sum_desc sum_dsc = {0}; |
1329 | struct sum_mgr *sum_mgr; | 1317 | struct sum_mgr *sum_mgr; |
1330 | int err, i; | 1318 | int err, i; |
1331 | unsigned short subsys_id; | ||
1332 | 1319 | ||
1333 | atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL); | 1320 | atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL); |
1334 | if (NULL == atc->daios) | 1321 | if (NULL == atc->daios) |
@@ -1359,13 +1346,10 @@ static int __devinit atc_get_resources(struct ct_atc *atc) | |||
1359 | } | 1346 | } |
1360 | atc->n_daio++; | 1347 | atc->n_daio++; |
1361 | } | 1348 | } |
1362 | subsys_id = atc->pci->subsystem_device; | 1349 | if (atc->model == CTSB073X) |
1363 | if ((subsys_id == 0x0029) || (subsys_id == 0x0031)) { | ||
1364 | /* SB073x cards */ | ||
1365 | da_desc.type = SPDIFI1; | 1350 | da_desc.type = SPDIFI1; |
1366 | } else { | 1351 | else |
1367 | da_desc.type = SPDIFIO; | 1352 | da_desc.type = SPDIFIO; |
1368 | } | ||
1369 | err = daio_mgr->get_daio(daio_mgr, &da_desc, | 1353 | err = daio_mgr->get_daio(daio_mgr, &da_desc, |
1370 | (struct daio **)&atc->daios[i]); | 1354 | (struct daio **)&atc->daios[i]); |
1371 | if (err) { | 1355 | if (err) { |
@@ -1555,7 +1539,8 @@ static struct ct_atc atc_preset __devinitdata = { | |||
1555 | */ | 1539 | */ |
1556 | 1540 | ||
1557 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | 1541 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, |
1558 | unsigned int rsr, unsigned int msr, struct ct_atc **ratc) | 1542 | unsigned int rsr, unsigned int msr, |
1543 | int chip_type, struct ct_atc **ratc) | ||
1559 | { | 1544 | { |
1560 | struct ct_atc *atc; | 1545 | struct ct_atc *atc; |
1561 | static struct snd_device_ops ops = { | 1546 | static struct snd_device_ops ops = { |
@@ -1576,6 +1561,7 @@ int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | |||
1576 | atc->pci = pci; | 1561 | atc->pci = pci; |
1577 | atc->rsr = rsr; | 1562 | atc->rsr = rsr; |
1578 | atc->msr = msr; | 1563 | atc->msr = msr; |
1564 | atc->chip_type = chip_type; | ||
1579 | 1565 | ||
1580 | spin_lock_init(&atc->atc_lock); | 1566 | spin_lock_init(&atc->atc_lock); |
1581 | 1567 | ||