30 #include <linux/module.h>
38 #define SNDRV_LEGACY_FIND_FREE_IRQ
39 #define SNDRV_LEGACY_FIND_FREE_DMA
49 "{Dynasonix,Dynasonix Pro},"
50 "{Panasonic,PCA761AW}}");
76 #define PFX "interwave-stb: "
77 #define INTERWAVE_DRIVER "snd_interwave_stb"
78 #define INTERWAVE_PNP_DRIVER "interwave-stb"
80 #define PFX "interwave: "
81 #define INTERWAVE_DRIVER "snd_interwave"
82 #define INTERWAVE_PNP_DRIVER "interwave"
99 MODULE_PARM_DESC(port_tc,
"Tone control (TEA6330T - i2c bus) port # for InterWave driver.");
108 MODULE_PARM_DESC(joystick_dac,
"Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for InterWave driver.");
112 MODULE_PARM_DESC(pcm_channels,
"Reserved PCM channels for InterWave driver.");
136 static int isa_registered;
137 static int pnp_registered;
142 { .
id =
"GRV0001", .devs = { { .id =
"GRV0000" } } },
144 { .id =
"STB011a", .devs = { { .id =
"STB0010" } } },
146 { .id =
"DXP3201", .devs = { { .id =
"DXP0010" } } },
149 { .id =
"CDC1111", .devs = { { .id =
"CDC1112" } } },
151 { .id =
"ADV55ff", .devs = { { .id =
"ADV0010" } } },
153 { .id =
"ADV550a", .devs = { { .id =
"ADV0010" } } },
156 { .id =
"ADV550a", .devs = { { .id =
"ADV0010" }, { .id =
"ADV0015" } } },
174 outb((data << 1) | ctrl, port);
178 static int snd_interwave_i2c_getclockline(
struct snd_i2c_bus *bus)
190 static int snd_interwave_i2c_getdataline(
struct snd_i2c_bus *bus,
int ack)
197 res = (
inb(port) & 2) >> 1;
205 .
setlines = snd_interwave_i2c_setlines,
206 .getclock = snd_interwave_i2c_getclockline,
207 .getdata = snd_interwave_i2c_getdataline,
224 if (gus->
gf1.port == 0x250) {
227 while (port <= 0x380) {
235 if (iwcard->i2c_res ==
NULL) {
244 bus->
hw_ops.
bit = &snd_interwave_i2c_bit_ops;
281 spin_unlock_irqrestore(&gus->
reg_lock, flags);
282 snd_printdd(
"[0x%lx] InterWave check - rev1=0x%x, rev2=0x%x\n", gus->
gf1.port, rev1, rev2);
283 if ((rev1 & 0xf0) == (rev2 & 0xf0) &&
284 (rev1 & 0x0f) != (rev2 & 0x0f)) {
287 strcpy(gus->
card->shortname,
"AMD InterWave");
292 return snd_interwave_detect_stb(iwcard, gus, dev, rbus);
317 }
while (loop && --max > 0);
335 for (idx = 0; idx < 4; idx++) {
338 for (local = idx << 22;
339 local < (idx << 22) + 0x400000;
340 local += 0x40000, d++) {
345 "local + 1 = 0x%x, idx << 22 = 0x%x\n",
360 sizes[0], sizes[1], sizes[2], sizes[3]);
382 static unsigned int lmc[13] =
384 0x00000001, 0x00000101, 0x01010101, 0x00000401,
385 0x04040401, 0x00040101, 0x04040101, 0x00000004,
386 0x00000404, 0x04040404, 0x00000010, 0x00001010,
391 unsigned int i, lmct;
393 unsigned char iwave[8];
396 snd_interwave_reset(gus);
410 snd_interwave_bank_sizes(gus, psizes);
411 lmct = (psizes[3] << 24) | (psizes[2] << 16) |
412 (psizes[1] << 8) | psizes[0];
417 if (lmct == lmc[i]) {
422 snd_interwave_bank_sizes(gus, psizes);
427 for (i = 0; i < 4; i++) {
428 gus->
gf1.mem_alloc.banks_8[
i].address =
429 gus->
gf1.mem_alloc.banks_16[
i].address = i << 22;
430 gus->
gf1.mem_alloc.banks_8[
i].size =
431 gus->
gf1.mem_alloc.banks_16[
i].size = psizes[
i] << 18;
440 gus->
gf1.rom_banks = 0;
441 gus->
gf1.rom_memory = 0;
442 for (bank_pos = 0; bank_pos < 16
L * 1024
L * 1024
L; bank_pos += 4L * 1024L * 1024L) {
443 for (i = 0; i < 8; ++
i)
445 #ifdef CONFIG_SND_DEBUG_ROM
449 if (
strncmp(iwave,
"INTRWAVE", 8))
452 for (i = 0; i <
sizeof(
struct rom_hdr); i++)
454 #ifdef CONFIG_SND_DEBUG_ROM
459 gus->
gf1.rom_banks++;
460 gus->
gf1.rom_present |= 1 << (bank_pos >> 22);
467 if (gus->
gf1.rom_memory > 0) {
468 if (gus->
gf1.rom_banks == 1 && gus->
gf1.rom_present == 8)
469 gus->
card->type = SNDRV_CARD_TYPE_IW_DYNASONIC;
474 if (!gus->
gf1.enh_mode)
475 snd_interwave_reset(gus);
491 spin_unlock_irqrestore(&gus->
reg_lock, flags);
531 for (idx = 0; idx <
ARRAY_SIZE(snd_interwave_controls); idx++)
540 strcpy(
id2.name,
"Synth Playback Switch");
544 strcpy(
id2.name,
"Synth Playback Volume");
569 if (iwcard->dev ==
NULL)
574 if (iwcard->devtc ==
NULL)
585 if (pnp_port_start(pdev, 0) + 0x100 != pnp_port_start(pdev, 1) ||
586 pnp_port_start(pdev, 0) + 0x10c != pnp_port_start(pdev, 2)) {
590 port[
dev] = pnp_port_start(pdev, 0);
595 snd_printdd(
"isapnp IW: sb port=0x%llx, gf1 port=0x%llx, codec port=0x%llx\n",
596 (
unsigned long long)pnp_port_start(pdev, 0),
597 (
unsigned long long)pnp_port_start(pdev, 1),
598 (
unsigned long long)pnp_port_start(pdev, 2));
599 snd_printdd(
"isapnp IW: dma1=%i, dma2=%i, irq=%i\n", dma1[dev], dma2[dev], irq[dev]);
602 pdev = iwcard->devtc;
606 snd_printk(
KERN_ERR "InterWave ToneControl PnP configure failure (out of resources?)\n");
609 port_tc[
dev] = pnp_port_start(pdev, 0);
610 snd_printdd(
"isapnp IW: tone control port=0x%lx\n", port_tc[dev]);
616 static void snd_interwave_free(
struct snd_card *card)
625 if (iwcard->
irq >= 0)
629 static int snd_interwave_card_new(
int dev,
struct snd_card **cardp)
649 int xirq, xdma1, xdma2;
668 pcm_channels[dev], effect[dev], &gus)) < 0)
671 if ((err = snd_interwave_detect(iwcard, gus, dev
681 snd_interwave_init(dev, gus);
682 snd_interwave_detect_memory(gus);
687 "InterWave", iwcard)) {
694 gus->
gf1.port + 0x10c, -1, xirq,
695 xdma2 < 0 ? xdma1 : xdma2, xdma1,
719 if (pcm_channels[dev] > 0) {
724 err = snd_interwave_mixer(wss);
734 strcpy(
id1.name,
"Master Playback Switch");
739 strcpy(
id1.name,
"Master Playback Volume");
753 str =
"AMD InterWave";
754 if (gus->
gf1.rom_banks == 1 && gus->
gf1.rom_present == 8)
755 str =
"Dynasonic 3-D";
757 str =
"InterWave STB";
778 static int __devinit snd_interwave_isa_probe1(
int dev,
struct device *devptr)
783 err = snd_interwave_card_new(dev, &card);
788 if ((err = snd_interwave_probe(card, dev)) < 0) {
812 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
813 static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1};
816 if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) {
822 if ((dma1[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) {
828 if ((dma2[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) {
835 return snd_interwave_isa_probe1(dev, pdev);
837 static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260};
839 for (i = 0; i <
ARRAY_SIZE(possible_ports); i++) {
840 port[
dev] = possible_ports[
i];
841 err = snd_interwave_isa_probe1(dev, pdev);
849 static int __devexit snd_interwave_isa_remove(
struct device *devptr,
unsigned int dev)
856 static struct isa_driver snd_interwave_driver = {
857 .match = snd_interwave_isa_match,
858 .probe = snd_interwave_isa_probe,
875 if (
enable[dev] && isapnp[dev])
878 if (dev >= SNDRV_CARDS)
881 res = snd_interwave_card_new(dev, &card);
885 if ((res = snd_interwave_pnp(dev, card->
private_data, pcard, pid)) < 0) {
890 if ((res = snd_interwave_probe(card, dev)) < 0) {
894 pnp_set_card_drvdata(pcard, card);
902 pnp_set_card_drvdata(pcard,
NULL);
908 .id_table = snd_interwave_pnpids,
909 .probe = snd_interwave_pnp_detect,
916 static int __init alsa_card_interwave_init(
void)
935 static void __exit alsa_card_interwave_exit(
void)