aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-06-08 12:10:32 -0400
committerTakashi Iwai <tiwai@suse.de>2009-06-08 12:10:32 -0400
commit9470195a9cd13e6d90221b8b5d897e9232da8d28 (patch)
tree12f57a49fe94310396f7108c267560c74189c0e0 /sound
parentd362af62ed98f58c64a2b3dd58c79d25ad181b0b (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')
-rw-r--r--sound/pci/ctxfi/ctatc.c132
-rw-r--r--sound/pci/ctxfi/ctatc.h17
-rw-r--r--sound/pci/ctxfi/ctdaio.c6
-rw-r--r--sound/pci/ctxfi/cthardware.c31
-rw-r--r--sound/pci/ctxfi/cthardware.h20
-rw-r--r--sound/pci/ctxfi/cthw20k1.c88
-rw-r--r--sound/pci/ctxfi/xfi.c15
7 files changed, 135 insertions, 174 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
42static const struct ct_atc_chip_sub_details atc_sub_details[NUM_CTCARDS] = { 42static 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
55static struct ct_atc_chip_details atc_chip_details[] = { 54static 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
68static 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
67static struct { 78static struct {
@@ -1208,62 +1219,39 @@ static int atc_dev_free(struct snd_device *dev)
1208 1219
1209static int __devinit atc_identify_card(struct ct_atc *atc) 1220static 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
1250int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc) 1249int __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
1557int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, 1541int __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
diff --git a/sound/pci/ctxfi/ctatc.h b/sound/pci/ctxfi/ctatc.h
index 04459aa0d4d9..a03347232e84 100644
--- a/sound/pci/ctxfi/ctatc.h
+++ b/sound/pci/ctxfi/ctatc.h
@@ -37,15 +37,6 @@ enum CTALSADEVS { /* Types of alsa devices */
37 NUM_CTALSADEVS /* This should always be the last */ 37 NUM_CTALSADEVS /* This should always be the last */
38}; 38};
39 39
40enum CTCARDS {
41 CTSB0760,
42 CTHENDRIX,
43 CTSB08801,
44 CTSB08802,
45 CTSB08803,
46 NUM_CTCARDS /* This should always be the last */
47};
48
49struct ct_atc_chip_sub_details { 40struct ct_atc_chip_sub_details {
50 u16 subsys; 41 u16 subsys;
51 const char *nm_model; 42 const char *nm_model;
@@ -89,8 +80,10 @@ struct ct_atc {
89 unsigned int msr; /* master sample rate in rsr */ 80 unsigned int msr; /* master sample rate in rsr */
90 unsigned int pll_rate; /* current rate of Phase Lock Loop */ 81 unsigned int pll_rate; /* current rate of Phase Lock Loop */
91 82
92 const struct ct_atc_chip_details *chip_details; 83 int chip_type;
93 enum CTCARDS model; 84 int model;
85 const char *chip_name;
86 const char *model_name;
94 87
95 struct ct_vm *vm; /* device virtual memory manager for this card */ 88 struct ct_vm *vm; /* device virtual memory manager for this card */
96 int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm); 89 int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
@@ -147,7 +140,7 @@ struct ct_atc {
147 140
148 141
149int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, 142int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci,
150 unsigned int rsr, unsigned int msr, 143 unsigned int rsr, unsigned int msr, int chip_type,
151 struct ct_atc **ratc); 144 struct ct_atc **ratc);
152int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc); 145int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc);
153 146
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
index befead4eeaab..082e35c08c02 100644
--- a/sound/pci/ctxfi/ctdaio.c
+++ b/sound/pci/ctxfi/ctdaio.c
@@ -116,7 +116,7 @@ static struct rsc_ops daio_in_rsc_ops_20k2 = {
116 116
117static unsigned int daio_device_index(enum DAIOTYP type, struct hw *hw) 117static unsigned int daio_device_index(enum DAIOTYP type, struct hw *hw)
118{ 118{
119 switch (hw->get_chip_type(hw)) { 119 switch (hw->chip_type) {
120 case ATC20K1: 120 case ATC20K1:
121 switch (type) { 121 switch (type) {
122 case SPDIFOO: return 0; 122 case SPDIFOO: return 0;
@@ -343,7 +343,7 @@ static int daio_rsc_init(struct daio *daio,
343 int err; 343 int err;
344 unsigned int idx_l, idx_r; 344 unsigned int idx_l, idx_r;
345 345
346 switch (((struct hw *)hw)->get_chip_type(hw)) { 346 switch (((struct hw *)hw)->chip_type) {
347 case ATC20K1: 347 case ATC20K1:
348 idx_l = idx_20k1[desc->type].left; 348 idx_l = idx_20k1[desc->type].left;
349 idx_r = idx_20k1[desc->type].right; 349 idx_r = idx_20k1[desc->type].right;
@@ -367,7 +367,7 @@ static int daio_rsc_init(struct daio *daio,
367 if (desc->type <= DAIO_OUT_MAX) { 367 if (desc->type <= DAIO_OUT_MAX) {
368 daio->rscl.ops = daio->rscr.ops = &daio_out_rsc_ops; 368 daio->rscl.ops = daio->rscr.ops = &daio_out_rsc_ops;
369 } else { 369 } else {
370 switch (((struct hw *)hw)->get_chip_type(hw)) { 370 switch (((struct hw *)hw)->chip_type) {
371 case ATC20K1: 371 case ATC20K1:
372 daio->rscl.ops = daio->rscr.ops = &daio_in_rsc_ops_20k1; 372 daio->rscl.ops = daio->rscr.ops = &daio_in_rsc_ops_20k1;
373 break; 373 break;
diff --git a/sound/pci/ctxfi/cthardware.c b/sound/pci/ctxfi/cthardware.c
index 5ec6813d3911..8e64f4862e85 100644
--- a/sound/pci/ctxfi/cthardware.c
+++ b/sound/pci/ctxfi/cthardware.c
@@ -20,34 +20,16 @@
20#include "cthw20k2.h" 20#include "cthw20k2.h"
21#include <linux/bug.h> 21#include <linux/bug.h>
22 22
23static enum CHIPTYP __devinitdata get_chip_type(struct hw *hw) 23int __devinit create_hw_obj(struct pci_dev *pci, enum CHIPTYP chip_type,
24{ 24 enum CTCARDS model, struct hw **rhw)
25 enum CHIPTYP type;
26
27 switch (hw->pci->device) {
28 case 0x0005: /* 20k1 device */
29 type = ATC20K1;
30 break;
31 case 0x000B: /* 20k2 device */
32 type = ATC20K2;
33 break;
34 default:
35 type = ATCNONE;
36 break;
37 }
38
39 return type;
40}
41
42int __devinit create_hw_obj(struct pci_dev *pci, struct hw **rhw)
43{ 25{
44 int err; 26 int err;
45 27
46 switch (pci->device) { 28 switch (chip_type) {
47 case 0x0005: /* 20k1 device */ 29 case ATC20K1:
48 err = create_20k1_hw_obj(rhw); 30 err = create_20k1_hw_obj(rhw);
49 break; 31 break;
50 case 0x000B: /* 20k2 device */ 32 case ATC20K2:
51 err = create_20k2_hw_obj(rhw); 33 err = create_20k2_hw_obj(rhw);
52 break; 34 break;
53 default: 35 default:
@@ -58,7 +40,8 @@ int __devinit create_hw_obj(struct pci_dev *pci, struct hw **rhw)
58 return err; 40 return err;
59 41
60 (*rhw)->pci = pci; 42 (*rhw)->pci = pci;
61 (*rhw)->get_chip_type = get_chip_type; 43 (*rhw)->chip_type = chip_type;
44 (*rhw)->model = model;
62 45
63 return 0; 46 return 0;
64} 47}
diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h
index 8f11644ddc92..4a8e04f090a4 100644
--- a/sound/pci/ctxfi/cthardware.h
+++ b/sound/pci/ctxfi/cthardware.h
@@ -27,6 +27,19 @@ enum CHIPTYP {
27 ATCNONE 27 ATCNONE
28}; 28};
29 29
30enum CTCARDS {
31 /* 20k1 models */
32 CTSB055X,
33 CTSB073X,
34 CTUAA,
35 CT20K1_UNKNOWN,
36 /* 20k2 models */
37 CTSB0760,
38 CTHENDRIX,
39 CTSB0880,
40 NUM_CTCARDS /* This should always be the last */
41};
42
30/* Type of input source for ADC */ 43/* Type of input source for ADC */
31enum ADCSRC{ 44enum ADCSRC{
32 ADC_MICIN, 45 ADC_MICIN,
@@ -48,7 +61,6 @@ struct hw {
48 int (*card_init)(struct hw *hw, struct card_conf *info); 61 int (*card_init)(struct hw *hw, struct card_conf *info);
49 int (*card_stop)(struct hw *hw); 62 int (*card_stop)(struct hw *hw);
50 int (*pll_init)(struct hw *hw, unsigned int rsr); 63 int (*pll_init)(struct hw *hw, unsigned int rsr);
51 enum CHIPTYP (*get_chip_type)(struct hw *hw);
52 int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source); 64 int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source);
53 int (*select_adc_source)(struct hw *hw, enum ADCSRC source); 65 int (*select_adc_source)(struct hw *hw, enum ADCSRC source);
54 int (*have_digit_io_switch)(struct hw *hw); 66 int (*have_digit_io_switch)(struct hw *hw);
@@ -156,9 +168,13 @@ struct hw {
156 int irq; 168 int irq;
157 unsigned long io_base; 169 unsigned long io_base;
158 unsigned long mem_base; 170 unsigned long mem_base;
171
172 enum CHIPTYP chip_type;
173 enum CTCARDS model;
159}; 174};
160 175
161int create_hw_obj(struct pci_dev *pci, struct hw **rhw); 176int create_hw_obj(struct pci_dev *pci, enum CHIPTYP chip_type,
177 enum CTCARDS model, struct hw **rhw);
162int destroy_hw_obj(struct hw *hw); 178int destroy_hw_obj(struct hw *hw);
163 179
164unsigned int get_field(unsigned int data, unsigned int field); 180unsigned int get_field(unsigned int data, unsigned int field);
diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c
index 38b87b6ee6d4..5d58650beb73 100644
--- a/sound/pci/ctxfi/cthw20k1.c
+++ b/sound/pci/ctxfi/cthw20k1.c
@@ -1432,11 +1432,9 @@ static int hw_dac_init(struct hw *hw, const struct dac_conf *info)
1432{ 1432{
1433 u32 data; 1433 u32 data;
1434 u16 gpioorg; 1434 u16 gpioorg;
1435 u16 subsys_id;
1436 unsigned int ret; 1435 unsigned int ret;
1437 1436
1438 pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id); 1437 if (hw->model == CTSB055X) {
1439 if ((subsys_id == 0x0022) || (subsys_id == 0x002F)) {
1440 /* SB055x, unmute outputs */ 1438 /* SB055x, unmute outputs */
1441 gpioorg = (u16)hw_read_20kx(hw, GPIO); 1439 gpioorg = (u16)hw_read_20kx(hw, GPIO);
1442 gpioorg &= 0xffbf; /* set GPIO6 to low */ 1440 gpioorg &= 0xffbf; /* set GPIO6 to low */
@@ -1538,19 +1536,14 @@ static int is_adc_input_selected_hendrix(struct hw *hw, enum ADCSRC type)
1538 1536
1539static int hw_is_adc_input_selected(struct hw *hw, enum ADCSRC type) 1537static int hw_is_adc_input_selected(struct hw *hw, enum ADCSRC type)
1540{ 1538{
1541 u16 subsys_id; 1539 switch (hw->model) {
1542 1540 case CTSB055X:
1543 pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id);
1544 if ((subsys_id == 0x0022) || (subsys_id == 0x002F)) {
1545 /* SB055x cards */
1546 return is_adc_input_selected_SB055x(hw, type); 1541 return is_adc_input_selected_SB055x(hw, type);
1547 } else if ((subsys_id == 0x0029) || (subsys_id == 0x0031)) { 1542 case CTSB073X:
1548 /* SB073x cards */
1549 return is_adc_input_selected_hendrix(hw, type); 1543 return is_adc_input_selected_hendrix(hw, type);
1550 } else if ((subsys_id & 0xf000) == 0x6000) { 1544 case CTHENDRIX:
1551 /* Vista compatible cards */
1552 return is_adc_input_selected_hendrix(hw, type); 1545 return is_adc_input_selected_hendrix(hw, type);
1553 } else { 1546 default:
1554 return is_adc_input_selected_SBx(hw, type); 1547 return is_adc_input_selected_SBx(hw, type);
1555 } 1548 }
1556} 1549}
@@ -1692,20 +1685,17 @@ adc_input_select_hendrix(struct hw *hw, enum ADCSRC type, unsigned char boost)
1692 1685
1693static int hw_adc_input_select(struct hw *hw, enum ADCSRC type) 1686static int hw_adc_input_select(struct hw *hw, enum ADCSRC type)
1694{ 1687{
1695 u16 subsys_id; 1688 int state = type == ADC_MICIN;
1696 1689
1697 pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id); 1690 switch (hw->model) {
1698 if ((subsys_id == 0x0022) || (subsys_id == 0x002F)) { 1691 case CTSB055X:
1699 /* SB055x cards */ 1692 return adc_input_select_SB055x(hw, type, state);
1700 return adc_input_select_SB055x(hw, type, (ADC_MICIN == type)); 1693 case CTSB073X:
1701 } else if ((subsys_id == 0x0029) || (subsys_id == 0x0031)) { 1694 return adc_input_select_hendrix(hw, type, state);
1702 /* SB073x cards */ 1695 case CTHENDRIX:
1703 return adc_input_select_hendrix(hw, type, (ADC_MICIN == type)); 1696 return adc_input_select_hendrix(hw, type, state);
1704 } else if ((subsys_id & 0xf000) == 0x6000) { 1697 default:
1705 /* Vista compatible cards */ 1698 return adc_input_select_SBx(hw, type, state);
1706 return adc_input_select_hendrix(hw, type, (ADC_MICIN == type));
1707 } else {
1708 return adc_input_select_SBx(hw, type, (ADC_MICIN == type));
1709 } 1699 }
1710} 1700}
1711 1701
@@ -1781,28 +1771,16 @@ static int adc_init_SBx(struct hw *hw, int input, int mic20db)
1781 1771
1782static int hw_adc_init(struct hw *hw, const struct adc_conf *info) 1772static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
1783{ 1773{
1784 int err; 1774 if (hw->model == CTSB055X)
1785 u16 subsys_id; 1775 return adc_init_SB055x(hw, info->input, info->mic20db);
1786 1776 else
1787 pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id); 1777 return adc_init_SBx(hw, info->input, info->mic20db);
1788 if ((subsys_id == 0x0022) || (subsys_id == 0x002F)) {
1789 /* Sb055x card */
1790 err = adc_init_SB055x(hw, info->input, info->mic20db);
1791 } else {
1792 err = adc_init_SBx(hw, info->input, info->mic20db);
1793 }
1794
1795 return err;
1796} 1778}
1797 1779
1798static int hw_have_digit_io_switch(struct hw *hw) 1780static int hw_have_digit_io_switch(struct hw *hw)
1799{ 1781{
1800 u16 subsys_id;
1801
1802 pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id);
1803 /* SB073x and Vista compatible cards have no digit IO switch */ 1782 /* SB073x and Vista compatible cards have no digit IO switch */
1804 return !((subsys_id == 0x0029) || (subsys_id == 0x0031) 1783 return !(hw->model == CTSB073X || hw->model == CTHENDRIX);
1805 || ((subsys_id & 0xf000) == 0x6000));
1806} 1784}
1807 1785
1808#define CTLBITS(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) 1786#define CTLBITS(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
@@ -1918,7 +1896,6 @@ static int hw_card_start(struct hw *hw)
1918{ 1896{
1919 int err; 1897 int err;
1920 struct pci_dev *pci = hw->pci; 1898 struct pci_dev *pci = hw->pci;
1921 u16 subsys_id;
1922 1899
1923 err = pci_enable_device(pci); 1900 err = pci_enable_device(pci);
1924 if (err < 0) 1901 if (err < 0)
@@ -1939,8 +1916,7 @@ static int hw_card_start(struct hw *hw)
1939 goto error1; 1916 goto error1;
1940 1917
1941 /* Switch to X-Fi mode from UAA mode if neeeded */ 1918 /* Switch to X-Fi mode from UAA mode if neeeded */
1942 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsys_id); 1919 if (hw->model == CTHENDRIX) {
1943 if ((0x5 == pci->device) && (0x6000 == (subsys_id & 0x6000))) {
1944 err = uaa_to_xfi(pci); 1920 err = uaa_to_xfi(pci);
1945 if (err) 1921 if (err)
1946 goto error2; 1922 goto error2;
@@ -2004,7 +1980,6 @@ static int hw_card_init(struct hw *hw, struct card_conf *info)
2004{ 1980{
2005 int err; 1981 int err;
2006 unsigned int gctl; 1982 unsigned int gctl;
2007 u16 subsys_id;
2008 u32 data; 1983 u32 data;
2009 struct dac_conf dac_info = {0}; 1984 struct dac_conf dac_info = {0};
2010 struct adc_conf adc_info = {0}; 1985 struct adc_conf adc_info = {0};
@@ -2044,19 +2019,20 @@ static int hw_card_init(struct hw *hw, struct card_conf *info)
2044 hw_write_20kx(hw, SRCIP, 0); 2019 hw_write_20kx(hw, SRCIP, 0);
2045 mdelay(30); 2020 mdelay(30);
2046 2021
2047 pci_read_config_word(hw->pci, PCI_SUBSYSTEM_ID, &subsys_id);
2048 /* Detect the card ID and configure GPIO accordingly. */ 2022 /* Detect the card ID and configure GPIO accordingly. */
2049 if ((subsys_id == 0x0022) || (subsys_id == 0x002F)) { 2023 switch (hw->model) {
2050 /* SB055x cards */ 2024 case CTSB055X:
2051 hw_write_20kx(hw, GPIOCTL, 0x13fe); 2025 hw_write_20kx(hw, GPIOCTL, 0x13fe);
2052 } else if ((subsys_id == 0x0029) || (subsys_id == 0x0031)) { 2026 break;
2053 /* SB073x cards */ 2027 case CTSB073X:
2054 hw_write_20kx(hw, GPIOCTL, 0x00e6); 2028 hw_write_20kx(hw, GPIOCTL, 0x00e6);
2055 } else if ((subsys_id & 0xf000) == 0x6000) { 2029 break;
2056 /* Vista compatible cards */ 2030 case CTHENDRIX: /* Vista compatible cards */
2057 hw_write_20kx(hw, GPIOCTL, 0x00c2); 2031 hw_write_20kx(hw, GPIOCTL, 0x00c2);
2058 } else { 2032 break;
2033 default:
2059 hw_write_20kx(hw, GPIOCTL, 0x01e6); 2034 hw_write_20kx(hw, GPIOCTL, 0x01e6);
2035 break;
2060 } 2036 }
2061 2037
2062 trn_info.vm_pgt_phys = info->vm_pgt_phys; 2038 trn_info.vm_pgt_phys = info->vm_pgt_phys;
diff --git a/sound/pci/ctxfi/xfi.c b/sound/pci/ctxfi/xfi.c
index 279dac6c34dd..2d3dd89af151 100644
--- a/sound/pci/ctxfi/xfi.c
+++ b/sound/pci/ctxfi/xfi.c
@@ -15,6 +15,7 @@
15#include <sound/core.h> 15#include <sound/core.h>
16#include <sound/initval.h> 16#include <sound/initval.h>
17#include "ctatc.h" 17#include "ctatc.h"
18#include "cthardware.h"
18 19
19MODULE_AUTHOR("Creative Technology Ltd"); 20MODULE_AUTHOR("Creative Technology Ltd");
20MODULE_DESCRIPTION("X-Fi driver version 1.03"); 21MODULE_DESCRIPTION("X-Fi driver version 1.03");
@@ -41,8 +42,12 @@ MODULE_PARM_DESC(enable, "Enable Creative X-Fi driver");
41 42
42static struct pci_device_id ct_pci_dev_ids[] = { 43static struct pci_device_id ct_pci_dev_ids[] = {
43 /* only X-Fi is supported, so... */ 44 /* only X-Fi is supported, so... */
44 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K1) }, 45 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K1),
45 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K2) }, 46 .driver_data = ATC20K1,
47 },
48 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K2),
49 .driver_data = ATC20K2,
50 },
46 { 0, } 51 { 0, }
47}; 52};
48MODULE_DEVICE_TABLE(pci, ct_pci_dev_ids); 53MODULE_DEVICE_TABLE(pci, ct_pci_dev_ids);
@@ -79,7 +84,8 @@ ct_card_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
79 "1 and 2, Value 2 is assumed.\n"); 84 "1 and 2, Value 2 is assumed.\n");
80 multiple = 2; 85 multiple = 2;
81 } 86 }
82 err = ct_atc_create(card, pci, reference_rate, multiple, &atc); 87 err = ct_atc_create(card, pci, reference_rate, multiple,
88 pci_id->driver_data, &atc);
83 if (err < 0) 89 if (err < 0)
84 goto error; 90 goto error;
85 91
@@ -92,7 +98,8 @@ ct_card_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
92 98
93 strcpy(card->driver, "SB-XFi"); 99 strcpy(card->driver, "SB-XFi");
94 strcpy(card->shortname, "Creative X-Fi"); 100 strcpy(card->shortname, "Creative X-Fi");
95 strcpy(card->longname, "Creative ALSA Driver X-Fi"); 101 snprintf(card->longname, sizeof(card->longname), "%s %s %s",
102 card->shortname, atc->chip_name, atc->model_name);
96 103
97 err = snd_card_register(card); 104 err = snd_card_register(card);
98 if (err < 0) 105 if (err < 0)