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/emu10k1/emu10k1.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  The driver for the EMU10K1 (SB Live!) based soundcards
     
    56 *  Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk>
    67 *      Added support for Audigy 2 Value.
    7  *
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    23  *
    248 */
    259
     
    2711#include <linux/pci.h>
    2812#include <linux/time.h>
    29 #include <linux/moduleparam.h>
     13#include <linux/module.h>
    3014#include <sound/core.h>
    3115#include <sound/emu10k1.h>
    3216#include <sound/initval.h>
     17
     18#ifdef TARGET_OS2
     19#define KBUILD_MODNAME "emu10k1"
     20#endif
    3321
    3422MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
     
    3826               "{Creative Labs,SB Audigy}}");
    3927
    40 #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
     28#if IS_ENABLED(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER)
    4129#define ENABLE_SYNTH
    4230#include <sound/emu10k1_synth.h>
     
    4533static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4634static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    47 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;      /* Enable this card */
     35static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
    4836static int extin[SNDRV_CARDS];
    4937static int extout[SNDRV_CARDS];
     
    5745static int max_buffer_size[SNDRV_CARDS] = {128,128,128,128,128,128,128,128};
    5846#endif
    59 static int enable_ir[SNDRV_CARDS];
     47static bool enable_ir[SNDRV_CARDS];
    6048static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */
    6149#ifndef TARGET_OS2
     
    9078 * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value  Model:SB0400
    9179 */
    92 static DEFINE_PCI_DEVICE_TABLE(snd_emu10k1_ids) = {
     80static const struct pci_device_id snd_emu10k1_ids[] = {
    9381        { PCI_VDEVICE(CREATIVE, 0x0002), 0 },   /* EMU10K1 */
    9482        { PCI_VDEVICE(CREATIVE, 0x0004), 1 },   /* Audigy */
     
    11098MODULE_DEVICE_TABLE(pci, snd_emu10k1_ids);
    11199
    112 static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci,
    113                                             const struct pci_device_id *pci_id)
     100static int snd_card_emu10k1_probe(struct pci_dev *pci,
     101                                  const struct pci_device_id *pci_id)
    114102{
    115103        static int dev;
     
    128116        }
    129117
    130         err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
     118        err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
     119                           0, &card);
    131120        if (err < 0)
    132121                return err;
     
    142131        card->private_data = emu;
    143132        emu->delay_pcm_irq = delay_pcm_irq[dev] & 0x1f;
    144         if ((err = snd_emu10k1_pcm(emu, 0, NULL)) < 0)
    145                 goto error;
    146         if ((err = snd_emu10k1_pcm_mic(emu, 1, NULL)) < 0)
    147                 goto error;
    148         if ((err = snd_emu10k1_pcm_efx(emu, 2, NULL)) < 0)
     133        if ((err = snd_emu10k1_pcm(emu, 0)) < 0)
     134                goto error;
     135        if ((err = snd_emu10k1_pcm_mic(emu, 1)) < 0)
     136                goto error;
     137        if ((err = snd_emu10k1_pcm_efx(emu, 2)) < 0)
    149138                goto error;
    150139        /* This stores the periods table. */
    151140        if (emu->card_capabilities->ca0151_chip) { /* P16V */   
    152                 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
    153                                                1024, &emu->p16v_buffer)) < 0)
     141                err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev,
     142                                          1024, &emu->p16v_buffer);
     143                if (err < 0)
    154144                        goto error;
    155145        }
     
    161151                goto error;
    162152
    163         if ((err = snd_emu10k1_pcm_multi(emu, 3, NULL)) < 0)
     153        if ((err = snd_emu10k1_pcm_multi(emu, 3)) < 0)
    164154                goto error;
    165155        if (emu->card_capabilities->ca0151_chip) { /* P16V */
    166                 if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0)
     156                if ((err = snd_p16v_pcm(emu, 4)) < 0)
    167157                        goto error;
    168158        }
     
    174164                        goto error;
    175165        }
    176         if ((err = snd_emu10k1_fx8010_new(emu, 0, NULL)) < 0)
     166        if ((err = snd_emu10k1_fx8010_new(emu, 0)) < 0)
    177167                goto error;
    178168#ifdef ENABLE_SYNTH
     
    180170                               sizeof(struct snd_emu10k1_synth_arg), &wave) < 0 ||
    181171            wave == NULL) {
    182                 snd_printk(KERN_WARNING "can't initialize Emu10k1 wavetable synth\n");
     172                dev_warn(emu->card->dev,
     173                         "can't initialize Emu10k1 wavetable synth\n");
    183174        } else {
    184175                struct snd_emu10k1_synth_arg *arg;
     
    192183#endif
    193184 
    194         strcpy(card->driver, emu->card_capabilities->driver);
    195         strcpy(card->shortname, emu->card_capabilities->name);
     185        strlcpy(card->driver, emu->card_capabilities->driver,
     186                sizeof(card->driver));
     187        strlcpy(card->shortname, emu->card_capabilities->name,
     188                sizeof(card->shortname));
    196189        snprintf(card->longname, sizeof(card->longname),
    197190                 "%s (rev.%d, serial:0x%x) at 0x%lx, irq %i",
     
    201194                goto error;
    202195
     196        if (emu->card_capabilities->emu_model)
     197                schedule_delayed_work(&emu->emu1010.firmware_work, 0);
     198
    203199        pci_set_drvdata(pci, card);
    204200        dev++;
     
    210206}
    211207
    212 static void __devexit snd_card_emu10k1_remove(struct pci_dev *pci)
     208static void snd_card_emu10k1_remove(struct pci_dev *pci)
    213209{
    214210        snd_card_free(pci_get_drvdata(pci));
    215         pci_set_drvdata(pci, NULL);
    216 }
    217 
    218 
    219 #ifdef CONFIG_PM
    220 static int snd_emu10k1_suspend(struct pci_dev *pci, pm_message_t state)
    221 {
    222         struct snd_card *card = pci_get_drvdata(pci);
     211}
     212
     213
     214#ifdef CONFIG_PM_SLEEP
     215static int snd_emu10k1_suspend(struct device *dev)
     216{
     217        struct snd_card *card = dev_get_drvdata(dev);
    223218        struct snd_emu10k1 *emu = card->private_data;
    224219
    225220        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    226221
    227         snd_pcm_suspend_all(emu->pcm);
    228         snd_pcm_suspend_all(emu->pcm_mic);
    229         snd_pcm_suspend_all(emu->pcm_efx);
    230         snd_pcm_suspend_all(emu->pcm_multi);
    231         snd_pcm_suspend_all(emu->pcm_p16v);
     222        emu->suspend = 1;
     223
     224        cancel_delayed_work_sync(&emu->emu1010.firmware_work);
    232225
    233226        snd_ac97_suspend(emu->ac97);
     
    239232
    240233        snd_emu10k1_done(emu);
    241 
    242         pci_disable_device(pci);
    243         pci_save_state(pci);
    244         pci_set_power_state(pci, pci_choose_state(pci, state));
    245234        return 0;
    246235}
    247236
    248 static int snd_emu10k1_resume(struct pci_dev *pci)
    249 {
    250         struct snd_card *card = pci_get_drvdata(pci);
     237static int snd_emu10k1_resume(struct device *dev)
     238{
     239        struct snd_card *card = dev_get_drvdata(dev);
    251240        struct snd_emu10k1 *emu = card->private_data;
    252 
    253         pci_set_power_state(pci, PCI_D0);
    254         pci_restore_state(pci);
    255         if (pci_enable_device(pci) < 0) {
    256                 printk(KERN_ERR "emu10k1: pci_enable_device failed, "
    257                        "disabling device\n");
    258                 snd_card_disconnect(card);
    259                 return -EIO;
    260         }
    261         pci_set_master(pci);
    262241
    263242        snd_emu10k1_resume_init(emu);
     
    269248                snd_p16v_resume(emu);
    270249
     250        emu->suspend = 0;
     251
    271252        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
     253
     254        if (emu->card_capabilities->emu_model)
     255                schedule_delayed_work(&emu->emu1010.firmware_work, 0);
     256
    272257        return 0;
    273258}
    274 #endif
    275 
    276 static struct pci_driver driver = {
    277         .name = "EMU10K1_Audigy",
     259
     260static SIMPLE_DEV_PM_OPS(snd_emu10k1_pm, snd_emu10k1_suspend, snd_emu10k1_resume);
     261#define SND_EMU10K1_PM_OPS      &snd_emu10k1_pm
     262#else
     263#define SND_EMU10K1_PM_OPS      NULL
     264#endif /* CONFIG_PM_SLEEP */
     265
     266static struct pci_driver emu10k1_driver = {
     267        .name = KBUILD_MODNAME,
    278268        .id_table = snd_emu10k1_ids,
    279269        .probe = snd_card_emu10k1_probe,
    280         .remove = __devexit_p(snd_card_emu10k1_remove),
    281 #ifdef CONFIG_PM
    282         .suspend = snd_emu10k1_suspend,
    283         .resume = snd_emu10k1_resume,
    284 #endif
     270        .remove = snd_card_emu10k1_remove,
     271        .driver = {
     272                .pm = SND_EMU10K1_PM_OPS,
     273        },
    285274};
    286275
    287 static int __init alsa_card_emu10k1_init(void)
    288 {
    289         return pci_register_driver(&driver);
    290 }
    291 
    292 static void __exit alsa_card_emu10k1_exit(void)
    293 {
    294         pci_unregister_driver(&driver);
    295 }
    296 
    297 module_init(alsa_card_emu10k1_init)
    298 module_exit(alsa_card_emu10k1_exit)
     276module_pci_driver(emu10k1_driver);
Note: See TracChangeset for help on using the changeset viewer.