aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt8
-rw-r--r--include/sound/sscape_ioctl.h21
-rw-r--r--sound/isa/Kconfig8
-rw-r--r--sound/isa/sscape.c328
4 files changed, 116 insertions, 249 deletions
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index 1c8eb4518ce0..cf985257ae40 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -1631,7 +1631,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1631 Module snd-sscape 1631 Module snd-sscape
1632 ----------------- 1632 -----------------
1633 1633
1634 Module for ENSONIQ SoundScape PnP cards. 1634 Module for ENSONIQ SoundScape cards.
1635 1635
1636 port - Port # (PnP setup) 1636 port - Port # (PnP setup)
1637 wss_port - WSS Port # (PnP setup) 1637 wss_port - WSS Port # (PnP setup)
@@ -1640,9 +1640,9 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1640 dma - DMA # (PnP setup) 1640 dma - DMA # (PnP setup)
1641 dma2 - 2nd DMA # (PnP setup, -1 to disable) 1641 dma2 - 2nd DMA # (PnP setup, -1 to disable)
1642 1642
1643 This module supports multiple cards. ISA PnP must be enabled. 1643 This module supports multiple cards.
1644 You need sscape_ctl tool in alsa-tools package for loading 1644
1645 the microcode. 1645 The driver requires the firmware loader support on kernel.
1646 1646
1647 Module snd-sun-amd7930 (on sparc only) 1647 Module snd-sun-amd7930 (on sparc only)
1648 -------------------------------------- 1648 --------------------------------------
diff --git a/include/sound/sscape_ioctl.h b/include/sound/sscape_ioctl.h
deleted file mode 100644
index 0d8885969c64..000000000000
--- a/include/sound/sscape_ioctl.h
+++ /dev/null
@@ -1,21 +0,0 @@
1#ifndef SSCAPE_IOCTL_H
2#define SSCAPE_IOCTL_H
3
4
5struct sscape_bootblock
6{
7 unsigned char code[256];
8 unsigned version;
9};
10
11#define SSCAPE_MICROCODE_SIZE 65536
12
13struct sscape_microcode
14{
15 unsigned char __user *code;
16};
17
18#define SND_SSCAPE_LOAD_BOOTB _IOWR('P', 100, struct sscape_bootblock)
19#define SND_SSCAPE_LOAD_MCODE _IOW ('P', 101, struct sscape_microcode)
20
21#endif
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index b90fc164a79c..02fe81ca88fd 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -372,9 +372,9 @@ config SND_SGALAXY
372 372
373config SND_SSCAPE 373config SND_SSCAPE
374 tristate "Ensoniq SoundScape driver" 374 tristate "Ensoniq SoundScape driver"
375 select SND_HWDEP
376 select SND_MPU401_UART 375 select SND_MPU401_UART
377 select SND_WSS_LIB 376 select SND_WSS_LIB
377 select FW_LOADER
378 help 378 help
379 Say Y here to include support for Ensoniq SoundScape 379 Say Y here to include support for Ensoniq SoundScape
380 and Ensoniq OEM soundcards. 380 and Ensoniq OEM soundcards.
@@ -382,7 +382,11 @@ config SND_SSCAPE
382 The PCM audio is supported on SoundScape Classic, Elite, PnP 382 The PCM audio is supported on SoundScape Classic, Elite, PnP
383 and VIVO cards. The supported OEM cards are SPEA Media FX and 383 and VIVO cards. The supported OEM cards are SPEA Media FX and
384 Reveal SC-600. 384 Reveal SC-600.
385 The MIDI support is very experimental. 385 The MIDI support is very experimental and requires binary
386 firmware files called "scope.cod" and "sndscape.co?" where the
387 ? is digit 0, 1, 2, 3 or 4. The firmware files can be found
388 in DOS or Windows driver packages. One has to put the firmware
389 files into the /lib/firmware directory.
386 390
387 To compile this driver as a module, choose M here: the module 391 To compile this driver as a module, choose M here: the module
388 will be called snd-sscape. 392 will be called snd-sscape.
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index b11c35f6aefe..1ce465cc66a8 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Low-level ALSA driver for the ENSONIQ SoundScape PnP 2 * Low-level ALSA driver for the ENSONIQ SoundScape
3 * Copyright (c) by Chris Rankin 3 * Copyright (c) by Chris Rankin
4 * 4 *
5 * This driver was written in part using information obtained from 5 * This driver was written in part using information obtained from
@@ -25,22 +25,26 @@
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/isa.h> 26#include <linux/isa.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/firmware.h>
28#include <linux/pnp.h> 29#include <linux/pnp.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
30#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
31#include <asm/dma.h> 32#include <asm/dma.h>
32#include <sound/core.h> 33#include <sound/core.h>
33#include <sound/hwdep.h>
34#include <sound/wss.h> 34#include <sound/wss.h>
35#include <sound/mpu401.h> 35#include <sound/mpu401.h>
36#include <sound/initval.h> 36#include <sound/initval.h>
37 37
38#include <sound/sscape_ioctl.h>
39
40 38
41MODULE_AUTHOR("Chris Rankin"); 39MODULE_AUTHOR("Chris Rankin");
42MODULE_DESCRIPTION("ENSONIQ SoundScape PnP driver"); 40MODULE_DESCRIPTION("ENSONIQ SoundScape driver");
43MODULE_LICENSE("GPL"); 41MODULE_LICENSE("GPL");
42MODULE_FIRMWARE("sndscape.co0");
43MODULE_FIRMWARE("sndscape.co1");
44MODULE_FIRMWARE("sndscape.co2");
45MODULE_FIRMWARE("sndscape.co3");
46MODULE_FIRMWARE("sndscape.co4");
47MODULE_FIRMWARE("scope.cod");
44 48
45static int index[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IDX; 49static int index[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IDX;
46static char* id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_STR; 50static char* id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_STR;
@@ -142,14 +146,12 @@ struct soundscape {
142 struct resource *wss_res; 146 struct resource *wss_res;
143 struct snd_wss *chip; 147 struct snd_wss *chip;
144 struct snd_mpu401 *mpu; 148 struct snd_mpu401 *mpu;
145 struct snd_hwdep *hw;
146 149
147 /* 150 /*
148 * The MIDI device won't work until we've loaded 151 * The MIDI device won't work until we've loaded
149 * its firmware via a hardware-dependent device IOCTL 152 * its firmware via a hardware-dependent device IOCTL
150 */ 153 */
151 spinlock_t fwlock; 154 spinlock_t fwlock;
152 int hw_in_use;
153 unsigned long midi_usage; 155 unsigned long midi_usage;
154 unsigned char midi_vol; 156 unsigned char midi_vol;
155}; 157};
@@ -167,12 +169,6 @@ static inline struct soundscape *get_mpu401_soundscape(struct snd_mpu401 * mpu)
167 return (struct soundscape *) (mpu->private_data); 169 return (struct soundscape *) (mpu->private_data);
168} 170}
169 171
170static inline struct soundscape *get_hwdep_soundscape(struct snd_hwdep * hw)
171{
172 return (struct soundscape *) (hw->private_data);
173}
174
175
176/* 172/*
177 * Allocates some kernel memory that we can use for DMA. 173 * Allocates some kernel memory that we can use for DMA.
178 * I think this means that the memory has to map to 174 * I think this means that the memory has to map to
@@ -393,12 +389,12 @@ static int obp_startup_ack(struct soundscape *s, unsigned timeout)
393 389
394 do { 390 do {
395 unsigned long flags; 391 unsigned long flags;
396 unsigned char x; 392 int x;
397 393
398 spin_lock_irqsave(&s->lock, flags); 394 spin_lock_irqsave(&s->lock, flags);
399 x = inb(HOST_DATA_IO(s->io_base)); 395 x = host_read_unsafe(s->io_base);
400 spin_unlock_irqrestore(&s->lock, flags); 396 spin_unlock_irqrestore(&s->lock, flags);
401 if ((x & 0xfe) == 0xfe) 397 if (x == 0xfe || x == 0xff)
402 return 1; 398 return 1;
403 399
404 msleep(10); 400 msleep(10);
@@ -420,10 +416,10 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout)
420 416
421 do { 417 do {
422 unsigned long flags; 418 unsigned long flags;
423 unsigned char x; 419 int x;
424 420
425 spin_lock_irqsave(&s->lock, flags); 421 spin_lock_irqsave(&s->lock, flags);
426 x = inb(HOST_DATA_IO(s->io_base)); 422 x = host_read_unsafe(s->io_base);
427 spin_unlock_irqrestore(&s->lock, flags); 423 spin_unlock_irqrestore(&s->lock, flags);
428 if (x == 0xfe) 424 if (x == 0xfe)
429 return 1; 425 return 1;
@@ -438,14 +434,14 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout)
438 * Upload a byte-stream into the SoundScape using DMA channel A. 434 * Upload a byte-stream into the SoundScape using DMA channel A.
439 */ 435 */
440static int upload_dma_data(struct soundscape *s, 436static int upload_dma_data(struct soundscape *s,
441 const unsigned char __user *data, 437 const unsigned char *data,
442 size_t size) 438 size_t size)
443{ 439{
444 unsigned long flags; 440 unsigned long flags;
445 struct snd_dma_buffer dma; 441 struct snd_dma_buffer dma;
446 int ret; 442 int ret;
447 443
448 if (!get_dmabuf(&dma, PAGE_ALIGN(size))) 444 if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024)))
449 return -ENOMEM; 445 return -ENOMEM;
450 446
451 spin_lock_irqsave(&s->lock, flags); 447 spin_lock_irqsave(&s->lock, flags);
@@ -458,7 +454,6 @@ static int upload_dma_data(struct soundscape *s,
458 /* 454 /*
459 * Enable the DMA channels and configure them ... 455 * Enable the DMA channels and configure them ...
460 */ 456 */
461 sscape_write_unsafe(s->io_base, GA_DMACFG_REG, 0x50);
462 sscape_write_unsafe(s->io_base, GA_DMAA_REG, (s->chip->dma1 << 4) | DMA_8BIT); 457 sscape_write_unsafe(s->io_base, GA_DMAA_REG, (s->chip->dma1 << 4) | DMA_8BIT);
463 sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20); 458 sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20);
464 459
@@ -468,35 +463,17 @@ static int upload_dma_data(struct soundscape *s,
468 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x80); 463 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x80);
469 464
470 /* 465 /*
471 * Upload the user's data (firmware?) to the SoundScape 466 * Upload the firmware to the SoundScape
472 * board through the DMA channel ... 467 * board through the DMA channel ...
473 */ 468 */
474 while (size != 0) { 469 while (size != 0) {
475 unsigned long len; 470 unsigned long len;
476 471
477 /*
478 * Apparently, copying to/from userspace can sleep.
479 * We are therefore forbidden from holding any
480 * spinlocks while we copy ...
481 */
482 spin_unlock_irqrestore(&s->lock, flags);
483
484 /*
485 * Remember that the data that we want to DMA
486 * comes from USERSPACE. We have already verified
487 * the userspace pointer ...
488 */
489 len = min(size, dma.bytes); 472 len = min(size, dma.bytes);
490 len -= __copy_from_user(dma.area, data, len); 473 memcpy(dma.area, data, len);
491 data += len; 474 data += len;
492 size -= len; 475 size -= len;
493 476
494 /*
495 * Grab that spinlock again, now that we've
496 * finished copying!
497 */
498 spin_lock_irqsave(&s->lock, flags);
499
500 snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE); 477 snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE);
501 sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG); 478 sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG);
502 if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) { 479 if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) {
@@ -512,6 +489,7 @@ static int upload_dma_data(struct soundscape *s,
512 } /* while */ 489 } /* while */
513 490
514 set_host_mode_unsafe(s->io_base); 491 set_host_mode_unsafe(s->io_base);
492 outb(0x0, s->io_base);
515 493
516 /* 494 /*
517 * Boot the board ... (I think) 495 * Boot the board ... (I think)
@@ -537,7 +515,7 @@ _release_dma:
537 /* 515 /*
538 * NOTE!!! We are NOT holding any spinlocks at this point !!! 516 * NOTE!!! We are NOT holding any spinlocks at this point !!!
539 */ 517 */
540 sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_ODIE ? 0x70 : 0x40)); 518 sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_OPUS ? 0x40 : 0x70));
541 free_dmabuf(&dma); 519 free_dmabuf(&dma);
542 520
543 return ret; 521 return ret;
@@ -547,162 +525,69 @@ _release_dma:
547 * Upload the bootblock(?) into the SoundScape. The only 525 * Upload the bootblock(?) into the SoundScape. The only
548 * purpose of this block of code seems to be to tell 526 * purpose of this block of code seems to be to tell
549 * us which version of the microcode we should be using. 527 * us which version of the microcode we should be using.
550 *
551 * NOTE: The boot-block data resides in USER-SPACE!!!
552 * However, we have already verified its memory
553 * addresses by the time we get here.
554 */ 528 */
555static int sscape_upload_bootblock(struct soundscape *sscape, struct sscape_bootblock __user *bb) 529static int sscape_upload_bootblock(struct snd_card *card)
556{ 530{
531 struct soundscape *sscape = get_card_soundscape(card);
557 unsigned long flags; 532 unsigned long flags;
533 const struct firmware *init_fw = NULL;
558 int data = 0; 534 int data = 0;
559 int ret; 535 int ret;
560 536
561 ret = upload_dma_data(sscape, bb->code, sizeof(bb->code)); 537 ret = request_firmware(&init_fw, "scope.cod", card->dev);
562 538 if (ret < 0) {
563 spin_lock_irqsave(&sscape->lock, flags); 539 snd_printk(KERN_ERR "Error loading scope.cod");
564 if (ret == 0) { 540 return ret;
565 data = host_read_ctrl_unsafe(sscape->io_base, 100);
566 }
567 set_midi_mode_unsafe(sscape->io_base);
568 spin_unlock_irqrestore(&sscape->lock, flags);
569
570 if (ret == 0) {
571 if (data < 0) {
572 snd_printk(KERN_ERR "sscape: timeout reading firmware version\n");
573 ret = -EAGAIN;
574 }
575 else if (__copy_to_user(&bb->version, &data, sizeof(bb->version))) {
576 ret = -EFAULT;
577 }
578 } 541 }
542 ret = upload_dma_data(sscape, init_fw->data, init_fw->size);
579 543
580 return ret; 544 release_firmware(init_fw);
581}
582 545
583/* 546 spin_lock_irqsave(&sscape->lock, flags);
584 * Upload the microcode into the SoundScape. The 547 if (ret == 0)
585 * microcode is 64K of data, and if we try to copy 548 data = host_read_ctrl_unsafe(sscape->io_base, 100);
586 * it into a local variable then we will SMASH THE
587 * KERNEL'S STACK! We therefore leave it in USER
588 * SPACE, and save ourselves from copying it at all.
589 */
590static int sscape_upload_microcode(struct soundscape *sscape,
591 const struct sscape_microcode __user *mc)
592{
593 unsigned long flags;
594 char __user *code;
595 int err;
596
597 /*
598 * We are going to have to copy this data into a special
599 * DMA-able buffer before we can upload it. We shall therefore
600 * just check that the data pointer is valid for now.
601 *
602 * NOTE: This buffer is 64K long! That's WAY too big to
603 * copy into a stack-temporary anyway.
604 */
605 if ( get_user(code, &mc->code) ||
606 !access_ok(VERIFY_READ, code, SSCAPE_MICROCODE_SIZE) )
607 return -EFAULT;
608 549
609 if ((err = upload_dma_data(sscape, code, SSCAPE_MICROCODE_SIZE)) == 0) { 550 if (data & 0x10)
610 snd_printk(KERN_INFO "sscape: MIDI firmware loaded\n"); 551 sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2f);
611 }
612 552
613 spin_lock_irqsave(&sscape->lock, flags);
614 set_midi_mode_unsafe(sscape->io_base);
615 spin_unlock_irqrestore(&sscape->lock, flags); 553 spin_unlock_irqrestore(&sscape->lock, flags);
616 554
617 initialise_mpu401(sscape->mpu); 555 data &= 0xf;
556 if (ret == 0 && data > 7) {
557 snd_printk(KERN_ERR "timeout reading firmware version\n");
558 ret = -EAGAIN;
559 }
618 560
619 return err; 561 return (ret == 0) ? data : ret;
620} 562}
621 563
622/* 564/*
623 * Hardware-specific device functions, to implement special 565 * Upload the microcode into the SoundScape.
624 * IOCTLs for the SoundScape card. This is how we upload
625 * the microcode into the card, for example, and so we
626 * must ensure that no two processes can open this device
627 * simultaneously, and that we can't open it at all if
628 * someone is using the MIDI device.
629 */ 566 */
630static int sscape_hw_open(struct snd_hwdep * hw, struct file *file) 567static int sscape_upload_microcode(struct snd_card *card, int version)
631{ 568{
632 register struct soundscape *sscape = get_hwdep_soundscape(hw); 569 struct soundscape *sscape = get_card_soundscape(card);
633 unsigned long flags; 570 const struct firmware *init_fw = NULL;
571 char name[14];
634 int err; 572 int err;
635 573
636 spin_lock_irqsave(&sscape->fwlock, flags); 574 snprintf(name, sizeof(name), "sndscape.co%d", version);
637 575
638 if ((sscape->midi_usage != 0) || sscape->hw_in_use) { 576 err = request_firmware(&init_fw, name, card->dev);
639 err = -EBUSY; 577 if (err < 0) {
640 } else { 578 snd_printk(KERN_ERR "Error loading sndscape.co%d", version);
641 sscape->hw_in_use = 1; 579 return err;
642 err = 0;
643 } 580 }
581 err = upload_dma_data(sscape, init_fw->data, init_fw->size);
582 if (err == 0)
583 snd_printk(KERN_INFO "MIDI firmware loaded %d KBs\n",
584 init_fw->size >> 10);
644 585
645 spin_unlock_irqrestore(&sscape->fwlock, flags); 586 release_firmware(init_fw);
646 return err;
647}
648
649static int sscape_hw_release(struct snd_hwdep * hw, struct file *file)
650{
651 register struct soundscape *sscape = get_hwdep_soundscape(hw);
652 unsigned long flags;
653
654 spin_lock_irqsave(&sscape->fwlock, flags);
655 sscape->hw_in_use = 0;
656 spin_unlock_irqrestore(&sscape->fwlock, flags);
657 return 0;
658}
659
660static int sscape_hw_ioctl(struct snd_hwdep * hw, struct file *file,
661 unsigned int cmd, unsigned long arg)
662{
663 struct soundscape *sscape = get_hwdep_soundscape(hw);
664 int err = -EBUSY;
665
666 switch (cmd) {
667 case SND_SSCAPE_LOAD_BOOTB:
668 {
669 register struct sscape_bootblock __user *bb = (struct sscape_bootblock __user *) arg;
670
671 /*
672 * We are going to have to copy this data into a special
673 * DMA-able buffer before we can upload it. We shall therefore
674 * just check that the data pointer is valid for now ...
675 */
676 if ( !access_ok(VERIFY_READ, bb->code, sizeof(bb->code)) )
677 return -EFAULT;
678
679 /*
680 * Now check that we can write the firmware version number too...
681 */
682 if ( !access_ok(VERIFY_WRITE, &bb->version, sizeof(bb->version)) )
683 return -EFAULT;
684
685 err = sscape_upload_bootblock(sscape, bb);
686 }
687 break;
688
689 case SND_SSCAPE_LOAD_MCODE:
690 {
691 register const struct sscape_microcode __user *mc = (const struct sscape_microcode __user *) arg;
692
693 err = sscape_upload_microcode(sscape, mc);
694 }
695 break;
696
697 default:
698 err = -EINVAL;
699 break;
700 } /* switch */
701 587
702 return err; 588 return err;
703} 589}
704 590
705
706/* 591/*
707 * Mixer control for the SoundScape's MIDI device. 592 * Mixer control for the SoundScape's MIDI device.
708 */ 593 */
@@ -920,7 +805,7 @@ static int mpu401_open(struct snd_mpu401 * mpu)
920 805
921 spin_lock_irqsave(&sscape->fwlock, flags); 806 spin_lock_irqsave(&sscape->fwlock, flags);
922 807
923 if (sscape->hw_in_use || (sscape->midi_usage == ULONG_MAX)) { 808 if (sscape->midi_usage == ULONG_MAX) {
924 err = -EBUSY; 809 err = -EBUSY;
925 } else { 810 } else {
926 ++(sscape->midi_usage); 811 ++(sscape->midi_usage);
@@ -1053,13 +938,6 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1053 } 938 }
1054 } 939 }
1055 940
1056 strcpy(card->driver, "SoundScape");
1057 strcpy(card->shortname, pcm->name);
1058 snprintf(card->longname, sizeof(card->longname),
1059 "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n",
1060 pcm->name, chip->port, chip->irq,
1061 chip->dma1, chip->dma2);
1062
1063 sscape->chip = chip; 941 sscape->chip = chip;
1064 } 942 }
1065 943
@@ -1162,29 +1040,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1162 return -ENXIO; 1040 return -ENXIO;
1163 } 1041 }
1164 1042
1165 if (sscape->type != SSCAPE_VIVO) {
1166 /*
1167 * Now create the hardware-specific device so that we can
1168 * load the microcode into the on-board processor.
1169 * We cannot use the MPU-401 MIDI system until this firmware
1170 * has been loaded into the card.
1171 */
1172 err = snd_hwdep_new(card, "MC68EC000", 0, &(sscape->hw));
1173 if (err < 0) {
1174 printk(KERN_ERR "sscape: Failed to create "
1175 "firmware device\n");
1176 goto _release_dma;
1177 }
1178 strlcpy(sscape->hw->name, "SoundScape M68K",
1179 sizeof(sscape->hw->name));
1180 sscape->hw->name[sizeof(sscape->hw->name) - 1] = '\0';
1181 sscape->hw->iface = SNDRV_HWDEP_IFACE_SSCAPE;
1182 sscape->hw->ops.open = sscape_hw_open;
1183 sscape->hw->ops.release = sscape_hw_release;
1184 sscape->hw->ops.ioctl = sscape_hw_ioctl;
1185 sscape->hw->private_data = sscape;
1186 }
1187
1188 /* 1043 /*
1189 * Tell the on-board devices where their resources are (I think - 1044 * Tell the on-board devices where their resources are (I think -
1190 * I can't be sure without a datasheet ... So many magic values!) 1045 * I can't be sure without a datasheet ... So many magic values!)
@@ -1222,28 +1077,56 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1222 wss_port[dev], irq[dev]); 1077 wss_port[dev], irq[dev]);
1223 goto _release_dma; 1078 goto _release_dma;
1224 } 1079 }
1080 strcpy(card->driver, "SoundScape");
1081 strcpy(card->shortname, name);
1082 snprintf(card->longname, sizeof(card->longname),
1083 "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n",
1084 name, sscape->chip->port, sscape->chip->irq,
1085 sscape->chip->dma1, sscape->chip->dma2);
1086
1225#define MIDI_DEVNUM 0 1087#define MIDI_DEVNUM 0
1226 if (sscape->type != SSCAPE_VIVO) { 1088 if (sscape->type != SSCAPE_VIVO) {
1227 err = create_mpu401(card, MIDI_DEVNUM, port[dev], mpu_irq[dev]); 1089 err = sscape_upload_bootblock(card);
1228 if (err < 0) { 1090 if (err >= 0)
1229 printk(KERN_ERR "sscape: Failed to create " 1091 err = sscape_upload_microcode(card, err);
1230 "MPU-401 device at 0x%lx\n",
1231 port[dev]);
1232 goto _release_dma;
1233 }
1234 1092
1235 /* 1093 if (err == 0) {
1236 * Enable the master IRQ ... 1094 err = create_mpu401(card, MIDI_DEVNUM, port[dev],
1237 */ 1095 mpu_irq[dev]);
1238 sscape_write(sscape, GA_INTENA_REG, 0x80); 1096 if (err < 0) {
1239 1097 printk(KERN_ERR "sscape: Failed to create "
1240 /* 1098 "MPU-401 device at 0x%lx\n",
1241 * Initialize mixer 1099 port[dev]);
1242 */ 1100 goto _release_dma;
1243 sscape->midi_vol = 0; 1101 }
1244 host_write_ctrl_unsafe(sscape->io_base, CMD_SET_MIDI_VOL, 100); 1102
1245 host_write_ctrl_unsafe(sscape->io_base, 0, 100); 1103 /*
1246 host_write_ctrl_unsafe(sscape->io_base, CMD_XXX_MIDI_VOL, 100); 1104 * Enable the master IRQ ...
1105 */
1106 sscape_write(sscape, GA_INTENA_REG, 0x80);
1107
1108 /*
1109 * Initialize mixer
1110 */
1111 spin_lock_irqsave(&sscape->lock, flags);
1112 sscape->midi_vol = 0;
1113 host_write_ctrl_unsafe(sscape->io_base,
1114 CMD_SET_MIDI_VOL, 100);
1115 host_write_ctrl_unsafe(sscape->io_base,
1116 sscape->midi_vol, 100);
1117 host_write_ctrl_unsafe(sscape->io_base,
1118 CMD_XXX_MIDI_VOL, 100);
1119 host_write_ctrl_unsafe(sscape->io_base,
1120 sscape->midi_vol, 100);
1121 host_write_ctrl_unsafe(sscape->io_base,
1122 CMD_SET_EXTMIDI, 100);
1123 host_write_ctrl_unsafe(sscape->io_base,
1124 0, 100);
1125 host_write_ctrl_unsafe(sscape->io_base, CMD_ACK, 100);
1126
1127 set_midi_mode_unsafe(sscape->io_base);
1128 spin_unlock_irqrestore(&sscape->lock, flags);
1129 }
1247 } 1130 }
1248 1131
1249 /* 1132 /*
@@ -1301,11 +1184,12 @@ static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev)
1301 sscape->type = SSCAPE; 1184 sscape->type = SSCAPE;
1302 1185
1303 dma[dev] &= 0x03; 1186 dma[dev] &= 0x03;
1187 snd_card_set_dev(card, pdev);
1188
1304 ret = create_sscape(dev, card); 1189 ret = create_sscape(dev, card);
1305 if (ret < 0) 1190 if (ret < 0)
1306 goto _release_card; 1191 goto _release_card;
1307 1192
1308 snd_card_set_dev(card, pdev);
1309 if ((ret = snd_card_register(card)) < 0) { 1193 if ((ret = snd_card_register(card)) < 0) {
1310 printk(KERN_ERR "sscape: Failed to register sound card\n"); 1194 printk(KERN_ERR "sscape: Failed to register sound card\n");
1311 goto _release_card; 1195 goto _release_card;
@@ -1426,12 +1310,12 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard,
1426 wss_port[idx] = pnp_port_start(dev, 1); 1310 wss_port[idx] = pnp_port_start(dev, 1);
1427 dma2[idx] = pnp_dma(dev, 1); 1311 dma2[idx] = pnp_dma(dev, 1);
1428 } 1312 }
1313 snd_card_set_dev(card, &pcard->card->dev);
1429 1314
1430 ret = create_sscape(idx, card); 1315 ret = create_sscape(idx, card);
1431 if (ret < 0) 1316 if (ret < 0)
1432 goto _release_card; 1317 goto _release_card;
1433 1318
1434 snd_card_set_dev(card, &pcard->card->dev);
1435 if ((ret = snd_card_register(card)) < 0) { 1319 if ((ret = snd_card_register(card)) < 0) {
1436 printk(KERN_ERR "sscape: Failed to register sound card\n"); 1320 printk(KERN_ERR "sscape: Failed to register sound card\n");
1437 goto _release_card; 1321 goto _release_card;