Changeset 679 for GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci.c
- Timestamp:
- Mar 18, 2021, 8:57:36 PM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-linux-3.2.102 (added) merged: 611-614 /GPL/branches/uniaud32-next (added) merged: 615-678
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci.c
r598 r679 1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 2 3 * The driver for the Yamaha's DS1/DS1E cards 3 4 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 4 *5 *6 * This program is free software; you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation; either version 2 of the License, or9 * (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 of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 *16 * You should have received a copy of the GNU General Public License17 * along with this program; if not, write to the Free Software18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19 *20 5 */ 21 6 … … 23 8 #include <linux/pci.h> 24 9 #include <linux/time.h> 25 #include <linux/module param.h>10 #include <linux/module.h> 26 11 #include <sound/core.h> 27 #include <sound/ymfpci.h>12 #include "ymfpci.h" 28 13 #include <sound/mpu401.h> 29 14 #include <sound/opl3.h> 30 15 #include <sound/initval.h> 16 17 #ifdef TARGET_OS2 18 #define KBUILD_MODNAME "ymfpci" 19 #endif 31 20 32 21 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); … … 42 31 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 43 32 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 44 static intenable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */33 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ 45 34 static long fm_port[SNDRV_CARDS]; 46 35 static long mpu_port[SNDRV_CARDS]; … … 48 37 static long joystick_port[SNDRV_CARDS]; 49 38 #endif 50 static intrear_switch[SNDRV_CARDS];39 static bool rear_switch[SNDRV_CARDS]; 51 40 52 41 module_param_array(index, int, NULL, 0444); … … 56 45 module_param_array(enable, bool, NULL, 0444); 57 46 MODULE_PARM_DESC(enable, "Enable Yamaha DS-1 soundcard."); 58 module_param_ array(mpu_port, long, NULL, 0444);47 module_param_hw_array(mpu_port, long, ioport, NULL, 0444); 59 48 MODULE_PARM_DESC(mpu_port, "MPU-401 Port."); 60 module_param_ array(fm_port, long, NULL, 0444);49 module_param_hw_array(fm_port, long, ioport, NULL, 0444); 61 50 MODULE_PARM_DESC(fm_port, "FM OPL-3 Port."); 62 51 #ifdef SUPPORT_JOYSTICK 63 module_param_ array(joystick_port, long, NULL, 0444);52 module_param_hw_array(joystick_port, long, ioport, NULL, 0444); 64 53 MODULE_PARM_DESC(joystick_port, "Joystick port address"); 65 54 #endif … … 67 56 MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch"); 68 57 69 static DEFINE_PCI_DEVICE_TABLE(snd_ymfpci_ids)= {58 static const struct pci_device_id snd_ymfpci_ids[] = { 70 59 { PCI_VDEVICE(YAMAHA, 0x0004), 0, }, /* YMF724 */ 71 60 { PCI_VDEVICE(YAMAHA, 0x000d), 0, }, /* YMF724F */ … … 80 69 81 70 #ifdef SUPPORT_JOYSTICK 82 static int __devinitsnd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,83 71 static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev, 72 int legacy_ctrl, int legacy_ctrl2) 84 73 { 85 74 struct gameport *gp; … … 107 96 } 108 97 if (!r) { 109 printk(KERN_ERR "ymfpci: no gameport ports available\n"); 98 dev_err(chip->card->dev, 99 "no gameport ports available\n"); 110 100 return -EBUSY; 111 101 } … … 117 107 case 0x205: legacy_ctrl2 |= 3 << 6; break; 118 108 default: 119 printk(KERN_ERR "ymfpci: invalid joystick port %#x", io_port); 109 dev_err(chip->card->dev, 110 "invalid joystick port %#x", io_port); 120 111 return -EINVAL; 121 112 } … … 123 114 124 115 if (!r && !(r = request_region(io_port, 1, "YMFPCI gameport"))) { 125 printk(KERN_ERR "ymfpci: joystick port %#x is in use.\n", io_port); 116 dev_err(chip->card->dev, 117 "joystick port %#x is in use.\n", io_port); 126 118 return -EBUSY; 127 119 } … … 129 121 chip->gameport = gp = gameport_allocate_port(); 130 122 if (!gp) { 131 printk(KERN_ERR "ymfpci: cannot allocate memory for gameport\n"); 123 dev_err(chip->card->dev, 124 "cannot allocate memory for gameport\n"); 132 125 release_and_free_resource(r); 133 126 return -ENOMEM; … … 168 161 #endif /* SUPPORT_JOYSTICK */ 169 162 170 static int __devinitsnd_card_ymfpci_probe(struct pci_dev *pci,171 163 static int snd_card_ymfpci_probe(struct pci_dev *pci, 164 const struct pci_device_id *pci_id) 172 165 { 173 166 static int dev; … … 188 181 } 189 182 190 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 183 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 184 0, &card); 191 185 if (err < 0) 192 186 return err; … … 264 258 old_legacy_ctrl, 265 259 &chip)) < 0) { 266 snd_card_free(card);267 260 release_and_free_resource(mpu_res); 268 261 release_and_free_resource(fm_res); 269 return err;262 goto free_card; 270 263 } 271 264 chip->fm_res = fm_res; … … 279 272 chip->reg_area_phys, 280 273 chip->irq); 281 if ((err = snd_ymfpci_pcm(chip, 0, NULL)) < 0) { 282 snd_card_free(card); 283 return err; 284 } 285 if ((err = snd_ymfpci_pcm_spdif(chip, 1, NULL)) < 0) { 286 snd_card_free(card); 287 return err; 288 } 289 if ((err = snd_ymfpci_pcm_4ch(chip, 2, NULL)) < 0) { 290 snd_card_free(card); 291 return err; 292 } 293 if ((err = snd_ymfpci_pcm2(chip, 3, NULL)) < 0) { 294 snd_card_free(card); 295 return err; 296 } 297 if ((err = snd_ymfpci_mixer(chip, rear_switch[dev])) < 0) { 298 snd_card_free(card); 299 return err; 300 } 301 if ((err = snd_ymfpci_timer(chip, 0)) < 0) { 302 snd_card_free(card); 303 return err; 304 } 274 err = snd_ymfpci_pcm(chip, 0); 275 if (err < 0) 276 goto free_card; 277 278 err = snd_ymfpci_pcm_spdif(chip, 1); 279 if (err < 0) 280 goto free_card; 281 282 err = snd_ymfpci_mixer(chip, rear_switch[dev]); 283 if (err < 0) 284 goto free_card; 285 286 if (chip->ac97->ext_id & AC97_EI_SDAC) { 287 err = snd_ymfpci_pcm_4ch(chip, 2); 288 if (err < 0) 289 goto free_card; 290 291 err = snd_ymfpci_pcm2(chip, 3); 292 if (err < 0) 293 goto free_card; 294 } 295 err = snd_ymfpci_timer(chip, 0); 296 if (err < 0) 297 goto free_card; 298 305 299 if (chip->mpu_res) { 306 300 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI, 307 301 mpu_port[dev], 308 MPU401_INFO_INTEGRATED, 309 pci->irq, 0, &chip->rawmidi)) < 0) { 310 printk(KERN_WARNING "ymfpci: cannot initialize MPU401 at 0x%lx, skipping...\n", mpu_port[dev]); 302 MPU401_INFO_INTEGRATED | 303 MPU401_INFO_IRQ_HOOK, 304 -1, &chip->rawmidi)) < 0) { 305 dev_warn(card->dev, 306 "cannot initialize MPU401 at 0x%lx, skipping...\n", 307 mpu_port[dev]); 311 308 legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */ 312 309 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); … … 318 315 fm_port[dev] + 2, 319 316 OPL3_HW_OPL3, 1, &opl3)) < 0) { 320 printk(KERN_WARNING "ymfpci: cannot initialize FM OPL3 at 0x%lx, skipping...\n", fm_port[dev]); 317 dev_warn(card->dev, 318 "cannot initialize FM OPL3 at 0x%lx, skipping...\n", 319 fm_port[dev]); 321 320 legacy_ctrl &= ~YMFPCI_LEGACY_FMEN; 322 321 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); 323 322 } else if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { 324 snd_card_free(card); 325 snd_printk(KERN_ERR "cannot create opl3 hwdep\n"); 326 return err; 323 dev_err(card->dev, "cannot create opl3 hwdep\n"); 324 goto free_card; 327 325 } 328 326 } … … 330 328 snd_ymfpci_create_gameport(chip, dev, legacy_ctrl, legacy_ctrl2); 331 329 332 if ((err = snd_card_register(card)) < 0) {333 snd_card_free(card);334 return err;335 } 330 err = snd_card_register(card); 331 if (err < 0) 332 goto free_card; 333 336 334 pci_set_drvdata(pci, card); 337 335 dev++; 338 336 return 0; 337 338 free_card: 339 snd_card_free(card); 340 return err; 339 341 } 340 342 341 static void __devexitsnd_card_ymfpci_remove(struct pci_dev *pci)343 static void snd_card_ymfpci_remove(struct pci_dev *pci) 342 344 { 343 345 snd_card_free(pci_get_drvdata(pci)); 344 pci_set_drvdata(pci, NULL);345 346 } 346 347 347 static struct pci_driver driver = {348 .name = "Yamaha DS-1 PCI",348 static struct pci_driver ymfpci_driver = { 349 .name = KBUILD_MODNAME, 349 350 .id_table = snd_ymfpci_ids, 350 351 .probe = snd_card_ymfpci_probe, 351 .remove = __devexit_p(snd_card_ymfpci_remove), 352 #ifdef CONFIG_PM 353 .suspend = snd_ymfpci_suspend, 354 .resume = snd_ymfpci_resume, 352 .remove = snd_card_ymfpci_remove, 353 #ifdef CONFIG_PM_SLEEP 354 .driver = { 355 .pm = &snd_ymfpci_pm, 356 }, 355 357 #endif 356 358 }; 357 359 358 static int __init alsa_card_ymfpci_init(void) 359 { 360 return pci_register_driver(&driver); 361 } 362 363 static void __exit alsa_card_ymfpci_exit(void) 364 { 365 pci_unregister_driver(&driver); 366 } 367 368 module_init(alsa_card_ymfpci_init) 369 module_exit(alsa_card_ymfpci_exit) 360 module_pci_driver(ymfpci_driver);
Note:
See TracChangeset
for help on using the changeset viewer.