Changeset 246
- Timestamp:
- Aug 22, 2007, 5:33:25 AM (18 years ago)
- Location:
- GPL/branches/alsa-resync1/alsa-kernel
- Files:
-
- 2 added
- 60 edited
- 1 moved
-
core/info.c (modified) (1 diff)
-
core/makefile.os2 (modified) (1 diff)
-
core/pcm_native.c (modified) (1 diff)
-
core/sound.c (modified) (1 diff)
-
core/wrappers.c (modified) (1 diff)
-
drivers/dummy.c (modified) (2 diffs)
-
drivers/mtpav.c (modified) (4 diffs)
-
include/sound/ad1848.h (modified) (2 diffs)
-
include/sound/adriver.h (modified) (2 diffs)
-
include/sound/ak4xxx-adda.h (added)
-
include/sound/config.h (modified) (1 diff)
-
include/sound/core.h (modified) (2 diffs)
-
include/sound/cs4231.h (modified) (1 diff)
-
include/sound/driver.h (modified) (1 diff)
-
include/sound/es1688.h (modified) (2 diffs)
-
include/sound/gus.h (modified) (2 diffs)
-
include/sound/hdsp.h (added)
-
include/sound/initval.h (modified) (1 diff)
-
include/sound/isapnp.h (modified) (1 diff)
-
include/sound/snd_wavefront.h (modified) (1 diff)
-
include/sound/uda1341.h (modified) (3 diffs)
-
include/sound/wavefront.h (modified) (1 diff)
-
isa/ad1816a/ad1816a.c (modified) (8 diffs)
-
isa/ad1816a/ad1816a_lib.c (modified) (2 diffs)
-
isa/ad1848/ad1848_lib.c (modified) (2 diffs)
-
isa/als100.c (modified) (10 diffs)
-
isa/azt2320.c (modified) (13 diffs)
-
isa/cmi8330.c (modified) (18 diffs)
-
isa/cs423x/cs4231_lib.c (modified) (5 diffs)
-
isa/cs423x/cs4236.c (modified) (20 diffs)
-
isa/dt019x.c (modified) (10 diffs)
-
isa/es1688/es1688_lib.c (modified) (2 diffs)
-
isa/es18xx.c (modified) (29 diffs)
-
isa/gus/gus_irq.c (modified) (2 diffs)
-
isa/gus/gusmax.c (modified) (1 diff)
-
isa/gus/interwave.c (modified) (24 diffs)
-
isa/opl3sa2.c (modified) (19 diffs)
-
isa/opti9xx/opti92x-ad1848.c (modified) (23 diffs)
-
isa/sb/es968.c (modified) (7 diffs)
-
isa/sb/sb16.c (modified) (22 diffs)
-
isa/sb/sb16_main.c (modified) (2 diffs)
-
isa/sb/sb8.c (modified) (4 diffs)
-
isa/sb/sb8_main.c (modified) (2 diffs)
-
isa/sb/sb8_midi.c (modified) (4 diffs)
-
isa/sgalaxy.c (modified) (2 diffs)
-
isa/wavefront/wavefront.c (modified) (26 diffs)
-
isa/wavefront/wavefront_fx.c (modified) (2 diffs)
-
isa/wavefront/wavefront_synth.c (modified) (4 diffs)
-
pci/ice1712/ak4xxx.c (moved) (moved from GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/ak4524.c ) (4 diffs)
-
pci/ice1712/delta.c (modified) (16 diffs)
-
pci/ice1712/ews.c (modified) (17 diffs)
-
pci/ice1712/ice1712.c (modified) (20 diffs)
-
pci/ice1712/ice1712.h (modified) (5 diffs)
-
pci/ice1712/ice1724.c (modified) (19 diffs)
-
pci/ice1712/makefile.os2 (modified) (1 diff)
-
pci/ice1712/revo.c (modified) (6 diffs)
-
pci/korg1212/korg1212.c (modified) (31 diffs)
-
pci/rme96.c (modified) (3 diffs)
-
pci/rme9652/hdsp.c (modified) (109 diffs)
-
pci/rme9652/rme9652.c (modified) (7 diffs)
-
pci/sonicvibes.c (modified) (2 diffs)
-
pci/trident/trident_main.c (modified) (3 diffs)
-
pci/ymfpci/ymfpci_main.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/alsa-resync1/alsa-kernel/core/info.c
r222 r246 21 21 22 22 #include <sound/driver.h> 23 #include <linux/version.h> 23 24 #include <linux/init.h> 24 25 #include <linux/vmalloc.h> -
GPL/branches/alsa-resync1/alsa-kernel/core/makefile.os2
r224 r246 32 32 # 33 33 #=================================================================== 34 FILE1 = sound.obj init.obj memory.obj mem ory_wrapper.obj memalloc.obj sgbuf.obj34 FILE1 = sound.obj init.obj memory.obj memalloc.obj sgbuf.obj 35 35 FILE2 = control.obj device.obj misc.obj wrappers.obj 36 36 #FILE3 = sound_oss.obj info_oss.obj isadma.obj -
GPL/branches/alsa-resync1/alsa-kernel/core/pcm_native.c
r232 r246 21 21 22 22 #include <sound/driver.h> 23 #include <linux/version.h> 23 24 #include <linux/mm.h> 24 25 #include <linux/file.h> -
GPL/branches/alsa-resync1/alsa-kernel/core/sound.c
r224 r246 21 21 22 22 #include <sound/driver.h> 23 #include <linux/version.h> 23 24 #include <linux/init.h> 24 25 #include <linux/slab.h> -
GPL/branches/alsa-resync1/alsa-kernel/core/wrappers.c
r224 r246 20 20 */ 21 21 22 #include <linux/version.h>23 22 #include <linux/config.h> 24 23 #include <linux/module.h> -
GPL/branches/alsa-resync1/alsa-kernel/drivers/dummy.c
r212 r246 20 20 21 21 #include <sound/driver.h> 22 #include <linux/version.h> 22 23 #include <linux/init.h> 23 24 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) … … 59 60 #define MAX_BUFFER_SIZE (256 * 1024) 60 61 #define USE_FORMATS SNDRV_PCM_FMTBIT_S32_LE 61 #define USE_CHANNELS_MIN 1 062 #define USE_CHANNELS_MAX 1 062 #define USE_CHANNELS_MIN 12 63 #define USE_CHANNELS_MAX 12 63 64 #define USE_PERIODS_MIN 1 64 65 #define USE_PERIODS_MAX 1024 -
GPL/branches/alsa-resync1/alsa-kernel/drivers/mtpav.c
r224 r246 103 103 * defines 104 104 */ 105 //#define USE_FAKE_MTP // don t actually read/write to MTP device (for debugging without an actual unit) (does not work yet)105 //#define USE_FAKE_MTP // don't actually read/write to MTP device (for debugging without an actual unit) (does not work yet) 106 106 107 107 // parallel port usage masks … … 587 587 } 588 588 589 static voidsnd_mtpav_irqh(int irq, void *dev_id, struct pt_regs *regs)590 { 591 mtpav_t *mcard = snd_magic_cast(mtpav_t, dev_id, return );589 static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id, struct pt_regs *regs) 590 { 591 mtpav_t *mcard = snd_magic_cast(mtpav_t, dev_id, return IRQ_NONE); 592 592 593 593 //printk("irqh()\n"); … … 595 595 snd_mtpav_read_bytes(mcard); 596 596 spin_unlock(&mcard->spinlock); 597 return IRQ_HANDLED; 597 598 } 598 599 … … 765 766 goto __error; 766 767 767 err = snd_card_register(mtp_card->card); // don t snd_card_register until AFTER all cards reources done!768 err = snd_card_register(mtp_card->card); // don't snd_card_register until AFTER all cards reources done! 768 769 769 770 //printk("snd_card_register returned %d\n", err); -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/ad1848.h
r222 r246 24 24 25 25 #include "pcm.h" 26 #include <linux/interrupt.h> 26 27 27 28 /* IO ports */ … … 165 166 const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction); 166 167 int snd_ad1848_mixer(ad1848_t * chip); 167 voidsnd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs);168 irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs); 168 169 169 170 /* exported mixer stuffs */ -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/adriver.h
r234 r246 22 22 * 23 23 */ 24 25 #include <linux/version.h> 24 26 25 27 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 3) … … 213 215 #endif 214 216 217 /* pm_message_t type */ 218 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11) 219 #include <linux/pm.h> 220 #ifndef PMSG_FREEZE 221 typedef u32 /* __bitwise */ pm_message_t; 222 #define PMSG_FREEZE 3 223 #define PMSG_SUSPEND 3 224 #define PMSG_ON 0 225 #endif 226 #endif 215 227 #ifndef PCI_D0 216 228 #define PCI_D0 0 -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/config.h
r92 r246 44 44 #define EXPORT_SYMBOL(a) 45 45 #define CONFIG_SOUND 46 #define CONFIG_SND_VERSION "0. 0.1"46 #define CONFIG_SND_VERSION "0.9.3" 47 47 #define ATTRIBUTE_UNUSED 48 48 -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/core.h
r224 r246 198 198 #define snd_power_lock(card) do { (void)(card); } while (0) 199 199 #define snd_power_unlock(card) do { (void)(card); } while (0) 200 #define snd_power_wait(card) do { (void)(card); } while (0) 201 #define snd_power_get_state(card) SNDRV_CTL_POWER_D0200 static inline int snd_power_wait(snd_card_t *card, unsigned int state, struct file *file) { return 0; } 201 #define snd_power_get_state(card) SNDRV_CTL_POWER_D0 202 202 #define snd_power_change_state(card, state) do { (void)(card); } while (0) 203 203 #define snd_card_set_pm_callback(card,suspend,resume,data) -EINVAL … … 501 501 #define unlikely(x) __builtin_expect((x),0) 502 502 503 typedef u32 /*__bitwise*/ pm_message_t;504 505 #ifndef __devexit_p506 #define __devexit_p(x) x507 #endif508 509 503 #define printk_ratelimit() 1 510 504 -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/cs4231.h
r215 r246 316 316 void snd_cs4231_mce_down(cs4231_t *chip); 317 317 318 voidsnd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs);318 irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs); 319 319 320 320 const char *snd_cs4231_chip_id(cs4231_t *chip); -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/driver.h
r224 r246 28 28 29 29 #include <linux/config.h> 30 #include <linux/version.h>31 30 32 31 #define SNDRV_CARDS 8 /* number of supported soundcards - don't change - minor numbers */ -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/es1688.h
r96 r246 25 25 #include "control.h" 26 26 #include "pcm.h" 27 #include <linux/interrupt.h> 27 28 28 29 #define ES1688_HW_AUTO 0x0000 … … 110 111 unsigned char snd_es1688_mixer_read(es1688_t *chip, unsigned char reg); 111 112 112 voidsnd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs);113 irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs); 113 114 114 115 int snd_es1688_create(snd_card_t * card, -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/gus.h
r222 r246 562 562 563 563 #if 0 564 extern voidsnd_gf1_lfo_effect_interrupt(snd_gus_card_t * gus, snd_gf1_voice_t * voice);564 extern irqreturn_t snd_gf1_lfo_effect_interrupt(snd_gus_card_t * gus, snd_gf1_voice_t * voice); 565 565 #endif 566 566 extern void snd_gf1_lfo_init(snd_gus_card_t * gus); … … 667 667 /* gus_irq.c */ 668 668 669 voidsnd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs);669 irqreturn_t snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs); 670 670 #ifdef CONFIG_SND_DEBUG 671 671 void snd_gus_irq_profile_init(snd_gus_card_t *gus); -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/initval.h
r224 r246 135 135 #include <linux/interrupt.h> 136 136 137 static void snd_legacy_empty_irq_handler(int irq, void *dev_id, struct pt_regs *regs) 138 { 137 static irqreturn_t snd_legacy_empty_irq_handler(int irq, void *dev_id, struct pt_regs *regs) 138 { 139 return IRQ_HANDLED; 139 140 } 140 141 -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/isapnp.h
r234 r246 22 22 #ifndef LINUX_ISAPNP_H 23 23 #define LINUX_ISAPNP_H 24 25 #define ISAPNP_ALSA_LOCAL 1 24 26 25 27 /* -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/snd_wavefront.h
r212 r246 99 99 struct _snd_wavefront_card { 100 100 snd_wavefront_t wavefront; 101 #ifdef __ISAPNP__102 struct isapnp_dev *wss;103 struct isapnp_dev *ctrl;104 struct isapnp_dev *mpu;105 struct isapnp_dev *synth;106 #endif /* CONFIG_ ISAPNP */101 #ifdef CONFIG_PNP 102 struct pnp_dev *wss; 103 struct pnp_dev *ctrl; 104 struct pnp_dev *mpu; 105 struct pnp_dev *synth; 106 #endif /* CONFIG_PNP */ 107 107 }; 108 108 -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/uda1341.h
r224 r246 16 16 */ 17 17 18 /* uda1341.h,v 1. 4 2003/02/25 12:48:16perex Exp */18 /* uda1341.h,v 1.5 2003/04/19 13:34:32 perex Exp */ 19 19 20 20 #define UDA1341_ALSA_NAME "snd-uda1341" … … 211 211 CMD_AGC_TIME, 212 212 CMD_AGC_LEVEL, 213 #ifdef CONFIG_PM 214 CMD_SUSPEND, 215 CMD_RESUME, 216 #endif 213 217 CMD_LAST, 214 218 }; … … 222 226 223 227 int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clnt); 224 void __init snd_chip_uda1341_mixer_del(snd_card_t *card);225 226 #ifdef DEBUG_MODE227 #define DEBUG(format, args...) do{printk(format, ##args);}while(0)228 #else229 #define DEBUG(format, args...) /* nothing */230 #endif231 232 #ifdef DEBUG_FUNCTION_NAMES233 #define DEBUG_NAME(format, args...) do{printk(format, ##args);}while(0)234 #else235 #define DEBUG_NAME(format, args...) /* nothing */236 #endif237 228 238 229 /* -
GPL/branches/alsa-resync1/alsa-kernel/include/sound/wavefront.h
r96 r246 688 688 /* Allow direct user-space control over FX memory/coefficient data. 689 689 In theory this could be used to download the FX microprogram, 690 but it would be a little slower, and involve some w ierd code.690 but it would be a little slower, and involve some weird code. 691 691 */ 692 692 -
GPL/branches/alsa-resync1/alsa-kernel/isa/ad1816a/ad1816a.c
r224 r246 23 23 #include <linux/time.h> 24 24 #include <linux/wait.h> 25 #ifndef LINUX_ISAPNP_H 26 #include <linux/isapnp.h> 27 #define isapnp_card pci_bus 28 #define isapnp_dev pci_dev 29 #endif 25 #include <linux/pnp.h> 30 26 #include <sound/core.h> 31 27 #define SNDRV_GET_ID … … 94 90 95 91 struct snd_card_ad1816a { 96 #ifdef __ISAPNP__ 97 struct isapnp_dev *dev; 98 struct isapnp_dev *devmpu; 99 #endif /* __ISAPNP__ */ 92 struct pnp_dev *dev; 93 struct pnp_dev *devmpu; 100 94 }; 101 95 102 static snd_card_t *snd_ad1816a_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 103 104 #ifdef __ISAPNP__ 105 106 static struct isapnp_card *snd_ad1816a_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 107 static const struct isapnp_card_id *snd_ad1816a_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 108 109 #define ISAPNP_AD1816A(_va, _vb, _vc, _device, _fa, _fb, _fc, _audio, _mpu401) \ 110 { \ 111 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 112 .devs = { ISAPNP_DEVICE_ID(_fa, _fb, _fc, _audio), \ 113 ISAPNP_DEVICE_ID(_fa, _fb, _fc, _mpu401), } \ 114 } 115 116 static struct isapnp_card_id snd_ad1816a_pnpids[] __devinitdata = { 96 static struct pnp_card_device_id snd_ad1816a_pnpids[] __devinitdata = { 97 /* Analog Devices AD1815 */ 98 { .id = "ADS7150", .devs = { { .id = "ADS7150" }, { .id = "ADS7151" } } }, 99 /* Analog Devices AD1816A - added by Kenneth Platz <kxp@atl.hp.com> */ 100 { .id = "ADS7181", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } }, 101 /* Analog Devices AD1816A - Aztech/Newcom SC-16 3D */ 102 { .id = "AZT1022", .devs = { { .id = "AZT1018" }, { .id = "AZT2002" } } }, 103 /* Highscreen Sound-Boostar 16 3D - added by Stefan Behnel */ 104 { .id = "LWC1061", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } }, 117 105 /* Highscreen Sound-Boostar 16 3D */ 118 ISAPNP_AD1816A('M','D','K',0x1605,'A','D','S',0x7180,0x7181), 119 /* Highscreen Sound-Boostar 16 3D - added by Stefan Behnel */ 120 ISAPNP_AD1816A('L','W','C',0x1061,'A','D','S',0x7180,0x7181), 121 /* Analog Devices AD1815 */ 122 ISAPNP_AD1816A('A','D','S',0x7150,'A','D','S',0x7150,0x7151), 123 /* Analog Devices AD1816A - added by Kenneth Platz <kxp@atl.hp.com> */ 124 ISAPNP_AD1816A('A','D','S',0x7181,'A','D','S',0x7180,0x7181), 106 { .id = "MDK1605", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } }, 107 /* Shark Predator ISA - added by Ken Arromdee */ 108 { .id = "SMM7180", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } }, 109 /* Analog Devices AD1816A - Terratec AudioSystem EWS64S */ 110 { .id = "TER1112", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } }, 125 111 /* Analog Devices AD1816A - Terratec Base 64 */ 126 ISAPNP_AD1816A('T','E','R',0x1411,'A','D','S',0x7180,0x7181), 127 /* Analog Devices AD1816A - Terratec AudioSystem EWS64S */ 128 ISAPNP_AD1816A('T','E','R',0x1112,'A','D','S',0x7180,0x7181), 129 /* Analog Devices AD1816A - Aztech/Newcom SC-16 3D */ 130 ISAPNP_AD1816A('A','Z','T',0x1022,'A','Z','T',0x1018,0x2002), 131 /* Shark Predator ISA - added by Ken Arromdee */ 132 ISAPNP_AD1816A('S','M','M',0x7180,'A','D','S',0x7180,0x7181), 133 { ISAPNP_CARD_END, } 112 { .id = "TER1411", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } }, 113 /* end */ 114 { .id = "" } 134 115 }; 135 116 136 ISAPNP_CARD_TABLE(snd_ad1816a_pnpids); 137 138 #endif /* __ISAPNP__ */ 117 MODULE_DEVICE_TABLE(pnp_card, snd_ad1816a_pnpids); 118 139 119 140 120 #define DRIVER_NAME "snd-card-ad1816a" 141 121 142 122 143 #ifdef __ISAPNP__ 144 static int __init snd_card_ad1816a_isapnp(int dev,145 struct snd_card_ad1816a *acard)146 { 147 const struct isapnp_card_id *id = snd_ad1816a_isapnp_id[dev];148 struct isapnp_card *card = snd_ad1816a_isapnp_cards[dev];149 struct isapnp_dev *pdev;150 151 acard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL);152 if (acard->dev ->active) {153 acard->dev = NULL;123 static int __devinit snd_card_ad1816a_pnp(int dev, struct snd_card_ad1816a *acard, 124 struct pnp_card_link *card, 125 const struct pnp_card_device_id *id) 126 { 127 struct pnp_dev *pdev; 128 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 129 int err; 130 131 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 132 if (acard->dev == NULL) { 133 kfree(cfg); 154 134 return -EBUSY; 155 135 } 156 acard->devmpu = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL);157 if (acard->devmpu ->active) {158 acard->dev = acard->devmpu = NULL;136 acard->devmpu = pnp_request_card_device(card, id->devs[1].id, NULL); 137 if (acard->devmpu == NULL) { 138 kfree(cfg); 159 139 return -EBUSY; 160 140 } 161 141 162 142 pdev = acard->dev; 163 if (pdev->prepare(pdev) < 0) 164 return -EAGAIN; 143 pnp_init_resource_table(cfg); 165 144 166 145 if (port[dev] != SNDRV_AUTO_PORT) 167 isapnp_resource_change(&pdev->resource[2], port[dev], 16);146 pnp_resource_change(&cfg->port_resource[2], port[dev], 16); 168 147 if (fm_port[dev] != SNDRV_AUTO_PORT) 169 isapnp_resource_change(&pdev->resource[1], fm_port[dev], 4);148 pnp_resource_change(&cfg->port_resource[1], fm_port[dev], 4); 170 149 if (dma1[dev] != SNDRV_AUTO_DMA) 171 isapnp_resource_change(&pdev->dma_resource[0], dma1[dev], 172 1); 150 pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1); 173 151 if (dma2[dev] != SNDRV_AUTO_DMA) 174 isapnp_resource_change(&pdev->dma_resource[1], dma2[dev], 175 1); 152 pnp_resource_change(&cfg->dma_resource[1], dma2[dev], 1); 176 153 if (irq[dev] != SNDRV_AUTO_IRQ) 177 isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); 178 179 if (pdev->activate(pdev) < 0) { 180 printk(KERN_ERR PFX "AUDIO isapnp configure failure\n"); 154 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 155 156 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 157 snd_printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n"); 158 err = pnp_activate_dev(pdev); 159 if (err < 0) { 160 printk(KERN_ERR PFX "AUDIO PnP configure failure\n"); 161 kfree(cfg); 181 162 return -EBUSY; 182 163 } 183 164 184 port[dev] = p dev->resource[2].start;185 fm_port[dev] = p dev->resource[1].start;186 dma1[dev] = p dev->dma_resource[0].start;187 dma2[dev] = p dev->dma_resource[1].start;188 irq[dev] = p dev->irq_resource[0].start;165 port[dev] = pnp_port_start(pdev, 2); 166 fm_port[dev] = pnp_port_start(pdev, 1); 167 dma1[dev] = pnp_dma(pdev, 0); 168 dma2[dev] = pnp_dma(pdev, 1); 169 irq[dev] = pnp_irq(pdev, 0); 189 170 190 171 pdev = acard->devmpu; 191 if (pdev == NULL || pdev->prepare(pdev) < 0) { 192 mpu_port[dev] = -1; 193 acard->devmpu = NULL; 194 return 0; 195 } 172 pnp_init_resource_table(cfg); 196 173 197 174 if (mpu_port[dev] != SNDRV_AUTO_PORT) 198 isapnp_resource_change(&pdev->resource[0], mpu_port[dev], 199 2); 175 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); 200 176 if (mpu_irq[dev] != SNDRV_AUTO_IRQ) 201 isapnp_resource_change(&pdev->irq_resource[0], mpu_irq[dev], 202 1); 203 204 if (pdev->activate(pdev) < 0) { 205 /* not fatal error */ 206 printk(KERN_ERR PFX "MPU-401 isapnp configure failure\n"); 177 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); 178 179 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 180 snd_printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n"); 181 err = pnp_activate_dev(pdev); 182 if (err < 0) { 183 printk(KERN_ERR PFX "MPU401 PnP configure failure\n"); 207 184 mpu_port[dev] = -1; 208 185 acard->devmpu = NULL; 209 186 } else { 210 mpu_port[dev] = pdev->resource[0].start; 211 mpu_irq[dev] = pdev->irq_resource[0].start; 212 } 213 187 mpu_port[dev] = pnp_port_start(pdev, 0); 188 mpu_irq[dev] = pnp_irq(pdev, 0); 189 } 190 191 kfree(cfg); 214 192 return 0; 215 193 } 216 194 217 static void snd_card_ad1816a_deactivate(struct snd_card_ad1816a *acard) 218 { 219 if (acard->dev) { 220 acard->dev->deactivate(acard->dev); 221 acard->dev = NULL; 222 } 223 if (acard->devmpu) { 224 acard->devmpu->deactivate(acard->devmpu); 225 acard->devmpu = NULL; 226 } 227 } 228 #endif /* __ISAPNP__ */ 229 230 static void snd_card_ad1816a_free(snd_card_t *card) 231 { 232 struct snd_card_ad1816a *acard = (struct snd_card_ad1816a *)card->private_data; 233 234 if (acard) { 235 #ifdef __ISAPNP__ 236 snd_card_ad1816a_deactivate(acard); 237 #endif /* __ISAPNP__ */ 238 } 239 } 240 241 static int __init snd_card_ad1816a_probe(int dev) 195 static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard, 196 const struct pnp_card_device_id *pid) 242 197 { 243 198 int error; … … 251 206 return -ENOMEM; 252 207 acard = (struct snd_card_ad1816a *)card->private_data; 253 card->private_free = snd_card_ad1816a_free; 254 255 #ifdef __ISAPNP__ 256 if ((error = snd_card_ad1816a_isapnp(dev, acard))) { 257 snd_card_free(card); 258 return error; 259 } 260 #else 261 printk(KERN_ERR PFX "you have to enable ISA PnP support.\n"); 262 return -ENOSYS; 263 #endif /* __ISAPNP__ */ 208 209 if ((error = snd_card_ad1816a_pnp(dev, acard, pcard, pid))) { 210 snd_card_free(card); 211 return error; 212 } 264 213 265 214 if ((error = snd_ad1816a_create(card, port[dev], … … 315 264 return error; 316 265 } 317 snd_ad1816a_cards[dev] = card;266 pnp_set_card_drvdata(pcard, card); 318 267 return 0; 319 268 } 320 269 321 #ifdef __ISAPNP__ 322 static int __init snd_ad1816a_isapnp_detect(struct isapnp_card *card, 323 const struct isapnp_card_id *id) 270 static int __devinit snd_ad1816a_pnp_detect(struct pnp_card_link *card, 271 const struct pnp_card_device_id *id) 324 272 { 325 273 static int dev; … … 329 277 if (!enable[dev]) 330 278 continue; 331 snd_ad1816a_isapnp_cards[dev] = card; 332 snd_ad1816a_isapnp_id[dev] = id; 333 res = snd_card_ad1816a_probe(dev); 279 res = snd_card_ad1816a_probe(dev, card, id); 334 280 if (res < 0) 335 281 return res; … … 339 285 return -ENODEV; 340 286 } 341 #endif 287 288 static void __devexit snd_ad1816a_pnp_remove(struct pnp_card_link * pcard) 289 { 290 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 291 292 snd_card_disconnect(card); 293 snd_card_free_in_thread(card); 294 } 295 296 static struct pnp_card_driver ad1816a_pnpc_driver = { 297 .flags = PNP_DRIVER_RES_DISABLE, 298 .name = "ad1816a", 299 .id_table = snd_ad1816a_pnpids, 300 .probe = snd_ad1816a_pnp_detect, 301 .remove = __devexit_p(snd_ad1816a_pnp_remove), 302 }; 342 303 343 304 static int __init alsa_card_ad1816a_init(void) … … 345 306 int cards = 0; 346 307 347 #ifdef __ISAPNP__ 348 cards += isapnp_probe_cards(snd_ad1816a_pnpids, snd_ad1816a_isapnp_detect); 349 #else 350 printk(KERN_ERR PFX "you have to enable ISA PnP support.\n"); 351 #endif 308 cards += pnp_register_card_driver(&ad1816a_pnpc_driver); 352 309 #ifdef MODULE 353 if (!cards) 310 if (!cards) { 311 pnp_unregister_card_driver(&ad1816a_pnpc_driver); 354 312 printk(KERN_ERR "no AD1816A based soundcards found.\n"); 313 } 355 314 #endif /* MODULE */ 356 315 return cards ? 0 : -ENODEV; … … 359 318 static void __exit alsa_card_ad1816a_exit(void) 360 319 { 361 int dev; 362 363 for (dev = 0; dev < SNDRV_CARDS; dev++) 364 snd_card_free(snd_ad1816a_cards[dev]); 320 pnp_unregister_card_driver(&ad1816a_pnpc_driver); 365 321 } 366 322 -
GPL/branches/alsa-resync1/alsa-kernel/isa/ad1816a/ad1816a_lib.c
r210 r246 310 310 311 311 312 static voidsnd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs *regs)313 { 314 ad1816a_t *chip = snd_magic_cast(ad1816a_t, dev_id, return );312 static irqreturn_t snd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs *regs) 313 { 314 ad1816a_t *chip = snd_magic_cast(ad1816a_t, dev_id, return IRQ_NONE); 315 315 unsigned char status; 316 316 … … 331 331 snd_ad1816a_out(chip, AD1816A_INTERRUPT_STATUS, 0x00); 332 332 spin_unlock(&chip->lock); 333 return IRQ_HANDLED; 333 334 } 334 335 -
GPL/branches/alsa-resync1/alsa-kernel/isa/ad1848/ad1848_lib.c
r224 r246 586 586 } 587 587 588 voidsnd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs)589 { 590 ad1848_t *chip = snd_magic_cast(ad1848_t, dev_id, return );588 irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs) 589 { 590 ad1848_t *chip = snd_magic_cast(ad1848_t, dev_id, return IRQ_NONE); 591 591 592 592 if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream && … … 597 597 snd_pcm_period_elapsed(chip->capture_substream); 598 598 outb(0, AD1848P(chip, STATUS)); /* clear global interrupt bit */ 599 return IRQ_HANDLED; 599 600 } 600 601 -
GPL/branches/alsa-resync1/alsa-kernel/isa/als100.c
r224 r246 25 25 #include <linux/wait.h> 26 26 #include <linux/time.h> 27 #ifndef LINUX_ISAPNP_H 28 #include <linux/isapnp.h> 29 #define isapnp_card pci_bus 30 #define isapnp_dev pci_dev 31 #endif 27 #include <linux/pnp.h> 32 28 #include <sound/core.h> 33 29 #define SNDRV_GET_ID … … 97 93 98 94 struct snd_card_als100 { 99 #ifdef __ISAPNP__ 100 struct isapnp_dev *dev; 101 struct isapnp_dev *devmpu; 102 struct isapnp_dev *devopl; 103 #endif /* __ISAPNP__ */ 95 int dev_no; 96 struct pnp_dev *dev; 97 struct pnp_dev *devmpu; 98 struct pnp_dev *devopl; 104 99 }; 105 100 106 static snd_card_t *snd_als100_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 107 108 #ifdef __ISAPNP__ 109 static struct isapnp_card *snd_als100_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 110 static const struct isapnp_card_id *snd_als100_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 111 112 #define ISAPNP_ALS100(_va, _vb, _vc, _device, _audio, _mpu401, _opl) \ 113 { \ 114 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 115 .devs = { ISAPNP_DEVICE_ID('@', '@', '@', _audio), \ 116 ISAPNP_DEVICE_ID('@', 'X', '@', _mpu401), \ 117 ISAPNP_DEVICE_ID('@', 'H', '@', _opl) } \ 118 } 119 120 static struct isapnp_card_id snd_als100_pnpids[] __devinitdata = { 101 static struct pnp_card_device_id snd_als100_pnpids[] __devinitdata = { 121 102 /* ALS100 - PRO16PNP */ 122 ISAPNP_ALS100('A','L','S',0x0001,0x0001,0x0001,0x0001),103 { .id = "ALS0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } } }, 123 104 /* ALS110 - MF1000 - Digimate 3D Sound */ 124 ISAPNP_ALS100('A','L','S',0x0110,0x1001,0x1001,0x1001),105 { .id = "ALS0110", .devs = { { "@@@1001" }, { "@X@1001" }, { "@H@1001" } } }, 125 106 /* ALS120 */ 126 ISAPNP_ALS100('A','L','S',0x0120,0x2001,0x2001,0x2001),107 { .id = "ALS0120", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } }, 127 108 /* ALS200 */ 128 ISAPNP_ALS100('A','L','S',0x0200,0x0020,0x0020,0x0001),109 { .id = "ALS0200", .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0001" } } }, 129 110 /* RTL3000 */ 130 ISAPNP_ALS100('R','T','L',0x3000,0x2001,0x2001,0x2001),131 { ISAPNP_CARD_END, }111 { .id = "RTL3000", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } }, 112 { .id = "", } /* end */ 132 113 }; 133 114 134 ISAPNP_CARD_TABLE(snd_als100_pnpids); 135 136 #endif /* __ISAPNP__ */ 115 MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids); 137 116 138 117 #define DRIVER_NAME "snd-card-als100" 139 118 140 141 #ifdef __ISAPNP__ 142 static int __init snd_card_als100_isapnp(int dev, struct snd_card_als100 *acard) 143 { 144 const struct isapnp_card_id *id = snd_als100_isapnp_id[dev]; 145 struct isapnp_card *card = snd_als100_isapnp_cards[dev]; 146 struct isapnp_dev *pdev; 147 148 acard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); 149 if (acard->dev->active) { 150 acard->dev = NULL; 151 return -EBUSY; 152 } 153 acard->devmpu = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL); 154 if (acard->devmpu->active) { 155 acard->dev = acard->devmpu = NULL; 156 return -EBUSY; 157 } 158 acard->devopl = isapnp_find_dev(card, id->devs[2].vendor, id->devs[2].function, NULL); 159 if (acard->devopl->active) { 160 acard->dev = acard->devmpu = acard->devopl = NULL; 161 return -EBUSY; 162 } 119 static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, 120 struct pnp_card_link *card, 121 const struct pnp_card_device_id *id) 122 { 123 struct pnp_dev *pdev; 124 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 125 int err; 126 127 if (!cfg) 128 return -ENOMEM; 129 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 130 if (acard->dev == NULL) { 131 kfree(cfg); 132 return -ENODEV; 133 } 134 acard->devmpu = pnp_request_card_device(card, id->devs[1].id, acard->dev); 135 acard->devopl = pnp_request_card_device(card, id->devs[2].id, acard->devmpu); 163 136 164 137 pdev = acard->dev; 165 if (pdev->prepare(pdev)<0) 166 return -EAGAIN; 167 138 139 pnp_init_resource_table(cfg); 140 141 /* override resources */ 168 142 if (port[dev] != SNDRV_AUTO_PORT) 169 isapnp_resource_change(&pdev->resource[0], port[dev], 16);143 pnp_resource_change(&cfg->port_resource[0], port[dev], 16); 170 144 if (dma8[dev] != SNDRV_AUTO_DMA) 171 isapnp_resource_change(&pdev->dma_resource[0], dma8[dev], 172 1); 145 pnp_resource_change(&cfg->dma_resource[0], dma8[dev], 1); 173 146 if (dma16[dev] != SNDRV_AUTO_DMA) 174 isapnp_resource_change(&pdev->dma_resource[1], dma16[dev], 175 1); 147 pnp_resource_change(&cfg->dma_resource[1], dma16[dev], 1); 176 148 if (irq[dev] != SNDRV_AUTO_IRQ) 177 isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); 178 179 if (pdev->activate(pdev)<0) { 180 printk(KERN_ERR PFX "AUDIO isapnp configure failure\n"); 181 return -EBUSY; 182 } 183 184 port[dev] = pdev->resource[0].start; 185 dma8[dev] = pdev->dma_resource[1].start; 186 dma16[dev] = pdev->dma_resource[0].start; 187 irq[dev] = pdev->irq_resource[0].start; 149 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 150 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 151 snd_printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n"); 152 err = pnp_activate_dev(pdev); 153 if (err < 0) { 154 snd_printk(KERN_ERR PFX "AUDIO pnp configure failure\n"); 155 kfree(cfg); 156 return err; 157 } 158 port[dev] = pnp_port_start(pdev, 0); 159 dma8[dev] = pnp_dma(pdev, 1); 160 dma16[dev] = pnp_dma(pdev, 0); 161 irq[dev] = pnp_irq(pdev, 0); 188 162 189 163 pdev = acard->devmpu; 190 if (pdev == NULL || pdev->prepare(pdev)<0) { 191 mpu_port[dev] = -1; 192 return 0; 193 } 194 164 if (pdev != NULL) { 165 pnp_init_resource_table(cfg); 195 166 if (mpu_port[dev] != SNDRV_AUTO_PORT) 196 isapnp_resource_change(&pdev->resource[0], mpu_port[dev], 197 2); 167 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); 198 168 if (mpu_irq[dev] != SNDRV_AUTO_IRQ) 199 isapnp_resource_change(&pdev->irq_resource[0], mpu_irq[dev], 200 1); 201 202 if (pdev->activate(pdev)<0) { 203 printk(KERN_ERR PFX "MPU-401 isapnp configure failure\n"); 204 mpu_port[dev] = -1; 205 acard->devmpu = NULL; 169 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); 170 if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0) 171 snd_printk(KERN_ERR PFX "MPU401 the requested resources are invalid, using auto config\n"); 172 err = pnp_activate_dev(pdev); 173 if (err < 0) 174 goto __mpu_error; 175 mpu_port[dev] = pnp_port_start(pdev, 0); 176 mpu_irq[dev] = pnp_irq(pdev, 0); 206 177 } else { 207 mpu_port[dev] = pdev->resource[0].start; 208 mpu_irq[dev] = pdev->irq_resource[0].start; 178 __mpu_error: 179 if (pdev) { 180 pnp_release_card_device(pdev); 181 snd_printk(KERN_ERR PFX "MPU401 pnp configure failure, skipping\n"); 182 } 183 acard->devmpu = NULL; 184 mpu_port[dev] = -1; 209 185 } 210 186 211 187 pdev = acard->devopl; 212 if (pdev == NULL || pdev->prepare(pdev)<0) { 213 fm_port[dev] = -1; 214 return 0; 215 } 216 217 if (fm_port[dev] != SNDRV_AUTO_PORT) 218 isapnp_resource_change(&pdev->resource[0], fm_port[dev], 4); 219 220 if (pdev->activate(pdev)<0) { 221 printk(KERN_ERR PFX "OPL isapnp configure failure\n"); 222 fm_port[dev] = -1; 188 if (pdev != NULL) { 189 pnp_init_resource_table(cfg); 190 if (fm_port[dev] != SNDRV_AUTO_PORT) 191 pnp_resource_change(&cfg->port_resource[0], fm_port[dev], 4); 192 if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0) 193 snd_printk(KERN_ERR PFX "OPL3 the requested resources are invalid, using auto config\n"); 194 err = pnp_activate_dev(pdev); 195 if (err < 0) 196 goto __fm_error; 197 fm_port[dev] = pnp_port_start(pdev, 0); 198 } else { 199 __fm_error: 200 if (pdev) { 201 pnp_release_card_device(pdev); 202 snd_printk(KERN_ERR PFX "OPL3 pnp configure failure, skipping\n"); 203 } 223 204 acard->devopl = NULL; 224 } else {225 fm_port[dev] = pdev->resource[0].start;226 } 227 205 fm_port[dev] = -1; 206 } 207 208 kfree(cfg); 228 209 return 0; 229 210 } 230 211 231 static void snd_card_als100_deactivate(struct snd_card_als100 *acard) 232 { 233 if (acard->dev) { 234 acard->dev->deactivate(acard->dev); 235 acard->dev = NULL; 236 } 237 if (acard->devmpu) { 238 acard->devmpu->deactivate(acard->devmpu); 239 acard->devmpu = NULL; 240 } 241 if (acard->devopl) { 242 acard->devopl->deactivate(acard->devopl); 243 acard->devopl = NULL; 244 } 245 } 246 #endif /* __ISAPNP__ */ 247 248 static void snd_card_als100_free(snd_card_t *card) 249 { 250 struct snd_card_als100 *acard = (struct snd_card_als100 *)card->private_data; 251 252 if (acard) { 253 #ifdef __ISAPNP__ 254 snd_card_als100_deactivate(acard); 255 #endif /* __ISAPNP__ */ 256 } 257 } 258 259 static int __init snd_card_als100_probe(int dev) 212 static int __init snd_card_als100_probe(int dev, 213 struct pnp_card_link *pcard, 214 const struct pnp_card_device_id *pid) 260 215 { 261 216 int error; … … 269 224 return -ENOMEM; 270 225 acard = (struct snd_card_als100 *)card->private_data; 271 card->private_free = snd_card_als100_free; 272 273 #ifdef __ISAPNP__ 274 if ((error = snd_card_als100_isapnp(dev, acard))) { 275 snd_card_free(card); 276 return error; 277 } 278 #else 279 printk(KERN_ERR PFX "you have to enable PnP support ...\n"); 280 snd_card_free(card); 281 return -ENOSYS; 282 #endif /* __ISAPNP__ */ 226 227 if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) { 228 snd_card_free(card); 229 return error; 230 } 283 231 284 232 if ((error = snd_sbdsp_create(card, port[dev], … … 307 255 mpu_irq[dev], SA_INTERRUPT, 308 256 NULL) < 0) 309 printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]);257 snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]); 310 258 } 311 259 … … 314 262 fm_port[dev], fm_port[dev] + 2, 315 263 OPL3_HW_AUTO, 0, &opl3) < 0) { 316 printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n",264 snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n", 317 265 fm_port[dev], fm_port[dev] + 2); 318 266 } else { … … 337 285 return error; 338 286 } 339 snd_als100_cards[dev] = card;287 pnp_set_card_drvdata(pcard, card); 340 288 return 0; 341 289 } 342 290 343 #ifdef __ISAPNP__ 344 static int __init snd_als100_isapnp_detect(struct isapnp_card *card, 345 const struct isapnp_card_id *id) 291 static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card, 292 const struct pnp_card_device_id *id) 346 293 { 347 294 static int dev; … … 351 298 if (!enable[dev]) 352 299 continue; 353 snd_als100_isapnp_cards[dev] = card; 354 snd_als100_isapnp_id[dev] = id; 355 res = snd_card_als100_probe(dev); 300 res = snd_card_als100_probe(dev, card, id); 356 301 if (res < 0) 357 302 return res; … … 361 306 return -ENODEV; 362 307 } 363 #endif 308 309 static void __devexit snd_als100_pnp_remove(struct pnp_card_link * pcard) 310 { 311 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 312 313 snd_card_disconnect(card); 314 snd_card_free_in_thread(card); 315 } 316 317 static struct pnp_card_driver als100_pnpc_driver = { 318 .flags = PNP_DRIVER_RES_DISABLE, 319 .name = "als100", 320 .id_table = snd_als100_pnpids, 321 .probe = snd_als100_pnp_detect, 322 .remove = __devexit_p(snd_als100_pnp_remove), 323 }; 364 324 365 325 static int __init alsa_card_als100_init(void) … … 367 327 int cards = 0; 368 328 369 #ifdef __ISAPNP__ 370 cards += isapnp_probe_cards(snd_als100_pnpids, snd_als100_isapnp_detect); 371 #else 372 printk(KERN_ERR PFX "you have to enable ISA PnP support.\n"); 373 #endif 329 cards += pnp_register_card_driver(&als100_pnpc_driver); 374 330 #ifdef MODULE 375 if (!cards) 376 printk(KERN_ERR "no ALS100 based soundcards found\n"); 331 if (!cards) { 332 pnp_unregister_card_driver(&als100_pnpc_driver); 333 snd_printk(KERN_ERR "no ALS100 based soundcards found\n"); 334 } 377 335 #endif 378 336 return cards ? 0 : -ENODEV; … … 381 339 static void __exit alsa_card_als100_exit(void) 382 340 { 383 int dev; 384 385 for (dev = 0; dev < SNDRV_CARDS; dev++) 386 snd_card_free(snd_als100_cards[dev]); 341 pnp_unregister_card_driver(&als100_pnpc_driver); 387 342 } 388 343 -
GPL/branches/alsa-resync1/alsa-kernel/isa/azt2320.c
r224 r246 37 37 #include <linux/time.h> 38 38 #include <linux/wait.h> 39 #include <linux/pnp.h> 39 40 #include <sound/core.h> 40 41 #define SNDRV_GET_ID … … 105 106 106 107 struct snd_card_azt2320 { 107 #ifdef __ISAPNP__ 108 struct isapnp_dev *dev; 109 struct isapnp_dev *devmpu; 110 #endif /* __ISAPNP__ */ 108 #ifdef CONFIG_PNP 109 int dev_no; 110 struct pnp_dev *dev; 111 struct pnp_dev *devmpu; 112 #endif /* CONFIG_PNP */ 111 113 }; 112 114 113 static snd_card_t *snd_azt2320_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 114 115 #ifdef __ISAPNP__ 116 117 static struct isapnp_card *snd_azt2320_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 118 static const struct isapnp_card_id *snd_azt2320_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 119 120 #define ISAPNP_AZT2320(_va, _vb, _vc, _device, _audio, _mpu401) \ 121 { \ 122 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 123 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), \ 124 ISAPNP_DEVICE_ID(_va, _vb, _vc, _mpu401), } \ 125 } 126 127 static struct isapnp_card_id snd_azt2320_pnpids[] __devinitdata = { 115 static struct pnp_card_device_id snd_azt2320_pnpids[] __devinitdata = { 128 116 /* PRO16V */ 129 ISAPNP_AZT2320('A','Z','T',0x1008,0x1008,0x2001),117 { .id = "AZT1008", .devs = { { "AZT1008" }, { "AZT2001" }, } }, 130 118 /* Aztech Sound Galaxy 16 */ 131 ISAPNP_AZT2320('A','Z','T',0x2320,0x0001,0x0002),119 { .id = "AZT2320", .devs = { { "AZT0001" }, { "AZT0002" }, } }, 132 120 /* Packard Bell Sound III 336 AM/SP */ 133 ISAPNP_AZT2320('A','Z','T',0x3000,0x1003,0x2001),121 { .id = "AZT3000", .devs = { { "AZT1003" }, { "AZT2001" }, } }, 134 122 /* AT3300 */ 135 ISAPNP_AZT2320('A','Z','T',0x3002,0x1004,0x2001),123 { .id = "AZT3002", .devs = { { "AZT1004" }, { "AZT2001" }, } }, 136 124 /* --- */ 137 ISAPNP_AZT2320('A','Z','T',0x3005,0x1003,0x2001),125 { .id = "AZT3005", .devs = { { "AZT1003" }, { "AZT2001" }, } }, 138 126 /* --- */ 139 ISAPNP_AZT2320('A','Z','T',0x3011,0x1003,0x2001),140 { ISAPNP_CARD_END,} /* end */127 { .id = "AZT3011", .devs = { { "AZT1003" }, { "AZT2001" }, } }, 128 { .id = "" } /* end */ 141 129 }; 142 130 143 ISAPNP_CARD_TABLE(snd_azt2320_pnpids); 144 145 #endif /* __ISAPNP__ */ 131 MODULE_DEVICE_TABLE(pnp_card, snd_azt2320_pnpids); 146 132 147 133 #define DRIVER_NAME "snd-card-azt2320" 148 134 149 150 #ifdef __ISAPNP__ 151 static int __init snd_card_azt2320_isapnp(int dev, struct snd_card_azt2320 *acard)152 { 153 const struct isapnp_card_id *id = snd_azt2320_isapnp_id[dev];154 struct isapnp_card *card = snd_azt2320_isapnp_cards[dev];155 struct isapnp_dev *pdev;156 157 acard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL);158 if (acard->dev->active) {159 acard->dev = NULL; 160 return -EBUSY;161 }162 acard->devmpu = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL);163 if (acard->devmpu->active) {164 acard->dev = acard->devmpu = NULL;165 return -EBUSY; 166 }135 static int __devinit snd_card_azt2320_pnp(int dev, struct snd_card_azt2320 *acard, 136 struct pnp_card_link *card, 137 const struct pnp_card_device_id *id) 138 { 139 struct pnp_dev *pdev; 140 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); 141 int err; 142 143 if (!cfg) 144 return -ENOMEM; 145 146 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 147 if (acard->dev == NULL) { 148 kfree(cfg); 149 return -ENODEV; 150 } 151 152 acard->devmpu = pnp_request_card_device(card, id->devs[1].id, NULL); 167 153 168 154 pdev = acard->dev; 169 if (pdev->prepare(pdev) < 0)170 return -EAGAIN; 171 155 pnp_init_resource_table(cfg); 156 157 /* override resources */ 172 158 if (port[dev] != SNDRV_AUTO_PORT) 173 isapnp_resource_change(&pdev->resource[0], port[dev], 16);159 pnp_resource_change(&cfg->port_resource[0], port[dev], 16); 174 160 if (fm_port[dev] != SNDRV_AUTO_PORT) 175 isapnp_resource_change(&pdev->resource[1], fm_port[dev], 4);161 pnp_resource_change(&cfg->port_resource[1], fm_port[dev], 4); 176 162 if (wss_port[dev] != SNDRV_AUTO_PORT) 177 isapnp_resource_change(&pdev->resource[2], wss_port[dev], 178 4); 163 pnp_resource_change(&cfg->port_resource[2], wss_port[dev], 4); 179 164 if (dma1[dev] != SNDRV_AUTO_DMA) 180 isapnp_resource_change(&pdev->dma_resource[0], dma1[dev], 181 1); 165 pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1); 182 166 if (dma2[dev] != SNDRV_AUTO_DMA) 183 isapnp_resource_change(&pdev->dma_resource[1], dma2[dev], 184 1); 167 pnp_resource_change(&cfg->dma_resource[1], dma2[dev], 1); 185 168 if (irq[dev] != SNDRV_AUTO_IRQ) 186 isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); 187 188 if (pdev->activate(pdev) < 0) { 189 printk(KERN_ERR PFX "AUDIO isapnp configure failure\n"); 190 return -EBUSY; 191 } 192 193 port[dev] = pdev->resource[0].start; 194 fm_port[dev] = pdev->resource[1].start; 195 wss_port[dev] = pdev->resource[2].start; 196 dma1[dev] = pdev->dma_resource[0].start; 197 dma2[dev] = pdev->dma_resource[1].start; 198 irq[dev] = pdev->irq_resource[0].start; 169 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 170 if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0) 171 snd_printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n"); 172 173 err = pnp_activate_dev(pdev); 174 if (err < 0) { 175 snd_printk(KERN_ERR PFX "AUDIO pnp configure failure\n"); 176 kfree(cfg); 177 return err; 178 } 179 port[dev] = pnp_port_start(pdev, 0); 180 fm_port[dev] = pnp_port_start(pdev, 1); 181 wss_port[dev] = pnp_port_start(pdev, 2); 182 dma1[dev] = pnp_dma(pdev, 0); 183 dma2[dev] = pnp_dma(pdev, 1); 184 irq[dev] = pnp_irq(pdev, 0); 199 185 200 186 pdev = acard->devmpu; 201 if (pdev == NULL || pdev->prepare(pdev) < 0) { 202 mpu_port[dev] = -1; 203 return 0; 204 } 205 187 if (pdev != NULL) { 188 pnp_init_resource_table(cfg); 206 189 if (mpu_port[dev] != SNDRV_AUTO_PORT) 207 isapnp_resource_change(&pdev->resource[0], mpu_port[dev], 208 2); 190 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); 209 191 if (mpu_irq[dev] != SNDRV_AUTO_IRQ) 210 isapnp_resource_change(&pdev->irq_resource[0], mpu_irq[dev],211 1);212 213 if (pdev->activate(pdev) < 0) {214 /* not fatal error */215 printk(KERN_ERR PFX "MPU-401 isapnp configure failure\n");216 mpu_port[dev] = -1;217 acard->devmpu = NULL;192 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); 193 if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0) 194 snd_printk(KERN_ERR PFX "MPU401 the requested resources are invalid, using auto config\n"); 195 err = pnp_activate_dev(pdev); 196 if (err < 0) 197 goto __mpu_error; 198 mpu_port[dev] = pnp_port_start(pdev, 0); 199 mpu_irq[dev] = pnp_irq(pdev, 0); 218 200 } else { 219 mpu_port[dev] = pdev->resource[0].start; 220 mpu_irq[dev] = pdev->irq_resource[0].start; 221 } 222 201 __mpu_error: 202 if (pdev) { 203 pnp_release_card_device(pdev); 204 snd_printk(KERN_ERR PFX "MPU401 pnp configure failure, skipping\n"); 205 } 206 acard->devmpu = NULL; 207 mpu_port[dev] = -1; 208 } 209 210 kfree (cfg); 223 211 return 0; 224 212 } 225 213 226 static void snd_card_azt2320_deactivate(struct snd_card_azt2320 *acard)227 {228 if (acard->dev)229 acard->dev->deactivate(acard->dev);230 if (acard->devmpu)231 acard->devmpu->deactivate(acard->devmpu);232 }233 #endif /* __ISAPNP__ */234 235 214 /* same of snd_sbdsp_command by Jaroslav Kysela */ 236 static int __ init snd_card_azt2320_command(unsigned long port, unsigned char val)215 static int __devinit snd_card_azt2320_command(unsigned long port, unsigned char val) 237 216 { 238 217 int i; … … 240 219 241 220 limit = jiffies + HZ / 10; 242 for (i = 50000; i && (limit - jiffies) > 0; i--)221 for (i = 50000; i && time_after(limit, jiffies); i--) 243 222 if (!(inb(port + 0x0c) & 0x80)) { 244 223 outb(val, port + 0x0c); … … 248 227 } 249 228 250 static int __ init snd_card_azt2320_enable_wss(unsigned long port)229 static int __devinit snd_card_azt2320_enable_wss(unsigned long port) 251 230 { 252 231 int error; … … 261 240 } 262 241 263 static void snd_card_azt2320_free(snd_card_t *card) 264 { 265 struct snd_card_azt2320 *acard = (struct snd_card_azt2320 *)card->private_data; 266 267 if (acard) { 268 #ifdef __ISAPNP__ 269 snd_card_azt2320_deactivate(acard); 270 #endif /* __ISAPNP__ */ 271 } 272 } 273 274 static int __init snd_card_azt2320_probe(int dev) 242 static int __devinit snd_card_azt2320_probe(int dev, 243 struct pnp_card_link *pcard, 244 const struct pnp_card_device_id *pid) 275 245 { 276 246 int error; … … 284 254 return -ENOMEM; 285 255 acard = (struct snd_card_azt2320 *)card->private_data; 286 card->private_free = snd_card_azt2320_free; 287 288 #ifdef __ISAPNP__ 289 if ((error = snd_card_azt2320_isapnp(dev, acard))) { 290 snd_card_free(card); 291 return error; 292 } 293 #endif /* __ISAPNP__ */ 256 257 if ((error = snd_card_azt2320_pnp(dev, acard, pcard, pid))) { 258 snd_card_free(card); 259 return error; 260 } 294 261 295 262 if ((error = snd_card_azt2320_enable_wss(port[dev]))) { … … 325 292 mpu_irq[dev], SA_INTERRUPT, 326 293 NULL) < 0) 327 printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", 328 mpu_port[dev]); 294 snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]); 329 295 } 330 296 … … 333 299 fm_port[dev], fm_port[dev] + 2, 334 300 OPL3_HW_AUTO, 0, &opl3) < 0) { 335 printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n",301 snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n", 336 302 fm_port[dev], fm_port[dev] + 2); 337 303 } else { … … 356 322 return error; 357 323 } 358 snd_azt2320_cards[dev] = card;324 pnp_set_card_drvdata(pcard, card); 359 325 return 0; 360 326 } 361 327 362 #ifdef __ISAPNP__ 363 static int __init snd_azt2320_isapnp_detect(struct isapnp_card *card, 364 const struct isapnp_card_id *id) 328 static int __devinit snd_azt2320_pnp_detect(struct pnp_card_link *card, 329 const struct pnp_card_device_id *id) 365 330 { 366 331 static int dev; … … 370 335 if (!enable[dev]) 371 336 continue; 372 snd_azt2320_isapnp_cards[dev] = card; 373 snd_azt2320_isapnp_id[dev] = id; 374 res = snd_card_azt2320_probe(dev); 337 res = snd_card_azt2320_probe(dev, card, id); 375 338 if (res < 0) 376 339 return res; … … 380 343 return -ENODEV; 381 344 } 382 #endif 345 346 static void __devexit snd_azt2320_pnp_remove(struct pnp_card_link * pcard) 347 { 348 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 349 350 snd_card_disconnect(card); 351 snd_card_free_in_thread(card); 352 } 353 354 static struct pnp_card_driver azt2320_pnpc_driver = { 355 .flags = PNP_DRIVER_RES_DISABLE, 356 .name = "azt2320", 357 .id_table = snd_azt2320_pnpids, 358 .probe = snd_azt2320_pnp_detect, 359 .remove = __devexit_p(snd_azt2320_pnp_remove), 360 }; 383 361 384 362 static int __init alsa_card_azt2320_init(void) … … 386 364 int cards = 0; 387 365 388 #ifdef __ISAPNP__ 389 cards += isapnp_probe_cards(snd_azt2320_pnpids, snd_azt2320_isapnp_detect); 390 #else 391 printk(KERN_ERR PFX "you have to enable ISA PnP support.\n"); 392 #endif 366 cards += pnp_register_card_driver(&azt2320_pnpc_driver); 393 367 #ifdef MODULE 394 if (!cards) 395 printk(KERN_ERR "no AZT2320 based soundcards found\n"); 368 if (!cards) { 369 pnp_unregister_card_driver(&azt2320_pnpc_driver); 370 snd_printk(KERN_ERR "no AZT2320 based soundcards found\n"); 371 } 396 372 #endif 397 373 return cards ? 0 : -ENODEV; … … 400 376 static void __exit alsa_card_azt2320_exit(void) 401 377 { 402 int dev; 403 404 for (dev = 0; dev < SNDRV_CARDS; dev++) 405 snd_card_free(snd_azt2320_cards[dev]); 378 pnp_unregister_card_driver(&azt2320_pnpc_driver); 406 379 } 407 380 -
GPL/branches/alsa-resync1/alsa-kernel/isa/cmi8330.c
r224 r246 47 47 #include <linux/init.h> 48 48 #include <linux/slab.h> 49 #ifndef LINUX_ISAPNP_H 50 #include <linux/isapnp.h> 51 #define isapnp_card pci_bus 52 #define isapnp_dev pci_dev 53 #endif 49 #include <linux/pnp.h> 54 50 #include <sound/core.h> 55 51 #include <sound/ad1848.h> … … 74 70 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 75 71 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; 76 #ifdef __ISAPNP__72 #ifdef CONFIG_PNP 77 73 #ifdef TARGET_OS2 78 74 static int isapnp[SNDRV_CARDS] = {REPEAT_SNDRV(1)}; … … 98 94 MODULE_PARM_DESC(enable, "Enable CMI8330 soundcard."); 99 95 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); 100 #ifdef __ISAPNP__96 #ifdef CONFIG_PNP 101 97 MODULE_PARM(isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 102 MODULE_PARM_DESC(isapnp, " ISAPnP detection for specified soundcard.");98 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard."); 103 99 MODULE_PARM_SYNTAX(isapnp, SNDRV_ISAPNP_DESC); 104 100 #endif … … 161 157 162 158 struct snd_cmi8330 { 163 #ifdef __ISAPNP__164 struct isapnp_dev *cap;165 struct isapnp_dev *play;159 #ifdef CONFIG_PNP 160 struct pnp_dev *cap; 161 struct pnp_dev *play; 166 162 #endif 167 163 snd_card_t *card; … … 177 173 }; 178 174 179 static snd_card_t *snd_cmi8330_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 180 181 #ifdef __ISAPNP__ 182 183 static struct isapnp_card *snd_cmi8330_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 184 static const struct isapnp_card_id *snd_cmi8330_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 185 186 #define ISAPNP_CMI8330(_va, _vb, _vc, _device, _audio1, _audio2) \ 187 { \ 188 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 189 .devs = { ISAPNP_DEVICE_ID('@', '@', '@', _audio1), \ 190 ISAPNP_DEVICE_ID('@', 'X', '@', _audio2), } \ 191 } 192 193 static struct isapnp_card_id snd_cmi8330_pnpids[] __devinitdata = 194 { 195 ISAPNP_CMI8330('C','M','I',0x0001,0x0001,0x0001), 196 { ISAPNP_CARD_END, } 175 static snd_card_t *snd_cmi8330_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 176 177 #ifdef CONFIG_PNP 178 179 static struct pnp_card_device_id snd_cmi8330_pnpids[] __devinitdata = { 180 { .id = "CMI0001", .devs = { { "@@@0001" }, { "@X@0001" } } }, 181 { .id = "" } 197 182 }; 198 183 199 ISAPNP_CARD_TABLE(snd_cmi8330_pnpids);184 MODULE_DEVICE_TABLE(pnp_card, snd_cmi8330_pnpids); 200 185 201 186 #endif … … 263 248 264 249 265 static int __ init cmi8330_add_sb_mixers(sb_t *chip)250 static int __devinit cmi8330_add_sb_mixers(sb_t *chip) 266 251 { 267 252 int idx, err; … … 288 273 #endif 289 274 290 static int __ init snd_cmi8330_mixer(snd_card_t *card, struct snd_cmi8330 *acard)275 static int __devinit snd_cmi8330_mixer(snd_card_t *card, struct snd_cmi8330 *acard) 291 276 { 292 277 unsigned int idx; … … 307 292 } 308 293 309 #ifdef __ISAPNP__ 310 static int __init snd_cmi8330_isapnp(int dev, struct snd_cmi8330 *acard) 311 { 312 const struct isapnp_card_id *id = snd_cmi8330_isapnp_id[dev]; 313 struct isapnp_card *card = snd_cmi8330_isapnp_cards[dev]; 314 struct isapnp_dev *pdev; 315 316 acard->cap = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); 317 if (acard->cap->active) { 318 acard->cap = NULL; 294 #ifdef CONFIG_PNP 295 static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard, 296 struct pnp_card_link *card, 297 const struct pnp_card_device_id *id) 298 { 299 struct pnp_dev *pdev; 300 struct pnp_resource_table * cfg = kmalloc(GFP_ATOMIC, sizeof(struct pnp_resource_table)); 301 int err; 302 303 acard->cap = pnp_request_card_device(card, id->devs[0].id, NULL); 304 if (acard->cap == NULL) { 305 kfree(cfg); 319 306 return -EBUSY; 320 307 } 321 acard->play = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL);322 if (acard->play ->active) {323 acard->cap = acard->play = NULL;308 acard->play = pnp_request_card_device(card, id->devs[1].id, NULL); 309 if (acard->play == NULL) { 310 kfree(cfg); 324 311 return -EBUSY; 325 312 } 326 313 327 314 pdev = acard->cap; 328 if (pdev->prepare(pdev)<0) 329 return -EAGAIN; 315 pnp_init_resource_table(cfg); 330 316 /* allocate AD1848 resources */ 331 317 if (wssport[dev] != SNDRV_AUTO_PORT) 332 isapnp_resource_change(&pdev->resource[0], wssport[dev], 8);318 pnp_resource_change(&cfg->port_resource[0], wssport[dev], 8); 333 319 if (wssdma[dev] != SNDRV_AUTO_DMA) 334 isapnp_resource_change(&pdev->dma_resource[0], wssdma[dev], 1);320 pnp_resource_change(&cfg->dma_resource[0], wssdma[dev], 1); 335 321 if (wssirq[dev] != SNDRV_AUTO_IRQ) 336 isapnp_resource_change(&pdev->irq_resource[0], wssirq[dev], 1); 337 338 if (pdev->activate(pdev)<0) { 339 snd_printk("(AD1848) PnP configure failure\n"); 322 pnp_resource_change(&cfg->irq_resource[0], wssirq[dev], 1); 323 324 err = pnp_manual_config_dev(pdev, cfg, 0); 325 if (err < 0) 326 snd_printk(KERN_ERR "CMI8330/C3D (AD1848) PnP manual resources are invalid, using auto config\n"); 327 err = pnp_activate_dev(pdev); 328 if (err < 0) { 329 snd_printk(KERN_ERR "CMI8330/C3D (AD1848) PnP configure failure\n"); 330 kfree(cfg); 340 331 return -EBUSY; 341 332 } 342 wssport[dev] = p dev->resource[0].start;343 wssdma[dev] = p dev->dma_resource[0].start;344 wssirq[dev] = p dev->irq_resource[0].start;333 wssport[dev] = pnp_port_start(pdev, 0); 334 wssdma[dev] = pnp_dma(pdev, 0); 335 wssirq[dev] = pnp_irq(pdev, 0); 345 336 346 337 /* allocate SB16 resources */ 347 338 pdev = acard->play; 348 if (pdev->prepare(pdev)<0) { 349 acard->cap->deactivate(acard->cap); 350 return -EAGAIN; 351 } 339 pnp_init_resource_table(cfg); 352 340 if (sbport[dev] != SNDRV_AUTO_PORT) 353 isapnp_resource_change(&pdev->resource[0], sbport[dev], 16);341 pnp_resource_change(&cfg->port_resource[0], sbport[dev], 16); 354 342 if (sbdma8[dev] != SNDRV_AUTO_DMA) 355 isapnp_resource_change(&pdev->dma_resource[0], sbdma8[dev], 1);343 pnp_resource_change(&cfg->dma_resource[0], sbdma8[dev], 1); 356 344 if (sbdma16[dev] != SNDRV_AUTO_DMA) 357 isapnp_resource_change(&pdev->dma_resource[1], sbdma16[dev], 1);345 pnp_resource_change(&cfg->dma_resource[1], sbdma16[dev], 1); 358 346 if (sbirq[dev] != SNDRV_AUTO_IRQ) 359 isapnp_resource_change(&pdev->irq_resource[0], sbirq[dev], 1); 360 361 if (pdev->activate(pdev)<0) { 362 snd_printk("CMI8330/C3D (SB16) PnP configure failure\n"); 363 acard->cap->deactivate(acard->cap); 347 pnp_resource_change(&cfg->irq_resource[0], sbirq[dev], 1); 348 349 err = pnp_manual_config_dev(pdev, cfg, 0); 350 if (err < 0) 351 snd_printk(KERN_ERR "CMI8330/C3D (SB16) PnP manual resources are invalid, using auto config\n"); 352 err = pnp_activate_dev(pdev); 353 if (err < 0) { 354 snd_printk(KERN_ERR "CMI8330/C3D (SB16) PnP configure failure\n"); 355 kfree(cfg); 364 356 return -EBUSY; 365 357 } 366 sbport[dev] = pdev->resource[0].start; 367 sbdma8[dev] = pdev->dma_resource[0].start; 368 sbdma16[dev] = pdev->dma_resource[1].start; 369 sbirq[dev] = pdev->irq_resource[0].start; 370 358 sbport[dev] = pnp_port_start(pdev, 0); 359 sbdma8[dev] = pnp_dma(pdev, 0); 360 sbdma16[dev] = pnp_dma(pdev, 1); 361 sbirq[dev] = pnp_irq(pdev, 0); 362 363 kfree(cfg); 371 364 return 0; 372 }373 374 static void snd_cmi8330_deactivate(struct snd_cmi8330 *acard)375 {376 if (acard->cap) {377 acard->cap->deactivate(acard->cap);378 acard->cap = NULL;379 }380 if (acard->play) {381 acard->play->deactivate(acard->play);382 acard->play = NULL;383 }384 365 } 385 366 #endif … … 429 410 } 430 411 431 static int __ init snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip)412 static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip) 432 413 { 433 414 snd_pcm_t *pcm; … … 472 453 */ 473 454 474 static void snd_cmi8330_free(snd_card_t *card) 475 { 476 struct snd_cmi8330 *acard = (struct snd_cmi8330 *)card->private_data; 477 478 if (acard) { 479 #ifdef __ISAPNP__ 480 snd_cmi8330_deactivate(acard); 481 #endif 482 } 483 } 484 485 static int __init snd_cmi8330_probe(int dev) 455 static int __devinit snd_cmi8330_probe(int dev, 456 struct pnp_card_link *pcard, 457 const struct pnp_card_device_id *pid) 486 458 { 487 459 snd_card_t *card; … … 490 462 int i, err; 491 463 492 #ifdef __ISAPNP__464 #ifdef CONFIG_PNP 493 465 if (!isapnp[dev]) { 494 466 #endif … … 501 473 return -EINVAL; 502 474 } 503 #ifdef __ISAPNP__475 #ifdef CONFIG_PNP 504 476 } 505 477 #endif … … 512 484 acard = (struct snd_cmi8330 *)card->private_data; 513 485 acard->card = card; 514 card->private_free = snd_cmi8330_free; 515 516 #ifdef __ISAPNP__ 517 if (isapnp[dev] && (err = snd_cmi8330_isapnp(dev, acard)) < 0) { 486 487 #ifdef CONFIG_PNP 488 if (isapnp[dev] && (err = snd_cmi8330_pnp(dev, acard, pcard, pid)) < 0) { 518 489 snd_printk("PnP detection failed\n"); 519 490 snd_card_free(card); … … 585 556 } 586 557 587 snd_cmi8330_cards[dev] = card; 558 if (pcard) 559 pnp_set_card_drvdata(pcard, card); 560 else 561 snd_cmi8330_legacy[dev] = card; 588 562 return 0; 589 563 } 590 564 591 static void __exit alsa_card_cmi8330_exit(void) 592 { 593 int i; 594 595 for (i = 0; i < SNDRV_CARDS; i++) 596 snd_card_free(snd_cmi8330_cards[i]); 597 } 598 599 #ifdef __ISAPNP__ 600 static int __init snd_cmi8330_isapnp_detect(struct isapnp_card *card, 601 const struct isapnp_card_id *id) 565 #ifdef CONFIG_PNP 566 static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *card, 567 const struct pnp_card_device_id *id) 602 568 { 603 569 static int dev; … … 607 573 if (!enable[dev] || !isapnp[dev]) 608 574 continue; 609 snd_cmi8330_isapnp_cards[dev] = card; 610 snd_cmi8330_isapnp_id[dev] = id; 611 res = snd_cmi8330_probe(dev); 575 res = snd_cmi8330_probe(dev, card, id); 612 576 if (res < 0) 613 577 return res; … … 617 581 return -ENODEV; 618 582 } 619 #endif /* __ISAPNP__ */ 583 584 static void __devexit snd_cmi8330_pnp_remove(struct pnp_card_link * pcard) 585 { 586 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 587 588 snd_card_disconnect(card); 589 snd_card_free_in_thread(card); 590 } 591 592 static struct pnp_card_driver cmi8330_pnpc_driver = { 593 .flags = PNP_DRIVER_RES_DISABLE, 594 .name = "cmi8330", 595 .id_table = snd_cmi8330_pnpids, 596 .probe = snd_cmi8330_pnp_detect, 597 .remove = __devexit_p(snd_cmi8330_pnp_remove), 598 }; 599 #endif /* CONFIG_PNP */ 620 600 621 601 static int __init alsa_card_cmi8330_init(void) … … 626 606 if (!enable[dev]) 627 607 continue; 628 #ifdef __ISAPNP__608 #ifdef CONFIG_PNP 629 609 if (isapnp[dev]) 630 610 continue; 631 611 #endif 632 if (snd_cmi8330_probe(dev ) >= 0)612 if (snd_cmi8330_probe(dev, NULL, NULL) >= 0) 633 613 cards++; 634 614 } 635 #ifdef __ISAPNP__636 cards += isapnp_probe_cards(snd_cmi8330_pnpids, snd_cmi8330_isapnp_detect);615 #ifdef CONFIG_PNP 616 cards += pnp_register_card_driver(&cmi8330_pnpc_driver); 637 617 #endif 638 618 639 619 if (!cards) { 620 #ifdef CONFIG_PNP 621 pnp_unregister_card_driver(&cmi8330_pnpc_driver); 622 #endif 640 623 #ifdef MODULE 641 printk(KERN_ERR "CMI8330 not found or device busy\n");624 snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); 642 625 #endif 643 626 return -ENODEV; 644 627 } 645 628 return 0; 629 } 630 631 static void __exit alsa_card_cmi8330_exit(void) 632 { 633 int i; 634 635 #ifdef CONFIG_PNP 636 /* PnP cards first */ 637 pnp_unregister_card_driver(&cmi8330_pnpc_driver); 638 #endif 639 for (i = 0; i < SNDRV_CARDS; i++) 640 snd_card_free(snd_cmi8330_legacy[i]); 646 641 } 647 642 … … 675 670 get_option(&str,&wssirq[nr_dev]) == 2 && 676 671 get_option(&str,&wssdma[nr_dev]) == 2); 677 #ifdef __ISAPNP__672 #ifdef CONFIG_PNP 678 673 if (pnp != INT_MAX) 679 674 isapnp[nr_dev] = pnp; -
GPL/branches/alsa-resync1/alsa-kernel/isa/cs423x/cs4231_lib.c
r224 r246 449 449 int result = 0; 450 450 unsigned int what; 451 struct list_head *pos; 451 452 snd_pcm_substream_t *s; 452 453 int do_start; … … 468 469 469 470 what = 0; 470 s = substream;471 do {471 snd_pcm_group_for_each(pos, substream) { 472 s = snd_pcm_group_substream_entry(pos); 472 473 if (s == chip->playback_substream) { 473 474 what |= CS4231_PLAYBACK_ENABLE; … … 477 478 snd_pcm_trigger_done(s, substream); 478 479 } 479 s = s->link_next; 480 } while (s != substream); 480 } 481 481 spin_lock(&chip->reg_lock); 482 482 if (do_start) { … … 968 968 } 969 969 970 voidsnd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs)971 { 972 cs4231_t *chip = snd_magic_cast(cs4231_t, dev_id, return );970 irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) 971 { 972 cs4231_t *chip = snd_magic_cast(cs4231_t, dev_id, return IRQ_NONE); 973 973 unsigned char status; 974 974 … … 999 999 snd_cs4231_outm(chip, CS4231_IRQ_STATUS, ~CS4231_ALL_IRQS | ~status, 0); 1000 1000 spin_unlock(&chip->reg_lock); 1001 return IRQ_HANDLED; 1001 1002 } 1002 1003 -
GPL/branches/alsa-resync1/alsa-kernel/isa/cs423x/cs4236.c
r224 r246 23 23 #include <linux/init.h> 24 24 #include <linux/slab.h> 25 #ifndef LINUX_ISAPNP_H 26 #include <linux/isapnp.h> 27 #define isapnp_card pci_bus 28 #define isapnp_dev pci_dev 29 #endif 25 #include <linux/pnp.h> 30 26 #include <sound/core.h> 31 27 #include <sound/cs4231.h> … … 88 84 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 89 85 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 90 #ifdef __ISAPNP__86 #ifdef CONFIG_PNP 91 87 #ifdef TARGET_OS2 92 88 static int isapnp[SNDRV_CARDS] = {1,1,1,1,1,1,1,1}; … … 114 110 MODULE_PARM_DESC(enable, "Enable " IDENT " soundcard."); 115 111 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); 116 #ifdef __ISAPNP__112 #ifdef CONFIG_PNP 117 113 MODULE_PARM(isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 118 114 MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard."); … … 149 145 struct snd_card_cs4236 { 150 146 struct resource *res_sb_port; 151 #ifdef __ISAPNP__152 struct isapnp_dev *wss;153 struct isapnp_dev *ctrl;154 struct isapnp_dev *mpu;147 #ifdef CONFIG_PNP 148 struct pnp_dev *wss; 149 struct pnp_dev *ctrl; 150 struct pnp_dev *mpu; 155 151 #endif 156 152 }; 157 153 158 static snd_card_t *snd_cs4236_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 159 160 #ifdef __ISAPNP__ 161 162 static struct isapnp_card *snd_cs4236_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 163 static const struct isapnp_card_id *snd_cs4236_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 154 static snd_card_t *snd_cs4236_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 155 156 #ifdef CONFIG_PNP 164 157 165 158 #ifdef TARGET_OS2 … … 209 202 210 203 #ifdef CS4232 211 static struct isapnp_card_id snd_card_pnpids[] __devinitdata = {204 static struct pnp_card_device_id snd_cs423x_pnpids[] __devinitdata = { 212 205 /* Philips PCA70PS */ 213 ISAPNP_CS4232_1('C','S','C',0x0d32,0x0000,0x0010,0xb006),206 { .id = "CSC0d32", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } }, 214 207 /* TerraTec Maestro 32/96 (CS4232) */ 215 ISAPNP_CS4232('C','S','C',0x1a32,0x0000,0x0010,0x0003),208 { .id = "CSC1a32", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 216 209 /* HP Omnibook 5500 onboard */ 217 ISAPNP_CS4232('C','S','C',0x4232,0x0000,0x0002,0x0003),210 { .id = "CSC4232", .devs = { { "CSC0000" }, { "CSC0002" }, { "CSC0003" } } }, 218 211 /* Unnamed CS4236 card (Made in Taiwan) */ 219 ISAPNP_CS4232('C','S','C',0x4236,0x0000,0x0010,0x0003),212 { .id = "CSC4236", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 220 213 /* Turtle Beach TBS-2000 (CS4232) */ 221 ISAPNP_CS4232('C','S','C',0x7532,0x0000,0x0010,0xb006),214 { .id = "CSC7532", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSCb006" } } }, 222 215 /* Turtle Beach Tropez Plus (CS4232) */ 223 ISAPNP_CS4232_1('C','S','C',0x7632,0x0000,0x0010,0xb006),216 { .id = "CSC7632", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } }, 224 217 /* SIC CrystalWave 32 (CS4232) */ 225 ISAPNP_CS4232('C','S','C',0xf032,0x0000,0x0010,0x0003),218 { .id = "CSCf032", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 226 219 /* --- */ 227 { ISAPNP_CARD_END,} /* end */220 { .id = "" } /* end */ 228 221 }; 229 222 #else /* CS4236 */ 230 static struct isapnp_card_id snd_card_pnpids[] __devinitdata = {223 static struct pnp_card_device_id snd_cs423x_pnpids[] __devinitdata = { 231 224 /* Intel Marlin Spike Motherboard - CS4235 */ 232 ISAPNP_CS4232('C','S','C',0x0225,0x0000,0x0010,0x0003),225 { .id = "CSC0225", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 233 226 /* Intel Marlin Spike Motherboard (#2) - CS4235 */ 234 ISAPNP_CS4232('C','S','C',0x0225,0x0100,0x0110,0x0103),227 { .id = "CSC0225", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } }, 235 228 /* Genius Sound Maker 3DJ - CS4237B */ 236 ISAPNP_CS4232('C','S','C',0x0437,0x0000,0x0010,0x0003),229 { .id = "CSC0437", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 237 230 /* Digital PC 5000 Onboard - CS4236B */ 238 ISAPNP_CS4232_WOMPU('C','S','C',0x0735,0x0000,0x0010),231 { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } }, 239 232 /* some uknown CS4236B */ 240 ISAPNP_CS4232('C','S','C',0x0b35,0x0000,0x0010,0x0003),233 { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 241 234 /* Intel PR440FX Onboard sound */ 242 ISAPNP_CS4232('C','S','C',0x0b36,0x0000,0x0010,0x0003),235 { .id = "CSC0b36", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 243 236 /* CS4235 on mainboard without MPU */ 244 ISAPNP_CS4232_WOMPU('C','S','C',0x1425,0x0100,0x0110),237 { .id = "CSC1425", .devs = { { "CSC0100" }, { "CSC0110" } } }, 245 238 /* Gateway E1000 Onboard CS4236B */ 246 ISAPNP_CS4232('C','S','C',0x1335,0x0000,0x0010,0x0003),239 { .id = "CSC1335", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 247 240 /* HP 6330 Onboard sound */ 248 ISAPNP_CS4232('C','S','C',0x1525,0x0100,0x0110,0x0103),241 { .id = "CSC1525", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } }, 249 242 /* Crystal Computer TidalWave128 */ 250 ISAPNP_CS4232('C','S','C',0x1e37,0x0000,0x0010,0x0003),243 { .id = "CSC1e37", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 251 244 /* ACER AW37 - CS4235 */ 252 ISAPNP_CS4232('C','S','C',0x4236,0x0000,0x0010,0x0003),245 { .id = "CSC4236", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 253 246 /* build-in soundcard in EliteGroup P5TX-LA motherboard - CS4237B */ 254 ISAPNP_CS4232('C','S','C',0x4237,0x0000,0x0010,0x0003),247 { .id = "CSC4237", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 255 248 /* Crystal 3D - CS4237B */ 256 ISAPNP_CS4232('C','S','C',0x4336,0x0000,0x0010,0x0003),249 { .id = "CSC4336", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 257 250 /* Typhoon Soundsystem PnP - CS4236B */ 258 ISAPNP_CS4232('C','S','C',0x4536,0x0000,0x0010,0x0003),251 { .id = "CSC4536", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 259 252 /* Crystal CX4235-XQ3 EP - CS4235 */ 260 ISAPNP_CS4232('C','S','C',0x4625,0x0100,0x0110,0x0103), 253 { .id = "CSC4625", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } }, 254 /* Crystal Semiconductors CS4237B */ 255 { .id = "CSC4637", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 256 /* NewClear 3D - CX4237B-XQ3 */ 257 { .id = "CSC4837", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 258 /* Dell Optiplex GX1 - CS4236B */ 259 { .id = "CSC6835", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 260 /* Dell P410 motherboard - CS4236B */ 261 { .id = "CSC6835", .devs = { { "CSC0000" }, { "CSC0010" } } }, 262 /* Dell Workstation 400 Onboard - CS4236B */ 263 { .id = "CSC6836", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 264 /* Turtle Beach Malibu - CS4237B */ 265 { .id = "CSC7537", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 266 /* CS4235 - onboard */ 267 { .id = "CSC8025", .devs = { { "CSC0100" }, { "CSC0110" }, { "CSC0103" } } }, 268 /* IBM Aptiva 2137 E24 Onboard - CS4237B */ 269 { .id = "CSC8037", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 270 /* IBM IntelliStation M Pro motherboard */ 271 { .id = "CSCc835", .devs = { { "CSC0000" }, { "CSC0010" } } }, 272 /* Guillemot MaxiSound 16 PnP - CS4236B */ 273 { .id = "CSC9836", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 274 /* Gallant SC-70P */ 275 { .id = "CSC9837", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 261 276 /* TerraTec AudioSystem EWS64XL - CS4236B */ 262 ISAPNP_CS4232('C','S','C',0xa836,0xa800,0xa810,0xa803),277 { .id = "CSCa836", .devs = { { "CSCa800" }, { "CSCa810" }, { "CSCa803" } } }, 263 278 /* TerraTec AudioSystem EWS64XL - CS4236B */ 264 ISAPNP_CS4232_WOMPU('C','S','C',0xa836,0xa800,0xa810), 265 /* Crystal Semiconductors CS4237B */ 266 ISAPNP_CS4232('C','S','C',0x4637,0x0000,0x0010,0x0003), 267 /* NewClear 3D - CX4237B-XQ3 */ 268 ISAPNP_CS4232('C','S','C',0x4837,0x0000,0x0010,0x0003), 269 /* Dell Optiplex GX1 - CS4236B */ 270 ISAPNP_CS4232('C','S','C',0x6835,0x0000,0x0010,0x0003), 271 /* Dell P410 motherboard - CS4236B */ 272 ISAPNP_CS4232_WOMPU('C','S','C',0x6835,0x0000,0x0010), 273 /* Dell Workstation 400 Onboard - CS4236B */ 274 ISAPNP_CS4232('C','S','C',0x6836,0x0000,0x0010,0x0003), 275 /* Turtle Beach Malibu - CS4237B */ 276 ISAPNP_CS4232('C','S','C',0x7537,0x0000,0x0010,0x0003), 277 /* CS4235 - onboard */ 278 ISAPNP_CS4232('C','S','C',0x8025,0x0100,0x0110,0x0103), 279 { .id = "CSCa836", .devs = { { "CSCa800" }, { "CSCa810" } } }, 280 /* ACER AW37/Pro - CS4235 */ 281 { .id = "CSCd925", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 282 /* ACER AW35/Pro - CS4237B */ 283 { .id = "CSCd937", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 284 /* CS4235 without MPU401 */ 285 { .id = "CSCe825", .devs = { { "CSC0100" }, { "CSC0110" } } }, 286 /* IBM IntelliStation M Pro 6898 11U - CS4236B */ 287 { .id = "CSCe835", .devs = { { "CSC0000" }, { "CSC0010" } } }, 279 288 /* IBM PC 300PL Onboard - CS4236B */ 280 ISAPNP_CS4232_WOMPU('C','S','C',0xe836,0x0000,0x0010), 281 /* IBM Aptiva 2137 E24 Onboard - CS4237B */ 282 ISAPNP_CS4232('C','S','C',0x8037,0x0000,0x0010,0x0003), 283 /* IBM IntelliStation M Pro motherboard */ 284 ISAPNP_CS4232_WOMPU('C','S','C',0xc835,0x0000,0x0010), 285 /* Guillemot MaxiSound 16 PnP - CS4236B */ 286 ISAPNP_CS4232('C','S','C',0x9836,0x0000,0x0010,0x0003), 287 /* Gallant SC-70P */ 288 ISAPNP_CS4232('C','S','C',0x9837,0x0000,0x0010,0x0003), 289 /* ACER AW37/Pro - CS4235 */ 290 ISAPNP_CS4232('C','S','C',0xd925,0x0000,0x0010,0x0003), 291 /* ACER AW35/Pro - CS4237B */ 292 ISAPNP_CS4232('C','S','C',0xd937,0x0000,0x0010,0x0003), 293 /* CS4235 without MPU401 */ 294 ISAPNP_CS4232_WOMPU('C','S','C',0xe825,0x0100,0x0110), 295 /* IBM IntelliStation M Pro 6898 11U - CS4236B */ 296 ISAPNP_CS4232_WOMPU('C','S','C',0xe835,0x0000,0x0010), 289 { .id = "CSCe836", .devs = { { "CSC0000" }, { "CSC0010" } } }, 297 290 /* Some noname CS4236 based card */ 298 ISAPNP_CS4232('C','S','C',0xe936,0x0000,0x0010,0x0003),291 { .id = "CSCe936", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 299 292 /* CS4236B */ 300 ISAPNP_CS4232('C','S','C',0xf235,0x0000,0x0010,0x0003),293 { .id = "CSCf235", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 301 294 /* CS4236B */ 302 ISAPNP_CS4232('C','S','C',0xf238,0x0000,0x0010,0x0003),295 { .id = "CSCf238", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, 303 296 /* --- */ 304 { ISAPNP_CARD_END,} /* end */297 { .id = "" } /* end */ 305 298 }; 306 299 #endif 307 300 308 ISAPNP_CARD_TABLE(snd_card_pnpids); 309 310 static int __init snd_card_cs4236_isapnp(int dev, struct snd_card_cs4236 *acard) 311 { 312 const struct isapnp_card_id *id = snd_cs4236_isapnp_id[dev]; 313 struct isapnp_card *card = snd_cs4236_isapnp_cards[dev]; 314 struct isapnp_dev *pdev; 315 316 acard->wss = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); 317 if (acard->wss->active) { 318 acard->wss = NULL; 301 MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids); 302 303 static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, 304 struct pnp_card_link *card, 305 const struct pnp_card_device_id *id) 306 { 307 struct pnp_dev *pdev; 308 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); 309 int err; 310 311 acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL); 312 if (acard->wss == NULL) { 313 kfree(cfg); 319 314 return -EBUSY; 320 315 } 321 acard->ctrl = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL);322 if (acard->ctrl ->active) {323 acard->wss = acard->ctrl = NULL;316 acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL); 317 if (acard->ctrl == NULL) { 318 kfree(cfg); 324 319 return -EBUSY; 325 320 } 326 if (id->devs[2]. vendor && id->devs[2].function) {327 acard->mpu = isapnp_find_dev(card, id->devs[2].vendor, id->devs[2].function, NULL);328 if (acard->mpu ->active) {329 acard->wss = acard->ctrl = acard->mpu = NULL;321 if (id->devs[2].id[0]) { 322 acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL); 323 if (acard->mpu == NULL) { 324 kfree(cfg); 330 325 return -EBUSY; 331 326 } … … 334 329 /* WSS initialization */ 335 330 pdev = acard->wss; 336 if (pdev->prepare(pdev) < 0) 337 return -EAGAIN; 331 pnp_init_resource_table(cfg); 338 332 if (port[dev] != SNDRV_AUTO_PORT) 339 isapnp_resource_change(&pdev->resource[0], port[dev], 4);333 pnp_resource_change(&cfg->port_resource[0], port[dev], 4); 340 334 if (fm_port[dev] != SNDRV_AUTO_PORT && fm_port[dev] >= 0) 341 isapnp_resource_change(&pdev->resource[1], fm_port[dev], 4);335 pnp_resource_change(&cfg->port_resource[1], fm_port[dev], 4); 342 336 if (sb_port[dev] != SNDRV_AUTO_PORT) 343 isapnp_resource_change(&pdev->resource[2], sb_port[dev], 16);337 pnp_resource_change(&cfg->port_resource[2], sb_port[dev], 16); 344 338 if (irq[dev] != SNDRV_AUTO_IRQ) 345 isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1);339 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 346 340 if (dma1[dev] != SNDRV_AUTO_DMA) 347 isapnp_resource_change(&pdev->dma_resource[0], dma1[dev], 1);341 pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1); 348 342 if (dma2[dev] != SNDRV_AUTO_DMA) 349 isapnp_resource_change(&pdev->dma_resource[1], dma2[dev] < 0 ? 4 : dma2[dev], 1); 350 if (pdev->activate(pdev)<0) { 351 printk(KERN_ERR IDENT " isapnp configure failed for WSS (out of resources?)\n"); 343 pnp_resource_change(&cfg->dma_resource[1], dma2[dev] < 0 ? 4 : dma2[dev], 1); 344 err = pnp_manual_config_dev(pdev, cfg, 0); 345 if (err < 0) 346 snd_printk(KERN_ERR IDENT " WSS PnP manual resources are invalid, using auto config\n"); 347 err = pnp_activate_dev(pdev); 348 if (err < 0) { 349 kfree(cfg); 350 printk(KERN_ERR IDENT " WSS PnP configure failed for WSS (out of resources?)\n"); 352 351 return -EBUSY; 353 352 } 354 port[dev] = p dev->resource[0].start;353 port[dev] = pnp_port_start(pdev, 0); 355 354 if (fm_port[dev] >= 0) 356 fm_port[dev] = p dev->resource[1].start;357 sb_port[dev] = p dev->resource[2].start;358 irq[dev] = p dev->irq_resource[0].start;359 dma1[dev] = p dev->dma_resource[0].start;360 dma2[dev] = p dev->dma_resource[1].start == 4 ? -1 : (int)pdev->dma_resource[1].start;355 fm_port[dev] = pnp_port_start(pdev, 1); 356 sb_port[dev] = pnp_port_start(pdev, 2); 357 irq[dev] = pnp_irq(pdev, 0); 358 dma1[dev] = pnp_dma(pdev, 0); 359 dma2[dev] = pnp_dma(pdev, 1) == 4 ? -1 : (int)pnp_dma(pdev, 1); 361 360 snd_printdd("isapnp WSS: wss port=0x%lx, fm port=0x%lx, sb port=0x%lx\n", 362 361 port[dev], fm_port[dev], sb_port[dev]); … … 366 365 if (acard->ctrl && cport[dev] >= 0) { 367 366 pdev = acard->ctrl; 368 if (pdev->prepare(pdev) < 0) { 369 acard->wss->deactivate(acard->wss); 370 return -EAGAIN; 371 } 367 pnp_init_resource_table(cfg); 372 368 if (cport[dev] != SNDRV_AUTO_PORT) 373 isapnp_resource_change(&pdev->resource[0], cport[dev], 8); 374 if (pdev->activate(pdev)<0) { 375 printk(KERN_ERR IDENT " isapnp configure failed for control (out of resources?)\n"); 376 acard->wss->deactivate(acard->wss); 369 pnp_resource_change(&cfg->port_resource[0], cport[dev], 8); 370 err = pnp_manual_config_dev(pdev, cfg, 0); 371 if (err < 0) 372 snd_printk(KERN_ERR IDENT " CTRL PnP manual resources are invalid, using auto config\n"); 373 err = pnp_activate_dev(pdev); 374 if (err < 0) { 375 kfree(cfg); 376 printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n"); 377 377 return -EBUSY; 378 378 } 379 cport[dev] = p dev->resource[0].start;379 cport[dev] = pnp_port_start(pdev, 0); 380 380 snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]); 381 381 } … … 383 383 if (acard->mpu && mpu_port[dev] >= 0) { 384 384 pdev = acard->mpu; 385 if (pdev->prepare(pdev) < 0) { 386 acard->wss->deactivate(acard->wss); 387 acard->ctrl->deactivate(acard->ctrl); 388 return -EAGAIN; 389 } 385 pnp_init_resource_table(cfg); 390 386 if (mpu_port[dev] != SNDRV_AUTO_PORT) 391 isapnp_resource_change(&pdev->resource[0], mpu_port[dev], 2);387 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); 392 388 if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0) 393 isapnp_resource_change(&pdev->irq_resource[0], mpu_irq[dev], 1); 394 if (pdev->activate(pdev)<0) { 389 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); 390 err = pnp_manual_config_dev(pdev, cfg, 0); 391 if (err < 0) 392 snd_printk(KERN_ERR IDENT " MPU401 PnP manual resources are invalid, using auto config\n"); 393 err = pnp_activate_dev(pdev); 394 if (err < 0) { 395 kfree(cfg); 396 printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n"); 395 397 mpu_port[dev] = SNDRV_AUTO_PORT; 396 398 mpu_irq[dev] = SNDRV_AUTO_IRQ; 397 printk(KERN_ERR IDENT " isapnp configure failed for MPU (out of resources?)\n");398 399 } else { 399 mpu_port[dev] = pdev->resource[0].start; 400 if ((pdev->irq_resource[0].flags & IORESOURCE_IRQ) && 401 mpu_irq[dev] >= 0) { 402 mpu_irq[dev] = pdev->irq_resource[0].start; 400 mpu_port[dev] = pnp_port_start(pdev, 0); 401 if (pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) { 402 mpu_irq[dev] = pnp_irq(pdev, 0); 403 403 } else { 404 404 mpu_irq[dev] = -1; /* disable interrupt */ … … 407 407 snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]); 408 408 } 409 kfree(cfg); 409 410 return 0; 410 411 } 411 412 static void snd_card_cs4236_deactivate(struct snd_card_cs4236 *acard)413 {414 if (acard->wss) {415 acard->wss->deactivate(acard->wss);416 acard->wss = NULL;417 }418 if (acard->ctrl) {419 acard->ctrl->deactivate(acard->ctrl);420 acard->ctrl = NULL;421 }422 if (acard->mpu) {423 acard->mpu->deactivate(acard->mpu);424 acard->mpu = NULL;425 }426 }427 412 #endif 428 413 … … 432 417 433 418 if (acard) { 434 #ifdef __ISAPNP__435 snd_card_cs4236_deactivate(acard);436 #endif437 419 if (acard->res_sb_port) { 438 420 release_resource(acard->res_sb_port); … … 442 424 } 443 425 444 static int __init snd_card_cs4236_probe(int dev) 426 static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, 427 const struct pnp_card_device_id *pid) 445 428 { 446 429 snd_card_t *card; … … 451 434 int err; 452 435 453 #ifdef __ISAPNP__436 #ifdef CONFIG_PNP 454 437 if (!isapnp[dev]) { 455 438 #endif … … 462 445 return -EINVAL; 463 446 } 464 #ifdef __ISAPNP__447 #ifdef CONFIG_PNP 465 448 } 466 449 #endif … … 471 454 acard = (struct snd_card_cs4236 *)card->private_data; 472 455 card->private_free = snd_card_cs4236_free; 473 #ifdef __ISAPNP__474 if (isapnp[dev] && (err = snd_card_cs4236_ isapnp(dev, acard))<0) {456 #ifdef CONFIG_PNP 457 if (isapnp[dev] && (err = snd_card_cs4236_pnp(dev, acard, pcard, pid))<0) { 475 458 printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n"); 476 459 snd_card_free(card); … … 574 557 return err; 575 558 } 576 snd_cs4236_cards[dev] = card; 559 if (pcard) 560 pnp_set_card_drvdata(pcard, card); 561 else 562 snd_cs4236_legacy[dev] = card; 577 563 return 0; 578 564 } 579 565 580 #ifdef __ISAPNP__581 static int __ init snd_cs4236_isapnp_detect(struct isapnp_card*card,582 const struct isapnp_card_id *id)566 #ifdef CONFIG_PNP 567 static int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *card, 568 const struct pnp_card_device_id *id) 583 569 { 584 570 static int dev; … … 588 574 if (!enable[dev]) 589 575 continue; 590 snd_cs4236_isapnp_cards[dev] = card; 591 snd_cs4236_isapnp_id[dev] = id; 592 res = snd_card_cs4236_probe(dev); 576 res = snd_card_cs423x_probe(dev, card, id); 593 577 if (res < 0) 594 578 return res; … … 598 582 return -ENODEV; 599 583 } 600 #endif /* __ISAPNP__ */ 584 585 static void __devexit snd_cs423x_pnp_remove(struct pnp_card_link * pcard) 586 { 587 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 588 589 snd_card_disconnect(card); 590 snd_card_free_in_thread(card); 591 } 592 593 static struct pnp_card_driver cs423x_pnpc_driver = { 594 .flags = PNP_DRIVER_RES_DISABLE, 595 .name = "cs423x", 596 .id_table = snd_cs423x_pnpids, 597 .probe = snd_cs423x_pnp_detect, 598 .remove = __devexit_p(snd_cs423x_pnp_remove), 599 }; 600 #endif /* CONFIG_PNP */ 601 601 602 602 static int __init alsa_card_cs423x_init(void) … … 607 607 if (!enable[dev]) 608 608 continue; 609 #ifdef __ISAPNP__609 #ifdef CONFIG_PNP 610 610 if (isapnp[dev]) 611 611 continue; 612 612 #endif 613 if (snd_card_cs423 6_probe(dev) >= 0)613 if (snd_card_cs423x_probe(dev, NULL, NULL) >= 0) 614 614 cards++; 615 615 } 616 #ifdef __ISAPNP__617 cards += isapnp_probe_cards(snd_card_pnpids, snd_cs4236_isapnp_detect);616 #ifdef CONFIG_PNP 617 cards += pnp_register_card_driver(&cs423x_pnpc_driver); 618 618 #endif 619 619 if (!cards) { 620 #ifdef CONFIG_PNP 621 pnp_unregister_card_driver(&cs423x_pnpc_driver); 622 #endif 620 623 #ifdef MODULE 621 624 printk(KERN_ERR IDENT " soundcard not found or device busy\n"); … … 630 633 int idx; 631 634 635 #ifdef CONFIG_PNP 636 /* PnP cards first */ 637 pnp_unregister_card_driver(&cs423x_pnpc_driver); 638 #endif 632 639 for (idx = 0; idx < SNDRV_CARDS; idx++) 633 snd_card_free(snd_cs4236_ cards[idx]);640 snd_card_free(snd_cs4236_legacy[idx]); 634 641 } 635 642 … … 666 673 get_option(&str,&dma1[nr_dev]) == 2 && 667 674 get_option(&str,&dma2[nr_dev]) == 2); 668 #ifdef __ISAPNP__675 #ifdef CONFIG_PNP 669 676 if (pnp != INT_MAX) 670 677 isapnp[nr_dev] = pnp; -
GPL/branches/alsa-resync1/alsa-kernel/isa/dt019x.c
r224 r246 26 26 #include <linux/sched.h> 27 27 #include <linux/wait.h> 28 #ifndef LINUX_ISAPNP_H 29 #include <linux/isapnp.h> 30 #define isapnp_card pci_bus 31 #define isapnp_dev pci_dev 32 #endif 28 #include <linux/pnp.h> 33 29 #include <sound/core.h> 34 30 #define SNDRV_GET_ID … … 88 84 89 85 struct snd_card_dt019x { 90 #ifdef __ISAPNP__ 91 struct isapnp_dev *dev; 92 struct isapnp_dev *devmpu; 93 struct isapnp_dev *devopl; 94 #endif /* __ISAPNP__ */ 86 struct pnp_dev *dev; 87 struct pnp_dev *devmpu; 88 struct pnp_dev *devopl; 95 89 }; 96 90 97 static snd_card_t *snd_dt019x_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 98 99 #ifdef __ISAPNP__ 100 static struct isapnp_card *snd_dt019x_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 101 static const struct isapnp_card_id *snd_dt019x_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 102 103 static struct isapnp_card_id snd_dt019x_pnpids[] __devinitdata = { 91 static struct pnp_card_device_id snd_dt019x_pnpids[] __devinitdata = { 104 92 /* DT197A30 */ 105 { 106 ISAPNP_CARD_ID('R','W','B',0x1688), 107 .devs = { ISAPNP_DEVICE_ID('@','@','@',0x0001), 108 ISAPNP_DEVICE_ID('@','X','@',0x0001), 109 ISAPNP_DEVICE_ID('@','H','@',0x0001) } 110 }, 93 { .id = "RWB1688", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, 111 94 /* DT0196 / ALS-007 */ 112 { 113 ISAPNP_CARD_ID('A','L','S',0x0007), 114 .devs = { ISAPNP_DEVICE_ID('@','@','@',0x0001), 115 ISAPNP_DEVICE_ID('@','X','@',0x0001), 116 ISAPNP_DEVICE_ID('@','H','@',0x0001) } 117 }, 118 { ISAPNP_CARD_END, } 95 { .id = "ALS0007", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, 96 { .id = "", } 119 97 }; 120 98 121 ISAPNP_CARD_TABLE(snd_dt019x_pnpids); 122 123 #endif /* __ISAPNP__ */ 99 MODULE_DEVICE_TABLE(pnp_card, snd_dt019x_pnpids); 100 124 101 125 102 #define DRIVER_NAME "snd-card-dt019x" 126 103 127 104 128 #ifdef __ISAPNP__ 129 static int __init snd_card_dt019x_isapnp(int dev, struct snd_card_dt019x *acard) 130 { 131 const struct isapnp_card_id *id = snd_dt019x_isapnp_id[dev]; 132 struct isapnp_card *card = snd_dt019x_isapnp_cards[dev]; 133 struct isapnp_dev *pdev; 134 135 acard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); 136 if (acard->dev->active) { 137 acard->dev = NULL; 138 return -EBUSY; 139 } 140 acard->devmpu = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL); 141 if (acard->devmpu->active) { 142 acard->dev = acard->devmpu = NULL; 143 return -EBUSY; 144 } 145 acard->devopl = isapnp_find_dev(card, id->devs[2].vendor, id->devs[2].function, NULL); 146 if (acard->devopl->active) { 147 acard->dev = acard->devmpu = acard->devopl = NULL; 148 return -EBUSY; 149 } 105 static int __devinit snd_card_dt019x_pnp(int dev, struct snd_card_dt019x *acard, 106 struct pnp_card_link *card, 107 const struct pnp_card_device_id *pid) 108 { 109 struct pnp_dev *pdev; 110 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); 111 int err; 112 113 if (!cfg) 114 return -ENOMEM; 115 116 acard->dev = pnp_request_card_device(card, pid->devs[0].id, NULL); 117 if (acard->dev == NULL) { 118 kfree (cfg); 119 return -ENODEV; 120 } 121 acard->devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); 122 acard->devopl = pnp_request_card_device(card, pid->devs[2].id, NULL); 150 123 151 124 pdev = acard->dev; 152 if (!pdev || pdev->prepare(pdev)<0) 153 return -EAGAIN; 125 pnp_init_resource_table(cfg); 154 126 155 127 if (port[dev] != SNDRV_AUTO_PORT) 156 isapnp_resource_change(&pdev->resource[0], port[dev], 16);128 pnp_resource_change(&cfg->port_resource[0], port[dev], 16); 157 129 if (dma8[dev] != SNDRV_AUTO_DMA) 158 isapnp_resource_change(&pdev->dma_resource[0], dma8[dev],130 pnp_resource_change(&cfg->dma_resource[0], dma8[dev], 159 131 1); 160 132 if (irq[dev] != SNDRV_AUTO_IRQ) 161 isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); 162 163 if (pdev->activate(pdev)<0) { 164 printk(KERN_ERR PFX "DT-019X AUDIO isapnp configure failure\n"); 165 return -EBUSY; 166 } 167 port[dev] = pdev->resource[0].start; 168 dma8[dev] = pdev->dma_resource[0].start; 169 irq[dev] = pdev->irq_resource[0].start; 133 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 134 135 if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0) 136 snd_printk(KERN_ERR PFX "DT-019X AUDIO the requested resources are invalid, using auto config\n"); 137 err = pnp_activate_dev(pdev); 138 if (err < 0) { 139 snd_printk(KERN_ERR PFX "DT-019X AUDIO pnp configure failure\n"); 140 kfree(cfg); 141 return err; 142 } 143 144 port[dev] = pnp_port_start(pdev, 0); 145 dma8[dev] = pnp_dma(pdev, 0); 146 irq[dev] = pnp_irq(pdev, 0); 170 147 snd_printdd("dt019x: found audio interface: port=0x%lx, irq=0x%lx, dma=0x%lx\n", 171 148 port[dev],irq[dev],dma8[dev]); 172 149 173 150 pdev = acard->devmpu; 174 if (!pdev || pdev->prepare(pdev)<0) 175 return 0; 176 177 if (mpu_port[dev] != SNDRV_AUTO_PORT) 178 isapnp_resource_change(&pdev->resource[0], mpu_port[dev], 179 2); 180 if (mpu_irq[dev] != SNDRV_AUTO_IRQ) 181 isapnp_resource_change(&pdev->irq_resource[0], mpu_irq[dev], 182 1); 183 184 if (pdev->activate(pdev)<0) { 185 printk(KERN_ERR PFX "DT-019X MPU-401 isapnp configure failure\n"); 186 mpu_port[dev] = -1; 187 acard->devmpu = NULL; 188 } else { 189 mpu_port[dev] = pdev->resource[0].start; 190 mpu_irq[dev] = pdev->irq_resource[0].start; 151 152 if (pdev != NULL) { 153 pnp_init_resource_table(cfg); 154 if (mpu_port[dev] != SNDRV_AUTO_PORT) 155 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); 156 if (mpu_irq[dev] != SNDRV_AUTO_IRQ) 157 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); 158 if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0) 159 snd_printk(KERN_ERR PFX "DT-019X MPU401 the requested resources are invalid, using auto config\n"); 160 err = pnp_activate_dev(pdev); 161 if (err < 0) 162 goto __mpu_error; 163 mpu_port[dev] = pnp_port_start(pdev, 0); 164 mpu_irq[dev] = pnp_irq(pdev, 0); 191 165 snd_printdd("dt019x: found MPU-401: port=0x%lx, irq=0x%lx\n", 192 166 mpu_port[dev],mpu_irq[dev]); 167 } else { 168 __mpu_error: 169 if (pdev) { 170 pnp_release_card_device(pdev); 171 snd_printk(KERN_ERR PFX "DT-019X MPU401 pnp configure failure, skipping\n"); 172 } 173 acard->devmpu = NULL; 174 mpu_port[dev] = -1; 193 175 } 194 176 195 177 pdev = acard->devopl; 196 if (!pdev || pdev->prepare(pdev)<0) 197 return 0; 198 199 if (fm_port[dev] != SNDRV_AUTO_PORT) 200 isapnp_resource_change(&pdev->resource[0], fm_port[dev], 4); 201 202 if (pdev->activate(pdev)<0) { 203 printk(KERN_ERR PFX "DT-019X OPL3 isapnp configure failure\n"); 178 if (pdev != NULL) { 179 pnp_init_resource_table(cfg); 180 if (fm_port[dev] != SNDRV_AUTO_PORT) 181 pnp_resource_change(&cfg->port_resource[0], fm_port[dev], 4); 182 if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0) 183 snd_printk(KERN_ERR PFX "DT-019X OPL3 the requested resources are invalid, using auto config\n"); 184 err = pnp_activate_dev(pdev); 185 if (err < 0) 186 goto __fm_error; 187 fm_port[dev] = pnp_port_start(pdev, 0); 188 snd_printdd("dt019x: found OPL3 synth: port=0x%lx\n",fm_port[dev]); 189 } else { 190 __fm_error: 191 if (pdev) { 192 pnp_release_card_device(pdev); 193 snd_printk(KERN_ERR PFX "DT-019X OPL3 pnp configure failure, skipping\n"); 194 } 195 acard->devopl = NULL; 204 196 fm_port[dev] = -1; 205 acard->devopl = NULL; 206 } else { 207 fm_port[dev] = pdev->resource[0].start; 208 snd_printdd("dt019x: found OPL3 synth: port=0x%lx\n",fm_port[dev]); 209 } 210 197 } 198 199 kfree(cfg); 211 200 return 0; 212 201 } 213 202 214 static void snd_card_dt019x_deactivate(struct snd_card_dt019x *acard) 215 { 216 if (acard->dev) { 217 acard->dev->deactivate(acard->dev); 218 acard->dev = NULL; 219 } 220 if (acard->devmpu) { 221 acard->devmpu->deactivate(acard->devmpu); 222 acard->devmpu = NULL; 223 } 224 if (acard->devopl) { 225 acard->devopl->deactivate(acard->devopl); 226 acard->devopl = NULL; 227 } 228 } 229 #endif /* __ISAPNP__ */ 230 231 static void snd_card_dt019x_free(snd_card_t *card) 232 { 233 struct snd_card_dt019x *acard = (struct snd_card_dt019x *)card->private_data; 234 235 if (acard != NULL) { 236 #ifdef __ISAPNP__ 237 snd_card_dt019x_deactivate(acard); 238 #endif /* __ISAPNP__ */ 239 } 240 } 241 242 static int __init snd_card_dt019x_probe(int dev) 203 static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) 243 204 { 244 205 int error; … … 252 213 return -ENOMEM; 253 214 acard = (struct snd_card_dt019x *)card->private_data; 254 card->private_free = snd_card_dt019x_free; 255 256 #ifdef __ISAPNP__ 257 if ((error = snd_card_dt019x_isapnp(dev, acard))) { 258 snd_card_free(card); 259 return error; 260 } 261 #else 262 printk(KERN_ERR PFX "you have to enable PnP support ...\n"); 263 snd_card_free(card); 264 return -ENOSYS; 265 #endif /* __ISAPNP__ */ 215 216 if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) { 217 snd_card_free(card); 218 return error; 219 } 266 220 267 221 if ((error = snd_sbdsp_create(card, port[dev], … … 293 247 SA_INTERRUPT, 294 248 NULL) < 0) 295 printk(KERN_ERR PFX "no MPU-401 device at 0x%lx ?\n", 296 mpu_port[dev]); 249 snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx ?\n", mpu_port[dev]); 297 250 } 298 251 … … 302 255 fm_port[dev] + 2, 303 256 OPL3_HW_AUTO, 0, &opl3) < 0) { 304 printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx ?\n",305 fm_port[dev], fm_port[dev] + 2);257 snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx ?\n", 258 fm_port[dev], fm_port[dev] + 2); 306 259 } else { 307 260 if ((error = snd_opl3_timer_new(opl3, 0, 1)) < 0) { … … 325 278 return error; 326 279 } 327 snd_dt019x_cards[dev] = card;280 pnp_set_card_drvdata(pcard, card); 328 281 return 0; 329 282 } 330 283 331 #ifdef __ISAPNP__ 332 static int __init snd_dt019x_isapnp_detect(struct isapnp_card *card, 333 const struct isapnp_card_id *id) 284 static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card, 285 const struct pnp_card_device_id *pid) 334 286 { 335 287 static int dev; … … 339 291 if (!enable[dev]) 340 292 continue; 341 snd_dt019x_isapnp_cards[dev] = card; 342 snd_dt019x_isapnp_id[dev] = id; 343 res = snd_card_dt019x_probe(dev); 293 res = snd_card_dt019x_probe(dev, card, pid); 344 294 if (res < 0) 345 295 return res; … … 349 299 return -ENODEV; 350 300 } 351 #endif /* __ISAPNP__ */ 301 302 static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard) 303 { 304 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 305 snd_card_disconnect(card); 306 snd_card_free_in_thread(card); 307 } 308 309 static struct pnp_card_driver dt019x_pnpc_driver = { 310 .flags = PNP_DRIVER_RES_DISABLE, 311 .name = "dt019x", 312 .id_table = snd_dt019x_pnpids, 313 .probe = snd_dt019x_pnp_probe, 314 .remove = __devexit_p(snd_dt019x_pnp_remove), 315 }; 352 316 353 317 static int __init alsa_card_dt019x_init(void) … … 355 319 int cards = 0; 356 320 357 #ifdef __ISAPNP__ 358 cards += isapnp_probe_cards(snd_dt019x_pnpids, snd_dt019x_isapnp_detect); 359 #else 360 printk(KERN_ERR PFX "you have to enable ISA PnP support.\n"); 361 #endif 321 cards += pnp_register_card_driver(&dt019x_pnpc_driver); 322 362 323 #ifdef MODULE 363 324 if (!cards) 364 printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n");325 snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n"); 365 326 #endif 366 327 return cards ? 0 : -ENODEV; … … 369 330 static void __exit alsa_card_dt019x_exit(void) 370 331 { 371 int dev; 372 373 for (dev = 0; dev < SNDRV_CARDS; dev++) 374 snd_card_free(snd_dt019x_cards[dev]); 332 pnp_unregister_card_driver(&dt019x_pnpc_driver); 375 333 } 376 334 -
GPL/branches/alsa-resync1/alsa-kernel/isa/es1688/es1688_lib.c
r224 r246 483 483 } 484 484 485 voidsnd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs)486 { 487 es1688_t *chip = snd_magic_cast(es1688_t, dev_id, return );485 irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs) 486 { 487 es1688_t *chip = snd_magic_cast(es1688_t, dev_id, return IRQ_NONE); 488 488 489 489 if (chip->trigger_value == 0x05) /* ok.. playback is active */ … … 493 493 494 494 inb(ES1688P(chip, DATA_AVAIL)); /* ack interrupt */ 495 return IRQ_HANDLED; 495 496 } 496 497 -
GPL/branches/alsa-resync1/alsa-kernel/isa/es18xx.c
r224 r246 71 71 #include <linux/pm.h> 72 72 #include <linux/slab.h> 73 #i fndef LINUX_ISAPNP_H73 #include <linux/pnp.h> 74 74 #include <linux/isapnp.h> 75 #define isapnp_card pci_bus76 #define isapnp_dev pci_dev77 #endif78 75 #include <sound/core.h> 79 76 #include <sound/control.h> … … 731 728 } 732 729 733 static voidsnd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *regs)734 { 735 es18xx_t *chip = snd_magic_cast(es18xx_t, dev_id, return );730 static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *regs) 731 { 732 es18xx_t *chip = snd_magic_cast(es18xx_t, dev_id, return IRQ_NONE); 736 733 unsigned char status; 737 738 734 739 735 if (chip->caps & ES18XX_CONTROL) { … … 791 787 snd_es18xx_mixer_write(chip, 0x66, 0x00); 792 788 } 793 789 return IRQ_HANDLED; 794 790 } 795 791 … … 1264 1260 1265 1261 #if 0 1266 static int __ init snd_es18xx_config_read(es18xx_t *chip, unsigned char reg)1262 static int __devinit snd_es18xx_config_read(es18xx_t *chip, unsigned char reg) 1267 1263 { 1268 1264 int data; … … 1276 1272 #endif 1277 1273 1278 static void __ init snd_es18xx_config_write(es18xx_t *chip,1274 static void __devinit snd_es18xx_config_write(es18xx_t *chip, 1279 1275 unsigned char reg, unsigned char data) 1280 1276 { … … 1288 1284 } 1289 1285 1290 static int __ init snd_es18xx_initialize(es18xx_t *chip)1286 static int __devinit snd_es18xx_initialize(es18xx_t *chip) 1291 1287 { 1292 1288 int mask = 0; … … 1437 1433 } 1438 1434 1439 static int __ init snd_es18xx_identify(es18xx_t *chip)1435 static int __devinit snd_es18xx_identify(es18xx_t *chip) 1440 1436 { 1441 1437 int hi,lo; … … 1501 1497 } 1502 1498 1503 static int __ init snd_es18xx_probe(es18xx_t *chip)1499 static int __devinit snd_es18xx_probe(es18xx_t *chip) 1504 1500 { 1505 1501 if (snd_es18xx_identify(chip) < 0) { 1506 printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port);1502 snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); 1507 1503 return -ENODEV; 1508 1504 } … … 1570 1566 } 1571 1567 1572 int __ init snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpcm)1568 int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpcm) 1573 1569 { 1574 1570 snd_pcm_t *pcm; … … 1715 1711 } 1716 1712 1717 static int __ init snd_es18xx_new_device(snd_card_t * card,1713 static int __devinit snd_es18xx_new_device(snd_card_t * card, 1718 1714 unsigned long port, 1719 1715 unsigned long mpu_port, … … 1747 1743 if ((chip->res_port = request_region(port, 16, "ES18xx")) == NULL) { 1748 1744 snd_es18xx_free(chip); 1749 printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1);1745 snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); 1750 1746 return -EBUSY; 1751 1747 } … … 1753 1749 if (request_irq(irq, snd_es18xx_interrupt, SA_INTERRUPT, "ES18xx", (void *) chip)) { 1754 1750 snd_es18xx_free(chip); 1755 printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq);1751 snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); 1756 1752 return -EBUSY; 1757 1753 } … … 1760 1756 if (request_dma(dma1, "ES18xx DMA 1")) { 1761 1757 snd_es18xx_free(chip); 1762 printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1);1758 snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); 1763 1759 return -EBUSY; 1764 1760 } … … 1767 1763 if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { 1768 1764 snd_es18xx_free(chip); 1769 printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2);1765 snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); 1770 1766 return -EBUSY; 1771 1767 } … … 1784 1780 } 1785 1781 1786 static int __ init snd_es18xx_mixer(es18xx_t *chip)1782 static int __devinit snd_es18xx_mixer(es18xx_t *chip) 1787 1783 { 1788 1784 snd_card_t *card; … … 1887 1883 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 1888 1884 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 1889 #ifdef __ISAPNP__1885 #ifdef CONFIG_PNP 1890 1886 #ifdef TARGET_OS2 1891 1887 static int isapnp[SNDRV_CARDS] = {1,1,1,1,1,1,1,1}; … … 1895 1891 #endif 1896 1892 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */ 1897 #ifndef __ISAPNP__1893 #ifndef CONFIG_PNP 1898 1894 #ifdef TARGET_OS2 1899 1895 static long mpu_port[SNDRV_CARDS] = {-1,-1,-1,-1,-1,-1,-1,-1}; … … 1917 1913 MODULE_PARM_DESC(enable, "Enable ES18xx soundcard."); 1918 1914 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); 1919 #ifdef __ISAPNP__1915 #ifdef CONFIG_PNP 1920 1916 MODULE_PARM(isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 1921 MODULE_PARM_DESC(isapnp, " ISAPnP detection for specified soundcard.");1917 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard."); 1922 1918 MODULE_PARM_SYNTAX(isapnp, SNDRV_ISAPNP_DESC); 1923 1919 #endif … … 1942 1938 1943 1939 struct snd_audiodrive { 1944 #ifdef __ISAPNP__1945 struct isapnp_dev *dev;1946 struct isapnp_dev *devc;1940 #ifdef CONFIG_PNP 1941 struct pnp_dev *dev; 1942 struct pnp_dev *devc; 1947 1943 #endif 1948 1944 }; 1949 1945 1950 static snd_card_t *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 1951 1952 #ifdef __ISAPNP__ 1953 1954 static struct isapnp_card *snd_audiodrive_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 1955 static const struct isapnp_card_id *snd_audiodrive_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 1956 1957 #define ISAPNP_ES18XX(_va, _vb, _vc, _device, _audio, _control) \ 1958 { \ 1959 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 1960 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), \ 1961 ISAPNP_DEVICE_ID(_va, _vb, _vc, _control) } \ 1962 } 1963 1964 static struct isapnp_card_id snd_audiodrive_pnpids[] __devinitdata = { 1946 static snd_card_t *snd_audiodrive_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 1947 1948 #ifdef CONFIG_PNP 1949 1950 static struct pnp_card_device_id snd_audiodrive_pnpids[] __devinitdata = { 1965 1951 /* ESS 1868 (integrated on Compaq dual P-Pro motherboard and Genius 18PnP 3D) */ 1966 ISAPNP_ES18XX('E','S','S',0x1868,0x1868,0x0000),1952 { .id = "ESS1868", .devs = { { "ESS1868" }, { "ESS0000" } } }, 1967 1953 /* ESS 1868 (integrated on Maxisound Cards) */ 1968 ISAPNP_ES18XX('E','S','S',0x1868,0x8601,0x8600),1954 { .id = "ESS1868", .devs = { { "ESS8601" }, { "ESS8600" } } }, 1969 1955 /* ESS 1868 (integrated on Maxisound Cards) */ 1970 ISAPNP_ES18XX('E','S','S',0x1868,0x8611,0x8610),1956 { .id = "ESS1868", .devs = { { "ESS8611" }, { "ESS8610" } } }, 1971 1957 /* ESS ES1869 Plug and Play AudioDrive */ 1972 ISAPNP_ES18XX('E','S','S',0x0003,0x1869,0x0006),1958 { .id = "ESS0003", .devs = { { "ESS1869" }, { "ESS0006" } } }, 1973 1959 /* ESS 1869 */ 1974 ISAPNP_ES18XX('E','S','S',0x1869,0x1869,0x0006),1960 { .id = "ESS1869", .devs = { { "ESS1869" }, { "ESS0006" } } }, 1975 1961 /* ESS 1878 */ 1976 ISAPNP_ES18XX('E','S','S',0x1878,0x1878,0x0004),1962 { .id = "ESS1878", .devs = { { "ESS1878" }, { "ESS0004" } } }, 1977 1963 /* ESS 1879 */ 1978 ISAPNP_ES18XX('E','S','S',0x1879,0x1879,0x0009),1964 { .id = "ESS1879", .devs = { { "ESS1879" }, { "ESS0009" } } }, 1979 1965 /* --- */ 1980 { ISAPNP_CARD_END,} /* end */1966 { .id = "" } /* end */ 1981 1967 }; 1982 1968 1983 ISAPNP_CARD_TABLE(snd_audiodrive_pnpids); 1984 1985 static int __init snd_audiodrive_isapnp(int dev, struct snd_audiodrive *acard) 1986 { 1987 const struct isapnp_card_id *id = snd_audiodrive_isapnp_id[dev]; 1988 struct isapnp_card *card = snd_audiodrive_isapnp_cards[dev]; 1989 struct isapnp_dev *pdev; 1990 1991 acard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); 1992 if (acard->dev->active) { 1993 acard->dev = NULL; 1969 MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids); 1970 1971 static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard, 1972 struct pnp_card_link *card, 1973 const struct pnp_card_device_id *id) 1974 { 1975 struct pnp_dev *pdev; 1976 struct pnp_resource_table * cfg = kmalloc(GFP_ATOMIC, sizeof(struct pnp_resource_table)); 1977 int err; 1978 1979 if (!cfg) 1980 return -ENOMEM; 1981 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 1982 if (acard->dev == NULL) { 1983 kfree(cfg); 1994 1984 return -EBUSY; 1995 1985 } 1996 acard->devc = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL);1997 if (acard->devc ->active) {1998 acard->dev = acard->devc = NULL;1986 acard->devc = pnp_request_card_device(card, id->devs[1].id, NULL); 1987 if (acard->devc == NULL) { 1988 kfree(cfg); 1999 1989 return -EBUSY; 2000 1990 } 2001 1991 /* Control port initialization */ 2002 if (acard->devc->prepare(acard->devc)<0) 1992 err = pnp_activate_dev(acard->devc); 1993 if (err < 0) { 1994 snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n"); 2003 1995 return -EAGAIN; 2004 if (acard->devc->activate(acard->devc)<0) { 2005 printk(KERN_ERR PFX "isapnp control configure failure (out of resources?)\n"); 2006 return -EAGAIN; 2007 } 2008 snd_printdd("isapnp: port=0x%lx\n", acard->devc->resource[0].start); 1996 } 1997 snd_printdd("pnp: port=0x%lx\n", pnp_port_start(acard->devc, 0)); 2009 1998 /* PnP initialization */ 2010 1999 pdev = acard->dev; 2011 if (pdev->prepare(pdev)<0) { 2012 acard->devc->deactivate(acard->devc); 2013 return -EAGAIN; 2014 } 2000 pnp_init_resource_table(cfg); 2015 2001 if (port[dev] != SNDRV_AUTO_PORT) 2016 isapnp_resource_change(&pdev->resource[0], port[dev], 16);2002 pnp_resource_change(&cfg->port_resource[0], port[dev], 16); 2017 2003 if (fm_port[dev] != SNDRV_AUTO_PORT) 2018 isapnp_resource_change(&pdev->resource[1], fm_port[dev], 4);2004 pnp_resource_change(&cfg->port_resource[1], fm_port[dev], 4); 2019 2005 if (mpu_port[dev] != SNDRV_AUTO_PORT) 2020 isapnp_resource_change(&pdev->resource[2], mpu_port[dev], 2);2006 pnp_resource_change(&cfg->port_resource[2], mpu_port[dev], 2); 2021 2007 if (dma1[dev] != SNDRV_AUTO_DMA) 2022 isapnp_resource_change(&pdev->dma_resource[0], dma1[dev], 1);2008 pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1); 2023 2009 if (dma2[dev] != SNDRV_AUTO_DMA) 2024 isapnp_resource_change(&pdev->dma_resource[1], dma2[dev], 1);2010 pnp_resource_change(&cfg->dma_resource[1], dma2[dev], 1); 2025 2011 if (irq[dev] != SNDRV_AUTO_IRQ) 2026 isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); 2027 if (pdev->activate(pdev)<0) { 2028 printk(KERN_ERR PFX "isapnp configure failure (out of resources?)\n"); 2029 acard->devc->deactivate(acard->devc); 2012 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 2013 err = pnp_manual_config_dev(pdev, cfg, 0); 2014 if (err < 0) 2015 snd_printk(KERN_ERR PFX "PnP manual resources are invalid, using auto config\n"); 2016 err = pnp_activate_dev(pdev); 2017 if (err < 0) { 2018 snd_printk(KERN_ERR PFX "PnP configure failure (out of resources?)\n"); 2019 kfree(cfg); 2030 2020 return -EBUSY; 2031 2021 } 2032 2022 /* ok. hack using Vendor-Defined Card-Level registers */ 2033 2023 /* skip csn and logdev initialization - already done in isapnp_configure */ 2034 isapnp_cfg_begin(pdev->bus->number, pdev->devfn); 2035 isapnp_write_byte(0x27, pdev->irq_resource[0].start); /* Hardware Volume IRQ Number */ 2024 if (pnp_device_is_isapnp(pdev)) { 2025 isapnp_cfg_begin(isapnp_card_number(pdev), isapnp_csn_number(pdev)); 2026 isapnp_write_byte(0x27, pnp_irq(pdev, 0)); /* Hardware Volume IRQ Number */ 2036 2027 if (mpu_port[dev] != SNDRV_AUTO_PORT) 2037 isapnp_write_byte(0x28, pdev->irq);/* MPU-401 IRQ Number */2038 isapnp_write_byte(0x72, pdev->irq_resource[0].start); /* second IRQ */2028 isapnp_write_byte(0x28, pnp_irq(pdev, 0)); /* MPU-401 IRQ Number */ 2029 isapnp_write_byte(0x72, pnp_irq(pdev, 0)); /* second IRQ */ 2039 2030 isapnp_cfg_end(); 2040 port[dev] = pdev->resource[0].start; 2041 fm_port[dev] = pdev->resource[1].start; 2042 mpu_port[dev] = pdev->resource[2].start; 2043 dma1[dev] = pdev->dma_resource[0].start; 2044 dma2[dev] = pdev->dma_resource[1].start; 2045 irq[dev] = pdev->irq_resource[0].start; 2046 snd_printdd("isapnp ES18xx: port=0x%lx, fm port=0x%lx, mpu port=0x%lx\n", port[dev], fm_port[dev], mpu_port[dev]); 2047 snd_printdd("isapnp ES18xx: dma1=%i, dma2=%i, irq=%i\n", dma1[dev], dma2[dev], irq[dev]); 2048 return 0; 2049 } 2050 2051 static void snd_audiodrive_deactivate(struct snd_audiodrive *acard) 2052 { 2053 if (acard->devc) { 2054 acard->devc->deactivate(acard->devc); 2055 acard->devc = NULL; 2056 } 2057 if (acard->dev) { 2058 acard->dev->deactivate(acard->dev); 2059 acard->dev = NULL; 2060 } 2061 } 2062 #endif /* __ISAPNP__ */ 2063 2064 static void snd_audiodrive_free(snd_card_t *card) 2065 { 2066 struct snd_audiodrive *acard = (struct snd_audiodrive *)card->private_data; 2067 2068 if (acard) { 2069 #ifdef __ISAPNP__ 2070 snd_audiodrive_deactivate(acard); 2071 #endif 2072 } 2073 } 2074 2075 static int __init snd_audiodrive_probe(int dev) 2031 } else { 2032 snd_printk(KERN_ERR PFX "unable to install ISA PnP hack, expect malfunction\n"); 2033 } 2034 port[dev] = pnp_port_start(pdev, 0); 2035 fm_port[dev] = pnp_port_start(pdev, 1); 2036 mpu_port[dev] = pnp_port_start(pdev, 2); 2037 dma1[dev] = pnp_dma(pdev, 0); 2038 dma2[dev] = pnp_dma(pdev, 1); 2039 irq[dev] = pnp_irq(pdev, 0); 2040 snd_printdd("PnP ES18xx: port=0x%lx, fm port=0x%lx, mpu port=0x%lx\n", port[dev], fm_port[dev], mpu_port[dev]); 2041 snd_printdd("PnP ES18xx: dma1=%i, dma2=%i, irq=%i\n", dma1[dev], dma2[dev], irq[dev]); 2042 kfree(cfg); 2043 return 0; 2044 } 2045 #endif /* CONFIG_PNP_ */ 2046 2047 static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, 2048 const struct pnp_card_device_id *pid) 2076 2049 { 2077 2050 static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; … … 2090 2063 return -ENOMEM; 2091 2064 acard = (struct snd_audiodrive *)card->private_data; 2092 card->private_free = snd_audiodrive_free; 2093 #ifdef __ISAPNP__ 2094 if (isapnp[dev] && (err = snd_audiodrive_isapnp(dev, acard)) < 0) { 2065 #ifdef CONFIG_PNP 2066 if (isapnp[dev] && (err = snd_audiodrive_pnp(dev, acard, pcard, pid)) < 0) { 2095 2067 snd_card_free(card); 2096 2068 return err; … … 2143 2115 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { 2144 2116 if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { 2145 printk(KERN_ERR PFX "opl3 not detected at 0x%lx\n", chip->fm_port);2117 snd_printk(KERN_ERR PFX "opl3 not detected at 0x%lx\n", chip->fm_port); 2146 2118 } else { 2147 2119 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { … … 2189 2161 return err; 2190 2162 } 2191 snd_audiodrive_cards[dev] = card; 2192 return 0; 2193 } 2194 2195 static int __init snd_audiodrive_probe_legacy_port(unsigned long xport) 2163 if (pcard) 2164 pnp_set_card_drvdata(pcard, card); 2165 else 2166 snd_audiodrive_legacy[dev] = card; 2167 return 0; 2168 } 2169 2170 static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport) 2196 2171 { 2197 2172 static int dev; … … 2201 2176 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 2202 2177 continue; 2203 #ifdef __ISAPNP__2178 #ifdef CONFIG_PNP 2204 2179 if (isapnp[dev]) 2205 2180 continue; 2206 2181 #endif 2207 2182 port[dev] = xport; 2208 res = snd_audiodrive_probe(dev );2183 res = snd_audiodrive_probe(dev, NULL, NULL); 2209 2184 if (res < 0) 2210 2185 port[dev] = SNDRV_AUTO_PORT; … … 2215 2190 2216 2191 2217 #ifdef __ISAPNP__2218 static int __ init snd_audiodrive_isapnp_detect(struct isapnp_card*card,2219 const struct isapnp_card_id *id)2192 #ifdef CONFIG_PNP 2193 static int __devinit snd_audiodrive_pnp_detect(struct pnp_card_link *card, 2194 const struct pnp_card_device_id *id) 2220 2195 { 2221 2196 static int dev; … … 2225 2200 if (!enable[dev] || !isapnp[dev]) 2226 2201 continue; 2227 snd_audiodrive_isapnp_cards[dev] = card; 2228 snd_audiodrive_isapnp_id[dev] = id; 2229 res = snd_audiodrive_probe(dev); 2202 res = snd_audiodrive_probe(dev, card, id); 2230 2203 if (res < 0) 2231 2204 return res; … … 2236 2209 return -ENODEV; 2237 2210 } 2238 #endif /* __ISAPNP__ */ 2211 2212 static void __devexit snd_audiodrive_pnp_remove(struct pnp_card_link * pcard) 2213 { 2214 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 2215 2216 snd_card_disconnect(card); 2217 snd_card_free_in_thread(card); 2218 } 2219 2220 static struct pnp_card_driver es18xx_pnpc_driver = { 2221 .flags = PNP_DRIVER_RES_DISABLE, 2222 .name = "es18xx", 2223 .id_table = snd_audiodrive_pnpids, 2224 .probe = snd_audiodrive_pnp_detect, 2225 .remove = __devexit_p(snd_audiodrive_pnp_remove), 2226 }; 2227 #endif /* CONFIG_PNP */ 2239 2228 2240 2229 static int __init alsa_card_es18xx_init(void) … … 2247 2236 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) 2248 2237 continue; 2249 #ifdef __ISAPNP__2238 #ifdef CONFIG_PNP 2250 2239 if (isapnp[dev]) 2251 2240 continue; 2252 2241 #endif 2253 if (snd_audiodrive_probe(dev ) >= 0)2242 if (snd_audiodrive_probe(dev, NULL, NULL) >= 0) 2254 2243 cards++; 2255 2244 } 2256 2245 /* legacy auto configured cards */ 2257 2246 cards += snd_legacy_auto_probe(possible_ports, snd_audiodrive_probe_legacy_port); 2258 #ifdef __ISAPNP__2247 #ifdef CONFIG_PNP 2259 2248 /* ISA PnP cards at last */ 2260 cards += isapnp_probe_cards(snd_audiodrive_pnpids, snd_audiodrive_isapnp_detect);2249 cards += pnp_register_card_driver(&es18xx_pnpc_driver); 2261 2250 #endif 2262 2251 if(!cards) { 2252 #ifdef CONFIG_PNP 2253 pnp_unregister_card_driver(&es18xx_pnpc_driver); 2254 #endif 2263 2255 #ifdef MODULE 2264 printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n");2256 snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n"); 2265 2257 #endif 2266 2258 return -ENODEV; … … 2273 2265 int idx; 2274 2266 2267 #ifdef CONFIG_PNP 2268 /* PnP cards first */ 2269 pnp_unregister_card_driver(&es18xx_pnpc_driver); 2270 #endif 2275 2271 for(idx = 0; idx < SNDRV_CARDS; idx++) 2276 snd_card_free(snd_audiodrive_ cards[idx]);2272 snd_card_free(snd_audiodrive_legacy[idx]); 2277 2273 } 2278 2274 2279 2275 module_init(alsa_card_es18xx_init) 2280 2276 module_exit(alsa_card_es18xx_exit) 2277 2281 2278 2282 2279 #ifndef MODULE … … 2303 2300 get_option(&str,&dma1[nr_dev]) == 2 && 2304 2301 get_option(&str,&dma2[nr_dev]) == 2); 2305 #ifdef __ISAPNP__2302 #ifdef CONFIG_PNP 2306 2303 if (pnp != INT_MAX) 2307 2304 isapnp[nr_dev] = pnp; -
GPL/branches/alsa-resync1/alsa-kernel/isa/gus/gus_irq.c
r210 r246 31 31 #endif 32 32 33 voidsnd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs)33 irqreturn_t snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs) 34 34 { 35 snd_gus_card_t * gus = snd_magic_cast(snd_gus_card_t, dev_id, return );35 snd_gus_card_t * gus = snd_magic_cast(snd_gus_card_t, dev_id, return IRQ_NONE); 36 36 unsigned char status; 37 37 int loop = 100; 38 39 __again: 38 int handled = 0; 39 40 __again: 40 41 status = inb(gus->gf1.reg_irqstat); 41 42 if (status == 0) 42 return; 43 return IRQ_RETVAL(handled); 44 handled = 1; 43 45 // snd_printk("IRQ: status = 0x%x\n", status); 44 46 if (status & 0x02) { … … 102 104 if (--loop > 0) 103 105 goto __again; 106 return IRQ_NONE; 104 107 } 105 108 -
GPL/branches/alsa-resync1/alsa-kernel/isa/gus/gusmax.c
r212 r246 137 137 } 138 138 139 static voidsnd_gusmax_interrupt(int irq, void *dev_id, struct pt_regs *regs)139 static irqreturn_t snd_gusmax_interrupt(int irq, void *dev_id, struct pt_regs *regs) 140 140 { 141 141 struct snd_gusmax *maxcard = (struct snd_gusmax *) dev_id; 142 142 int loop, max = 5; 143 int handled = 0; 143 144 144 145 do { 145 146 loop = 0; 146 147 if (inb(maxcard->gus_status_reg)) { 148 handled = 1; 147 149 snd_gus_interrupt(irq, maxcard->gus, regs); 148 150 loop++; 149 151 } 150 152 if (inb(maxcard->pcm_status_reg) & 0x01) { /* IRQ bit is set? */ 153 handled = 1; 151 154 snd_cs4231_interrupt(irq, maxcard->cs4231, regs); 152 155 loop++; 153 156 } 154 157 } while (loop && --max > 0); 158 return IRQ_RETVAL(handled); 155 159 } 156 160 -
GPL/branches/alsa-resync1/alsa-kernel/isa/gus/interwave.c
r224 r246 28 28 #include <linux/init.h> 29 29 #include <linux/slab.h> 30 #ifndef LINUX_ISAPNP_H 31 #include <linux/isapnp.h> 32 #define isapnp_card pci_bus 33 #define isapnp_dev pci_dev 34 #endif 30 #include <linux/pnp.h> 35 31 #include <sound/core.h> 36 32 #include <sound/gus.h> … … 63 59 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 64 60 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 65 #ifdef __ISAPNP__61 #ifdef CONFIG_PNP 66 62 #ifdef TARGET_OS2 67 63 static int isapnp[SNDRV_CARDS] = {1,1,1,1,1,1,1,1}; … … 143 139 unsigned short gus_status_reg; 144 140 unsigned short pcm_status_reg; 145 #ifdef __ISAPNP__146 struct isapnp_dev *dev;147 #ifdef SNDRV_STB 148 struct isapnp_dev *devtc;141 #ifdef CONFIG_PNP 142 struct pnp_dev *dev; 143 #ifdef SNDRV_STB 144 struct pnp_dev *devtc; 149 145 #endif 150 146 #endif 151 147 }; 152 148 153 static snd_card_t *snd_interwave_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 154 155 #ifdef __ISAPNP__ 156 157 static struct isapnp_card *snd_interwave_isapnp_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 158 static const struct isapnp_card_id *snd_interwave_isapnp_id[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 159 160 #define ISAPNP_INTERWAVE(_va, _vb, _vc, _device, _audio) \ 161 { \ 162 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 163 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), } \ 164 } 165 #define ISAPNP_INTERWAVE_STB(_va, _vb, _vc, _device, _audio, _tone) \ 166 { \ 167 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 168 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), \ 169 ISAPNP_DEVICE_ID(_va, _vb, _vc, _tone), } \ 170 } 171 172 static struct isapnp_card_id snd_interwave_pnpids[] __devinitdata = { 149 static snd_card_t *snd_interwave_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 150 151 #ifdef CONFIG_PNP 152 153 static struct pnp_card_device_id snd_interwave_pnpids[] __devinitdata = { 173 154 #ifndef SNDRV_STB 174 155 /* Gravis UltraSound Plug & Play */ 175 ISAPNP_INTERWAVE('G','R','V',0x0001,0x0000),156 { .id = "GRV0001", .devs = { { .id = "GRV0000" } } }, 176 157 /* STB SoundRage32 */ 177 ISAPNP_INTERWAVE('S','T','B',0x011a,0x0010),158 { .id = "STB011a", .devs = { { .id = "STB0010" } } }, 178 159 /* MED3210 */ 179 ISAPNP_INTERWAVE('D','X','P',0x3201,0x0010),160 { .id = "DXP3201", .devs = { { .id = "DXP0010" } } }, 180 161 /* Dynasonic Pro */ 181 162 /* This device also have CDC1117:DynaSonix Pro Audio Effects Processor */ 182 ISAPNP_INTERWAVE('C','D','C',0x1111,0x1112),163 { .id = "CDC1111", .devs = { { .id = "CDC1112" } } }, 183 164 /* Panasonic PCA761AW Audio Card */ 184 ISAPNP_INTERWAVE('A','D','V',0x55ff,0x0010),165 { .id = "ADV55ff", .devs = { { .id = "ADV0010" } } }, 185 166 #else 186 167 /* InterWave STB with TEA6330T */ 187 ISAPNP_INTERWAVE_STB('A','D','V',0x550a,0x0010,0x0015),188 #endif 189 { ISAPNP_CARD_END,}168 { .id = "ADV550a", .devs = { { .id = "ADV0010" }, { .id = "ADV0015" } } }, 169 #endif 170 { .id = "" } 190 171 }; 191 172 192 ISAPNP_CARD_TABLE(snd_interwave_pnpids);193 194 #endif /* __ISAPNP__*/173 MODULE_DEVICE_TABLE(pnp_card, snd_interwave_pnpids); 174 175 #endif /* CONFIG_PNP */ 195 176 196 177 … … 239 220 }; 240 221 241 static int __ init snd_interwave_detect_stb(struct snd_interwave *iwcard,242 snd_gus_card_t * gus, int dev,243 snd_i2c_bus_t **rbus)222 static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard, 223 snd_gus_card_t * gus, int dev, 224 snd_i2c_bus_t **rbus) 244 225 { 245 226 unsigned long port; … … 279 260 #endif 280 261 281 static int __ init snd_interwave_detect(struct snd_interwave *iwcard,282 snd_gus_card_t * gus,283 int dev284 #ifdef SNDRV_STB 285 , snd_i2c_bus_t **rbus286 #endif 287 )262 static int __devinit snd_interwave_detect(struct snd_interwave *iwcard, 263 snd_gus_card_t * gus, 264 int dev 265 #ifdef SNDRV_STB 266 , snd_i2c_bus_t **rbus 267 #endif 268 ) 288 269 { 289 270 unsigned long flags; … … 344 325 } 345 326 346 static voidsnd_interwave_interrupt(int irq, void *dev_id, struct pt_regs *regs)327 static irqreturn_t snd_interwave_interrupt(int irq, void *dev_id, struct pt_regs *regs) 347 328 { 348 329 struct snd_interwave *iwcard = (struct snd_interwave *) dev_id; 349 330 int loop, max = 5; 331 int handled = 0; 350 332 351 333 do { 352 334 loop = 0; 353 335 if (inb(iwcard->gus_status_reg)) { 336 handled = 1; 354 337 snd_gus_interrupt(irq, iwcard->gus, regs); 355 338 loop++; 356 339 } 357 340 if (inb(iwcard->pcm_status_reg) & 0x01) { /* IRQ bit is set? */ 341 handled = 1; 358 342 snd_cs4231_interrupt(irq, iwcard->cs4231, regs); 359 343 loop++; 360 344 } 361 345 } while (loop && --max > 0); 362 } 363 364 static void __init snd_interwave_reset(snd_gus_card_t * gus) 346 return IRQ_RETVAL(handled); 347 } 348 349 static void __devinit snd_interwave_reset(snd_gus_card_t * gus) 365 350 { 366 351 snd_gf1_write8(gus, SNDRV_GF1_GB_RESET, 0x00); … … 370 355 } 371 356 372 static void __ init snd_interwave_bank_sizes(snd_gus_card_t * gus, int *sizes)357 static void __devinit snd_interwave_bank_sizes(snd_gus_card_t * gus, int *sizes) 373 358 { 374 359 unsigned int idx; … … 419 404 }; 420 405 421 static void __ init snd_interwave_detect_memory(snd_gus_card_t * gus)406 static void __devinit snd_interwave_detect_memory(snd_gus_card_t * gus) 422 407 { 423 408 static unsigned int lmc[13] = … … 522 507 } 523 508 524 static void __ init snd_interwave_init(int dev, snd_gus_card_t * gus)509 static void __devinit snd_interwave_init(int dev, snd_gus_card_t * gus) 525 510 { 526 511 unsigned long flags; … … 553 538 }; 554 539 555 static int __ init snd_interwave_mixer(cs4231_t *chip)540 static int __devinit snd_interwave_mixer(cs4231_t *chip) 556 541 { 557 542 snd_card_t *card = chip->card; … … 601 586 } 602 587 603 #ifdef __ISAPNP__ 604 605 static int __init snd_interwave_isapnp(int dev, struct snd_interwave *iwcard) 606 { 607 const struct isapnp_card_id *id = snd_interwave_isapnp_id[dev]; 608 struct isapnp_card *card = snd_interwave_isapnp_cards[dev]; 609 struct isapnp_dev *pdev; 610 611 iwcard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); 612 if (iwcard->dev->active) { 613 iwcard->dev = NULL; 588 #ifdef CONFIG_PNP 589 590 static int __devinit snd_interwave_pnp(int dev, struct snd_interwave *iwcard, 591 struct pnp_card_link *card, 592 const struct pnp_card_device_id *id) 593 { 594 struct pnp_dev *pdev; 595 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); 596 int err; 597 598 iwcard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 599 if (iwcard->dev == NULL) { 600 kfree(cfg); 614 601 return -EBUSY; 615 602 } 616 603 #ifdef SNDRV_STB 617 iwcard->devtc = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL);618 if (iwcard->devtc ->active) {619 iwcard->dev = iwcard->devtc = NULL;604 iwcard->devtc = pnp_request_card_device(card, id->devs[1].id, NULL); 605 if (iwcard->devtc == NULL) { 606 kfree(cfg); 620 607 return -EBUSY; 621 608 } … … 623 610 /* Synth & Codec initialization */ 624 611 pdev = iwcard->dev; 625 if (pdev->prepare(pdev)<0) 626 return -EAGAIN; 612 pnp_init_resource_table(cfg); 627 613 if (port[dev] != SNDRV_AUTO_PORT) { 628 isapnp_resource_change(&pdev->resource[0], port[dev], 16);629 isapnp_resource_change(&pdev->resource[1], port[dev] + 0x100, 12);630 isapnp_resource_change(&pdev->resource[2], port[dev] + 0x10c, 4);614 pnp_resource_change(&cfg->port_resource[0], port[dev], 16); 615 pnp_resource_change(&cfg->port_resource[1], port[dev] + 0x100, 12); 616 pnp_resource_change(&cfg->port_resource[2], port[dev] + 0x10c, 4); 631 617 } 632 618 if (dma1[dev] != SNDRV_AUTO_DMA) 633 isapnp_resource_change(&pdev->dma_resource[0], dma1[dev], 1);619 pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1); 634 620 if (dma2[dev] != SNDRV_AUTO_DMA) 635 isapnp_resource_change(&pdev->dma_resource[1], dma2[dev], 1);621 pnp_resource_change(&cfg->dma_resource[1], dma2[dev], 1); 636 622 if (dma2[dev] < 0) 637 isapnp_resource_change(&pdev->dma_resource[1], 4, 1);623 pnp_resource_change(&cfg->dma_resource[1], 4, 1); 638 624 if (irq[dev] != SNDRV_AUTO_IRQ) 639 isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); 640 if (pdev->activate(pdev)<0) { 641 snd_printk("isapnp configure failure (out of resources?)\n"); 642 return -EBUSY; 643 } 644 if (pdev->resource[0].start + 0x100 != pdev->resource[1].start || 645 pdev->resource[0].start + 0x10c != pdev->resource[2].start) { 646 snd_printk("isapnp configure failure (wrong ports)\n"); 647 pdev->deactivate(pdev); 625 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 626 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 627 snd_printk(KERN_ERR "InterWave - Synth - the requested resources are invalid, using auto config\n"); 628 err = pnp_activate_dev(pdev); 629 if (err < 0) { 630 kfree(cfg); 631 snd_printk(KERN_ERR "InterWave PnP configure failure (out of resources?)\n"); 632 return err; 633 } 634 if (pnp_port_start(pdev, 0) + 0x100 != pnp_port_start(pdev, 1) || 635 pnp_port_start(pdev, 0) + 0x10c != pnp_port_start(pdev, 2)) { 636 kfree(cfg); 637 snd_printk(KERN_ERR "PnP configure failure (wrong ports)\n"); 648 638 return -ENOENT; 649 639 } 650 port[dev] = p dev->resource[0].start;651 dma1[dev] = p dev->dma_resource[0].start;640 port[dev] = pnp_port_start(pdev, 0); 641 dma1[dev] = pnp_dma(pdev, 1); 652 642 if (dma2[dev] >= 0) 653 dma2[dev] = p dev->dma_resource[1].start;654 irq[dev] = p dev->irq_resource[0].start;643 dma2[dev] = pnp_dma(pdev, 1); 644 irq[dev] = pnp_irq(pdev, 0); 655 645 snd_printdd("isapnp IW: sb port=0x%lx, gf1 port=0x%lx, codec port=0x%lx\n", 656 p dev->resource[0].start,657 p dev->resource[1].start,658 p dev->resource[2].start);646 pnp_port_start(pdev, 0), 647 pnp_port_start(pdev, 1), 648 pnp_port_start(pdev, 2)); 659 649 snd_printdd("isapnp IW: dma1=%i, dma2=%i, irq=%i\n", dma1[dev], dma2[dev], irq[dev]); 660 650 #ifdef SNDRV_STB 661 651 /* Tone Control initialization */ 662 652 pdev = iwcard->devtc; 663 if (pdev->prepare(pdev)<0) { 664 iwcard->dev->deactivate(iwcard->dev); 665 return -EAGAIN; 666 } 653 pnp_init_resource_table(cfg); 667 654 if (port_tc[dev] != SNDRV_AUTO_PORT) 668 isapnp_resource_change(&pdev->resource[0], port_tc[dev], 1); 669 if (pdev->activate(pdev)<0) { 670 snd_printk("Tone Control isapnp configure failure (out of resources?)\n"); 671 iwcard->dev->deactivate(iwcard->dev); 672 return -EBUSY; 673 } 674 port_tc[dev] = pdev->resource[0].start; 655 pnp_resource_change(&cfg->port_resource[0], port_tc[dev], 1); 656 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 657 snd_printk(KERN_ERR "InterWave - ToneControl - the requested resources are invalid, using auto config\n"); 658 err = pnp_activate_dev(pdev); 659 if (err < 0) { 660 kfree(cfg); 661 snd_printk(KERN_ERR "InterWave ToneControl PnP configure failure (out of resources?)\n"); 662 return err; 663 } 664 port_tc[dev] = pnp_port_start(pdev, 0); 675 665 snd_printdd("isapnp IW: tone control port=0x%lx\n", port_tc[dev]); 676 666 #endif 667 kfree(cfg); 677 668 return 0; 678 669 } 679 680 static void snd_interwave_deactivate(struct snd_interwave *iwcard) 681 { 682 if (iwcard->dev) { 683 iwcard->dev->deactivate(iwcard->dev); 684 iwcard->dev = NULL; 685 } 686 #ifdef SNDRV_STB 687 if (iwcard->devtc) { 688 iwcard->devtc->deactivate(iwcard->devtc); 689 iwcard->devtc = NULL; 690 } 691 #endif 692 } 693 694 #endif /* __ISAPNP__ */ 670 #endif /* CONFIG_PNP */ 695 671 696 672 static void snd_interwave_free(snd_card_t *card) … … 700 676 if (iwcard == NULL) 701 677 return; 702 #ifdef __ISAPNP__703 snd_interwave_deactivate(iwcard);704 #endif705 678 #ifdef SNDRV_STB 706 679 if (iwcard->i2c_res) { … … 713 686 } 714 687 715 static int __init snd_interwave_probe(int dev) 688 static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, 689 const struct pnp_card_device_id *pid) 716 690 { 717 691 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; … … 737 711 iwcard->irq = -1; 738 712 card->private_free = snd_interwave_free; 739 #ifdef __ISAPNP__740 if (isapnp[dev] && snd_interwave_ isapnp(dev, iwcard)) {713 #ifdef CONFIG_PNP 714 if (isapnp[dev] && snd_interwave_pnp(dev, iwcard, pcard, pid)) { 741 715 snd_card_free(card); 742 716 return -ENODEV; … … 892 866 iwcard->cs4231 = cs4231; 893 867 iwcard->gus = gus; 894 snd_interwave_cards[dev++] = card; 868 if (pcard) 869 pnp_set_card_drvdata(pcard, card); 870 else 871 snd_interwave_legacy[dev++] = card; 895 872 return 0; 896 873 } 897 874 898 static int __ init snd_interwave_probe_legacy_port(unsigned long xport)875 static int __devinit snd_interwave_probe_legacy_port(unsigned long xport) 899 876 { 900 877 static int dev; … … 904 881 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 905 882 continue; 906 #ifdef __ISAPNP__883 #ifdef CONFIG_PNP 907 884 if (isapnp[dev]) 908 885 continue; 909 886 #endif 910 887 port[dev] = xport; 911 res = snd_interwave_probe(dev );888 res = snd_interwave_probe(dev, NULL, NULL); 912 889 if (res < 0) 913 890 port[dev] = SNDRV_AUTO_PORT; … … 917 894 } 918 895 919 #ifdef __ISAPNP__920 921 static int __ init snd_interwave_isapnp_detect(struct isapnp_card*card,922 const struct isapnp_card_id *id)896 #ifdef CONFIG_PNP 897 898 static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *card, 899 const struct pnp_card_device_id *id) 923 900 { 924 901 static int dev; … … 928 905 if (!enable[dev] || !isapnp[dev]) 929 906 continue; 930 snd_interwave_isapnp_cards[dev] = card; 931 snd_interwave_isapnp_id[dev] = id; 932 res = snd_interwave_probe(dev); 907 res = snd_interwave_probe(dev, card, id); 933 908 if (res < 0) 934 909 return res; … … 940 915 } 941 916 942 #endif /* __ISAPNP__ */ 917 static void __devexit snd_interwave_pnp_remove(struct pnp_card_link * pcard) 918 { 919 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 920 921 snd_card_disconnect(card); 922 snd_card_free_in_thread(card); 923 } 924 925 static struct pnp_card_driver interwave_pnpc_driver = { 926 .flags = PNP_DRIVER_RES_DISABLE, 927 .name = "interwave", 928 .id_table = snd_interwave_pnpids, 929 .probe = snd_interwave_pnp_detect, 930 .remove = __devexit_p(snd_interwave_pnp_remove), 931 }; 932 933 #endif /* CONFIG_PNP */ 943 934 944 935 static int __init alsa_card_interwave_init(void) … … 951 942 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) 952 943 continue; 953 #ifdef __ISAPNP__944 #ifdef CONFIG_PNP 954 945 if (isapnp[dev]) 955 946 continue; 956 947 #endif 957 if (!snd_interwave_probe(dev )) {948 if (!snd_interwave_probe(dev, NULL, NULL)) { 958 949 cards++; 959 950 continue; … … 965 956 /* legacy auto configured cards */ 966 957 cards += snd_legacy_auto_probe(possible_ports, snd_interwave_probe_legacy_port); 967 #ifdef __ISAPNP__958 #ifdef CONFIG_PNP 968 959 /* ISA PnP cards */ 969 cards += isapnp_probe_cards(snd_interwave_pnpids, snd_interwave_isapnp_detect);960 cards += pnp_register_card_driver(&interwave_pnpc_driver); 970 961 #endif 971 962 972 963 if (!cards) { 964 #ifdef CONFIG_PNP 965 pnp_unregister_card_driver(&interwave_pnpc_driver); 966 #endif 973 967 #ifdef MODULE 974 968 printk(KERN_ERR "InterWave soundcard not found or device busy\n"); … … 983 977 int dev; 984 978 979 #ifdef CONFIG_PNP 980 /* PnP cards first */ 981 pnp_unregister_card_driver(&interwave_pnpc_driver); 982 #endif 985 983 for (dev = 0; dev < SNDRV_CARDS; dev++) 986 snd_card_free(snd_interwave_ cards[dev]);984 snd_card_free(snd_interwave_legacy[dev]); 987 985 } 988 986 … … 1020 1018 get_option(&str,&pcm_channels[nr_dev]) == 2 && 1021 1019 get_option(&str,&effect[nr_dev]) == 2); 1022 #ifdef __ISAPNP__1020 #ifdef CONFIG_PNP 1023 1021 if (pnp != INT_MAX) 1024 1022 isapnp[nr_dev] = pnp; -
GPL/branches/alsa-resync1/alsa-kernel/isa/opl3sa2.c
r224 r246 25 25 #include <linux/pm.h> 26 26 #include <linux/slab.h> 27 #ifndef LINUX_ISAPNP_H 28 #include <linux/isapnp.h> 29 #define isapnp_card pci_bus 30 #define isapnp_dev pci_dev 31 #endif 27 #include <linux/pnp.h> 32 28 #include <sound/core.h> 33 29 #include <sound/cs4231.h> … … 52 48 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 53 49 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 54 #ifdef __ISAPNP__50 #ifdef CONFIG_PNP 55 51 #ifdef TARGET_OS2 56 52 static int isapnp[SNDRV_CARDS] = {1,1,1,1,1,1,1,1}; … … 82 78 MODULE_PARM_DESC(enable, "Enable OPL3-SA soundcard."); 83 79 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); 84 #ifdef __ISAPNP__80 #ifdef CONFIG_PNP 85 81 MODULE_PARM(isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 86 MODULE_PARM_DESC(isapnp, " ISAPnP detection for specified soundcard.");82 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard."); 87 83 MODULE_PARM_SYNTAX(isapnp, SNDRV_ISAPNP_DESC); 88 84 #endif … … 156 152 snd_rawmidi_t *rmidi; 157 153 cs4231_t *cs4231; 158 #ifdef __ISAPNP__159 struct isapnp_dev *dev;154 #ifdef CONFIG_PNP 155 struct pnp_dev *dev; 160 156 #endif 161 157 unsigned char ctlregs[0x20]; … … 170 166 }; 171 167 172 static snd_card_t *snd_opl3sa2_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 173 174 #ifdef __ISAPNP__ 175 176 static struct isapnp_card *snd_opl3sa2_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 177 static const struct isapnp_card_id *snd_opl3sa2_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 178 179 #ifdef TARGET_OS2 180 #define ISAPNP_OPL3SA2(_va, _vb, _vc, _device, _function) \ 181 { \ 182 0, ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 183 { ISAPNP_DEVICE_ID(_va, _vb, _vc, _function), } \ 184 } 185 #else 186 #define ISAPNP_OPL3SA2(_va, _vb, _vc, _device, _function) \ 187 { \ 188 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 189 devs : { ISAPNP_DEVICE_ID(_va, _vb, _vc, _function), } \ 190 } 191 #endif 192 193 static struct isapnp_card_id snd_opl3sa2_pnpids[] __devinitdata = { 168 static snd_card_t *snd_opl3sa2_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 169 170 #ifdef CONFIG_PNP 171 172 static struct pnp_card_device_id snd_opl3sa2_pnpids[] __devinitdata = { 194 173 /* Yamaha YMF719E-S (Genius Sound Maker 3DX) */ 195 ISAPNP_OPL3SA2('Y','M','H',0x0020,0x0021),174 { .id = "YMH0020", .devs = { { "YMH0021" } } }, 196 175 /* Yamaha OPL3-SA3 (integrated on Intel's Pentium II AL440LX motherboard) */ 197 ISAPNP_OPL3SA2('Y','M','H',0x0030,0x0021),176 { .id = "YMH0030", .devs = { { "YMH0021" } } }, 198 177 /* Yamaha OPL3-SA2 */ 199 ISAPNP_OPL3SA2('Y','M','H',0x0800,0x0021),178 { .id = "YMH0800", .devs = { { "YMH0021" } } }, 200 179 /* NeoMagic MagicWave 3DX */ 201 ISAPNP_OPL3SA2('N','M','X',0x2200,0x2210),180 { .id = "NMX2200", .devs = { { "YMH2210" } } }, 202 181 /* --- */ 203 { ISAPNP_CARD_END,} /* end */182 { .id = "" } /* end */ 204 183 }; 205 184 206 ISAPNP_CARD_TABLE(snd_opl3sa2_pnpids);207 208 #endif /* __ISAPNP__*/185 MODULE_DEVICE_TABLE(pnp_card, snd_opl3sa2_pnpids); 186 187 #endif /* CONFIG_PNP */ 209 188 210 189 … … 327 306 } 328 307 329 static i nt snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs *regs)308 static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs *regs) 330 309 { 331 310 unsigned short status; 332 311 opl3sa2_t *chip = dev_id; 312 int handled = 0; 333 313 334 314 if (chip == NULL || chip->card == NULL) 335 return 0;315 return IRQ_NONE; 336 316 337 317 status = snd_opl3sa2_read(chip, OPL3SA2_IRQ_STATUS); 338 318 339 if (status & 0x20) 319 if (status & 0x20) { 320 handled = 1; 340 321 snd_opl3_interrupt(chip->synth); 341 342 if ((status & 0x10) && chip->rmidi != NULL) 322 } 323 324 if ((status & 0x10) && chip->rmidi != NULL) { 325 handled = 1; 343 326 snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs); 344 345 if (status & 0x07) /* TI,CI,PI */ 327 } 328 329 if (status & 0x07) { /* TI,CI,PI */ 330 handled = 1; 346 331 snd_cs4231_interrupt(irq, chip->cs4231, regs); 332 } 347 333 348 334 if (status & 0x40) { /* hardware volume change */ 335 handled = 1; 349 336 /* reading from Master Lch register at 0x07 clears this bit */ 350 337 snd_opl3sa2_read(chip, OPL3SA2_MASTER_RIGHT); … … 355 342 } 356 343 } 357 return 0;344 return IRQ_RETVAL(handled); 358 345 } 359 346 … … 605 592 #endif /* CONFIG_PM */ 606 593 607 #ifdef __ISAPNP__ 608 static int __init snd_opl3sa2_isapnp(int dev, opl3sa2_t *chip) 609 { 610 const struct isapnp_card_id *id = snd_opl3sa2_isapnp_id[dev]; 611 struct isapnp_card *card = snd_opl3sa2_isapnp_cards[dev]; 612 struct isapnp_dev *pdev; 613 614 chip->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); 615 if (chip->dev->active) { 616 chip->dev = NULL; 594 #ifdef CONFIG_PNP 595 static int __init snd_opl3sa2_pnp(int dev, opl3sa2_t *chip, 596 struct pnp_card_link *card, 597 const struct pnp_card_device_id *id) 598 { 599 struct pnp_dev *pdev; 600 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); 601 int err; 602 603 if (!cfg) 604 return -ENOMEM; 605 pdev = chip->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 606 if (chip->dev == NULL) { 607 kfree(cfg); 617 608 return -EBUSY; 618 609 } 619 610 /* PnP initialization */ 620 pdev = chip->dev; 621 if (pdev->prepare(pdev)<0) 622 return -EAGAIN; 611 pnp_init_resource_table(cfg); 623 612 if (sb_port[dev] != SNDRV_AUTO_PORT) 624 isapnp_resource_change(&pdev->resource[0], sb_port[dev], 16); 625 if (wss_port[dev] != SNDRV_AUTO_PORT) 626 isapnp_resource_change(&pdev->resource[1], wss_port[dev], 8); 613 pnp_resource_change(&cfg->port_resource[0], sb_port[dev], 16); 614 pnp_resource_change(&cfg->port_resource[1], wss_port[dev], 8); 627 615 if (fm_port[dev] != SNDRV_AUTO_PORT) 628 isapnp_resource_change(&pdev->resource[2], fm_port[dev], 4);616 pnp_resource_change(&cfg->port_resource[2], fm_port[dev], 4); 629 617 if (midi_port[dev] != SNDRV_AUTO_PORT) 630 isapnp_resource_change(&pdev->resource[3], midi_port[dev], 2);618 pnp_resource_change(&cfg->port_resource[3], midi_port[dev], 2); 631 619 if (port[dev] != SNDRV_AUTO_PORT) 632 isapnp_resource_change(&pdev->resource[4], port[dev], 2);620 pnp_resource_change(&cfg->port_resource[4], port[dev], 2); 633 621 if (dma1[dev] != SNDRV_AUTO_DMA) 634 isapnp_resource_change(&pdev->dma_resource[0], dma1[dev], 1);622 pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1); 635 623 if (dma2[dev] != SNDRV_AUTO_DMA) 636 isapnp_resource_change(&pdev->dma_resource[1], dma2[dev], 1);624 pnp_resource_change(&cfg->dma_resource[1], dma2[dev], 1); 637 625 if (irq[dev] != SNDRV_AUTO_IRQ) 638 isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); 639 if (pdev->activate(pdev)<0) { 640 snd_printk("isapnp configure failure (out of resources?)\n"); 626 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 627 err = pnp_manual_config_dev(pdev, cfg, 0); 628 if (err < 0) 629 snd_printk(KERN_ERR "PnP manual resources are invalid, using auto config\n"); 630 err = pnp_activate_dev(pdev); 631 if (err < 0) { 632 kfree(cfg); 633 snd_printk(KERN_ERR "PnP configure failure (out of resources?)\n"); 641 634 return -EBUSY; 642 635 } 643 sb_port[dev] = p dev->resource[0].start;644 wss_port[dev] = p dev->resource[1].start;645 fm_port[dev] = p dev->resource[2].start;646 midi_port[dev] = p dev->resource[3].start;647 port[dev] = p dev->resource[4].start;648 dma1[dev] = p dev->dma_resource[0].start;649 dma2[dev] = p dev->dma_resource[1].start;650 irq[dev] = p dev->irq_resource[0].start;651 snd_printdd(" isapnpOPL3-SA: sb port=0x%lx, wss port=0x%lx, fm port=0x%lx, midi port=0x%lx\n",636 sb_port[dev] = pnp_port_start(pdev, 0); 637 wss_port[dev] = pnp_port_start(pdev, 1); 638 fm_port[dev] = pnp_port_start(pdev, 2); 639 midi_port[dev] = pnp_port_start(pdev, 3); 640 port[dev] = pnp_port_start(pdev, 4); 641 dma1[dev] = pnp_dma(pdev, 0); 642 dma2[dev] = pnp_dma(pdev, 1); 643 irq[dev] = pnp_irq(pdev, 0); 644 snd_printdd("PnP OPL3-SA: sb port=0x%lx, wss port=0x%lx, fm port=0x%lx, midi port=0x%lx\n", 652 645 sb_port[dev], wss_port[dev], fm_port[dev], midi_port[dev]); 653 snd_printdd(" isapnpOPL3-SA: control port=0x%lx, dma1=%i, dma2=%i, irq=%i\n",646 snd_printdd("PnP OPL3-SA: control port=0x%lx, dma1=%i, dma2=%i, irq=%i\n", 654 647 port[dev], dma1[dev], dma2[dev], irq[dev]); 655 return 0; 656 } 657 658 static void snd_opl3sa2_deactivate(opl3sa2_t *chip) 659 { 660 if (chip->dev) { 661 chip->dev->deactivate(chip->dev); 662 chip->dev = NULL; 663 } 664 } 665 #endif /* __ISAPNP__ */ 648 kfree(cfg); 649 return 0; 650 } 651 #endif /* CONFIG_PNP */ 666 652 667 653 static int snd_opl3sa2_free(opl3sa2_t *chip) 668 654 { 669 #ifdef __ISAPNP__670 snd_opl3sa2_deactivate(chip);671 #endif672 655 #ifdef CONFIG_PM 673 656 if (chip->pm_dev) … … 690 673 } 691 674 692 static int __init snd_opl3sa2_probe(int dev) 675 static int __devinit snd_opl3sa2_probe(int dev, 676 struct pnp_card_link *pcard, 677 const struct pnp_card_device_id *pid) 693 678 { 694 679 int xirq, xdma1, xdma2; … … 702 687 int err; 703 688 704 #ifdef __ISAPNP__689 #ifdef CONFIG_PNP 705 690 if (!isapnp[dev]) { 706 691 #endif … … 721 706 return -EINVAL; 722 707 } 723 #ifdef __ISAPNP__708 #ifdef CONFIG_PNP 724 709 } 725 710 #endif … … 737 722 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) 738 723 goto __error; 739 #ifdef __ISAPNP__740 if (isapnp[dev] && (err = snd_opl3sa2_ isapnp(dev, chip)) < 0)724 #ifdef CONFIG_PNP 725 if (isapnp[dev] && (err = snd_opl3sa2_pnp(dev, chip, pcard, pid)) < 0) 741 726 goto __error; 742 727 #endif … … 807 792 goto __error; 808 793 809 snd_opl3sa2_cards[dev] = card; 794 if (pcard) 795 pnp_set_card_drvdata(pcard, card); 796 else 797 snd_opl3sa2_legacy[dev] = card; 810 798 return 0; 811 799 … … 815 803 } 816 804 817 #ifdef __ISAPNP__818 static int __ init snd_opl3sa2_isapnp_detect(struct isapnp_card*card,819 const struct isapnp_card_id *id)805 #ifdef CONFIG_PNP 806 static int __devinit snd_opl3sa2_pnp_detect(struct pnp_card_link *card, 807 const struct pnp_card_device_id *id) 820 808 { 821 809 static int dev; … … 823 811 824 812 for ( ; dev < SNDRV_CARDS; dev++) { 825 if (!enable[dev] )813 if (!enable[dev] && !isapnp[dev]) 826 814 continue; 827 snd_opl3sa2_isapnp_cards[dev] = card; 828 snd_opl3sa2_isapnp_id[dev] = id; 829 res = snd_opl3sa2_probe(dev); 815 res = snd_opl3sa2_probe(dev, card, id); 830 816 if (res < 0) 831 817 return res; … … 835 821 return -ENODEV; 836 822 } 837 #endif /* __ISAPNP__ */ 823 824 static void __devexit snd_opl3sa2_pnp_remove(struct pnp_card_link * pcard) 825 { 826 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 827 828 snd_card_disconnect(card); 829 snd_card_free_in_thread(card); 830 } 831 832 static struct pnp_card_driver opl3sa2_pnpc_driver = { 833 .flags = PNP_DRIVER_RES_DISABLE, 834 .name = "opl3sa2", 835 .id_table = snd_opl3sa2_pnpids, 836 .probe = snd_opl3sa2_pnp_detect, 837 .remove = __devexit_p(snd_opl3sa2_pnp_remove), 838 }; 839 #endif /* CONFIG_PNP */ 838 840 839 841 static int __init alsa_card_opl3sa2_init(void) … … 844 846 if (!enable[dev]) 845 847 continue; 846 #ifdef __ISAPNP__848 #ifdef CONFIG_PNP 847 849 if (isapnp[dev]) 848 850 continue; 849 851 #endif 850 if (snd_opl3sa2_probe(dev ) >= 0)852 if (snd_opl3sa2_probe(dev, NULL, NULL) >= 0) 851 853 cards++; 852 854 } 853 #ifdef __ISAPNP__854 cards += isapnp_probe_cards(snd_opl3sa2_pnpids, snd_opl3sa2_isapnp_detect);855 #ifdef CONFIG_PNP 856 cards += pnp_register_card_driver(&opl3sa2_pnpc_driver); 855 857 #endif 856 858 if (!cards) { 857 859 #ifdef MODULE 858 printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); 860 snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); 861 #endif 862 #ifdef CONFIG_PNP 863 pnp_unregister_card_driver(&opl3sa2_pnpc_driver); 859 864 #endif 860 865 return -ENODEV; … … 867 872 int idx; 868 873 874 #ifdef CONFIG_PNP 875 /* PnP cards first */ 876 pnp_unregister_card_driver(&opl3sa2_pnpc_driver); 877 #endif 869 878 for (idx = 0; idx < SNDRV_CARDS; idx++) 870 snd_card_free(snd_opl3sa2_ cards[idx]);879 snd_card_free(snd_opl3sa2_legacy[idx]); 871 880 } 872 881 … … 901 910 get_option(&str,&dma2[nr_dev]) == 2 && 902 911 get_option(&str,&opl3sa3_ymode[nr_dev]) == 2); 903 #ifdef __ISAPNP__912 #ifdef CONFIG_PNP 904 913 if (pnp != INT_MAX) 905 914 isapnp[nr_dev] = pnp; -
GPL/branches/alsa-resync1/alsa-kernel/isa/opti9xx/opti92x-ad1848.c
r231 r246 30 30 #include <linux/init.h> 31 31 #include <linux/slab.h> 32 #ifndef LINUX_ISAPNP_H 33 #include <linux/isapnp.h> 34 #define isapnp_card pci_bus 35 #define isapnp_dev pci_dev 36 #endif 32 #include <linux/pnp.h> 37 33 #include <sound/core.h> 38 34 #ifdef CS4231 … … 48 44 #include <sound/mpu401.h> 49 45 #include <sound/opl3.h> 46 #ifdef USE_OPL4 47 #ifndef OPTi93X 48 #include "opl4.h" /* <sound/opl4.h> */ 49 #endif 50 #endif 50 51 #define SNDRV_LEGACY_FIND_FREE_IRQ 51 52 #define SNDRV_LEGACY_FIND_FREE_DMA … … 268 269 int mpu_irq; 269 270 270 #if defined(OPTi93X) 271 opti93x_t *opti93x; 272 #elif defined(CS4231) 273 cs4231_t *cs4231; 274 #else 275 ad1848_t *ad1848; 276 #endif /* AD1848 */ 277 snd_rawmidi_t *rmidi; 278 #ifdef __ISAPNP__ 279 struct isapnp_dev *dev; 280 struct isapnp_dev *devmpu; 281 #endif /* __ISAPNP__ */ 271 #ifdef CONFIG_PNP 272 struct pnp_dev *dev; 273 struct pnp_dev *devmpu; 274 #endif /* CONFIG_PNP */ 282 275 }; 283 276 284 static snd_card_t *snd_opti9xx_card = SNDRV_DEFAULT_PTR1; 285 286 #ifdef __ISAPNP__ 277 static int snd_opti9xx_first_hit = 1; 278 static snd_card_t *snd_opti9xx_legacy = SNDRV_DEFAULT_PTR1; 279 280 #ifdef CONFIG_PNP 287 281 288 282 #define ISAPNP_OPTI9XX(_va, _vb, _vc, _device, _fa, _fb, _fc, _audio, _mpu401) \ … … 293 287 } 294 288 295 static struct isapnp_card_id snd_card_opti9xx_pnpids[] = {289 static struct pnp_card_device_id snd_opti9xx_pnpids[] = { 296 290 #ifndef OPTi93X 297 291 /* OPTi 82C924 */ 298 ISAPNP_OPTI9XX('O','P','T',0x0924,'O','P','T',0x0000,0x0002),292 { .id = "OPT0924", .devs = { { "OPT0000" }, { "OPT0002" } }, .driver_data = 0x0924 }, 299 293 /* OPTi 82C925 */ 300 ISAPNP_OPTI9XX('O','P','T',0x0925,'O','P','T',0x9250,0x0002),294 { .id = "OPT0925", .devs = { { "OPT9250" }, { "OPT0002" } }, .driver_data = 0x0925 }, 301 295 #else 302 296 /* OPTi 82C931/3 */ 303 ISAPNP_OPTI9XX('O','P','T',0x0931,'O','P','T',0x9310,0x0002),297 { .id = "OPT0931", .devs = { { "OPT9310" }, { "OPT0002" } }, .driver_data = 0x0931 }, 304 298 #endif /* OPTi93X */ 305 { ISAPNP_CARD_END,}299 { .id = "" } 306 300 }; 307 301 308 ISAPNP_CARD_TABLE(snd_card_opti9xx_pnpids);309 310 #endif /* __ISAPNP__*/302 MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids); 303 304 #endif /* CONFIG_PNP */ 311 305 312 306 #ifdef OPTi93X … … 334 328 } 335 329 336 static int __ init snd_opti9xx_init(opti9xx_t *chip, unsigned short hardware)330 static int __devinit snd_opti9xx_init(opti9xx_t *chip, unsigned short hardware) 337 331 { 338 332 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; … … 479 473 480 474 481 static int __ init snd_opti9xx_configure(opti9xx_t *chip)475 static int __devinit snd_opti9xx_configure(opti9xx_t *chip) 482 476 { 483 477 unsigned char wss_base_bits; … … 976 970 { 977 971 unsigned int what = 0; 978 snd_pcm_substream_t *s = substream; 979 do { 972 struct list_head *pos; 973 snd_pcm_substream_t *s; 974 snd_pcm_group_for_each(pos, substream) { 975 s = snd_pcm_group_substream_entry(pos); 980 976 if (s == chip->playback_substream) { 981 977 what |= OPTi93X_PLAYBACK_ENABLE; … … 985 981 snd_pcm_trigger_done(s, substream); 986 982 } 987 s = s->link_next; 988 } while (s != substream); 983 } 989 984 spin_lock(&chip->lock); 990 985 if (cmd == SNDRV_PCM_TRIGGER_START) { … … 1132 1127 } 1133 1128 1134 voidsnd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *regs)1135 { 1136 opti93x_t *codec = snd_magic_cast(opti93x_t, dev_id, return );1129 irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1130 { 1131 opti93x_t *codec = snd_magic_cast(opti93x_t, dev_id, return IRQ_NONE); 1137 1132 unsigned char status; 1138 1133 … … 1145 1140 } 1146 1141 outb(0x00, OPTi93X_PORT(codec, STATUS)); 1142 return IRQ_HANDLED; 1147 1143 } 1148 1144 … … 1670 1666 #endif /* OPTi93X */ 1671 1667 1672 static int __ init snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip)1668 static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip) 1673 1669 { 1674 1670 int i, err; … … 1716 1712 } 1717 1713 1718 #ifdef __ISAPNP__ 1719 static int __init snd_card_opti9xx_isapnp(opti9xx_t *chip) 1720 { 1721 struct isapnp_dev *pdev = NULL; 1722 const struct isapnp_card_id *pid = snd_card_opti9xx_pnpids-1; 1723 static struct isapnp_card *card = NULL; 1724 1725 __again: 1726 while (1) { 1727 pid++; 1728 if (pid->card_vendor == 0) 1729 return -ENODEV; 1730 if ((card = isapnp_find_card(pid->card_vendor, pid->card_device, card))) 1731 break; 1732 } 1733 if (card == NULL) 1734 return -ENODEV; 1735 1736 chip->dev = isapnp_find_dev(card, pid->devs[0].vendor, pid->devs[0].function, NULL); 1737 if (chip->dev == NULL) 1738 goto __again; 1739 1740 chip->devmpu = isapnp_find_dev(card, pid->devs[1].vendor, pid->devs[1].function, NULL); 1714 #ifdef CONFIG_PNP 1715 static int __devinit snd_card_opti9xx_pnp(opti9xx_t *chip, struct pnp_card_link *card, 1716 const struct pnp_card_device_id *pid) 1717 { 1718 struct pnp_dev *pdev; 1719 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 1720 int err; 1721 1722 chip->dev = pnp_request_card_device(card, pid->devs[0].id, NULL); 1723 if (chip->dev == NULL) { 1724 kfree(cfg); 1725 return -EBUSY; 1726 } 1727 chip->devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); 1741 1728 1742 1729 pdev = chip->dev; 1743 if (pdev->prepare(pdev) < 0) 1744 return -EAGAIN; 1730 pnp_init_resource_table(cfg); 1745 1731 1746 1732 #ifdef OPTi93X 1747 1733 if (port != SNDRV_AUTO_PORT) 1748 isapnp_resource_change(&pdev->resource[0], port + 4, 4);1734 pnp_resource_change(&cfg->port_resource[0], port + 4, 4); 1749 1735 #else 1750 if ( (pid->card_device != ISAPNP_DEVICE(0x0924)) && (port != SNDRV_AUTO_PORT))1751 isapnp_resource_change(&pdev->resource[1], port, 4);1736 if (pid->driver_data != 0x0924 && port != SNDRV_AUTO_PORT) 1737 pnp_resource_change(&cfg->port_resource[1], port, 4); 1752 1738 #endif /* OPTi93X */ 1753 1739 if (irq != SNDRV_AUTO_IRQ) 1754 isapnp_resource_change(&pdev->irq_resource[0], irq, 1);1740 pnp_resource_change(&cfg->irq_resource[0], irq, 1); 1755 1741 if (dma1 != SNDRV_AUTO_DMA) 1756 isapnp_resource_change(&pdev->dma_resource[0], dma1, 1);1742 pnp_resource_change(&cfg->dma_resource[0], dma1, 1); 1757 1743 #if defined(CS4231) || defined(OPTi93X) 1758 1744 if (dma2 != SNDRV_AUTO_DMA) 1759 isapnp_resource_change(&pdev->dma_resource[1], dma2, 1);1745 pnp_resource_change(&cfg->dma_resource[1], dma2, 1); 1760 1746 #endif /* CS4231 || OPTi93X */ 1761 1747 if (fm_port != SNDRV_AUTO_PORT) 1762 isapnp_resource_change(&pdev->resource[1], fm_port, 4); 1763 1764 if (pdev->activate(pdev) < 0) { 1765 snd_printk("AUDIO isapnp configure failure\n"); 1766 return -EBUSY; 1748 pnp_resource_change(&cfg->port_resource[1], fm_port, 4); 1749 1750 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 1751 snd_printk(KERN_ERR "AUDIO the requested resources are invalid, using auto config\n"); 1752 err = pnp_activate_dev(pdev); 1753 if (err < 0) { 1754 snd_printk(KERN_ERR "AUDIO pnp configure failure\n"); 1755 kfree(cfg); 1756 return err; 1767 1757 } 1768 1758 1769 1759 #ifdef OPTi93X 1770 port = p dev->resource[0].start- 4;1771 fm_port = p dev->resource[1].start;1760 port = pnp_port_start(pdev, 0) - 4; 1761 fm_port = pnp_port_start(pdev, 1); 1772 1762 #else 1773 if (pid-> card_device != ISAPNP_DEVICE(0x0924))1774 port = p dev->resource[1].start;1775 fm_port = p dev->resource[2].start;1763 if (pid->driver_data != 0x0924) 1764 port = pnp_port_start(pdev, 1); 1765 fm_port = pnp_port_start(pdev, 2); 1776 1766 #endif /* OPTi93X */ 1777 irq = p dev->irq_resource[0].start;1778 dma1 = p dev->dma_resource[0].start;1767 irq = pnp_irq(pdev, 0); 1768 dma1 = pnp_dma(pdev, 0); 1779 1769 #if defined(CS4231) || defined(OPTi93X) 1780 dma2 = p dev->dma_resource[1].start;1770 dma2 = pnp_dma(pdev, 1); 1781 1771 #endif /* CS4231 || OPTi93X */ 1782 1772 1783 1773 pdev = chip->devmpu; 1784 if (pdev == NULL || pdev->prepare(pdev) < 0) { 1785 mpu_port = -1; 1786 chip->devmpu = NULL; 1787 return pid->card_device; 1788 } 1789 1790 if (mpu_port != SNDRV_AUTO_PORT) 1791 isapnp_resource_change(&pdev->resource[0], mpu_port, 2); 1792 if (mpu_irq != SNDRV_AUTO_IRQ) 1793 isapnp_resource_change(&pdev->irq_resource[0], mpu_irq, 1); 1794 1795 if (pdev->activate(pdev) < 0) { 1796 snd_printk("MPU-401 isapnp configure failure\n"); 1797 mpu_port = -1; 1798 chip->devmpu = NULL; 1799 } else { 1800 mpu_port = pdev->resource[0].start; 1801 mpu_irq = pdev->irq_resource[0].start; 1802 } 1803 return pid->card_device; 1804 } 1805 1806 static void snd_card_opti9xx_deactivate(opti9xx_t *chip) 1807 { 1808 if (chip->dev) 1809 chip->dev->deactivate(chip->dev); 1810 if (chip->devmpu) 1811 chip->devmpu->deactivate(chip->devmpu); 1812 } 1813 #endif /* __ISAPNP__ */ 1774 if (pdev) { 1775 pnp_init_resource_table(cfg); 1776 1777 if (mpu_port != SNDRV_AUTO_PORT) 1778 pnp_resource_change(&cfg->port_resource[0], mpu_port, 2); 1779 if (mpu_irq != SNDRV_AUTO_IRQ) 1780 pnp_resource_change(&cfg->irq_resource[0], mpu_irq, 1); 1781 1782 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 1783 snd_printk(KERN_ERR "AUDIO the requested resources are invalid, using auto config\n"); 1784 err = pnp_activate_dev(pdev); 1785 if (err < 0) { 1786 snd_printk(KERN_ERR "AUDIO pnp configure failure\n"); 1787 mpu_port = -1; 1788 chip->devmpu = NULL; 1789 } else { 1790 mpu_port = pnp_port_start(pdev, 0); 1791 mpu_irq = pnp_irq(pdev, 0); 1792 } 1793 } 1794 kfree(cfg); 1795 return pid->driver_data; 1796 } 1797 #endif /* CONFIG_PNP */ 1814 1798 1815 1799 #if 0 1816 static int __ init snd_card_opti9xx_resources(struct snd_card_opti9xx *chip,1817 snd_card_t *card)1800 static int __devinit snd_card_opti9xx_resources(struct snd_card_opti9xx *chip, 1801 snd_card_t *card) 1818 1802 { 1819 1803 int error, i, pnp = 0; 1820 1804 1821 #ifdef __ISAPNP__1805 #ifdef CONFIG_PNP 1822 1806 pnp = chip->dev != NULL; 1823 #endif /* __ISAPNP__*/1807 #endif /* CONFIG_PNP */ 1824 1808 1825 1809 #ifndef OPTi93X … … 1915 1899 1916 1900 if (chip) { 1917 #ifdef __ISAPNP__1918 snd_card_opti9xx_deactivate(chip);1919 #endif /* __ISAPNP__ */1920 1901 if (chip->res_mc_base) { 1921 1902 release_resource(chip->res_mc_base); … … 1925 1906 } 1926 1907 1927 static int __init snd_card_opti9xx_probe(void) 1908 static int __devinit snd_card_opti9xx_probe(struct pnp_card_link *pcard, 1909 const struct pnp_card_device_id *pid) 1928 1910 { 1929 1911 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; … … 1953 1935 snd_rawmidi_t *rmidi; 1954 1936 snd_hwdep_t *synth; 1955 #ifdef __ISAPNP__1937 #ifdef CONFIG_PNP 1956 1938 int hw; 1957 #endif /* __ISAPNP__ */ 1958 1939 #endif /* CONFIG_PNP */ 1940 1941 if (pcard && !snd_opti9xx_first_hit) 1942 return -EBUSY; 1959 1943 if (!(card = snd_card_new(index, id, THIS_MODULE, 1960 1944 sizeof(opti9xx_t)))) … … 1963 1947 chip = (opti9xx_t *)card->private_data; 1964 1948 1965 #ifdef __ISAPNP__1966 if (isapnp && (hw = snd_card_opti9xx_isapnp(chip)) > 0) {1949 #ifdef CONFIG_PNP 1950 if (isapnp && pcard && (hw = snd_card_opti9xx_pnp(chip, pcard, pid)) > 0) { 1967 1951 switch (hw) { 1968 case ISAPNP_DEVICE(0x0924):1952 case 0x0924: 1969 1953 hw = OPTi9XX_HW_82C924; 1970 1954 break; 1971 case ISAPNP_DEVICE(0x0925):1955 case 0x0925: 1972 1956 hw = OPTi9XX_HW_82C925; 1973 1957 break; 1974 case ISAPNP_DEVICE(0x0931):1958 case 0x0931: 1975 1959 hw = OPTi9XX_HW_82C931; 1976 1960 break; … … 1987 1971 chip->mc_base -= 0x80; 1988 1972 } else { 1989 #endif /* __ISAPNP__*/1973 #endif /* CONFIG_PNP */ 1990 1974 if ((error = snd_card_opti9xx_detect(card, chip)) < 0) { 1991 1975 snd_card_free(card); 1992 1976 return error; 1993 1977 } 1994 #ifdef __ISAPNP__1995 } 1996 #endif /* __ISAPNP__*/1978 #ifdef CONFIG_PNP 1979 } 1980 #endif /* CONFIG_PNP */ 1997 1981 1998 1982 if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) { … … 2011 1995 #endif 2012 1996 2013 #ifdef __ISAPNP__1997 #ifdef CONFIG_PNP 2014 1998 if (!isapnp) { 2015 1999 #endif … … 2059 2043 #endif 2060 2044 2061 #ifdef __ISAPNP__2045 #ifdef CONFIG_PNP 2062 2046 } 2063 2047 #endif … … 2128 2112 2129 2113 if (chip->fm_port > 0) { 2130 opl3_t *opl3; 2131 if (snd_opl3_create(card, 2132 chip->fm_port, 2133 chip->fm_port + 2, 2134 OPL3_HW_AUTO, 0, &opl3) < 0) { 2114 opl3_t *opl3 = NULL; 2115 #ifdef USE_OPL4 2116 #ifndef OPTi93X 2117 if (chip->hardware == OPTi9XX_HW_82C928 || 2118 chip->hardware == OPTi9XX_HW_82C929 || 2119 chip->hardware == OPTi9XX_HW_82C924) { 2120 opl4_t *opl4; 2121 /* assume we have an OPL4 */ 2122 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 2123 0x20, 0x20); 2124 if (snd_opl4_create(card, 2125 chip->fm_port, 2126 chip->fm_port - 8, 2127 2, &opl3, &opl4) < 0) { 2128 /* no luck, use OPL3 instead */ 2129 snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 2130 0x00, 0x20); 2131 } 2132 } 2133 #endif /* !OPTi93X */ 2134 #endif 2135 if (!opl3 && snd_opl3_create(card, 2136 chip->fm_port, 2137 chip->fm_port + 2, 2138 OPL3_HW_AUTO, 0, &opl3) < 0) { 2135 2139 snd_printk("no OPL device at 0x%lx-0x%lx\n", 2136 chip->fm_port, chip->fm_port + 4 - 1); 2137 } else { 2140 chip->fm_port, chip->fm_port + 4 - 1); 2141 } 2142 if (opl3) { 2138 2143 if ((error = snd_opl3_timer_new(opl3, 2139 2144 #ifdef CS4231 … … 2167 2172 return error; 2168 2173 } 2169 snd_opti9xx_card = card; 2174 snd_opti9xx_first_hit = 0; 2175 if (pcard) 2176 pnp_set_card_drvdata(pcard, card); 2177 else 2178 snd_opti9xx_legacy = card; 2170 2179 return 0; 2171 2180 } 2172 2181 2182 #ifdef CONFIG_PNP 2183 static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard) 2184 { 2185 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 2186 2187 snd_card_disconnect(card); 2188 snd_card_free_in_thread(card); 2189 snd_opti9xx_first_hit = 0; 2190 } 2191 2192 static struct pnp_card_driver opti9xx_pnpc_driver = { 2193 .flags = PNP_DRIVER_RES_DISABLE, 2194 .name = "opti9xx", 2195 .id_table = snd_opti9xx_pnpids, 2196 .probe = snd_card_opti9xx_probe, 2197 .remove = __devexit_p(snd_opti9xx_pnp_remove), 2198 }; 2199 #endif 2200 2173 2201 static int __init alsa_card_opti9xx_init(void) 2174 2202 { 2175 int error; 2176 2177 if ((error = snd_card_opti9xx_probe())) { 2203 int cards, error; 2204 2205 cards = pnp_register_card_driver(&opti9xx_pnpc_driver); 2206 if (cards == 0 && (error = snd_card_opti9xx_probe(NULL, NULL)) < 0) { 2207 #ifdef CONFIG_PNP 2208 pnp_unregister_card_driver(&opti9xx_pnpc_driver); 2209 #endif 2178 2210 #ifdef MODULE 2179 2211 #ifdef OPTi93X … … 2190 2222 static void __exit alsa_card_opti9xx_exit(void) 2191 2223 { 2192 if (snd_opti9xx_card) 2193 snd_card_free(snd_opti9xx_card); 2224 #ifdef CONFIG_PNP 2225 pnp_unregister_card_driver(&opti9xx_pnpc_driver); 2226 #endif 2227 if (snd_opti9xx_legacy) 2228 snd_card_free(snd_opti9xx_legacy); 2194 2229 } 2195 2230 … … 2224 2259 #endif 2225 2260 ); 2226 #ifdef __ISAPNP__2261 #ifdef CONFIG_PNP 2227 2262 if (pnp != INT_MAX) 2228 2263 isapnp = pnp; -
GPL/branches/alsa-resync1/alsa-kernel/isa/sb/es968.c
r224 r246 24 24 #include <linux/init.h> 25 25 #include <linux/time.h> 26 #ifndef LINUX_ISAPNP_H 27 #include <linux/isapnp.h> 28 #define isapnp_card pci_bus 29 #define isapnp_dev pci_dev 30 #endif 26 #include <linux/pnp.h> 31 27 #include <sound/core.h> 32 28 #define SNDRV_GET_ID … … 35 31 36 32 #define chip_t sb_t 33 34 #define PFX "es968: " 37 35 38 36 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); … … 69 67 70 68 struct snd_card_es968 { 71 #ifdef __ISAPNP__ 72 struct isapnp_dev *dev; 73 #endif /* __ISAPNP__ */ 69 struct pnp_dev *dev; 74 70 }; 75 71 76 static snd_card_t *snd_es968_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 77 78 #ifdef __ISAPNP__ 79 static struct isapnp_card *snd_es968_isapnp_cards[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 80 static const struct isapnp_card_id *snd_es968_isapnp_id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PTR; 81 82 static struct isapnp_card_id snd_es968_pnpids[] __devinitdata = { 83 { 84 ISAPNP_CARD_ID('E','S','S',0x0968), 85 .devs = { ISAPNP_DEVICE_ID('E','S','S',0x0968), } 86 }, 87 { ISAPNP_CARD_END, } 72 static struct pnp_card_device_id snd_es968_pnpids[] __devinitdata = { 73 { .id = "ESS0968", .devs = { { "@@@0968" }, } }, 74 { .id = "", } /* end */ 88 75 }; 89 76 90 ISAPNP_CARD_TABLE(snd_es968_pnpids); 91 92 #endif /* __ISAPNP__ */ 77 MODULE_DEVICE_TABLE(pnp_card, snd_es968_pnpids); 93 78 94 79 #define DRIVER_NAME "snd-card-es968" 95 80 96 97 static void snd_card_es968_interrupt(int irq, void *dev_id, 81 static irqreturn_t snd_card_es968_interrupt(int irq, void *dev_id, 98 82 struct pt_regs *regs) 99 83 { 100 sb_t *chip = snd_magic_cast(sb_t, dev_id, return );84 sb_t *chip = snd_magic_cast(sb_t, dev_id, return IRQ_NONE); 101 85 102 86 if (chip->open & SB_OPEN_PCM) { 103 snd_sb8dsp_interrupt(chip);87 return snd_sb8dsp_interrupt(chip); 104 88 } else { 105 snd_sb8dsp_midi_interrupt(chip); 106 } 107 } 108 109 #ifdef __ISAPNP__ 110 static int __init snd_card_es968_isapnp(int dev, struct snd_card_es968 *acard) 111 { 112 const struct isapnp_card_id *id = snd_es968_isapnp_id[dev]; 113 struct isapnp_card *card = snd_es968_isapnp_cards[dev]; 114 struct isapnp_dev *pdev; 115 116 acard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); 117 if (acard->dev->active) { 118 acard->dev = NULL; 119 return -EBUSY; 89 return snd_sb8dsp_midi_interrupt(chip); 90 } 91 } 92 93 static int __devinit snd_card_es968_pnp(int dev, struct snd_card_es968 *acard, 94 struct pnp_card_link *card, 95 const struct pnp_card_device_id *id) 96 { 97 struct pnp_dev *pdev; 98 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 99 int err; 100 if (!cfg) 101 return -ENOMEM; 102 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 103 if (acard->dev == NULL) { 104 kfree(cfg); 105 return -ENODEV; 120 106 } 121 107 122 108 pdev = acard->dev; 123 if (pdev->prepare(pdev)<0) 124 return -EAGAIN; 125 109 110 pnp_init_resource_table(cfg); 111 112 /* override resources */ 126 113 if (port[dev] != SNDRV_AUTO_PORT) 127 isapnp_resource_change(&pdev->resource[0], port[dev], 16);114 pnp_resource_change(&cfg->port_resource[0], port[dev], 16); 128 115 if (dma8[dev] != SNDRV_AUTO_DMA) 129 isapnp_resource_change(&pdev->dma_resource[0], dma8[dev], 130 1); 116 pnp_resource_change(&cfg->dma_resource[0], dma8[dev], 1); 131 117 if (irq[dev] != SNDRV_AUTO_IRQ) 132 isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); 133 134 if (pdev->activate(pdev)<0) { 135 snd_printk("AUDIO isapnp configure failure\n"); 136 return -EBUSY; 137 } 138 139 port[dev] = pdev->resource[0].start; 140 dma8[dev] = pdev->dma_resource[0].start; 141 irq[dev] = pdev->irq_resource[0].start; 142 118 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 119 if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0) 120 snd_printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n"); 121 err = pnp_activate_dev(pdev); 122 if (err < 0) { 123 snd_printk(KERN_ERR PFX "AUDIO pnp configure failure\n"); 124 return err; 125 } 126 port[dev] = pnp_port_start(pdev, 0); 127 dma8[dev] = pnp_dma(pdev, 1); 128 irq[dev] = pnp_irq(pdev, 0); 129 130 kfree(cfg); 143 131 return 0; 144 132 } 145 133 146 static void snd_card_es968_deactivate(struct snd_card_es968 *acard) 147 { 148 if (acard->dev) { 149 acard->dev->deactivate(acard->dev); 150 acard->dev = NULL; 151 } 152 } 153 #endif /* __ISAPNP__ */ 154 155 static void snd_card_es968_free(snd_card_t *card) 156 { 157 struct snd_card_es968 *acard = (struct snd_card_es968 *)card->private_data; 158 159 if (acard) { 160 #ifdef __ISAPNP__ 161 snd_card_es968_deactivate(acard); 162 #endif /* __ISAPNP__ */ 163 } 164 } 165 166 static int __init snd_card_es968_probe(int dev) 134 static int __init snd_card_es968_probe(int dev, 135 struct pnp_card_link *pcard, 136 const struct pnp_card_device_id *pid) 167 137 { 168 138 int error; … … 175 145 return -ENOMEM; 176 146 acard = (struct snd_card_es968 *)card->private_data; 177 card->private_free = snd_card_es968_free; 178 179 #ifdef __ISAPNP__ 180 if ((error = snd_card_es968_isapnp(dev, acard))) { 181 snd_card_free(card); 182 return error; 183 } 184 #else 185 snd_printk("you have to enable PnP support ...\n"); 186 snd_card_free(card); 187 return -ENOSYS; 188 #endif /* __ISAPNP__ */ 147 if ((error = snd_card_es968_pnp(dev, acard, pcard, pid))) { 148 snd_card_free(card); 149 return error; 150 } 189 151 190 152 if ((error = snd_sbdsp_create(card, port[dev], … … 222 184 return error; 223 185 } 224 snd_es968_cards[dev] = card;186 pnp_set_card_drvdata(pcard, card); 225 187 return 0; 226 188 } 227 189 228 #ifdef __ISAPNP__ 229 static int __init snd_es968_isapnp_detect(struct isapnp_card *card, 230 const struct isapnp_card_id *id) 190 static int __devinit snd_es968_pnp_detect(struct pnp_card_link *card, 191 const struct pnp_card_device_id *id) 231 192 { 232 193 static int dev; … … 236 197 if (!enable[dev]) 237 198 continue; 238 snd_es968_isapnp_cards[dev] = card; 239 snd_es968_isapnp_id[dev] = id; 240 res = snd_card_es968_probe(dev); 199 res = snd_card_es968_probe(dev, card, id); 241 200 if (res < 0) 242 201 return res; … … 246 205 return -ENODEV; 247 206 } 248 #endif /* __ISAPNP__ */ 207 208 static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard) 209 { 210 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 211 212 snd_card_disconnect(card); 213 snd_card_free_in_thread(card); 214 } 215 216 static struct pnp_card_driver es968_pnpc_driver = { 217 .flags = PNP_DRIVER_RES_DISABLE, 218 .name = "es968", 219 .id_table = snd_es968_pnpids, 220 .probe = snd_es968_pnp_detect, 221 .remove = __devexit_p(snd_es968_pnp_remove), 222 }; 249 223 250 224 static int __init alsa_card_es968_init(void) 251 225 { 252 int cards = 0;253 254 #ifdef __ISAPNP__ 255 cards += isapnp_probe_cards(snd_es968_pnpids, snd_es968_isapnp_detect);256 # else257 snd_printk("you have to enable ISA PnP support.\n");226 int res = pnp_register_card_driver(&es968_pnpc_driver); 227 if (res == 0) 228 { 229 pnp_unregister_card_driver(&es968_pnpc_driver); 230 #ifdef MODULE 231 snd_printk(KERN_ERR "no ES968 based soundcards found\n"); 258 232 #endif 259 #ifdef MODULE 260 if (!cards) 261 snd_printk("no ES968 based soundcards found\n"); 262 #endif 263 return cards ? 0 : -ENODEV; 233 } 234 return res < 0 ? res : 0; 264 235 } 265 236 266 237 static void __exit alsa_card_es968_exit(void) 267 238 { 268 int dev; 269 270 for (dev = 0; dev < SNDRV_CARDS; dev++) 271 snd_card_free(snd_es968_cards[dev]); 239 pnp_unregister_card_driver(&es968_pnpc_driver); 272 240 } 273 241 -
GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb16.c
r224 r246 24 24 #include <linux/init.h> 25 25 #include <linux/slab.h> 26 #ifndef LINUX_ISAPNP_H 27 #include <linux/isapnp.h> 28 #define isapnp_card pci_bus 29 #define isapnp_dev pci_dev 30 #endif 26 #include <linux/pnp.h> 31 27 #include <sound/core.h> 32 28 #include <sound/sb.h> … … 78 74 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 79 75 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 80 #ifdef __ISAPNP__76 #ifdef CONFIG_PNP 81 77 #ifdef TARGET_OS2 82 78 static int isapnp[SNDRV_CARDS] = {1,1,1,1,1,1,1,1}; … … 125 121 MODULE_PARM_DESC(enable, "Enable SoundBlaster 16 soundcard."); 126 122 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); 127 #ifdef __ISAPNP__123 #ifdef CONFIG_PNP 128 124 MODULE_PARM(isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 129 MODULE_PARM_DESC(isapnp, " ISAPnP detection for specified soundcard.");125 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard."); 130 126 MODULE_PARM_SYNTAX(isapnp, SNDRV_ISAPNP_DESC); 131 127 #endif … … 167 163 #endif 168 164 169 struct snd_ sb16 {165 struct snd_card_sb16 { 170 166 struct resource *fm_res; /* used to block FM i/o region for legacy cards */ 171 #ifdef __ISAPNP__ 172 struct isapnp_dev *dev; 173 #ifdef SNDRV_SBAWE_EMU8000 174 struct isapnp_dev *devwt; 167 #ifdef CONFIG_PNP 168 int dev_no; 169 struct pnp_dev *dev; 170 #ifdef SNDRV_SBAWE_EMU8000 171 struct pnp_dev *devwt; 175 172 #endif 176 173 #endif 177 174 }; 178 175 179 static snd_card_t *snd_sb16_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 180 181 #ifdef __ISAPNP__ 182 183 static struct isapnp_card *snd_sb16_isapnp_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 184 static const struct isapnp_card_id *snd_sb16_isapnp_id[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 185 186 #ifdef TARGET_OS2 187 #define ISAPNP_SB16(_va, _vb, _vc, _device, _audio) \ 188 { \ 189 0, ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 190 { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), } \ 191 } 192 #define ISAPNP_SBAWE(_va, _vb, _vc, _device, _audio, _awe) \ 193 { \ 194 0, ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 195 { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), \ 196 ISAPNP_DEVICE_ID(_va, _vb, _vc, _awe), } \ 197 } 198 #else 199 #define ISAPNP_SB16(_va, _vb, _vc, _device, _audio) \ 200 { \ 201 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 202 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), } \ 203 } 204 #define ISAPNP_SBAWE(_va, _vb, _vc, _device, _audio, _awe) \ 205 { \ 206 ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ 207 .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _audio), \ 208 ISAPNP_DEVICE_ID(_va, _vb, _vc, _awe), } \ 209 } 210 #endif 211 212 static struct isapnp_card_id snd_sb16_pnpids[] __devinitdata = { 176 static snd_card_t *snd_sb16_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 177 178 static struct pnp_card_device_id snd_sb16_pnpids[] __devinitdata = { 213 179 #ifndef SNDRV_SBAWE 214 180 /* Sound Blaster 16 PnP */ 215 ISAPNP_SB16('C','T','L',0x0024,0x0031),181 { .id = "CTL0024", .devs = { { "CTL0031" } } }, 216 182 /* Sound Blaster 16 PnP */ 217 ISAPNP_SB16('C','T','L',0x0025,0x0031),218 /* Sound Blaster 16 PnP */219 ISAPNP_SB16('C','T','L',0x0026,0x0031),220 /* Sound Blaster 16 PnP */221 ISAPNP_SB16('C','T','L',0x0027,0x0031),222 /* Sound Blaster 16 PnP */223 ISAPNP_SB16('C','T','L',0x0028,0x0031),224 /* Sound Blaster 16 PnP */225 ISAPNP_SB16('C','T','L',0x0029,0x0031),226 /* Sound Blaster 16 PnP */227 ISAPNP_SB16('C','T','L',0x002a,0x0031),183 { .id = "CTL0025", .devs = { { "CTL0031" } } }, 184 /* Sound Blaster 16 PnP */ 185 { .id = "CTL0026", .devs = { { "CTL0031" } } }, 186 /* Sound Blaster 16 PnP */ 187 { .id = "CTL0027", .devs = { { "CTL0031" } } }, 188 /* Sound Blaster 16 PnP */ 189 { .id = "CTL0028", .devs = { { "CTL0031" } } }, 190 /* Sound Blaster 16 PnP */ 191 { .id = "CTL0029", .devs = { { "CTL0031" } } }, 192 /* Sound Blaster 16 PnP */ 193 { .id = "CTL002a", .devs = { { "CTL0031" } } }, 228 194 /* Sound Blaster 16 PnP */ 229 195 /* Note: This card has also a CTL0051:StereoEnhance device!!! */ 230 ISAPNP_SB16('C','T','L',0x002b,0x0031),231 /* Sound Blaster 16 PnP */232 ISAPNP_SB16('C','T','L',0x002c,0x0031),196 { .id = "CTL002b", .devs = { { "CTL0031" } } }, 197 /* Sound Blaster 16 PnP */ 198 { .id = "CTL002c", .devs = { { "CTL0031" } } }, 233 199 /* Sound Blaster Vibra16S */ 234 ISAPNP_SB16('C','T','L',0x0051,0x0001),200 { .id = "CTL0051", .devs = { { "CTL0001" } } }, 235 201 /* Sound Blaster Vibra16C */ 236 ISAPNP_SB16('C','T','L',0x0070,0x0001),202 { .id = "CTL0070", .devs = { { "CTL0001" } } }, 237 203 /* Sound Blaster Vibra16CL - added by ctm@ardi.com */ 238 ISAPNP_SB16('C','T','L',0x0080,0x0041),204 { .id = "CTL0080", .devs = { { "CTL0041" } } }, 239 205 /* Sound Blaster 16 'value' PnP. It says model ct4130 on the pcb, */ 240 206 /* but ct4131 on a sticker on the board.. */ 241 ISAPNP_SB16('C','T','L',0x0086,0x0041),207 { .id = "CTL0086", .devs = { { "CTL0041" } } }, 242 208 /* Sound Blaster Vibra16X */ 243 ISAPNP_SB16('C','T','L',0x00f0,0x0043),209 { .id = "CTL00f0", .devs = { { "CTL0043" } } }, 244 210 #else /* SNDRV_SBAWE defined */ 245 211 /* Sound Blaster AWE 32 PnP */ 246 ISAPNP_SBAWE('C','T','L',0x0035,0x0031,0x0021),247 /* Sound Blaster AWE 32 PnP */248 ISAPNP_SBAWE('C','T','L',0x0039,0x0031,0x0021),249 /* Sound Blaster AWE 32 PnP */250 ISAPNP_SBAWE('C','T','L',0x0042,0x0031,0x0021),251 /* Sound Blaster AWE 32 PnP */252 ISAPNP_SBAWE('C','T','L',0x0043,0x0031,0x0021),212 { .id = "CTL0035", .devs = { { "CTL0031" }, { "CTL0021" } } }, 213 /* Sound Blaster AWE 32 PnP */ 214 { .id = "CTL0039", .devs = { { "CTL0031" }, { "CTL0021" } } }, 215 /* Sound Blaster AWE 32 PnP */ 216 { .id = "CTL0042", .devs = { { "CTL0031" }, { "CTL0021" } } }, 217 /* Sound Blaster AWE 32 PnP */ 218 { .id = "CTL0043", .devs = { { "CTL0031" }, { "CTL0021" } } }, 253 219 /* Sound Blaster AWE 32 PnP */ 254 220 /* Note: This card has also a CTL0051:StereoEnhance device!!! */ 255 ISAPNP_SBAWE('C','T','L',0x0044,0x0031,0x0021),221 { .id = "CTL0044", .devs = { { "CTL0031" }, { "CTL0021" } } }, 256 222 /* Sound Blaster AWE 32 PnP */ 257 223 /* Note: This card has also a CTL0051:StereoEnhance device!!! */ 258 ISAPNP_SBAWE('C','T','L',0x0045,0x0031,0x0021),259 /* Sound Blaster AWE 32 PnP */ 260 ISAPNP_SBAWE('C','T','L',0x0046,0x0031,0x0021),261 /* Sound Blaster AWE 32 PnP */262 ISAPNP_SBAWE('C','T','L',0x0047,0x0031,0x0021),263 /* Sound Blaster AWE 32 PnP */264 ISAPNP_SBAWE('C','T','L',0x0048,0x0031,0x0021),265 /* Sound Blaster AWE 32 PnP */266 ISAPNP_SBAWE('C','T','L',0x0054,0x0031,0x0021),267 /* Sound Blaster AWE 32 PnP */268 ISAPNP_SBAWE('C','T','L',0x009a,0x0041,0x0021),269 /* Sound Blaster AWE 32 PnP */270 ISAPNP_SBAWE('C','T','L',0x009c,0x0041,0x0021),224 { .id = "CTL0045", .devs = { { "CTL0031" }, { "CTL0021" } } }, 225 /* Sound Blaster AWE 32 PnP */ 226 { .id = "CTL0046", .devs = { { "CTL0031" }, { "CTL0021" } } }, 227 /* Sound Blaster AWE 32 PnP */ 228 { .id = "CTL0047", .devs = { { "CTL0031" }, { "CTL0021" } } }, 229 /* Sound Blaster AWE 32 PnP */ 230 { .id = "CTL0048", .devs = { { "CTL0031" }, { "CTL0021" } } }, 231 /* Sound Blaster AWE 32 PnP */ 232 { .id = "CTL0054", .devs = { { "CTL0031" }, { "CTL0021" } } }, 233 /* Sound Blaster AWE 32 PnP */ 234 { .id = "CTL009a", .devs = { { "CTL0041" }, { "CTL0021" } } }, 235 /* Sound Blaster AWE 32 PnP */ 236 { .id = "CTL009c", .devs = { { "CTL0041" }, { "CTL0021" } } }, 271 237 /* Sound Blaster 32 PnP */ 272 ISAPNP_SBAWE('C','T','L',0x009f,0x0041,0x0021),238 { .id = "CTL009f", .devs = { { "CTL0041" }, { "CTL0021" } } }, 273 239 /* Sound Blaster AWE 64 PnP */ 274 ISAPNP_SBAWE('C','T','L',0x009d,0x0042,0x0022),240 { .id = "CTL009d", .devs = { { "CTL0042" }, { "CTL0022" } } }, 275 241 /* Sound Blaster AWE 64 PnP Gold */ 276 ISAPNP_SBAWE('C','T','L',0x009e,0x0044,0x0023),242 { .id = "CTL009e", .devs = { { "CTL0044" }, { "CTL0023" } } }, 277 243 /* Sound Blaster AWE 64 PnP Gold */ 278 ISAPNP_SBAWE('C','T','L',0x00b2,0x0044,0x0023),244 { .id = "CTL00b2", .devs = { { "CTL0044" }, { "CTL0023" } } }, 279 245 /* Sound Blaster AWE 64 PnP */ 280 ISAPNP_SBAWE('C','T','L',0x00c1,0x0042,0x0022),246 { .id = "CTL00c1", .devs = { { "CTL0042" }, { "CTL0022" } } }, 281 247 /* Sound Blaster AWE 64 PnP */ 282 ISAPNP_SBAWE('C','T','L',0x00c3,0x0045,0x0022),248 { .id = "CTL00c3", .devs = { { "CTL0045" }, { "CTL0022" } } }, 283 249 /* Sound Blaster AWE 64 PnP */ 284 ISAPNP_SBAWE('C','T','L',0x00c5,0x0045,0x0022),250 { .id = "CTL00c5", .devs = { { "CTL0045" }, { "CTL0022" } } }, 285 251 /* Sound Blaster AWE 64 PnP */ 286 ISAPNP_SBAWE('C','T','L',0x00c7,0x0045,0x0022),252 { .id = "CTL00c7", .devs = { { "CTL0045" }, { "CTL0022" } } }, 287 253 /* Sound Blaster AWE 64 PnP */ 288 ISAPNP_SBAWE('C','T','L',0x00e4,0x0045,0x0022),254 { .id = "CTL00e4", .devs = { { "CTL0045" }, { "CTL0022" } } }, 289 255 /* Sound Blaster AWE 64 PnP */ 290 ISAPNP_SBAWE('C','T','L',0x00e9,0x0045,0x0022),256 { .id = "CTL00e9", .devs = { { "CTL0045" }, { "CTL0022" } } }, 291 257 /* Sound Blaster 16 PnP (AWE) */ 292 ISAPNP_SBAWE('C','T','L',0x00ed,0x0041,0x0070),258 { .id = "CTL00ed", .devs = { { "CTL0041" }, { "CTL0070" } } }, 293 259 /* Generic entries */ 294 ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0031,0x0021),295 ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0041,0x0021),296 ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0042,0x0022),297 ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0044,0x0023),298 ISAPNP_SBAWE('C','T','L',ISAPNP_ANY_ID,0x0045,0x0022),260 { .id = "CTLXXXX" , .devs = { { "CTL0031" }, { "CTL0021" } } }, 261 { .id = "CTLXXXX" , .devs = { { "CTL0041" }, { "CTL0021" } } }, 262 { .id = "CTLXXXX" , .devs = { { "CTL0042" }, { "CTL0022" } } }, 263 { .id = "CTLXXXX" , .devs = { { "CTL0044" }, { "CTL0023" } } }, 264 { .id = "CTLXXXX" , .devs = { { "CTL0045" }, { "CTL0022" } } }, 299 265 #endif /* SNDRV_SBAWE */ 300 { ISAPNP_CARD_END, }266 { .id = "", } 301 267 }; 302 268 303 ISAPNP_CARD_TABLE(snd_sb16_pnpids); 304 305 static int __init snd_sb16_isapnp(int dev, struct snd_sb16 *acard) 269 MODULE_DEVICE_TABLE(pnp_card, snd_sb16_pnpids); 270 271 #ifdef SNDRV_SBAWE_EMU8000 272 #define DRIVER_NAME "snd-card-sbawe" 273 #else 274 #define DRIVER_NAME "snd-card-sb16" 275 #endif 276 277 static int __devinit snd_card_sb16_pnp(int dev, struct snd_card_sb16 *acard, 278 struct pnp_card_link *card, 279 const struct pnp_card_device_id *id) 306 280 { 307 const struct isapnp_card_id *id = snd_sb16_isapnp_id[dev]; 308 struct isapnp_card *card = snd_sb16_isapnp_cards[dev]; 309 struct isapnp_dev *pdev; 310 311 acard->dev = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL); 312 if (acard->dev->active) { 313 acard->dev = NULL; 314 return -EBUSY; 315 } 316 #ifdef SNDRV_SBAWE_EMU8000 317 acard->devwt = isapnp_find_dev(card, id->devs[1].vendor, id->devs[1].function, NULL); 318 if (acard->devwt->active) { 319 acard->dev = acard->devwt = NULL; 320 return -EBUSY; 321 } 322 #endif 281 struct pnp_dev *pdev; 282 struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); 283 int err; 284 285 if (!cfg) 286 return -ENOMEM; 287 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 288 if (acard->dev == NULL) { 289 kfree(cfg); 290 return -ENODEV; 291 } 292 #ifdef SNDRV_SBAWE_EMU8000 293 acard->devwt = pnp_request_card_device(card, id->devs[1].id, acard->dev); 294 #endif 323 295 /* Audio initialization */ 324 296 pdev = acard->dev; 325 if (pdev->prepare(pdev) < 0) 326 return -EAGAIN; 297 298 pnp_init_resource_table(cfg); 299 300 /* override resources */ 301 327 302 if (port[dev] != SNDRV_AUTO_PORT) 328 isapnp_resource_change(&pdev->resource[0], port[dev], 16);303 pnp_resource_change(&cfg->port_resource[0], port[dev], 16); 329 304 if (mpu_port[dev] != SNDRV_AUTO_PORT) 330 isapnp_resource_change(&pdev->resource[1], mpu_port[dev], 2);305 pnp_resource_change(&cfg->port_resource[1], mpu_port[dev], 2); 331 306 if (fm_port[dev] != SNDRV_AUTO_PORT) 332 isapnp_resource_change(&pdev->resource[2], fm_port[dev], 4);307 pnp_resource_change(&cfg->port_resource[2], fm_port[dev], 4); 333 308 if (dma8[dev] != SNDRV_AUTO_DMA) 334 isapnp_resource_change(&pdev->dma_resource[0], dma8[dev], 1);309 pnp_resource_change(&cfg->dma_resource[0], dma8[dev], 1); 335 310 if (dma16[dev] != SNDRV_AUTO_DMA) 336 isapnp_resource_change(&pdev->dma_resource[1], dma16[dev], 1);311 pnp_resource_change(&cfg->dma_resource[1], dma16[dev], 1); 337 312 if (irq[dev] != SNDRV_AUTO_IRQ) 338 isapnp_resource_change(&pdev->irq_resource[0], irq[dev], 1); 339 if (pdev->activate(pdev) < 0) { 340 printk(KERN_ERR PFX "isapnp configure failure (out of resources?)\n"); 341 return -EBUSY; 342 } 343 port[dev] = pdev->resource[0].start; 344 mpu_port[dev] = pdev->resource[1].start; 345 fm_port[dev] = pdev->resource[2].start; 346 dma8[dev] = pdev->dma_resource[0].start; 347 dma16[dev] = pdev->dma_resource[1].start; 348 irq[dev] = pdev->irq_resource[0].start; 349 snd_printdd("isapnp SB16: port=0x%lx, mpu port=0x%lx, fm port=0x%lx\n", 313 pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); 314 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 315 snd_printk(KERN_ERR PFX "AUDIO the requested resources are invalid, using auto config\n"); 316 err = pnp_activate_dev(pdev); 317 if (err < 0) { 318 snd_printk(KERN_ERR PFX "AUDIO pnp configure failure\n"); 319 kfree(cfg); 320 return err; 321 } 322 port[dev] = pnp_port_start(pdev, 0); 323 mpu_port[dev] = pnp_port_start(pdev, 1); 324 fm_port[dev] = pnp_port_start(pdev, 2); 325 dma8[dev] = pnp_dma(pdev, 0); 326 dma16[dev] = pnp_dma(pdev, 1); 327 irq[dev] = pnp_irq(pdev, 0); 328 snd_printdd("pnp SB16: port=0x%lx, mpu port=0x%lx, fm port=0x%lx\n", 350 329 port[dev], mpu_port[dev], fm_port[dev]); 351 snd_printdd("isapnp SB16: dma1=%i, dma2=%i, irq=%i\n",330 snd_printdd("pnp SB16: dma1=%i, dma2=%i, irq=%i\n", 352 331 dma8[dev], dma16[dev], irq[dev]); 353 332 #ifdef SNDRV_SBAWE_EMU8000 354 333 /* WaveTable initialization */ 355 334 pdev = acard->devwt; 356 if (pdev->prepare(pdev)<0) { 357 acard->dev->deactivate(acard->dev); 358 return -EAGAIN; 359 } 335 if (pdev != NULL) { 336 pnp_init_resource_table(cfg); 337 338 /* override resources */ 339 360 340 if (awe_port[dev] != SNDRV_AUTO_PORT) { 361 isapnp_resource_change(&pdev->resource[0], awe_port[dev], 4); 362 isapnp_resource_change(&pdev->resource[1], awe_port[dev] + 0x400, 4); 363 isapnp_resource_change(&pdev->resource[2], awe_port[dev] + 0x800, 4); 341 pnp_resource_change(&cfg->port_resource[0], awe_port[dev], 4); 342 pnp_resource_change(&cfg->port_resource[1], awe_port[dev] + 0x400, 4); 343 pnp_resource_change(&cfg->port_resource[2], awe_port[dev] + 0x800, 4); 344 } 345 if ((pnp_manual_config_dev(pdev, cfg, 0)) < 0) 346 snd_printk(KERN_ERR PFX "WaveTable the requested resources are invalid, using auto config\n"); 347 err = pnp_activate_dev(pdev); 348 if (err < 0) { 349 goto __wt_error; 350 } 351 awe_port[dev] = pnp_port_start(pdev, 0); 352 snd_printdd("pnp SB16: wavetable port=0x%lx\n", pnp_port_start(pdev, 0)); 353 } else { 354 __wt_error: 355 if (pdev) { 356 pnp_release_card_device(pdev); 357 snd_printk(KERN_ERR PFX "WaveTable pnp configure failure\n"); 358 } 359 acard->devwt = NULL; 360 awe_port[dev] = -1; 364 361 } 365 if (pdev->activate(pdev)<0) { 366 printk(KERN_ERR PFX "WaveTable isapnp configure failure (out of resources?)\n"); 367 acard->dev->deactivate(acard->dev); 368 return -EBUSY; 369 } 370 awe_port[dev] = pdev->resource[0].start; 371 snd_printdd("isapnp SB16: wavetable port=0x%lx\n", pdev->resource[0].start); 372 #endif 373 return 0; 362 #endif 363 kfree(cfg); 364 return 0; 374 365 } 375 366 376 static void snd_sb16_deactivate(struct snd_sb16 *acard) 377 { 378 if (acard->dev) { 379 acard->dev->deactivate(acard->dev); 380 acard->dev = NULL; 381 } 382 #ifdef SNDRV_SBAWE_EMU8000 383 if (acard->devwt) { 384 acard->devwt->deactivate(acard->devwt); 385 acard->devwt = NULL; 386 } 387 #endif 388 } 389 390 #endif /* __ISAPNP__ */ 391 392 static void snd_sb16_free(snd_card_t *card) 393 { 394 struct snd_sb16 *acard = (struct snd_sb16 *)card->private_data; 395 396 if (acard == NULL) 397 return; 398 if (acard->fm_res) { 399 release_resource(acard->fm_res); 400 kfree_nocheck(acard->fm_res); 401 } 402 #ifdef __ISAPNP__ 403 snd_sb16_deactivate(acard); 404 #endif 405 } 406 407 static int __init snd_sb16_probe(int dev) 367 static int __init snd_sb16_probe(int dev, 368 struct pnp_card_link *pcard, 369 const struct pnp_card_device_id *pid) 408 370 { 409 371 static int possible_irqs[] = {5, 9, 10, 7, -1}; … … 413 375 sb_t *chip; 414 376 snd_card_t *card; 415 struct snd_sb16 *acard;377 struct snd_card_sb16 *acard; 416 378 opl3_t *opl3; 417 379 snd_hwdep_t *synth = NULL; … … 423 385 424 386 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 425 sizeof(struct snd_sb16));387 sizeof(struct snd_card_sb16)); 426 388 if (card == NULL) 427 389 return -ENOMEM; 428 acard = (struct snd_sb16 *) card->private_data; 429 card->private_free = snd_sb16_free; 430 #ifdef __ISAPNP__ 431 if (isapnp[dev] && snd_sb16_isapnp(dev, acard) < 0) { 432 snd_card_free(card); 433 return -EBUSY; 434 } 435 #endif 390 acard = (struct snd_card_sb16 *) card->private_data; 391 if (isapnp[dev]) { 392 if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid))) { 393 snd_card_free(card); 394 return err; 395 } 396 } 436 397 437 398 xirq = irq[dev]; 438 399 xdma8 = dma8[dev]; 439 400 xdma16 = dma16[dev]; 440 #ifdef __ISAPNP__401 #ifdef CONFIG_PNP 441 402 if (!isapnp[dev]) { 442 403 #endif … … 444 405 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { 445 406 snd_card_free(card); 446 printk(KERN_ERR PFX "unable to find a free IRQ\n");407 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); 447 408 return -EBUSY; 448 409 } … … 451 412 if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) { 452 413 snd_card_free(card); 453 printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n");414 snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); 454 415 return -EBUSY; 455 416 } … … 458 419 if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) { 459 420 snd_card_free(card); 460 printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n");421 snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); 461 422 return -EBUSY; 462 423 } … … 470 431 awe_port[dev] = port[dev] + 0x400; 471 432 #endif 472 #ifdef __ISAPNP__433 #ifdef CONFIG_PNP 473 434 } 474 435 #endif … … 491 452 } 492 453 chip->mpu_port = mpu_port[dev]; 493 #ifdef __ISAPNP__454 #ifdef CONFIG_PNP 494 455 if (!isapnp[dev] && (err = snd_sb16dsp_configure(chip)) < 0) { 495 456 #else … … 518 479 OPL3_HW_OPL3, fm_port[dev] == port[dev], 519 480 &opl3) < 0) { 520 printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n",481 snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n", 521 482 fm_port[dev], fm_port[dev] + 2); 522 483 } else { … … 546 507 chip->hardware = SB_HW_16CSP; 547 508 } else { 548 printk(KERN_INFO PFX "warning - CSP chip not detected on soundcard #%i\n", dev + 1);509 snd_printk(KERN_INFO PFX "warning - CSP chip not detected on soundcard #%i\n", dev + 1); 549 510 } 550 511 } … … 554 515 if (snd_emu8000_new(card, 1, awe_port[dev], 555 516 seq_ports[dev], NULL) < 0) { 556 printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]);517 snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]); 557 518 snd_card_free(card); 558 519 return -ENXIO; … … 587 548 return err; 588 549 } 589 snd_sb16_cards[dev] = card; 550 if (pcard) 551 pnp_set_card_drvdata(pcard, card); 552 else 553 snd_sb16_legacy[dev] = card; 590 554 return 0; 591 555 } … … 599 563 if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) 600 564 continue; 601 #ifdef __ISAPNP__565 #ifdef CONFIG_PNP 602 566 if (isapnp[dev]) 603 567 continue; 604 568 #endif 605 569 port[dev] = xport; 606 res = snd_sb16_probe(dev);570 res = snd_sb16_probe(dev, NULL, NULL); 607 571 if (res < 0) 608 572 port[dev] = SNDRV_AUTO_PORT; … … 612 576 } 613 577 614 #ifdef __ISAPNP__615 616 static int __init snd_sb16_isapnp_detect(struct isapnp_card*card,617 const struct isapnp_card_id *id)578 #ifdef CONFIG_PNP 579 580 static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *card, 581 const struct pnp_card_device_id *id) 618 582 { 619 583 static int dev; … … 623 587 if (!enable[dev] || !isapnp[dev]) 624 588 continue; 625 snd_sb16_isapnp_cards[dev] = card; 626 snd_sb16_isapnp_id[dev] = id; 627 res = snd_sb16_probe(dev); 589 res = snd_sb16_probe(dev, card, id); 628 590 if (res < 0) 629 591 return res; … … 635 597 } 636 598 637 #endif /* __ISAPNP__ */ 599 static void __devexit snd_sb16_pnp_remove(struct pnp_card_link * pcard) 600 { 601 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 602 603 snd_card_disconnect(card); 604 snd_card_free_in_thread(card); 605 } 606 607 static struct pnp_card_driver sb16_pnpc_driver = { 608 .flags = PNP_DRIVER_RES_DISABLE, 609 .name = "sb16", 610 .id_table = snd_sb16_pnpids, 611 .probe = snd_sb16_pnp_detect, 612 .remove = __devexit_p(snd_sb16_pnp_remove), 613 }; 614 615 #endif /* CONFIG_PNP */ 638 616 639 617 static int __init alsa_card_sb16_init(void) … … 646 624 if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) 647 625 continue; 648 #ifdef __ISAPNP__626 #ifdef CONFIG_PNP 649 627 if (isapnp[dev]) 650 628 continue; 651 629 #endif 652 if (!snd_sb16_probe(dev)) {630 if (!snd_sb16_probe(dev, NULL, NULL)) { 653 631 cards++; 654 632 continue; 655 633 } 656 634 #ifdef MODULE 657 printk(KERN_ERR "Sound Blaster 16+ soundcard #%i not found at 0x%lx or device busy\n", dev, port[dev]);658 #endif 635 snd_printk(KERN_ERR "Sound Blaster 16+ soundcard #%i not found at 0x%lx or device busy\n", dev, port[dev]); 636 #endif 659 637 } 660 638 /* legacy auto configured cards */ 661 639 cards += snd_legacy_auto_probe(possible_ports, snd_sb16_probe_legacy_port); 662 #ifdef __ISAPNP__663 /* ISAPnP cards at last */664 cards += isapnp_probe_cards(snd_sb16_pnpids, snd_sb16_isapnp_detect);640 #ifdef CONFIG_PNP 641 /* PnP cards at last */ 642 cards += pnp_register_card_driver(&sb16_pnpc_driver); 665 643 #endif 666 644 667 645 if (!cards) { 646 #ifdef CONFIG_PNP 647 pnp_unregister_card_driver(&sb16_pnpc_driver); 648 #endif 668 649 #ifdef MODULE 669 printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n");670 #ifdef SNDRV_SBAWE_EMU8000 671 printk(KERN_ERR "In case, if you have non-AWE card, try snd-sb16 module\n");672 #else 673 printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n");650 snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n"); 651 #ifdef SNDRV_SBAWE_EMU8000 652 snd_printk(KERN_ERR "In case, if you have non-AWE card, try snd-sb16 module\n"); 653 #else 654 snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n"); 674 655 #endif 675 656 #endif … … 683 664 int dev; 684 665 666 #ifdef CONFIG_PNP 667 /* PnP cards first */ 668 pnp_unregister_card_driver(&sb16_pnpc_driver); 669 #endif 685 670 for (dev = 0; dev < SNDRV_CARDS; dev++) 686 snd_card_free(snd_sb16_cards[dev]);671 snd_card_free(snd_sb16_legacy[dev]); 687 672 } 688 673 … … 727 712 #endif 728 713 ); 729 #ifdef __ISAPNP__714 #ifdef CONFIG_PNP 730 715 if (pnp != INT_MAX) 731 716 isapnp[nr_dev] = pnp; -
GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb16_main.c
r224 r246 394 394 } 395 395 396 voidsnd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs)396 irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs) 397 397 { 398 398 sb_t *chip = dev_id; … … 439 439 spin_unlock(&chip->reg_lock); 440 440 } 441 return IRQ_HANDLED; 441 442 } 442 443 -
GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb8.c
r224 r246 71 71 static snd_card_t *snd_sb8_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 72 72 73 static voidsnd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs)74 { 75 sb_t *chip = snd_magic_cast(sb_t, dev_id, return );73 static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs) 74 { 75 sb_t *chip = snd_magic_cast(sb_t, dev_id, return IRQ_NONE); 76 76 77 77 if (chip->open & SB_OPEN_PCM) { 78 snd_sb8dsp_interrupt(chip);78 return snd_sb8dsp_interrupt(chip); 79 79 } else { 80 snd_sb8dsp_midi_interrupt(chip);80 return snd_sb8dsp_midi_interrupt(chip); 81 81 } 82 82 } … … 144 144 OPL3_HW_AUTO, 1, 145 145 &opl3)) < 0) { 146 printk(KERN_ERR "sb8: no OPL device at 0x%lx\n", chip->port + 8);146 snd_printk(KERN_ERR "sb8: no OPL device at 0x%lx\n", chip->port + 8); 147 147 } 148 148 } else { … … 150 150 OPL3_HW_AUTO, 1, 151 151 &opl3)) < 0) { 152 printk(KERN_ERR "sb8: no OPL device at 0x%lx-0x%lx\n",152 snd_printk(KERN_ERR "sb8: no OPL device at 0x%lx-0x%lx\n", 153 153 chip->port, chip->port + 2); 154 154 } … … 211 211 if (!cards) { 212 212 #ifdef MODULE 213 printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n");213 snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n"); 214 214 #endif 215 215 return -ENODEV; -
GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb8_main.c
r224 r246 332 332 } 333 333 334 voidsnd_sb8dsp_interrupt(sb_t *chip)334 irqreturn_t snd_sb8dsp_interrupt(sb_t *chip) 335 335 { 336 336 snd_pcm_substream_t *substream; … … 357 357 break; 358 358 } 359 return IRQ_HANDLED; 359 360 } 360 361 -
GPL/branches/alsa-resync1/alsa-kernel/isa/sb/sb8_midi.c
r210 r246 34 34 */ 35 35 36 voidsnd_sb8dsp_midi_interrupt(sb_t * chip)36 irqreturn_t snd_sb8dsp_midi_interrupt(sb_t * chip) 37 37 { 38 38 snd_rawmidi_t *rmidi; … … 42 42 if (chip == NULL || (rmidi = chip->rmidi) == NULL) { 43 43 inb(SBP(chip, READ)); /* ack interrupt */ 44 return;44 return IRQ_NONE; 45 45 } 46 46 while (max-- > 0) { … … 54 54 } 55 55 } 56 return IRQ_HANDLED; 56 57 } 57 58 … … 206 207 if (up) { 207 208 if (!(chip->open & SB_OPEN_MIDI_TRIGGER)) { 209 init_timer(&chip->midi_timer); 208 210 chip->midi_timer.function = snd_sb8dsp_midi_output_timer; 209 211 chip->midi_timer.data = (unsigned long) substream; -
GPL/branches/alsa-resync1/alsa-kernel/isa/sgalaxy.c
r224 r246 113 113 } 114 114 115 static void snd_sgalaxy_dummy_interrupt(int irq, void *dev_id, struct pt_regs *regs) 116 { 115 static irqreturn_t snd_sgalaxy_dummy_interrupt(int irq, void *dev_id, struct pt_regs *regs) 116 { 117 return IRQ_NONE; 117 118 } 118 119 … … 307 308 if (!cards) { 308 309 #ifdef MODULE 309 printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n");310 snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n"); 310 311 #endif 311 312 return -ENODEV; -
GPL/branches/alsa-resync1/alsa-kernel/isa/wavefront/wavefront.c
r212 r246 22 22 #include <sound/driver.h> 23 23 #include <linux/init.h> 24 #include <linux/interrupt.h> 24 25 #include <linux/slab.h> 25 #ifndef LINUX_ISAPNP_H 26 #include <linux/isapnp.h> 27 #define isapnp_card pci_bus 28 #define isapnp_dev pci_dev 29 #endif 26 #include <linux/pnp.h> 30 27 #include <sound/core.h> 31 28 #define SNDRV_GET_ID … … 66 63 MODULE_PARM_DESC(enable, "Enable WaveFront soundcard."); 67 64 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); 68 #ifdef __ISAPNP__65 #ifdef CONFIG_PNP 69 66 MODULE_PARM(isapnp, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); 70 67 MODULE_PARM_DESC(isapnp, "ISA PnP detection for WaveFront soundcards."); … … 102 99 MODULE_PARM_SYNTAX(use_cs4232_midi, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC); 103 100 104 static snd_card_t *snd_wavefront_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 105 106 #ifdef __ISAPNP__ 107 108 static struct isapnp_card *snd_wavefront_isapnp_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 109 static const struct isapnp_card_id *snd_wavefront_isapnp_id[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 110 111 static struct isapnp_card_id snd_wavefront_pnpids[] __devinitdata = { 112 { 113 ISAPNP_CARD_ID('C','S','C',0x7532), /* Tropez */ 114 .devs = { ISAPNP_DEVICE_ID('C','S','C',0x0000), /* WSS */ 115 ISAPNP_DEVICE_ID('C','S','C',0x0010), /* CTRL */ 116 ISAPNP_DEVICE_ID('P','n','P',0xb006), /* MPU */ 117 ISAPNP_DEVICE_ID('C','S','C',000004), }, /* SYNTH */ 118 }, 119 { 120 ISAPNP_CARD_ID('C','S','C',0x7632), /* Tropez+ */ 121 .devs = { ISAPNP_DEVICE_ID('C','S','C',0x0000), /* WSS */ 122 ISAPNP_DEVICE_ID('C','S','C',0x0010), /* CTRL */ 123 ISAPNP_DEVICE_ID('P','n','P',0xb006), /* MPU */ 124 ISAPNP_DEVICE_ID('C','S','C',000004), }, /* SYNTH */ 125 }, 126 { ISAPNP_CARD_END, } 101 static snd_card_t *snd_wavefront_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; 102 103 #ifdef CONFIG_PNP 104 105 static struct pnp_card_device_id snd_wavefront_pnpids[] __devinitdata = { 106 /* Tropez */ 107 { .id = "CSC7532", .devs = { { "CSC0000" }, { "CSC0010" }, { "PnPb006" }, { "CSC0004" } } }, 108 /* Tropez+ */ 109 { .id = "CSC7632", .devs = { { "CSC0000" }, { "CSC0010" }, { "PnPb006" }, { "CSC0004" } } }, 110 { .id = "" } 127 111 }; 128 112 129 ISAPNP_CARD_TABLE(snd_wavefront_pnpids); 130 131 static int __init 132 snd_wavefront_isapnp (int dev, snd_wavefront_card_t *acard) 133 { 134 const struct isapnp_card_id *id = snd_wavefront_isapnp_id[dev]; 135 struct isapnp_card *card = snd_wavefront_isapnp_cards[dev]; 136 struct isapnp_dev *pdev; 137 int tmp; 113 MODULE_DEVICE_TABLE(pnp_card, snd_wavefront_pnpids); 114 115 static int __devinit 116 snd_wavefront_pnp (int dev, snd_wavefront_card_t *acard, struct pnp_card_link *card, 117 const struct pnp_card_device_id *id) 118 { 119 struct pnp_dev *pdev; 120 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 121 int err; 122 123 if (!cfg) 124 return -ENOMEM; 138 125 139 126 /* Check for each logical device. */ … … 141 128 /* CS4232 chip (aka "windows sound system") is logical device 0 */ 142 129 143 acard->wss = isapnp_find_dev(card, id->devs[0].vendor, id->devs[0].function, NULL);144 if (acard->wss ->active) {145 acard->wss = NULL;130 acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL); 131 if (acard->wss == NULL) { 132 kfree(cfg); 146 133 return -EBUSY; 147 134 } … … 159 146 160 147 if (use_cs4232_midi[dev]) { 161 acard->mpu = isapnp_find_dev(card, id->devs[2].vendor, id->devs[2].function, NULL);162 if (acard->mpu ->active) {163 acard->wss = acard->synth = acard->mpu = NULL;148 acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL); 149 if (acard->mpu == NULL) { 150 kfree(cfg); 164 151 return -EBUSY; 165 152 } … … 168 155 /* The ICS2115 synth is logical device 4 */ 169 156 170 acard->synth = isapnp_find_dev(card, id->devs[3].vendor, id->devs[3].function, NULL);171 if (acard->synth ->active) {172 acard->wss = acard->synth = NULL;157 acard->synth = pnp_request_card_device(card, id->devs[3].id, NULL); 158 if (acard->synth == NULL) { 159 kfree(cfg); 173 160 return -EBUSY; 174 161 } … … 178 165 pdev = acard->wss; 179 166 180 if ((tmp = pdev->prepare (pdev)) < 0) { 181 if (tmp == -EBUSY) { 182 snd_printk ("ISA PnP configuration appears to have " 183 "been done. Restart the isapnp module.\n"); 184 return 0; 185 } 186 snd_printk ("isapnp WSS preparation failed\n"); 187 return -EAGAIN; 188 } 167 pnp_init_resource_table(cfg); 189 168 190 169 /* An interesting note from the Tropez+ FAQ: … … 201 180 202 181 if (cs4232_pcm_port[dev] != SNDRV_AUTO_PORT) 203 isapnp_resource_change(&pdev->resource[0], cs4232_pcm_port[dev], 4);204 182 if (fm_port[dev] != SNDRV_AUTO_PORT) 205 isapnp_resource_change(&pdev->resource[1], fm_port[dev], 4);183 pnp_resource_change(&cfg->port_resource[1], fm_port[dev], 4); 206 184 if (dma1[dev] != SNDRV_AUTO_DMA) 207 isapnp_resource_change(&pdev->dma_resource[0], dma1[dev], 1);185 pnp_resource_change(&cfg->dma_resource[0], dma1[dev], 1); 208 186 if (dma2[dev] != SNDRV_AUTO_DMA) 209 isapnp_resource_change(&pdev->dma_resource[1], dma2[dev], 1);187 pnp_resource_change(&cfg->dma_resource[1], dma2[dev], 1); 210 188 if (cs4232_pcm_irq[dev] != SNDRV_AUTO_IRQ) 211 isapnp_resource_change(&pdev->irq_resource[0], cs4232_pcm_irq[dev], 1); 212 213 if (pdev->activate(pdev)<0) { 214 snd_printk ("isapnp WSS activation failed\n"); 215 return -EBUSY; 216 } 217 218 cs4232_pcm_port[dev] = pdev->resource[0].start; 219 fm_port[dev] = pdev->resource[1].start; 220 dma1[dev] = pdev->dma_resource[0].start; 221 dma2[dev] = pdev->dma_resource[1].start; 222 cs4232_pcm_irq[dev] = pdev->irq_resource[0].start; 189 pnp_resource_change(&cfg->irq_resource[0], cs4232_pcm_irq[dev], 1); 190 191 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 192 snd_printk(KERN_ERR "PnP WSS the requested resources are invalid, using auto config\n"); 193 err = pnp_activate_dev(pdev); 194 if (err < 0) { 195 snd_printk(KERN_ERR "PnP WSS pnp configure failure\n"); 196 kfree(cfg); 197 return err; 198 } 199 200 cs4232_pcm_port[dev] = pnp_port_start(pdev, 0); 201 fm_port[dev] = pnp_port_start(pdev, 1); 202 dma1[dev] = pnp_dma(pdev, 0); 203 dma2[dev] = pnp_dma(pdev, 1); 204 cs4232_pcm_irq[dev] = pnp_irq(pdev, 0); 223 205 224 206 /* Synth initialization */ … … 226 208 pdev = acard->synth; 227 209 228 if ((tmp = pdev->prepare(pdev))<0) { 229 if (tmp == -EBUSY) { 230 snd_printk ("ISA PnP configuration appears to have " 231 "been done. Restart the isapnp module.\n"); 232 } 233 acard->wss->deactivate(acard->wss); 234 snd_printk ("ICS2115 synth preparation failed\n"); 235 return -EAGAIN; 236 } 210 pnp_init_resource_table(cfg); 211 237 212 if (ics2115_port[dev] != SNDRV_AUTO_PORT) { 238 isapnp_resource_change(&pdev->resource[0], ics2115_port[dev], 16);213 pnp_resource_change(&cfg->port_resource[0], ics2115_port[dev], 16); 239 214 } 240 215 241 216 if (ics2115_port[dev] != SNDRV_AUTO_IRQ) { 242 isapnp_resource_change(&pdev->irq_resource[0], ics2115_irq[dev], 1); 243 } 244 245 if (pdev->activate(pdev)<0) { 246 snd_printk("isapnp activation for ICS2115 failed\n"); 247 acard->wss->deactivate(acard->wss); 248 return -EBUSY; 249 } 250 251 ics2115_port[dev] = pdev->resource[0].start; 252 ics2115_irq[dev] = pdev->irq_resource[0].start; 217 pnp_resource_change(&cfg->irq_resource[0], ics2115_irq[dev], 1); 218 } 219 220 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 221 snd_printk(KERN_ERR "PnP ICS2115 the requested resources are invalid, using auto config\n"); 222 err = pnp_activate_dev(pdev); 223 if (err < 0) { 224 snd_printk(KERN_ERR "PnP ICS2115 pnp configure failure\n"); 225 kfree(cfg); 226 return err; 227 } 228 229 ics2115_port[dev] = pnp_port_start(pdev, 0); 230 ics2115_irq[dev] = pnp_irq(pdev, 0); 253 231 254 232 /* CS4232 MPU initialization. Configure this only if … … 261 239 pdev = acard->mpu; 262 240 263 if (pdev->prepare(pdev)<0) { 264 acard->wss->deactivate(acard->wss); 265 if (acard->synth) 266 acard->synth->deactivate(acard->synth); 267 snd_printk ("CS4232 MPU preparation failed\n"); 268 return -EAGAIN; 269 } 241 pnp_init_resource_table(cfg); 270 242 271 243 if (cs4232_mpu_port[dev] != SNDRV_AUTO_PORT) 272 isapnp_resource_change(&pdev->resource[0], cs4232_mpu_port[dev], 2);244 pnp_resource_change(&cfg->port_resource[0], cs4232_mpu_port[dev], 2); 273 245 if (cs4232_mpu_irq[dev] != SNDRV_AUTO_IRQ) 274 isapnp_resource_change(&pdev->resource[0], cs4232_mpu_irq[dev], 1); 275 276 if (pdev->activate(pdev)<0) { 277 snd_printk("isapnp CS4232 MPU activation failed\n"); 246 pnp_resource_change(&cfg->port_resource[0], cs4232_mpu_irq[dev], 1); 247 248 if (pnp_manual_config_dev(pdev, cfg, 0) < 0) 249 snd_printk(KERN_ERR "PnP MPU401 the requested resources are invalid, using auto config\n"); 250 err = pnp_activate_dev(pdev); 251 if (err < 0) { 252 snd_printk(KERN_ERR "PnP MPU401 pnp configure failure\n"); 278 253 cs4232_mpu_port[dev] = SNDRV_AUTO_PORT; 279 254 } else { 280 cs4232_mpu_port[dev] = p dev->resource[0].start;281 cs4232_mpu_irq[dev] = p dev->irq_resource[0].start;255 cs4232_mpu_port[dev] = pnp_port_start(pdev, 0); 256 cs4232_mpu_irq[dev] = pnp_irq(pdev, 0); 282 257 } 283 258 … … 296 271 ics2115_irq[dev]); 297 272 273 kfree(cfg); 298 274 return 0; 299 275 } 300 276 301 static void 302 snd_wavefront_deactivate (snd_wavefront_card_t *acard) 303 { 304 snd_printk ("deactivating PnP devices\n"); 305 if (acard->wss) { 306 acard->wss->deactivate(acard->wss); 307 acard->wss = NULL; 308 } 309 if (acard->ctrl) { 310 acard->ctrl->deactivate(acard->ctrl); 311 acard->ctrl = NULL; 312 } 313 if (acard->mpu) { 314 acard->mpu->deactivate(acard->mpu); 315 acard->mpu = NULL; 316 } 317 if (acard->synth) { 318 acard->synth->deactivate(acard->synth); 319 acard->synth = NULL; 320 } 321 } 322 323 #endif /* __ISAPNP__ */ 324 325 static void snd_wavefront_ics2115_interrupt(int irq, 277 #endif /* CONFIG_PNP */ 278 279 static irqreturn_t snd_wavefront_ics2115_interrupt(int irq, 326 280 void *dev_id, 327 281 struct pt_regs *regs) … … 332 286 333 287 if (acard == NULL) 334 return ;288 return IRQ_NONE; 335 289 336 290 if (acard->wavefront.interrupts_are_midi) { … … 339 293 snd_wavefront_internal_interrupt (acard); 340 294 } 341 } 342 343 snd_hwdep_t * __init 295 return IRQ_HANDLED; 296 } 297 298 snd_hwdep_t * __devinit 344 299 snd_wavefront_new_synth (snd_card_t *card, 345 300 int hw_dev, … … 367 322 } 368 323 369 snd_hwdep_t * __ init324 snd_hwdep_t * __devinit 370 325 snd_wavefront_new_fx (snd_card_t *card, 371 326 int hw_dev, … … 394 349 static snd_wavefront_mpu_id external_id = external_mpu; 395 350 396 snd_rawmidi_t * __ init351 snd_rawmidi_t * __devinit 397 352 snd_wavefront_new_midi (snd_card_t *card, 398 353 int midi_dev, … … 441 396 442 397 if (acard) { 443 #ifdef __ISAPNP__444 snd_wavefront_deactivate(acard);445 #endif446 398 if (acard->wavefront.res_base != NULL) { 447 399 release_resource(acard->wavefront.res_base); … … 453 405 } 454 406 455 static int __init 456 snd_wavefront_probe (int dev) 407 static int __devinit 408 snd_wavefront_probe (int dev, struct pnp_card_link *pcard, 409 const struct pnp_card_device_id *pid) 457 410 { 458 411 snd_card_t *card; … … 472 425 ics2115_port[dev] = SNDRV_AUTO_PORT; 473 426 474 #ifdef __ISAPNP__427 #ifdef CONFIG_PNP 475 428 if (!isapnp[dev]) { 476 429 #endif … … 483 436 return -ENODEV; 484 437 } 485 #ifdef __ISAPNP__438 #ifdef CONFIG_PNP 486 439 } 487 440 #endif … … 502 455 card->private_free = snd_wavefront_free; 503 456 504 #ifdef __ISAPNP__505 if (isapnp[dev] && snd_wavefront_ isapnp (dev, acard) < 0) {457 #ifdef CONFIG_PNP 458 if (isapnp[dev] && snd_wavefront_pnp (dev, acard, pcard, pid) < 0) { 506 459 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { 507 460 snd_printk ("isapnp detection failed\n"); … … 510 463 } 511 464 } 512 #endif /* __ISAPNP__*/465 #endif /* CONFIG_PNP */ 513 466 514 467 /* --------- PCM --------------- */ … … 694 647 return err; 695 648 } 696 snd_wavefront_cards[dev] = card; 649 if (pcard) 650 pnp_set_card_drvdata(pcard, card); 651 else 652 snd_wavefront_legacy[dev] = card; 697 653 return 0; 698 654 } 699 655 700 #ifdef __ISAPNP__701 702 static int __ init snd_wavefront_isapnp_detect(struct isapnp_card*card,703 const struct isapnp_card_id *id)656 #ifdef CONFIG_PNP 657 658 static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *card, 659 const struct pnp_card_device_id *id) 704 660 { 705 661 static int dev; … … 709 665 if (!enable[dev] || !isapnp[dev]) 710 666 continue; 711 snd_wavefront_isapnp_cards[dev] = card; 712 snd_wavefront_isapnp_id[dev] = id; 713 res = snd_wavefront_probe(dev); 667 res = snd_wavefront_probe(dev, card, id); 714 668 if (res < 0) 715 669 return res; … … 721 675 } 722 676 723 #endif /* __ISAPNP__ */ 677 static void __devexit snd_wavefront_pnp_remove(struct pnp_card_link * pcard) 678 { 679 snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); 680 681 snd_card_disconnect(card); 682 snd_card_free_in_thread(card); 683 } 684 685 static struct pnp_card_driver wavefront_pnpc_driver = { 686 .flags = PNP_DRIVER_RES_DISABLE, 687 .name = "wavefront", 688 .id_table = snd_wavefront_pnpids, 689 .probe = snd_wavefront_pnp_detect, 690 .remove = __devexit_p(snd_wavefront_pnp_remove), 691 }; 692 693 #endif /* CONFIG_PNP */ 724 694 725 695 static int __init alsa_card_wavefront_init(void) … … 730 700 if (!enable[dev]) 731 701 continue; 732 #ifdef __ISAPNP__702 #ifdef CONFIG_PNP 733 703 if (isapnp[dev]) 734 704 continue; 735 705 #endif 736 if (snd_wavefront_probe(dev ) >= 0)706 if (snd_wavefront_probe(dev, NULL, NULL) >= 0) 737 707 cards++; 738 708 } 739 #ifdef __ISAPNP__740 cards += isapnp_probe_cards(snd_wavefront_pnpids, snd_wavefront_isapnp_detect);709 #ifdef CONFIG_PNP 710 cards += pnp_register_card_driver(&wavefront_pnpc_driver); 741 711 #endif 742 712 if (!cards) { 713 #ifdef CONFIG_PNP 714 pnp_unregister_card_driver(&wavefront_pnpc_driver); 715 #endif 743 716 #ifdef MODULE 744 717 printk (KERN_ERR "No WaveFront cards found or devices busy\n"); … … 753 726 int idx; 754 727 728 #ifdef CONFIG_PNP 729 pnp_unregister_card_driver(&wavefront_pnpc_driver); 730 #endif 755 731 for (idx = 0; idx < SNDRV_CARDS; idx++) 756 snd_card_free(snd_wavefront_ cards[idx]);732 snd_card_free(snd_wavefront_legacy[idx]); 757 733 } 758 734 -
GPL/branches/alsa-resync1/alsa-kernel/isa/wavefront/wavefront_fx.c
r224 r246 228 228 utility was run with I/O tracing in DOSEMU enabled, and a reconstruction 229 229 of the port I/O done, using the Yamaha faxback document as a guide 230 to add more logic to the code. Its really pretty w ierd.230 to add more logic to the code. Its really pretty weird. 231 231 232 232 There was an alternative approach of just dumping the whole I/O … … 693 693 } 694 694 695 /* w ierd stuff, derived from port I/O tracing with dosemu */695 /* weird stuff, derived from port I/O tracing with dosemu */ 696 696 697 697 static unsigned char page_zero[] __initdata = { -
GPL/branches/alsa-resync1/alsa-kernel/isa/wavefront/wavefront_synth.c
r224 r246 520 520 WaveFront data munging 521 521 522 Things here are w ierd. All data written to the board cannot522 Things here are weird. All data written to the board cannot 523 523 have its most significant bit set. Any data item with values 524 524 potentially > 0x7F (127) must be split across multiple bytes. … … 529 529 efficient approach to handling both cases seems to be to use 2 530 530 different functions for munging and 2 for de-munging. This avoids 531 w ierd casting and worrying about bit-level offsets.531 weird casting and worrying about bit-level offsets. 532 532 533 533 **********************************************************************/ … … 909 909 if (header->size) { 910 910 911 /* XXX it s a debatable point whether or not RDONLY semantics911 /* XXX it's a debatable point whether or not RDONLY semantics 912 912 on the ROM samples should cover just the sample data or 913 913 the sample header. For now, it only covers the sample data, … … 1037 1037 shptr, 4); 1038 1038 1039 /* This one is truly w ierd. What kind of wierdo decided that in1039 /* This one is truly weird. What kind of weirdo decided that in 1040 1040 a system dominated by 16 and 32 bit integers, they would use 1041 1041 a just 12 bits ? -
GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/ak4xxx.c
r244 r246 30 30 #include "ice1712.h" 31 31 32 static void snd_ice1712_akm4xxx_lock(akm4xxx_t *ak, int chip) 33 { 34 ice1712_t *ice = ak->private_data[0]; 35 36 snd_ice1712_save_gpio_status(ice); 37 } 38 39 static void snd_ice1712_akm4xxx_unlock(akm4xxx_t *ak, int chip) 40 { 41 ice1712_t *ice = ak->private_data[0]; 42 43 snd_ice1712_restore_gpio_status(ice); 44 } 32 45 33 46 /* 34 47 * write AK4xxx register 35 48 */ 36 void snd_ice1712_akm4xxx_write(akm4xxx_t *ak, int chip,37 unsigned char addr, unsigned char data)49 static void snd_ice1712_akm4xxx_write(akm4xxx_t *ak, int chip, 50 unsigned char addr, unsigned char data) 38 51 { 39 52 unsigned int tmp; 40 53 int idx; 41 54 unsigned int addrdata; 42 ice1712_t *ice = ak->chip; 55 struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; 56 ice1712_t *ice = ak->private_data[0]; 43 57 44 58 snd_assert(chip >= 0 && chip < 4, return); 45 59 46 if (ak->ops.start) {47 if (ak->ops.start(ak, chip) < 0)48 return;49 } else50 snd_ice1712_save_gpio_status(ice);51 52 60 tmp = snd_ice1712_gpio_read(ice); 53 tmp |= ak->add_flags;54 tmp &= ~ ak->mask_flags;55 if ( ak->cs_mask == ak->cs_addr) {56 if ( ak->cif) {57 tmp |= ak->cs_mask; /* start without chip select */61 tmp |= priv->add_flags; 62 tmp &= ~priv->mask_flags; 63 if (priv->cs_mask == priv->cs_addr) { 64 if (priv->cif) { 65 tmp |= priv->cs_mask; /* start without chip select */ 58 66 } else { 59 tmp &= ~ ak->cs_mask; /* chip select low */67 tmp &= ~priv->cs_mask; /* chip select low */ 60 68 snd_ice1712_gpio_write(ice, tmp); 61 69 udelay(1); … … 63 71 } else { 64 72 /* doesn't handle cf=1 yet */ 65 tmp &= ~ ak->cs_mask;66 tmp |= ak->cs_addr;73 tmp &= ~priv->cs_mask; 74 tmp |= priv->cs_addr; 67 75 snd_ice1712_gpio_write(ice, tmp); 68 76 udelay(1); … … 70 78 71 79 /* build I2C address + data byte */ 72 addrdata = ( ak->caddr << 6) | 0x20 | (addr & 0x1f);80 addrdata = (priv->caddr << 6) | 0x20 | (addr & 0x1f); 73 81 addrdata = (addrdata << 8) | data; 74 82 for (idx = 15; idx >= 0; idx--) { 75 83 /* drop clock */ 76 tmp &= ~ ak->clk_mask;84 tmp &= ~priv->clk_mask; 77 85 snd_ice1712_gpio_write(ice, tmp); 78 86 udelay(1); 79 87 /* set data */ 80 88 if (addrdata & (1 << idx)) 81 tmp |= ak->data_mask;89 tmp |= priv->data_mask; 82 90 else 83 tmp &= ~ ak->data_mask;91 tmp &= ~priv->data_mask; 84 92 snd_ice1712_gpio_write(ice, tmp); 85 93 udelay(1); 86 94 /* raise clock */ 87 tmp |= ak->clk_mask;95 tmp |= priv->clk_mask; 88 96 snd_ice1712_gpio_write(ice, tmp); 89 97 udelay(1); … … 101 109 } 102 110 103 if ( ak->cs_mask == ak->cs_addr) {104 if ( ak->cif) {111 if (priv->cs_mask == priv->cs_addr) { 112 if (priv->cif) { 105 113 /* assert a cs pulse to trigger */ 106 tmp &= ~ ak->cs_mask;114 tmp &= ~priv->cs_mask; 107 115 snd_ice1712_gpio_write(ice, tmp); 108 116 udelay(1); 109 117 } 110 tmp |= ak->cs_mask; /* chip select high to trigger */118 tmp |= priv->cs_mask; /* chip select high to trigger */ 111 119 } else { 112 tmp &= ~ ak->cs_mask;113 tmp |= ak->cs_none; /* deselect address */120 tmp &= ~priv->cs_mask; 121 tmp |= priv->cs_none; /* deselect address */ 114 122 } 115 123 snd_ice1712_gpio_write(ice, tmp); 116 124 udelay(1); 117 118 if (ak->ops.stop)119 ak->ops.stop(ak);120 else121 snd_ice1712_restore_gpio_status(ice);122 125 } 123 124 /*125 * reset the AKM codecs126 * @state: 1 = reset codec, 0 = restore the registers127 *128 * assert the reset operation and restores the register values to the chips.129 */130 void snd_ice1712_akm4xxx_reset(akm4xxx_t *ak, int state)131 {132 unsigned int chip;133 unsigned char reg;134 135 switch (ak->type) {136 case SND_AK4524:137 case SND_AK4528:138 for (chip = 0; chip < ak->num_dacs/2; chip++) {139 snd_ice1712_akm4xxx_write(ak, chip, 0x01, state ? 0x00 : 0x03);140 if (state)141 continue;142 /* DAC volumes */143 for (reg = 0x04; reg < (ak->type == SND_AK4528 ? 0x06 : 0x08); reg++)144 snd_ice1712_akm4xxx_write(ak, chip, reg, ak->images[chip][reg]);145 if (ak->type == SND_AK4528)146 continue;147 /* IPGA */148 for (reg = 0x04; reg < 0x06; reg++)149 snd_ice1712_akm4xxx_write(ak, chip, reg, ak->ipga_gain[chip][reg-4]);150 }151 break;152 case SND_AK4529:153 /* FIXME: needed for ak4529? */154 break;155 case SND_AK4355:156 snd_ice1712_akm4xxx_write(ak, 0, 0x01, state ? 0x02 : 0x01);157 if (state)158 return;159 for (reg = 0x00; reg < 0x0a; reg++)160 if (reg != 0x01)161 snd_ice1712_akm4xxx_write(ak, 0, reg, ak->images[0][reg]);162 break;163 case SND_AK4381:164 for (chip = 0; chip < ak->num_dacs/2; chip++) {165 snd_ice1712_akm4xxx_write(ak, chip, 0x00, state ? 0x0c : 0x0f);166 if (state)167 continue;168 for (reg = 0x01; reg < 0x05; reg++)169 snd_ice1712_akm4xxx_write(ak, chip, reg, ak->images[chip][reg]);170 }171 break;172 }173 }174 175 /*176 * initialize all the ak4xxx chips177 */178 static void __devinit snd_ice1712_akm4xxx_init_chip(akm4xxx_t *ak)179 {180 static unsigned char inits_ak4524[] = {181 0x00, 0x07, /* 0: all power up */182 0x01, 0x00, /* 1: ADC/DAC reset */183 0x02, 0x60, /* 2: 24bit I2S */184 0x03, 0x19, /* 3: deemphasis off */185 0x01, 0x03, /* 1: ADC/DAC enable */186 0x04, 0x00, /* 4: ADC left muted */187 0x05, 0x00, /* 5: ADC right muted */188 0x04, 0x80, /* 4: ADC IPGA gain 0dB */189 0x05, 0x80, /* 5: ADC IPGA gain 0dB */190 0x06, 0x00, /* 6: DAC left muted */191 0x07, 0x00, /* 7: DAC right muted */192 0xff, 0xff193 };194 static unsigned char inits_ak4528[] = {195 0x00, 0x07, /* 0: all power up */196 0x01, 0x00, /* 1: ADC/DAC reset */197 0x02, 0x60, /* 2: 24bit I2S */198 0x03, 0x0d, /* 3: deemphasis off, turn LR highpass filters on */199 0x01, 0x03, /* 1: ADC/DAC enable */200 0x04, 0x00, /* 4: ADC left muted */201 0x05, 0x00, /* 5: ADC right muted */202 0xff, 0xff203 };204 static unsigned char inits_ak4529[] = {205 0x09, 0x01, /* 9: ATS=0, RSTN=1 */206 0x0a, 0x3f, /* A: all power up, no zero/overflow detection */207 0x00, 0x0c, /* 0: TDM=0, 24bit I2S, SMUTE=0 */208 0x01, 0x00, /* 1: ACKS=0, ADC, loop off */209 0x02, 0xff, /* 2: LOUT1 muted */210 0x03, 0xff, /* 3: ROUT1 muted */211 0x04, 0xff, /* 4: LOUT2 muted */212 0x05, 0xff, /* 5: ROUT2 muted */213 0x06, 0xff, /* 6: LOUT3 muted */214 0x07, 0xff, /* 7: ROUT3 muted */215 0x0b, 0xff, /* B: LOUT4 muted */216 0x0c, 0xff, /* C: ROUT4 muted */217 0x08, 0x55, /* 8: deemphasis all off */218 0xff, 0xff219 };220 static unsigned char inits_ak4355[] = {221 0x01, 0x02, /* 1: reset and soft-mute */222 0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect, disable DZF, sharp roll-off, RSTN#=0 */223 // 0x02, 0x0e, /* 2: DA's power up, normal speed, RSTN#=0 */224 0x02, 0x2e,225 0x03, 0x01, /* 3: de-emphasis off */226 0x04, 0x00, /* 4: LOUT1 volume muted */227 0x05, 0x00, /* 5: ROUT1 volume muted */228 0x06, 0x00, /* 6: LOUT2 volume muted */229 0x07, 0x00, /* 7: ROUT2 volume muted */230 0x08, 0x00, /* 8: LOUT3 volume muted */231 0x09, 0x00, /* 9: ROUT3 volume muted */232 0x0a, 0x00, /* a: DATT speed=0, ignore DZF */233 0x01, 0x01, /* 1: un-reset, unmute */234 0xff, 0xff235 };236 static unsigned char inits_ak4381[] = {237 0x00, 0x0c, /* 0: mode3(i2s), disable auto-clock detect */238 // 0x01, 0x02, /* 1: de-emphasis off, normal speed, sharp roll-off, DZF off */239 0x01, 0x12,240 0x02, 0x00, /* 2: DZF disabled */241 0x03, 0x00, /* 3: LATT 0 */242 0x04, 0x00, /* 4: RATT 0 */243 0x00, 0x0f, /* 0: power-up, un-reset */244 0xff, 0xff245 };246 247 int chip, num_chips;248 unsigned char *ptr, reg, data, *inits;249 250 switch (ak->type) {251 case SND_AK4524:252 inits = inits_ak4524;253 num_chips = ak->num_dacs / 2;254 break;255 case SND_AK4528:256 inits = inits_ak4528;257 num_chips = ak->num_dacs / 2;258 break;259 case SND_AK4529:260 inits = inits_ak4529;261 num_chips = 1;262 break;263 case SND_AK4355:264 inits = inits_ak4355;265 num_chips = 1;266 break;267 case SND_AK4381:268 inits = inits_ak4381;269 num_chips = ak->num_dacs / 2;270 break;271 default:272 snd_BUG();273 return;274 }275 276 for (chip = 0; chip < num_chips; chip++) {277 ptr = inits;278 while (*ptr != 0xff) {279 reg = *ptr++;280 data = *ptr++;281 snd_ice1712_akm4xxx_write(ak, chip, reg, data);282 }283 }284 }285 286 126 287 127 /* 288 128 * initialize the akm4xxx_t record with the template 289 129 */ 290 void snd_ice1712_akm4xxx_init(akm4xxx_t *ak, const akm4xxx_t *temp, ice1712_t *ice) 130 int __devinit snd_ice1712_akm4xxx_init(akm4xxx_t *ak, const akm4xxx_t *temp, 131 const struct snd_ak4xxx_private *_priv, ice1712_t *ice) 291 132 { 133 struct snd_ak4xxx_private *priv; 134 135 priv = kmalloc(sizeof(*priv), GFP_KERNEL); 136 if (priv == NULL) 137 return -ENOMEM; 292 138 *ak = *temp; 293 ak->chip = ice; 294 snd_ice1712_akm4xxx_init_chip(ak); 295 } 296 297 298 #define AK_GET_CHIP(val) (((val) >> 8) & 0xff) 299 #define AK_GET_ADDR(val) ((val) & 0xff) 300 #define AK_GET_SHIFT(val) (((val) >> 16) & 0x7f) 301 #define AK_GET_INVERT(val) (((val) >> 23) & 1) 302 #define AK_GET_MASK(val) (((val) >> 24) & 0xff) 303 #define AK_COMPOSE(chip,addr,shift,mask) (((chip) << 8) | (addr) | ((shift) << 16) | ((mask) << 24)) 304 #define AK_INVERT (1<<23) 305 306 static int snd_ice1712_akm4xxx_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 307 { 308 unsigned int mask = AK_GET_MASK(kcontrol->private_value); 309 310 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 311 uinfo->count = 1; 312 uinfo->value.integer.min = 0; 313 uinfo->value.integer.max = mask; 139 ak->card = ice->card; 140 *priv = *_priv; 141 ak->private_value[0] = (unsigned long)priv; 142 ak->private_data[0] = ice; 143 if (ak->ops.lock == NULL) 144 ak->ops.lock = snd_ice1712_akm4xxx_lock; 145 if (ak->ops.unlock == NULL) 146 ak->ops.unlock = snd_ice1712_akm4xxx_unlock; 147 if (ak->ops.write == NULL) 148 ak->ops.write = snd_ice1712_akm4xxx_write; 149 snd_akm4xxx_init(ak); 314 150 return 0; 315 151 } 316 152 317 static int snd_ice1712_akm4xxx_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)153 void __devexit snd_ice1712_akm4xxx_free(ice1712_t *ice) 318 154 { 319 akm4xxx_t *ak = _snd_kcontrol_chip(kcontrol); 320 int chip = AK_GET_CHIP(kcontrol->private_value); 321 int addr = AK_GET_ADDR(kcontrol->private_value); 322 int invert = AK_GET_INVERT(kcontrol->private_value); 323 unsigned int mask = AK_GET_MASK(kcontrol->private_value); 324 unsigned char val = ak->images[chip][addr]; 325 326 ucontrol->value.integer.value[0] = invert ? mask - val : val; 327 return 0; 328 } 329 330 static int snd_ice1712_akm4xxx_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 331 { 332 akm4xxx_t *ak = _snd_kcontrol_chip(kcontrol); 333 int chip = AK_GET_CHIP(kcontrol->private_value); 334 int addr = AK_GET_ADDR(kcontrol->private_value); 335 int invert = AK_GET_INVERT(kcontrol->private_value); 336 unsigned int mask = AK_GET_MASK(kcontrol->private_value); 337 unsigned char nval = ucontrol->value.integer.value[0] % (mask+1); 338 int change; 339 340 if (invert) 341 nval = mask - nval; 342 change = ak->images[chip][addr] != nval; 343 if (change) 344 snd_ice1712_akm4xxx_write(ak, chip, addr, nval); 345 return change; 346 } 347 348 static int snd_ice1712_akm4xxx_ipga_gain_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 349 { 350 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 351 uinfo->count = 1; 352 uinfo->value.integer.min = 0; 353 uinfo->value.integer.max = 36; 354 return 0; 355 } 356 357 static int snd_ice1712_akm4xxx_ipga_gain_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 358 { 359 akm4xxx_t *ak = _snd_kcontrol_chip(kcontrol); 360 int chip = AK_GET_CHIP(kcontrol->private_value); 361 int addr = AK_GET_ADDR(kcontrol->private_value); 362 ucontrol->value.integer.value[0] = ak->ipga_gain[chip][addr-4] & 0x7f; 363 return 0; 364 } 365 366 static int snd_ice1712_akm4xxx_ipga_gain_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 367 { 368 akm4xxx_t *ak = _snd_kcontrol_chip(kcontrol); 369 int chip = AK_GET_CHIP(kcontrol->private_value); 370 int addr = AK_GET_ADDR(kcontrol->private_value); 371 unsigned char nval = (ucontrol->value.integer.value[0] % 37) | 0x80; 372 int change = ak->ipga_gain[chip][addr] != nval; 373 if (change) 374 snd_ice1712_akm4xxx_write(ak, chip, addr, nval); 375 return change; 376 } 377 378 static int snd_ice1712_akm4xxx_deemphasis_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 379 { 380 static char *texts[4] = { 381 "44.1kHz", "Off", "48kHz", "32kHz", 382 }; 383 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 384 uinfo->count = 1; 385 uinfo->value.enumerated.items = 4; 386 if (uinfo->value.enumerated.item >= 4) 387 uinfo->value.enumerated.item = 3; 388 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 389 return 0; 390 } 391 392 static int snd_ice1712_akm4xxx_deemphasis_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) 393 { 394 akm4xxx_t *ak = _snd_kcontrol_chip(kcontrol); 395 int chip = AK_GET_CHIP(kcontrol->private_value); 396 int addr = AK_GET_ADDR(kcontrol->private_value); 397 int shift = AK_GET_SHIFT(kcontrol->private_value); 398 ucontrol->value.enumerated.item[0] = (ak->images[chip][addr] >> shift) & 3; 399 return 0; 400 } 401 402 static int snd_ice1712_akm4xxx_deemphasis_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 403 { 404 akm4xxx_t *ak = _snd_kcontrol_chip(kcontrol); 405 int chip = AK_GET_CHIP(kcontrol->private_value); 406 int addr = AK_GET_ADDR(kcontrol->private_value); 407 int shift = AK_GET_SHIFT(kcontrol->private_value); 408 unsigned char nval = ucontrol->value.enumerated.item[0] & 3; 409 int change; 410 411 nval = (nval << shift) | (ak->images[chip][addr] & ~(3 << shift)); 412 change = ak->images[chip][addr] != nval; 413 if (change) 414 snd_ice1712_akm4xxx_write(ak, chip, addr, nval); 415 return change; 155 unsigned int akidx; 156 if (ice->akm == NULL) 157 return; 158 for (akidx = 0; akidx < ice->akm_codecs; akidx++) { 159 akm4xxx_t *ak = &ice->akm[akidx]; 160 if (ak->private_value[0]) 161 kfree((void *)ak->private_value[0]); 162 } 163 kfree(ice->akm); 416 164 } 417 165 418 166 /* 419 * build AK4 524controls167 * build AK4xxx controls 420 168 */ 421 422 169 int __devinit snd_ice1712_akm4xxx_build_controls(ice1712_t *ice) 423 170 { 424 unsigned int idx;171 unsigned int akidx; 425 172 int err; 426 unsigned int akidx;427 173 428 174 for (akidx = 0; akidx < ice->akm_codecs; akidx++) { 429 175 akm4xxx_t *ak = &ice->akm[akidx]; 430 for (idx = 0; idx < ak->num_dacs; ++idx) { 431 snd_kcontrol_t ctl; 432 memset(&ctl, 0, sizeof(ctl)); 433 strcpy(ctl.id.name, "DAC Volume"); 434 ctl.id.index = idx + ak->idx_offset * 2; 435 ctl.id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 436 ctl.info = snd_ice1712_akm4xxx_volume_info; 437 ctl.access = SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE; 438 ctl.get = snd_ice1712_akm4xxx_volume_get; 439 ctl.put = snd_ice1712_akm4xxx_volume_put; 440 switch (ak->type) { 441 case SND_AK4524: 442 ctl.private_value = AK_COMPOSE(idx/2, (idx%2) + 6, 0, 127); /* register 6 & 7 */ 443 break; 444 case SND_AK4528: 445 ctl.private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127); /* register 4 & 5 */ 446 break; 447 case SND_AK4529: { 448 int val = idx < 6 ? idx + 2 : (idx - 6) + 0xb; /* registers 2-7 and b,c */ 449 ctl.private_value = AK_COMPOSE(0, val, 0, 255) | AK_INVERT; 450 break; 451 } 452 case SND_AK4355: 453 ctl.private_value = AK_COMPOSE(0, idx + 4, 0, 255); /* register 4-9, chip #0 only */ 454 break; 455 case SND_AK4381: 456 ctl.private_value = AK_COMPOSE(idx/2, (idx%2) + 3, 0, 255); /* register 3 & 4 */ 457 break; 458 default: 459 return -EINVAL; 460 } 461 ctl.private_data = ak; 462 if ((err = snd_ctl_add(ice->card, snd_ctl_new(&ctl))) < 0) 463 return err; 464 } 465 for (idx = 0; idx < ak->num_adcs && ak->type == SND_AK4524; ++idx) { 466 snd_kcontrol_t ctl; 467 memset(&ctl, 0, sizeof(ctl)); 468 strcpy(ctl.id.name, "ADC Volume"); 469 ctl.id.index = idx; 470 ctl.id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 471 ctl.info = snd_ice1712_akm4xxx_volume_info; 472 ctl.access = SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE; 473 ctl.get = snd_ice1712_akm4xxx_volume_get; 474 ctl.put = snd_ice1712_akm4xxx_volume_put; 475 ctl.private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127); /* register 4 & 5 */ 476 ctl.private_data = ak; 477 if ((err = snd_ctl_add(ice->card, snd_ctl_new(&ctl))) < 0) 478 return err; 479 memset(&ctl, 0, sizeof(ctl)); 480 strcpy(ctl.id.name, "IPGA Analog Capture Volume"); 481 ctl.id.index = idx; 482 ctl.id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 483 ctl.info = snd_ice1712_akm4xxx_ipga_gain_info; 484 ctl.access = SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE; 485 ctl.get = snd_ice1712_akm4xxx_ipga_gain_get; 486 ctl.put = snd_ice1712_akm4xxx_ipga_gain_put; 487 ctl.private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 0); /* register 4 & 5 */ 488 ctl.private_data = ak; 489 if ((err = snd_ctl_add(ice->card, snd_ctl_new(&ctl))) < 0) 490 return err; 491 } 492 for (idx = 0; idx < ak->num_dacs/2; idx++) { 493 snd_kcontrol_t ctl; 494 memset(&ctl, 0, sizeof(ctl)); 495 strcpy(ctl.id.name, "Deemphasis"); 496 ctl.id.index = idx + ak->idx_offset; 497 ctl.id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 498 ctl.info = snd_ice1712_akm4xxx_deemphasis_info; 499 ctl.access = SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE; 500 ctl.get = snd_ice1712_akm4xxx_deemphasis_get; 501 ctl.put = snd_ice1712_akm4xxx_deemphasis_put; 502 switch (ak->type) { 503 case SND_AK4524: 504 case SND_AK4528: 505 ctl.private_value = AK_COMPOSE(idx, 3, 0, 0); /* register 3 */ 506 break; 507 case SND_AK4529: { 508 int shift = idx == 3 ? 6 : (2 - idx) * 2; 509 ctl.private_value = AK_COMPOSE(0, 8, shift, 0); /* register 8 with shift */ 510 break; 511 } 512 case SND_AK4355: 513 ctl.private_value = AK_COMPOSE(idx, 3, 0, 0); 514 break; 515 case SND_AK4381: 516 ctl.private_value = AK_COMPOSE(idx, 1, 1, 0); 517 break; 518 } 519 ctl.private_data = ak; 520 if ((err = snd_ctl_add(ice->card, snd_ctl_new(&ctl))) < 0) 521 return err; 522 } 176 err = snd_akm4xxx_build_controls(ak); 177 if (err < 0) 178 return err; 523 179 } 524 180 return 0; 525 181 } 526 527 -
GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/delta.c
r224 r246 233 233 * AK4524 on Delta 44 and 66 to choose the chip mask 234 234 */ 235 static int delta_ak4524_start(akm4xxx_t *ak, int chip) 236 { 237 snd_ice1712_save_gpio_status(ak->chip); 238 ak->cs_mask = 239 ak->cs_addr = chip == 0 ? ICE1712_DELTA_CODEC_CHIP_A : 240 ICE1712_DELTA_CODEC_CHIP_B; 241 return 0; 235 static void delta_ak4524_lock(akm4xxx_t *ak, int chip) 236 { 237 struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; 238 ice1712_t *ice = ak->private_data[0]; 239 240 snd_ice1712_save_gpio_status(ice); 241 priv->cs_mask = 242 priv->cs_addr = chip == 0 ? ICE1712_DELTA_CODEC_CHIP_A : 243 ICE1712_DELTA_CODEC_CHIP_B; 242 244 } 243 245 … … 245 247 * AK4524 on Delta1010LT to choose the chip address 246 248 */ 247 static int delta1010lt_ak4524_start(akm4xxx_t *ak, int chip) 248 { 249 snd_ice1712_save_gpio_status(ak->chip); 250 ak->cs_mask = ICE1712_DELTA_1010LT_CS; 251 ak->cs_addr = chip << 4; 252 return 0; 249 static void delta1010lt_ak4524_lock(akm4xxx_t *ak, int chip) 250 { 251 struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; 252 ice1712_t *ice = ak->private_data[0]; 253 254 snd_ice1712_save_gpio_status(ice); 255 priv->cs_mask = ICE1712_DELTA_1010LT_CS; 256 priv->cs_addr = chip << 4; 253 257 } 254 258 … … 259 263 { 260 264 unsigned char tmp, tmp2; 261 ice1712_t *ice = ak-> chip;265 ice1712_t *ice = ak->private_data[0]; 262 266 263 267 if (rate == 0) /* no hint - S/PDIF input is master, simply return */ … … 276 280 277 281 /* do it again */ 278 snd_ ice1712_akm4xxx_reset(ak, 1);282 snd_akm4xxx_reset(ak, 1); 279 283 down(&ice->gpio_mutex); 280 284 tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ~ICE1712_DELTA_DFS; … … 283 287 snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp); 284 288 up(&ice->gpio_mutex); 285 snd_ ice1712_akm4xxx_reset(ak, 0);289 snd_akm4xxx_reset(ak, 0); 286 290 } 287 291 … … 331 335 .num_adcs = 2, 332 336 .num_dacs = 2, 337 .ops = { 338 .set_rate_val = delta_ak4524_set_rate_val 339 } 340 }; 341 342 static struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = { 333 343 .caddr = 2, 334 344 .cif = 0, … … 340 350 .add_flags = ICE1712_DELTA_AP_CS_DIGITAL, 341 351 .mask_flags = 0, 342 .ops = {343 .set_rate_val = delta_ak4524_set_rate_val344 }345 352 }; 346 353 … … 349 356 .num_adcs = 2, 350 357 .num_dacs = 8, 358 .ops = { 359 .set_rate_val = delta_ak4524_set_rate_val 360 } 361 }; 362 363 static struct snd_ak4xxx_private akm_delta410_priv __devinitdata = { 351 364 .caddr = 0, 352 365 .cif = 0, … … 358 371 .add_flags = ICE1712_DELTA_AP_CS_DIGITAL, 359 372 .mask_flags = 0, 360 .ops = {361 .set_rate_val = delta_ak4524_set_rate_val362 }363 373 }; 364 374 … … 367 377 .num_adcs = 8, 368 378 .num_dacs = 8, 379 .ops = { 380 .lock = delta1010lt_ak4524_lock, 381 .set_rate_val = delta_ak4524_set_rate_val 382 } 383 }; 384 385 static struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = { 369 386 .caddr = 2, 370 387 .cif = 0, /* the default level of the CIF pin from AK4524 */ … … 376 393 .add_flags = 0, 377 394 .mask_flags = 0, 378 .ops = {379 .start = delta1010lt_ak4524_start,380 .set_rate_val = delta_ak4524_set_rate_val381 }382 395 }; 383 396 … … 386 399 .num_adcs = 4, 387 400 .num_dacs = 4, 401 .ops = { 402 .lock = delta_ak4524_lock, 403 .set_rate_val = delta_ak4524_set_rate_val 404 } 405 }; 406 407 static struct snd_ak4xxx_private akm_delta44_priv __devinitdata = { 388 408 .caddr = 2, 389 409 .cif = 0, /* the default level of the CIF pin from AK4524 */ … … 395 415 .add_flags = 0, 396 416 .mask_flags = 0, 397 .ops = {398 .start = delta_ak4524_start,399 .set_rate_val = delta_ak4524_set_rate_val400 }401 417 }; 402 418 … … 467 483 switch (ice->eeprom.subvendor) { 468 484 case ICE1712_SUBDEVICE_AUDIOPHILE: 469 snd_ice1712_akm4xxx_init(ak, &akm_audiophile, ice);485 err = snd_ice1712_akm4xxx_init(ak, &akm_audiophile, &akm_audiophile_priv, ice); 470 486 break; 471 487 case ICE1712_SUBDEVICE_DELTA410: 472 snd_ice1712_akm4xxx_init(ak, &akm_delta410, ice);488 err = snd_ice1712_akm4xxx_init(ak, &akm_delta410, &akm_delta410_priv, ice); 473 489 break; 474 490 case ICE1712_SUBDEVICE_DELTA1010LT: 475 snd_ice1712_akm4xxx_init(ak, &akm_delta1010lt, ice);491 err = snd_ice1712_akm4xxx_init(ak, &akm_delta1010lt, &akm_delta1010lt_priv, ice); 476 492 break; 477 493 case ICE1712_SUBDEVICE_DELTA66: 478 494 case ICE1712_SUBDEVICE_DELTA44: 479 snd_ice1712_akm4xxx_init(ak, &akm_delta44, ice);495 err = snd_ice1712_akm4xxx_init(ak, &akm_delta44, &akm_delta44_priv, ice); 480 496 break; 481 497 default: … … 484 500 } 485 501 486 return 0;502 return err; 487 503 } 488 504 … … 535 551 case ICE1712_SUBDEVICE_DELTADIO2496: 536 552 case ICE1712_SUBDEVICE_DELTA66: 537 case ICE1712_SUBDEVICE_AUDIOPHILE:538 case ICE1712_SUBDEVICE_DELTA410:539 case ICE1712_SUBDEVICE_DELTA1010LT:540 553 err = snd_ice1712_spdif_build_controls(ice); 541 554 if (err < 0) -
GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/ews.c
r224 r246 156 156 157 157 /* start callback for EWS88MT, needs to select a certain chip mask */ 158 static int ews88mt_ak4524_start(akm4xxx_t *ak, int chip)159 { 160 ice1712_t *ice = ak-> chip;158 static void ews88mt_ak4524_lock(akm4xxx_t *ak, int chip) 159 { 160 ice1712_t *ice = ak->private_data[0]; 161 161 unsigned char tmp; 162 162 /* assert AK4524 CS */ 163 163 if (snd_ice1712_ews88mt_chip_select(ice, ~(1 << chip) & 0x0f) < 0) 164 return -EINVAL;164 snd_printk(KERN_ERR "fatal error (ews88mt chip select)\n"); 165 165 snd_ice1712_save_gpio_status(ice); 166 166 tmp = ICE1712_EWS88_SERIAL_DATA | … … 170 170 ice->gpio.direction | tmp); 171 171 snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~tmp); 172 return 0;173 172 } 174 173 175 174 /* stop callback for EWS88MT, needs to deselect chip mask */ 176 static void ews88mt_ak4524_ stop(akm4xxx_t *ak)177 { 178 ice1712_t *ice = ak-> chip;175 static void ews88mt_ak4524_unlock(akm4xxx_t *ak, int chip) 176 { 177 ice1712_t *ice = ak->private_data[0]; 179 178 snd_ice1712_restore_gpio_status(ice); 180 179 udelay(1); … … 183 182 184 183 /* start callback for EWX24/96 */ 185 static int ewx2496_ak4524_start(akm4xxx_t *ak, int chip)186 { 187 ice1712_t *ice = ak-> chip;184 static void ewx2496_ak4524_lock(akm4xxx_t *ak, int chip) 185 { 186 ice1712_t *ice = ak->private_data[0]; 188 187 unsigned char tmp; 189 188 snd_ice1712_save_gpio_status(ice); … … 195 194 ice->gpio.direction | tmp); 196 195 snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~tmp); 197 return 0;198 196 } 199 197 200 198 /* start callback for DMX 6fire */ 201 static int dmx6fire_ak4524_start(akm4xxx_t *ak, int chip) 202 { 203 ice1712_t *ice = ak->chip; 199 static void dmx6fire_ak4524_lock(akm4xxx_t *ak, int chip) 200 { 201 struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; 202 ice1712_t *ice = ak->private_data[0]; 204 203 unsigned char tmp; 205 204 snd_ice1712_save_gpio_status(ice); 206 tmp = ak->cs_mask = ak->cs_addr = (1 << chip) & ICE1712_6FIRE_AK4524_CS_MASK;205 tmp = priv->cs_mask = priv->cs_addr = (1 << chip) & ICE1712_6FIRE_AK4524_CS_MASK; 207 206 tmp |= ICE1712_6FIRE_SERIAL_DATA | 208 207 ICE1712_6FIRE_SERIAL_CLOCK | … … 211 210 ice->gpio.direction | tmp); 212 211 snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~tmp); 213 return 0; 214 } 215 212 } 216 213 217 214 /* … … 329 326 .num_dacs = 8, 330 327 .type = SND_AK4524, 328 .ops = { 329 .lock = ews88mt_ak4524_lock, 330 .unlock = ews88mt_ak4524_unlock 331 } 332 }; 333 334 static struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = { 331 335 .caddr = 2, 332 336 .cif = 1, /* CIF high */ … … 338 342 .add_flags = ICE1712_EWS88_RW, /* set rw bit high */ 339 343 .mask_flags = 0, 340 .ops = {341 .start = ews88mt_ak4524_start,342 .stop = ews88mt_ak4524_stop343 }344 344 }; 345 345 … … 348 348 .num_dacs = 2, 349 349 .type = SND_AK4524, 350 .ops = { 351 .lock = ewx2496_ak4524_lock 352 } 353 }; 354 355 static struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = { 350 356 .caddr = 2, 351 357 .cif = 1, /* CIF high */ … … 357 363 .add_flags = ICE1712_EWS88_RW, /* set rw bit high */ 358 364 .mask_flags = 0, 359 .ops = {360 .start = ewx2496_ak4524_start361 }362 365 }; 363 366 … … 366 369 .num_dacs = 6, 367 370 .type = SND_AK4524, 371 .ops = { 372 .lock = dmx6fire_ak4524_lock 373 } 374 }; 375 376 static struct snd_ak4xxx_private akm_6fire_priv __devinitdata = { 368 377 .caddr = 2, 369 378 .cif = 1, /* CIF high */ … … 375 384 .add_flags = ICE1712_6FIRE_RW, /* set rw bit high */ 376 385 .mask_flags = 0, 377 .ops = { 378 .start = dmx6fire_ak4524_start 379 } 380 }; 381 386 }; 382 387 383 388 /* … … 480 485 case ICE1712_SUBDEVICE_EWS88MT: 481 486 case ICE1712_SUBDEVICE_EWS88MT_NEW: 482 snd_ice1712_akm4xxx_init(ak, &akm_ews88mt, ice);487 err = snd_ice1712_akm4xxx_init(ak, &akm_ews88mt, &akm_ews88mt_priv, ice); 483 488 break; 484 489 case ICE1712_SUBDEVICE_EWX2496: 485 snd_ice1712_akm4xxx_init(ak, &akm_ewx2496, ice);490 err = snd_ice1712_akm4xxx_init(ak, &akm_ewx2496, &akm_ewx2496_priv, ice); 486 491 break; 487 492 case ICE1712_SUBDEVICE_DMX6FIRE: 488 snd_ice1712_akm4xxx_init(ak, &akm_6fire, ice); 489 break; 490 } 491 492 return 0; 493 err = snd_ice1712_akm4xxx_init(ak, &akm_6fire, &akm_6fire_priv, ice); 494 break; 495 default: 496 err = 0; 497 } 498 499 return err; 493 500 } 494 501 … … 603 610 { 604 611 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 605 int channel = kcontrol->id.index;612 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 606 613 unsigned char data; 607 614 … … 622 629 { 623 630 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 624 int channel = kcontrol->id.index;631 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 625 632 unsigned char data, ndata; 626 633 … … 646 653 .get = snd_ice1712_ews88mt_input_sense_get, 647 654 .put = snd_ice1712_ews88mt_input_sense_put, 655 .count = 8, 648 656 }; 649 657 … … 895 903 unsigned int idx; 896 904 int err; 897 snd_kcontrol_t *kctl;898 905 899 /* all terratec cards have spdif */ 900 err = snd_ice1712_spdif_build_controls(ice); 901 if (err < 0) 902 return err; 906 /* all terratec cards have spdif, but cs8427 module builds it's own controls */ 907 if (ice->cs8427 == NULL) { 908 err = snd_ice1712_spdif_build_controls(ice); 909 if (err < 0) 910 return err; 911 } 903 912 904 913 /* ak4524 controls */ … … 925 934 case ICE1712_SUBDEVICE_EWS88MT: 926 935 case ICE1712_SUBDEVICE_EWS88MT_NEW: 927 for (idx = 0; idx < 8; idx++) { 928 kctl = snd_ctl_new1(&snd_ice1712_ews88mt_input_sense, ice); 929 kctl->id.index = idx; 930 err = snd_ctl_add(ice->card, kctl); 931 if (err < 0) 932 return err; 933 } 936 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_input_sense, ice)); 937 if (err < 0) 938 return err; 934 939 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_output_sense, ice)); 935 940 if (err < 0) -
GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/ice1712.c
r231 r246 119 119 120 120 /* 121 * AK4xxx stuff 122 */ 123 124 #include "ak4xxx.c" 125 126 /* 121 127 * Basic I/O 122 128 */ … … 399 405 */ 400 406 401 static voidsnd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs *regs)402 { 403 ice1712_t *ice = snd_magic_cast(ice1712_t, dev_id, return );407 static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs *regs) 408 { 409 ice1712_t *ice = snd_magic_cast(ice1712_t, dev_id, return IRQ_NONE); 404 410 unsigned char status; 411 int handled = 0; 405 412 406 413 while (1) { … … 408 415 if (status == 0) 409 416 break; 417 handled = 1; 410 418 if (status & ICE1712_IRQ_MPU1) { 411 419 if (ice->rmidi[0]) … … 463 471 } 464 472 } 473 return IRQ_RETVAL(handled); 465 474 } 466 475 … … 963 972 unsigned int what = 0; 964 973 unsigned int old; 965 snd_pcm_substream_t *s = substream; 966 967 do { 974 struct list_head *pos; 975 snd_pcm_substream_t *s; 976 977 snd_pcm_group_for_each(pos, substream) { 978 s = snd_pcm_group_substream_entry(pos); 968 979 if (s == ice->playback_pro_substream) { 969 980 what |= ICE1712_PLAYBACK_START; … … 973 984 snd_pcm_trigger_done(s, substream); 974 985 } 975 s = s->link_next; 976 } while (s != substream); 986 } 977 987 spin_lock(&ice->reg_lock); 978 988 old = inl(ICEMT(ice, PLAYBACK_CONTROL)); … … 1297 1307 { 1298 1308 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1299 int index = kcontrol->private_value;1309 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1300 1310 1301 1311 spin_lock_irq(&ice->reg_lock); … … 1309 1319 { 1310 1320 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1311 int index = kcontrol->private_value;1321 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1312 1322 unsigned int nval, change; 1313 1323 … … 1335 1345 { 1336 1346 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1337 int index = kcontrol->private_value;1347 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1338 1348 1339 1349 spin_lock_irq(&ice->reg_lock); … … 1347 1357 { 1348 1358 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1349 int index = kcontrol->private_value;1359 int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; 1350 1360 unsigned int nval, change; 1351 1361 … … 1362 1372 1363 1373 1374 static snd_kcontrol_new_t snd_ice1712_multi_ctrls[] __devinitdata = { 1375 { 1376 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1377 .name = "Multi Playback Switch", 1378 .info = snd_ice1712_pro_mixer_switch_info, 1379 .get = snd_ice1712_pro_mixer_switch_get, 1380 .put = snd_ice1712_pro_mixer_switch_put, 1381 .private_value = 0, 1382 .count = 10, 1383 }, 1384 { 1385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1386 .name = "Multi Playback Volume", 1387 .info = snd_ice1712_pro_mixer_volume_info, 1388 .get = snd_ice1712_pro_mixer_volume_get, 1389 .put = snd_ice1712_pro_mixer_volume_put, 1390 .private_value = 0, 1391 .count = 10, 1392 }, 1393 { 1394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1395 .name = "Multi Capture Switch", 1396 .info = snd_ice1712_pro_mixer_switch_info, 1397 .get = snd_ice1712_pro_mixer_switch_get, 1398 .put = snd_ice1712_pro_mixer_switch_put, 1399 .private_value = 10, 1400 .count = 10, 1401 }, 1402 { 1403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1404 .name = "Multi Capture Volume", 1405 .info = snd_ice1712_pro_mixer_volume_info, 1406 .get = snd_ice1712_pro_mixer_volume_get, 1407 .put = snd_ice1712_pro_mixer_volume_put, 1408 .private_value = 10, 1409 .count = 10, 1410 }, 1411 }; 1412 1364 1413 static int __devinit snd_ice1712_build_pro_mixer(ice1712_t *ice) 1365 1414 { 1366 1415 snd_card_t * card = ice->card; 1367 snd_kcontrol_t ctl; 1368 int idx, err; 1369 1370 /* PCM playback */ 1371 for (idx = 0; idx < 10; idx++) { 1372 memset(&ctl, 0, sizeof(ctl)); 1373 strcpy(ctl.id.name, "Multi Playback Switch"); 1374 ctl.id.index = idx; 1375 ctl.id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 1376 ctl.info = snd_ice1712_pro_mixer_switch_info; 1377 ctl.access = SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE; 1378 ctl.get = snd_ice1712_pro_mixer_switch_get; 1379 ctl.put = snd_ice1712_pro_mixer_switch_put; 1380 ctl.private_value = idx; 1381 ctl.private_data = ice; 1382 if ((err = snd_ctl_add(card, snd_ctl_new(&ctl))) < 0) 1383 return err; 1384 memset(&ctl, 0, sizeof(ctl)); 1385 strcpy(ctl.id.name, "Multi Playback Volume"); 1386 ctl.id.index = idx; 1387 ctl.id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 1388 ctl.info = snd_ice1712_pro_mixer_volume_info; 1389 ctl.access = SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE; 1390 ctl.get = snd_ice1712_pro_mixer_volume_get; 1391 ctl.put = snd_ice1712_pro_mixer_volume_put; 1392 ctl.private_value = idx; 1393 ctl.private_data = ice; 1394 if ((err = snd_ctl_add(card, snd_ctl_new(&ctl))) < 0) 1395 return err; 1396 } 1397 1398 /* PCM capture */ 1399 for (idx = 0; idx < 10; idx++) { 1400 memset(&ctl, 0, sizeof(ctl)); 1401 strcpy(ctl.id.name, "Multi Capture Switch"); 1402 ctl.id.index = idx; 1403 ctl.id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 1404 ctl.info = snd_ice1712_pro_mixer_switch_info; 1405 ctl.access = SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE; 1406 ctl.get = snd_ice1712_pro_mixer_switch_get; 1407 ctl.put = snd_ice1712_pro_mixer_switch_put; 1408 ctl.private_value = idx + 10; 1409 ctl.private_data = ice; 1410 if ((err = snd_ctl_add(card, snd_ctl_new(&ctl))) < 0) 1411 return err; 1412 memset(&ctl, 0, sizeof(ctl)); 1413 strcpy(ctl.id.name, "Multi Capture Volume"); 1414 ctl.id.index = idx; 1415 ctl.id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 1416 ctl.info = snd_ice1712_pro_mixer_volume_info; 1417 ctl.access = SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE; 1418 ctl.get = snd_ice1712_pro_mixer_volume_get; 1419 ctl.put = snd_ice1712_pro_mixer_volume_put; 1420 ctl.private_value = idx + 10; 1421 ctl.private_data = ice; 1422 if ((err = snd_ctl_add(card, snd_ctl_new(&ctl))) < 0) 1416 unsigned int idx; 1417 int err; 1418 1419 /* multi-channel mixer */ 1420 for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_multi_ctrls); idx++) { 1421 err = snd_ctl_add(card, snd_ctl_new1(&snd_ice1712_multi_ctrls[idx], ice)); 1422 if (err < 0) 1423 1423 return err; 1424 1424 } … … 1909 1909 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1910 1910 uinfo->count = 1; 1911 uinfo->value.enumerated.items = kcontrol->id.index< 2 ? 12 : 11;1911 uinfo->value.enumerated.items = snd_ctl_get_ioffidx(kcontrol, &uinfo->id) < 2 ? 12 : 11; 1912 1912 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1913 1913 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; … … 1919 1919 { 1920 1920 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1921 int idx = kcontrol->id.index;1921 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1922 1922 unsigned int val, cval; 1923 1923 … … 1945 1945 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1946 1946 int change, shift; 1947 int idx = kcontrol->id.index;1947 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1948 1948 unsigned int val, old_val, nval; 1949 1949 … … 1993 1993 { 1994 1994 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1995 int idx = kcontrol->id.index;1995 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1996 1996 unsigned int val, cval; 1997 1997 val = inw(ICEMT(ice, ROUTE_SPDOUT)); … … 2013 2013 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 2014 2014 int change, shift; 2015 int idx = kcontrol->id.index;2015 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 2016 2016 unsigned int val, old_val, nval; 2017 2017 … … 2061 2061 .get = snd_ice1712_pro_route_spdif_get, 2062 2062 .put = snd_ice1712_pro_route_spdif_put, 2063 .count = 2, 2063 2064 }; 2064 2065 … … 2247 2248 static int __devinit snd_ice1712_build_controls(ice1712_t *ice) 2248 2249 { 2249 unsigned int idx;2250 snd_kcontrol_t *kctl;2251 2250 int err; 2252 2251 … … 2265 2264 return err; 2266 2265 2267 for (idx = 0; idx < ice->num_total_dacs; idx++) { 2268 kctl = snd_ctl_new1(&snd_ice1712_mixer_pro_analog_route, ice); 2269 if (kctl == NULL) 2270 return -ENOMEM; 2271 kctl->id.index = idx; 2272 err = snd_ctl_add(ice->card, kctl); 2266 if (ice->num_total_dacs > 0) { 2267 snd_kcontrol_new_t tmp = snd_ice1712_mixer_pro_analog_route; 2268 tmp.count = ice->num_total_dacs; 2269 err = snd_ctl_add(ice->card, snd_ctl_new1(&tmp, ice)); 2273 2270 if (err < 0) 2274 2271 return err; 2275 2272 } 2276 2273 2277 for (idx = 0; idx < 2; idx++) { 2278 kctl = snd_ctl_new1(&snd_ice1712_mixer_pro_spdif_route, ice); 2279 if (kctl == NULL) 2280 return -ENOMEM; 2281 kctl->id.index = idx; 2282 err = snd_ctl_add(ice->card, kctl); 2283 if (err < 0) 2284 return err; 2285 } 2274 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_spdif_route, ice)); 2275 if (err < 0) 2276 return err; 2286 2277 2287 2278 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_volume_rate, ice)); … … 2324 2315 kfree_nocheck(ice->res_profi_port); 2325 2316 } 2326 if (ice->akm) 2327 kfree(ice->akm); 2317 snd_ice1712_akm4xxx_free(ice); 2328 2318 snd_magic_kfree(ice); 2329 2319 return 0; -
GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/ice1712.h
r224 r246 27 27 #include <sound/rawmidi.h> 28 28 #include <sound/i2c.h> 29 #include <sound/ak4xxx-adda.h> 29 30 #include <sound/pcm.h> 30 31 … … 215 216 216 217 typedef struct _snd_ice1712 ice1712_t; 217 typedef struct snd_ak4xxx akm4xxx_t;218 218 219 219 typedef struct { … … 255 255 256 256 257 struct snd_ak4xxx { 258 unsigned int num_adcs; /* AK4524 or AK4528 ADCs */ 259 unsigned int num_dacs; /* AK4524 or AK4528 DACs */ 260 unsigned char images[4][16]; /* saved register image */ 261 unsigned char ipga_gain[4][2]; /* saved register image for IPGA (AK4528) */ 262 ice1712_t *chip; 263 /* template should fill the following fields */ 264 unsigned int idx_offset; /* control index offset */ 265 enum { 266 SND_AK4524, SND_AK4528, SND_AK4529, SND_AK4355, SND_AK4381 267 } type; 257 struct snd_ak4xxx_private { 268 258 unsigned int cif: 1; /* CIF mode */ 269 259 unsigned char caddr; /* C0 and C1 bits */ … … 276 266 unsigned int mask_flags; /* total mask bits */ 277 267 struct snd_akm4xxx_ops { 278 int (*start)(akm4xxx_t *ak, int chip);279 void (*stop)(akm4xxx_t *ak);280 268 void (*set_rate_val)(akm4xxx_t *ak, unsigned int rate); 281 269 } ops; … … 440 428 int snd_ice1712_spdif_build_controls(ice1712_t *ice); 441 429 442 void snd_ice1712_akm4xxx_write(akm4xxx_t *ice, int chip, unsigned char addr, unsigned char data); 443 void snd_ice1712_akm4xxx_reset(akm4xxx_t *ice, int state); 444 void snd_ice1712_akm4xxx_init(akm4xxx_t *ak, const akm4xxx_t *template, ice1712_t *ice); 430 int snd_ice1712_akm4xxx_init(akm4xxx_t *ak, const akm4xxx_t *template, const struct snd_ak4xxx_private *priv, ice1712_t *ice); 431 void snd_ice1712_akm4xxx_free(ice1712_t *ice); 445 432 int snd_ice1712_akm4xxx_build_controls(ice1712_t *ice); 446 433 -
GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/ice1724.c
r231 r246 89 89 90 90 /* 91 * AK4xxx stuff 92 */ 93 94 #include "ak4xxx.c" 95 96 /* 91 97 * Basic I/O 92 98 */ … … 195 201 */ 196 202 197 static voidsnd_vt1724_interrupt(int irq, void *dev_id, struct pt_regs *regs)198 { 199 ice1712_t *ice = snd_magic_cast(ice1712_t, dev_id, return );203 static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id, struct pt_regs *regs) 204 { 205 ice1712_t *ice = snd_magic_cast(ice1712_t, dev_id, return IRQ_NONE); 200 206 unsigned char status; 207 int handled = 0; 201 208 202 209 while (1) { … … 204 211 if (status == 0) 205 212 break; 206 213 214 handled = 1; 207 215 /* these should probably be separated at some point, 208 216 but as we don't currently have MPU support on the board I will leave it */ … … 243 251 } 244 252 } 253 return IRQ_RETVAL(handled); 245 254 } 246 255 … … 282 291 unsigned int what; 283 292 unsigned int old; 293 struct list_head *pos; 284 294 snd_pcm_substream_t *s; 285 295 … … 288 298 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 289 299 what = 0; 290 s = substream;291 do {300 snd_pcm_group_for_each(pos, substream) { 301 s = snd_pcm_group_substream_entry(pos); 292 302 if (s == ice->playback_pro_substream) 293 303 what |= VT1724_PDMA0_PAUSE; … … 298 308 else if (s == ice->capture_con_substream) 299 309 what |= VT1724_RDMA1_PAUSE; 300 s = s->link_next; 301 } while (s != substream); 310 } 302 311 spin_lock(&ice->reg_lock); 303 312 old = inl(ICEMT1724(ice, DMA_PAUSE)); … … 314 323 what = 0; 315 324 s = substream; 316 do { 325 snd_pcm_group_for_each(pos, substream) { 326 s = snd_pcm_group_substream_entry(pos); 317 327 if (s == ice->playback_pro_substream) { 318 328 what |= VT1724_PDMA0_START; … … 328 338 snd_pcm_trigger_done(s, substream); 329 339 } 330 s = s->link_next; 331 } while (s != substream); 340 } 332 341 spin_lock(&ice->reg_lock); 333 342 old = inl(ICEMT1724(ice, DMA_CONTROL)); … … 1295 1304 } 1296 1305 1297 static snd_kcontrol_new_t snd_vt1724_pro_internal_clock = __devinitdata{1306 static snd_kcontrol_new_t snd_vt1724_pro_internal_clock __devinitdata = { 1298 1307 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1299 1308 .name = "Multi Track Internal Clock", … … 1450 1459 { 1451 1460 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1452 int idx = kcontrol->id.index;1461 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1453 1462 ucontrol->value.enumerated.item[0] = get_route_val(ice, analog_route_shift(idx)); 1454 1463 return 0; … … 1458 1467 { 1459 1468 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1460 int idx = kcontrol->id.index;1469 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1461 1470 return put_route_val(ice, ucontrol->value.enumerated.item[0], 1462 1471 analog_route_shift(idx)); … … 1466 1475 { 1467 1476 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1468 int idx = kcontrol->id.index;1477 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1469 1478 ucontrol->value.enumerated.item[0] = get_route_val(ice, digital_route_shift(idx)); 1470 1479 return 0; … … 1474 1483 { 1475 1484 ice1712_t *ice = snd_kcontrol_chip(kcontrol); 1476 int idx = kcontrol->id.index;1485 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1477 1486 return put_route_val(ice, ucontrol->value.enumerated.item[0], 1478 1487 digital_route_shift(idx)); … … 1493 1502 .get = snd_vt1724_pro_route_spdif_get, 1494 1503 .put = snd_vt1724_pro_route_spdif_put, 1504 .count = 2, 1495 1505 }; 1496 1506 … … 1603 1613 { 1604 1614 int err; 1605 unsigned int idx;1606 1615 snd_kcontrol_t *kctl; 1607 1616 1608 1617 snd_assert(ice->pcm != NULL, return -EIO); 1609 1618 1610 for (idx = 0; idx < 2; idx++) { 1611 kctl = snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route, ice); 1612 if (kctl == NULL) 1613 return -ENOMEM; 1614 kctl->id.index = idx; 1615 err = snd_ctl_add(ice->card, kctl); 1616 if (err < 0) 1617 return err; 1618 } 1619 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_mixer_pro_spdif_route, ice)); 1620 if (err < 0) 1621 return err; 1619 1622 1620 1623 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_spdif_switch, ice)); … … 1647 1650 static int __devinit snd_vt1724_build_controls(ice1712_t *ice) 1648 1651 { 1649 unsigned int idx;1650 snd_kcontrol_t *kctl;1651 1652 int err; 1652 1653 … … 1665 1666 return err; 1666 1667 1667 for (idx = 0; idx < ice->num_total_dacs; idx++) { 1668 kctl = snd_ctl_new1(&snd_vt1724_mixer_pro_analog_route, ice); 1669 if (kctl == NULL) 1670 return -ENOMEM; 1671 kctl->id.index = idx; 1672 err = snd_ctl_add(ice->card, kctl); 1668 if (ice->num_total_dacs > 0) { 1669 snd_kcontrol_new_t tmp = snd_vt1724_mixer_pro_analog_route; 1670 tmp.count = ice->num_total_dacs; 1671 err = snd_ctl_add(ice->card, snd_ctl_new1(&tmp, ice)); 1673 1672 if (err < 0) 1674 1673 return err; … … 1703 1702 kfree_nocheck(ice->res_profi_port); 1704 1703 } 1705 if (ice->akm) 1706 kfree(ice->akm); 1704 snd_ice1712_akm4xxx_free(ice); 1707 1705 snd_magic_kfree(ice); 1708 1706 return 0; -
GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/makefile.os2
r224 r246 13 13 # 14 14 #=================================================================== 15 FILE1 = ak4 524.obj delta.obj ews.obj hoontech.obj ice1712.obj15 FILE1 = ak4xxx.obj delta.obj ews.obj hoontech.obj ice1712.obj 16 16 FILE2 = ice1724.obj revo.obj 17 17 FILE3 = -
GPL/branches/alsa-resync1/alsa-kernel/pci/ice1712/revo.c
r224 r246 66 66 67 67 /* reset DFS */ 68 snd_ ice1712_akm4xxx_reset(ak, 1);68 snd_akm4xxx_reset(ak, 1); 69 69 tmp = ak->images[0][reg]; 70 70 tmp &= ~(0x03 << shift); 71 71 tmp |= dfs << shift; 72 snd_ ice1712_akm4xxx_write(ak, 0, reg, tmp);73 snd_ ice1712_akm4xxx_reset(ak, 0);72 snd_akm4xxx_write(ak, 0, reg, tmp); 73 snd_akm4xxx_reset(ak, 0); 74 74 } 75 75 … … 81 81 .type = SND_AK4381, 82 82 .num_dacs = 2, 83 .ops = { 84 .set_rate_val = revo_set_rate_val 85 } 86 }; 87 88 static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = { 83 89 .caddr = 1, 84 90 .cif = 0, … … 90 96 .add_flags = VT1724_REVO_CCLK, /* high at init */ 91 97 .mask_flags = 0, 92 .ops = {93 .set_rate_val = revo_set_rate_val94 }95 98 }; 96 99 … … 99 102 .idx_offset = 1, 100 103 .num_dacs = 6, 104 .ops = { 105 .set_rate_val = revo_set_rate_val 106 } 107 }; 108 109 static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = { 101 110 .caddr = 3, 102 111 .cif = 0, … … 108 117 .add_flags = VT1724_REVO_CCLK, /* high at init */ 109 118 .mask_flags = 0, 110 .ops = {111 .set_rate_val = revo_set_rate_val112 }113 119 }; 114 120 … … 134 140 switch (ice->eeprom.subvendor) { 135 141 case VT1724_SUBDEVICE_REVOLUTION71: 136 snd_ice1712_akm4xxx_init(ak, &akm_revo_front, ice);137 snd_ice1712_akm4xxx_init(ak + 1, &akm_revo_surround, ice);142 snd_ice1712_akm4xxx_init(ak, &akm_revo_front, &akm_revo_front_priv, ice); 143 snd_ice1712_akm4xxx_init(ak + 1, &akm_revo_surround, &akm_revo_surround_priv, ice); 138 144 /* unmute all codecs */ 139 145 snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE, VT1724_REVO_MUTE); -
GPL/branches/alsa-resync1/alsa-kernel/pci/korg1212/korg1212.c
r224 r246 150 150 #define MAILBOX2_OFFSET 0x48 // location of mailbox 2 relative to base address 151 151 #define MAILBOX3_OFFSET 0x4c // location of mailbox 3 relative to base address 152 #define OUT_DOORBELL_OFFSET 0x60 // location of PCI to local doorbell "153 #define IN_DOORBELL_OFFSET 0x64 // location of local to PCI doorbell "154 #define STATUS_REG_OFFSET 0x68 // location of interrupt control/status register "152 #define OUT_DOORBELL_OFFSET 0x60 // location of PCI to local doorbell 153 #define IN_DOORBELL_OFFSET 0x64 // location of local to PCI doorbell 154 #define STATUS_REG_OFFSET 0x68 // location of interrupt control/status register 155 155 #define PCI_CONTROL_OFFSET 0x6c // location of the EEPROM, PCI, User I/O, init control 156 156 // register … … 330 330 331 331 spinlock_t lock; 332 struct semaphore open_mutex; 333 334 struct timer_list timer; /* timer callback for checking ack of stop request */ 335 int stop_pending_cnt; /* counter for stop pending check */ 332 336 333 337 wait_queue_head_t wait; … … 603 607 } 604 608 605 static void snd_korg1212_WaitForCardStopAck(korg1212_t *korg1212) 606 { 607 u32 endtime = jiffies + 2 * HZ; 608 609 #if K1212_DEBUG_LEVEL > 0 610 K1212_DEBUG_PRINTK("K1212_DEBUG: WaitForCardStopAck.in [%s] %lu %lu\n", stateName[korg1212->cardState], jiffies, korg1212->inIRQ); 611 #endif 612 613 if (korg1212->inIRQ) 614 return; 615 616 do { 609 /* spinlock already held */ 610 static void snd_korg1212_SendStop(korg1212_t *korg1212) 611 { 612 if (! korg1212->stop_pending_cnt) { 613 writel(0xffffffff, &korg1212->sharedBufferPtr->cardCommand); 614 /* program the timer */ 615 korg1212->stop_pending_cnt = HZ; 616 korg1212->timer.expires = jiffies + 1; 617 add_timer(&korg1212->timer); 618 } 619 } 620 621 static void snd_korg1212_SendStopAndWait(korg1212_t *korg1212) 622 { 623 unsigned long flags; 624 spin_lock_irqsave(&korg1212->lock, flags); 625 snd_korg1212_SendStop(korg1212); 626 spin_unlock_irqrestore(&korg1212->lock, flags); 627 sleep_on_timeout(&korg1212->wait, (HZ * 3) / 2); 628 } 629 630 /* timer callback for checking the ack of stop request */ 631 static void snd_korg1212_timer_func(unsigned long data) 632 { 633 korg1212_t *korg1212 = snd_magic_cast(korg1212_t, (void*)data, return); 634 635 spin_lock(&korg1212->lock); 617 636 if (readl(&korg1212->sharedBufferPtr->cardCommand) == 0) { 618 #if K1212_DEBUG_LEVEL > 0 619 K1212_DEBUG_PRINTK("K1212_DEBUG: WaitForCardStopAck.out [%s] %lu %lu\n", stateName[korg1212->cardState], jiffies, korg1212->inIRQ); 620 #endif 621 return; 637 /* ack'ed */ 638 korg1212->stop_pending_cnt = 0; 639 wake_up(&korg1212->wait); 640 #if K1212_DEBUG_LEVEL > 1 641 K1212_DEBUG_PRINTK("K1212_DEBUG: Stop ack'ed [%s]\n", stateName[korg1212->cardState]); 642 #endif 643 } else { 644 if (--korg1212->stop_pending_cnt > 0) { 645 /* reprogram timer */ 646 korg1212->timer.expires = jiffies + 1; 647 add_timer(&korg1212->timer); 648 } else { 649 snd_printd("korg1212_timer_func timeout\n"); 650 writel(0, &korg1212->sharedBufferPtr->cardCommand); 651 wake_up(&korg1212->wait); 652 #if K1212_DEBUG_LEVEL > 0 653 K1212_DEBUG_PRINTK("K1212_DEBUG: Stop timeout [%s]\n", stateName[korg1212->cardState]); 654 #endif 622 655 } 623 if (!korg1212->inIRQ) 624 schedule(); 625 } while (time_before(jiffies, endtime)); 626 627 #if K1212_DEBUG_LEVEL > 0 628 K1212_DEBUG_PRINTK("K1212_DEBUG: WaitForCardStopAck.out TO [%s] %lu %lu\n", stateName[korg1212->cardState], jiffies, korg1212->inIRQ); 629 #endif 630 writel(0, &korg1212->sharedBufferPtr->cardCommand); 656 } 657 spin_unlock(&korg1212->lock); 631 658 } 632 659 633 660 static void snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212) 634 661 { 662 unsigned long flags; 663 635 664 udelay(INTERCOMMAND_DELAY); 665 spin_lock_irqsave(&korg1212->lock, flags); 636 666 korg1212->idleMonitorOn = 1; 637 667 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, 638 668 K1212_MODE_MonitorOn, 0, 0, 0); 669 spin_unlock_irqrestore(&korg1212->lock, flags); 639 670 } 640 671 … … 642 673 { 643 674 if (korg1212->idleMonitorOn) { 644 writel(0xffffffff, &korg1212->sharedBufferPtr->cardCommand); 645 snd_korg1212_WaitForCardStopAck(korg1212); 675 snd_korg1212_SendStopAndWait(korg1212); 646 676 korg1212->idleMonitorOn = 0; 647 677 } 648 678 } 649 679 650 static void snd_korg1212_setCardState(korg1212_t * korg1212, CardState csState) 651 { 652 switch (csState) { 653 case K1212_STATE_READY: 654 snd_korg1212_TurnOnIdleMonitor(korg1212); 655 break; 656 657 case K1212_STATE_OPEN: 658 snd_korg1212_TurnOffIdleMonitor(korg1212); 659 break; 660 661 default: 662 break; 663 } 664 680 static inline void snd_korg1212_setCardState(korg1212_t * korg1212, CardState csState) 681 { 665 682 korg1212->cardState = csState; 666 683 } … … 671 688 K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", stateName[korg1212->cardState], korg1212->opencnt); 672 689 #endif 673 if (korg1212->opencnt++ == 0) 690 down(&korg1212->open_mutex); 691 if (korg1212->opencnt++ == 0) { 692 snd_korg1212_TurnOffIdleMonitor(korg1212); 674 693 snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN); 694 } 695 696 up(&korg1212->open_mutex); 675 697 return 1; 676 698 } … … 682 704 #endif 683 705 684 if (--(korg1212->opencnt)) 706 down(&korg1212->open_mutex); 707 if (--(korg1212->opencnt)) { 708 up(&korg1212->open_mutex); 685 709 return 0; 710 } 686 711 687 712 if (korg1212->cardState == K1212_STATE_SETUP) { … … 692 717 #endif 693 718 694 if (rc != K1212_CMDRET_Success) 719 if (rc != K1212_CMDRET_Success) { 720 up(&korg1212->open_mutex); 695 721 return 0; 722 } 696 723 } else if (korg1212->cardState > K1212_STATE_SETUP) { 697 writel(0xffffffff, &korg1212->sharedBufferPtr->cardCommand);698 snd_korg1212_WaitForCardStopAck(korg1212);699 } 700 701 if (korg1212->cardState > K1212_STATE_READY) 724 snd_korg1212_SendStopAndWait(korg1212); 725 } 726 727 if (korg1212->cardState > K1212_STATE_READY) { 728 snd_korg1212_TurnOnIdleMonitor(korg1212); 702 729 snd_korg1212_setCardState(korg1212, K1212_STATE_READY); 703 730 } 731 732 up(&korg1212->open_mutex); 704 733 return 0; 705 734 } 706 735 736 /* spinlock already held */ 707 737 static int snd_korg1212_SetupForPlay(korg1212_t * korg1212) 708 738 { … … 727 757 } 728 758 759 /* spinlock already held */ 729 760 static int snd_korg1212_TriggerPlay(korg1212_t * korg1212) 730 761 { … … 749 780 } 750 781 782 /* spinlock already held */ 751 783 static int snd_korg1212_StopPlay(korg1212_t * korg1212) 752 784 { … … 760 792 korg1212->setcnt = 0; 761 793 762 if (korg1212->cardState != K1212_STATE_ERRORSTOP) { 763 writel(0xffffffff, &korg1212->sharedBufferPtr->cardCommand); 764 snd_korg1212_WaitForCardStopAck(korg1212); 765 } 794 if (korg1212->cardState != K1212_STATE_ERRORSTOP) 795 snd_korg1212_SendStop(korg1212); 796 766 797 snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN); 767 798 return 0; … … 790 821 return 0; 791 822 } else { 792 writel(0xffffffff, &korg1212->sharedBufferPtr->cardCommand); 793 snd_korg1212_WaitForCardStopAck(korg1212); 823 snd_korg1212_SendStopAndWait(korg1212); 794 824 snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN); 795 825 } … … 885 915 // the card's eeprom control register. 886 916 u16 count; 917 unsigned long flags; 887 918 888 919 #if K1212_DEBUG_LEVEL > 0 … … 901 932 // ---------------------------------------------------------------------------- 902 933 if (korg1212->cardState == K1212_STATE_MONITOR || korg1212->idleMonitorOn) { 903 writel(0xffffffff, &korg1212->sharedBufferPtr->cardCommand);904 934 monModeSet = 1; 905 snd_korg1212_WaitForCardStopAck(korg1212);935 snd_korg1212_SendStopAndWait(korg1212); 906 936 } else 907 937 monModeSet = 0; 938 939 spin_lock_irqsave(&korg1212->lock, flags); 908 940 909 941 // ---------------------------------------------------------------------------- … … 1017 1049 } 1018 1050 1051 spin_unlock_irqrestore(&korg1212->lock, flags); 1052 1019 1053 return 1; 1020 1054 } … … 1090 1124 #endif 1091 1125 1126 snd_korg1212_TurnOnIdleMonitor(korg1212); 1092 1127 snd_korg1212_setCardState(korg1212, K1212_STATE_READY); 1093 1128 … … 1096 1131 #endif 1097 1132 1098 wake_up_interruptible(&korg1212->wait);1099 } 1100 1101 static voidsnd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs *regs)1133 snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE); 1134 } 1135 1136 static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1102 1137 { 1103 1138 u32 doorbellValue; 1104 korg1212_t *korg1212 = snd_magic_cast(korg1212_t, dev_id, return );1139 korg1212_t *korg1212 = snd_magic_cast(korg1212_t, dev_id, return IRQ_NONE); 1105 1140 1106 1141 if(irq != korg1212->irq) 1107 return ;1142 return IRQ_NONE; 1108 1143 1109 1144 doorbellValue = readl(korg1212->inDoorbellPtr); 1110 1145 1111 1146 if (!doorbellValue) 1112 return; 1147 return IRQ_HANDLED; 1148 1149 spin_lock(&korg1212->lock); 1113 1150 1114 1151 writel(doorbellValue, korg1212->inDoorbellPtr); … … 1124 1161 K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DNLD count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]); 1125 1162 #endif 1126 if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) { 1127 snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE); 1128 snd_korg1212_OnDSPDownloadComplete(korg1212); 1129 } 1163 if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) 1164 wake_up(&korg1212->wait); 1130 1165 break; 1131 1166 … … 1167 1202 1168 1203 if (korg1212->capture_substream) { 1204 spin_unlock(&korg1212->lock); 1169 1205 snd_pcm_period_elapsed(korg1212->capture_substream); 1206 spin_lock(&korg1212->lock); 1170 1207 } 1171 1208 1172 1209 if (korg1212->playback_substream) { 1210 spin_unlock(&korg1212->lock); 1173 1211 snd_pcm_period_elapsed(korg1212->playback_substream); 1212 spin_lock(&korg1212->lock); 1174 1213 } 1175 1214 } … … 1178 1217 1179 1218 korg1212->inIRQ--; 1219 1220 spin_unlock(&korg1212->lock); 1221 return IRQ_HANDLED; 1180 1222 } 1181 1223 … … 1206 1248 #endif 1207 1249 1208 interruptible_sleep_on_timeout(&korg1212->wait, HZ * 4); 1250 if (! sleep_on_timeout(&korg1212->wait, HZ * 4)) 1251 return -EBUSY; /* timeout */ 1252 1253 snd_korg1212_OnDSPDownloadComplete(korg1212); 1209 1254 1210 1255 return 0; … … 1364 1409 snd_pcm_set_sync(substream); // ??? 1365 1410 1366 spin_lock_irqsave(&korg1212->lock, flags);1367 1368 1411 snd_korg1212_OpenCard(korg1212); 1369 1412 1413 runtime->hw = snd_korg1212_playback_info; 1370 1414 runtime->dma_area = (char *) korg1212->playDataBufsPtr; 1371 1415 runtime->dma_bytes = K1212_BUF_SIZE; 1416 1417 spin_lock_irqsave(&korg1212->lock, flags); 1372 1418 1373 1419 korg1212->playback_substream = substream; … … 1394 1440 snd_pcm_set_sync(substream); // ??? 1395 1441 1396 spin_lock_irqsave(&korg1212->lock, flags);1397 1398 1442 snd_korg1212_OpenCard(korg1212); 1399 1443 … … 1402 1446 runtime->dma_bytes = K1212_BUF_SIZE; 1403 1447 1448 spin_lock_irqsave(&korg1212->lock, flags); 1449 1404 1450 korg1212->capture_substream = substream; 1405 1451 korg1212->periodsize = K1212_PERIODS; … … 1428 1474 korg1212->periodsize = 0; 1429 1475 1430 snd_korg1212_CloseCard(korg1212);1431 1432 1476 spin_unlock_irqrestore(&korg1212->lock, flags); 1477 1478 snd_korg1212_CloseCard(korg1212); 1433 1479 return 0; 1434 1480 } … … 1448 1494 korg1212->periodsize = 0; 1449 1495 1450 snd_korg1212_CloseCard(korg1212);1451 1452 1496 spin_unlock_irqrestore(&korg1212->lock, flags); 1497 1498 snd_korg1212_CloseCard(korg1212); 1453 1499 return 0; 1454 1500 } … … 1508 1554 { 1509 1555 korg1212_t *korg1212 = _snd_pcm_substream_chip(substream); 1510 unsigned long flags;1511 1556 int rc; 1512 1557 … … 1515 1560 #endif 1516 1561 1517 spin_lock_irqsave(&korg1212->lock, flags); 1562 spin_lock(&korg1212->lock); 1563 1564 /* FIXME: we should wait for ack! */ 1565 if (korg1212->stop_pending_cnt > 0) { 1566 #if K1212_DEBUG_LEVEL > 0 1567 K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n", stateName[korg1212->cardState]); 1568 #endif 1569 spin_unlock(&korg1212->lock); 1570 return -EAGAIN; 1571 /* 1572 writel(0, &korg1212->sharedBufferPtr->cardCommand); 1573 del_timer(&korg1212->timer); 1574 korg1212->stop_pending_cnt = 0; 1575 */ 1576 } 1518 1577 1519 1578 rc = snd_korg1212_SetupForPlay(korg1212); 1579 1520 1580 korg1212->currentBuffer = 0; 1521 1581 1522 spin_unlock _irqrestore(&korg1212->lock, flags);1582 spin_unlock(&korg1212->lock); 1523 1583 1524 1584 return rc ? -EINVAL : 0; … … 1535 1595 #endif 1536 1596 1597 spin_lock(&korg1212->lock); 1537 1598 switch (cmd) { 1538 1599 case SNDRV_PCM_TRIGGER_START: … … 1566 1627 break; 1567 1628 } 1629 spin_unlock(&korg1212->lock); 1568 1630 return rc ? -EINVAL : 0; 1569 1631 } … … 1894 1956 } 1895 1957 1958 spin_unlock_irqrestore(&korg1212->lock, flags); 1959 1896 1960 if (change) 1897 1961 snd_korg1212_WriteADCSensitivity(korg1212); 1898 1899 spin_unlock_irqrestore(&korg1212->lock, flags);1900 1962 1901 1963 return change; … … 2151 2213 init_waitqueue_head(&korg1212->wait); 2152 2214 spin_lock_init(&korg1212->lock); 2215 init_MUTEX(&korg1212->open_mutex); 2216 init_timer(&korg1212->timer); 2217 korg1212->timer.function = snd_korg1212_timer_func; 2218 korg1212->timer.data = (unsigned long)korg1212; 2153 2219 2154 2220 korg1212->irq = -1; -
GPL/branches/alsa-resync1/alsa-kernel/pci/rme96.c
r224 r246 1154 1154 } 1155 1155 1156 static void1156 static irqreturn_t 1157 1157 snd_rme96_interrupt(int irq, 1158 1158 void *dev_id, … … 1166 1166 (rme96->rcreg & RME96_RCR_IRQ_2))) 1167 1167 { 1168 return ;1168 return IRQ_NONE; 1169 1169 } 1170 1170 … … 1179 1179 writel(0, rme96->iobase + RME96_IO_CONFIRM_REC_IRQ); 1180 1180 } 1181 return IRQ_HANDLED; 1181 1182 } 1182 1183 -
GPL/branches/alsa-resync1/alsa-kernel/pci/rme9652/hdsp.c
r224 r246 3 3 * 4 4 * Copyright (c) 2002 Paul Davis 5 * Marcus Andersson 6 * Thomas Charbonnel 5 7 * 6 8 * This program is free software; you can redistribute it and/or modify … … 21 23 22 24 #include <sound/driver.h> 23 #include <asm/io.h>24 #include <asm/byteorder.h>25 25 #include <linux/delay.h> 26 #include <linux/in it.h>26 #include <linux/interrupt.h> 27 27 #include <linux/slab.h> 28 28 #include <linux/pci.h> 29 29 30 #include <sound/core.h> 30 31 #include <sound/control.h> … … 33 34 #include <sound/asoundef.h> 34 35 #include <sound/rawmidi.h> 36 #include <sound/hwdep.h> 35 37 #define SNDRV_GET_ID 36 38 #include <sound/initval.h> 37 38 #include "multiface_firmware.dat" 39 #include "digiface_firmware.dat" 39 #include <sound/hdsp.h> 40 41 #include <asm/byteorder.h> 42 #include <asm/current.h> 43 #include <asm/io.h> 40 44 41 45 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ … … 44 48 static int precise_ptr[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0 }; /* Enable precise pointer */ 45 49 static int line_outs_monitor[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0}; /* Send all inputs/playback to line outs */ 46 static int force_firmware[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = 0}; /* Force firmware reload */47 50 48 51 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); … … 61 64 MODULE_PARM_DESC(line_outs_monitor, "Send all input and playback streams to line outs by default."); 62 65 MODULE_PARM_SYNTAX(line_outs_monitor, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC); 63 MODULE_PARM(force_firmware,"1-" __MODULE_STRING(SNDRV_CARDS) "i"); 64 MODULE_PARM_DESC(force_firmware, "Force a reload of the I/O box firmware"); 65 MODULE_PARM_SYNTAX(force_firmware, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC); 66 MODULE_AUTHOR("Paul Davis <pbd@op.net>"); 66 MODULE_AUTHOR("Paul Davis <paul@linuxaudiosystems.com>, Marcus Andersson, Thomas Charbonnel <thomas@undata.org>"); 67 67 MODULE_DESCRIPTION("RME Hammerfall DSP"); 68 68 MODULE_LICENSE("GPL"); 69 69 MODULE_CLASSES("{sound}"); 70 MODULE_DEVICES("{{RME,Hammerfall-DSP}}"); 71 72 typedef enum { 73 Digiface, 74 Multiface 75 } HDSP_Type; 70 MODULE_DEVICES("{{RME Hammerfall-DSP}," 71 "{RME HDSP-9652}}"); 76 72 77 73 #define HDSP_MAX_CHANNELS 26 … … 79 75 #define DIGIFACE_DS_CHANNELS 14 80 76 #define MULTIFACE_SS_CHANNELS 18 81 #define MULTIFACE_DS_CHANNELS 1 077 #define MULTIFACE_DS_CHANNELS 14 82 78 83 79 /* Write registers. These are defined as byte-offsets from the iobase value. … … 119 115 #define HDSP_playbackPeakLevel 4096 /* 26 * 32 bit values */ 120 116 #define HDSP_inputPeakLevel 4224 /* 26 * 32 bit values */ 121 #define HDSP_outputPeakLevel 4 100 /* 26* 32 bit values */117 #define HDSP_outputPeakLevel 4352 /* (26+2) * 32 bit values */ 122 118 #define HDSP_playbackRmsLevel 4612 /* 26 * 64 bit values */ 123 #define HDSP_inputRmsLevel 48 84/* 26 * 64 bit values */119 #define HDSP_inputRmsLevel 4868 /* 26 * 64 bit values */ 124 120 125 121 #define HDSP_IO_EXTENT 5192 … … 144 140 /* Control Register bits */ 145 141 146 #define HDSP_Start (1<<0) / / start engine147 #define HDSP_Latency0 (1<<1) / / buffer size = 2^n where n is defined by Latency{2,1,0}148 #define HDSP_Latency1 (1<<2) / / [ see above ]149 #define HDSP_Latency2 (1<<3) / / ] see above ]150 #define HDSP_ClockModeMaster (1<<4) / / 1=Master, 0=Slave/Autosync151 #define HDSP_AudioInterruptEnable (1<<5) / / what do you think ?152 #define HDSP_Frequency0 (1<<6) / / 0=44.1kHz/88.2kHz 1=48kHz/96kHz153 #define HDSP_Frequency1 (1<<7) / / 0=32kHz/64kHz154 #define HDSP_DoubleSpeed (1<<8) / / 0=normal speed, 1=double speed155 #define HDSP_SPDIFProfessional (1<<9) / / 0=consumer, 1=professional156 #define HDSP_SPDIFEmphasis (1<<10) / / 0=none, 1=on157 #define HDSP_SPDIFNonAudio (1<<11) / / 0=off, 1=on158 #define HDSP_SPDIFOpticalOut (1<<12) / / 1=use 1st ADAT connector for SPDIF, 0=do not142 #define HDSP_Start (1<<0) /* start engine */ 143 #define HDSP_Latency0 (1<<1) /* buffer size = 2^n where n is defined by Latency{2,1,0} */ 144 #define HDSP_Latency1 (1<<2) /* [ see above ] */ 145 #define HDSP_Latency2 (1<<3) /* ] see above ] */ 146 #define HDSP_ClockModeMaster (1<<4) /* 1=Master, 0=Slave/Autosync */ 147 #define HDSP_AudioInterruptEnable (1<<5) /* what do you think ? */ 148 #define HDSP_Frequency0 (1<<6) /* 0=44.1kHz/88.2kHz 1=48kHz/96kHz */ 149 #define HDSP_Frequency1 (1<<7) /* 0=32kHz/64kHz */ 150 #define HDSP_DoubleSpeed (1<<8) /* 0=normal speed, 1=double speed */ 151 #define HDSP_SPDIFProfessional (1<<9) /* 0=consumer, 1=professional */ 152 #define HDSP_SPDIFEmphasis (1<<10) /* 0=none, 1=on */ 153 #define HDSP_SPDIFNonAudio (1<<11) /* 0=off, 1=on */ 154 #define HDSP_SPDIFOpticalOut (1<<12) /* 1=use 1st ADAT connector for SPDIF, 0=do not */ 159 155 #define HDSP_SyncRef2 (1<<13) 160 156 #define HDSP_SPDIFInputSelect0 (1<<14) … … 182 178 #define HDSP_SyncRef_ADAT_SYNC (HDSP_SyncRef0|HDSP_SyncRef2) 183 179 184 /* Preferred sync source choices - used by "sync_pref" control switch */ 185 186 #define HDSP_SYNC_FROM_SELF 0 187 #define HDSP_SYNC_FROM_WORD 1 188 #define HDSP_SYNC_FROM_ADAT_SYNC 2 189 #define HDSP_SYNC_FROM_SPDIF 3 190 #define HDSP_SYNC_FROM_ADAT1 4 191 #define HDSP_SYNC_FROM_ADAT2 5 192 #define HDSP_SYNC_FROM_ADAT3 6 180 /* Sample Clock Sources */ 181 182 #define HDSP_CLOCK_SOURCE_AUTOSYNC 0 183 #define HDSP_CLOCK_SOURCE_INTERNAL_32KHZ 1 184 #define HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ 2 185 #define HDSP_CLOCK_SOURCE_INTERNAL_48KHZ 3 186 #define HDSP_CLOCK_SOURCE_INTERNAL_64KHZ 4 187 #define HDSP_CLOCK_SOURCE_INTERNAL_88_2KHZ 5 188 #define HDSP_CLOCK_SOURCE_INTERNAL_96KHZ 6 189 190 /* Preferred sync reference choices - used by "pref_sync_ref" control switch */ 191 192 #define HDSP_SYNC_FROM_WORD 0 193 #define HDSP_SYNC_FROM_ADAT_SYNC 1 194 #define HDSP_SYNC_FROM_SPDIF 2 195 #define HDSP_SYNC_FROM_ADAT1 3 196 #define HDSP_SYNC_FROM_ADAT2 4 197 #define HDSP_SYNC_FROM_ADAT3 5 198 199 /* SyncCheck status */ 200 201 #define HDSP_SYNC_CHECK_NO_LOCK 0 202 #define HDSP_SYNC_CHECK_LOCK 1 203 #define HDSP_SYNC_CHECK_SYNC 2 204 205 /* AutoSync references - used by "autosync_ref" control switch */ 206 207 #define HDSP_AUTOSYNC_FROM_WORD 0 208 #define HDSP_AUTOSYNC_FROM_ADAT_SYNC 1 209 #define HDSP_AUTOSYNC_FROM_SPDIF 2 210 #define HDSP_AUTOSYNC_FROM_NONE 3 211 #define HDSP_AUTOSYNC_FROM_ADAT1 4 212 #define HDSP_AUTOSYNC_FROM_ADAT2 5 213 #define HDSP_AUTOSYNC_FROM_ADAT3 6 193 214 194 215 /* Possible sources of S/PDIF input */ … … 238 259 #define HDSP_spdifFrequencyMask (HDSP_spdifFrequency0|HDSP_spdifFrequency1|HDSP_spdifFrequency2) 239 260 240 #define HDSP_spdifFrequency32KHz (HDSP_spdifFrequency0 |HDSP_spdifFrequency1|HDSP_spdifFrequency2)241 #define HDSP_spdifFrequency44_1KHz (HDSP_spdifFrequency 2|HDSP_spdifFrequency1)242 #define HDSP_spdifFrequency48KHz (HDSP_spdifFrequency0|HDSP_spdifFrequency 2)243 244 #define HDSP_spdifFrequency64KHz 0245 #define HDSP_spdifFrequency88_2KHz (HDSP_spdifFrequency 2)246 #define HDSP_spdifFrequency96KHz (HDSP_spdifFrequency 0|HDSP_spdifFrequency1)261 #define HDSP_spdifFrequency32KHz (HDSP_spdifFrequency0) 262 #define HDSP_spdifFrequency44_1KHz (HDSP_spdifFrequency1) 263 #define HDSP_spdifFrequency48KHz (HDSP_spdifFrequency0|HDSP_spdifFrequency1) 264 265 #define HDSP_spdifFrequency64KHz (HDSP_spdifFrequency2) 266 #define HDSP_spdifFrequency88_2KHz (HDSP_spdifFrequency0|HDSP_spdifFrequency2) 267 #define HDSP_spdifFrequency96KHz (HDSP_spdifFrequency2|HDSP_spdifFrequency1) 247 268 248 269 /* Status2 Register bits */ … … 278 299 #define HDSP_SelSyncRef_ADAT_SYNC (HDSP_SelSyncRef0|HDSP_SelSyncRef2) 279 300 280 /* FIFO wait times, defined in terms of loops on readl() */ 281 282 #define HDSP_LONG_WAIT 40000 283 #define HDSP_SHORT_WAIT 100 284 285 /* Computing addresses for adjusting gains */ 286 287 #define INPUT_TO_OUTPUT_KEY(in,out) ((64 * (out)) + (in)) 288 #define PLAYBACK_TO_OUTPUT_KEY(chn,out) ((64 * (out)) + 32 + (chn)) 301 /* Card state flags */ 302 303 #define HDSP_InitializationComplete (1<<0) 304 #define HDSP_FirmwareLoaded (1<<1) 305 #define HDSP_FirmwareCached (1<<2) 306 307 /* FIFO wait times, defined in terms of 1/10ths of msecs */ 308 309 #define HDSP_LONG_WAIT 5000 310 #define HDSP_SHORT_WAIT 30 311 289 312 #define UNITY_GAIN 32768 290 313 #define MINUS_INFINITY_GAIN 0 … … 314 337 #define HDSP_DMA_AREA_KILOBYTES (HDSP_DMA_AREA_BYTES/1024) 315 338 316 #define HDSP_MATRIX_MIXER_SIZE 2048 317 318 typedef struct _hdsp hdsp_t; 319 typedef struct _hdsp_midi hdsp_midi_t; 339 typedef struct _hdsp hdsp_t; 340 typedef struct _hdsp_midi hdsp_midi_t; 320 341 321 342 struct _hdsp_midi { … … 328 349 struct timer_list timer; 329 350 spinlock_t lock; 351 int pending; 330 352 }; 331 353 332 354 struct _hdsp { 333 spinlock_t lock; 334 snd_pcm_substream_t *capture_substream; 335 snd_pcm_substream_t *playback_substream; 336 hdsp_midi_t midi[2]; 337 int precise_ptr; 338 u32 control_register; /* cached value */ 339 u32 creg_spdif; 340 u32 creg_spdif_stream; 341 char *card_name; /* digiface/multiface */ 342 HDSP_Type type; /* ditto, but for code use */ 343 size_t period_bytes; /* guess what this is */ 344 unsigned char ds_channels; 345 unsigned char ss_channels; /* different for multiface/digiface */ 346 void *capture_buffer_unaligned; /* original buffer addresses */ 347 void *playback_buffer_unaligned; /* original buffer addresses */ 348 unsigned char *capture_buffer; /* suitably aligned address */ 349 unsigned char *playback_buffer; /* suitably aligned address */ 350 dma_addr_t capture_buffer_addr; 351 dma_addr_t playback_buffer_addr; 352 pid_t capture_pid; 353 pid_t playback_pid; 354 int running; 355 int passthru; /* non-zero if doing pass-thru */ 356 int last_spdif_sample_rate; /* so that we can catch externally ... */ 357 int last_adat_sample_rate; /* ... induced rate changes */ 358 char *channel_map; 359 int dev; 360 int irq; 361 unsigned long port; 362 struct resource *res_port; 363 unsigned long iobase; 364 snd_card_t *card; 365 snd_pcm_t *pcm; 366 struct pci_dev *pci; 367 snd_info_entry_t *proc_entry; 368 snd_kcontrol_t *spdif_ctl; 369 unsigned short mixer_matrix[HDSP_MATRIX_MIXER_SIZE]; 355 spinlock_t lock; 356 snd_pcm_substream_t *capture_substream; 357 snd_pcm_substream_t *playback_substream; 358 hdsp_midi_t midi[2]; 359 struct tasklet_struct midi_tasklet; 360 int precise_ptr; 361 u32 control_register; /* cached value */ 362 u32 creg_spdif; 363 u32 creg_spdif_stream; 364 char *card_name; /* digiface/multiface */ 365 HDSP_IO_Type io_type; /* ditto, but for code use */ 366 unsigned short firmware_rev; 367 unsigned short state; /* stores state bits */ 368 u32 firmware_cache[24413]; /* this helps recover from accidental iobox power failure */ 369 size_t period_bytes; /* guess what this is */ 370 unsigned char ds_channels; 371 unsigned char ss_channels; /* different for multiface/digiface */ 372 void *capture_buffer_unaligned; /* original buffer addresses */ 373 void *playback_buffer_unaligned; /* original buffer addresses */ 374 unsigned char *capture_buffer; /* suitably aligned address */ 375 unsigned char *playback_buffer; /* suitably aligned address */ 376 dma_addr_t capture_buffer_addr; 377 dma_addr_t playback_buffer_addr; 378 pid_t capture_pid; 379 pid_t playback_pid; 380 int running; 381 int passthru; /* non-zero if doing pass-thru */ 382 int last_spdif_sample_rate;/* for information reporting */ 383 int last_external_sample_rate; 384 int last_internal_sample_rate; 385 int system_sample_rate; 386 char *channel_map; 387 int dev; 388 int irq; 389 unsigned long port; 390 struct resource *res_port; 391 unsigned long iobase; 392 snd_card_t *card; 393 snd_pcm_t *pcm; 394 snd_hwdep_t *hwdep; 395 struct pci_dev *pci; 396 snd_kcontrol_t *spdif_ctl; 397 snd_kcontrol_t *playback_mixer_ctls[HDSP_MAX_CHANNELS]; 398 unsigned short mixer_matrix[HDSP_MATRIX_MIXER_SIZE]; 370 399 }; 371 400 … … 384 413 385 414 static char channel_map_mf_ss[HDSP_MAX_CHANNELS] = { /* Multiface */ 386 /* A DAT 0*/415 /* Analog */ 387 416 0, 1, 2, 3, 4, 5, 6, 7, 388 417 /* ADAT 2 */ … … 410 439 411 440 static struct pci_device_id snd_hdsp_ids[] __devinitdata = { 412 {PCI_VENDOR_ID_XILINX, 413 PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP, 414 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,}, /* RME Hammerfall-DSP */ 415 {0,} 441 { 442 .vendor = PCI_VENDOR_ID_XILINX, 443 .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP, 444 .subvendor = PCI_ANY_ID, 445 .subdevice = PCI_ANY_ID, 446 }, /* RME Hammerfall-DSP */ 447 { 0, }, 416 448 }; 417 449 418 450 MODULE_DEVICE_TABLE(pci, snd_hdsp_ids); 419 451 452 /* prototypes */ 453 static int __devinit snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp); 454 static int __devinit snd_hdsp_create_pcm(snd_card_t *card, hdsp_t *hdsp); 455 static inline int snd_hdsp_initialize_input_enable (hdsp_t *hdsp); 456 static inline void snd_hdsp_initialize_midi_flush (hdsp_t *hdsp); 457 static inline void snd_hdsp_initialize_channels (hdsp_t *hdsp); 458 static inline int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout); 459 static int hdsp_update_simple_mixer_controls(hdsp_t *hdsp); 460 static int hdsp_autosync_ref(hdsp_t *hdsp); 461 static int snd_hdsp_set_defaults(hdsp_t *hdsp); 462 463 static inline int hdsp_is_9652 (hdsp_t *hdsp) 464 { 465 switch (hdsp->firmware_rev) { 466 case 0x64: 467 case 0x65: 468 case 0x68: 469 return 1; 470 default: 471 return 0; 472 } 473 } 474 475 static inline int hdsp_playback_to_output_key (hdsp_t *hdsp, int in, int out) 476 { 477 switch (hdsp->firmware_rev) { 478 case 0xa: 479 return (64 * out) + (32 + (in)); 480 default: 481 return (52 * out) + (26 + (in)); 482 } 483 } 484 485 static inline int hdsp_input_to_output_key (hdsp_t *hdsp, int in, int out) 486 { 487 switch (hdsp->firmware_rev) { 488 case 0xa: 489 return (64 * out) + in; 490 default: 491 return (52 * out) + in; 492 } 493 } 494 420 495 static inline void hdsp_write(hdsp_t *hdsp, int reg, int val) 421 496 { … … 426 501 { 427 502 return readl (hdsp->iobase + reg); 428 }429 430 static inline unsigned long long hdsp_read64 (hdsp_t *hdsp, int reg)431 {432 unsigned long long val;433 val = hdsp_read(hdsp, reg);434 val = (val<<32)|hdsp_read(hdsp, reg + 4);435 436 return val;437 503 } 438 504 … … 441 507 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_ConfigError) { 442 508 snd_printk ("Hammerfall-DSP: no Digiface or Multiface connected!\n"); 509 hdsp->state &= ~HDSP_FirmwareLoaded; 443 510 return -EIO; 444 511 } 445 512 return 0; 446 513 } 514 515 static int snd_hdsp_load_firmware_from_cache(hdsp_t *hdsp) { 516 517 int i; 518 unsigned long flags; 519 520 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { 521 522 snd_printk ("loading firmware\n"); 523 524 hdsp_write (hdsp, HDSP_jtagReg, HDSP_S_PROGRAM); 525 hdsp_write (hdsp, HDSP_fifoData, 0); 526 527 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { 528 snd_printk ("timeout waiting for download preparation\n"); 529 return -EIO; 530 } 531 532 hdsp_write (hdsp, HDSP_jtagReg, HDSP_S_LOAD); 533 534 for (i = 0; i < 24413; ++i) { 535 hdsp_write(hdsp, HDSP_fifoData, hdsp->firmware_cache[i]); 536 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) { 537 snd_printk ("timeout during firmware loading\n"); 538 return -EIO; 539 } 540 } 541 542 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { 543 snd_printk ("timeout at end of firmware loading\n"); 544 return -EIO; 545 } 546 547 hdsp_write (hdsp, HDSP_jtagReg, 0); 548 snd_printk ("finished firmware loading\n"); 549 550 if ((1000 / HZ) < 3000) { 551 set_current_state(TASK_UNINTERRUPTIBLE); 552 schedule_timeout((3000 * HZ + 999) / 1000); 553 } else { 554 mdelay(3000); 555 } 556 } 557 if (hdsp->state & HDSP_InitializationComplete) { 558 snd_printk("firmware loaded from cache, restoring defaults\n"); 559 spin_lock_irqsave(&hdsp->lock, flags); 560 snd_hdsp_set_defaults(hdsp); 561 spin_unlock_irqrestore(&hdsp->lock, flags); 562 } 563 564 hdsp->state |= HDSP_FirmwareLoaded; 565 566 return 0; 567 } 568 569 static inline int hdsp_get_iobox_version (hdsp_t *hdsp) 570 { 571 int err; 572 573 if (hdsp_check_for_iobox (hdsp)) { 574 return -EIO; 575 } 576 577 if ((err = snd_hdsp_initialize_input_enable(hdsp)) < 0) { 578 return err; 579 } 580 581 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { 582 583 hdsp_write (hdsp, HDSP_jtagReg, HDSP_PROGRAM); 584 hdsp_write (hdsp, HDSP_fifoData, 0); 585 if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT) < 0) { 586 return -EIO; 587 } 588 589 hdsp_write (hdsp, HDSP_jtagReg, HDSP_S_LOAD); 590 hdsp_write (hdsp, HDSP_fifoData, 0); 591 592 if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT)) { 593 hdsp->io_type = Multiface; 594 hdsp_write (hdsp, HDSP_jtagReg, HDSP_VERSION_BIT); 595 hdsp_write (hdsp, HDSP_jtagReg, HDSP_S_LOAD); 596 hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT); 597 } else { 598 hdsp->io_type = Digiface; 599 } 600 } else { 601 /* firmware was already loaded, get iobox type */ 602 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) { 603 hdsp->io_type = Multiface; 604 } else { 605 hdsp->io_type = Digiface; 606 } 607 } 608 return 0; 609 } 610 611 612 static inline int hdsp_check_for_firmware (hdsp_t *hdsp) 613 { 614 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { 615 snd_printk("firmware not present.\n"); 616 hdsp->state &= ~HDSP_FirmwareLoaded; 617 return -EIO; 618 } 619 return 0; 620 } 621 447 622 448 623 static inline int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout) … … 454 629 */ 455 630 456 for (i = 0; i < timeout; i++) 631 for (i = 0; i < timeout; i++) { 632 457 633 if ((int)(hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count) 458 634 return 0; 635 636 /* not very friendly, but we only do this during a firmware 637 load and changing the mixer, so we just put up with it. 638 */ 639 640 udelay (100); 641 } 459 642 460 643 snd_printk ("wait for FIFO status <= %d failed after %d iterations\n", … … 475 658 unsigned int ad; 476 659 477 if (addr >= HDSP_MATRIX_MIXER_SIZE) 478 return -1; 479 480 ad = data + addr * 65536; 481 482 if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT)) { 483 return -1; 484 } 485 hdsp_write (hdsp, HDSP_fifoData, ad); 486 hdsp->mixer_matrix[addr] = data; 660 if (hdsp_is_9652 (hdsp)) { 661 662 if ((ad = addr/2) < 676) { 663 664 /* from martin björnsen: 665 666 "You can only write dwords to the 667 mixer memory which contain two 668 mixer values in the low and high 669 word. So if you want to change 670 value 0 you have to read value 1 671 from the cache and write both to 672 the first dword in the mixer 673 memory." 674 */ 675 676 hdsp->mixer_matrix[addr] = data; 677 hdsp_write (hdsp, 1024 + ad, 678 (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) + 679 hdsp->mixer_matrix[addr&0x7fe]); 680 return 0; 681 } else { 682 return -1; 683 } 684 685 686 } else { 687 if (addr >= HDSP_MATRIX_MIXER_SIZE) 688 return -1; 689 690 ad = (addr << 16) + data; 691 692 if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT)) { 693 return -1; 694 } 695 696 hdsp_write (hdsp, HDSP_fifoData, ad); 697 hdsp->mixer_matrix[addr] = data; 698 699 } 487 700 488 701 return 0; … … 503 716 } 504 717 505 static inline int hdsp_ system_sample_rate (hdsp_t *hdsp)718 static inline int hdsp_external_sample_rate (hdsp_t *hdsp) 506 719 { 507 720 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); … … 515 728 case HDSP_systemFrequency88_2: return 88200; 516 729 case HDSP_systemFrequency96: return 96000; 517 default: return 0; 730 default: 731 return 0; 518 732 } 519 733 } … … 527 741 return 0; 528 742 } 529 743 530 744 switch (rate_bits) { 531 745 case HDSP_spdifFrequency32KHz: return 32000; … … 536 750 case HDSP_spdifFrequency96KHz: return 96000; 537 751 default: 538 snd_printk ("unknown frequency status; bits = 0x%x, status = 0x%x", rate_bits, status);752 snd_printk ("unknown spdif frequency status; bits = 0x%x, status = 0x%x\n", rate_bits, status); 539 753 return 0; 540 754 } … … 565 779 static inline void hdsp_reset_hw_pointer(hdsp_t *hdsp) 566 780 { 567 #if 0 568 /* reset the hw pointer to zero. We do this by writing to 8 569 registers, each of which is a 32bit wide register, and set 570 them all to zero. 571 */ 572 573 for (i = 0; i < 8; ++i) { 574 hdsp_write(hdsp, i, 0); 575 udelay(10); 576 } 577 #endif 781 hdsp_write (hdsp, HDSP_resetPointer, 0); 578 782 } 579 783 … … 620 824 } 621 825 622 static int hdsp_set_rate(hdsp_t *hdsp, int rate )826 static int hdsp_set_rate(hdsp_t *hdsp, int rate, int called_internally) 623 827 { 624 828 int reject_if_open = 0; 625 829 int current_rate; 626 627 if (!(hdsp->control_register & HDSP_ClockModeMaster)) { 628 snd_printk ("device is not running as a clock master: cannot set sample rate.\n"); 629 return -1; 630 } 830 int rate_bits; 831 832 if (!(hdsp->control_register & HDSP_ClockModeMaster)) { 833 if (called_internally) { 834 /* request from ctl or card initialization */ 835 snd_printk("device is not running as a clock master: cannot set sample rate.\n"); 836 return -1; 837 } else { 838 /* hw_param request while in AutoSync mode */ 839 int external_freq = hdsp_external_sample_rate(hdsp); 840 int spdif_freq = hdsp_spdif_sample_rate(hdsp); 841 842 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) { 843 snd_printk("Detected ADAT in double speed mode\n"); 844 } else if (rate != external_freq) { 845 snd_printk("No AutoSync source for requested rate\n"); 846 return -1; 847 } 848 } 849 } 850 851 current_rate = hdsp->system_sample_rate; 631 852 632 853 /* Changing from a "single speed" to a "double speed" rate is … … 638 859 Note that a similar but essentially insoluble problem 639 860 exists for externally-driven rate changes. All we can do 640 is to flag rate changes in the read/write routines. 641 */ 861 is to flag rate changes in the read/write routines. */ 642 862 643 863 spin_lock_irq(&hdsp->lock); 644 current_rate = hdsp_system_sample_rate(hdsp);645 864 646 865 switch (rate) { … … 649 868 reject_if_open = 1; 650 869 } 651 rate = HDSP_Frequency32KHz;870 rate_bits = HDSP_Frequency32KHz; 652 871 break; 653 872 case 44100: … … 655 874 reject_if_open = 1; 656 875 } 657 rate = HDSP_Frequency44_1KHz;876 rate_bits = HDSP_Frequency44_1KHz; 658 877 break; 659 878 case 48000: … … 661 880 reject_if_open = 1; 662 881 } 663 rate = HDSP_Frequency48KHz;882 rate_bits = HDSP_Frequency48KHz; 664 883 break; 665 884 case 64000: 666 if (current_rate < 48000) {885 if (current_rate <= 48000) { 667 886 reject_if_open = 1; 668 887 } 669 rate = HDSP_Frequency64KHz;888 rate_bits = HDSP_Frequency64KHz; 670 889 break; 671 890 case 88200: 672 if (current_rate < 48000) {891 if (current_rate <= 48000) { 673 892 reject_if_open = 1; 674 893 } 675 rate = HDSP_Frequency88_2KHz;894 rate_bits = HDSP_Frequency88_2KHz; 676 895 break; 677 896 case 96000: 678 if (current_rate < 48000) {897 if (current_rate <= 48000) { 679 898 reject_if_open = 1; 680 899 } 681 rate = HDSP_Frequency96KHz;900 rate_bits = HDSP_Frequency96KHz; 682 901 break; 683 902 default: 903 spin_unlock_irq(&hdsp->lock); 684 904 return -EINVAL; 685 905 } … … 694 914 695 915 hdsp->control_register &= ~HDSP_FrequencyMask; 696 hdsp->control_register |= rate ;916 hdsp->control_register |= rate_bits; 697 917 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 698 918 … … 700 920 hdsp->channel_map = channel_map_ds; 701 921 } else { 702 switch (hdsp-> type) {922 switch (hdsp->io_type) { 703 923 case Multiface: 704 924 hdsp->channel_map = channel_map_mf_ss; … … 707 927 hdsp->channel_map = channel_map_df_ss; 708 928 break; 709 } 929 default: 930 /* should never happen */ 931 break; 932 } 933 } 934 935 hdsp->system_sample_rate = rate; 936 937 if (reject_if_open) { 938 hdsp_update_simple_mixer_controls (hdsp); 710 939 } 711 940 … … 727 956 if (enable) { 728 957 for (i = 0; i < 26; i++) { 729 hdsp_write_gain (hdsp, INPUT_TO_OUTPUT_KEY(i,i), UNITY_GAIN);958 hdsp_write_gain (hdsp, hdsp_input_to_output_key(hdsp,i,i), UNITY_GAIN); 730 959 } 731 960 } else { 732 961 for (i = 0; i < 26; i++) { 733 hdsp_write_gain (hdsp, INPUT_TO_OUTPUT_KEY(i,i), MINUS_INFINITY_GAIN);962 hdsp_write_gain (hdsp, hdsp_input_to_output_key(hdsp,i,i), MINUS_INFINITY_GAIN); 734 963 } 735 964 } … … 742 971 mapped_channel = hdsp->channel_map[channel]; 743 972 973 snd_assert(mapped_channel > -1, return); 974 744 975 if (enable) { 745 hdsp_write_gain (hdsp, INPUT_TO_OUTPUT_KEY(channel,channel), UNITY_GAIN);976 hdsp_write_gain (hdsp, hdsp_input_to_output_key(hdsp,mapped_channel,mapped_channel), UNITY_GAIN); 746 977 } else { 747 hdsp_write_gain (hdsp, INPUT_TO_OUTPUT_KEY(channel,channel), MINUS_INFINITY_GAIN);978 hdsp_write_gain (hdsp, hdsp_input_to_output_key(hdsp,mapped_channel,mapped_channel), MINUS_INFINITY_GAIN); 748 979 } 749 980 } … … 809 1040 static inline int snd_hdsp_midi_output_possible (hdsp_t *hdsp, int id) 810 1041 { 1042 int fifo_bytes_used; 1043 811 1044 if (id) { 812 return (hdsp_read(hdsp, HDSP_midiStatusOut1) & 0xff) < 128;1045 fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut1) & 0xff; 813 1046 } else { 814 return (hdsp_read(hdsp, HDSP_midiStatusOut0) & 0xff)< 128; 1047 fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut0) & 0xff; 1048 } 1049 1050 if (fifo_bytes_used < 128) { 1051 return 128 - fifo_bytes_used; 1052 } else { 1053 return 0; 815 1054 } 816 1055 } … … 827 1066 unsigned long flags; 828 1067 int n_pending; 829 int clear_timer = 0;830 1068 int to_write; 831 1069 int i; … … 835 1073 836 1074 spin_lock_irqsave (&hmidi->lock, flags); 837 838 1075 if (hmidi->output) { 839 1076 if (!snd_rawmidi_transmit_empty (hmidi->output)) { … … 845 1082 for (i = 0; i < to_write; ++i) 846 1083 snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]); 847 } else {848 clear_timer = 1;849 1084 } 850 1085 } 851 } else { 852 clear_timer = 1; 853 } 854 855 if (clear_timer && hmidi->istimer && --hmidi->istimer <= 0) { 856 del_timer(&hmidi->timer); 857 } 858 } 859 1086 } 1087 } 860 1088 spin_unlock_irqrestore (&hmidi->lock, flags); 861 1089 return 0; … … 870 1098 871 1099 spin_lock_irqsave (&hmidi->lock, flags); 872 873 1100 if ((n_pending = snd_hdsp_midi_input_available (hmidi->hdsp, hmidi->id)) > 0) { 874 1101 if (hmidi->input) { … … 888 1115 } 889 1116 } 890 } 1117 } 1118 hmidi->pending = 0; 1119 if (hmidi->id) { 1120 hmidi->hdsp->control_register |= HDSP_Midi1InterruptEnable; 1121 } else { 1122 hmidi->hdsp->control_register |= HDSP_Midi0InterruptEnable; 1123 } 1124 hdsp_write(hmidi->hdsp, HDSP_controlRegister, hmidi->hdsp->control_register); 891 1125 spin_unlock_irqrestore (&hmidi->lock, flags); 892 1126 return snd_hdsp_midi_output_write (hmidi); … … 963 1197 } 964 1198 spin_unlock_irqrestore (&hmidi->lock, flags); 1199 if (up) 1200 snd_hdsp_midi_output_write(hmidi); 965 1201 } 966 1202 … … 1046 1282 hdsp->midi[id].hdsp = hdsp; 1047 1283 hdsp->midi[id].istimer = 0; 1284 hdsp->midi[id].pending = 0; 1048 1285 spin_lock_init (&hdsp->midi[id].lock); 1049 1286 … … 1168 1405 1169 1406 #define HDSP_SPDIF_IN(xname, xindex) \ 1170 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = xname, .index = xindex, \ 1407 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, \ 1408 .name = xname, \ 1409 .index = xindex, \ 1171 1410 .info = snd_hdsp_info_spdif_in, \ 1172 .get = snd_hdsp_get_spdif_in, .put = snd_hdsp_put_spdif_in } 1411 .get = snd_hdsp_get_spdif_in, \ 1412 .put = snd_hdsp_put_spdif_in } 1173 1413 1174 1414 static unsigned int hdsp_spdif_in(hdsp_t *hdsp) … … 1201 1441 { 1202 1442 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1203 unsigned long flags; 1204 1205 spin_lock_irqsave(&hdsp->lock, flags); 1443 1206 1444 ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp); 1207 spin_unlock_irqrestore(&hdsp->lock, flags);1208 1445 return 0; 1209 1446 } … … 1228 1465 1229 1466 #define HDSP_SPDIF_OUT(xname, xindex) \ 1230 { .iface = SNDRV_CTL_ELEM_IFACE_ PCM, .name = xname, .index = xindex, \1231 .info = snd_hdsp_info_spdif_ out, \1467 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \ 1468 .info = snd_hdsp_info_spdif_bits, \ 1232 1469 .get = snd_hdsp_get_spdif_out, .put = snd_hdsp_put_spdif_out } 1233 1470 … … 1248 1485 } 1249 1486 1250 static int snd_hdsp_info_spdif_ out(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)1487 static int snd_hdsp_info_spdif_bits(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1251 1488 { 1252 1489 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; … … 1260 1497 { 1261 1498 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1262 unsigned long flags; 1263 1264 spin_lock_irqsave(&hdsp->lock, flags); 1499 1265 1500 ucontrol->value.integer.value[0] = hdsp_spdif_out(hdsp); 1266 spin_unlock_irqrestore(&hdsp->lock, flags);1267 1501 return 0; 1268 1502 } … … 1285 1519 } 1286 1520 1287 #define HDSP_SYNC_PREF(xname, xindex) \ 1288 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = xname, .index = xindex, \ 1289 .info = snd_hdsp_info_sync_pref, \ 1290 .get = snd_hdsp_get_sync_pref, .put = snd_hdsp_put_sync_pref } 1291 1292 static int hdsp_sync_pref(hdsp_t *hdsp) 1521 #define HDSP_SPDIF_PROFESSIONAL(xname, xindex) \ 1522 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \ 1523 .info = snd_hdsp_info_spdif_bits, \ 1524 .get = snd_hdsp_get_spdif_professional, .put = snd_hdsp_put_spdif_professional } 1525 1526 static int hdsp_spdif_professional(hdsp_t *hdsp) 1527 { 1528 return (hdsp->control_register & HDSP_SPDIFProfessional) ? 1 : 0; 1529 } 1530 1531 static int hdsp_set_spdif_professional(hdsp_t *hdsp, int val) 1532 { 1533 if (val) { 1534 hdsp->control_register |= HDSP_SPDIFProfessional; 1535 } else { 1536 hdsp->control_register &= ~HDSP_SPDIFProfessional; 1537 } 1538 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 1539 return 0; 1540 } 1541 1542 static int snd_hdsp_get_spdif_professional(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1543 { 1544 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1545 1546 ucontrol->value.integer.value[0] = hdsp_spdif_professional(hdsp); 1547 return 0; 1548 } 1549 1550 static int snd_hdsp_put_spdif_professional(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1551 { 1552 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1553 unsigned long flags; 1554 int change; 1555 unsigned int val; 1556 1557 if (!snd_hdsp_use_is_exclusive(hdsp)) 1558 return -EBUSY; 1559 val = ucontrol->value.integer.value[0] & 1; 1560 spin_lock_irqsave(&hdsp->lock, flags); 1561 change = (int)val != hdsp_spdif_professional(hdsp); 1562 hdsp_set_spdif_professional(hdsp, val); 1563 spin_unlock_irqrestore(&hdsp->lock, flags); 1564 return change; 1565 } 1566 1567 #define HDSP_SPDIF_EMPHASIS(xname, xindex) \ 1568 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \ 1569 .info = snd_hdsp_info_spdif_bits, \ 1570 .get = snd_hdsp_get_spdif_emphasis, .put = snd_hdsp_put_spdif_emphasis } 1571 1572 static int hdsp_spdif_emphasis(hdsp_t *hdsp) 1573 { 1574 return (hdsp->control_register & HDSP_SPDIFEmphasis) ? 1 : 0; 1575 } 1576 1577 static int hdsp_set_spdif_emphasis(hdsp_t *hdsp, int val) 1578 { 1579 if (val) { 1580 hdsp->control_register |= HDSP_SPDIFEmphasis; 1581 } else { 1582 hdsp->control_register &= ~HDSP_SPDIFEmphasis; 1583 } 1584 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 1585 return 0; 1586 } 1587 1588 static int snd_hdsp_get_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1589 { 1590 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1591 1592 ucontrol->value.integer.value[0] = hdsp_spdif_emphasis(hdsp); 1593 return 0; 1594 } 1595 1596 static int snd_hdsp_put_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1597 { 1598 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1599 unsigned long flags; 1600 int change; 1601 unsigned int val; 1602 1603 if (!snd_hdsp_use_is_exclusive(hdsp)) 1604 return -EBUSY; 1605 val = ucontrol->value.integer.value[0] & 1; 1606 spin_lock_irqsave(&hdsp->lock, flags); 1607 change = (int)val != hdsp_spdif_emphasis(hdsp); 1608 hdsp_set_spdif_emphasis(hdsp, val); 1609 spin_unlock_irqrestore(&hdsp->lock, flags); 1610 return change; 1611 } 1612 1613 #define HDSP_SPDIF_NON_AUDIO(xname, xindex) \ 1614 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \ 1615 .info = snd_hdsp_info_spdif_bits, \ 1616 .get = snd_hdsp_get_spdif_nonaudio, .put = snd_hdsp_put_spdif_nonaudio } 1617 1618 static int hdsp_spdif_nonaudio(hdsp_t *hdsp) 1619 { 1620 return (hdsp->control_register & HDSP_SPDIFNonAudio) ? 1 : 0; 1621 } 1622 1623 static int hdsp_set_spdif_nonaudio(hdsp_t *hdsp, int val) 1624 { 1625 if (val) { 1626 hdsp->control_register |= HDSP_SPDIFNonAudio; 1627 } else { 1628 hdsp->control_register &= ~HDSP_SPDIFNonAudio; 1629 } 1630 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 1631 return 0; 1632 } 1633 1634 static int snd_hdsp_get_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1635 { 1636 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1637 1638 ucontrol->value.integer.value[0] = hdsp_spdif_nonaudio(hdsp); 1639 return 0; 1640 } 1641 1642 static int snd_hdsp_put_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1643 { 1644 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1645 unsigned long flags; 1646 int change; 1647 unsigned int val; 1648 1649 if (!snd_hdsp_use_is_exclusive(hdsp)) 1650 return -EBUSY; 1651 val = ucontrol->value.integer.value[0] & 1; 1652 spin_lock_irqsave(&hdsp->lock, flags); 1653 change = (int)val != hdsp_spdif_nonaudio(hdsp); 1654 hdsp_set_spdif_nonaudio(hdsp, val); 1655 spin_unlock_irqrestore(&hdsp->lock, flags); 1656 return change; 1657 } 1658 1659 #define HDSP_SPDIF_SAMPLE_RATE(xname, xindex) \ 1660 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 1661 .name = xname, \ 1662 .index = xindex, \ 1663 .access = SNDRV_CTL_ELEM_ACCESS_READ, \ 1664 .info = snd_hdsp_info_spdif_sample_rate, \ 1665 .get = snd_hdsp_get_spdif_sample_rate \ 1666 } 1667 1668 static int snd_hdsp_info_spdif_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1669 { 1670 static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None"}; 1671 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1672 uinfo->count = 1; 1673 uinfo->value.enumerated.items = 7 ; 1674 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1675 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1676 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1677 return 0; 1678 } 1679 1680 static int snd_hdsp_get_spdif_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1681 { 1682 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1683 1684 switch (hdsp_spdif_sample_rate(hdsp)) { 1685 case 32000: 1686 ucontrol->value.enumerated.item[0] = 0; 1687 break; 1688 case 44100: 1689 ucontrol->value.enumerated.item[0] = 1; 1690 break; 1691 case 48000: 1692 ucontrol->value.enumerated.item[0] = 2; 1693 break; 1694 case 64000: 1695 ucontrol->value.enumerated.item[0] = 3; 1696 break; 1697 case 88200: 1698 ucontrol->value.enumerated.item[0] = 4; 1699 break; 1700 case 96000: 1701 ucontrol->value.enumerated.item[0] = 5; 1702 break; 1703 default: 1704 ucontrol->value.enumerated.item[0] = 6; 1705 } 1706 return 0; 1707 } 1708 1709 #define HDSP_SYSTEM_SAMPLE_RATE(xname, xindex) \ 1710 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 1711 .name = xname, \ 1712 .index = xindex, \ 1713 .access = SNDRV_CTL_ELEM_ACCESS_READ, \ 1714 .info = snd_hdsp_info_system_sample_rate, \ 1715 .get = snd_hdsp_get_system_sample_rate \ 1716 } 1717 1718 static int snd_hdsp_info_system_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1719 { 1720 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1721 uinfo->count = 1; 1722 return 0; 1723 } 1724 1725 static int snd_hdsp_get_system_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1726 { 1727 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1728 1729 ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate; 1730 return 0; 1731 } 1732 1733 #define HDSP_AUTOSYNC_SAMPLE_RATE(xname, xindex) \ 1734 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, \ 1735 .name = xname, \ 1736 .index = xindex, \ 1737 .access = SNDRV_CTL_ELEM_ACCESS_READ, \ 1738 .info = snd_hdsp_info_autosync_sample_rate, \ 1739 .get = snd_hdsp_get_autosync_sample_rate \ 1740 } 1741 1742 static int snd_hdsp_info_autosync_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1743 { 1744 static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None"}; 1745 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1746 uinfo->count = 1; 1747 uinfo->value.enumerated.items = 7 ; 1748 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1749 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1750 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1751 return 0; 1752 } 1753 1754 static int snd_hdsp_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1755 { 1756 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1757 1758 switch (hdsp_external_sample_rate(hdsp)) { 1759 case 32000: 1760 ucontrol->value.enumerated.item[0] = 0; 1761 break; 1762 case 44100: 1763 ucontrol->value.enumerated.item[0] = 1; 1764 break; 1765 case 48000: 1766 ucontrol->value.enumerated.item[0] = 2; 1767 break; 1768 case 64000: 1769 ucontrol->value.enumerated.item[0] = 3; 1770 break; 1771 case 88200: 1772 ucontrol->value.enumerated.item[0] = 4; 1773 break; 1774 case 96000: 1775 ucontrol->value.enumerated.item[0] = 5; 1776 break; 1777 default: 1778 ucontrol->value.enumerated.item[0] = 6; 1779 } 1780 return 0; 1781 } 1782 1783 #define HDSP_SYSTEM_CLOCK_MODE(xname, xindex) \ 1784 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 1785 .name = xname, \ 1786 .index = xindex, \ 1787 .access = SNDRV_CTL_ELEM_ACCESS_READ, \ 1788 .info = snd_hdsp_info_system_clock_mode, \ 1789 .get = snd_hdsp_get_system_clock_mode \ 1790 } 1791 1792 static int hdsp_system_clock_mode(hdsp_t *hdsp) 1793 { 1794 if (hdsp->control_register & HDSP_ClockModeMaster) { 1795 return 0; 1796 } else if (hdsp_external_sample_rate(hdsp) != hdsp->system_sample_rate) { 1797 return 0; 1798 } 1799 return 1; 1800 } 1801 1802 static int snd_hdsp_info_system_clock_mode(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1803 { 1804 static char *texts[] = {"Master", "Slave" }; 1805 1806 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1807 uinfo->count = 1; 1808 uinfo->value.enumerated.items = 2; 1809 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1810 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1811 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1812 return 0; 1813 } 1814 1815 static int snd_hdsp_get_system_clock_mode(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1816 { 1817 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1818 1819 ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp); 1820 return 0; 1821 } 1822 1823 #define HDSP_CLOCK_SOURCE(xname, xindex) \ 1824 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, \ 1825 .name = xname, \ 1826 .index = xindex, \ 1827 .info = snd_hdsp_info_clock_source, \ 1828 .get = snd_hdsp_get_clock_source, \ 1829 .put = snd_hdsp_put_clock_source \ 1830 } 1831 1832 static int hdsp_clock_source(hdsp_t *hdsp) 1833 { 1834 if (hdsp->control_register & HDSP_ClockModeMaster) { 1835 switch (hdsp->system_sample_rate) { 1836 case 32000: 1837 return 1; 1838 case 44100: 1839 return 2; 1840 case 48000: 1841 return 3; 1842 case 64000: 1843 return 4; 1844 case 88200: 1845 return 5; 1846 case 96000: 1847 return 6; 1848 default: 1849 return 3; 1850 } 1851 } else { 1852 return 0; 1853 } 1854 } 1855 1856 static int hdsp_set_clock_source(hdsp_t *hdsp, int mode) 1857 { 1858 int rate; 1859 switch (mode) { 1860 case HDSP_CLOCK_SOURCE_AUTOSYNC: 1861 if (hdsp_external_sample_rate(hdsp) != 0) { 1862 hdsp->control_register &= ~HDSP_ClockModeMaster; 1863 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 1864 return 0; 1865 } 1866 return -1; 1867 case HDSP_CLOCK_SOURCE_INTERNAL_32KHZ: 1868 rate = 32000; 1869 break; 1870 case HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ: 1871 rate = 44100; 1872 break; 1873 case HDSP_CLOCK_SOURCE_INTERNAL_48KHZ: 1874 rate = 48000; 1875 break; 1876 case HDSP_CLOCK_SOURCE_INTERNAL_64KHZ: 1877 rate = 64000; 1878 break; 1879 case HDSP_CLOCK_SOURCE_INTERNAL_88_2KHZ: 1880 rate = 88200; 1881 break; 1882 case HDSP_CLOCK_SOURCE_INTERNAL_96KHZ: 1883 rate = 96000; 1884 break; 1885 default: 1886 rate = 48000; 1887 } 1888 hdsp->control_register |= HDSP_ClockModeMaster; 1889 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 1890 hdsp_set_rate(hdsp, rate, 1); 1891 return 0; 1892 } 1893 1894 static int snd_hdsp_info_clock_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1895 { 1896 static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz" }; 1897 1898 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1899 uinfo->count = 1; 1900 uinfo->value.enumerated.items = 7; 1901 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1902 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 1903 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1904 return 0; 1905 } 1906 1907 static int snd_hdsp_get_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1908 { 1909 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1910 1911 ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp); 1912 return 0; 1913 } 1914 1915 static int snd_hdsp_put_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1916 { 1917 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1918 unsigned long flags; 1919 int change; 1920 int val; 1921 1922 if (!snd_hdsp_use_is_exclusive(hdsp)) 1923 return -EBUSY; 1924 val = ucontrol->value.enumerated.item[0]; 1925 if (val < 0) val = 0; 1926 if (val > 6) val = 6; 1927 spin_lock_irqsave(&hdsp->lock, flags); 1928 if (val != hdsp_clock_source(hdsp)) { 1929 change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0; 1930 } else { 1931 change = 0; 1932 } 1933 spin_unlock_irqrestore(&hdsp->lock, flags); 1934 return change; 1935 } 1936 1937 #define HDSP_PREF_SYNC_REF(xname, xindex) \ 1938 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 1939 .name = xname, \ 1940 .index = xindex, \ 1941 .info = snd_hdsp_info_pref_sync_ref, \ 1942 .get = snd_hdsp_get_pref_sync_ref, \ 1943 .put = snd_hdsp_put_pref_sync_ref \ 1944 } 1945 1946 static int hdsp_pref_sync_ref(hdsp_t *hdsp) 1293 1947 { 1294 1948 /* Notice that this looks at the requested sync source, 1295 1949 not the one actually in use. 1296 1950 */ 1297 1298 if (hdsp->control_register & HDSP_ClockModeMaster) {1299 return HDSP_SYNC_FROM_SELF;1300 }1301 1951 1302 1952 switch (hdsp->control_register & HDSP_SyncRefMask) { … … 1314 1964 return HDSP_SYNC_FROM_ADAT_SYNC; 1315 1965 default: 1316 return HDSP_SYNC_FROM_ SELF;1317 } 1318 return 0; 1319 } 1320 1321 static int hdsp_set_ sync_pref(hdsp_t *hdsp, int pref)1966 return HDSP_SYNC_FROM_WORD; 1967 } 1968 return 0; 1969 } 1970 1971 static int hdsp_set_pref_sync_ref(hdsp_t *hdsp, int pref) 1322 1972 { 1323 1973 hdsp->control_register &= ~HDSP_SyncRefMask; 1324 1974 switch (pref) { 1325 1975 case HDSP_SYNC_FROM_ADAT1: 1326 hdsp->control_register &= ~HDSP_ClockModeMaster;1327 1976 hdsp->control_register &= ~HDSP_SyncRefMask; /* clear SyncRef bits */ 1328 1977 break; 1329 1978 case HDSP_SYNC_FROM_ADAT2: 1330 hdsp->control_register &= ~HDSP_ClockModeMaster;1331 1979 hdsp->control_register |= HDSP_SyncRef_ADAT2; 1332 1980 break; 1333 1981 case HDSP_SYNC_FROM_ADAT3: 1334 hdsp->control_register &= ~HDSP_ClockModeMaster;1335 1982 hdsp->control_register |= HDSP_SyncRef_ADAT3; 1336 1983 break; 1337 1984 case HDSP_SYNC_FROM_SPDIF: 1338 hdsp->control_register &= ~HDSP_ClockModeMaster;1339 1985 hdsp->control_register |= HDSP_SyncRef_SPDIF; 1340 1986 break; 1341 1987 case HDSP_SYNC_FROM_WORD: 1342 hdsp->control_register &= ~HDSP_ClockModeMaster;1343 1988 hdsp->control_register |= HDSP_SyncRef_WORD; 1344 1989 break; 1345 1990 case HDSP_SYNC_FROM_ADAT_SYNC: 1346 hdsp->control_register &= ~HDSP_ClockModeMaster;1347 1991 hdsp->control_register |= HDSP_SyncRef_ADAT_SYNC; 1348 break;1349 case HDSP_SYNC_FROM_SELF:1350 hdsp->control_register |= HDSP_ClockModeMaster;1351 1992 break; 1352 1993 default: … … 1357 1998 } 1358 1999 1359 static int snd_hdsp_info_ sync_pref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)1360 { 1361 static char *texts[] = {" Internal", "Word", "ADAT Sync", "IEC958", "ADAT1", "ADAT2", "ADAT3" };2000 static int snd_hdsp_info_pref_sync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 2001 { 2002 static char *texts[] = {"Word", "ADAT Sync", "IEC958", "ADAT1", "ADAT2", "ADAT3" }; 1362 2003 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1363 2004 1364 2005 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1365 2006 uinfo->count = 1; 1366 uinfo->value.enumerated.items = (hdsp-> type == Digiface) ? 7 : 6;2007 uinfo->value.enumerated.items = (hdsp->io_type == Digiface) ? 6 : 4; 1367 2008 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 1368 2009 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; … … 1371 2012 } 1372 2013 1373 static int snd_hdsp_get_ sync_pref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)2014 static int snd_hdsp_get_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1374 2015 { 1375 2016 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1376 unsigned long flags; 1377 1378 spin_lock_irqsave(&hdsp->lock, flags); 1379 ucontrol->value.enumerated.item[0] = hdsp_sync_pref(hdsp); 1380 spin_unlock_irqrestore(&hdsp->lock, flags); 1381 return 0; 1382 } 1383 1384 static int snd_hdsp_put_sync_pref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 2017 2018 ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp); 2019 return 0; 2020 } 2021 2022 static int snd_hdsp_put_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1385 2023 { 1386 2024 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); … … 1391 2029 if (!snd_hdsp_use_is_exclusive(hdsp)) 1392 2030 return -EBUSY; 1393 max = hdsp->ss_channels == (hdsp->type == Digiface) ? 7 : 6;2031 max = (hdsp->io_type == Digiface) ? 6 : 4; 1394 2032 val = ucontrol->value.enumerated.item[0] % max; 1395 2033 spin_lock_irqsave(&hdsp->lock, flags); 1396 change = (int)val != hdsp_ sync_pref(hdsp);1397 hdsp_set_ sync_pref(hdsp, val);2034 change = (int)val != hdsp_pref_sync_ref(hdsp); 2035 hdsp_set_pref_sync_ref(hdsp, val); 1398 2036 spin_unlock_irqrestore(&hdsp->lock, flags); 1399 2037 return change; 1400 2038 } 1401 2039 2040 #define HDSP_AUTOSYNC_REF(xname, xindex) \ 2041 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 2042 .name = xname, \ 2043 .index = xindex, \ 2044 .access = SNDRV_CTL_ELEM_ACCESS_READ, \ 2045 .info = snd_hdsp_info_autosync_ref, \ 2046 .get = snd_hdsp_get_autosync_ref, \ 2047 } 2048 2049 static int hdsp_autosync_ref(hdsp_t *hdsp) 2050 { 2051 /* This looks at the autosync selected sync reference */ 2052 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); 2053 2054 switch (status2 & HDSP_SelSyncRefMask) { 2055 case HDSP_SelSyncRef_WORD: 2056 return HDSP_AUTOSYNC_FROM_WORD; 2057 case HDSP_SelSyncRef_ADAT_SYNC: 2058 return HDSP_AUTOSYNC_FROM_ADAT_SYNC; 2059 case HDSP_SelSyncRef_SPDIF: 2060 return HDSP_AUTOSYNC_FROM_SPDIF; 2061 case HDSP_SelSyncRefMask: 2062 return HDSP_AUTOSYNC_FROM_NONE; 2063 case HDSP_SelSyncRef_ADAT1: 2064 return HDSP_AUTOSYNC_FROM_ADAT1; 2065 case HDSP_SelSyncRef_ADAT2: 2066 return HDSP_AUTOSYNC_FROM_ADAT2; 2067 case HDSP_SelSyncRef_ADAT3: 2068 return HDSP_AUTOSYNC_FROM_ADAT3; 2069 default: 2070 return HDSP_AUTOSYNC_FROM_WORD; 2071 } 2072 return 0; 2073 } 2074 2075 static int snd_hdsp_info_autosync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 2076 { 2077 static char *texts[] = {"Word", "ADAT Sync", "IEC958", "None", "ADAT1", "ADAT2", "ADAT3" }; 2078 2079 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2080 uinfo->count = 1; 2081 uinfo->value.enumerated.items = 7; 2082 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 2083 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 2084 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2085 return 0; 2086 } 2087 2088 static int snd_hdsp_get_autosync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 2089 { 2090 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 2091 2092 ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp); 2093 return 0; 2094 } 2095 1402 2096 #define HDSP_PASSTHRU(xname, xindex) \ 1403 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = xname, .index = xindex, \ 2097 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 2098 .name = xname, \ 2099 .index = xindex, \ 1404 2100 .info = snd_hdsp_info_passthru, \ 1405 2101 .put = snd_hdsp_put_passthru, \ 1406 .get = snd_hdsp_get_passthru } 2102 .get = snd_hdsp_get_passthru \ 2103 } 1407 2104 1408 2105 static int snd_hdsp_info_passthru(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) … … 1447 2144 1448 2145 #define HDSP_LINE_OUT(xname, xindex) \ 1449 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = xname, .index = xindex, \ 2146 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 2147 .name = xname, \ 2148 .index = xindex, \ 1450 2149 .info = snd_hdsp_info_line_out, \ 1451 .get = snd_hdsp_get_line_out, .put = snd_hdsp_put_line_out } 2150 .get = snd_hdsp_get_line_out, \ 2151 .put = snd_hdsp_put_line_out \ 2152 } 1452 2153 1453 2154 static int hdsp_line_out(hdsp_t *hdsp) … … 1505 2206 1506 2207 #define HDSP_MIXER(xname, xindex) \ 1507 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = xname, .index = xindex, \ 2208 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 2209 .name = xname, \ 2210 .index = xindex, \ 2211 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ 2212 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ 1508 2213 .info = snd_hdsp_info_mixer, \ 1509 .get = snd_hdsp_get_mixer, .put = snd_hdsp_put_mixer } 2214 .get = snd_hdsp_get_mixer, \ 2215 .put = snd_hdsp_put_mixer \ 2216 } 1510 2217 1511 2218 static int snd_hdsp_info_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) … … 1531 2238 1532 2239 if (source > 25) { 1533 addr = PLAYBACK_TO_OUTPUT_KEY(source-26,destination);2240 addr = hdsp_playback_to_output_key(hdsp,source-26,destination); 1534 2241 } else { 1535 addr = INPUT_TO_OUTPUT_KEY(source, destination);2242 addr = hdsp_input_to_output_key(hdsp,source, destination); 1536 2243 } 1537 2244 1538 2245 spin_lock_irqsave(&hdsp->lock, flags); 1539 ucontrol->value.integer.value[ 0] = hdsp_read_gain (hdsp, addr);2246 ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr); 1540 2247 spin_unlock_irqrestore(&hdsp->lock, flags); 1541 2248 return 0; … … 1559 2266 1560 2267 if (source > 25) { 1561 addr = PLAYBACK_TO_OUTPUT_KEY(source-26, destination);2268 addr = hdsp_playback_to_output_key(hdsp,source-26, destination); 1562 2269 } else { 1563 addr = INPUT_TO_OUTPUT_KEY(source, destination);2270 addr = hdsp_input_to_output_key(hdsp,source, destination); 1564 2271 } 1565 2272 … … 1584 2291 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ 1585 2292 .info = snd_hdsp_info_playback_mixer, \ 1586 .get = snd_hdsp_get_playback_mixer, .put = snd_hdsp_put_playback_mixer } 2293 .get = snd_hdsp_get_playback_mixer, \ 2294 .put = snd_hdsp_put_playback_mixer \ 2295 } 1587 2296 1588 2297 static int snd_hdsp_info_playback_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) … … 1601 2310 unsigned long flags; 1602 2311 int addr; 1603 int chn; 1604 1605 chn = ucontrol->id.index - 1; 1606 addr = PLAYBACK_TO_OUTPUT_KEY(chn, chn); 2312 int channel; 2313 int mapped_channel; 2314 2315 channel = ucontrol->id.index - 1; 2316 2317 snd_assert(channel >= 0 || channel < HDSP_MAX_CHANNELS, return -EINVAL); 2318 2319 if ((mapped_channel = hdsp->channel_map[channel]) < 0) { 2320 return -EINVAL; 2321 } 2322 2323 addr = hdsp_playback_to_output_key(hdsp,mapped_channel, mapped_channel); 1607 2324 1608 2325 spin_lock_irqsave(&hdsp->lock, flags); … … 1618 2335 int change; 1619 2336 int addr; 1620 int chn; 2337 int channel; 2338 int mapped_channel; 1621 2339 int gain; 1622 2340 … … 1624 2342 return -EBUSY; 1625 2343 1626 chn = ucontrol->id.index - 1; 1627 addr = PLAYBACK_TO_OUTPUT_KEY(chn, chn); 2344 channel = ucontrol->id.index - 1; 2345 2346 snd_assert(channel >= 0 || channel < HDSP_MAX_CHANNELS, return -EINVAL); 2347 2348 if ((mapped_channel = hdsp->channel_map[channel]) < 0) { 2349 return -EINVAL; 2350 } 2351 2352 addr = hdsp_playback_to_output_key(hdsp,mapped_channel, mapped_channel); 1628 2353 gain = ucontrol->value.integer.value[0]; 1629 2354 … … 1637 2362 } 1638 2363 1639 #define HDSP_PEAK_PLAYBACK \ 1640 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, \ 2364 #define HDSP_WC_SYNC_CHECK(xname, xindex) \ 2365 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 2366 .name = xname, \ 2367 .index = xindex, \ 1641 2368 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ 1642 .info = snd_hdsp_info_peak_playback, \ 1643 .get = snd_hdsp_get_peak_playback \ 1644 } 1645 1646 static int snd_hdsp_info_peak_playback(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1647 { 1648 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1649 uinfo->count = 2; 1650 return 0; 1651 } 1652 1653 static int snd_hdsp_get_peak_playback(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 2369 .info = snd_hdsp_info_sync_check, \ 2370 .get = snd_hdsp_get_wc_sync_check \ 2371 } 2372 2373 static int snd_hdsp_info_sync_check(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 2374 { 2375 static char *texts[] = {"No Lock", "Lock", "Sync" }; 2376 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2377 uinfo->count = 1; 2378 uinfo->value.enumerated.items = 3; 2379 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 2380 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 2381 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2382 return 0; 2383 } 2384 2385 static int hdsp_wc_sync_check(hdsp_t *hdsp) 2386 { 2387 int status2 = hdsp_read(hdsp, HDSP_status2Register); 2388 if (status2 & HDSP_wc_lock) { 2389 if (status2 & HDSP_wc_sync) { 2390 return 2; 2391 } else { 2392 return 1; 2393 } 2394 } else { 2395 return 0; 2396 } 2397 return 0; 2398 } 2399 2400 static int snd_hdsp_get_wc_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1654 2401 { 1655 2402 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1656 unsigned int peakval = hdsp_read (hdsp, HDSP_playbackPeakLevel + (4 * (ucontrol->id.index-1))); 1657 ucontrol->value.integer.value[0] = peakval & 0xffffff00; /* peak */ 1658 ucontrol->value.integer.value[1] = peakval & 0xf; /* overs */ 1659 return 0; 1660 } 1661 1662 #define HDSP_PEAK_INPUT \ 1663 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, \ 2403 2404 ucontrol->value.enumerated.item[0] = hdsp_wc_sync_check(hdsp); 2405 return 0; 2406 } 2407 2408 #define HDSP_SPDIF_SYNC_CHECK(xname, xindex) \ 2409 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 2410 .name = xname, \ 2411 .index = xindex, \ 1664 2412 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ 1665 .info = snd_hdsp_info_peak_input, \ 1666 .get = snd_hdsp_get_peak_input \ 1667 } 1668 1669 static int snd_hdsp_info_peak_input(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1670 { 1671 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1672 uinfo->count = 2; 1673 return 0; 1674 } 1675 1676 static int snd_hdsp_get_peak_input(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 2413 .info = snd_hdsp_info_sync_check, \ 2414 .get = snd_hdsp_get_spdif_sync_check \ 2415 } 2416 2417 static int hdsp_spdif_sync_check(hdsp_t *hdsp) 2418 { 2419 int status = hdsp_read(hdsp, HDSP_statusRegister); 2420 if (status & HDSP_SPDIFErrorFlag) { 2421 return 0; 2422 } else { 2423 if (status & HDSP_SPDIFSync) { 2424 return 2; 2425 } else { 2426 return 1; 2427 } 2428 } 2429 return 0; 2430 } 2431 2432 static int snd_hdsp_get_spdif_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1677 2433 { 1678 2434 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1679 unsigned int peakval = hdsp_read (hdsp, HDSP_inputPeakLevel + (4 * (ucontrol->id.index-1))); 1680 ucontrol->value.integer.value[0] = peakval & 0xffffff00; /* peak */ 1681 ucontrol->value.integer.value[1] = peakval & 0xf; /* overs */ 1682 return 0; 1683 } 1684 1685 #define HDSP_PEAK_OUTPUT \ 1686 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, \ 2435 2436 ucontrol->value.enumerated.item[0] = hdsp_spdif_sync_check(hdsp); 2437 return 0; 2438 } 2439 2440 #define HDSP_ADATSYNC_SYNC_CHECK(xname, xindex) \ 2441 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 2442 .name = xname, \ 2443 .index = xindex, \ 1687 2444 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ 1688 .info = snd_hdsp_info_peak_output, \ 1689 .get = snd_hdsp_get_peak_output \ 1690 } 1691 1692 static int snd_hdsp_info_peak_output(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1693 { 1694 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1695 uinfo->count = 2; 1696 return 0; 1697 } 1698 1699 static int snd_hdsp_get_peak_output(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 2445 .info = snd_hdsp_info_sync_check, \ 2446 .get = snd_hdsp_get_adatsync_sync_check \ 2447 } 2448 2449 static int hdsp_adatsync_sync_check(hdsp_t *hdsp) 2450 { 2451 int status = hdsp_read(hdsp, HDSP_statusRegister); 2452 if (status & HDSP_TimecodeLock) { 2453 if (status & HDSP_TimecodeSync) { 2454 return 2; 2455 } else { 2456 return 1; 2457 } 2458 } else { 2459 return 0; 2460 } 2461 } 2462 2463 static int snd_hdsp_get_adatsync_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1700 2464 { 1701 2465 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1702 unsigned int peakval = hdsp_read (hdsp, HDSP_outputPeakLevel + (4 * (ucontrol->id.index-1))); 1703 ucontrol->value.integer.value[0] = peakval & 0xffffff00; /* peak */ 1704 ucontrol->value.integer.value[1] = peakval & 0xf; /* overs */ 1705 return 0; 1706 } 1707 1708 #define HDSP_RMS_INPUT \ 1709 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, \ 2466 2467 ucontrol->value.enumerated.item[0] = hdsp_adatsync_sync_check(hdsp); 2468 return 0; 2469 } 2470 2471 #define HDSP_ADAT_SYNC_CHECK \ 2472 { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 1710 2473 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ 1711 .info = snd_hdsp_info_rms_input, \ 1712 .get = snd_hdsp_get_rms_input \ 1713 } 1714 1715 static int snd_hdsp_info_rms_input(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1716 { 1717 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER64; 1718 uinfo->count = 1; 1719 return 0; 1720 } 1721 1722 static int snd_hdsp_get_rms_input(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1723 { 2474 .info = snd_hdsp_info_sync_check, \ 2475 .get = snd_hdsp_get_adat_sync_check \ 2476 } 2477 2478 static int hdsp_adat_sync_check(hdsp_t *hdsp, int idx) 2479 { 2480 int status = hdsp_read(hdsp, HDSP_statusRegister); 2481 2482 if (status & (HDSP_Lock0>>idx)) { 2483 if (status & (HDSP_Sync0>>idx)) { 2484 return 2; 2485 } else { 2486 return 1; 2487 } 2488 } else { 2489 return 0; 2490 } 2491 } 2492 2493 static int snd_hdsp_get_adat_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 2494 { 2495 int offset; 1724 2496 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1725 ucontrol->value.integer64.value[0] = hdsp_read64 (hdsp, HDSP_inputRmsLevel + (8 * (ucontrol->id.index-1))); 1726 return 0; 1727 } 1728 1729 #define HDSP_RMS_PLAYBACK \ 1730 { .iface = SNDRV_CTL_ELEM_IFACE_PCM, \ 1731 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ 1732 .info = snd_hdsp_info_rms_playback, \ 1733 .get = snd_hdsp_get_rms_playback \ 1734 } 1735 1736 static int snd_hdsp_info_rms_playback(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1737 { 1738 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER64; 1739 uinfo->count = 1; 1740 return 0; 1741 } 1742 1743 static int snd_hdsp_get_rms_playback(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 1744 { 1745 hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol); 1746 ucontrol->value.integer64.value[0] = hdsp_read64 (hdsp, HDSP_playbackRmsLevel + (8 * (ucontrol->id.index-1))); 2497 2498 offset = ucontrol->id.index - 1; 2499 snd_assert(offset >= 0 || offset < ((hdsp->io_type == Digiface) ? 3 : 1), return -EINVAL); 2500 ucontrol->value.enumerated.item[0] = hdsp_adat_sync_check(hdsp, offset); 1747 2501 return 0; 1748 2502 } … … 1771 2525 .get = snd_hdsp_control_spdif_mask_get, 1772 2526 .private_value = IEC958_AES0_NONAUDIO | 1773 IEC958_AES0_PROFESSIONAL |1774 IEC958_AES0_CON_EMPHASIS,2527 IEC958_AES0_PROFESSIONAL | 2528 IEC958_AES0_CON_EMPHASIS, 1775 2529 }, 1776 2530 { … … 1781 2535 .get = snd_hdsp_control_spdif_mask_get, 1782 2536 .private_value = IEC958_AES0_NONAUDIO | 1783 IEC958_AES0_PROFESSIONAL |1784 IEC958_AES0_PRO_EMPHASIS,2537 IEC958_AES0_PROFESSIONAL | 2538 IEC958_AES0_PRO_EMPHASIS, 1785 2539 }, 1786 2540 HDSP_MIXER("Mixer", 0), 1787 2541 HDSP_SPDIF_IN("IEC958 Input Connector", 0), 1788 2542 HDSP_SPDIF_OUT("IEC958 Output also on ADAT1", 0), 1789 HDSP_SYNC_PREF("Preferred Sync Source", 0), 2543 HDSP_SPDIF_PROFESSIONAL("IEC958 Professional Bit", 0), 2544 HDSP_SPDIF_EMPHASIS("IEC958 Emphasis Bit", 0), 2545 HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0), 2546 /* 'Sample Clock Source' complies with the alsa control naming scheme */ 2547 HDSP_CLOCK_SOURCE("Sample Clock Source", 0), 2548 HDSP_SYSTEM_CLOCK_MODE("System Clock Mode", 0), 2549 HDSP_PREF_SYNC_REF("Preferred Sync Reference", 0), 2550 HDSP_AUTOSYNC_REF("AutoSync Reference", 0), 2551 HDSP_SPDIF_SAMPLE_RATE("SPDIF Sample Rate", 0), 2552 HDSP_SYSTEM_SAMPLE_RATE("System Sample Rate", 0), 2553 /* 'External Rate' complies with the alsa control naming scheme */ 2554 HDSP_AUTOSYNC_SAMPLE_RATE("External Rate", 0), 2555 HDSP_WC_SYNC_CHECK("Word Clock Lock Status", 0), 2556 HDSP_SPDIF_SYNC_CHECK("SPDIF Lock Status", 0), 2557 HDSP_ADATSYNC_SYNC_CHECK("ADAT Sync Lock Status", 0), 1790 2558 HDSP_PASSTHRU("Passthru", 0), 1791 2559 HDSP_LINE_OUT("Line Out", 0), … … 1795 2563 1796 2564 static snd_kcontrol_new_t snd_hdsp_playback_mixer = HDSP_PLAYBACK_MIXER; 1797 static snd_kcontrol_new_t snd_hdsp_input_peak = HDSP_PEAK_INPUT; 1798 static snd_kcontrol_new_t snd_hdsp_output_peak = HDSP_PEAK_OUTPUT; 1799 static snd_kcontrol_new_t snd_hdsp_playback_peak = HDSP_PEAK_PLAYBACK; 1800 static snd_kcontrol_new_t snd_hdsp_input_rms = HDSP_RMS_INPUT; 1801 static snd_kcontrol_new_t snd_hdsp_playback_rms = HDSP_RMS_PLAYBACK; 2565 static snd_kcontrol_new_t snd_hdsp_adat_sync_check = HDSP_ADAT_SYNC_CHECK; 2566 2567 2568 static int hdsp_update_simple_mixer_controls(hdsp_t *hdsp) 2569 { 2570 int i; 2571 2572 for (i = hdsp->ds_channels; i < hdsp->ss_channels; ++i) { 2573 if (hdsp->system_sample_rate > 48000) { 2574 hdsp->playback_mixer_ctls[i]->vd[0].access = SNDRV_CTL_ELEM_ACCESS_INACTIVE | 2575 SNDRV_CTL_ELEM_ACCESS_READ | 2576 SNDRV_CTL_ELEM_ACCESS_VOLATILE; 2577 } else { 2578 hdsp->playback_mixer_ctls[i]->vd[0].access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 2579 SNDRV_CTL_ELEM_ACCESS_VOLATILE; 2580 } 2581 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | 2582 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->playback_mixer_ctls[i]->id); 2583 } 2584 2585 return 0; 2586 } 2587 1802 2588 1803 2589 int snd_hdsp_create_controls(snd_card_t *card, hdsp_t *hdsp) … … 1814 2600 } 1815 2601 1816 if (hdsp->type == Digiface) { 2602 snd_hdsp_playback_mixer.name = "Chn"; 2603 snd_hdsp_adat_sync_check.name = "ADAT Lock Status"; 2604 2605 if (hdsp->io_type == Digiface) { 1817 2606 limit = DIGIFACE_SS_CHANNELS; 1818 2607 } else { 1819 2608 limit = MULTIFACE_SS_CHANNELS; 1820 2609 } 1821 2610 1822 2611 /* The index values are one greater than the channel ID so that alsamixer 1823 2612 will display them correctly. We want to use the index for fast lookup … … 1826 2615 */ 1827 2616 1828 snd_hdsp_playback_mixer.name = "Chn";1829 snd_hdsp_input_peak.name = "Input Peak";1830 snd_hdsp_output_peak.name = "Output Peak";1831 snd_hdsp_playback_peak.name = "Playback Peak";1832 snd_hdsp_playback_rms.name = "Playback RMS";1833 snd_hdsp_input_rms.name = "Input RMS";1834 1835 2617 for (idx = 0; idx < limit; ++idx) { 1836 2618 snd_hdsp_playback_mixer.index = idx+1; … … 1838 2620 return err; 1839 2621 } 1840 snd_hdsp_input_peak.index = idx+1; 1841 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_input_peak, hdsp)))) { 1842 return err; 1843 } 1844 snd_hdsp_output_peak.index = idx+1; 1845 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_output_peak, hdsp)))) { 1846 return err; 1847 } 1848 snd_hdsp_playback_peak.index = idx+1; 1849 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_playback_peak, hdsp)))) { 1850 return err; 1851 } 1852 snd_hdsp_playback_rms.index = idx+1; 1853 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_playback_rms, hdsp)))) { 1854 return err; 1855 } 1856 snd_hdsp_input_rms.index = idx+1; 1857 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_input_rms, hdsp)))) { 1858 return err; 2622 hdsp->playback_mixer_ctls[idx] = kctl; 2623 } 2624 2625 /* ADAT SyncCheck status */ 2626 snd_hdsp_adat_sync_check.index = 1; 2627 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) { 2628 return err; 2629 } 2630 if (hdsp->io_type == Digiface) { 2631 for (idx = 1; idx < 3; ++idx) { 2632 snd_hdsp_adat_sync_check.index = idx+1; 2633 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) { 2634 return err; 2635 } 1859 2636 } 1860 2637 } … … 1873 2650 unsigned int status; 1874 2651 unsigned int status2; 1875 char *requested_sync_ref; 2652 char *pref_sync_ref; 2653 char *autosync_ref; 2654 char *system_clock_mode; 2655 char *clock_source; 1876 2656 int x; 1877 2657 1878 2658 if (hdsp_check_for_iobox (hdsp)) { 2659 snd_iprintf(buffer, "No I/O box connected.\nPlease connect one and upload firmware.\n"); 1879 2660 return; 1880 2661 } 1881 2662 2663 if (hdsp_check_for_firmware(hdsp)) { 2664 if (hdsp->state & HDSP_FirmwareCached) { 2665 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { 2666 snd_iprintf(buffer, "Firmware loading from cache failed, please upload manually.\n"); 2667 return; 2668 } 2669 } else { 2670 snd_iprintf(buffer, "No firmware loaded nor cached, please upload firmware.\n"); 2671 return; 2672 } 2673 } 2674 1882 2675 status = hdsp_read(hdsp, HDSP_statusRegister); 1883 2676 status2 = hdsp_read(hdsp, HDSP_status2Register); … … 1902 2695 x = 1 << (6 + hdsp_decode_latency(hdsp->control_register & HDSP_LatencyMask)); 1903 2696 1904 snd_iprintf(buffer, " Latency: %d samples (2 periods of %lu bytes)\n", x, (unsigned long) hdsp->period_bytes);2697 snd_iprintf(buffer, "Buffer Size (Latency): %d samples (2 periods of %lu bytes)\n", x, (unsigned long) hdsp->period_bytes); 1905 2698 snd_iprintf(buffer, "Hardware pointer (frames): %ld\n", hdsp_hw_pointer(hdsp)); 1906 2699 snd_iprintf(buffer, "Passthru: %s\n", hdsp->passthru ? "yes" : "no"); … … 1909 2702 snd_iprintf(buffer, "Firmware version: %d\n", (status2&HDSP_version0)|(status2&HDSP_version1)<<1|(status2&HDSP_version2)<<2); 1910 2703 1911 switch (hdsp_sync_pref (hdsp)) { 2704 snd_iprintf(buffer, "\n"); 2705 2706 2707 switch (hdsp_clock_source(hdsp)) { 2708 case HDSP_CLOCK_SOURCE_AUTOSYNC: 2709 clock_source = "AutoSync"; 2710 break; 2711 case HDSP_CLOCK_SOURCE_INTERNAL_32KHZ: 2712 clock_source = "Internal 32 kHz"; 2713 break; 2714 case HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ: 2715 clock_source = "Internal 44.1 kHz"; 2716 break; 2717 case HDSP_CLOCK_SOURCE_INTERNAL_48KHZ: 2718 clock_source = "Internal 48 kHz"; 2719 break; 2720 case HDSP_CLOCK_SOURCE_INTERNAL_64KHZ: 2721 clock_source = "Internal 64 kHz"; 2722 break; 2723 case HDSP_CLOCK_SOURCE_INTERNAL_88_2KHZ: 2724 clock_source = "Internal 88.2 kHz"; 2725 break; 2726 case HDSP_CLOCK_SOURCE_INTERNAL_96KHZ: 2727 clock_source = "Internal 96 kHz"; 2728 break; 2729 default: 2730 clock_source = "Error"; 2731 } 2732 snd_iprintf (buffer, "Sample Clock Source: %s\n", clock_source); 2733 2734 if (hdsp_system_clock_mode(hdsp)) { 2735 system_clock_mode = "Slave"; 2736 } else { 2737 system_clock_mode = "Master"; 2738 } 2739 2740 switch (hdsp_pref_sync_ref (hdsp)) { 1912 2741 case HDSP_SYNC_FROM_WORD: 1913 requested_sync_ref = "Word";2742 pref_sync_ref = "Word Clock"; 1914 2743 break; 1915 2744 case HDSP_SYNC_FROM_ADAT_SYNC: 1916 requested_sync_ref = "ADAT Sync";2745 pref_sync_ref = "ADAT Sync"; 1917 2746 break; 1918 2747 case HDSP_SYNC_FROM_SPDIF: 1919 requested_sync_ref = "SPDIF";2748 pref_sync_ref = "SPDIF"; 1920 2749 break; 1921 2750 case HDSP_SYNC_FROM_ADAT1: 1922 requested_sync_ref = "ADAT1";2751 pref_sync_ref = "ADAT1"; 1923 2752 break; 1924 2753 case HDSP_SYNC_FROM_ADAT2: 1925 requested_sync_ref = "ADAT2";2754 pref_sync_ref = "ADAT2"; 1926 2755 break; 1927 2756 case HDSP_SYNC_FROM_ADAT3: 1928 requested_sync_ref = "ADAT3"; 1929 break; 1930 case HDSP_SYNC_FROM_SELF: 2757 pref_sync_ref = "ADAT3"; 2758 break; 1931 2759 default: 1932 requested_sync_ref = "Master"; 1933 break; 1934 } 1935 1936 if ((hdsp->control_register & HDSP_ClockModeMaster)) { 1937 snd_iprintf (buffer, "Sync reference: %s/Master (chosen)\n", requested_sync_ref); 1938 } else if (hdsp_system_sample_rate(hdsp) == 0) { 1939 snd_iprintf (buffer, "Sync reference: %s/Master (forced)\n", requested_sync_ref); 1940 } else { 1941 switch (status2 & HDSP_SelSyncRefMask) { 1942 case HDSP_SelSyncRef_ADAT1: 1943 snd_iprintf (buffer, "Sync reference: %s/ADAT1\n", requested_sync_ref); 1944 break; 1945 case HDSP_SelSyncRef_ADAT2: 1946 snd_iprintf (buffer, "Sync reference: %s/ADAT2\n", requested_sync_ref); 1947 break; 1948 case HDSP_SelSyncRef_ADAT3: 1949 snd_iprintf (buffer, "Sync reference: %s/ADAT3\n", requested_sync_ref); 1950 break; 1951 case HDSP_SelSyncRef_SPDIF: 1952 snd_iprintf (buffer, "Sync reference: %s/SPDIF\n", requested_sync_ref); 1953 break; 1954 case HDSP_SelSyncRef_WORD: 1955 snd_iprintf (buffer, "Sync reference: %s/WORD\n", requested_sync_ref); 1956 break; 1957 case HDSP_SelSyncRef_ADAT_SYNC: 1958 snd_iprintf (buffer, "Sync reference: %s/ADAT Sync\n", requested_sync_ref); 1959 break; 1960 default: 1961 snd_iprintf (buffer, "Sync reference: %s/Master (fallback)\n", requested_sync_ref); 1962 break; 1963 } 1964 } 1965 snd_iprintf (buffer, "Sample rate: %d\n", hdsp_system_sample_rate(hdsp)); 1966 2760 pref_sync_ref = "Word Clock"; 2761 break; 2762 } 2763 snd_iprintf (buffer, "Preferred Sync Reference: %s\n", pref_sync_ref); 2764 2765 switch (hdsp_autosync_ref (hdsp)) { 2766 case HDSP_AUTOSYNC_FROM_WORD: 2767 autosync_ref = "Word Clock"; 2768 break; 2769 case HDSP_AUTOSYNC_FROM_ADAT_SYNC: 2770 autosync_ref = "ADAT Sync"; 2771 break; 2772 case HDSP_AUTOSYNC_FROM_SPDIF: 2773 autosync_ref = "SPDIF"; 2774 break; 2775 case HDSP_AUTOSYNC_FROM_NONE: 2776 autosync_ref = "None"; 2777 break; 2778 case HDSP_AUTOSYNC_FROM_ADAT1: 2779 autosync_ref = "ADAT1"; 2780 break; 2781 case HDSP_AUTOSYNC_FROM_ADAT2: 2782 autosync_ref = "ADAT2"; 2783 break; 2784 case HDSP_AUTOSYNC_FROM_ADAT3: 2785 autosync_ref = "ADAT3"; 2786 break; 2787 default: 2788 autosync_ref = "---"; 2789 break; 2790 } 2791 snd_iprintf (buffer, "AutoSync Reference: %s\n", autosync_ref); 2792 2793 snd_iprintf (buffer, "AutoSync Frequency: %d\n", hdsp_external_sample_rate(hdsp)); 2794 2795 snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode); 2796 2797 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate); 2798 1967 2799 snd_iprintf(buffer, "\n"); 1968 2800 … … 2005 2837 snd_iprintf(buffer, "IEC958 NonAudio: off\n"); 2006 2838 } 2007 2008 snd_iprintf(buffer, "\n");2009 2010 2839 if ((x = hdsp_spdif_sample_rate (hdsp)) != 0) { 2011 2840 snd_iprintf (buffer, "IEC958 sample rate: %d\n", x); … … 2024 2853 } 2025 2854 2026 x = status & HDSP_Sync1;2027 if (status & HDSP_Lock1) {2028 snd_iprintf(buffer, "ADAT2: %s\n", x ? "Sync" : "Lock");2029 } else{2030 snd_iprintf(buffer, "ADAT2: No Lock\n");2031 }2032 2033 if (hdsp->type == Digiface) {2855 switch (hdsp->io_type) { 2856 case Digiface: 2857 x = status & HDSP_Sync1; 2858 if (status & HDSP_Lock1) { 2859 snd_iprintf(buffer, "ADAT2: %s\n", x ? "Sync" : "Lock"); 2860 } else { 2861 snd_iprintf(buffer, "ADAT2: No Lock\n"); 2862 } 2034 2863 x = status & HDSP_Sync2; 2035 2864 if (status & HDSP_Lock2) { … … 2038 2867 snd_iprintf(buffer, "ADAT3: No Lock\n"); 2039 2868 } 2869 default: 2870 /* relax */ 2871 break; 2872 } 2873 2874 x = status & HDSP_SPDIFSync; 2875 if (status & HDSP_SPDIFErrorFlag) { 2876 snd_iprintf (buffer, "SPDIF: No Lock\n"); 2877 } else { 2878 snd_iprintf (buffer, "SPDIF: %s\n", x ? "Sync" : "Lock"); 2879 } 2880 2881 x = status2 & HDSP_wc_sync; 2882 if (status2 & HDSP_wc_lock) { 2883 snd_iprintf (buffer, "Word Clock: %s\n", x ? "Sync" : "Lock"); 2884 } else { 2885 snd_iprintf (buffer, "Word Clock: No Lock\n"); 2886 } 2887 2888 x = status & HDSP_TimecodeSync; 2889 if (status & HDSP_TimecodeLock) { 2890 snd_iprintf(buffer, "ADAT Sync: %s\n", x ? "Sync" : "Lock"); 2891 } else { 2892 snd_iprintf(buffer, "ADAT Sync: No Lock\n"); 2040 2893 } 2041 2894 … … 2054 2907 snd_info_entry_t *entry; 2055 2908 2056 if ((entry = snd_info_create_card_entry(hdsp->card, "hdsp", hdsp->card->proc_root)) != 2057 NULL) { 2058 entry->content = SNDRV_INFO_CONTENT_TEXT; 2059 entry->private_data = hdsp; 2060 entry->mode = S_IFREG | S_IRUGO | S_IWUSR; 2061 entry->c.text.read_size = 256; 2062 entry->c.text.read = snd_hdsp_proc_read; 2063 if (snd_info_register(entry) < 0) { 2064 snd_info_free_entry(entry); 2065 entry = NULL; 2066 } 2067 } 2068 hdsp->proc_entry = entry; 2069 } 2070 2071 static void snd_hdsp_proc_done(hdsp_t *hdsp) 2072 { 2073 if (hdsp->proc_entry) { 2074 snd_info_unregister(hdsp->proc_entry); 2075 hdsp->proc_entry = NULL; 2076 } 2909 if (! snd_card_proc_new(hdsp->card, "hdsp", &entry)) 2910 snd_info_set_text_ops(entry, hdsp, snd_hdsp_proc_read); 2077 2911 } 2078 2912 … … 2159 2993 } 2160 2994 2161 static voidsnd_hdsp_set_defaults(hdsp_t *hdsp)2995 static int snd_hdsp_set_defaults(hdsp_t *hdsp) 2162 2996 { 2163 2997 unsigned int i; … … 2192 3026 } 2193 3027 2194 for (i = 0; i < 2048; i++) 2195 hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN); 2196 2197 if (line_outs_monitor[hdsp->dev]) { 3028 for (i = 0; i < (hdsp_is_9652(hdsp) ? 1352 : HDSP_MATRIX_MIXER_SIZE); i++) { 3029 if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN)) { 3030 return -EIO; 3031 } 3032 } 3033 3034 if (!hdsp_is_9652(hdsp) && line_outs_monitor[hdsp->dev]) { 2198 3035 2199 3036 snd_printk ("sending all inputs and playback streams to line outs.\n"); … … 2205 3042 for (i = 0; i < HDSP_MAX_CHANNELS; i++) { 2206 3043 if (i & 1) { 2207 hdsp_write_gain (hdsp, INPUT_TO_OUTPUT_KEY (i, 26), UNITY_GAIN); 2208 hdsp_write_gain (hdsp, PLAYBACK_TO_OUTPUT_KEY (i, 26), UNITY_GAIN); 3044 if (hdsp_write_gain (hdsp, hdsp_input_to_output_key (hdsp, i, 26), UNITY_GAIN) || 3045 hdsp_write_gain (hdsp, hdsp_playback_to_output_key (hdsp, i, 26), UNITY_GAIN)) { 3046 return -EIO; 3047 } 2209 3048 } else { 2210 hdsp_write_gain (hdsp, INPUT_TO_OUTPUT_KEY (i, 27), UNITY_GAIN); 2211 hdsp_write_gain (hdsp, PLAYBACK_TO_OUTPUT_KEY (i, 27), UNITY_GAIN); 3049 if (hdsp_write_gain (hdsp, hdsp_input_to_output_key (hdsp, i, 27), UNITY_GAIN) || 3050 hdsp_write_gain (hdsp, hdsp_playback_to_output_key (hdsp, i, 27), UNITY_GAIN)) { 3051 return -EIO; 3052 } 2212 3053 } 2213 3054 } … … 2219 3060 */ 2220 3061 2221 hdsp_set_rate(hdsp, 48000); 2222 } 2223 2224 void snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *regs) 3062 hdsp_set_rate(hdsp, 48000, 1); 3063 3064 return 0; 3065 } 3066 3067 void hdsp_midi_tasklet(unsigned long arg) 3068 { 3069 hdsp_t *hdsp = (hdsp_t *)arg; 3070 3071 if (hdsp->midi[0].pending) { 3072 snd_hdsp_midi_input_read (&hdsp->midi[0]); 3073 } 3074 if (hdsp->midi[1].pending) { 3075 snd_hdsp_midi_input_read (&hdsp->midi[1]); 3076 } 3077 } 3078 3079 static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *regs) 2225 3080 { 2226 3081 hdsp_t *hdsp = (hdsp_t *) dev_id; … … 2231 3086 unsigned int midi0status; 2232 3087 unsigned int midi1status; 2233 3088 int schedule = 0; 3089 2234 3090 status = hdsp_read(hdsp, HDSP_statusRegister); 2235 3091 … … 2239 3095 2240 3096 if (!audio && !midi0 && !midi1) { 2241 return ;3097 return IRQ_NONE; 2242 3098 } 2243 3099 … … 2246 3102 midi0status = hdsp_read (hdsp, HDSP_midiStatusIn0) & 0xff; 2247 3103 midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff; 2248 3104 2249 3105 if (audio) { 2250 3106 if (hdsp->capture_substream) { … … 2256 3112 } 2257 3113 } 2258 2259 /* note: snd_hdsp_midi_input_read() calls output_write() because 2260 output is not interrupt-driven ... 2261 */ 2262 2263 if (midi0status) 2264 snd_hdsp_midi_input_read (&hdsp->midi[0]); 2265 if (midi1status) 2266 snd_hdsp_midi_input_read (&hdsp->midi[1]); 3114 3115 if (midi0 && midi0status) { 3116 /* we disable interrupts for this input until processing is done */ 3117 hdsp->control_register &= ~HDSP_Midi0InterruptEnable; 3118 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 3119 hdsp->midi[0].pending = 1; 3120 schedule = 1; 3121 } 3122 if (midi1 && midi1status) { 3123 /* we disable interrupts for this input until processing is done */ 3124 hdsp->control_register &= ~HDSP_Midi1InterruptEnable; 3125 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 3126 hdsp->midi[1].pending = 1; 3127 schedule = 1; 3128 } 3129 if (schedule) 3130 tasklet_hi_schedule(&hdsp->midi_tasklet); 3131 return IRQ_HANDLED; 2267 3132 } 2268 3133 … … 2303 3168 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); 2304 3169 snd_assert(channel_buf != NULL, return -EIO); 2305 if (copy_from_user(channel_buf + pos * 4, src, count * 4)) 2306 return -EFAULT; 3170 copy_from_user(channel_buf + pos * 4, src, count * 4); 2307 3171 return count; 2308 3172 } … … 2318 3182 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); 2319 3183 snd_assert(channel_buf != NULL, return -EIO); 2320 if (copy_to_user(dst, channel_buf + pos * 4, count * 4)) 2321 return -EFAULT; 3184 copy_to_user(dst, channel_buf + pos * 4, count * 4); 2322 3185 return count; 2323 3186 } … … 2349 3212 runtime->status->hw_ptr = 0; 2350 3213 if (other) { 2351 snd_pcm_substream_t *s = substream; 3214 struct list_head *pos; 3215 snd_pcm_substream_t *s; 2352 3216 snd_pcm_runtime_t *oruntime = other->runtime; 2353 do{2354 s = s ->link_next;3217 snd_pcm_group_for_each(pos, substream) { 3218 s = snd_pcm_group_substream_entry(pos); 2355 3219 if (s == other) { 2356 3220 oruntime->status->hw_ptr = runtime->status->hw_ptr; 2357 3221 break; 2358 3222 } 2359 } while (s != substream);3223 } 2360 3224 } 2361 3225 return 0; … … 2371 3235 2372 3236 if (hdsp_check_for_iobox (hdsp)) { 3237 return -EIO; 3238 } 3239 3240 if (hdsp_check_for_firmware(hdsp)) { 3241 if (hdsp->state & HDSP_FirmwareCached) { 3242 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { 3243 snd_printk("Firmware loading from cache failed, please upload manually.\n"); 3244 } 3245 } else { 3246 snd_printk("No firmware loaded nor cached, please upload firmware.\n"); 3247 } 2373 3248 return -EIO; 2374 3249 } … … 2393 3268 */ 2394 3269 2395 if ( (int)params_rate(params) != hdsp_system_sample_rate(hdsp)) {3270 if (params_rate(params) != hdsp->system_sample_rate) { 2396 3271 spin_unlock_irq(&hdsp->lock); 2397 3272 _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE); … … 2417 3292 */ 2418 3293 2419 if ((err = hdsp_set_rate(hdsp, params_rate(params) )) < 0) {3294 if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) { 2420 3295 _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE); 2421 3296 return err; … … 2434 3309 { 2435 3310 hdsp_t *hdsp = _snd_pcm_substream_chip(substream); 2436 int chn;3311 int mapped_channel; 2437 3312 2438 3313 snd_assert(info->channel < HDSP_MAX_CHANNELS, return -EINVAL); 2439 3314 2440 if (( chn= hdsp->channel_map[info->channel]) < 0) {3315 if ((mapped_channel = hdsp->channel_map[info->channel]) < 0) { 2441 3316 return -EINVAL; 2442 3317 } 2443 3318 2444 info->offset = chn* HDSP_CHANNEL_BUFFER_BYTES;3319 info->offset = mapped_channel * HDSP_CHANNEL_BUFFER_BYTES; 2445 3320 info->first = 0; 2446 3321 info->step = 32; … … 2475 3350 2476 3351 if (hdsp_check_for_iobox (hdsp)) { 3352 return -EIO; 3353 } 3354 3355 if (hdsp_check_for_firmware(hdsp)) { 3356 if (hdsp->state & HDSP_FirmwareCached) { 3357 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { 3358 snd_printk("Firmware loading from cache failed, please upload manually.\n"); 3359 } 3360 } else { 3361 snd_printk("No firmware loaded nor cached, please upload firmware.\n"); 3362 } 2477 3363 return -EIO; 2478 3364 } … … 2498 3384 2499 3385 if (other) { 2500 snd_pcm_substream_t *s = substream; 2501 do { 2502 s = s->link_next; 3386 struct list_head *pos; 3387 snd_pcm_substream_t *s; 3388 snd_pcm_group_for_each(pos, substream) { 3389 s = snd_pcm_group_substream_entry(pos); 2503 3390 if (s == other) { 2504 3391 snd_pcm_trigger_done(s, substream); … … 2509 3396 goto _ok; 2510 3397 } 2511 } while (s != substream);3398 } 2512 3399 if (cmd == SNDRV_PCM_TRIGGER_START) { 2513 3400 if (!(running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) && … … 2541 3428 2542 3429 if (hdsp_check_for_iobox (hdsp)) { 3430 return -EIO; 3431 } 3432 3433 if (hdsp_check_for_firmware(hdsp)) { 3434 if (hdsp->state & HDSP_FirmwareCached) { 3435 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { 3436 snd_printk("Firmware loading from cache failed, please upload manually.\n"); 3437 } 3438 } else { 3439 snd_printk("No firmware loaded nor cached, please upload firmware.\n"); 3440 } 2543 3441 return -EIO; 2544 3442 } … … 2567 3465 .rate_min = 32000, 2568 3466 .rate_max = 96000, 2569 .channels_min = 1 0,3467 .channels_min = 14, 2570 3468 .channels_max = HDSP_MAX_CHANNELS, 2571 3469 .buffer_bytes_max = HDSP_CHANNEL_BUFFER_BYTES * HDSP_MAX_CHANNELS, 2572 .period_bytes_min = (64 * 4) * 10,3470 .period_bytes_min = (64 * 4) * 10, 2573 3471 .period_bytes_max = (8192 * 4) * HDSP_MAX_CHANNELS, 2574 3472 .periods_min = 2, 2575 3473 .periods_max = 2, 2576 .fifo_size = 0 ,3474 .fifo_size = 0 2577 3475 }; 2578 3476 … … 2592 3490 .rate_min = 32000, 2593 3491 .rate_max = 96000, 2594 .channels_min = 1 0,3492 .channels_min = 14, 2595 3493 .channels_max = HDSP_MAX_CHANNELS, 2596 3494 .buffer_bytes_max = HDSP_CHANNEL_BUFFER_BYTES * HDSP_MAX_CHANNELS, … … 2599 3497 .periods_min = 2, 2600 3498 .periods_max = 2, 2601 .fifo_size = 0 ,3499 .fifo_size = 0 2602 3500 }; 2603 3501 … … 2679 3577 } 2680 3578 3579 if (hdsp_check_for_firmware(hdsp)) { 3580 if (hdsp->state & HDSP_FirmwareCached) { 3581 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { 3582 snd_printk("Firmware loading from cache failed, please upload manually.\n"); 3583 } 3584 } else { 3585 snd_printk("No firmware loaded nor cached, please upload firmware.\n"); 3586 } 3587 return -EIO; 3588 } 3589 2681 3590 spin_lock_irqsave(&hdsp->lock, flags); 2682 3591 … … 2710 3619 2711 3620 hdsp->creg_spdif_stream = hdsp->creg_spdif; 2712 hdsp->spdif_ctl-> access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;3621 hdsp->spdif_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; 2713 3622 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | 2714 3623 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->spdif_ctl->id); … … 2728 3637 spin_unlock_irqrestore(&hdsp->lock, flags); 2729 3638 2730 hdsp->spdif_ctl-> access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;3639 hdsp->spdif_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; 2731 3640 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | 2732 3641 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->spdif_ctl->id); … … 2742 3651 2743 3652 if (hdsp_check_for_iobox (hdsp)) { 3653 return -EIO; 3654 } 3655 3656 if (hdsp_check_for_firmware(hdsp)) { 3657 if (hdsp->state & HDSP_FirmwareCached) { 3658 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { 3659 snd_printk("Firmware loading from cache failed, please upload manually.\n"); 3660 } 3661 } else { 3662 snd_printk("No firmware loaded nor cached, please upload firmware.\n"); 3663 } 2744 3664 return -EIO; 2745 3665 } … … 2791 3711 } 2792 3712 3713 static int snd_hdsp_hwdep_dummy_op(snd_hwdep_t *hw, struct file *file) 3714 { 3715 /* we have nothing to initialize but the call is required */ 3716 return 0; 3717 } 3718 3719 3720 static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int cmd, unsigned long arg) 3721 { 3722 hdsp_t *hdsp = (hdsp_t *)hw->private_data; 3723 hdsp_peak_rms_t *peak_rms; 3724 hdsp_firmware_t *firmware; 3725 hdsp_mixer_t *mixer; 3726 hdsp_config_info_t info; 3727 hdsp_version_t hdsp_version; 3728 int i; 3729 int err; 3730 unsigned long flags; 3731 3732 switch (cmd) { 3733 case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: 3734 if (!(hdsp->state & HDSP_FirmwareLoaded)) { 3735 snd_printk("firmware needs to be uploaded to the card.\n"); 3736 return -EINVAL; 3737 } 3738 peak_rms = (hdsp_peak_rms_t *)arg; 3739 if (copy_to_user_fromio((void *)peak_rms->playback_peaks, hdsp->iobase+HDSP_playbackPeakLevel, 26*4) != 0) { 3740 return -EFAULT; 3741 } 3742 if (copy_to_user_fromio((void *)peak_rms->input_peaks, hdsp->iobase+HDSP_inputPeakLevel, 26*4) != 0) { 3743 return -EFAULT; 3744 } 3745 if (copy_to_user_fromio((void *)peak_rms->output_peaks, hdsp->iobase+HDSP_outputPeakLevel, 28*4) != 0) { 3746 return -EFAULT; 3747 } 3748 if (copy_to_user_fromio((void *)peak_rms->playback_rms, hdsp->iobase+HDSP_playbackRmsLevel, 26*8) != 0) { 3749 return -EFAULT; 3750 } 3751 if (copy_to_user_fromio((void *)peak_rms->input_rms, hdsp->iobase+HDSP_inputRmsLevel, 26*8) != 0) { 3752 return -EFAULT; 3753 } 3754 break; 3755 case SNDRV_HDSP_IOCTL_GET_CONFIG_INFO: 3756 if (!(hdsp->state & HDSP_FirmwareLoaded)) { 3757 snd_printk("Firmware needs to be uploaded to the card.\n"); 3758 return -EINVAL; 3759 } 3760 spin_lock_irqsave(&hdsp->lock, flags); 3761 info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp); 3762 info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp); 3763 info.adatsync_sync_check = (unsigned char)hdsp_adatsync_sync_check(hdsp); 3764 info.spdif_sync_check = (unsigned char)hdsp_spdif_sync_check(hdsp); 3765 for (i = 0; i < ((hdsp->io_type != Multiface) ? 3 : 1); ++i) { 3766 info.adat_sync_check[i] = (unsigned char)hdsp_adat_sync_check(hdsp, i); 3767 } 3768 info.spdif_in = (unsigned char)hdsp_spdif_in(hdsp); 3769 info.spdif_out = (unsigned char)hdsp_spdif_out(hdsp); 3770 info.spdif_professional = (unsigned char)hdsp_spdif_professional(hdsp); 3771 info.spdif_emphasis = (unsigned char)hdsp_spdif_emphasis(hdsp); 3772 info.spdif_nonaudio = (unsigned char)hdsp_spdif_nonaudio(hdsp); 3773 info.spdif_sample_rate = hdsp_spdif_sample_rate(hdsp); 3774 info.system_sample_rate = hdsp->system_sample_rate; 3775 info.autosync_sample_rate = hdsp_external_sample_rate(hdsp); 3776 info.system_clock_mode = (unsigned char)hdsp_system_clock_mode(hdsp); 3777 info.clock_source = (unsigned char)hdsp_clock_source(hdsp); 3778 info.autosync_ref = (unsigned char)hdsp_autosync_ref(hdsp); 3779 info.line_out = (unsigned char)hdsp_line_out(hdsp); 3780 info.passthru = (unsigned char)hdsp->passthru; 3781 spin_unlock_irqrestore(&hdsp->lock, flags); 3782 if (copy_to_user((void *)arg, &info, sizeof(info))) 3783 return -EFAULT; 3784 break; 3785 case SNDRV_HDSP_IOCTL_GET_VERSION: 3786 if (hdsp_is_9652(hdsp)) return -EINVAL; 3787 if (hdsp->io_type == Undefined) { 3788 if ((err = hdsp_get_iobox_version(hdsp)) < 0) { 3789 return err; 3790 } 3791 } 3792 hdsp_version.io_type = hdsp->io_type; 3793 hdsp_version.firmware_rev = hdsp->firmware_rev; 3794 if ((err = copy_to_user((void *)arg, &hdsp_version, sizeof(hdsp_version)))) { 3795 return -EFAULT; 3796 } 3797 break; 3798 case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: 3799 if (hdsp_is_9652(hdsp)) return -EINVAL; 3800 /* SNDRV_HDSP_IOCTL_GET_VERSION must have been called */ 3801 if (hdsp->io_type == Undefined) return -EINVAL; 3802 3803 snd_printk("initializing firmware upload\n"); 3804 firmware = (hdsp_firmware_t *)arg; 3805 3806 if (hdsp_check_for_iobox (hdsp)) { 3807 return -EIO; 3808 } 3809 3810 if (copy_from_user(hdsp->firmware_cache, firmware->firmware_data, sizeof(unsigned long)*24413) != 0) { 3811 return -EFAULT; 3812 } 3813 3814 hdsp->state |= HDSP_FirmwareCached; 3815 3816 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) { 3817 return err; 3818 } 3819 3820 3821 if (!(hdsp->state & HDSP_InitializationComplete)) { 3822 snd_hdsp_initialize_channels(hdsp); 3823 3824 snd_hdsp_initialize_midi_flush(hdsp); 3825 3826 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { 3827 snd_printk("error creating alsa devices\n"); 3828 return err; 3829 } 3830 } 3831 break; 3832 case SNDRV_HDSP_IOCTL_GET_MIXER: 3833 mixer = (hdsp_mixer_t *)arg; 3834 if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE)) 3835 return -EFAULT; 3836 break; 3837 default: 3838 return -EINVAL; 3839 } 3840 return 0; 3841 } 3842 2793 3843 static snd_pcm_ops_t snd_hdsp_playback_ops = { 2794 3844 .open = snd_hdsp_playback_open, … … 2814 3864 }; 2815 3865 3866 static int __devinit snd_hdsp_create_hwdep(snd_card_t *card, 3867 hdsp_t *hdsp) 3868 { 3869 snd_hwdep_t *hw; 3870 int err; 3871 3872 if ((err = snd_hwdep_new(card, "HDSP hwdep", 0, &hw)) < 0) 3873 return err; 3874 3875 hdsp->hwdep = hw; 3876 hw->private_data = hdsp; 3877 strcpy(hw->name, "HDSP hwdep interface"); 3878 3879 hw->ops.open = snd_hdsp_hwdep_dummy_op; 3880 hw->ops.ioctl = snd_hdsp_hwdep_ioctl; 3881 hw->ops.release = snd_hdsp_hwdep_dummy_op; 3882 3883 return 0; 3884 } 3885 2816 3886 static int __devinit snd_hdsp_create_pcm(snd_card_t *card, 2817 3887 hdsp_t *hdsp) … … 2835 3905 } 2836 3906 2837 static in t __devinit snd_hdsp_initialize_firmware (hdsp_t *hdsp)3907 static inline int snd_hdsp_initialize_input_enable (hdsp_t *hdsp) 2838 3908 { 2839 3909 int i; 2840 u32 *firmware_ptr; 2841 2842 if (hdsp_check_for_iobox (hdsp)) { 2843 return -EIO; 2844 } 2845 3910 2846 3911 if (hdsp_fifo_wait (hdsp, 0, 100)) { 2847 3912 return -EIO; 2848 3913 } 2849 3914 2850 /* enable all channels */2851 2852 3915 for (i = 0; i < HDSP_MAX_CHANNELS; ++i) { 2853 3916 hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1); 2854 3917 hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1); 2855 3918 } 2856 2857 if (force_firmware[hdsp->dev] || (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { 2858 2859 snd_printk ("loading firmware\n"); 2860 2861 hdsp_write (hdsp, HDSP_jtagReg, HDSP_PROGRAM); 2862 hdsp_write (hdsp, HDSP_fifoData, 0); 2863 if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT) < 0) { 2864 snd_printk ("timeout waiting for firmware setup\n"); 2865 return -EIO; 2866 } 2867 2868 hdsp_write (hdsp, HDSP_jtagReg, HDSP_S_LOAD); 2869 hdsp_write (hdsp, HDSP_fifoData, 0); 2870 2871 if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT)) { 2872 hdsp->type = Multiface; 2873 hdsp_write (hdsp, HDSP_jtagReg, HDSP_VERSION_BIT); 2874 hdsp_write (hdsp, HDSP_jtagReg, HDSP_S_LOAD); 2875 hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT); 2876 } else { 2877 hdsp->type = Digiface; 2878 } 2879 2880 hdsp_write (hdsp, HDSP_jtagReg, HDSP_S_PROGRAM); 2881 hdsp_write (hdsp, HDSP_fifoData, 0); 2882 2883 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { 2884 snd_printk ("timeout waiting for download preparation\n"); 2885 return -EIO; 2886 } 2887 2888 hdsp_write (hdsp, HDSP_jtagReg, HDSP_S_LOAD); 2889 2890 if (hdsp->type == Digiface) { 2891 firmware_ptr = (u32 *) digiface_firmware; 2892 } else { 2893 firmware_ptr = (u32 *) multiface_firmware; 2894 } 2895 2896 for (i = 0; i < 24413; ++i) { 2897 hdsp_write(hdsp, HDSP_fifoData, firmware_ptr[i]); 2898 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) { 2899 snd_printk ("timeout during firmware loading\n"); 2900 return -EIO; 2901 } 2902 } 2903 2904 if (hdsp_fifo_wait (hdsp, 3, HDSP_LONG_WAIT)) { 2905 snd_printk ("timeout at end of firmware loading\n"); 2906 return -EIO; 2907 } 2908 2909 } else { 2910 2911 /* firmware already loaded, but we need to know what type 2912 of I/O box is connected. 2913 */ 2914 2915 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) { 2916 hdsp->type = Multiface; 2917 } else { 2918 hdsp->type = Digiface; 2919 } 2920 } 2921 2922 if (hdsp->type == Digiface) { 2923 snd_printk ("I/O Box is a Digiface\n"); 2924 hdsp->card_name = "RME Hammerfall DSP (Digiface)"; 3919 3920 return 0; 3921 } 3922 3923 static inline void snd_hdsp_initialize_channels(hdsp_t *hdsp) 3924 { 3925 if (hdsp->io_type == Digiface) { 3926 hdsp->card_name = "RME Hammerfall DSP + Digiface"; 2925 3927 hdsp->ss_channels = DIGIFACE_SS_CHANNELS; 2926 3928 hdsp->ds_channels = DIGIFACE_DS_CHANNELS; 2927 3929 } else { 2928 snd_printk ("I/O Box is a Multiface\n"); 2929 hdsp->card_name = "RME Hammerfall DSP (Multiface)"; 3930 hdsp->card_name = "RME Hammerfall DSP + Multiface"; 2930 3931 hdsp->ss_channels = MULTIFACE_SS_CHANNELS; 2931 3932 hdsp->ds_channels = MULTIFACE_DS_CHANNELS; 2932 3933 } 2933 3934 } 3935 3936 static inline void snd_hdsp_initialize_midi_flush (hdsp_t *hdsp) 3937 { 2934 3938 snd_hdsp_flush_midi_input (hdsp, 0); 2935 3939 snd_hdsp_flush_midi_input (hdsp, 1); … … 2938 3942 hdsp_write(hdsp, HDSP_jtagReg, HDSP_BIGENDIAN_MODE); 2939 3943 #endif 2940 3944 } 3945 3946 static int __devinit snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp) 3947 { 3948 int err; 3949 3950 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) { 3951 return err; 3952 } 3953 3954 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) { 3955 return err; 3956 } 3957 3958 if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) { 3959 return err; 3960 } 3961 3962 if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) { 3963 return err; 3964 } 3965 3966 snd_hdsp_proc_init(hdsp); 3967 3968 hdsp->last_spdif_sample_rate = -1; 3969 hdsp->system_sample_rate = -1; 3970 hdsp->last_external_sample_rate = -1; 3971 hdsp->last_internal_sample_rate = -1; 3972 hdsp->playback_pid = -1; 3973 hdsp->capture_pid = -1; 3974 hdsp->capture_substream = NULL; 3975 hdsp->playback_substream = NULL; 3976 3977 if ((err = snd_hdsp_set_defaults(hdsp)) < 0) { 3978 return err; 3979 } 3980 3981 hdsp_update_simple_mixer_controls(hdsp); 3982 3983 if (!(hdsp->state & HDSP_InitializationComplete)) { 3984 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, 3985 hdsp->port, hdsp->irq); 3986 3987 if ((err = snd_card_register(card)) < 0) { 3988 snd_printk("error registering card\n"); 3989 return err; 3990 } 3991 hdsp->state |= HDSP_InitializationComplete; 3992 } 3993 2941 3994 return 0; 2942 3995 } … … 2948 4001 struct pci_dev *pci = hdsp->pci; 2949 4002 int err; 2950 unsigned short rev;4003 int i; 2951 4004 2952 4005 hdsp->irq = -1; 4006 hdsp->state = 0; 2953 4007 hdsp->midi[0].rmidi = 0; 2954 4008 hdsp->midi[1].rmidi = 0; … … 2961 4015 hdsp->iobase = 0; 2962 4016 hdsp->res_port = 0; 4017 hdsp->io_type = Undefined; 4018 for (i = 0; i < HDSP_MAX_CHANNELS; ++i) 4019 hdsp->playback_mixer_ctls[i] = 0; 2963 4020 2964 4021 hdsp->card = card; … … 2966 4023 spin_lock_init(&hdsp->lock); 2967 4024 2968 pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &rev); 4025 tasklet_init(&hdsp->midi_tasklet, hdsp_midi_tasklet, (unsigned long)hdsp); 4026 4027 pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev); 2969 4028 strcpy(card->driver, "H-DSP"); 2970 4029 strcpy(card->mixername, "Xilinx FPGA"); 2971 4030 2972 switch ( rev & 0xff) {4031 switch (hdsp->firmware_rev & 0xff) { 2973 4032 case 0xa: 2974 4033 case 0xb: 4034 hdsp->card_name = "RME Hammerfall DSP"; 4035 break; 2975 4036 case 0x64: 2976 /* hdsp_initialize_firmware() will reset this */2977 hdsp->card_name = "RME Hammerfall DSP";2978 break;2979 4037 case 0x65: 4038 case 0x68: 4039 hdsp->card_name = "RME HDSP 9652"; 4040 break; 2980 4041 default: 2981 4042 return -ENODEV; … … 3010 4071 return err; 3011 4072 } 3012 3013 if ((err = snd_hdsp_initialize_firmware(hdsp)) < 0) { 4073 4074 if (hdsp_is_9652(hdsp)) { 4075 4076 if ((err = snd_hdsp_initialize_input_enable(hdsp)) != 0) { 4077 return err; 4078 } 4079 4080 hdsp->io_type = Digiface; 4081 4082 hdsp->ss_channels = DIGIFACE_SS_CHANNELS; 4083 hdsp->ds_channels = DIGIFACE_DS_CHANNELS; 4084 4085 snd_hdsp_initialize_midi_flush(hdsp); 4086 4087 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) { 4088 return err; 4089 } 4090 4091 } else { 4092 4093 if (hdsp_check_for_iobox (hdsp)) { 4094 /* no iobox connected, we defer initialization */ 4095 snd_printk("card initialization pending : waiting for firmware\n"); 4096 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) { 4097 return err; 4098 } 4099 return 0; 4100 } 4101 4102 if ((err = snd_hdsp_initialize_input_enable(hdsp)) != 0) { 4103 return err; 4104 } 4105 4106 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { 4107 snd_printk("card initialization pending : waiting for firmware\n"); 4108 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) { 4109 return err; 4110 } 4111 return 0; 4112 } 4113 4114 snd_printk("Firmware already loaded, initializing card.\n"); 4115 4116 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) { 4117 hdsp->io_type = Multiface; 4118 } else { 4119 hdsp->io_type = Digiface; 4120 } 4121 4122 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) { 4123 return err; 4124 } 4125 4126 snd_hdsp_initialize_channels(hdsp); 4127 4128 snd_hdsp_initialize_midi_flush(hdsp); 4129 4130 } 4131 4132 hdsp->state |= HDSP_FirmwareLoaded; 4133 4134 if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0) { 3014 4135 return err; 3015 4136 } 3016 3017 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) { 3018 return err; 3019 } 3020 3021 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) { 3022 return err; 3023 } 3024 3025 if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) { 3026 return err; 3027 } 3028 3029 if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) { 3030 return err; 3031 } 3032 3033 snd_hdsp_proc_init(hdsp); 3034 3035 hdsp->last_spdif_sample_rate = -1; 3036 hdsp->last_adat_sample_rate = -1; 3037 hdsp->playback_pid = -1; 3038 hdsp->capture_pid = -1; 3039 hdsp->capture_substream = NULL; 3040 hdsp->playback_substream = NULL; 3041 3042 snd_hdsp_set_defaults(hdsp); 3043 3044 return 0; 4137 4138 return 0; 3045 4139 } 3046 4140 3047 4141 static int snd_hdsp_free(hdsp_t *hdsp) 3048 4142 { 3049 /* stop the audio, and cancel all interrupts */ 3050 hdsp->control_register &= ~(HDSP_Start|HDSP_AudioInterruptEnable|HDSP_Midi0InterruptEnable|HDSP_Midi1InterruptEnable); 3051 hdsp_write (hdsp, HDSP_controlRegister, hdsp->control_register); 4143 if (hdsp->res_port) { 4144 /* stop the audio, and cancel all interrupts */ 4145 hdsp->control_register &= ~(HDSP_Start|HDSP_AudioInterruptEnable|HDSP_Midi0InterruptEnable|HDSP_Midi1InterruptEnable); 4146 hdsp_write (hdsp, HDSP_controlRegister, hdsp->control_register); 4147 } 3052 4148 3053 4149 if (hdsp->irq >= 0) 3054 4150 free_irq(hdsp->irq, (void *)hdsp); 3055 4151 3056 snd_hdsp_proc_done(hdsp);3057 4152 snd_hdsp_free_buffers(hdsp); 3058 4153 … … 3124 4219 3125 4220 static struct pci_driver driver = { 3126 .name = "RME Hammerfall DSP",4221 .name = "RME Hammerfall DSP", 3127 4222 .id_table = snd_hdsp_ids, 3128 .probe = snd_hdsp_probe,4223 .probe = snd_hdsp_probe, 3129 4224 .remove = __devexit_p(snd_hdsp_remove), 3130 4225 }; -
GPL/branches/alsa-resync1/alsa-kernel/pci/rme9652/rme9652.c
r224 r246 1947 1947 } 1948 1948 1949 voidsnd_rme9652_interrupt(int irq, void *dev_id, struct pt_regs *regs)1949 static irqreturn_t snd_rme9652_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1950 1950 { 1951 1951 rme9652_t *rme9652 = (rme9652_t *) dev_id; 1952 1952 1953 1953 if (!(rme9652_read(rme9652, RME9652_status_register) & RME9652_IRQ)) { 1954 return ;1954 return IRQ_NONE; 1955 1955 } 1956 1956 … … 1964 1964 snd_pcm_period_elapsed(rme9652->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream); 1965 1965 } 1966 return IRQ_HANDLED; 1966 1967 } 1967 1968 … … 2054 2055 runtime->status->hw_ptr = 0; 2055 2056 if (other) { 2056 snd_pcm_substream_t *s = substream; 2057 struct list_head *pos; 2058 snd_pcm_substream_t *s; 2057 2059 snd_pcm_runtime_t *oruntime = other->runtime; 2058 do{2059 s = s ->link_next;2060 snd_pcm_group_for_each(pos, substream) { 2061 s = snd_pcm_group_substream_entry(pos); 2060 2062 if (s == other) { 2061 2063 oruntime->status->hw_ptr = runtime->status->hw_ptr; 2062 2064 break; 2063 2065 } 2064 } while (s != substream);2066 } 2065 2067 } 2066 2068 return 0; … … 2200 2202 2201 2203 if (other) { 2202 snd_pcm_substream_t *s = substream; 2203 do { 2204 s = s->link_next; 2204 struct list_head *pos; 2205 snd_pcm_substream_t *s; 2206 snd_pcm_group_for_each(pos, substream) { 2207 s = snd_pcm_group_substream_entry(pos); 2205 2208 if (s == other) { 2206 2209 snd_pcm_trigger_done(s, substream); … … 2211 2214 goto _ok; 2212 2215 } 2213 } while (s != substream);2216 } 2214 2217 if (cmd == SNDRV_PCM_TRIGGER_START) { 2215 2218 if (!(running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) && … … 2405 2408 2406 2409 rme9652->creg_spdif_stream = rme9652->creg_spdif; 2407 rme9652->spdif_ctl-> access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;2410 rme9652->spdif_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; 2408 2411 snd_ctl_notify(rme9652->card, SNDRV_CTL_EVENT_MASK_VALUE | 2409 2412 SNDRV_CTL_EVENT_MASK_INFO, &rme9652->spdif_ctl->id); … … 2423 2426 spin_unlock_irqrestore(&rme9652->lock, flags); 2424 2427 2425 rme9652->spdif_ctl-> access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;2428 rme9652->spdif_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; 2426 2429 snd_ctl_notify(rme9652->card, SNDRV_CTL_EVENT_MASK_VALUE | 2427 2430 SNDRV_CTL_EVENT_MASK_INFO, &rme9652->spdif_ctl->id); -
GPL/branches/alsa-resync1/alsa-kernel/pci/sonicvibes.c
r224 r246 602 602 } 603 603 604 static voidsnd_sonicvibes_interrupt(int irq, void *dev_id, struct pt_regs *regs)605 { 606 sonicvibes_t *sonic = snd_magic_cast(sonicvibes_t, dev_id, return );604 static irqreturn_t snd_sonicvibes_interrupt(int irq, void *dev_id, struct pt_regs *regs) 605 { 606 sonicvibes_t *sonic = snd_magic_cast(sonicvibes_t, dev_id, return IRQ_NONE); 607 607 unsigned char status; 608 608 609 609 status = inb(SV_REG(sonic, STATUS)); 610 610 if (!(status & (SV_DMAA_IRQ | SV_DMAC_IRQ | SV_MIDI_IRQ))) 611 return ;611 return IRQ_NONE; 612 612 if (status == 0xff) { /* failure */ 613 613 outb(sonic->irqmask = ~0, SV_REG(sonic, IRQMASK)); 614 614 snd_printk("IRQ failure - interrupts disabled!!\n"); 615 return ;615 return IRQ_HANDLED; 616 616 } 617 617 if (sonic->pcm) { … … 660 660 snd_ctl_notify(sonic->card, SNDRV_CTL_EVENT_MASK_VALUE, &sonic->master_volume->id); 661 661 } 662 return IRQ_HANDLED; 662 663 } 663 664 -
GPL/branches/alsa-resync1/alsa-kernel/pci/trident/trident_main.c
r224 r246 2715 2715 .name = "PCM Front Playback Volume", 2716 2716 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, 2717 .count = 32, 2717 2718 .info = snd_trident_pcm_vol_control_info, 2718 2719 .get = snd_trident_pcm_vol_control_get, … … 2776 2777 .name = "PCM Pan Playback Control", 2777 2778 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, 2779 .count = 32, 2778 2780 .info = snd_trident_pcm_pan_control_info, 2779 2781 .get = snd_trident_pcm_pan_control_get, … … 2829 2831 .name = "PCM Reverb Playback Volume", 2830 2832 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, 2833 .count = 32, 2831 2834 .info = snd_trident_pcm_rvol_control_info, 2832 2835 .get = snd_trident_pcm_rvol_control_get, -
GPL/branches/alsa-resync1/alsa-kernel/pci/ymfpci/ymfpci_main.c
r224 r246 1368 1368 { 1369 1369 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, 1370 .iface = SNDRV_CTL_ELEM_IFACE_PCM,1371 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM),1370 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1371 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM), 1372 1372 .info = snd_ymfpci_spdif_stream_info, 1373 1373 .get = snd_ymfpci_spdif_stream_get,
Note:
See TracChangeset
for help on using the changeset viewer.
