Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * The driver for the Yamaha's DS1/DS1E cards |
Jaroslav Kysela | c1017a4 | 2007-10-15 09:50:19 +0200 | [diff] [blame] | 3 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | * |
| 20 | */ |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/init.h> |
| 23 | #include <linux/pci.h> |
| 24 | #include <linux/time.h> |
Paul Gortmaker | 65a7721 | 2011-07-15 13:13:37 -0400 | [diff] [blame] | 25 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <sound/core.h> |
Takashi Iwai | 81fcb17 | 2012-07-02 16:37:05 +0200 | [diff] [blame] | 27 | #include "ymfpci.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <sound/mpu401.h> |
| 29 | #include <sound/opl3.h> |
| 30 | #include <sound/initval.h> |
| 31 | |
Jaroslav Kysela | c1017a4 | 2007-10-15 09:50:19 +0200 | [diff] [blame] | 32 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); |
Clemens Ladisch | 22fb2a7 | 2005-12-12 09:27:14 +0100 | [diff] [blame] | 33 | MODULE_DESCRIPTION("Yamaha DS-1 PCI"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | MODULE_LICENSE("GPL"); |
| 35 | MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF724}," |
| 36 | "{Yamaha,YMF724F}," |
| 37 | "{Yamaha,YMF740}," |
| 38 | "{Yamaha,YMF740C}," |
| 39 | "{Yamaha,YMF744}," |
| 40 | "{Yamaha,YMF754}}"); |
| 41 | |
| 42 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
| 43 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
Rusty Russell | a67ff6a | 2011-12-15 13:49:36 +1030 | [diff] [blame] | 44 | static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | static long fm_port[SNDRV_CARDS]; |
| 46 | static long mpu_port[SNDRV_CARDS]; |
| 47 | #ifdef SUPPORT_JOYSTICK |
| 48 | static long joystick_port[SNDRV_CARDS]; |
| 49 | #endif |
Rusty Russell | a67ff6a | 2011-12-15 13:49:36 +1030 | [diff] [blame] | 50 | static bool rear_switch[SNDRV_CARDS]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | module_param_array(index, int, NULL, 0444); |
Clemens Ladisch | 22fb2a7 | 2005-12-12 09:27:14 +0100 | [diff] [blame] | 53 | MODULE_PARM_DESC(index, "Index value for the Yamaha DS-1 PCI soundcard."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | module_param_array(id, charp, NULL, 0444); |
Clemens Ladisch | 22fb2a7 | 2005-12-12 09:27:14 +0100 | [diff] [blame] | 55 | MODULE_PARM_DESC(id, "ID string for the Yamaha DS-1 PCI soundcard."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | module_param_array(enable, bool, NULL, 0444); |
Clemens Ladisch | 22fb2a7 | 2005-12-12 09:27:14 +0100 | [diff] [blame] | 57 | MODULE_PARM_DESC(enable, "Enable Yamaha DS-1 soundcard."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | module_param_array(mpu_port, long, NULL, 0444); |
| 59 | MODULE_PARM_DESC(mpu_port, "MPU-401 Port."); |
| 60 | module_param_array(fm_port, long, NULL, 0444); |
| 61 | MODULE_PARM_DESC(fm_port, "FM OPL-3 Port."); |
| 62 | #ifdef SUPPORT_JOYSTICK |
| 63 | module_param_array(joystick_port, long, NULL, 0444); |
| 64 | MODULE_PARM_DESC(joystick_port, "Joystick port address"); |
| 65 | #endif |
| 66 | module_param_array(rear_switch, bool, NULL, 0444); |
| 67 | MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch"); |
| 68 | |
Benoit Taine | 9baa3c3 | 2014-08-08 15:56:03 +0200 | [diff] [blame] | 69 | static const struct pci_device_id snd_ymfpci_ids[] = { |
Joe Perches | 28d27aa | 2009-06-24 22:13:35 -0700 | [diff] [blame] | 70 | { PCI_VDEVICE(YAMAHA, 0x0004), 0, }, /* YMF724 */ |
| 71 | { PCI_VDEVICE(YAMAHA, 0x000d), 0, }, /* YMF724F */ |
| 72 | { PCI_VDEVICE(YAMAHA, 0x000a), 0, }, /* YMF740 */ |
| 73 | { PCI_VDEVICE(YAMAHA, 0x000c), 0, }, /* YMF740C */ |
| 74 | { PCI_VDEVICE(YAMAHA, 0x0010), 0, }, /* YMF744 */ |
| 75 | { PCI_VDEVICE(YAMAHA, 0x0012), 0, }, /* YMF754 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { 0, } |
| 77 | }; |
| 78 | |
| 79 | MODULE_DEVICE_TABLE(pci, snd_ymfpci_ids); |
| 80 | |
| 81 | #ifdef SUPPORT_JOYSTICK |
Bill Pemberton | e23e7a1 | 2012-12-06 12:35:10 -0500 | [diff] [blame] | 82 | static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev, |
| 83 | int legacy_ctrl, int legacy_ctrl2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | { |
| 85 | struct gameport *gp; |
| 86 | struct resource *r = NULL; |
| 87 | int io_port = joystick_port[dev]; |
| 88 | |
| 89 | if (!io_port) |
| 90 | return -ENODEV; |
| 91 | |
| 92 | if (chip->pci->device >= 0x0010) { /* YMF 744/754 */ |
| 93 | |
| 94 | if (io_port == 1) { |
| 95 | /* auto-detect */ |
| 96 | if (!(io_port = pci_resource_start(chip->pci, 2))) |
| 97 | return -ENODEV; |
| 98 | } |
| 99 | } else { |
| 100 | if (io_port == 1) { |
| 101 | /* auto-detect */ |
| 102 | for (io_port = 0x201; io_port <= 0x205; io_port++) { |
| 103 | if (io_port == 0x203) |
| 104 | continue; |
| 105 | if ((r = request_region(io_port, 1, "YMFPCI gameport")) != NULL) |
| 106 | break; |
| 107 | } |
| 108 | if (!r) { |
Takashi Iwai | 6436bcf | 2014-02-26 12:18:27 +0100 | [diff] [blame] | 109 | dev_err(chip->card->dev, |
| 110 | "no gameport ports available\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | return -EBUSY; |
| 112 | } |
| 113 | } |
| 114 | switch (io_port) { |
| 115 | case 0x201: legacy_ctrl2 |= 0 << 6; break; |
| 116 | case 0x202: legacy_ctrl2 |= 1 << 6; break; |
| 117 | case 0x204: legacy_ctrl2 |= 2 << 6; break; |
| 118 | case 0x205: legacy_ctrl2 |= 3 << 6; break; |
| 119 | default: |
Takashi Iwai | 6436bcf | 2014-02-26 12:18:27 +0100 | [diff] [blame] | 120 | dev_err(chip->card->dev, |
| 121 | "invalid joystick port %#x", io_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | return -EINVAL; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | if (!r && !(r = request_region(io_port, 1, "YMFPCI gameport"))) { |
Takashi Iwai | 6436bcf | 2014-02-26 12:18:27 +0100 | [diff] [blame] | 127 | dev_err(chip->card->dev, |
| 128 | "joystick port %#x is in use.\n", io_port); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | return -EBUSY; |
| 130 | } |
| 131 | |
| 132 | chip->gameport = gp = gameport_allocate_port(); |
| 133 | if (!gp) { |
Takashi Iwai | 6436bcf | 2014-02-26 12:18:27 +0100 | [diff] [blame] | 134 | dev_err(chip->card->dev, |
| 135 | "cannot allocate memory for gameport\n"); |
Takashi Iwai | b1d5776 | 2005-10-10 11:56:31 +0200 | [diff] [blame] | 136 | release_and_free_resource(r); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | return -ENOMEM; |
| 138 | } |
| 139 | |
| 140 | |
| 141 | gameport_set_name(gp, "Yamaha YMF Gameport"); |
| 142 | gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci)); |
| 143 | gameport_set_dev_parent(gp, &chip->pci->dev); |
| 144 | gp->io = io_port; |
| 145 | gameport_set_port_data(gp, r); |
| 146 | |
| 147 | if (chip->pci->device >= 0x0010) /* YMF 744/754 */ |
| 148 | pci_write_config_word(chip->pci, PCIR_DSXG_JOYBASE, io_port); |
| 149 | |
| 150 | pci_write_config_word(chip->pci, PCIR_DSXG_LEGACY, legacy_ctrl | YMFPCI_LEGACY_JPEN); |
| 151 | pci_write_config_word(chip->pci, PCIR_DSXG_ELEGACY, legacy_ctrl2); |
| 152 | |
| 153 | gameport_register_port(chip->gameport); |
| 154 | |
| 155 | return 0; |
| 156 | } |
| 157 | |
Takashi Iwai | 208a1b4 | 2005-11-17 14:53:41 +0100 | [diff] [blame] | 158 | void snd_ymfpci_free_gameport(struct snd_ymfpci *chip) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | { |
| 160 | if (chip->gameport) { |
| 161 | struct resource *r = gameport_get_port_data(chip->gameport); |
| 162 | |
| 163 | gameport_unregister_port(chip->gameport); |
| 164 | chip->gameport = NULL; |
| 165 | |
Takashi Iwai | b1d5776 | 2005-10-10 11:56:31 +0200 | [diff] [blame] | 166 | release_and_free_resource(r); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | } |
| 169 | #else |
Takashi Iwai | 208a1b4 | 2005-11-17 14:53:41 +0100 | [diff] [blame] | 170 | static inline int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev, int l, int l2) { return -ENOSYS; } |
| 171 | void snd_ymfpci_free_gameport(struct snd_ymfpci *chip) { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | #endif /* SUPPORT_JOYSTICK */ |
| 173 | |
Bill Pemberton | e23e7a1 | 2012-12-06 12:35:10 -0500 | [diff] [blame] | 174 | static int snd_card_ymfpci_probe(struct pci_dev *pci, |
| 175 | const struct pci_device_id *pci_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | { |
| 177 | static int dev; |
Takashi Iwai | 208a1b4 | 2005-11-17 14:53:41 +0100 | [diff] [blame] | 178 | struct snd_card *card; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | struct resource *fm_res = NULL; |
| 180 | struct resource *mpu_res = NULL; |
Takashi Iwai | 208a1b4 | 2005-11-17 14:53:41 +0100 | [diff] [blame] | 181 | struct snd_ymfpci *chip; |
| 182 | struct snd_opl3 *opl3; |
Clemens Ladisch | 22fb2a7 | 2005-12-12 09:27:14 +0100 | [diff] [blame] | 183 | const char *str, *model; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | int err; |
| 185 | u16 legacy_ctrl, legacy_ctrl2, old_legacy_ctrl; |
| 186 | |
| 187 | if (dev >= SNDRV_CARDS) |
| 188 | return -ENODEV; |
| 189 | if (!enable[dev]) { |
| 190 | dev++; |
| 191 | return -ENOENT; |
| 192 | } |
| 193 | |
Takashi Iwai | 60c5772 | 2014-01-29 14:20:19 +0100 | [diff] [blame] | 194 | err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, |
| 195 | 0, &card); |
Takashi Iwai | e58de7b | 2008-12-28 16:44:30 +0100 | [diff] [blame] | 196 | if (err < 0) |
| 197 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | |
| 199 | switch (pci_id->device) { |
Clemens Ladisch | 22fb2a7 | 2005-12-12 09:27:14 +0100 | [diff] [blame] | 200 | case 0x0004: str = "YMF724"; model = "DS-1"; break; |
| 201 | case 0x000d: str = "YMF724F"; model = "DS-1"; break; |
| 202 | case 0x000a: str = "YMF740"; model = "DS-1L"; break; |
| 203 | case 0x000c: str = "YMF740C"; model = "DS-1L"; break; |
| 204 | case 0x0010: str = "YMF744"; model = "DS-1S"; break; |
| 205 | case 0x0012: str = "YMF754"; model = "DS-1E"; break; |
| 206 | default: model = str = "???"; break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | legacy_ctrl = 0; |
| 210 | legacy_ctrl2 = 0x0800; /* SBEN = 0, SMOD = 01, LAD = 0 */ |
| 211 | |
| 212 | if (pci_id->device >= 0x0010) { /* YMF 744/754 */ |
| 213 | if (fm_port[dev] == 1) { |
| 214 | /* auto-detect */ |
| 215 | fm_port[dev] = pci_resource_start(pci, 1); |
| 216 | } |
| 217 | if (fm_port[dev] > 0 && |
| 218 | (fm_res = request_region(fm_port[dev], 4, "YMFPCI OPL3")) != NULL) { |
| 219 | legacy_ctrl |= YMFPCI_LEGACY_FMEN; |
| 220 | pci_write_config_word(pci, PCIR_DSXG_FMBASE, fm_port[dev]); |
| 221 | } |
| 222 | if (mpu_port[dev] == 1) { |
| 223 | /* auto-detect */ |
| 224 | mpu_port[dev] = pci_resource_start(pci, 1) + 0x20; |
| 225 | } |
| 226 | if (mpu_port[dev] > 0 && |
| 227 | (mpu_res = request_region(mpu_port[dev], 2, "YMFPCI MPU401")) != NULL) { |
| 228 | legacy_ctrl |= YMFPCI_LEGACY_MEN; |
| 229 | pci_write_config_word(pci, PCIR_DSXG_MPU401BASE, mpu_port[dev]); |
| 230 | } |
| 231 | } else { |
| 232 | switch (fm_port[dev]) { |
| 233 | case 0x388: legacy_ctrl2 |= 0; break; |
| 234 | case 0x398: legacy_ctrl2 |= 1; break; |
| 235 | case 0x3a0: legacy_ctrl2 |= 2; break; |
| 236 | case 0x3a8: legacy_ctrl2 |= 3; break; |
| 237 | default: fm_port[dev] = 0; break; |
| 238 | } |
| 239 | if (fm_port[dev] > 0 && |
| 240 | (fm_res = request_region(fm_port[dev], 4, "YMFPCI OPL3")) != NULL) { |
| 241 | legacy_ctrl |= YMFPCI_LEGACY_FMEN; |
| 242 | } else { |
| 243 | legacy_ctrl2 &= ~YMFPCI_LEGACY2_FMIO; |
| 244 | fm_port[dev] = 0; |
| 245 | } |
| 246 | switch (mpu_port[dev]) { |
| 247 | case 0x330: legacy_ctrl2 |= 0 << 4; break; |
| 248 | case 0x300: legacy_ctrl2 |= 1 << 4; break; |
| 249 | case 0x332: legacy_ctrl2 |= 2 << 4; break; |
| 250 | case 0x334: legacy_ctrl2 |= 3 << 4; break; |
| 251 | default: mpu_port[dev] = 0; break; |
| 252 | } |
| 253 | if (mpu_port[dev] > 0 && |
| 254 | (mpu_res = request_region(mpu_port[dev], 2, "YMFPCI MPU401")) != NULL) { |
| 255 | legacy_ctrl |= YMFPCI_LEGACY_MEN; |
| 256 | } else { |
| 257 | legacy_ctrl2 &= ~YMFPCI_LEGACY2_MPUIO; |
| 258 | mpu_port[dev] = 0; |
| 259 | } |
| 260 | } |
| 261 | if (mpu_res) { |
| 262 | legacy_ctrl |= YMFPCI_LEGACY_MIEN; |
| 263 | legacy_ctrl2 |= YMFPCI_LEGACY2_IMOD; |
| 264 | } |
| 265 | pci_read_config_word(pci, PCIR_DSXG_LEGACY, &old_legacy_ctrl); |
| 266 | pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); |
| 267 | pci_write_config_word(pci, PCIR_DSXG_ELEGACY, legacy_ctrl2); |
| 268 | if ((err = snd_ymfpci_create(card, pci, |
| 269 | old_legacy_ctrl, |
| 270 | &chip)) < 0) { |
| 271 | snd_card_free(card); |
Takashi Iwai | b1d5776 | 2005-10-10 11:56:31 +0200 | [diff] [blame] | 272 | release_and_free_resource(mpu_res); |
| 273 | release_and_free_resource(fm_res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | return err; |
| 275 | } |
| 276 | chip->fm_res = fm_res; |
| 277 | chip->mpu_res = mpu_res; |
Takashi Iwai | ded4623 | 2005-11-17 16:09:43 +0100 | [diff] [blame] | 278 | card->private_data = chip; |
| 279 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | strcpy(card->driver, str); |
Clemens Ladisch | 22fb2a7 | 2005-12-12 09:27:14 +0100 | [diff] [blame] | 281 | sprintf(card->shortname, "Yamaha %s (%s)", model, str); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | sprintf(card->longname, "%s at 0x%lx, irq %i", |
| 283 | card->shortname, |
| 284 | chip->reg_area_phys, |
| 285 | chip->irq); |
Lars-Peter Clausen | 38c4718 | 2015-01-02 12:24:55 +0100 | [diff] [blame] | 286 | if ((err = snd_ymfpci_pcm(chip, 0)) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | snd_card_free(card); |
| 288 | return err; |
| 289 | } |
Lars-Peter Clausen | 38c4718 | 2015-01-02 12:24:55 +0100 | [diff] [blame] | 290 | if ((err = snd_ymfpci_pcm_spdif(chip, 1)) < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | snd_card_free(card); |
| 292 | return err; |
| 293 | } |
Raymond Yau | 4d20bb1 | 2012-01-17 11:41:47 +0800 | [diff] [blame] | 294 | err = snd_ymfpci_mixer(chip, rear_switch[dev]); |
| 295 | if (err < 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | snd_card_free(card); |
| 297 | return err; |
| 298 | } |
Raymond Yau | 4d20bb1 | 2012-01-17 11:41:47 +0800 | [diff] [blame] | 299 | if (chip->ac97->ext_id & AC97_EI_SDAC) { |
Lars-Peter Clausen | 38c4718 | 2015-01-02 12:24:55 +0100 | [diff] [blame] | 300 | err = snd_ymfpci_pcm_4ch(chip, 2); |
Raymond Yau | 4d20bb1 | 2012-01-17 11:41:47 +0800 | [diff] [blame] | 301 | if (err < 0) { |
| 302 | snd_card_free(card); |
| 303 | return err; |
| 304 | } |
Lars-Peter Clausen | 38c4718 | 2015-01-02 12:24:55 +0100 | [diff] [blame] | 305 | err = snd_ymfpci_pcm2(chip, 3); |
Raymond Yau | 4d20bb1 | 2012-01-17 11:41:47 +0800 | [diff] [blame] | 306 | if (err < 0) { |
| 307 | snd_card_free(card); |
| 308 | return err; |
| 309 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | } |
| 311 | if ((err = snd_ymfpci_timer(chip, 0)) < 0) { |
| 312 | snd_card_free(card); |
| 313 | return err; |
| 314 | } |
| 315 | if (chip->mpu_res) { |
| 316 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI, |
Takashi Iwai | 302e4c2 | 2006-05-23 13:24:30 +0200 | [diff] [blame] | 317 | mpu_port[dev], |
Clemens Ladisch | dba8b46 | 2011-09-13 11:24:41 +0200 | [diff] [blame] | 318 | MPU401_INFO_INTEGRATED | |
| 319 | MPU401_INFO_IRQ_HOOK, |
| 320 | -1, &chip->rawmidi)) < 0) { |
Takashi Iwai | 6436bcf | 2014-02-26 12:18:27 +0100 | [diff] [blame] | 321 | dev_warn(card->dev, |
| 322 | "cannot initialize MPU401 at 0x%lx, skipping...\n", |
| 323 | mpu_port[dev]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */ |
| 325 | pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); |
| 326 | } |
| 327 | } |
| 328 | if (chip->fm_res) { |
| 329 | if ((err = snd_opl3_create(card, |
| 330 | fm_port[dev], |
| 331 | fm_port[dev] + 2, |
| 332 | OPL3_HW_OPL3, 1, &opl3)) < 0) { |
Takashi Iwai | 6436bcf | 2014-02-26 12:18:27 +0100 | [diff] [blame] | 333 | dev_warn(card->dev, |
| 334 | "cannot initialize FM OPL3 at 0x%lx, skipping...\n", |
| 335 | fm_port[dev]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | legacy_ctrl &= ~YMFPCI_LEGACY_FMEN; |
| 337 | pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); |
| 338 | } else if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { |
| 339 | snd_card_free(card); |
Takashi Iwai | 6436bcf | 2014-02-26 12:18:27 +0100 | [diff] [blame] | 340 | dev_err(card->dev, "cannot create opl3 hwdep\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | return err; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | snd_ymfpci_create_gameport(chip, dev, legacy_ctrl, legacy_ctrl2); |
| 346 | |
| 347 | if ((err = snd_card_register(card)) < 0) { |
| 348 | snd_card_free(card); |
| 349 | return err; |
| 350 | } |
| 351 | pci_set_drvdata(pci, card); |
| 352 | dev++; |
| 353 | return 0; |
| 354 | } |
| 355 | |
Bill Pemberton | e23e7a1 | 2012-12-06 12:35:10 -0500 | [diff] [blame] | 356 | static void snd_card_ymfpci_remove(struct pci_dev *pci) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | { |
| 358 | snd_card_free(pci_get_drvdata(pci)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Takashi Iwai | e9f66d9 | 2012-04-24 12:25:00 +0200 | [diff] [blame] | 361 | static struct pci_driver ymfpci_driver = { |
Takashi Iwai | 3733e42 | 2011-06-10 16:20:20 +0200 | [diff] [blame] | 362 | .name = KBUILD_MODNAME, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | .id_table = snd_ymfpci_ids, |
| 364 | .probe = snd_card_ymfpci_probe, |
Bill Pemberton | e23e7a1 | 2012-12-06 12:35:10 -0500 | [diff] [blame] | 365 | .remove = snd_card_ymfpci_remove, |
Takashi Iwai | c7561cd | 2012-08-14 18:12:04 +0200 | [diff] [blame] | 366 | #ifdef CONFIG_PM_SLEEP |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 367 | .driver = { |
| 368 | .pm = &snd_ymfpci_pm, |
| 369 | }, |
Takashi Iwai | ded4623 | 2005-11-17 16:09:43 +0100 | [diff] [blame] | 370 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | }; |
| 372 | |
Takashi Iwai | e9f66d9 | 2012-04-24 12:25:00 +0200 | [diff] [blame] | 373 | module_pci_driver(ymfpci_driver); |