Ignore:
Timestamp:
Mar 18, 2021, 8:57:36 PM (4 years ago)
Author:
David Azarewicz
Message:

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/pci/ymfpci/ymfpci.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  The driver for the Yamaha's DS1/DS1E cards
    34 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    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  *
    205 */
    216
     
    238#include <linux/pci.h>
    249#include <linux/time.h>
    25 #include <linux/moduleparam.h>
     10#include <linux/module.h>
    2611#include <sound/core.h>
    27 #include <sound/ymfpci.h>
     12#include "ymfpci.h"
    2813#include <sound/mpu401.h>
    2914#include <sound/opl3.h>
    3015#include <sound/initval.h>
     16
     17#ifdef TARGET_OS2
     18#define KBUILD_MODNAME "ymfpci"
     19#endif
    3120
    3221MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
     
    4231static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4332static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    44 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;      /* Enable this card */
     33static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
    4534static long fm_port[SNDRV_CARDS];
    4635static long mpu_port[SNDRV_CARDS];
     
    4837static long joystick_port[SNDRV_CARDS];
    4938#endif
    50 static int rear_switch[SNDRV_CARDS];
     39static bool rear_switch[SNDRV_CARDS];
    5140
    5241module_param_array(index, int, NULL, 0444);
     
    5645module_param_array(enable, bool, NULL, 0444);
    5746MODULE_PARM_DESC(enable, "Enable Yamaha DS-1 soundcard.");
    58 module_param_array(mpu_port, long, NULL, 0444);
     47module_param_hw_array(mpu_port, long, ioport, NULL, 0444);
    5948MODULE_PARM_DESC(mpu_port, "MPU-401 Port.");
    60 module_param_array(fm_port, long, NULL, 0444);
     49module_param_hw_array(fm_port, long, ioport, NULL, 0444);
    6150MODULE_PARM_DESC(fm_port, "FM OPL-3 Port.");
    6251#ifdef SUPPORT_JOYSTICK
    63 module_param_array(joystick_port, long, NULL, 0444);
     52module_param_hw_array(joystick_port, long, ioport, NULL, 0444);
    6453MODULE_PARM_DESC(joystick_port, "Joystick port address");
    6554#endif
     
    6756MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch");
    6857
    69 static DEFINE_PCI_DEVICE_TABLE(snd_ymfpci_ids) = {
     58static const struct pci_device_id snd_ymfpci_ids[] = {
    7059        { PCI_VDEVICE(YAMAHA, 0x0004), 0, },   /* YMF724 */
    7160        { PCI_VDEVICE(YAMAHA, 0x000d), 0, },   /* YMF724F */
     
    8069
    8170#ifdef SUPPORT_JOYSTICK
    82 static int __devinit snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,
    83                                                 int legacy_ctrl, int legacy_ctrl2)
     71static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,
     72                                      int legacy_ctrl, int legacy_ctrl2)
    8473{
    8574        struct gameport *gp;
     
    10796                        }
    10897                        if (!r) {
    109                                 printk(KERN_ERR "ymfpci: no gameport ports available\n");
     98                                dev_err(chip->card->dev,
     99                                        "no gameport ports available\n");
    110100                                return -EBUSY;
    111101                        }
     
    117107                case 0x205: legacy_ctrl2 |= 3 << 6; break;
    118108                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);
    120111                        return -EINVAL;
    121112                }
     
    123114
    124115        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);
    126118                return -EBUSY;
    127119        }
     
    129121        chip->gameport = gp = gameport_allocate_port();
    130122        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");
    132125                release_and_free_resource(r);
    133126                return -ENOMEM;
     
    168161#endif /* SUPPORT_JOYSTICK */
    169162
    170 static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci,
    171                                           const struct pci_device_id *pci_id)
     163static int snd_card_ymfpci_probe(struct pci_dev *pci,
     164                                const struct pci_device_id *pci_id)
    172165{
    173166        static int dev;
     
    188181        }
    189182
    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);
    191185        if (err < 0)
    192186                return err;
     
    264258                                     old_legacy_ctrl,
    265259                                     &chip)) < 0) {
    266                 snd_card_free(card);
    267260                release_and_free_resource(mpu_res);
    268261                release_and_free_resource(fm_res);
    269                 return err;
     262                goto free_card;
    270263        }
    271264        chip->fm_res = fm_res;
     
    279272                chip->reg_area_phys,
    280273                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
    305299        if (chip->mpu_res) {
    306300                if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI,
    307301                                               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]);
    311308                        legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */
    312309                        pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
     
    318315                                           fm_port[dev] + 2,
    319316                                           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]);
    321320                        legacy_ctrl &= ~YMFPCI_LEGACY_FMEN;
    322321                        pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
    323322                } 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;
    327325                }
    328326        }
     
    330328        snd_ymfpci_create_gameport(chip, dev, legacy_ctrl, legacy_ctrl2);
    331329
    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
    336334        pci_set_drvdata(pci, card);
    337335        dev++;
    338336        return 0;
     337
     338free_card:
     339        snd_card_free(card);
     340        return err;
    339341}
    340342
    341 static void __devexit snd_card_ymfpci_remove(struct pci_dev *pci)
     343static void snd_card_ymfpci_remove(struct pci_dev *pci)
    342344{
    343345        snd_card_free(pci_get_drvdata(pci));
    344         pci_set_drvdata(pci, NULL);
    345346}
    346347
    347 static struct pci_driver driver = {
    348         .name = "Yamaha DS-1 PCI",
     348static struct pci_driver ymfpci_driver = {
     349        .name = KBUILD_MODNAME,
    349350        .id_table = snd_ymfpci_ids,
    350351        .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        },
    355357#endif
    356358};
    357359
    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)
     360module_pci_driver(ymfpci_driver);
Note: See TracChangeset for help on using the changeset viewer.