diff options
Diffstat (limited to 'sound/pci/ctxfi')
-rw-r--r-- | sound/pci/ctxfi/ctatc.c | 41 | ||||
-rw-r--r-- | sound/pci/ctxfi/ctatc.h | 2 | ||||
-rw-r--r-- | sound/pci/ctxfi/ctpcm.c | 1 | ||||
-rw-r--r-- | sound/pci/ctxfi/ctvmem.c | 38 | ||||
-rw-r--r-- | sound/pci/ctxfi/ctvmem.h | 8 | ||||
-rw-r--r-- | sound/pci/ctxfi/xfi.c | 7 |
6 files changed, 49 insertions, 48 deletions
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 75454648d50c..1bff80cde0a2 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "ctdaio.h" | 24 | #include "ctdaio.h" |
25 | #include "cttimer.h" | 25 | #include "cttimer.h" |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/slab.h> | ||
27 | #include <sound/pcm.h> | 28 | #include <sound/pcm.h> |
28 | #include <sound/control.h> | 29 | #include <sound/control.h> |
29 | #include <sound/asoundef.h> | 30 | #include <sound/asoundef.h> |
@@ -166,18 +167,7 @@ static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
166 | 167 | ||
167 | static unsigned long atc_get_ptp_phys(struct ct_atc *atc, int index) | 168 | static unsigned long atc_get_ptp_phys(struct ct_atc *atc, int index) |
168 | { | 169 | { |
169 | struct ct_vm *vm; | 170 | return atc->vm->get_ptp_phys(atc->vm, index); |
170 | void *kvirt_addr; | ||
171 | unsigned long phys_addr; | ||
172 | |||
173 | vm = atc->vm; | ||
174 | kvirt_addr = vm->get_ptp_virt(vm, index); | ||
175 | if (kvirt_addr == NULL) | ||
176 | phys_addr = (~0UL); | ||
177 | else | ||
178 | phys_addr = virt_to_phys(kvirt_addr); | ||
179 | |||
180 | return phys_addr; | ||
181 | } | 171 | } |
182 | 172 | ||
183 | static unsigned int convert_format(snd_pcm_format_t snd_format) | 173 | static unsigned int convert_format(snd_pcm_format_t snd_format) |
@@ -240,7 +230,7 @@ static int select_rom(unsigned int pitch) | |||
240 | } else if (pitch == 0x02000000) { | 230 | } else if (pitch == 0x02000000) { |
241 | /* pitch == 2 */ | 231 | /* pitch == 2 */ |
242 | return 3; | 232 | return 3; |
243 | } else if (pitch >= 0x0 && pitch <= 0x08000000) { | 233 | } else if (pitch <= 0x08000000) { |
244 | /* 0 <= pitch <= 8 */ | 234 | /* 0 <= pitch <= 8 */ |
245 | return 0; | 235 | return 0; |
246 | } else { | 236 | } else { |
@@ -1225,10 +1215,11 @@ static int atc_dev_free(struct snd_device *dev) | |||
1225 | return ct_atc_destroy(atc); | 1215 | return ct_atc_destroy(atc); |
1226 | } | 1216 | } |
1227 | 1217 | ||
1228 | static int __devinit atc_identify_card(struct ct_atc *atc) | 1218 | static int __devinit atc_identify_card(struct ct_atc *atc, unsigned int ssid) |
1229 | { | 1219 | { |
1230 | const struct snd_pci_quirk *p; | 1220 | const struct snd_pci_quirk *p; |
1231 | const struct snd_pci_quirk *list; | 1221 | const struct snd_pci_quirk *list; |
1222 | u16 vendor_id, device_id; | ||
1232 | 1223 | ||
1233 | switch (atc->chip_type) { | 1224 | switch (atc->chip_type) { |
1234 | case ATC20K1: | 1225 | case ATC20K1: |
@@ -1242,13 +1233,19 @@ static int __devinit atc_identify_card(struct ct_atc *atc) | |||
1242 | default: | 1233 | default: |
1243 | return -ENOENT; | 1234 | return -ENOENT; |
1244 | } | 1235 | } |
1245 | p = snd_pci_quirk_lookup(atc->pci, list); | 1236 | if (ssid) { |
1237 | vendor_id = ssid >> 16; | ||
1238 | device_id = ssid & 0xffff; | ||
1239 | } else { | ||
1240 | vendor_id = atc->pci->subsystem_vendor; | ||
1241 | device_id = atc->pci->subsystem_device; | ||
1242 | } | ||
1243 | p = snd_pci_quirk_lookup_id(vendor_id, device_id, list); | ||
1246 | if (p) { | 1244 | if (p) { |
1247 | if (p->value < 0) { | 1245 | if (p->value < 0) { |
1248 | printk(KERN_ERR "ctxfi: " | 1246 | printk(KERN_ERR "ctxfi: " |
1249 | "Device %04x:%04x is black-listed\n", | 1247 | "Device %04x:%04x is black-listed\n", |
1250 | atc->pci->subsystem_vendor, | 1248 | vendor_id, device_id); |
1251 | atc->pci->subsystem_device); | ||
1252 | return -ENOENT; | 1249 | return -ENOENT; |
1253 | } | 1250 | } |
1254 | atc->model = p->value; | 1251 | atc->model = p->value; |
@@ -1261,8 +1258,7 @@ static int __devinit atc_identify_card(struct ct_atc *atc) | |||
1261 | atc->model_name = ct_subsys_name[atc->model]; | 1258 | atc->model_name = ct_subsys_name[atc->model]; |
1262 | snd_printd("ctxfi: chip %s model %s (%04x:%04x) is found\n", | 1259 | snd_printd("ctxfi: chip %s model %s (%04x:%04x) is found\n", |
1263 | atc->chip_name, atc->model_name, | 1260 | atc->chip_name, atc->model_name, |
1264 | atc->pci->subsystem_vendor, | 1261 | vendor_id, device_id); |
1265 | atc->pci->subsystem_device); | ||
1266 | return 0; | 1262 | return 0; |
1267 | } | 1263 | } |
1268 | 1264 | ||
@@ -1636,7 +1632,8 @@ static struct ct_atc atc_preset __devinitdata = { | |||
1636 | 1632 | ||
1637 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | 1633 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, |
1638 | unsigned int rsr, unsigned int msr, | 1634 | unsigned int rsr, unsigned int msr, |
1639 | int chip_type, struct ct_atc **ratc) | 1635 | int chip_type, unsigned int ssid, |
1636 | struct ct_atc **ratc) | ||
1640 | { | 1637 | { |
1641 | struct ct_atc *atc; | 1638 | struct ct_atc *atc; |
1642 | static struct snd_device_ops ops = { | 1639 | static struct snd_device_ops ops = { |
@@ -1662,14 +1659,14 @@ int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | |||
1662 | mutex_init(&atc->atc_mutex); | 1659 | mutex_init(&atc->atc_mutex); |
1663 | 1660 | ||
1664 | /* Find card model */ | 1661 | /* Find card model */ |
1665 | err = atc_identify_card(atc); | 1662 | err = atc_identify_card(atc, ssid); |
1666 | if (err < 0) { | 1663 | if (err < 0) { |
1667 | printk(KERN_ERR "ctatc: Card not recognised\n"); | 1664 | printk(KERN_ERR "ctatc: Card not recognised\n"); |
1668 | goto error1; | 1665 | goto error1; |
1669 | } | 1666 | } |
1670 | 1667 | ||
1671 | /* Set up device virtual memory management object */ | 1668 | /* Set up device virtual memory management object */ |
1672 | err = ct_vm_create(&atc->vm); | 1669 | err = ct_vm_create(&atc->vm, pci); |
1673 | if (err < 0) | 1670 | if (err < 0) |
1674 | goto error1; | 1671 | goto error1; |
1675 | 1672 | ||
diff --git a/sound/pci/ctxfi/ctatc.h b/sound/pci/ctxfi/ctatc.h index 9fd8a5708943..7167c0185d52 100644 --- a/sound/pci/ctxfi/ctatc.h +++ b/sound/pci/ctxfi/ctatc.h | |||
@@ -148,7 +148,7 @@ struct ct_atc { | |||
148 | 148 | ||
149 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | 149 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, |
150 | unsigned int rsr, unsigned int msr, int chip_type, | 150 | unsigned int rsr, unsigned int msr, int chip_type, |
151 | struct ct_atc **ratc); | 151 | unsigned int subsysid, struct ct_atc **ratc); |
152 | int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc); | 152 | int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc); |
153 | 153 | ||
154 | #endif /* CTATC_H */ | 154 | #endif /* CTATC_H */ |
diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index d0dc227fbdd3..85ab43e89212 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c | |||
@@ -17,6 +17,7 @@ | |||
17 | 17 | ||
18 | #include "ctpcm.h" | 18 | #include "ctpcm.h" |
19 | #include "cttimer.h" | 19 | #include "cttimer.h" |
20 | #include <linux/slab.h> | ||
20 | #include <sound/pcm.h> | 21 | #include <sound/pcm.h> |
21 | 22 | ||
22 | /* Hardware descriptions for playback */ | 23 | /* Hardware descriptions for playback */ |
diff --git a/sound/pci/ctxfi/ctvmem.c b/sound/pci/ctxfi/ctvmem.c index 6b78752e9503..65da6e466f80 100644 --- a/sound/pci/ctxfi/ctvmem.c +++ b/sound/pci/ctxfi/ctvmem.c | |||
@@ -138,7 +138,7 @@ ct_vm_map(struct ct_vm *vm, struct snd_pcm_substream *substream, int size) | |||
138 | return NULL; | 138 | return NULL; |
139 | } | 139 | } |
140 | 140 | ||
141 | ptp = vm->ptp[0]; | 141 | ptp = (unsigned long *)vm->ptp[0].area; |
142 | pte_start = (block->addr >> CT_PAGE_SHIFT); | 142 | pte_start = (block->addr >> CT_PAGE_SHIFT); |
143 | pages = block->size >> CT_PAGE_SHIFT; | 143 | pages = block->size >> CT_PAGE_SHIFT; |
144 | for (i = 0; i < pages; i++) { | 144 | for (i = 0; i < pages; i++) { |
@@ -158,25 +158,25 @@ static void ct_vm_unmap(struct ct_vm *vm, struct ct_vm_block *block) | |||
158 | } | 158 | } |
159 | 159 | ||
160 | /* * | 160 | /* * |
161 | * return the host (kmalloced) addr of the @index-th device | 161 | * return the host physical addr of the @index-th device |
162 | * page talbe page on success, or NULL on failure. | 162 | * page table page on success, or ~0UL on failure. |
163 | * The first returned NULL indicates the termination. | 163 | * The first returned ~0UL indicates the termination. |
164 | * */ | 164 | * */ |
165 | static void * | 165 | static dma_addr_t |
166 | ct_get_ptp_virt(struct ct_vm *vm, int index) | 166 | ct_get_ptp_phys(struct ct_vm *vm, int index) |
167 | { | 167 | { |
168 | void *addr; | 168 | dma_addr_t addr; |
169 | 169 | ||
170 | addr = (index >= CT_PTP_NUM) ? NULL : vm->ptp[index]; | 170 | addr = (index >= CT_PTP_NUM) ? ~0UL : vm->ptp[index].addr; |
171 | 171 | ||
172 | return addr; | 172 | return addr; |
173 | } | 173 | } |
174 | 174 | ||
175 | int ct_vm_create(struct ct_vm **rvm) | 175 | int ct_vm_create(struct ct_vm **rvm, struct pci_dev *pci) |
176 | { | 176 | { |
177 | struct ct_vm *vm; | 177 | struct ct_vm *vm; |
178 | struct ct_vm_block *block; | 178 | struct ct_vm_block *block; |
179 | int i; | 179 | int i, err = 0; |
180 | 180 | ||
181 | *rvm = NULL; | 181 | *rvm = NULL; |
182 | 182 | ||
@@ -188,23 +188,21 @@ int ct_vm_create(struct ct_vm **rvm) | |||
188 | 188 | ||
189 | /* Allocate page table pages */ | 189 | /* Allocate page table pages */ |
190 | for (i = 0; i < CT_PTP_NUM; i++) { | 190 | for (i = 0; i < CT_PTP_NUM; i++) { |
191 | vm->ptp[i] = kmalloc(PAGE_SIZE, GFP_KERNEL); | 191 | err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, |
192 | if (!vm->ptp[i]) | 192 | snd_dma_pci_data(pci), |
193 | PAGE_SIZE, &vm->ptp[i]); | ||
194 | if (err < 0) | ||
193 | break; | 195 | break; |
194 | } | 196 | } |
195 | if (!i) { | 197 | if (err < 0) { |
196 | /* no page table pages are allocated */ | 198 | /* no page table pages are allocated */ |
197 | kfree(vm); | 199 | ct_vm_destroy(vm); |
198 | return -ENOMEM; | 200 | return -ENOMEM; |
199 | } | 201 | } |
200 | vm->size = CT_ADDRS_PER_PAGE * i; | 202 | vm->size = CT_ADDRS_PER_PAGE * i; |
201 | /* Initialise remaining ptps */ | ||
202 | for (; i < CT_PTP_NUM; i++) | ||
203 | vm->ptp[i] = NULL; | ||
204 | |||
205 | vm->map = ct_vm_map; | 203 | vm->map = ct_vm_map; |
206 | vm->unmap = ct_vm_unmap; | 204 | vm->unmap = ct_vm_unmap; |
207 | vm->get_ptp_virt = ct_get_ptp_virt; | 205 | vm->get_ptp_phys = ct_get_ptp_phys; |
208 | INIT_LIST_HEAD(&vm->unused); | 206 | INIT_LIST_HEAD(&vm->unused); |
209 | INIT_LIST_HEAD(&vm->used); | 207 | INIT_LIST_HEAD(&vm->used); |
210 | block = kzalloc(sizeof(*block), GFP_KERNEL); | 208 | block = kzalloc(sizeof(*block), GFP_KERNEL); |
@@ -242,7 +240,7 @@ void ct_vm_destroy(struct ct_vm *vm) | |||
242 | 240 | ||
243 | /* free allocated page table pages */ | 241 | /* free allocated page table pages */ |
244 | for (i = 0; i < CT_PTP_NUM; i++) | 242 | for (i = 0; i < CT_PTP_NUM; i++) |
245 | kfree(vm->ptp[i]); | 243 | snd_dma_free_pages(&vm->ptp[i]); |
246 | 244 | ||
247 | vm->size = 0; | 245 | vm->size = 0; |
248 | 246 | ||
diff --git a/sound/pci/ctxfi/ctvmem.h b/sound/pci/ctxfi/ctvmem.h index 01e4fd0386a3..b23adfca4de6 100644 --- a/sound/pci/ctxfi/ctvmem.h +++ b/sound/pci/ctxfi/ctvmem.h | |||
@@ -22,6 +22,8 @@ | |||
22 | 22 | ||
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <linux/pci.h> | ||
26 | #include <sound/memalloc.h> | ||
25 | 27 | ||
26 | /* The chip can handle the page table of 4k pages | 28 | /* The chip can handle the page table of 4k pages |
27 | * (emu20k1 can handle even 8k pages, but we don't use it right now) | 29 | * (emu20k1 can handle even 8k pages, but we don't use it right now) |
@@ -41,7 +43,7 @@ struct snd_pcm_substream; | |||
41 | 43 | ||
42 | /* Virtual memory management object for card device */ | 44 | /* Virtual memory management object for card device */ |
43 | struct ct_vm { | 45 | struct ct_vm { |
44 | void *ptp[CT_PTP_NUM]; /* Device page table pages */ | 46 | struct snd_dma_buffer ptp[CT_PTP_NUM]; /* Device page table pages */ |
45 | unsigned int size; /* Available addr space in bytes */ | 47 | unsigned int size; /* Available addr space in bytes */ |
46 | struct list_head unused; /* List of unused blocks */ | 48 | struct list_head unused; /* List of unused blocks */ |
47 | struct list_head used; /* List of used blocks */ | 49 | struct list_head used; /* List of used blocks */ |
@@ -52,10 +54,10 @@ struct ct_vm { | |||
52 | int size); | 54 | int size); |
53 | /* Unmap device logical addr area. */ | 55 | /* Unmap device logical addr area. */ |
54 | void (*unmap)(struct ct_vm *, struct ct_vm_block *block); | 56 | void (*unmap)(struct ct_vm *, struct ct_vm_block *block); |
55 | void *(*get_ptp_virt)(struct ct_vm *vm, int index); | 57 | dma_addr_t (*get_ptp_phys)(struct ct_vm *vm, int index); |
56 | }; | 58 | }; |
57 | 59 | ||
58 | int ct_vm_create(struct ct_vm **rvm); | 60 | int ct_vm_create(struct ct_vm **rvm, struct pci_dev *pci); |
59 | void ct_vm_destroy(struct ct_vm *vm); | 61 | void ct_vm_destroy(struct ct_vm *vm); |
60 | 62 | ||
61 | #endif /* CTVMEM_H */ | 63 | #endif /* CTVMEM_H */ |
diff --git a/sound/pci/ctxfi/xfi.c b/sound/pci/ctxfi/xfi.c index 76541748e7bc..f42e7e1a1074 100644 --- a/sound/pci/ctxfi/xfi.c +++ b/sound/pci/ctxfi/xfi.c | |||
@@ -32,6 +32,7 @@ module_param(multiple, uint, S_IRUGO); | |||
32 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | 32 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
33 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; | 33 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
34 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; | 34 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; |
35 | static unsigned int subsystem[SNDRV_CARDS]; | ||
35 | 36 | ||
36 | module_param_array(index, int, NULL, 0444); | 37 | module_param_array(index, int, NULL, 0444); |
37 | MODULE_PARM_DESC(index, "Index value for Creative X-Fi driver"); | 38 | MODULE_PARM_DESC(index, "Index value for Creative X-Fi driver"); |
@@ -39,8 +40,10 @@ module_param_array(id, charp, NULL, 0444); | |||
39 | MODULE_PARM_DESC(id, "ID string for Creative X-Fi driver"); | 40 | MODULE_PARM_DESC(id, "ID string for Creative X-Fi driver"); |
40 | module_param_array(enable, bool, NULL, 0444); | 41 | module_param_array(enable, bool, NULL, 0444); |
41 | MODULE_PARM_DESC(enable, "Enable Creative X-Fi driver"); | 42 | MODULE_PARM_DESC(enable, "Enable Creative X-Fi driver"); |
43 | module_param_array(subsystem, int, NULL, 0444); | ||
44 | MODULE_PARM_DESC(subsystem, "Override subsystem ID for Creative X-Fi driver"); | ||
42 | 45 | ||
43 | static struct pci_device_id ct_pci_dev_ids[] = { | 46 | static DEFINE_PCI_DEVICE_TABLE(ct_pci_dev_ids) = { |
44 | /* only X-Fi is supported, so... */ | 47 | /* only X-Fi is supported, so... */ |
45 | { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K1), | 48 | { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_DEVICE_ID_CREATIVE_20K1), |
46 | .driver_data = ATC20K1, | 49 | .driver_data = ATC20K1, |
@@ -85,7 +88,7 @@ ct_card_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | |||
85 | multiple = 2; | 88 | multiple = 2; |
86 | } | 89 | } |
87 | err = ct_atc_create(card, pci, reference_rate, multiple, | 90 | err = ct_atc_create(card, pci, reference_rate, multiple, |
88 | pci_id->driver_data, &atc); | 91 | pci_id->driver_data, subsystem[dev], &atc); |
89 | if (err < 0) | 92 | if (err < 0) |
90 | goto error; | 93 | goto error; |
91 | 94 | ||