1*1da177e4SLinus Torvalds /* 2*1da177e4SLinus Torvalds * Driver for PowerMac AWACS 3*1da177e4SLinus Torvalds * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de> 4*1da177e4SLinus Torvalds * based on dmasound.c. 5*1da177e4SLinus Torvalds * 6*1da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 7*1da177e4SLinus Torvalds * it under the terms of the GNU General Public License as published by 8*1da177e4SLinus Torvalds * the Free Software Foundation; either version 2 of the License, or 9*1da177e4SLinus Torvalds * (at your option) any later version. 10*1da177e4SLinus Torvalds * 11*1da177e4SLinus Torvalds * This program is distributed in the hope that it will be useful, 12*1da177e4SLinus Torvalds * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*1da177e4SLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*1da177e4SLinus Torvalds * GNU General Public License for more details. 15*1da177e4SLinus Torvalds * 16*1da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License 17*1da177e4SLinus Torvalds * along with this program; if not, write to the Free Software 18*1da177e4SLinus Torvalds * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19*1da177e4SLinus Torvalds */ 20*1da177e4SLinus Torvalds 21*1da177e4SLinus Torvalds #include <sound/driver.h> 22*1da177e4SLinus Torvalds #include <linux/init.h> 23*1da177e4SLinus Torvalds #include <linux/moduleparam.h> 24*1da177e4SLinus Torvalds #include <sound/core.h> 25*1da177e4SLinus Torvalds #include <sound/initval.h> 26*1da177e4SLinus Torvalds #include "pmac.h" 27*1da177e4SLinus Torvalds #include "awacs.h" 28*1da177e4SLinus Torvalds #include "burgundy.h" 29*1da177e4SLinus Torvalds 30*1da177e4SLinus Torvalds #define CHIP_NAME "PMac" 31*1da177e4SLinus Torvalds 32*1da177e4SLinus Torvalds MODULE_DESCRIPTION("PowerMac"); 33*1da177e4SLinus Torvalds MODULE_SUPPORTED_DEVICE("{{Apple,PowerMac}}"); 34*1da177e4SLinus Torvalds MODULE_LICENSE("GPL"); 35*1da177e4SLinus Torvalds 36*1da177e4SLinus Torvalds static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ 37*1da177e4SLinus Torvalds static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ 38*1da177e4SLinus Torvalds static int enable_beep = 1; 39*1da177e4SLinus Torvalds 40*1da177e4SLinus Torvalds module_param(index, int, 0444); 41*1da177e4SLinus Torvalds MODULE_PARM_DESC(index, "Index value for " CHIP_NAME " soundchip."); 42*1da177e4SLinus Torvalds module_param(id, charp, 0444); 43*1da177e4SLinus Torvalds MODULE_PARM_DESC(id, "ID string for " CHIP_NAME " soundchip."); 44*1da177e4SLinus Torvalds module_param(enable_beep, bool, 0444); 45*1da177e4SLinus Torvalds MODULE_PARM_DESC(enable_beep, "Enable beep using PCM."); 46*1da177e4SLinus Torvalds 47*1da177e4SLinus Torvalds 48*1da177e4SLinus Torvalds /* 49*1da177e4SLinus Torvalds * card entry 50*1da177e4SLinus Torvalds */ 51*1da177e4SLinus Torvalds 52*1da177e4SLinus Torvalds static snd_card_t *snd_pmac_card = NULL; 53*1da177e4SLinus Torvalds 54*1da177e4SLinus Torvalds /* 55*1da177e4SLinus Torvalds */ 56*1da177e4SLinus Torvalds 57*1da177e4SLinus Torvalds static int __init snd_pmac_probe(void) 58*1da177e4SLinus Torvalds { 59*1da177e4SLinus Torvalds snd_card_t *card; 60*1da177e4SLinus Torvalds pmac_t *chip; 61*1da177e4SLinus Torvalds char *name_ext; 62*1da177e4SLinus Torvalds int err; 63*1da177e4SLinus Torvalds 64*1da177e4SLinus Torvalds card = snd_card_new(index, id, THIS_MODULE, 0); 65*1da177e4SLinus Torvalds if (card == NULL) 66*1da177e4SLinus Torvalds return -ENOMEM; 67*1da177e4SLinus Torvalds 68*1da177e4SLinus Torvalds if ((err = snd_pmac_new(card, &chip)) < 0) 69*1da177e4SLinus Torvalds goto __error; 70*1da177e4SLinus Torvalds 71*1da177e4SLinus Torvalds switch (chip->model) { 72*1da177e4SLinus Torvalds case PMAC_BURGUNDY: 73*1da177e4SLinus Torvalds strcpy(card->driver, "PMac Burgundy"); 74*1da177e4SLinus Torvalds strcpy(card->shortname, "PowerMac Burgundy"); 75*1da177e4SLinus Torvalds sprintf(card->longname, "%s (Dev %d) Sub-frame %d", 76*1da177e4SLinus Torvalds card->shortname, chip->device_id, chip->subframe); 77*1da177e4SLinus Torvalds if ((err = snd_pmac_burgundy_init(chip)) < 0) 78*1da177e4SLinus Torvalds goto __error; 79*1da177e4SLinus Torvalds break; 80*1da177e4SLinus Torvalds case PMAC_DACA: 81*1da177e4SLinus Torvalds strcpy(card->driver, "PMac DACA"); 82*1da177e4SLinus Torvalds strcpy(card->shortname, "PowerMac DACA"); 83*1da177e4SLinus Torvalds sprintf(card->longname, "%s (Dev %d) Sub-frame %d", 84*1da177e4SLinus Torvalds card->shortname, chip->device_id, chip->subframe); 85*1da177e4SLinus Torvalds if ((err = snd_pmac_daca_init(chip)) < 0) 86*1da177e4SLinus Torvalds goto __error; 87*1da177e4SLinus Torvalds break; 88*1da177e4SLinus Torvalds case PMAC_TUMBLER: 89*1da177e4SLinus Torvalds case PMAC_SNAPPER: 90*1da177e4SLinus Torvalds name_ext = chip->model == PMAC_TUMBLER ? "Tumbler" : "Snapper"; 91*1da177e4SLinus Torvalds sprintf(card->driver, "PMac %s", name_ext); 92*1da177e4SLinus Torvalds sprintf(card->shortname, "PowerMac %s", name_ext); 93*1da177e4SLinus Torvalds sprintf(card->longname, "%s (Dev %d) Sub-frame %d", 94*1da177e4SLinus Torvalds card->shortname, chip->device_id, chip->subframe); 95*1da177e4SLinus Torvalds if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0) 96*1da177e4SLinus Torvalds goto __error; 97*1da177e4SLinus Torvalds break; 98*1da177e4SLinus Torvalds case PMAC_AWACS: 99*1da177e4SLinus Torvalds case PMAC_SCREAMER: 100*1da177e4SLinus Torvalds name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS"; 101*1da177e4SLinus Torvalds sprintf(card->driver, "PMac %s", name_ext); 102*1da177e4SLinus Torvalds sprintf(card->shortname, "PowerMac %s", name_ext); 103*1da177e4SLinus Torvalds if (chip->is_pbook_3400) 104*1da177e4SLinus Torvalds name_ext = " [PB3400]"; 105*1da177e4SLinus Torvalds else if (chip->is_pbook_G3) 106*1da177e4SLinus Torvalds name_ext = " [PBG3]"; 107*1da177e4SLinus Torvalds else 108*1da177e4SLinus Torvalds name_ext = ""; 109*1da177e4SLinus Torvalds sprintf(card->longname, "%s%s Rev %d", 110*1da177e4SLinus Torvalds card->shortname, name_ext, chip->revision); 111*1da177e4SLinus Torvalds if ((err = snd_pmac_awacs_init(chip)) < 0) 112*1da177e4SLinus Torvalds goto __error; 113*1da177e4SLinus Torvalds break; 114*1da177e4SLinus Torvalds default: 115*1da177e4SLinus Torvalds snd_printk("unsupported hardware %d\n", chip->model); 116*1da177e4SLinus Torvalds err = -EINVAL; 117*1da177e4SLinus Torvalds goto __error; 118*1da177e4SLinus Torvalds } 119*1da177e4SLinus Torvalds 120*1da177e4SLinus Torvalds if ((err = snd_pmac_pcm_new(chip)) < 0) 121*1da177e4SLinus Torvalds goto __error; 122*1da177e4SLinus Torvalds 123*1da177e4SLinus Torvalds chip->initialized = 1; 124*1da177e4SLinus Torvalds if (enable_beep) 125*1da177e4SLinus Torvalds snd_pmac_attach_beep(chip); 126*1da177e4SLinus Torvalds 127*1da177e4SLinus Torvalds if ((err = snd_card_register(card)) < 0) 128*1da177e4SLinus Torvalds goto __error; 129*1da177e4SLinus Torvalds 130*1da177e4SLinus Torvalds snd_pmac_card = card; 131*1da177e4SLinus Torvalds return 0; 132*1da177e4SLinus Torvalds 133*1da177e4SLinus Torvalds __error: 134*1da177e4SLinus Torvalds snd_card_free(card); 135*1da177e4SLinus Torvalds return err; 136*1da177e4SLinus Torvalds } 137*1da177e4SLinus Torvalds 138*1da177e4SLinus Torvalds 139*1da177e4SLinus Torvalds /* 140*1da177e4SLinus Torvalds * MODULE stuff 141*1da177e4SLinus Torvalds */ 142*1da177e4SLinus Torvalds 143*1da177e4SLinus Torvalds static int __init alsa_card_pmac_init(void) 144*1da177e4SLinus Torvalds { 145*1da177e4SLinus Torvalds int err; 146*1da177e4SLinus Torvalds if ((err = snd_pmac_probe()) < 0) 147*1da177e4SLinus Torvalds return err; 148*1da177e4SLinus Torvalds return 0; 149*1da177e4SLinus Torvalds 150*1da177e4SLinus Torvalds } 151*1da177e4SLinus Torvalds 152*1da177e4SLinus Torvalds static void __exit alsa_card_pmac_exit(void) 153*1da177e4SLinus Torvalds { 154*1da177e4SLinus Torvalds if (snd_pmac_card) 155*1da177e4SLinus Torvalds snd_card_free(snd_pmac_card); 156*1da177e4SLinus Torvalds } 157*1da177e4SLinus Torvalds 158*1da177e4SLinus Torvalds module_init(alsa_card_pmac_init) 159*1da177e4SLinus Torvalds module_exit(alsa_card_pmac_exit) 160