Ignore:
Timestamp:
May 31, 2007, 6:45:32 AM (18 years ago)
Author:
Brendan Oakley
Message:

Merged to Alsa 0.9.0rc1. Builds.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/alsa-resync1/alsa-kernel/pci/sonicvibes.c

    r77 r112  
    1919 *   You should have received a copy of the GNU General Public License
    2020 *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     21 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2222 *
    2323 */
    2424
    25 #define SNDRV_MAIN_OBJECT_FILE
    2625#include <sound/driver.h>
     26#include <asm/io.h>
     27#include <linux/delay.h>
     28#include <linux/init.h>
     29#include <linux/slab.h>
     30#include <sound/core.h>
    2731#include <sound/pcm.h>
    2832#include <sound/info.h>
     
    3236#define SNDRV_GET_ID
    3337#include <sound/initval.h>
     38#ifndef LINUX_2_2
     39#include <linux/gameport.h>
     40#endif
    3441
    3542EXPORT_NO_SYMBOLS;
     43
     44MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
    3645MODULE_DESCRIPTION("S3 SonicVibes PCI");
     46MODULE_LICENSE("GPL");
    3747MODULE_CLASSES("{sound}");
    3848MODULE_DEVICES("{{S3,SonicVibes PCI}}");
     
    4757static int snd_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;  /* Index 0-MAX */
    4858static char *snd_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;   /* ID for this card */
    49 static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     59static int snd_enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;  /* Enable this card */
    5060#ifdef TARGET_OS2
    5161static int snd_reverb[SNDRV_CARDS] = {0,0,0,0,0,0,0,0};
     
    250260        snd_kcontrol_t *master_mute;
    251261        snd_kcontrol_t *master_volume;
     262
     263#ifndef LINUX_2_2
     264        struct gameport gameport;
     265#endif
    252266};
    253267
     
    940954}
    941955
    942 static int __init snd_sonicvibes_pcm(sonicvibes_t * sonic, int device, snd_pcm_t ** rpcm)
     956static int __devinit snd_sonicvibes_pcm(sonicvibes_t * sonic, int device, snd_pcm_t ** rpcm)
    943957{
    944958        snd_pcm_t *pcm;
     
    11791193#define SONICVIBES_CONTROLS (sizeof(snd_sonicvibes_controls)/sizeof(snd_kcontrol_new_t))
    11801194
    1181 static snd_kcontrol_new_t snd_sonicvibes_controls[] = {
     1195static snd_kcontrol_new_t snd_sonicvibes_controls[] __devinitdata = {
    11821196SONICVIBES_DOUBLE("Capture Volume", 0, SV_IREG_LEFT_ADC, SV_IREG_RIGHT_ADC, 0, 0, 15, 0),
    11831197SONICVIBES_DOUBLE("Aux Playback Switch", 0, SV_IREG_LEFT_AUX1, SV_IREG_RIGHT_AUX1, 7, 7, 1, 1),
     
    12101224}
    12111225
    1212 static int __init snd_sonicvibes_mixer(sonicvibes_t * sonic)
     1226static int __devinit snd_sonicvibes_mixer(sonicvibes_t * sonic)
    12131227{
    12141228        snd_card_t *card;
     
    12651279}
    12661280
    1267 static void __init snd_sonicvibes_proc_init(sonicvibes_t * sonic)
     1281static void __devinit snd_sonicvibes_proc_init(sonicvibes_t * sonic)
    12681282{
    12691283        snd_info_entry_t *entry;
     
    12951309 */
    12961310
    1297 static snd_kcontrol_new_t snd_sonicvibes_game_control =
     1311static snd_kcontrol_new_t snd_sonicvibes_game_control __devinitdata =
    12981312SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0);
    12991313
    13001314static int snd_sonicvibes_free(sonicvibes_t *sonic)
    13011315{
     1316#ifndef LINUX_2_2
     1317        if (sonic->gameport.io)
     1318                gameport_unregister_port(&sonic->gameport);
     1319#endif
    13021320        snd_sonicvibes_proc_done(sonic);
    13031321        pci_write_config_dword(sonic->pci, 0x40, sonic->dmaa_port);
    13041322        pci_write_config_dword(sonic->pci, 0x48, sonic->dmac_port);
    1305         if (sonic->res_sb_port)
     1323        if (sonic->res_sb_port) {
    13061324                release_resource(sonic->res_sb_port);
    1307         if (sonic->res_enh_port)
     1325                kfree_nocheck(sonic->res_sb_port);
     1326        }
     1327        if (sonic->res_enh_port) {
    13081328                release_resource(sonic->res_enh_port);
    1309         if (sonic->res_synth_port)
     1329                kfree_nocheck(sonic->res_enh_port);
     1330        }
     1331        if (sonic->res_synth_port) {
    13101332                release_resource(sonic->res_synth_port);
    1311         if (sonic->res_midi_port)
     1333                kfree_nocheck(sonic->res_synth_port);
     1334        }
     1335        if (sonic->res_midi_port) {
    13121336                release_resource(sonic->res_midi_port);
    1313         if (sonic->res_dmaa)
     1337                kfree_nocheck(sonic->res_midi_port);
     1338        }
     1339        if (sonic->res_dmaa) {
    13141340                release_resource(sonic->res_dmaa);
    1315         if (sonic->res_dmac)
     1341                kfree_nocheck(sonic->res_dmaa);
     1342        }
     1343        if (sonic->res_dmac) {
    13161344                release_resource(sonic->res_dmac);
     1345                kfree_nocheck(sonic->res_dmac);
     1346        }
    13171347        if (sonic->irq >= 0)
    13181348                free_irq(sonic->irq, (void *)sonic);
     
    13271357}
    13281358
    1329 static int __init snd_sonicvibes_create(snd_card_t * card,
     1359static int __devinit snd_sonicvibes_create(snd_card_t * card,
    13301360                                        struct pci_dev *pci,
    13311361                                        int reverb,
     
    14961526#define SONICVIBES_MIDI_CONTROLS (sizeof(snd_sonicvibes_midi_controls)/sizeof(snd_kcontrol_new_t))
    14971527
    1498 static snd_kcontrol_new_t snd_sonicvibes_midi_controls[] = {
     1528static snd_kcontrol_new_t snd_sonicvibes_midi_controls[] __devinitdata = {
    14991529SONICVIBES_SINGLE("SonicVibes Wave Source RAM", 0, SV_IREG_WAVE_SOURCE, 0, 1, 0),
    15001530SONICVIBES_SINGLE("SonicVibes Wave Source RAM+ROM", 0, SV_IREG_WAVE_SOURCE, 1, 1, 0),
     
    15041534};
    15051535
    1506 static void snd_sonicvibes_midi_input_open(mpu401_t * mpu)
    1507 {
    1508         sonicvibes_t *sonic = snd_magic_cast(sonicvibes_t, mpu->private_data, return);
     1536static int snd_sonicvibes_midi_input_open(mpu401_t * mpu)
     1537{
     1538        sonicvibes_t *sonic = snd_magic_cast(sonicvibes_t, mpu->private_data, return -EIO);
    15091539        outb(sonic->irqmask &= ~SV_MIDI_MASK, SV_REG(sonic, IRQMASK));
     1540        return 0;
    15101541}
    15111542
     
    15161547}
    15171548
    1518 static int snd_sonicvibes_midi(sonicvibes_t * sonic, snd_rawmidi_t * rmidi)
     1549static int __devinit snd_sonicvibes_midi(sonicvibes_t * sonic, snd_rawmidi_t * rmidi)
    15191550{
    15201551        mpu401_t * mpu = snd_magic_cast(mpu401_t, rmidi->private_data, return -ENXIO);
     
    15331564}
    15341565
    1535 static int __init snd_sonic_probe(struct pci_dev *pci,
     1566static int __devinit snd_sonic_probe(struct pci_dev *pci,
    15361567                                  const struct pci_device_id *id)
    15371568{
    1538         static int dev = 0;
     1569        static int dev;
    15391570        snd_card_t *card;
    15401571        sonicvibes_t *sonic;
     
    15431574        int idx, err;
    15441575
    1545         for ( ; dev < SNDRV_CARDS; dev++) {
     1576        if (dev >= SNDRV_CARDS)
     1577                return -ENODEV;
    15461578                if (!snd_enable[dev]) {
    15471579                        dev++;
    15481580                        return -ENOENT;
    15491581                }
    1550                 break;
    1551         }
    1552         if (dev >= SNDRV_CARDS)
    1553                 return -ENODEV;
    15541582 
    15551583        card = snd_card_new(snd_index[dev], snd_id[dev], THIS_MODULE, 0);
     
    15961624                return err;
    15971625        }
     1626#ifndef LINUX_2_2
     1627        sonic->gameport.io = sonic->game_port;
     1628        gameport_register_port(&sonic->gameport);
     1629#endif
    15981630        strcpy(card->driver, "SonicVibes");
    15991631        strcpy(card->shortname, "S3 SonicVibes");
     
    16091641        }
    16101642       
    1611         PCI_SET_DRIVER_DATA(pci, card);
     1643        pci_set_drvdata(pci, card);
    16121644        dev++;
    16131645        return 0;
    16141646}
    16151647
    1616 static void __exit snd_sonic_remove(struct pci_dev *pci)
    1617 {
    1618         snd_card_free(PCI_GET_DRIVER_DATA(pci));
    1619         PCI_SET_DRIVER_DATA(pci, NULL);
     1648static void __devexit snd_sonic_remove(struct pci_dev *pci)
     1649{
     1650        snd_card_free(pci_get_drvdata(pci));
     1651        pci_set_drvdata(pci, NULL);
    16201652}
    16211653
     
    16321664        id_table: snd_sonic_ids,
    16331665        probe: snd_sonic_probe,
    1634         remove: snd_sonic_remove,
     1666        remove: __devexit_p(snd_sonic_remove),
    16351667#endif
    16361668};
     
    16421674        if ((err = pci_module_init(&driver)) < 0) {
    16431675#ifdef MODULE
    1644 //              snd_printk("S3 SonicVibes soundcard not found or device busy\n");
     1676//              printk(KERN_ERR "S3 SonicVibes soundcard not found or device busy\n");
    16451677#endif
    16461678                return err;
     
    16591691#ifndef MODULE
    16601692
    1661 /* format is: snd-card-sonicvibes=snd_enable,snd_index,snd_id,
     1693/* format is: snd-sonicvibes=snd_enable,snd_index,snd_id,
    16621694                                  snd_reverb,snd_mge,snd_dmaio */
    16631695
     
    16781710}
    16791711
    1680 __setup("snd-card-sonicvibes=", alsa_card_sonicvibes_setup);
     1712__setup("snd-sonicvibes=", alsa_card_sonicvibes_setup);
    16811713
    16821714#endif /* ifndef MODULE */
Note: See TracChangeset for help on using the changeset viewer.