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

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
51 edited
7 copied

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/isa/Makefile

    r587 r679  
    77!include $(ROOT)\tools\header.mif
    88
    9 WMAKEOPTS=-h $(__MAKEOPTS__) KEE=$(KEE) DEBUG=$(DEBUG)
     9WMAKEOPTS=-h $(__MAKEOPTS__) DEBUG=$(DEBUG)
    1010
    1111
  • GPL/trunk/alsa-kernel/isa/ad1816a/ad1816a.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12
    23/*
     
    45    Copyright (C) 2000 by Massimo Piccioni <dafastidio@libero.it>
    56
    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
    197*/
    208
     
    2311#include <linux/wait.h>
    2412#include <linux/pnp.h>
    25 #include <linux/moduleparam.h>
     13#include <linux/module.h>
    2614#include <sound/core.h>
    2715#include <sound/initval.h>
     
    4533static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 1-MAX */
    4634static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    47 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;   /* Enable this card */
     35static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;  /* Enable this card */
    4836static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* PnP setup */
    4937static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
     
    6452MODULE_PARM_DESC(clockfreq, "Clock frequency for ad1816a driver (default = 0).");
    6553
    66 struct snd_card_ad1816a {
    67         struct pnp_dev *dev;
    68         struct pnp_dev *devmpu;
    69 };
    70 
    71 static struct pnp_card_device_id snd_ad1816a_pnpids[] = {
     54static const struct pnp_card_device_id snd_ad1816a_pnpids[] = {
    7255        /* Analog Devices AD1815 */
    7356        { .id = "ADS7150", .devs = { { .id = "ADS7150" }, { .id = "ADS7151" } } },
    74         /* Analog Device AD1816? */
     57        /* Analog Devices AD1816? */
    7558        { .id = "ADS7180", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } },
    7659        /* Analog Devices AD1816A - added by Kenneth Platz <kxp@atl.hp.com> */
     
    10083
    10184
    102 static int __devinit snd_card_ad1816a_pnp(int dev, struct snd_card_ad1816a *acard,
    103                                           struct pnp_card_link *card,
    104                                           const struct pnp_card_device_id *id)
     85static int snd_card_ad1816a_pnp(int dev, struct pnp_card_link *card,
     86                                const struct pnp_card_device_id *id)
    10587{
    10688        struct pnp_dev *pdev;
    10789        int err;
    10890
    109         acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
    110         if (acard->dev == NULL)
     91        pdev = pnp_request_card_device(card, id->devs[0].id, NULL);
     92        if (pdev == NULL)
    11193                return -EBUSY;
    112 
    113         acard->devmpu = pnp_request_card_device(card, id->devs[1].id, NULL);
    114         if (acard->devmpu == NULL) {
    115                 mpu_port[dev] = -1;
    116                 snd_printk(KERN_WARNING PFX "MPU401 device busy, skipping.\n");
    117         }
    118 
    119         pdev = acard->dev;
    12094
    12195        err = pnp_activate_dev(pdev);
     
    131105        irq[dev] = pnp_irq(pdev, 0);
    132106
    133         if (acard->devmpu == NULL)
     107        pdev = pnp_request_card_device(card, id->devs[1].id, NULL);
     108        if (pdev == NULL) {
     109                mpu_port[dev] = -1;
     110                snd_printk(KERN_WARNING PFX "MPU401 device busy, skipping.\n");
    134111                return 0;
    135 
    136         pdev = acard->devmpu;
     112        }
    137113
    138114        err = pnp_activate_dev(pdev);
     
    140116                printk(KERN_ERR PFX "MPU401 PnP configure failure\n");
    141117                mpu_port[dev] = -1;
    142                 acard->devmpu = NULL;
    143118        } else {
    144119                mpu_port[dev] = pnp_port_start(pdev, 0);
     
    149124}
    150125
    151 static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard,
    152                                             const struct pnp_card_device_id *pid)
     126static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard,
     127                                  const struct pnp_card_device_id *pid)
    153128{
    154129        int error;
    155130        struct snd_card *card;
    156         struct snd_card_ad1816a *acard;
    157131        struct snd_ad1816a *chip;
    158132        struct snd_opl3 *opl3;
    159         struct snd_timer *timer;
    160 
    161         error = snd_card_create(index[dev], id[dev], THIS_MODULE,
    162                                 sizeof(struct snd_card_ad1816a), &card);
     133
     134        error = snd_card_new(&pcard->card->dev,
     135                             index[dev], id[dev], THIS_MODULE,
     136                             sizeof(struct snd_ad1816a), &card);
    163137        if (error < 0)
    164138                return error;
    165         acard = card->private_data;
    166 
    167         if ((error = snd_card_ad1816a_pnp(dev, acard, pcard, pid))) {
    168                 snd_card_free(card);
    169                 return error;
    170         }
    171         snd_card_set_dev(card, &pcard->card->dev);
     139        chip = card->private_data;
     140
     141        if ((error = snd_card_ad1816a_pnp(dev, pcard, pid))) {
     142                snd_card_free(card);
     143                return error;
     144        }
    172145
    173146        if ((error = snd_ad1816a_create(card, port[dev],
     
    175148                                        dma1[dev],
    176149                                        dma2[dev],
    177                                         &chip)) < 0) {
     150                                        chip)) < 0) {
    178151                snd_card_free(card);
    179152                return error;
     
    187160                card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]);
    188161
    189         if ((error = snd_ad1816a_pcm(chip, 0, NULL)) < 0) {
     162        if ((error = snd_ad1816a_pcm(chip, 0)) < 0) {
    190163                snd_card_free(card);
    191164                return error;
     
    197170        }
    198171
    199         error = snd_ad1816a_timer(chip, 0, &timer);
     172        error = snd_ad1816a_timer(chip, 0);
    200173        if (error < 0) {
    201174                snd_card_free(card);
     
    205178        if (mpu_port[dev] > 0) {
    206179                if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
    207                                         mpu_port[dev], 0, mpu_irq[dev], IRQF_DISABLED,
     180                                        mpu_port[dev], 0, mpu_irq[dev],
    208181                                        NULL) < 0)
    209182                        printk(KERN_ERR PFX "no MPU-401 device at 0x%lx.\n", mpu_port[dev]);
     
    232205}
    233206
    234 static unsigned int __devinitdata ad1816a_devices;
    235 
    236 static int __devinit snd_ad1816a_pnp_detect(struct pnp_card_link *card,
    237                                             const struct pnp_card_device_id *id)
     207static unsigned int ad1816a_devices;
     208
     209static int snd_ad1816a_pnp_detect(struct pnp_card_link *card,
     210                                  const struct pnp_card_device_id *id)
    238211{
    239212        static int dev;
     
    253226}
    254227
    255 static void __devexit snd_ad1816a_pnp_remove(struct pnp_card_link * pcard)
     228static void snd_ad1816a_pnp_remove(struct pnp_card_link *pcard)
    256229{
    257230        snd_card_free(pnp_get_card_drvdata(pcard));
    258231        pnp_set_card_drvdata(pcard, NULL);
    259232}
     233
     234#ifdef CONFIG_PM
     235static int snd_ad1816a_pnp_suspend(struct pnp_card_link *pcard,
     236                                   pm_message_t state)
     237{
     238        struct snd_card *card = pnp_get_card_drvdata(pcard);
     239
     240        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
     241        snd_ad1816a_suspend(card->private_data);
     242        return 0;
     243}
     244
     245static int snd_ad1816a_pnp_resume(struct pnp_card_link *pcard)
     246{
     247        struct snd_card *card = pnp_get_card_drvdata(pcard);
     248
     249        snd_ad1816a_resume(card->private_data);
     250        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
     251        return 0;
     252}
     253#endif
    260254
    261255static struct pnp_card_driver ad1816a_pnpc_driver = {
     
    264258        .id_table       = snd_ad1816a_pnpids,
    265259        .probe          = snd_ad1816a_pnp_detect,
    266         .remove         = __devexit_p(snd_ad1816a_pnp_remove),
    267         /* FIXME: suspend/resume */
     260        .remove         = snd_ad1816a_pnp_remove,
     261#ifdef CONFIG_PM
     262        .suspend        = snd_ad1816a_pnp_suspend,
     263        .resume         = snd_ad1816a_pnp_resume,
     264#endif
    268265};
    269266
  • GPL/trunk/alsa-kernel/isa/ad1816a/ad1816a_lib.c

    r426 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23    ad1816a.c - lowlevel code for Analog Devices AD1816A chip.
    34    Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it>
    45
    5     This program is free software; you can redistribute it and/or modify
    6     it under the terms of the GNU General Public License as published by
    7     the Free Software Foundation; either version 2 of the License, or
    8     (at your option) any later version.
    9 
    10     This program is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13     GNU General Public License for more details.
    14 
    15     You should have received a copy of the GNU General Public License
    16     along with this program; if not, write to the Free Software
    17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    186*/
    197
     
    2311#include <linux/slab.h>
    2412#include <linux/ioport.h>
     13#include <linux/io.h>
    2514#include <sound/core.h>
    2615#include <sound/tlv.h>
    2716#include <sound/ad1816a.h>
    2817
    29 #include <asm/io.h>
    3018#include <asm/dma.h>
    3119
     
    8674
    8775static unsigned char snd_ad1816a_get_format(struct snd_ad1816a *chip,
    88                                             unsigned int format, int channels)
     76                                            snd_pcm_format_t format,
     77                                            int channels)
    8978{
    9079        unsigned char retval = AD1816A_FMT_LINEAR_8;
     
    218207}
    219208
    220 static int snd_ad1816a_hw_params(struct snd_pcm_substream *substream,
    221                                  struct snd_pcm_hw_params *hw_params)
    222 {
    223         return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
    224 }
    225 
    226 static int snd_ad1816a_hw_free(struct snd_pcm_substream *substream)
    227 {
    228         return snd_pcm_lib_free_pages(substream);
    229 }
    230 
    231209static int snd_ad1816a_playback_prepare(struct snd_pcm_substream *substream)
    232210{
     
    340318
    341319
    342 static struct snd_pcm_hardware snd_ad1816a_playback = {
     320static const struct snd_pcm_hardware snd_ad1816a_playback = {
    343321        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
    344322                                 SNDRV_PCM_INFO_MMAP_VALID),
     
    359337};
    360338
    361 static struct snd_pcm_hardware snd_ad1816a_capture = {
     339static const struct snd_pcm_hardware snd_ad1816a_capture = {
    362340        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
    363341                                 SNDRV_PCM_INFO_MMAP_VALID),
     
    432410}
    433411
    434 static struct snd_timer_hardware snd_ad1816a_timer_table = {
     412static const struct snd_timer_hardware snd_ad1816a_timer_table = {
    435413        .flags =        SNDRV_TIMER_HW_AUTO,
    436414        .resolution =   10000,
     
    492470
    493471
    494 static void __devinit snd_ad1816a_init(struct snd_ad1816a *chip)
     472static void snd_ad1816a_init(struct snd_ad1816a *chip)
    495473{
    496474        unsigned long flags;
     
    512490}
    513491
    514 static int __devinit snd_ad1816a_probe(struct snd_ad1816a *chip)
     492#ifdef CONFIG_PM
     493void snd_ad1816a_suspend(struct snd_ad1816a *chip)
     494{
     495        int reg;
     496        unsigned long flags;
     497
     498        spin_lock_irqsave(&chip->lock, flags);
     499        for (reg = 0; reg < 48; reg++)
     500                chip->image[reg] = snd_ad1816a_read(chip, reg);
     501        spin_unlock_irqrestore(&chip->lock, flags);
     502}
     503
     504void snd_ad1816a_resume(struct snd_ad1816a *chip)
     505{
     506        int reg;
     507        unsigned long flags;
     508
     509        snd_ad1816a_init(chip);
     510        spin_lock_irqsave(&chip->lock, flags);
     511        for (reg = 0; reg < 48; reg++)
     512                snd_ad1816a_write(chip, reg, chip->image[reg]);
     513        spin_unlock_irqrestore(&chip->lock, flags);
     514}
     515#endif
     516
     517static int snd_ad1816a_probe(struct snd_ad1816a *chip)
    515518{
    516519        unsigned long flags;
     
    549552                free_dma(chip->dma2);
    550553        }
    551         kfree(chip);
    552554        return 0;
    553555}
     
    559561}
    560562
    561 static const char __devinit *snd_ad1816a_chip_id(struct snd_ad1816a *chip)
     563static const char *snd_ad1816a_chip_id(struct snd_ad1816a *chip)
    562564{
    563565        switch (chip->hardware) {
     
    572574}
    573575
    574 int __devinit snd_ad1816a_create(struct snd_card *card,
    575                                 unsigned long port, int irq, int dma1, int dma2,
    576                                  struct snd_ad1816a **rchip)
    577 {
    578         static struct snd_device_ops ops = {
     576int snd_ad1816a_create(struct snd_card *card,
     577                      unsigned long port, int irq, int dma1, int dma2,
     578                       struct snd_ad1816a *chip)
     579{
     580        static const struct snd_device_ops ops = {
    579581                .dev_free =     snd_ad1816a_dev_free,
    580582        };
    581583        int error;
    582         struct snd_ad1816a *chip;
    583 
    584         *rchip = NULL;
    585 
    586         chip = kzalloc(sizeof(*chip), GFP_KERNEL);
    587         if (chip == NULL)
    588                 return -ENOMEM;
     584
    589585        chip->irq = -1;
    590586        chip->dma1 = -1;
     
    596592                return -EBUSY;
    597593        }
    598         if (request_irq(irq, snd_ad1816a_interrupt, IRQF_DISABLED, "AD1816A", (void *) chip)) {
     594        if (request_irq(irq, snd_ad1816a_interrupt, 0, "AD1816A", (void *) chip)) {
    599595                snd_printk(KERN_ERR "ad1816a: can't grab IRQ %d\n", irq);
    600596                snd_ad1816a_free(chip);
     
    602598        }
    603599        chip->irq = irq;
     600        card->sync_irq = chip->irq;
    604601        if (request_dma(dma1, "AD1816A - 1")) {
    605602                snd_printk(KERN_ERR "ad1816a: can't grab DMA1 %d\n", dma1);
     
    632629        }
    633630
    634         *rchip = chip;
    635         return 0;
    636 }
    637 
    638 static struct snd_pcm_ops snd_ad1816a_playback_ops = {
     631        return 0;
     632}
     633
     634static const struct snd_pcm_ops snd_ad1816a_playback_ops = {
    639635        .open =         snd_ad1816a_playback_open,
    640636        .close =        snd_ad1816a_playback_close,
    641         .ioctl =        snd_pcm_lib_ioctl,
    642         .hw_params =    snd_ad1816a_hw_params,
    643         .hw_free =      snd_ad1816a_hw_free,
    644637        .prepare =      snd_ad1816a_playback_prepare,
    645638        .trigger =      snd_ad1816a_playback_trigger,
     
    647640};
    648641
    649 static struct snd_pcm_ops snd_ad1816a_capture_ops = {
     642static const struct snd_pcm_ops snd_ad1816a_capture_ops = {
    650643        .open =         snd_ad1816a_capture_open,
    651644        .close =        snd_ad1816a_capture_close,
    652         .ioctl =        snd_pcm_lib_ioctl,
    653         .hw_params =    snd_ad1816a_hw_params,
    654         .hw_free =      snd_ad1816a_hw_free,
    655645        .prepare =      snd_ad1816a_capture_prepare,
    656646        .trigger =      snd_ad1816a_capture_trigger,
     
    658648};
    659649
    660 int __devinit snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm)
     650int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device)
    661651{
    662652        int error;
     
    675665        snd_ad1816a_init(chip);
    676666
    677         snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    678                                               snd_dma_isa_data(),
    679                                               64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
     667        snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev,
     668                                       64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
    680669
    681670        chip->pcm = pcm;
    682         if (rpcm)
    683                 *rpcm = pcm;
    684         return 0;
    685 }
    686 
    687 int __devinit snd_ad1816a_timer(struct snd_ad1816a *chip, int device, struct snd_timer **rtimer)
     671        return 0;
     672}
     673
     674int snd_ad1816a_timer(struct snd_ad1816a *chip, int device)
    688675{
    689676        struct snd_timer *timer;
     
    702689        chip->timer = timer;
    703690        timer->hw = snd_ad1816a_timer_table;
    704         if (rtimer)
    705                 *rtimer = timer;
    706691        return 0;
    707692}
     
    713698static int snd_ad1816a_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    714699{
    715         static char *texts[8] = {
     700        static const char * const texts[8] = {
    716701                "Line", "Mix", "CD", "Synth", "Video",
    717702                "Mic", "Phone",
    718703        };
    719704
    720         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    721         uinfo->count = 2;
    722         uinfo->value.enumerated.items = 7;
    723         if (uinfo->value.enumerated.item > 6)
    724                 uinfo->value.enumerated.item = 6;
    725         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
    726         return 0;
     705        return snd_ctl_enum_info(uinfo, 2, 7, texts);
    727706}
    728707
     
    906885static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
    907886
    908 static struct snd_kcontrol_new snd_ad1816a_controls[] __devinitdata = {
     887static const struct snd_kcontrol_new snd_ad1816a_controls[] = {
    909888AD1816A_DOUBLE("Master Playback Switch", AD1816A_MASTER_ATT, 15, 7, 1, 1),
    910889AD1816A_DOUBLE_TLV("Master Playback Volume", AD1816A_MASTER_ATT, 8, 0, 31, 1,
     
    952931};
    953932                                       
    954 int __devinit snd_ad1816a_mixer(struct snd_ad1816a *chip)
     933int snd_ad1816a_mixer(struct snd_ad1816a *chip)
    955934{
    956935        struct snd_card *card;
  • GPL/trunk/alsa-kernel/isa/ad1848/ad1848.c

    r410 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Generic driver for AD1848/AD1847/CS4248 chips (0.1 Alpha)
     
    45 *                   Jaroslav Kysela <perex@perex.cz>
    56 *  Based on card-4232.c by Jaroslav Kysela <perex@perex.cz>
    6  *
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    21  *
    227 */
    238
     
    2712#include <linux/time.h>
    2813#include <linux/wait.h>
    29 #include <linux/moduleparam.h>
     14#include <linux/module.h>
    3015#include <sound/core.h>
    3116#include <sound/wss.h>
     
    4429static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4530static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    46 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;  /* Enable this card */
     31static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
    4732static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* PnP setup */
    4833static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;        /* 5,7,9,11,12,15 */
    4934static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;       /* 0,1,3,5,6,7 */
    50 static int thinkpad[SNDRV_CARDS];                       /* Thinkpad special case */
     35static bool thinkpad[SNDRV_CARDS];                      /* Thinkpad special case */
    5136
    5237module_param_array(index, int, NULL, 0444);
     
    5641module_param_array(enable, bool, NULL, 0444);
    5742MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
    58 module_param_array(port, long, NULL, 0444);
     43module_param_hw_array(port, long, ioport, NULL, 0444);
    5944MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
    60 module_param_array(irq, int, NULL, 0444);
     45module_param_hw_array(irq, int, irq, NULL, 0444);
    6146MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
    62 module_param_array(dma1, int, NULL, 0444);
     47module_param_hw_array(dma1, int, dma, NULL, 0444);
    6348MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
    6449module_param_array(thinkpad, bool, NULL, 0444);
    6550MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series.");
    6651
    67 static int __devinit snd_ad1848_match(struct device *dev, unsigned int n)
     52static int snd_ad1848_match(struct device *dev, unsigned int n)
    6853{
    6954        if (!enable[n])
     
    8570}
    8671
    87 static int __devinit snd_ad1848_probe(struct device *dev, unsigned int n)
     72static int snd_ad1848_probe(struct device *dev, unsigned int n)
    8873{
    8974        struct snd_card *card;
    9075        struct snd_wss *chip;
    91         struct snd_pcm *pcm;
    9276        int error;
    9377
    94         error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card);
     78        error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
    9579        if (error < 0)
    9680                return error;
     
    10488        card->private_data = chip;
    10589
    106         error = snd_wss_pcm(chip, 0, &pcm);
     90        error = snd_wss_pcm(chip, 0);
    10791        if (error < 0)
    10892                goto out;
     
    11296                goto out;
    11397
    114         strcpy(card->driver, "AD1848");
    115         strcpy(card->shortname, pcm->name);
     98        strlcpy(card->driver, "AD1848", sizeof(card->driver));
     99        strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname));
    116100
    117         sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
    118                 pcm->name, chip->port, irq[n], dma1[n]);
    119         if (thinkpad[n])
    120                 strcat(card->longname, " [Thinkpad]");
    121 
    122         snd_card_set_dev(card, dev);
     101        if (!thinkpad[n])
     102                snprintf(card->longname, sizeof(card->longname),
     103                         "%s at 0x%lx, irq %d, dma %d",
     104                         chip->pcm->name, chip->port, irq[n], dma1[n]);
     105        else
     106                snprintf(card->longname, sizeof(card->longname),
     107                         "%s at 0x%lx, irq %d, dma %d [Thinkpad]",
     108                         chip->pcm->name, chip->port, irq[n], dma1[n]);
    123109
    124110        error = snd_card_register(card);
     
    133119}
    134120
    135 static int __devexit snd_ad1848_remove(struct device *dev, unsigned int n)
     121static int snd_ad1848_remove(struct device *dev, unsigned int n)
    136122{
    137123        snd_card_free(dev_get_drvdata(dev));
    138         dev_set_drvdata(dev, NULL);
    139124        return 0;
    140125}
     
    165150        .match          = snd_ad1848_match,
    166151        .probe          = snd_ad1848_probe,
    167         .remove         = __devexit_p(snd_ad1848_remove),
     152        .remove         = snd_ad1848_remove,
    168153#ifdef CONFIG_PM
    169154        .suspend        = snd_ad1848_suspend,
     
    175160};
    176161
    177 static int __init alsa_card_ad1848_init(void)
    178 {
    179         return isa_register_driver(&snd_ad1848_driver, SNDRV_CARDS);
    180 }
    181 
    182 static void __exit alsa_card_ad1848_exit(void)
    183 {
    184         isa_unregister_driver(&snd_ad1848_driver);
    185 }
    186 
    187 module_init(alsa_card_ad1848_init);
    188 module_exit(alsa_card_ad1848_exit);
     162module_isa_driver(snd_ad1848_driver, SNDRV_CARDS);
  • GPL/trunk/alsa-kernel/isa/als100.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12
    23/*
     
    89
    910    Generalised for soundcards based on DT-0196 and ALS-007 chips
    10     by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>: June 2002.
    11 
    12     This program is free software; you can redistribute it and/or modify
    13     it under the terms of the GNU General Public License as published by
    14     the Free Software Foundation; either version 2 of the License, or
    15     (at your option) any later version.
    16 
    17     This program is distributed in the hope that it will be useful,
    18     but WITHOUT ANY WARRANTY; without even the implied warranty of
    19     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20     GNU General Public License for more details.
    21 
    22     You should have received a copy of the GNU General Public License
    23     along with this program; if not, write to the Free Software
    24     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     11    by Jonathan Woithe <jwoithe@just42.net>: June 2002.
     12
    2513*/
    2614
     
    2917#include <linux/time.h>
    3018#include <linux/pnp.h>
    31 #include <linux/moduleparam.h>
     19#include <linux/module.h>
    3220#include <sound/core.h>
    3321#include <sound/initval.h>
     
    5543static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    5644static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    57 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;  /* Enable this card */
     45static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
    5846static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* PnP setup */
    5947static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
     
    8068};
    8169
    82 static struct pnp_card_device_id snd_als100_pnpids[] = {
     70static const struct pnp_card_device_id snd_als100_pnpids[] = {
    8371        /* DT197A30 */
    8472        { .id = "RWB1688",
     
    118106MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids);
    119107
    120 static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard,
    121                                         struct pnp_card_link *card,
    122                                         const struct pnp_card_device_id *id)
     108static int snd_card_als100_pnp(int dev, struct snd_card_als100 *acard,
     109                              struct pnp_card_link *card,
     110                              const struct pnp_card_device_id *id)
    123111{
    124112        struct pnp_dev *pdev;
     
    184172}
    185173
    186 static int __devinit snd_card_als100_probe(int dev,
    187                                         struct pnp_card_link *pcard,
    188                                         const struct pnp_card_device_id *pid)
     174static int snd_card_als100_probe(int dev,
     175                                 struct pnp_card_link *pcard,
     176                                 const struct pnp_card_device_id *pid)
    189177{
    190178        int error;
     
    194182        struct snd_opl3 *opl3;
    195183
    196         error = snd_card_create(index[dev], id[dev], THIS_MODULE,
    197                                 sizeof(struct snd_card_als100), &card);
     184        error = snd_card_new(&pcard->card->dev,
     185                             index[dev], id[dev], THIS_MODULE,
     186                             sizeof(struct snd_card_als100), &card);
    198187        if (error < 0)
    199188                return error;
     
    204193                return error;
    205194        }
    206         snd_card_set_dev(card, &pcard->card->dev);
    207195
    208196        if (pid->driver_data == SB_HW_DT019X)
     
    223211                strcpy(card->driver, "DT-019X");
    224212                strcpy(card->shortname, "Diamond Tech. DT-019X");
    225                 sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d",
    226                         card->shortname, chip->name, chip->port,
    227                         irq[dev], dma8[dev]);
     213                snprintf(card->longname, sizeof(card->longname),
     214                         "Diamond Tech. DT-019X, %s at 0x%lx, irq %d, dma %d",
     215                         chip->name, chip->port, irq[dev], dma8[dev]);
    228216        } else {
    229217                strcpy(card->driver, "ALS100");
    230218                strcpy(card->shortname, "Avance Logic ALS100");
    231                 sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d",
    232                         card->shortname, chip->name, chip->port,
    233                         irq[dev], dma8[dev], dma16[dev]);
    234         }
    235 
    236         if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) {
     219                snprintf(card->longname, sizeof(card->longname),
     220                         "Avance Logic ALS100, %s at 0x%lx, irq %d, dma %d&%d",
     221                         chip->name, chip->port, irq[dev], dma8[dev],
     222                         dma16[dev]);
     223        }
     224
     225        if ((error = snd_sb16dsp_pcm(chip, 0)) < 0) {
    237226                snd_card_free(card);
    238227                return error;
     
    257246                                        mpu_port[dev], 0,
    258247                                        mpu_irq[dev],
    259                                         mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0,
    260248                                        NULL) < 0)
    261249                        snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]);
     
    288276}
    289277
    290 static unsigned int __devinitdata als100_devices;
    291 
    292 static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card,
    293                                           const struct pnp_card_device_id *id)
     278static unsigned int als100_devices;
     279
     280static int snd_als100_pnp_detect(struct pnp_card_link *card,
     281                                const struct pnp_card_device_id *id)
    294282{
    295283        static int dev;
     
    309297}
    310298
    311 static void __devexit snd_als100_pnp_remove(struct pnp_card_link * pcard)
     299static void snd_als100_pnp_remove(struct pnp_card_link *pcard)
    312300{
    313301        snd_card_free(pnp_get_card_drvdata(pcard));
     
    323311
    324312        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    325         snd_pcm_suspend_all(chip->pcm);
    326313        snd_sbmixer_suspend(chip);
    327314        return 0;
     
    346333        .id_table       = snd_als100_pnpids,
    347334        .probe          = snd_als100_pnp_detect,
    348         .remove         = __devexit_p(snd_als100_pnp_remove),
     335        .remove         = snd_als100_pnp_remove,
    349336#ifdef CONFIG_PM
    350337        .suspend        = snd_als100_pnp_suspend,
  • GPL/trunk/alsa-kernel/isa/azt2320.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23    card-azt2320.c - driver for Aztech Systems AZT2320 based soundcards.
    34    Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it>
    45
    5     This program is free software; you can redistribute it and/or modify
    6     it under the terms of the GNU General Public License as published by
    7     the Free Software Foundation; either version 2 of the License, or
    8     (at your option) any later version.
    9 
    10     This program is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13     GNU General Public License for more details.
    14 
    15     You should have received a copy of the GNU General Public License
    16     along with this program; if not, write to the Free Software
    17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    186*/
    197
     
    3018*/
    3119
    32 #include <asm/io.h>
     20#include <linux/io.h>
    3321#include <linux/delay.h>
    3422#include <linux/init.h>
     
    3624#include <linux/wait.h>
    3725#include <linux/pnp.h>
    38 #include <linux/moduleparam.h>
     26#include <linux/module.h>
    3927#include <sound/core.h>
    4028#include <sound/initval.h>
     
    5644static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    5745static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    58 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
     46static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    5947static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* PnP setup */
    6048static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
     
    8068};
    8169
    82 static struct pnp_card_device_id snd_azt2320_pnpids[] = {
     70static const struct pnp_card_device_id snd_azt2320_pnpids[] = {
    8371        /* PRO16V */
    8472        { .id = "AZT1008", .devs = { { "AZT1008" }, { "AZT2001" }, } },
     
    10088#define DRIVER_NAME     "snd-card-azt2320"
    10189
    102 static int __devinit snd_card_azt2320_pnp(int dev, struct snd_card_azt2320 *acard,
    103                                           struct pnp_card_link *card,
    104                                           const struct pnp_card_device_id *id)
     90static int snd_card_azt2320_pnp(int dev, struct snd_card_azt2320 *acard,
     91                                struct pnp_card_link *card,
     92                                const struct pnp_card_device_id *id)
    10593{
    10694        struct pnp_dev *pdev;
     
    148136
    149137/* same of snd_sbdsp_command by Jaroslav Kysela */
    150 static int __devinit snd_card_azt2320_command(unsigned long port, unsigned char val)
     138static int snd_card_azt2320_command(unsigned long port, unsigned char val)
    151139{
    152140        int i;
     
    162150}
    163151
    164 static int __devinit snd_card_azt2320_enable_wss(unsigned long port)
     152static int snd_card_azt2320_enable_wss(unsigned long port)
    165153{
    166154        int error;
     
    175163}
    176164
    177 static int __devinit snd_card_azt2320_probe(int dev,
    178                                             struct pnp_card_link *pcard,
    179                                             const struct pnp_card_device_id *pid)
     165static int snd_card_azt2320_probe(int dev,
     166                                  struct pnp_card_link *pcard,
     167                                  const struct pnp_card_device_id *pid)
    180168{
    181169        int error;
     
    185173        struct snd_opl3 *opl3;
    186174
    187         error = snd_card_create(index[dev], id[dev], THIS_MODULE,
    188                                 sizeof(struct snd_card_azt2320), &card);
     175        error = snd_card_new(&pcard->card->dev,
     176                             index[dev], id[dev], THIS_MODULE,
     177                             sizeof(struct snd_card_azt2320), &card);
    189178        if (error < 0)
    190179                return error;
     
    195184                return error;
    196185        }
    197         snd_card_set_dev(card, &pcard->card->dev);
    198186
    199187        if ((error = snd_card_azt2320_enable_wss(port[dev]))) {
     
    216204                card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]);
    217205
    218         error = snd_wss_pcm(chip, 0, NULL);
     206        error = snd_wss_pcm(chip, 0);
    219207        if (error < 0) {
    220208                snd_card_free(card);
     
    226214                return error;
    227215        }
    228         error = snd_wss_timer(chip, 0, NULL);
     216        error = snd_wss_timer(chip, 0);
    229217        if (error < 0) {
    230218                snd_card_free(card);
     
    235223                if (snd_mpu401_uart_new(card, 0, MPU401_HW_AZT2320,
    236224                                mpu_port[dev], 0,
    237                                 mpu_irq[dev], IRQF_DISABLED,
    238                                 NULL) < 0)
     225                                mpu_irq[dev], NULL) < 0)
    239226                        snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]);
    240227        }
     
    266253}
    267254
    268 static unsigned int __devinitdata azt2320_devices;
    269 
    270 static int __devinit snd_azt2320_pnp_detect(struct pnp_card_link *card,
    271                                             const struct pnp_card_device_id *id)
     255static unsigned int azt2320_devices;
     256
     257static int snd_azt2320_pnp_detect(struct pnp_card_link *card,
     258                                  const struct pnp_card_device_id *id)
    272259{
    273260        static int dev;
     
    287274}
    288275
    289 static void __devexit snd_azt2320_pnp_remove(struct pnp_card_link * pcard)
     276static void snd_azt2320_pnp_remove(struct pnp_card_link *pcard)
    290277{
    291278        snd_card_free(pnp_get_card_drvdata(pcard));
     
    322309        .id_table       = snd_azt2320_pnpids,
    323310        .probe          = snd_azt2320_pnp_detect,
    324         .remove         = __devexit_p(snd_azt2320_pnp_remove),
     311        .remove         = snd_azt2320_pnp_remove,
    325312#ifdef CONFIG_PM
    326313        .suspend        = snd_azt2320_pnp_suspend,
  • GPL/trunk/alsa-kernel/isa/cmi8330.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for C-Media's CMI8330 and CMI8329 soundcards.
    34 *  Copyright (c) by George Talusan <gstalusan@uwaterloo.ca>
    45 *    http://www.undergrad.math.uwaterloo.ca/~gstalusa
    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  *
    206 */
    217
     
    4834#include <linux/isa.h>
    4935#include <linux/pnp.h>
    50 #include <linux/moduleparam.h>
     36#include <linux/module.h>
    5137#include <sound/core.h>
    5238#include <sound/wss.h>
     
    7056static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
    7157static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
    72 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
    73 #ifdef CONFIG_PNP
    74 static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
     58static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
     59#ifdef CONFIG_PNP
     60static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
    7561#endif
    7662static long sbport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
     
    9682#endif
    9783
    98 module_param_array(sbport, long, NULL, 0444);
     84module_param_hw_array(sbport, long, ioport, NULL, 0444);
    9985MODULE_PARM_DESC(sbport, "Port # for CMI8330/CMI8329 SB driver.");
    100 module_param_array(sbirq, int, NULL, 0444);
     86module_param_hw_array(sbirq, int, irq, NULL, 0444);
    10187MODULE_PARM_DESC(sbirq, "IRQ # for CMI8330/CMI8329 SB driver.");
    102 module_param_array(sbdma8, int, NULL, 0444);
     88module_param_hw_array(sbdma8, int, dma, NULL, 0444);
    10389MODULE_PARM_DESC(sbdma8, "DMA8 for CMI8330/CMI8329 SB driver.");
    104 module_param_array(sbdma16, int, NULL, 0444);
     90module_param_hw_array(sbdma16, int, dma, NULL, 0444);
    10591MODULE_PARM_DESC(sbdma16, "DMA16 for CMI8330/CMI8329 SB driver.");
    10692
    107 module_param_array(wssport, long, NULL, 0444);
     93module_param_hw_array(wssport, long, ioport, NULL, 0444);
    10894MODULE_PARM_DESC(wssport, "Port # for CMI8330/CMI8329 WSS driver.");
    109 module_param_array(wssirq, int, NULL, 0444);
     95module_param_hw_array(wssirq, int, irq, NULL, 0444);
    11096MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330/CMI8329 WSS driver.");
    111 module_param_array(wssdma, int, NULL, 0444);
     97module_param_hw_array(wssdma, int, dma, NULL, 0444);
    11298MODULE_PARM_DESC(wssdma, "DMA for CMI8330/CMI8329 WSS driver.");
    11399
    114 module_param_array(fmport, long, NULL, 0444);
     100module_param_hw_array(fmport, long, ioport, NULL, 0444);
    115101MODULE_PARM_DESC(fmport, "FM port # for CMI8330/CMI8329 driver.");
    116 module_param_array(mpuport, long, NULL, 0444);
     102module_param_hw_array(mpuport, long, ioport, NULL, 0444);
    117103MODULE_PARM_DESC(mpuport, "MPU-401 port # for CMI8330/CMI8329 driver.");
    118 module_param_array(mpuirq, int, NULL, 0444);
     104module_param_hw_array(mpuirq, int, irq, NULL, 0444);
    119105MODULE_PARM_DESC(mpuirq, "IRQ # for CMI8330/CMI8329 MPU-401 port.");
    120106#ifdef CONFIG_PNP
     
    135121#define CMI8330_CDINGAIN  26
    136122
    137 static unsigned char snd_cmi8330_image[((CMI8330_CDINGAIN)-16) + 1] =
     123static const unsigned char snd_cmi8330_image[((CMI8330_CDINGAIN)-16) + 1] =
    138124{
    139125        0x40,                   /* 16 - recording mux (SB-mixer-enabled) */
     
    183169#ifdef CONFIG_PNP
    184170
    185 static struct pnp_card_device_id snd_cmi8330_pnpids[] = {
     171static const struct pnp_card_device_id snd_cmi8330_pnpids[] = {
    186172        { .id = "CMI0001", .devs = { { "@X@0001" }, { "@@@0001" }, { "@H@0001" }, { "A@@0001" } } },
    187173        { .id = "CMI0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } } },
     
    194180
    195181
    196 static struct snd_kcontrol_new snd_cmi8330_controls[] __devinitdata = {
     182static const struct snd_kcontrol_new snd_cmi8330_controls[] = {
    197183WSS_DOUBLE("Master Playback Volume", 0,
    198184                CMI8330_MASTVOL, CMI8330_MASTVOL, 4, 0, 15, 0),
     
    250236
    251237#ifdef ENABLE_SB_MIXER
    252 static struct sbmix_elem cmi8330_sb_mixers[] __devinitdata = {
     238static const struct sbmix_elem cmi8330_sb_mixers[] = {
    253239SB_DOUBLE("SB Master Playback Volume", SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31),
    254240SB_DOUBLE("Tone Control - Bass", SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15),
     
    268254};
    269255
    270 static unsigned char cmi8330_sb_init_values[][2] __devinitdata = {
     256static const unsigned char cmi8330_sb_init_values[][2] = {
    271257        { SB_DSP4_MASTER_DEV + 0, 0 },
    272258        { SB_DSP4_MASTER_DEV + 1, 0 },
     
    282268
    283269
    284 static int __devinit cmi8330_add_sb_mixers(struct snd_sb *chip)
     270static int cmi8330_add_sb_mixers(struct snd_sb *chip)
    285271{
    286272        int idx, err;
     
    307293#endif
    308294
    309 static int __devinit snd_cmi8330_mixer(struct snd_card *card, struct snd_cmi8330 *acard)
     295static int snd_cmi8330_mixer(struct snd_card *card, struct snd_cmi8330 *acard)
    310296{
    311297        unsigned int idx;
     
    330316
    331317#ifdef CONFIG_PNP
    332 static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard,
    333                                      struct pnp_card_link *card,
    334                                      const struct pnp_card_device_id *id)
     318static int snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard,
     319                           struct pnp_card_link *card,
     320                           const struct pnp_card_device_id *id)
    335321{
    336322        struct pnp_dev *pdev;
     
    438424}
    439425
    440 static int __devinit snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip)
     426static int snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip)
    441427{
    442428        struct snd_pcm *pcm;
    443429        const struct snd_pcm_ops *ops;
    444430        int err;
    445         static snd_pcm_open_callback_t cmi_open_callbacks[2] = {
     431        static const snd_pcm_open_callback_t cmi_open_callbacks[2] = {
    446432                snd_cmi8330_playback_open,
    447433                snd_cmi8330_capture_open
     
    470456        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &chip->streams[SNDRV_PCM_STREAM_CAPTURE].ops);
    471457
    472         snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    473                                               snd_dma_isa_data(),
    474                                               64*1024, 128*1024);
     458        snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
     459                                       card->dev, 64*1024, 128*1024);
    475460        chip->pcm = pcm;
    476461
     
    485470
    486471        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    487         snd_pcm_suspend_all(acard->pcm);
    488472        acard->wss->suspend(acard->wss);
    489473        snd_sbmixer_suspend(acard->sb);
     
    515499#define PFX     "cmi8330: "
    516500
    517 static int snd_cmi8330_card_new(int dev, struct snd_card **cardp)
     501static int snd_cmi8330_card_new(struct device *pdev, int dev,
     502                                struct snd_card **cardp)
    518503{
    519504        struct snd_card *card;
     
    521506        int err;
    522507
    523         err = snd_card_create(index[dev], id[dev], THIS_MODULE,
    524                               sizeof(struct snd_cmi8330), &card);
     508        err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
     509                           sizeof(struct snd_cmi8330), &card);
    525510        if (err < 0) {
    526511                snd_printk(KERN_ERR PFX "could not get a new card\n");
     
    533518}
    534519
    535 static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev)
     520static int snd_cmi8330_probe(struct snd_card *card, int dev)
    536521{
    537522        struct snd_cmi8330 *acard;
     
    598583                if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
    599584                                        mpuport[dev], 0, mpuirq[dev],
    600                                         IRQF_DISABLED, NULL) < 0)
     585                                        NULL) < 0)
    601586                        printk(KERN_ERR PFX "no MPU-401 device at 0x%lx.\n",
    602587                                mpuport[dev]);
     
    614599}
    615600
    616 static int __devinit snd_cmi8330_isa_match(struct device *pdev,
    617                                           unsigned int dev)
     601static int snd_cmi8330_isa_match(struct device *pdev,
     602                                unsigned int dev)
    618603{
    619604        if (!enable[dev] || is_isapnp_selected(dev))
     
    630615}
    631616
    632 static int __devinit snd_cmi8330_isa_probe(struct device *pdev,
    633                                           unsigned int dev)
     617static int snd_cmi8330_isa_probe(struct device *pdev,
     618                                unsigned int dev)
    634619{
    635620        struct snd_card *card;
    636621        int err;
    637622
    638         err = snd_cmi8330_card_new(dev, &card);
     623        err = snd_cmi8330_card_new(pdev, dev, &card);
    639624        if (err < 0)
    640625                return err;
    641         snd_card_set_dev(card, pdev);
    642626        if ((err = snd_cmi8330_probe(card, dev)) < 0) {
    643627                snd_card_free(card);
     
    648632}
    649633
    650 static int __devexit snd_cmi8330_isa_remove(struct device *devptr,
    651                                             unsigned int dev)
     634static int snd_cmi8330_isa_remove(struct device *devptr,
     635                                  unsigned int dev)
    652636{
    653637        snd_card_free(dev_get_drvdata(devptr));
    654         dev_set_drvdata(devptr, NULL);
    655638        return 0;
    656639}
     
    674657        .match          = snd_cmi8330_isa_match,
    675658        .probe          = snd_cmi8330_isa_probe,
    676         .remove         = __devexit_p(snd_cmi8330_isa_remove),
     659        .remove         = snd_cmi8330_isa_remove,
    677660#ifdef CONFIG_PM
    678661        .suspend        = snd_cmi8330_isa_suspend,
     
    686669
    687670#ifdef CONFIG_PNP
    688 static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard,
    689                                             const struct pnp_card_device_id *pid)
     671static int snd_cmi8330_pnp_detect(struct pnp_card_link *pcard,
     672                                  const struct pnp_card_device_id *pid)
    690673{
    691674        static int dev;
     
    700683                return -ENODEV;
    701684                               
    702         res = snd_cmi8330_card_new(dev, &card);
     685        res = snd_cmi8330_card_new(&pcard->card->dev, dev, &card);
    703686        if (res < 0)
    704687                return res;
     
    708691                return res;
    709692        }
    710         snd_card_set_dev(card, &pcard->card->dev);
    711693        if ((res = snd_cmi8330_probe(card, dev)) < 0) {
    712694                snd_card_free(card);
     
    718700}
    719701
    720 static void __devexit snd_cmi8330_pnp_remove(struct pnp_card_link * pcard)
     702static void snd_cmi8330_pnp_remove(struct pnp_card_link *pcard)
    721703{
    722704        snd_card_free(pnp_get_card_drvdata(pcard));
     
    741723        .id_table = snd_cmi8330_pnpids,
    742724        .probe = snd_cmi8330_pnp_detect,
    743         .remove = __devexit_p(snd_cmi8330_pnp_remove),
     725        .remove = snd_cmi8330_pnp_remove,
    744726#ifdef CONFIG_PM
    745727        .suspend        = snd_cmi8330_pnp_suspend,
  • GPL/trunk/alsa-kernel/isa/cs423x/cs4231.c

    r410 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Generic driver for CS4231 chips
     
    45 *  Originally the CS4232/CS4232A driver, modified for use on CS4231 by
    56 *  Tugrul Galatali <galatalt@stuy.edu>
    6  *
    7  *   This program is free software; you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation; either version 2 of the License, or
    10  *   (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    20  *
    217 */
    228
     
    2612#include <linux/time.h>
    2713#include <linux/wait.h>
    28 #include <linux/moduleparam.h>
     14#include <linux/module.h>
    2915#include <sound/core.h>
    3016#include <sound/wss.h>
     
    4228static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4329static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    44 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;  /* Enable this card */
     30static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
    4531static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* PnP setup */
    4632static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
     
    5642module_param_array(enable, bool, NULL, 0444);
    5743MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
    58 module_param_array(port, long, NULL, 0444);
     44module_param_hw_array(port, long, ioport, NULL, 0444);
    5945MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
    60 module_param_array(mpu_port, long, NULL, 0444);
     46module_param_hw_array(mpu_port, long, ioport, NULL, 0444);
    6147MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
    62 module_param_array(irq, int, NULL, 0444);
     48module_param_hw_array(irq, int, irq, NULL, 0444);
    6349MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
    64 module_param_array(mpu_irq, int, NULL, 0444);
     50module_param_hw_array(mpu_irq, int, irq, NULL, 0444);
    6551MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
    66 module_param_array(dma1, int, NULL, 0444);
     52module_param_hw_array(dma1, int, dma, NULL, 0444);
    6753MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
    68 module_param_array(dma2, int, NULL, 0444);
     54module_param_hw_array(dma2, int, dma, NULL, 0444);
    6955MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver.");
    7056
    71 static int __devinit snd_cs4231_match(struct device *dev, unsigned int n)
     57static int snd_cs4231_match(struct device *dev, unsigned int n)
    7258{
    7359        if (!enable[n])
     
    8975}
    9076
    91 static int __devinit snd_cs4231_probe(struct device *dev, unsigned int n)
     77static int snd_cs4231_probe(struct device *dev, unsigned int n)
    9278{
    9379        struct snd_card *card;
    9480        struct snd_wss *chip;
    95         struct snd_pcm *pcm;
    9681        int error;
    9782
    98         error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card);
     83        error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
    9984        if (error < 0)
    10085                return error;
     
    10792        card->private_data = chip;
    10893
    109         error = snd_wss_pcm(chip, 0, &pcm);
     94        error = snd_wss_pcm(chip, 0);
    11095        if (error < 0)
    11196                goto out;
    11297
    113         strcpy(card->driver, "CS4231");
    114         strcpy(card->shortname, pcm->name);
     98        strlcpy(card->driver, "CS4231", sizeof(card->driver));
     99        strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname));
    115100
    116         sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
    117                 pcm->name, chip->port, irq[n], dma1[n]);
    118         if (dma2[n] >= 0)
    119                 sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]);
     101        if (dma2[n] < 0)
     102                snprintf(card->longname, sizeof(card->longname),
     103                         "%s at 0x%lx, irq %d, dma %d",
     104                         chip->pcm->name, chip->port, irq[n], dma1[n]);
     105        else
     106                snprintf(card->longname, sizeof(card->longname),
     107                         "%s at 0x%lx, irq %d, dma %d&%d",
     108                         chip->pcm->name, chip->port, irq[n], dma1[n], dma2[n]);
    120109
    121110        error = snd_wss_mixer(chip);
     
    123112                goto out;
    124113
    125         error = snd_wss_timer(chip, 0, NULL);
     114        error = snd_wss_timer(chip, 0);
    126115        if (error < 0)
    127116                goto out;
     
    132121                if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
    133122                                        mpu_port[n], 0, mpu_irq[n],
    134                                         mpu_irq[n] >= 0 ? IRQF_DISABLED : 0,
    135123                                        NULL) < 0)
    136124                        dev_warn(dev, "MPU401 not detected\n");
    137125        }
    138 
    139         snd_card_set_dev(card, dev);
    140126
    141127        error = snd_card_register(card);
     
    150136}
    151137
    152 static int __devexit snd_cs4231_remove(struct device *dev, unsigned int n)
     138static int snd_cs4231_remove(struct device *dev, unsigned int n)
    153139{
    154140        snd_card_free(dev_get_drvdata(dev));
    155         dev_set_drvdata(dev, NULL);
    156141        return 0;
    157142}
     
    182167        .match          = snd_cs4231_match,
    183168        .probe          = snd_cs4231_probe,
    184         .remove         = __devexit_p(snd_cs4231_remove),
     169        .remove         = snd_cs4231_remove,
    185170#ifdef CONFIG_PM
    186171        .suspend        = snd_cs4231_suspend,
     
    192177};
    193178
    194 static int __init alsa_card_cs4231_init(void)
    195 {
    196         return isa_register_driver(&snd_cs4231_driver, SNDRV_CARDS);
    197 }
    198 
    199 static void __exit alsa_card_cs4231_exit(void)
    200 {
    201         isa_unregister_driver(&snd_cs4231_driver);
    202 }
    203 
    204 module_init(alsa_card_cs4231_init);
    205 module_exit(alsa_card_cs4231_exit);
     179module_isa_driver(snd_cs4231_driver, SNDRV_CARDS);
  • GPL/trunk/alsa-kernel/isa/cs423x/cs4236.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for generic CS4232/CS4235/CS4236/CS4236B/CS4237B/CS4238B/CS4239 chips
    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
     
    249#include <linux/isa.h>
    2510#include <linux/pnp.h>
    26 #include <linux/moduleparam.h>
     11#include <linux/module.h>
    2712#include <sound/core.h>
    2813#include <sound/wss.h>
     
    7560static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    7661static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    77 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    78 #ifdef CONFIG_PNP
    79 static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
     62static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
     63#ifdef CONFIG_PNP
     64static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
    8065#endif
    8166static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* PnP setup */
     
    9984MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard.");
    10085#endif
    101 module_param_array(port, long, NULL, 0444);
     86module_param_hw_array(port, long, ioport, NULL, 0444);
    10287MODULE_PARM_DESC(port, "Port # for " IDENT " driver.");
    103 module_param_array(cport, long, NULL, 0444);
     88module_param_hw_array(cport, long, ioport, NULL, 0444);
    10489MODULE_PARM_DESC(cport, "Control port # for " IDENT " driver.");
    105 module_param_array(mpu_port, long, NULL, 0444);
     90module_param_hw_array(mpu_port, long, ioport, NULL, 0444);
    10691MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " IDENT " driver.");
    107 module_param_array(fm_port, long, NULL, 0444);
     92module_param_hw_array(fm_port, long, ioport, NULL, 0444);
    10893MODULE_PARM_DESC(fm_port, "FM port # for " IDENT " driver.");
    109 module_param_array(sb_port, long, NULL, 0444);
     94module_param_hw_array(sb_port, long, ioport, NULL, 0444);
    11095MODULE_PARM_DESC(sb_port, "SB port # for " IDENT " driver (optional).");
    111 module_param_array(irq, int, NULL, 0444);
     96module_param_hw_array(irq, int, irq, NULL, 0444);
    11297MODULE_PARM_DESC(irq, "IRQ # for " IDENT " driver.");
    113 module_param_array(mpu_irq, int, NULL, 0444);
     98module_param_hw_array(mpu_irq, int, irq, NULL, 0444);
    11499MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " IDENT " driver.");
    115 module_param_array(dma1, int, NULL, 0444);
     100module_param_hw_array(dma1, int, dma, NULL, 0444);
    116101MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
    117 module_param_array(dma2, int, NULL, 0444);
     102module_param_hw_array(dma2, int, dma, NULL, 0444);
    118103MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
    119104
     
    150135
    151136#define CS423X_ISAPNP_DRIVER    "cs4232_isapnp"
    152 static struct pnp_card_device_id snd_cs423x_pnpids[] = {
     137static const struct pnp_card_device_id snd_cs423x_pnpids[] = {
    153138        /* Philips PCA70PS */
    154139        { .id = "CSC0d32", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } },
     
    252237
    253238/* WSS initialization */
    254 static int __devinit snd_cs423x_pnp_init_wss(int dev, struct pnp_dev *pdev)
     239static int snd_cs423x_pnp_init_wss(int dev, struct pnp_dev *pdev)
    255240{
    256241        if (pnp_activate_dev(pdev) < 0) {
     
    273258
    274259/* CTRL initialization */
    275 static int __devinit snd_cs423x_pnp_init_ctrl(int dev, struct pnp_dev *pdev)
     260static int snd_cs423x_pnp_init_ctrl(int dev, struct pnp_dev *pdev)
    276261{
    277262        if (pnp_activate_dev(pdev) < 0) {
     
    285270
    286271/* MPU initialization */
    287 static int __devinit snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev)
     272static int snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev)
    288273{
    289274        if (pnp_activate_dev(pdev) < 0) {
     
    294279                mpu_port[dev] = pnp_port_start(pdev, 0);
    295280                if (mpu_irq[dev] >= 0 &&
    296                     pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) {
     281                    pnp_irq_valid(pdev, 0) &&
     282                    pnp_irq(pdev, 0) != (resource_size_t)-1) {
    297283                        mpu_irq[dev] = pnp_irq(pdev, 0);
    298284                } else {
     
    304290}
    305291
    306 static int __devinit snd_card_cs423x_pnp(int dev, struct snd_card_cs4236 *acard,
    307                                         struct pnp_dev *pdev,
    308                                         struct pnp_dev *cdev)
     292static int snd_card_cs423x_pnp(int dev, struct snd_card_cs4236 *acard,
     293                              struct pnp_dev *pdev,
     294                              struct pnp_dev *cdev)
    309295{
    310296        acard->wss = pdev;
     
    318304}
    319305
    320 static int __devinit snd_card_cs423x_pnpc(int dev, struct snd_card_cs4236 *acard,
    321                                           struct pnp_card_link *card,
    322                                           const struct pnp_card_device_id *id)
     306static int snd_card_cs423x_pnpc(int dev, struct snd_card_cs4236 *acard,
     307                                struct pnp_card_link *card,
     308                                const struct pnp_card_device_id *id)
    323309{
    324310        acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL);
     
    365351}
    366352
    367 static int snd_cs423x_card_new(int dev, struct snd_card **cardp)
     353static int snd_cs423x_card_new(struct device *pdev, int dev,
     354                               struct snd_card **cardp)
    368355{
    369356        struct snd_card *card;
    370357        int err;
    371358
    372         err = snd_card_create(index[dev], id[dev], THIS_MODULE,
    373                               sizeof(struct snd_card_cs4236), &card);
     359        err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
     360                           sizeof(struct snd_card_cs4236), &card);
    374361        if (err < 0)
    375362                return err;
     
    379366}
    380367
    381 static int __devinit snd_cs423x_probe(struct snd_card *card, int dev)
     368static int snd_cs423x_probe(struct snd_card *card, int dev)
    382369{
    383370        struct snd_card_cs4236 *acard;
    384         struct snd_pcm *pcm;
    385371        struct snd_wss *chip;
    386372        struct snd_opl3 *opl3;
     
    404390        if (chip->hardware & WSS_HW_CS4236B_MASK) {
    405391
    406                 err = snd_cs4236_pcm(chip, 0, &pcm);
     392                err = snd_cs4236_pcm(chip, 0);
    407393                if (err < 0)
    408394                        return err;
     
    412398                        return err;
    413399        } else {
    414                 err = snd_wss_pcm(chip, 0, &pcm);
     400                err = snd_wss_pcm(chip, 0);
    415401                if (err < 0)
    416402                        return err;
     
    420406                        return err;
    421407        }
    422         strcpy(card->driver, pcm->name);
    423         strcpy(card->shortname, pcm->name);
    424         sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i",
    425                 pcm->name,
    426                 chip->port,
    427                 irq[dev],
    428                 dma1[dev]);
    429         if (dma2[dev] >= 0)
    430                 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
    431 
    432         err = snd_wss_timer(chip, 0, NULL);
     408        strlcpy(card->driver, chip->pcm->name, sizeof(card->driver));
     409        strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname));
     410        if (dma2[dev] < 0)
     411                snprintf(card->longname, sizeof(card->longname),
     412                         "%s at 0x%lx, irq %i, dma %i",
     413                         chip->pcm->name, chip->port, irq[dev], dma1[dev]);
     414        else
     415                snprintf(card->longname, sizeof(card->longname),
     416                         "%s at 0x%lx, irq %i, dma %i&%d",
     417                         chip->pcm->name, chip->port, irq[dev], dma1[dev],
     418                         dma2[dev]);
     419
     420        err = snd_wss_timer(chip, 0);
    433421        if (err < 0)
    434422                return err;
     
    450438                if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
    451439                                        mpu_port[dev], 0,
    452                                         mpu_irq[dev],
    453                                         mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, NULL) < 0)
     440                                        mpu_irq[dev], NULL) < 0)
    454441                        printk(KERN_WARNING IDENT ": MPU401 not detected\n");
    455442        }
     
    458445}
    459446
    460 static int __devinit snd_cs423x_isa_match(struct device *pdev,
    461                                           unsigned int dev)
     447static int snd_cs423x_isa_match(struct device *pdev,
     448                                unsigned int dev)
    462449{
    463450        if (!enable[dev] || is_isapnp_selected(dev))
     
    483470}
    484471
    485 static int __devinit snd_cs423x_isa_probe(struct device *pdev,
    486                                           unsigned int dev)
     472static int snd_cs423x_isa_probe(struct device *pdev,
     473                                unsigned int dev)
    487474{
    488475        struct snd_card *card;
    489476        int err;
    490477
    491         err = snd_cs423x_card_new(dev, &card);
     478        err = snd_cs423x_card_new(pdev, dev, &card);
    492479        if (err < 0)
    493480                return err;
    494         snd_card_set_dev(card, pdev);
    495481        if ((err = snd_cs423x_probe(card, dev)) < 0) {
    496482                snd_card_free(card);
     
    502488}
    503489
    504 static int __devexit snd_cs423x_isa_remove(struct device *pdev,
    505                                           unsigned int dev)
     490static int snd_cs423x_isa_remove(struct device *pdev,
     491                                unsigned int dev)
    506492{
    507493        snd_card_free(dev_get_drvdata(pdev));
    508         dev_set_drvdata(pdev, NULL);
    509494        return 0;
    510495}
     
    542527        .match          = snd_cs423x_isa_match,
    543528        .probe          = snd_cs423x_isa_probe,
    544         .remove         = __devexit_p(snd_cs423x_isa_remove),
     529        .remove         = snd_cs423x_isa_remove,
    545530#ifdef CONFIG_PM
    546531        .suspend        = snd_cs423x_isa_suspend,
     
    554539
    555540#ifdef CONFIG_PNP
    556 static int __devinit snd_cs423x_pnpbios_detect(struct pnp_dev *pdev,
    557                                                const struct pnp_device_id *id)
     541static int snd_cs423x_pnpbios_detect(struct pnp_dev *pdev,
     542                                     const struct pnp_device_id *id)
    558543{
    559544        static int dev;
     
    580565                        break;
    581566        }
    582         err = snd_cs423x_card_new(dev, &card);
     567        err = snd_cs423x_card_new(&pdev->dev, dev, &card);
    583568        if (err < 0)
    584569                return err;
     
    589574                return err;
    590575        }
    591         snd_card_set_dev(card, &pdev->dev);
    592576        if ((err = snd_cs423x_probe(card, dev)) < 0) {
    593577                snd_card_free(card);
     
    599583}
    600584
    601 static void __devexit snd_cs423x_pnp_remove(struct pnp_dev *pdev)
     585static void snd_cs423x_pnp_remove(struct pnp_dev *pdev)
    602586{
    603587        snd_card_free(pnp_get_drvdata(pdev));
    604         pnp_set_drvdata(pdev, NULL);
    605588}
    606589
     
    621604        .id_table = snd_cs423x_pnpbiosids,
    622605        .probe = snd_cs423x_pnpbios_detect,
    623         .remove = __devexit_p(snd_cs423x_pnp_remove),
     606        .remove = snd_cs423x_pnp_remove,
    624607#ifdef CONFIG_PM
    625608        .suspend        = snd_cs423x_pnp_suspend,
     
    628611};
    629612
    630 static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
    631                                             const struct pnp_card_device_id *pid)
     613static int snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
     614                                  const struct pnp_card_device_id *pid)
    632615{
    633616        static int dev;
     
    642625                return -ENODEV;
    643626
    644         res = snd_cs423x_card_new(dev, &card);
     627        res = snd_cs423x_card_new(&pcard->card->dev, dev, &card);
    645628        if (res < 0)
    646629                return res;
     
    651634                return res;
    652635        }
    653         snd_card_set_dev(card, &pcard->card->dev);
    654636        if ((res = snd_cs423x_probe(card, dev)) < 0) {
    655637                snd_card_free(card);
     
    661643}
    662644
    663 static void __devexit snd_cs423x_pnpc_remove(struct pnp_card_link * pcard)
     645static void snd_cs423x_pnpc_remove(struct pnp_card_link *pcard)
    664646{
    665647        snd_card_free(pnp_get_card_drvdata(pcard));
     
    684666        .id_table = snd_cs423x_pnpids,
    685667        .probe = snd_cs423x_pnpc_detect,
    686         .remove = __devexit_p(snd_cs423x_pnpc_remove),
     668        .remove = snd_cs423x_pnpc_remove,
    687669#ifdef CONFIG_PM
    688670        .suspend        = snd_cs423x_pnpc_suspend,
  • GPL/trunk/alsa-kernel/isa/cs423x/cs4236_lib.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    89 *  Bugs:
    910 *     -----
    10  *
    11  *   This program is free software; you can redistribute it and/or modify
    12  *   it under the terms of the GNU General Public License as published by
    13  *   the Free Software Foundation; either version 2 of the License, or
    14  *   (at your option) any later version.
    15  *
    16  *   This program is distributed in the hope that it will be useful,
    17  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  *   GNU General Public License for more details.
    20  *
    21  *   You should have received a copy of the GNU General Public License
    22  *   along with this program; if not, write to the Free Software
    23  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    24  *
    2511 */
    2612
     
    5440 *     D6: channels status block reset (CS4237B,CS4238B)
    5541 *     D5: user bit in sub-frame of digital audio data (CS4237B,CS4238B)
    56  *     D4: validity bit bit in sub-frame of digital audio data (CS4237B,CS4238B)
     42 *     D4: validity bit in sub-frame of digital audio data (CS4237B,CS4238B)
    5743 *
    5844 *  C5  lower channel status (digital serial data description) (CS4237B,CS4238B)
     
    8066 */
    8167
    82 #include <asm/io.h>
     68#include <linux/io.h>
    8369#include <linux/delay.h>
    8470#include <linux/init.h>
     
    9581 */
    9682
    97 static unsigned char snd_cs4236_ext_map[18] = {
     83static const unsigned char snd_cs4236_ext_map[18] = {
    9884        /* CS4236_LEFT_LINE */          0xff,
    9985        /* CS4236_RIGHT_LINE */         0xff,
     
    139125#define CLOCKS 8
    140126
    141 static struct snd_ratnum clocks[CLOCKS] = {
     127static const struct snd_ratnum clocks[CLOCKS] = {
    142128        { .num = 16934400, .den_min = 353, .den_max = 353, .den_step = 1 },
    143129        { .num = 16934400, .den_min = 529, .den_max = 529, .den_step = 1 },
     
    150136};
    151137
    152 static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = {
     138static const struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = {
    153139        .nrats = CLOCKS,
    154140        .rats = clocks,
     
    377363}
    378364
    379 int snd_cs4236_pcm(struct snd_wss *chip, int device, struct snd_pcm **rpcm)
    380 {
    381         struct snd_pcm *pcm;
     365int snd_cs4236_pcm(struct snd_wss *chip, int device)
     366{
    382367        int err;
    383368       
    384         err = snd_wss_pcm(chip, device, &pcm);
     369        err = snd_wss_pcm(chip, device);
    385370        if (err < 0)
    386371                return err;
    387         pcm->info_flags &= ~SNDRV_PCM_INFO_JOINT_DUPLEX;
    388         if (rpcm)
    389                 *rpcm = pcm;
     372        chip->pcm->info_flags &= ~SNDRV_PCM_INFO_JOINT_DUPLEX;
    390373        return 0;
    391374}
     
    776759static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
    777760
    778 static struct snd_kcontrol_new snd_cs4236_controls[] = {
     761static const struct snd_kcontrol_new snd_cs4236_controls[] = {
    779762
    780763CS4236_DOUBLE("Master Digital Playback Switch", 0,
     
    871854static const DECLARE_TLV_DB_SCALE(db_scale_2bit_16db_max, -2400, 800, 0);
    872855
    873 static struct snd_kcontrol_new snd_cs4235_controls[] = {
     856static const struct snd_kcontrol_new snd_cs4235_controls[] = {
    874857
    875858WSS_DOUBLE("Master Playback Switch", 0,
     
    1004987}
    1005988
    1006 static struct snd_kcontrol_new snd_cs4236_iec958_controls[] = {
     989static const struct snd_kcontrol_new snd_cs4236_iec958_controls[] = {
    1007990CS4236_IEC958_ENABLE("IEC958 Output Enable", 0),
    1008991CS4236_SINGLEC("IEC958 Output Validity", 0, 4, 4, 1, 0),
     
    1013996};
    1014997
    1015 static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4235[] = {
     998static const struct snd_kcontrol_new snd_cs4236_3d_controls_cs4235[] = {
    1016999CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0),
    10171000CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1)
    10181001};
    10191002
    1020 static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4237[] = {
     1003static const struct snd_kcontrol_new snd_cs4236_3d_controls_cs4237[] = {
    10211004CS4236_SINGLEC("3D Control - Switch", 0, 3, 7, 1, 0),
    10221005CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1),
     
    10261009};
    10271010
    1028 static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4238[] = {
     1011static const struct snd_kcontrol_new snd_cs4236_3d_controls_cs4238[] = {
    10291012CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0),
    10301013CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1),
     
    10381021        unsigned int idx, count;
    10391022        int err;
    1040         struct snd_kcontrol_new *kcontrol;
     1023        const struct snd_kcontrol_new *kcontrol;
    10411024
    10421025        if (snd_BUG_ON(!chip || !chip->card))
  • GPL/trunk/alsa-kernel/isa/es1688/es1688.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for generic ESS AudioDrive ESx688 soundcards
    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
     
    2611#include <linux/time.h>
    2712#include <linux/wait.h>
    28 #include <linux/moduleparam.h>
     13#include <linux/module.h>
    2914#include <asm/dma.h>
    3015#include <sound/core.h>
     
    5237static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    5338#ifdef CONFIG_PNP
    54 static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
    55 #endif
    56 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;  /* Enable this card */
     39static bool isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
     40#endif
     41static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
    5742static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x240,0x260 */
    5843static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;  /* Usually 0x388 */
     
    7257#endif
    7358MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
    74 module_param_array(port, long, NULL, 0444);
     59module_param_hw_array(port, long, ioport, NULL, 0444);
    7560MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
    76 module_param_array(mpu_port, long, NULL, 0444);
     61module_param_hw_array(mpu_port, long, ioport, NULL, 0444);
    7762MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
    78 module_param_array(irq, int, NULL, 0444);
    79 module_param_array(fm_port, long, NULL, 0444);
     63module_param_hw_array(irq, int, irq, NULL, 0444);
     64module_param_hw_array(fm_port, long, ioport, NULL, 0444);
    8065MODULE_PARM_DESC(fm_port, "FM port # for ES1688 driver.");
    8166MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
    82 module_param_array(mpu_irq, int, NULL, 0444);
     67module_param_hw_array(mpu_irq, int, irq, NULL, 0444);
    8368MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
    84 module_param_array(dma8, int, NULL, 0444);
     69module_param_hw_array(dma8, int, dma, NULL, 0444);
    8570MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver.");
    8671
     
    9176#endif
    9277
    93 static int __devinit snd_es1688_match(struct device *dev, unsigned int n)
     78static int snd_es1688_match(struct device *dev, unsigned int n)
    9479{
    9580        return enable[n] && !is_isapnp_selected(n);
    9681}
    9782
    98 static int __devinit snd_es1688_legacy_create(struct snd_card *card,
    99                                         struct device *dev, unsigned int n)
     83static int snd_es1688_legacy_create(struct snd_card *card,
     84                                    struct device *dev, unsigned int n)
    10085{
    10186        struct snd_es1688 *chip = card->private_data;
    102         static long possible_ports[] = {0x220, 0x240, 0x260};
    103         static int possible_irqs[] = {5, 9, 10, 7, -1};
    104         static int possible_dmas[] = {1, 3, 0, -1};
     87        static const long possible_ports[] = {0x220, 0x240, 0x260};
     88        static const int possible_irqs[] = {5, 9, 10, 7, -1};
     89        static const int possible_dmas[] = {1, 3, 0, -1};
    10590
    10691        int i, error;
     
    135120}
    136121
    137 static int __devinit snd_es1688_probe(struct snd_card *card, unsigned int n)
     122static int snd_es1688_probe(struct snd_card *card, unsigned int n)
    138123{
    139124        struct snd_es1688 *chip = card->private_data;
    140125        struct snd_opl3 *opl3;
    141         struct snd_pcm *pcm;
    142126        int error;
    143127
    144         error = snd_es1688_pcm(card, chip, 0, &pcm);
     128        error = snd_es1688_pcm(card, chip, 0);
    145129        if (error < 0)
    146130                return error;
     
    151135
    152136        strlcpy(card->driver, "ES1688", sizeof(card->driver));
    153         strlcpy(card->shortname, pcm->name, sizeof(card->shortname));
     137        strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname));
    154138        snprintf(card->longname, sizeof(card->longname),
    155                 "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port,
     139                "%s at 0x%lx, irq %i, dma %i", chip->pcm->name, chip->port,
    156140                 chip->irq, chip->dma8);
    157141
     
    175159                error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
    176160                                chip->mpu_port, 0,
    177                                 mpu_irq[n], IRQF_DISABLED, NULL);
     161                                mpu_irq[n], NULL);
    178162                if (error < 0)
    179163                        return error;
     
    183167}
    184168
    185 static int __devinit snd_es1688_isa_probe(struct device *dev, unsigned int n)
     169static int snd_es1688_isa_probe(struct device *dev, unsigned int n)
    186170{
    187171        struct snd_card *card;
    188172        int error;
    189173
    190         error = snd_card_create(index[n], id[n], THIS_MODULE,
    191                                 sizeof(struct snd_es1688), &card);
     174        error = snd_card_new(dev, index[n], id[n], THIS_MODULE,
     175                             sizeof(struct snd_es1688), &card);
    192176        if (error < 0)
    193177                return error;
     
    196180        if (error < 0)
    197181                goto out;
    198 
    199         snd_card_set_dev(card, dev);
    200182
    201183        error = snd_es1688_probe(card, n);
     
    211193}
    212194
    213 static int __devexit snd_es1688_isa_remove(struct device *dev, unsigned int n)
     195static int snd_es1688_isa_remove(struct device *dev, unsigned int n)
    214196{
    215197        snd_card_free(dev_get_drvdata(dev));
    216         dev_set_drvdata(dev, NULL);
    217198        return 0;
    218199}
     
    221202        .match          = snd_es1688_match,
    222203        .probe          = snd_es1688_isa_probe,
    223         .remove         = __devexit_p(snd_es1688_isa_remove),
     204        .remove         = snd_es1688_isa_remove,
    224205#if 0   /* FIXME */
    225206        .suspend        = snd_es1688_suspend,
     
    234215
    235216#ifdef CONFIG_PNP
    236 static int __devinit snd_card_es968_pnp(struct snd_card *card, unsigned int n,
    237                                         struct pnp_card_link *pcard,
    238                                         const struct pnp_card_device_id *pid)
     217static int snd_card_es968_pnp(struct snd_card *card, unsigned int n,
     218                              struct pnp_card_link *pcard,
     219                              const struct pnp_card_device_id *pid)
    239220{
    240221        struct snd_es1688 *chip = card->private_data;
     
    259240}
    260241
    261 static int __devinit snd_es968_pnp_detect(struct pnp_card_link *pcard,
    262                                           const struct pnp_card_device_id *pid)
     242static int snd_es968_pnp_detect(struct pnp_card_link *pcard,
     243                                const struct pnp_card_device_id *pid)
    263244{
    264245        struct snd_card *card;
    265246        static unsigned int dev;
    266247        int error;
    267         struct snd_es1688 *chip;
    268248
    269249        if (snd_es968_pnp_is_probed)
     
    276256                return -ENODEV;
    277257
    278         error = snd_card_create(index[dev], id[dev], THIS_MODULE,
    279                                 sizeof(struct snd_es1688), &card);
    280         if (error < 0)
    281                 return error;
    282         chip = card->private_data;
     258        error = snd_card_new(&pcard->card->dev,
     259                             index[dev], id[dev], THIS_MODULE,
     260                             sizeof(struct snd_es1688), &card);
     261        if (error < 0)
     262                return error;
    283263
    284264        error = snd_card_es968_pnp(card, dev, pcard, pid);
     
    287267                return error;
    288268        }
    289         snd_card_set_dev(card, &pcard->card->dev);
    290269        error = snd_es1688_probe(card, dev);
    291         if (error < 0)
    292                 return error;
     270        if (error < 0) {
     271                snd_card_free(card);
     272                return error;
     273        }
    293274        pnp_set_card_drvdata(pcard, card);
    294275        snd_es968_pnp_is_probed = 1;
     
    296277}
    297278
    298 static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard)
     279static void snd_es968_pnp_remove(struct pnp_card_link *pcard)
    299280{
    300281        snd_card_free(pnp_get_card_drvdata(pcard));
     
    308289{
    309290        struct snd_card *card = pnp_get_card_drvdata(pcard);
    310         struct snd_es1688 *chip = card->private_data;
    311291
    312292        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    313         snd_pcm_suspend_all(chip->pcm);
    314293        return 0;
    315294}
     
    326305#endif
    327306
    328 static struct pnp_card_device_id snd_es968_pnpids[] = {
     307static const struct pnp_card_device_id snd_es968_pnpids[] = {
    329308        { .id = "ESS0968", .devs = { { "@@@0968" }, } },
    330309        { .id = "ESS0968", .devs = { { "ESS0968" }, } },
     
    339318        .id_table       = snd_es968_pnpids,
    340319        .probe          = snd_es968_pnp_detect,
    341         .remove         = __devexit_p(snd_es968_pnp_remove),
     320        .remove         = snd_es968_pnp_remove,
    342321#ifdef CONFIG_PM
    343322        .suspend        = snd_es968_pnp_suspend,
  • GPL/trunk/alsa-kernel/isa/es1688/es1688_lib.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    34 *  Routines for control of ESS ES1688/688/488 chip
    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
     
    2510#include <linux/slab.h>
    2611#include <linux/ioport.h>
     12#include <linux/module.h>
     13#include <linux/io.h>
    2714#include <sound/core.h>
    2815#include <sound/es1688.h>
    2916#include <sound/initval.h>
    3017
    31 #include <asm/io.h>
    3218#include <asm/dma.h>
    3319
     
    121107{
    122108        unsigned long flags;
    123         unsigned short major, minor, hw;
     109        unsigned short major, minor;
    124110        int i;
    125111
     
    166152                return -ENODEV; /* probably SB */
    167153
    168         hw = ES1688_HW_AUTO;
    169154        switch (chip->version & 0xfff0) {
    170155        case 0x4880:
     
    173158                return -ENODEV;
    174159        case 0x6880:
    175                 hw = (chip->version & 0x0f) >= 8 ? ES1688_HW_1688 : ES1688_HW_688;
    176160                break;
    177161        default:
     
    197181static int snd_es1688_init(struct snd_es1688 * chip, int enable)
    198182{
    199         static int irqs[16] = {-1, -1, 0, -1, -1, 1, -1, 2, -1, 0, 3, -1, -1, -1, -1, -1};
     183        static const int irqs[16] = {-1, -1, 0, -1, -1, 1, -1, 2, -1, 0, 3, -1, -1, -1, -1, -1};
    200184        unsigned long flags;
    201185        int cfg, irq_bits, dma, dma_bits, tmp, tmp1;
     
    290274 */
    291275
    292 static struct snd_ratnum clocks[2] = {
     276static const struct snd_ratnum clocks[2] = {
    293277        {
    294278                .num = 795444,
     
    305289};
    306290
    307 static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks  = {
     291static const struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks  = {
    308292        .nrats = 2,
    309293        .rats = clocks,
     
    326310}
    327311
    328 static int snd_es1688_ioctl(struct snd_pcm_substream *substream,
    329                             unsigned int cmd, void *arg)
    330 {
    331         return snd_pcm_lib_ioctl(substream, cmd, arg);
    332 }
    333 
    334312static int snd_es1688_trigger(struct snd_es1688 *chip, int cmd, unsigned char value)
    335313{
     
    356334        spin_unlock(&chip->reg_lock);
    357335        return 0;
    358 }
    359 
    360 static int snd_es1688_hw_params(struct snd_pcm_substream *substream,
    361                                 struct snd_pcm_hw_params *hw_params)
    362 {
    363         return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
    364 }
    365 
    366 static int snd_es1688_hw_free(struct snd_pcm_substream *substream)
    367 {
    368         return snd_pcm_lib_free_pages(substream);
    369336}
    370337
     
    526493 */
    527494
    528 static struct snd_pcm_hardware snd_es1688_playback =
     495static const struct snd_pcm_hardware snd_es1688_playback =
    529496{
    530497        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    544511};
    545512
    546 static struct snd_pcm_hardware snd_es1688_capture =
     513static const struct snd_pcm_hardware snd_es1688_capture =
    547514{
    548515        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    612579static int snd_es1688_free(struct snd_es1688 *chip)
    613580{
    614         if (chip->res_port) {
     581        if (chip->hardware != ES1688_HW_UNDEF)
    615582                snd_es1688_init(chip, 0);
    616                 release_and_free_resource(chip->res_port);
    617         }
     583        release_and_free_resource(chip->res_port);
    618584        if (chip->irq >= 0)
    619585                free_irq(chip->irq, (void *) chip);
     
    647613                      unsigned short hardware)
    648614{
    649         static struct snd_device_ops ops = {
     615        static const struct snd_device_ops ops = {
    650616                .dev_free =     snd_es1688_dev_free,
    651617        };
     
    657623        chip->irq = -1;
    658624        chip->dma8 = -1;
     625        chip->hardware = ES1688_HW_UNDEF;
    659626       
    660         if ((chip->res_port = request_region(port + 4, 12, "ES1688")) == NULL) {
     627        chip->res_port = request_region(port + 4, 12, "ES1688");
     628        if (chip->res_port == NULL) {
    661629                snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4);
    662                 return -EBUSY;
    663         }
    664         if (request_irq(irq, snd_es1688_interrupt, IRQF_DISABLED, "ES1688", (void *) chip)) {
     630                err = -EBUSY;
     631                goto exit;
     632        }
     633
     634        err = request_irq(irq, snd_es1688_interrupt, 0, "ES1688", (void *) chip);
     635        if (err < 0) {
    665636                snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq);
    666                 return -EBUSY;
    667         }
     637                goto exit;
     638        }
     639
    668640        chip->irq = irq;
    669         if (request_dma(dma8, "ES1688")) {
     641        card->sync_irq = chip->irq;
     642        err = request_dma(dma8, "ES1688");
     643
     644        if (err < 0) {
    670645                snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8);
    671                 return -EBUSY;
     646                goto exit;
    672647        }
    673648        chip->dma8 = dma8;
     
    685660        err = snd_es1688_probe(chip);
    686661        if (err < 0)
    687                 return err;
     662                goto exit;
    688663
    689664        err = snd_es1688_init(chip, 1);
    690665        if (err < 0)
    691                 return err;
     666                goto exit;
    692667
    693668        /* Register device */
    694         return snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
    695 }
    696 
    697 static struct snd_pcm_ops snd_es1688_playback_ops = {
     669        err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
     670exit:
     671        if (err)
     672                snd_es1688_free(chip);
     673        return err;
     674}
     675
     676static const struct snd_pcm_ops snd_es1688_playback_ops = {
    698677        .open =                 snd_es1688_playback_open,
    699678        .close =                snd_es1688_playback_close,
    700         .ioctl =                snd_es1688_ioctl,
    701         .hw_params =            snd_es1688_hw_params,
    702         .hw_free =              snd_es1688_hw_free,
    703679        .prepare =              snd_es1688_playback_prepare,
    704680        .trigger =              snd_es1688_playback_trigger,
     
    706682};
    707683
    708 static struct snd_pcm_ops snd_es1688_capture_ops = {
     684static const struct snd_pcm_ops snd_es1688_capture_ops = {
    709685        .open =                 snd_es1688_capture_open,
    710686        .close =                snd_es1688_capture_close,
    711         .ioctl =                snd_es1688_ioctl,
    712         .hw_params =            snd_es1688_hw_params,
    713         .hw_free =              snd_es1688_hw_free,
    714687        .prepare =              snd_es1688_capture_prepare,
    715688        .trigger =              snd_es1688_capture_trigger,
     
    717690};
    718691
    719 int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip,
    720                    int device, struct snd_pcm **rpcm)
     692int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip, int device)
    721693{
    722694        struct snd_pcm *pcm;
     
    732704        pcm->private_data = chip;
    733705        pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
    734         sprintf(pcm->name, snd_es1688_chip_id(chip));
     706        strcpy(pcm->name, snd_es1688_chip_id(chip));
    735707        chip->pcm = pcm;
    736708
    737         snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    738                                               snd_dma_isa_data(),
    739                                               64*1024, 64*1024);
    740 
    741         if (rpcm)
    742                 *rpcm = pcm;
     709        snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev,
     710                                       64*1024, 64*1024);
    743711        return 0;
    744712}
     
    750718static int snd_es1688_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    751719{
    752         static char *texts[9] = {
     720        static const char * const texts[8] = {
    753721                "Mic", "Mic Master", "CD", "AOUT",
    754722                "Mic1", "Mix", "Line", "Master"
    755723        };
    756724
    757         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    758         uinfo->count = 1;
    759         uinfo->value.enumerated.items = 8;
    760         if (uinfo->value.enumerated.item > 7)
    761                 uinfo->value.enumerated.item = 7;
    762         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
    763         return 0;
     725        return snd_ctl_enum_info(uinfo, 1, 8, texts);
    764726}
    765727
     
    963925}
    964926
    965 static struct snd_kcontrol_new snd_es1688_controls[] = {
     927static const struct snd_kcontrol_new snd_es1688_controls[] = {
    966928ES1688_DOUBLE("Master Playback Volume", 0, ES1688_MASTER_DEV, ES1688_MASTER_DEV, 4, 0, 15, 0),
    967929ES1688_DOUBLE("PCM Playback Volume", 0, ES1688_PCM_DEV, ES1688_PCM_DEV, 4, 0, 15, 0),
     
    985947#define ES1688_INIT_TABLE_SIZE (sizeof(snd_es1688_init_table)/2)
    986948
    987 static unsigned char snd_es1688_init_table[][2] = {
     949static const unsigned char snd_es1688_init_table[][2] = {
    988950        { ES1688_MASTER_DEV, 0 },
    989951        { ES1688_PCM_DEV, 0 },
     
    1028990EXPORT_SYMBOL(snd_es1688_pcm);
    1029991EXPORT_SYMBOL(snd_es1688_mixer);
    1030 
    1031 /*
    1032  *  INIT part
    1033  */
    1034 
    1035 static int __init alsa_es1688_init(void)
    1036 {
    1037         return 0;
    1038 }
    1039 
    1040 static void __exit alsa_es1688_exit(void)
    1041 {
    1042 }
    1043 
    1044 module_init(alsa_es1688_init)
    1045 module_exit(alsa_es1688_exit)
  • GPL/trunk/alsa-kernel/isa/es18xx.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for generic ESS AudioDrive ES18xx soundcards
    34 *  Copyright (c) by Christian Fischbach <fishbach@pool.informatik.rwth-aachen.de>
    45 *  Copyright (c) by Abramo Bagnara <abramo@alsa-project.org>
    5  *
    6  *
    7  *   This program is free software; you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation; either version 2 of the License, or
    10  *   (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    20  *
    216 */
    227/* GENERAL NOTES:
     
    8368#include <linux/pnp.h>
    8469#include <linux/isapnp.h>
    85 #include <linux/moduleparam.h>
     70#include <linux/module.h>
    8671#include <linux/delay.h>
    87 
    88 #include <asm/io.h>
     72#include <linux/io.h>
     73
    8974#include <asm/dma.h>
    9075#include <sound/core.h>
     
    157142#define ES18XX_MUTEREC  0x0400  /* Record source can be muted */
    158143#define ES18XX_CONTROL  0x0800  /* Has control ports */
     144#define ES18XX_GPO_2BIT 0x1000  /* GPO0,1 controlled by PM port */
    159145
    160146/* Power Management */
     
    349335
    350336
    351 static int __devinit snd_es18xx_reset(struct snd_es18xx *chip)
     337static int snd_es18xx_reset(struct snd_es18xx *chip)
    352338{
    353339        int i;
     
    369355}
    370356
    371 static struct snd_ratnum new_clocks[2] = {
     357static const struct snd_ratnum new_clocks[2] = {
    372358        {
    373359                .num = 793800,
     
    384370};
    385371
    386 static struct snd_pcm_hw_constraint_ratnums new_hw_constraints_clocks = {
     372static const struct snd_pcm_hw_constraint_ratnums new_hw_constraints_clocks = {
    387373        .nrats = 2,
    388374        .rats = new_clocks,
    389375};
    390376
    391 static struct snd_ratnum old_clocks[2] = {
     377static const struct snd_ratnum old_clocks[2] = {
    392378        {
    393379                .num = 795444,
     
    404390};
    405391
    406 static struct snd_pcm_hw_constraint_ratnums old_hw_constraints_clocks  = {
     392static const struct snd_pcm_hw_constraint_ratnums old_hw_constraints_clocks  = {
    407393        .nrats = 2,
    408394        .rats = old_clocks,
     
    449435{
    450436        struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
    451         int shift, err;
     437        int shift;
    452438
    453439        shift = 0;
     
    468454                chip->dma1_shift = shift;
    469455        }
    470         if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
    471                 return err;
    472         return 0;
    473 }
    474 
    475 static int snd_es18xx_pcm_hw_free(struct snd_pcm_substream *substream)
    476 {
    477         return snd_pcm_lib_free_pages(substream);
     456        return 0;
    478457}
    479458
     
    521500#ifdef AVOID_POPS
    522501                /* Avoid pops */
    523                 udelay(100000);
     502                mdelay(100);
    524503                if (chip->caps & ES18XX_PCM2)
    525504                        /* Restore Audio 2 volume */
     
    538517                snd_es18xx_mixer_write(chip, 0x78, 0x00);
    539518#ifdef AVOID_POPS
    540                 udelay(25000);
     519                mdelay(25);
    541520                if (chip->caps & ES18XX_PCM2)
    542521                        /* Set Audio 2 volume to 0 */
     
    558537{
    559538        struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
    560         int shift, err;
     539        int shift;
    561540
    562541        shift = 0;
     
    572551                shift++;
    573552        chip->dma1_shift = shift;
    574         if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
    575                 return err;
    576553        return 0;
    577554}
     
    597574
    598575#ifdef AVOID_POPS
    599         udelay(100000);
     576        mdelay(100);
    600577#endif
    601578
     
    692669#ifdef AVOID_POPS
    693670                /* Avoid pops */
    694                 udelay(100000);
     671                mdelay(100);
    695672                /* Enable Audio 1 */
    696673                snd_es18xx_dsp_command(chip, 0xD1);
     
    706683#ifdef AVOID_POPS
    707684                /* Avoid pops */
    708                 udelay(25000);
     685                mdelay(25);
    709686                /* Disable Audio 1 */
    710687                snd_es18xx_dsp_command(chip, 0xD3);
     
    838815}
    839816
    840 static struct snd_pcm_hardware snd_es18xx_playback =
     817static const struct snd_pcm_hardware snd_es18xx_playback =
    841818{
    842819        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    858835};
    859836
    860 static struct snd_pcm_hardware snd_es18xx_capture =
     837static const struct snd_pcm_hardware snd_es18xx_capture =
    861838{
    862839        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    930907                chip->playback_b_substream = NULL;
    931908       
    932         snd_pcm_lib_free_pages(substream);
    933909        return 0;
    934910}
     
    939915
    940916        chip->capture_a_substream = NULL;
    941         snd_pcm_lib_free_pages(substream);
    942917        return 0;
    943918}
     
    965940static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    966941{
    967         static char *texts5Source[5] = {
     942        static const char * const texts5Source[5] = {
    968943                "Mic", "CD", "Line", "Master", "Mix"
    969944        };
    970         static char *texts8Source[8] = {
     945        static const char * const texts8Source[8] = {
    971946                "Mic", "Mic Master", "CD", "AOUT",
    972947                "Mic1", "Mix", "Line", "Master"
     
    974949        struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
    975950
    976         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    977         uinfo->count = 1;
    978951        switch (chip->version) {
    979952        case 0x1868:
    980953        case 0x1878:
    981                 uinfo->value.enumerated.items = 4;
    982                 if (uinfo->value.enumerated.item > 3)
    983                         uinfo->value.enumerated.item = 3;
    984                 strcpy(uinfo->value.enumerated.name,
    985                         texts5Source[uinfo->value.enumerated.item]);
    986                 break;
     954                return snd_ctl_enum_info(uinfo, 1, 4, texts5Source);
    987955        case 0x1887:
    988956        case 0x1888:
    989                 uinfo->value.enumerated.items = 5;
    990                 if (uinfo->value.enumerated.item > 4)
    991                         uinfo->value.enumerated.item = 4;
    992                 strcpy(uinfo->value.enumerated.name, texts5Source[uinfo->value.enumerated.item]);
    993                 break;
    994         case 0x1869: /* DS somewhat contradictory for 1869: could be be 5 or 8 */
     957                return snd_ctl_enum_info(uinfo, 1, 5, texts5Source);
     958        case 0x1869: /* DS somewhat contradictory for 1869: could be 5 or 8 */
    995959        case 0x1879:
    996                 uinfo->value.enumerated.items = 8;
    997                 if (uinfo->value.enumerated.item > 7)
    998                         uinfo->value.enumerated.item = 7;
    999                 strcpy(uinfo->value.enumerated.name, texts8Source[uinfo->value.enumerated.item]);
    1000                 break;
     960                return snd_ctl_enum_info(uinfo, 1, 8, texts8Source);
    1001961        default:
    1002962                return -EINVAL;
    1003963        }
    1004         return 0;
    1005964}
    1006965
    1007966static int snd_es18xx_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1008967{
    1009         static unsigned char invMap4Source[8] = {0, 0, 1, 1, 0, 0, 2, 3};
     968        static const unsigned char invMap4Source[8] = {0, 0, 1, 1, 0, 0, 2, 3};
    1010969        struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
    1011970        int muxSource = snd_es18xx_mixer_read(chip, 0x1c) & 0x07;
     
    1024983static int snd_es18xx_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
    1025984{
    1026         static unsigned char map4Source[4] = {0, 2, 6, 7};
     985        static const unsigned char map4Source[4] = {0, 2, 6, 7};
    1027986        struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol);
    1028987        unsigned char val = ucontrol->value.enumerated.item[0];
     
    1040999                } else
    10411000                        retVal = snd_es18xx_mixer_bits(chip, 0x7a, 0x08, 0x00) != 0x00;
     1001                fallthrough;
    10421002 /* 4 source chips */
    10431003        case 0x1868:
     
    11371097}
    11381098
    1139 #define ES18XX_SINGLE(xname, xindex, reg, shift, mask, invert) \
     1099#define ES18XX_SINGLE(xname, xindex, reg, shift, mask, flags) \
    11401100{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
    11411101  .info = snd_es18xx_info_single, \
    11421102  .get = snd_es18xx_get_single, .put = snd_es18xx_put_single, \
    1143   .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
     1103  .private_value = reg | (shift << 8) | (mask << 16) | (flags << 24) }
     1104
     1105#define ES18XX_FL_INVERT        (1 << 0)
     1106#define ES18XX_FL_PMPORT        (1 << 1)
    11441107
    11451108static int snd_es18xx_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
     
    11601123        int shift = (kcontrol->private_value >> 8) & 0xff;
    11611124        int mask = (kcontrol->private_value >> 16) & 0xff;
    1162         int invert = (kcontrol->private_value >> 24) & 0xff;
     1125        int invert = (kcontrol->private_value >> 24) & ES18XX_FL_INVERT;
     1126        int pm_port = (kcontrol->private_value >> 24) & ES18XX_FL_PMPORT;
    11631127        int val;
    1164        
    1165         val = snd_es18xx_reg_read(chip, reg);
     1128
     1129        if (pm_port)
     1130                val = inb(chip->port + ES18XX_PM);
     1131        else
     1132                val = snd_es18xx_reg_read(chip, reg);
    11661133        ucontrol->value.integer.value[0] = (val >> shift) & mask;
    11671134        if (invert)
     
    11761143        int shift = (kcontrol->private_value >> 8) & 0xff;
    11771144        int mask = (kcontrol->private_value >> 16) & 0xff;
    1178         int invert = (kcontrol->private_value >> 24) & 0xff;
     1145        int invert = (kcontrol->private_value >> 24) & ES18XX_FL_INVERT;
     1146        int pm_port = (kcontrol->private_value >> 24) & ES18XX_FL_PMPORT;
    11791147        unsigned char val;
    11801148       
     
    11841152        mask <<= shift;
    11851153        val <<= shift;
     1154        if (pm_port) {
     1155                unsigned char cur = inb(chip->port + ES18XX_PM);
     1156
     1157                if ((cur & mask) == val)
     1158                        return 0;
     1159                outb((cur & ~mask) | val, chip->port + ES18XX_PM);
     1160                return 1;
     1161        }
     1162
    11861163        return snd_es18xx_reg_bits(chip, reg, mask, val) != val;
    11871164}
     
    12701247 * here.
    12711248 */
    1272 static struct snd_kcontrol_new snd_es18xx_base_controls[] = {
     1249static const struct snd_kcontrol_new snd_es18xx_base_controls[] = {
    12731250ES18XX_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0),
    12741251ES18XX_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1),
     
    12891266};
    12901267
    1291 static struct snd_kcontrol_new snd_es18xx_recmix_controls[] = {
     1268static const struct snd_kcontrol_new snd_es18xx_recmix_controls[] = {
    12921269ES18XX_DOUBLE("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0),
    12931270ES18XX_DOUBLE("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0),
     
    13011278 * The chipset specific mixer controls
    13021279 */
    1303 static struct snd_kcontrol_new snd_es18xx_opt_speaker =
     1280static const struct snd_kcontrol_new snd_es18xx_opt_speaker =
    13041281        ES18XX_SINGLE("Beep Playback Volume", 0, 0x3c, 0, 7, 0);
    13051282
    1306 static struct snd_kcontrol_new snd_es18xx_opt_1869[] = {
    1307 ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1),
     1283static const struct snd_kcontrol_new snd_es18xx_opt_1869[] = {
     1284ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, ES18XX_FL_INVERT),
    13081285ES18XX_SINGLE("Video Playback Switch", 0, 0x7f, 0, 1, 0),
    13091286ES18XX_DOUBLE("Mono Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0),
     
    13111288};
    13121289
    1313 static struct snd_kcontrol_new snd_es18xx_opt_1878 =
     1290static const struct snd_kcontrol_new snd_es18xx_opt_1878 =
    13141291        ES18XX_DOUBLE("Video Playback Volume", 0, 0x68, 0x68, 4, 0, 15, 0);
    13151292
    1316 static struct snd_kcontrol_new snd_es18xx_opt_1879[] = {
     1293static const struct snd_kcontrol_new snd_es18xx_opt_1879[] = {
    13171294ES18XX_SINGLE("Video Playback Switch", 0, 0x71, 6, 1, 0),
    13181295ES18XX_DOUBLE("Video Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0),
     
    13201297};
    13211298
    1322 static struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = {
     1299static const struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = {
    13231300ES18XX_DOUBLE("PCM Playback Volume", 0, 0x14, 0x14, 4, 0, 15, 0),
    13241301};
    13251302
    1326 static struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = {
     1303static const struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = {
    13271304ES18XX_DOUBLE("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0),
    13281305ES18XX_DOUBLE("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0)
    13291306};
    13301307
    1331 static struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = {
     1308static const struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = {
    13321309ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0),
    13331310{
     
    13401317};
    13411318
    1342 static struct snd_kcontrol_new snd_es18xx_micpre1_control =
     1319static const struct snd_kcontrol_new snd_es18xx_micpre1_control =
    13431320ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0xa9, 2, 1, 0);
    13441321
    1345 static struct snd_kcontrol_new snd_es18xx_micpre2_control =
     1322static const struct snd_kcontrol_new snd_es18xx_micpre2_control =
    13461323ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0);
    13471324
    1348 static struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = {
     1325static const struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = {
    13491326{
    13501327        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    13641341};
    13651342
    1366 static int __devinit snd_es18xx_config_read(struct snd_es18xx *chip, unsigned char reg)
     1343static const struct snd_kcontrol_new snd_es18xx_opt_gpo_2bit[] = {
     1344ES18XX_SINGLE("GPO0 Switch", 0, ES18XX_PM, 0, 1, ES18XX_FL_PMPORT),
     1345ES18XX_SINGLE("GPO1 Switch", 0, ES18XX_PM, 1, 1, ES18XX_FL_PMPORT),
     1346};
     1347
     1348static int snd_es18xx_config_read(struct snd_es18xx *chip, unsigned char reg)
    13671349{
    13681350        int data;
     
    13731355}
    13741356
    1375 static void __devinit snd_es18xx_config_write(struct snd_es18xx *chip,
    1376                                               unsigned char reg, unsigned char data)
     1357static void snd_es18xx_config_write(struct snd_es18xx *chip,
     1358                                    unsigned char reg, unsigned char data)
    13771359{
    13781360        /* No need for spinlocks, this function is used only in
     
    13851367}
    13861368
    1387 static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip,
    1388                                           unsigned long mpu_port,
    1389                                           unsigned long fm_port)
     1369static int snd_es18xx_initialize(struct snd_es18xx *chip,
     1370                                unsigned long mpu_port,
     1371                                unsigned long fm_port)
    13901372{
    13911373        int mask = 0;
     
    15501532}
    15511533
    1552 static int __devinit snd_es18xx_identify(struct snd_es18xx *chip)
     1534static int snd_es18xx_identify(struct snd_es18xx *chip)
    15531535{
    15541536        int hi,lo;
     
    16191601}
    16201602
    1621 static int __devinit snd_es18xx_probe(struct snd_es18xx *chip,
    1622                                         unsigned long mpu_port,
    1623                                         unsigned long fm_port)
     1603static int snd_es18xx_probe(struct snd_es18xx *chip,
     1604                            unsigned long mpu_port,
     1605                            unsigned long fm_port)
    16241606{
    16251607        if (snd_es18xx_identify(chip) < 0) {
     
    16301612        switch (chip->version) {
    16311613        case 0x1868:
    1632                 chip->caps = ES18XX_DUPLEX_MONO | ES18XX_DUPLEX_SAME | ES18XX_CONTROL;
     1614                chip->caps = ES18XX_DUPLEX_MONO | ES18XX_DUPLEX_SAME | ES18XX_CONTROL | ES18XX_GPO_2BIT;
    16331615                break;
    16341616        case 0x1869:
    1635                 chip->caps = ES18XX_PCM2 | ES18XX_SPATIALIZER | ES18XX_RECMIX | ES18XX_NEW_RATE | ES18XX_AUXB | ES18XX_MONO | ES18XX_MUTEREC | ES18XX_CONTROL | ES18XX_HWV;
     1617                chip->caps = ES18XX_PCM2 | ES18XX_SPATIALIZER | ES18XX_RECMIX | ES18XX_NEW_RATE | ES18XX_AUXB | ES18XX_MONO | ES18XX_MUTEREC | ES18XX_CONTROL | ES18XX_HWV | ES18XX_GPO_2BIT;
    16361618                break;
    16371619        case 0x1878:
     
    16431625        case 0x1887:
    16441626        case 0x1888:
    1645                 chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME;
     1627                chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME | ES18XX_GPO_2BIT;
    16461628                break;
    16471629        default:
     
    16591641}
    16601642
    1661 static struct snd_pcm_ops snd_es18xx_playback_ops = {
     1643static const struct snd_pcm_ops snd_es18xx_playback_ops = {
    16621644        .open =         snd_es18xx_playback_open,
    16631645        .close =        snd_es18xx_playback_close,
    1664         .ioctl =        snd_pcm_lib_ioctl,
    16651646        .hw_params =    snd_es18xx_playback_hw_params,
    1666         .hw_free =      snd_es18xx_pcm_hw_free,
    16671647        .prepare =      snd_es18xx_playback_prepare,
    16681648        .trigger =      snd_es18xx_playback_trigger,
     
    16701650};
    16711651
    1672 static struct snd_pcm_ops snd_es18xx_capture_ops = {
     1652static const struct snd_pcm_ops snd_es18xx_capture_ops = {
    16731653        .open =         snd_es18xx_capture_open,
    16741654        .close =        snd_es18xx_capture_close,
    1675         .ioctl =        snd_pcm_lib_ioctl,
    16761655        .hw_params =    snd_es18xx_capture_hw_params,
    1677         .hw_free =      snd_es18xx_pcm_hw_free,
    16781656        .prepare =      snd_es18xx_capture_prepare,
    16791657        .trigger =      snd_es18xx_capture_trigger,
     
    16811659};
    16821660
    1683 static int __devinit snd_es18xx_pcm(struct snd_card *card, int device,
    1684                                     struct snd_pcm **rpcm)
     1661static int snd_es18xx_pcm(struct snd_card *card, int device)
    16851662{
    16861663        struct snd_es18xx *chip = card->private_data;
     
    16891666        int err;
    16901667
    1691         if (rpcm)
    1692                 *rpcm = NULL;
    16931668        sprintf(str, "ES%x", chip->version);
    16941669        if (chip->caps & ES18XX_PCM2)
     
    17121687        chip->pcm = pcm;
    17131688
    1714         snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    1715                                               snd_dma_isa_data(),
    1716                                               64*1024,
    1717                                               chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
    1718 
    1719         if (rpcm)
    1720                 *rpcm = pcm;
     1689        snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev,
     1690                                       64*1024,
     1691                                       chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024);
    17211692        return 0;
    17221693}
     
    17291700
    17301701        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    1731 
    1732         snd_pcm_suspend_all(chip->pcm);
    17331702
    17341703        /* power down */
     
    17781747}
    17791748
    1780 static int __devinit snd_es18xx_new_device(struct snd_card *card,
    1781                                           unsigned long port,
    1782                                           unsigned long mpu_port,
    1783                                           unsigned long fm_port,
    1784                                           int irq, int dma1, int dma2)
     1749static int snd_es18xx_new_device(struct snd_card *card,
     1750                                unsigned long port,
     1751                                unsigned long mpu_port,
     1752                                unsigned long fm_port,
     1753                                int irq, int dma1, int dma2)
    17851754{
    17861755        struct snd_es18xx *chip = card->private_data;
    1787         static struct snd_device_ops ops = {
     1756        static const struct snd_device_ops ops = {
    17881757                .dev_free =     snd_es18xx_dev_free,
    17891758        };
     
    18061775        }
    18071776
    1808         if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx",
     1777        if (request_irq(irq, snd_es18xx_interrupt, 0, "ES18xx",
    18091778                        (void *) card)) {
    18101779                snd_es18xx_free(card);
     
    18131782        }
    18141783        chip->irq = irq;
     1784        card->sync_irq = chip->irq;
    18151785
    18161786        if (request_dma(dma1, "ES18xx DMA 1")) {
     
    18401810}
    18411811
    1842 static int __devinit snd_es18xx_mixer(struct snd_card *card)
     1812static int snd_es18xx_mixer(struct snd_card *card)
    18431813{
    18441814        struct snd_es18xx *chip = card->private_data;
     
    19451915                }
    19461916        }
     1917        if (chip->caps & ES18XX_GPO_2BIT) {
     1918                for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_opt_gpo_2bit); idx++) {
     1919                        err = snd_ctl_add(card,
     1920                                          snd_ctl_new1(&snd_es18xx_opt_gpo_2bit[idx],
     1921                                                       chip));
     1922                        if (err < 0)
     1923                                return err;
     1924                }
     1925        }
    19471926        return 0;
    19481927}
     
    19651944static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    19661945static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    1967 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
     1946static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    19681947#ifdef CONFIG_PNP
    1969 static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
     1948static bool isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
    19701949#endif
    19711950static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x240,0x260,0x280 */
     
    19901969MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard.");
    19911970#endif
    1992 module_param_array(port, long, NULL, 0444);
     1971module_param_hw_array(port, long, ioport, NULL, 0444);
    19931972MODULE_PARM_DESC(port, "Port # for ES18xx driver.");
    1994 module_param_array(mpu_port, long, NULL, 0444);
     1973module_param_hw_array(mpu_port, long, ioport, NULL, 0444);
    19951974MODULE_PARM_DESC(mpu_port, "MPU-401 port # for ES18xx driver.");
    1996 module_param_array(fm_port, long, NULL, 0444);
     1975module_param_hw_array(fm_port, long, ioport, NULL, 0444);
    19971976MODULE_PARM_DESC(fm_port, "FM port # for ES18xx driver.");
    1998 module_param_array(irq, int, NULL, 0444);
     1977module_param_hw_array(irq, int, irq, NULL, 0444);
    19991978MODULE_PARM_DESC(irq, "IRQ # for ES18xx driver.");
    2000 module_param_array(dma1, int, NULL, 0444);
     1979module_param_hw_array(dma1, int, dma, NULL, 0444);
    20011980MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver.");
    2002 module_param_array(dma2, int, NULL, 0444);
     1981module_param_hw_array(dma2, int, dma, NULL, 0444);
    20031982MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver.");
    20041983
     
    20081987static int pnpc_registered;
    20091988
    2010 static struct pnp_device_id snd_audiodrive_pnpbiosids[] = {
     1989static const struct pnp_device_id snd_audiodrive_pnpbiosids[] = {
    20111990        { .id = "ESS1869" },
    20121991        { .id = "ESS1879" },
     
    20171996
    20181997/* PnP main device initialization */
    2019 static int __devinit snd_audiodrive_pnp_init_main(int dev, struct pnp_dev *pdev)
     1998static int snd_audiodrive_pnp_init_main(int dev, struct pnp_dev *pdev)
    20201999{
    20212000        if (pnp_activate_dev(pdev) < 0) {
     
    20442023}
    20452024
    2046 static int __devinit snd_audiodrive_pnp(int dev, struct snd_es18xx *chip,
    2047                                         struct pnp_dev *pdev)
     2025static int snd_audiodrive_pnp(int dev, struct snd_es18xx *chip,
     2026                              struct pnp_dev *pdev)
    20482027{
    20492028        chip->dev = pdev;
     
    20532032}
    20542033
    2055 static struct pnp_card_device_id snd_audiodrive_pnpids[] = {
     2034static const struct pnp_card_device_id snd_audiodrive_pnpids[] = {
    20562035        /* ESS 1868 (integrated on Compaq dual P-Pro motherboard and Genius 18PnP 3D) */
    20572036        { .id = "ESS1868", .devs = { { "ESS1868" }, { "ESS0000" } } },
     
    20742053MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids);
    20752054
    2076 static int __devinit snd_audiodrive_pnpc(int dev, struct snd_es18xx *chip,
    2077                                         struct pnp_card_link *card,
    2078                                         const struct pnp_card_device_id *id)
     2055static int snd_audiodrive_pnpc(int dev, struct snd_es18xx *chip,
     2056                               struct pnp_card_link *card,
     2057                               const struct pnp_card_device_id *id)
    20792058{
    20802059        chip->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
     
    21062085#endif
    21072086
    2108 static int snd_es18xx_card_new(int dev, struct snd_card **cardp)
    2109 {
    2110         return snd_card_create(index[dev], id[dev], THIS_MODULE,
    2111                                sizeof(struct snd_es18xx), cardp);
    2112 }
    2113 
    2114 static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev)
     2087static int snd_es18xx_card_new(struct device *pdev, int dev,
     2088                               struct snd_card **cardp)
     2089{
     2090        return snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
     2091                            sizeof(struct snd_es18xx), cardp);
     2092}
     2093
     2094static int snd_audiodrive_probe(struct snd_card *card, int dev)
    21152095{
    21162096        struct snd_es18xx *chip = card->private_data;
     
    21382118                        irq[dev], dma1[dev]);
    21392119
    2140         err = snd_es18xx_pcm(card, 0, NULL);
     2120        err = snd_es18xx_pcm(card, 0);
    21412121        if (err < 0)
    21422122                return err;
     
    21612141        if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
    21622142                err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX,
    2163                                           mpu_port[dev], 0,
    2164                                           irq[dev], 0, &chip->rmidi);
     2143                                          mpu_port[dev], MPU401_INFO_IRQ_HOOK,
     2144                                          -1, &chip->rmidi);
    21652145                if (err < 0)
    21662146                        return err;
     
    21702150}
    21712151
    2172 static int __devinit snd_es18xx_isa_match(struct device *pdev, unsigned int dev)
     2152static int snd_es18xx_isa_match(struct device *pdev, unsigned int dev)
    21732153{
    21742154        return enable[dev] && !is_isapnp_selected(dev);
    21752155}
    21762156
    2177 static int __devinit snd_es18xx_isa_probe1(int dev, struct device *devptr)
     2157static int snd_es18xx_isa_probe1(int dev, struct device *devptr)
    21782158{
    21792159        struct snd_card *card;
    21802160        int err;
    21812161
    2182         err = snd_es18xx_card_new(dev, &card);
     2162        err = snd_es18xx_card_new(devptr, dev, &card);
    21832163        if (err < 0)
    21842164                return err;
    2185         snd_card_set_dev(card, devptr);
    21862165        if ((err = snd_audiodrive_probe(card, dev)) < 0) {
    21872166                snd_card_free(card);
     
    21922171}
    21932172
    2194 static int __devinit snd_es18xx_isa_probe(struct device *pdev, unsigned int dev)
     2173static int snd_es18xx_isa_probe(struct device *pdev, unsigned int dev)
    21952174{
    21962175        int err;
    2197         static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1};
    2198         static int possible_dmas[] = {1, 0, 3, 5, -1};
     2176        static const int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1};
     2177        static const int possible_dmas[] = {1, 0, 3, 5, -1};
    21992178
    22002179        if (irq[dev] == SNDRV_AUTO_IRQ) {
     
    22202199                return snd_es18xx_isa_probe1(dev, pdev);
    22212200        } else {
    2222                 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280};
     2201                static const unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280};
    22232202                int i;
    22242203                for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
     
    22322211}
    22332212
    2234 static int __devexit snd_es18xx_isa_remove(struct device *devptr,
    2235                                           unsigned int dev)
     2213static int snd_es18xx_isa_remove(struct device *devptr,
     2214                                unsigned int dev)
    22362215{
    22372216        snd_card_free(dev_get_drvdata(devptr));
    2238         dev_set_drvdata(devptr, NULL);
    22392217        return 0;
    22402218}
     
    22582236        .match          = snd_es18xx_isa_match,
    22592237        .probe          = snd_es18xx_isa_probe,
    2260         .remove         = __devexit_p(snd_es18xx_isa_remove),
     2238        .remove         = snd_es18xx_isa_remove,
    22612239#ifdef CONFIG_PM
    22622240        .suspend        = snd_es18xx_isa_suspend,
     
    22702248
    22712249#ifdef CONFIG_PNP
    2272 static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev,
    2273                                             const struct pnp_device_id *id)
     2250static int snd_audiodrive_pnp_detect(struct pnp_dev *pdev,
     2251                                     const struct pnp_device_id *id)
    22742252{
    22752253        static int dev;
     
    22862264                return -ENODEV;
    22872265
    2288         err = snd_es18xx_card_new(dev, &card);
     2266        err = snd_es18xx_card_new(&pdev->dev, dev, &card);
    22892267        if (err < 0)
    22902268                return err;
     
    22932271                return err;
    22942272        }
    2295         snd_card_set_dev(card, &pdev->dev);
    22962273        if ((err = snd_audiodrive_probe(card, dev)) < 0) {
    22972274                snd_card_free(card);
     
    23032280}
    23042281
    2305 static void __devexit snd_audiodrive_pnp_remove(struct pnp_dev * pdev)
     2282static void snd_audiodrive_pnp_remove(struct pnp_dev *pdev)
    23062283{
    23072284        snd_card_free(pnp_get_drvdata(pdev));
    2308         pnp_set_drvdata(pdev, NULL);
    23092285}
    23102286
     
    23242300        .id_table = snd_audiodrive_pnpbiosids,
    23252301        .probe = snd_audiodrive_pnp_detect,
    2326         .remove = __devexit_p(snd_audiodrive_pnp_remove),
     2302        .remove = snd_audiodrive_pnp_remove,
    23272303#ifdef CONFIG_PM
    23282304        .suspend = snd_audiodrive_pnp_suspend,
     
    23312307};
    23322308
    2333 static int __devinit snd_audiodrive_pnpc_detect(struct pnp_card_link *pcard,
    2334                                                const struct pnp_card_device_id *pid)
     2309static int snd_audiodrive_pnpc_detect(struct pnp_card_link *pcard,
     2310                                      const struct pnp_card_device_id *pid)
    23352311{
    23362312        static int dev;
     
    23452321                return -ENODEV;
    23462322
    2347         res = snd_es18xx_card_new(dev, &card);
     2323        res = snd_es18xx_card_new(&pcard->card->dev, dev, &card);
    23482324        if (res < 0)
    23492325                return res;
     
    23532329                return res;
    23542330        }
    2355         snd_card_set_dev(card, &pcard->card->dev);
    23562331        if ((res = snd_audiodrive_probe(card, dev)) < 0) {
    23572332                snd_card_free(card);
     
    23642339}
    23652340
    2366 static void __devexit snd_audiodrive_pnpc_remove(struct pnp_card_link * pcard)
     2341static void snd_audiodrive_pnpc_remove(struct pnp_card_link *pcard)
    23672342{
    23682343        snd_card_free(pnp_get_card_drvdata(pcard));
     
    23882363        .id_table = snd_audiodrive_pnpids,
    23892364        .probe = snd_audiodrive_pnpc_detect,
    2390         .remove = __devexit_p(snd_audiodrive_pnpc_remove),
     2365        .remove = snd_audiodrive_pnpc_remove,
    23912366#ifdef CONFIG_PM
    23922367        .suspend        = snd_audiodrive_pnpc_suspend,
  • GPL/trunk/alsa-kernel/isa/gus/gus_dma.c

    r426 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Routines for GF1 DMA control
    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
     
    202187
    203188        block = kmalloc(sizeof(*block), atomic ? GFP_ATOMIC : GFP_KERNEL);
    204         if (block == NULL) {
    205                 snd_printk(KERN_ERR "gf1: DMA transfer failure; not enough memory\n");
     189        if (!block)
    206190                return -ENOMEM;
    207         }
     191
    208192        *block = *__block;
    209193        block->next = NULL;
  • GPL/trunk/alsa-kernel/isa/gus/gus_dram.c

    r305 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    34 *  DRAM access routines
    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
  • GPL/trunk/alsa-kernel/isa/gus/gus_io.c

    r305 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    34 *  I/O routines for GF1/InterWave synthesizer chips
    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
     
    419404        unsigned short voices;
    420405
    421         static unsigned short voices_tbl[32 - 14 + 1] =
     406        static const unsigned short voices_tbl[32 - 14 + 1] =
    422407        {
    423408            44100, 41160, 38587, 36317, 34300, 32494, 30870, 29400, 28063, 26843,
     
    462447                        printk(KERN_INFO " -%i- GFA1 effect volume          = 0x%x\n", voice, snd_gf1_i_read16(gus, 0x16));
    463448                        printk(KERN_INFO " -%i- GFA1 effect volume final    = 0x%x\n", voice, snd_gf1_i_read16(gus, 0x1d));
    464                         printk(KERN_INFO " -%i- GFA1 effect acumulator      = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x14));
     449                        printk(KERN_INFO " -%i- GFA1 effect accumulator     = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x14));
    465450                }
    466451                if (mode & 0x20) {
  • GPL/trunk/alsa-kernel/isa/gus/gus_irq.c

    r426 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Routine for IRQ handling from GF1/InterWave chip
    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
     
    141126void snd_gus_irq_profile_init(struct snd_gus_card *gus)
    142127{
    143         struct snd_info_entry *entry;
    144 
    145         if (! snd_card_proc_new(gus->card, "gusirq", &entry))
    146                 snd_info_set_text_ops(entry, gus, snd_gus_irq_info_read);
     128        snd_card_ro_proc_new(gus->card, "gusirq", gus, snd_gus_irq_info_read);
    147129}
    148130
  • GPL/trunk/alsa-kernel/isa/gus/gus_main.c

    r399 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Routines for Gravis UltraSound soundcards
    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
     
    2510#include <linux/slab.h>
    2611#include <linux/ioport.h>
     12#include <linux/module.h>
    2713#include <sound/core.h>
    2814#include <sound/gus.h>
     
    8268}
    8369
    84 static struct snd_kcontrol_new snd_gus_joystick_control = {
     70static const struct snd_kcontrol_new snd_gus_joystick_control = {
    8571        .iface = SNDRV_CTL_ELEM_IFACE_CARD,
    8672        .name = "Joystick Speed",
     
    9278static void snd_gus_init_control(struct snd_gus_card *gus)
    9379{
    94         if (!gus->ace_flag)
    95                 snd_ctl_add(gus->card, snd_ctl_new1(&snd_gus_joystick_control, gus));
     80        int ret;
     81
     82        if (!gus->ace_flag) {
     83                ret =
     84                        snd_ctl_add(gus->card,
     85                                        snd_ctl_new1(&snd_gus_joystick_control,
     86                                                gus));
     87                if (ret)
     88                        snd_printk(KERN_ERR "gus: snd_ctl_add failed: %d\n",
     89                                        ret);
     90        }
    9691}
    9792
     
    140135        struct snd_gus_card *gus;
    141136        int err;
    142         static struct snd_device_ops ops = {
     137        static const struct snd_device_ops ops = {
    143138                .dev_free =     snd_gus_dev_free,
    144139        };
     
    181176                return -EBUSY;
    182177        }
    183         if (irq >= 0 && request_irq(irq, snd_gus_interrupt, IRQF_DISABLED, "GUS GF1", (void *) gus)) {
     178        if (irq >= 0 && request_irq(irq, snd_gus_interrupt, 0, "GUS GF1", (void *) gus)) {
    184179                snd_printk(KERN_ERR "gus: can't grab irq %d\n", irq);
    185180                snd_gus_free(gus);
     
    187182        }
    188183        gus->gf1.irq = irq;
     184        card->sync_irq = irq;
    189185        if (request_dma(dma1, "GUS - 1")) {
    190186                snd_printk(KERN_ERR "gus: can't grab DMA1 %d\n", dma1);
     
    272268        unsigned long flags;
    273269        int irq, dma1, dma2;
    274         static unsigned char irqs[16] =
     270        static const unsigned char irqs[16] =
    275271                {0, 0, 1, 3, 0, 2, 0, 4, 0, 1, 0, 5, 6, 0, 0, 7};
    276         static unsigned char dmas[8] =
     272        static const unsigned char dmas[8] =
    277273                {6, 1, 0, 2, 0, 3, 4, 5};
    278274
     
    465461EXPORT_SYMBOL(snd_gf1_mem_free);
    466462EXPORT_SYMBOL(snd_gf1_mem_lock);
    467 
    468 /*
    469  *  INIT part
    470  */
    471 
    472 static int __init alsa_gus_init(void)
    473 {
    474         return 0;
    475 }
    476 
    477 static void __exit alsa_gus_exit(void)
    478 {
    479 }
    480 
    481 module_init(alsa_gus_init)
    482 module_exit(alsa_gus_exit)
  • GPL/trunk/alsa-kernel/isa/gus/gus_mem.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    34 *  GUS's memory allocation routines / bottom layer
    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
     
    239224        struct snd_gf1_mem *alloc;
    240225        struct snd_gf1_mem_block block;
    241 #ifdef CONFIG_SND_DEBUG
    242         struct snd_info_entry *entry;
    243 #endif
    244226
    245227        alloc = &gus->gf1.mem_alloc;
     
    264246                return -ENOMEM;
    265247#ifdef CONFIG_SND_DEBUG
    266         if (! snd_card_proc_new(gus->card, "gusmem", &entry))
    267                 snd_info_set_text_ops(entry, gus, snd_gf1_mem_info_read);
     248        snd_card_ro_proc_new(gus->card, "gusmem", gus, snd_gf1_mem_info_read);
    268249#endif
    269250        return 0;
     
    311292        for (block = alloc->first, i = 0; block; block = block->next, i++) {
    312293                used += block->size;
    313                 snd_iprintf(buffer, "Block %i at 0x%lx onboard 0x%x size %i (0x%x):\n", i, (long) block, block->ptr, block->size, block->size);
     294                snd_iprintf(buffer, "Block %i onboard 0x%x size %i (0x%x):\n", i, block->ptr, block->size, block->size);
    314295                if (block->share ||
    315296                    block->share_id[0] || block->share_id[1] ||
  • GPL/trunk/alsa-kernel/isa/gus/gus_mem_proc.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    34 *  GUS's memory access via proc filesystem
    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
     
    5338}
    5439
    55 static struct snd_info_entry_ops snd_gf1_mem_proc_ops = {
     40static const struct snd_info_entry_ops snd_gf1_mem_proc_ops = {
    5641        .read = snd_gf1_mem_proc_dump,
    5742};
  • GPL/trunk/alsa-kernel/isa/gus/gus_mixer.c

    r399 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    34 *  Routines for control of ICS 2101 chip and "mixer" in GF1 chip
    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
     
    11095        int addr = kcontrol->private_value & 0xff;
    11196        int change;
    112         unsigned char val1, val2, oval1, oval2, tmp;
     97        unsigned char val1, val2, oval1, oval2;
    11398       
    11499        val1 = ucontrol->value.integer.value[0] & 127;
     
    121106        gus->gf1.ics_regs[addr][1] = val2;
    122107        if (gus->ics_flag && gus->ics_flipped &&
    123             (addr == SNDRV_ICS_GF1_DEV || addr == SNDRV_ICS_MASTER_DEV)) {
    124                 tmp = val1;
    125                 val1 = val2;
    126                 val2 = tmp;
    127         }
     108            (addr == SNDRV_ICS_GF1_DEV || addr == SNDRV_ICS_MASTER_DEV))
     109                swap(val1, val2);
    128110        addr <<= 3;
    129111        outb(addr | 0, GUSP(gus, MIXCNTRLPORT));
     
    139121}
    140122
    141 static struct snd_kcontrol_new snd_gf1_controls[] = {
     123static const struct snd_kcontrol_new snd_gf1_controls[] = {
    142124GF1_SINGLE("Master Playback Switch", 0, 1, 1),
    143125GF1_SINGLE("Line Switch", 0, 0, 1),
     
    145127};
    146128
    147 static struct snd_kcontrol_new snd_ics_controls[] = {
     129static const struct snd_kcontrol_new snd_ics_controls[] = {
    148130GF1_SINGLE("Master Playback Switch", 0, 1, 1),
    149131ICS_DOUBLE("Master Playback Volume", 0, SNDRV_ICS_MASTER_DEV),
  • GPL/trunk/alsa-kernel/isa/gus/gus_pcm.c

    r464 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    89 *  This code emulates autoinit DMA transfer for playback, recording by GF1
    910 *  chip doesn't support autoinit DMA.
    10  *
    11  *
    12  *   This program is free software; you can redistribute it and/or modify
    13  *   it under the terms of the GNU General Public License as published by
    14  *   the Free Software Foundation; either version 2 of the License, or
    15  *   (at your option) any later version.
    16  *
    17  *   This program is distributed in the hope that it will be useful,
    18  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    19  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  *   GNU General Public License for more details.
    21  *
    22  *   You should have received a copy of the GNU General Public License
    23  *   along with this program; if not, write to the Free Software
    24  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    25  *
    2611 */
    2712
    2813#include <asm/dma.h>
    2914#include <linux/slab.h>
     15#include <linux/sched/signal.h>
     16
    3017#include <sound/core.h>
    3118#include <sound/control.h>
     
    5946        int final_volume;
    6047};
    61 
    62 static int snd_gf1_pcm_use_dma = 1;
    6348
    6449static void snd_gf1_pcm_block_change_ack(struct snd_gus_card * gus, void *private_data)
     
    354339}
    355340
    356 static int snd_gf1_pcm_playback_copy(struct snd_pcm_substream *substream,
    357                                      int voice,
    358                                      snd_pcm_uframes_t pos,
    359                                      void __user *src,
    360                                      snd_pcm_uframes_t count)
    361 {
    362         struct snd_pcm_runtime *runtime = substream->runtime;
    363         struct gus_pcm_private *pcmp = runtime->private_data;
    364         unsigned int bpos, len;
    365        
    366         bpos = samples_to_bytes(runtime, pos) + (voice * (pcmp->dma_size / 2));
    367         len = samples_to_bytes(runtime, count);
     341static int get_bpos(struct gus_pcm_private *pcmp, int voice, unsigned int pos,
     342                    unsigned int len)
     343{
     344        unsigned int bpos = pos + (voice * (pcmp->dma_size / 2));
    368345        if (snd_BUG_ON(bpos > pcmp->dma_size))
    369346                return -EIO;
    370347        if (snd_BUG_ON(bpos + len > pcmp->dma_size))
    371348                return -EIO;
     349        return bpos;
     350}
     351
     352static int playback_copy_ack(struct snd_pcm_substream *substream,
     353                             unsigned int bpos, unsigned int len)
     354{
     355        struct snd_pcm_runtime *runtime = substream->runtime;
     356        struct gus_pcm_private *pcmp = runtime->private_data;
     357        struct snd_gus_card *gus = pcmp->gus;
     358        int w16, invert;
     359
     360        if (len > 32)
     361                return snd_gf1_pcm_block_change(substream, bpos,
     362                                                pcmp->memory + bpos, len);
     363
     364        w16 = (snd_pcm_format_width(runtime->format) == 16);
     365        invert = snd_pcm_format_unsigned(runtime->format);
     366        return snd_gf1_pcm_poke_block(gus, runtime->dma_area + bpos,
     367                                      pcmp->memory + bpos, len, w16, invert);
     368}
     369
     370static int snd_gf1_pcm_playback_copy(struct snd_pcm_substream *substream,
     371                                     int voice, unsigned long pos,
     372                                     void __user *src, unsigned long count)
     373{
     374        struct snd_pcm_runtime *runtime = substream->runtime;
     375        struct gus_pcm_private *pcmp = runtime->private_data;
     376        unsigned int len = count;
     377        int bpos;
     378
     379        bpos = get_bpos(pcmp, voice, pos, len);
     380        if (bpos < 0)
     381                return pos;
    372382        if (copy_from_user(runtime->dma_area + bpos, src, len))
    373383                return -EFAULT;
    374         if (snd_gf1_pcm_use_dma && len > 32) {
    375                 return snd_gf1_pcm_block_change(substream, bpos, pcmp->memory + bpos, len);
    376         } else {
    377                 struct snd_gus_card *gus = pcmp->gus;
    378                 int err, w16, invert;
    379 
    380                 w16 = (snd_pcm_format_width(runtime->format) == 16);
    381                 invert = snd_pcm_format_unsigned(runtime->format);
    382                 if ((err = snd_gf1_pcm_poke_block(gus, runtime->dma_area + bpos, pcmp->memory + bpos, len, w16, invert)) < 0)
    383                         return err;
    384         }
    385         return 0;
     384        return playback_copy_ack(substream, bpos, len);
     385}
     386
     387static int snd_gf1_pcm_playback_copy_kernel(struct snd_pcm_substream *substream,
     388                                            int voice, unsigned long pos,
     389                                            void *src, unsigned long count)
     390{
     391        struct snd_pcm_runtime *runtime = substream->runtime;
     392        struct gus_pcm_private *pcmp = runtime->private_data;
     393        unsigned int len = count;
     394        int bpos;
     395
     396        bpos = get_bpos(pcmp, voice, pos, len);
     397        if (bpos < 0)
     398                return pos;
     399        memcpy(runtime->dma_area + bpos, src, len);
     400        return playback_copy_ack(substream, bpos, len);
    386401}
    387402
    388403static int snd_gf1_pcm_playback_silence(struct snd_pcm_substream *substream,
    389                                         int voice,
    390                                         snd_pcm_uframes_t pos,
    391                                         snd_pcm_uframes_t count)
    392 {
    393         struct snd_pcm_runtime *runtime = substream->runtime;
    394         struct gus_pcm_private *pcmp = runtime->private_data;
    395         unsigned int bpos, len;
     404                                        int voice, unsigned long pos,
     405                                        unsigned long count)
     406{
     407        struct snd_pcm_runtime *runtime = substream->runtime;
     408        struct gus_pcm_private *pcmp = runtime->private_data;
     409        unsigned int len = count;
     410        int bpos;
    396411       
    397         bpos = samples_to_bytes(runtime, pos) + (voice * (pcmp->dma_size / 2));
    398         len = samples_to_bytes(runtime, count);
    399         if (snd_BUG_ON(bpos > pcmp->dma_size))
    400                 return -EIO;
    401         if (snd_BUG_ON(bpos + len > pcmp->dma_size))
    402                 return -EIO;
    403         snd_pcm_format_set_silence(runtime->format, runtime->dma_area + bpos, count);
    404         if (snd_gf1_pcm_use_dma && len > 32) {
    405                 return snd_gf1_pcm_block_change(substream, bpos, pcmp->memory + bpos, len);
    406         } else {
    407                 struct snd_gus_card *gus = pcmp->gus;
    408                 int err, w16, invert;
    409 
    410                 w16 = (snd_pcm_format_width(runtime->format) == 16);
    411                 invert = snd_pcm_format_unsigned(runtime->format);
    412                 if ((err = snd_gf1_pcm_poke_block(gus, runtime->dma_area + bpos, pcmp->memory + bpos, len, w16, invert)) < 0)
    413                         return err;
    414         }
    415         return 0;
     412        bpos = get_bpos(pcmp, voice, pos, len);
     413        if (bpos < 0)
     414                return pos;
     415        snd_pcm_format_set_silence(runtime->format, runtime->dma_area + bpos,
     416                                   bytes_to_samples(runtime, count));
     417        return playback_copy_ack(substream, bpos, len);
    416418}
    417419
     
    422424        struct snd_pcm_runtime *runtime = substream->runtime;
    423425        struct gus_pcm_private *pcmp = runtime->private_data;
    424         int err;
    425        
    426         if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0)
    427                 return err;
    428         if (err > 0) {  /* change */
     426
     427        if (runtime->buffer_changed) {
    429428                struct snd_gf1_mem_block *block;
    430429                if (pcmp->memory > 0) {
     
    470469        struct gus_pcm_private *pcmp = runtime->private_data;
    471470
    472         snd_pcm_lib_free_pages(substream);
    473471        if (pcmp->pvoices[0]) {
    474472                snd_gf1_free_voice(pcmp->gus, pcmp->pvoices[0]);
     
    546544}
    547545
    548 static struct snd_ratnum clock = {
     546static const struct snd_ratnum clock = {
    549547        .num = 9878400/16,
    550548        .den_min = 2,
     
    553551};
    554552
    555 static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks  = {
     553static const struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks  = {
    556554        .nrats = 1,
    557555        .rats = &clock,
     
    573571        if (snd_pcm_format_unsigned(params_format(hw_params)))
    574572                gus->gf1.pcm_rcntrl_reg |= 0x80;
    575         return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
    576 }
    577 
    578 static int snd_gf1_pcm_capture_hw_free(struct snd_pcm_substream *substream)
    579 {
    580         return snd_pcm_lib_free_pages(substream);
     573        return 0;
    581574}
    582575
     
    634627}
    635628
    636 static struct snd_pcm_hardware snd_gf1_pcm_playback =
     629static const struct snd_pcm_hardware snd_gf1_pcm_playback =
    637630{
    638631        .info =                 SNDRV_PCM_INFO_NONINTERLEAVED,
     
    652645};
    653646
    654 static struct snd_pcm_hardware snd_gf1_pcm_capture =
     647static const struct snd_pcm_hardware snd_gf1_pcm_capture =
    655648{
    656649        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    808801}
    809802
    810 static struct snd_kcontrol_new snd_gf1_pcm_volume_control =
     803static const struct snd_kcontrol_new snd_gf1_pcm_volume_control =
    811804{
    812805        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    817810};
    818811
    819 static struct snd_kcontrol_new snd_gf1_pcm_volume_control1 =
     812static const struct snd_kcontrol_new snd_gf1_pcm_volume_control1 =
    820813{
    821814        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    826819};
    827820
    828 static struct snd_pcm_ops snd_gf1_pcm_playback_ops = {
     821static const struct snd_pcm_ops snd_gf1_pcm_playback_ops = {
    829822        .open =         snd_gf1_pcm_playback_open,
    830823        .close =        snd_gf1_pcm_playback_close,
    831         .ioctl =        snd_pcm_lib_ioctl,
    832824        .hw_params =    snd_gf1_pcm_playback_hw_params,
    833825        .hw_free =      snd_gf1_pcm_playback_hw_free,
     
    835827        .trigger =      snd_gf1_pcm_playback_trigger,
    836828        .pointer =      snd_gf1_pcm_playback_pointer,
    837         .copy =         snd_gf1_pcm_playback_copy,
    838         .silence =      snd_gf1_pcm_playback_silence,
     829        .copy_user =    snd_gf1_pcm_playback_copy,
     830        .copy_kernel =  snd_gf1_pcm_playback_copy_kernel,
     831        .fill_silence = snd_gf1_pcm_playback_silence,
    839832};
    840833
    841 static struct snd_pcm_ops snd_gf1_pcm_capture_ops = {
     834static const struct snd_pcm_ops snd_gf1_pcm_capture_ops = {
    842835        .open =         snd_gf1_pcm_capture_open,
    843836        .close =        snd_gf1_pcm_capture_close,
    844         .ioctl =        snd_pcm_lib_ioctl,
    845837        .hw_params =    snd_gf1_pcm_capture_hw_params,
    846         .hw_free =      snd_gf1_pcm_capture_hw_free,
    847838        .prepare =      snd_gf1_pcm_capture_prepare,
    848839        .trigger =      snd_gf1_pcm_capture_trigger,
     
    850841};
    851842
    852 int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, struct snd_pcm ** rpcm)
     843int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index)
    853844{
    854845        struct snd_card *card;
     
    858849        int capture, err;
    859850
    860         if (rpcm)
    861                 *rpcm = NULL;
    862851        card = gus->card;
    863852        capture = !gus->interwave && !gus->ess_flag && !gus->ace_flag ? 1 : 0;
     
    875864
    876865        for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
    877                 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
    878                                               snd_dma_isa_data(),
    879                                               64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024);
     866                snd_pcm_set_managed_buffer(substream, SNDRV_DMA_TYPE_DEV,
     867                                           card->dev,
     868                                           64*1024, gus->gf1.dma1 > 3 ? 128*1024 : 64*1024);
    880869       
    881870        pcm->info_flags = 0;
     
    885874                if (gus->gf1.dma2 == gus->gf1.dma1)
    886875                        pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX;
    887                 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
    888                                               SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(),
    889                                               64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024);
     876                snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
     877                                           SNDRV_DMA_TYPE_DEV, card->dev,
     878                                           64*1024, gus->gf1.dma2 > 3 ? 128*1024 : 64*1024);
    890879        }
    891880        strcpy(pcm->name, pcm->id);
     
    904893        kctl->id.index = control_index;
    905894
    906         if (rpcm)
    907                 *rpcm = pcm;
    908         return 0;
    909 }
    910 
     895        return 0;
     896}
     897
  • GPL/trunk/alsa-kernel/isa/gus/gus_reset.c

    r305 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    3  *
    4  *
    5  *   This program is free software; you can redistribute it and/or modify
    6  *   it under the terms of the GNU General Public License as published by
    7  *   the Free Software Foundation; either version 2 of the License, or
    8  *   (at your option) any later version.
    9  *
    10  *   This program is distributed in the hope that it will be useful,
    11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  *   GNU General Public License for more details.
    14  *
    15  *   You should have received a copy of the GNU General Public License
    16  *   along with this program; if not, write to the Free Software
    17  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    18  *
    194 */
    205
     
    2510#include <sound/gus.h>
    2611
    27 extern void snd_gf1_timers_init(struct snd_gus_card * gus);
    28 extern void snd_gf1_timers_done(struct snd_gus_card * gus);
    2912extern int snd_gf1_synth_init(struct snd_gus_card * gus);
    3013extern void snd_gf1_synth_done(struct snd_gus_card * gus);
     
    293276        unsigned long flags;
    294277        void (*private_free)(struct snd_gus_voice *voice);
    295         void *private_data;
    296278
    297279        if (voice == NULL || !voice->use)
     
    301283        spin_lock_irqsave(&gus->voice_alloc, flags);
    302284        private_free = voice->private_free;
    303         private_data = voice->private_data;
    304285        voice->private_free = NULL;
    305286        voice->private_data = NULL;
  • GPL/trunk/alsa-kernel/isa/gus/gus_tables.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    3  *
    4  *
    5  *   This program is free software; you can redistribute it and/or modify
    6  *   it under the terms of the GNU General Public License as published by
    7  *   the Free Software Foundation; either version 2 of the License, or
    8  *   (at your option) any later version.
    9  *
    10  *   This program is distributed in the hope that it will be useful,
    11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  *   GNU General Public License for more details.
    14  *
    15  *   You should have received a copy of the GNU General Public License
    16  *   along with this program; if not, write to the Free Software
    17  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    18  *
    194 */
    205
  • GPL/trunk/alsa-kernel/isa/gus/gus_timer.c

    r305 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Routines for Gravis UltraSound soundcards - Timers
     
    45 *
    56 *  GUS have similar timers as AdLib (OPL2/OPL3 chips).
    6  *
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    21  *
    227 */
    238
     
    124109 */
    125110
    126 static struct snd_timer_hardware snd_gf1_timer1 =
     111static const struct snd_timer_hardware snd_gf1_timer1 =
    127112{
    128113        .flags =        SNDRV_TIMER_HW_STOP,
     
    133118};
    134119
    135 static struct snd_timer_hardware snd_gf1_timer2 =
     120static const struct snd_timer_hardware snd_gf1_timer2 =
    136121{
    137122        .flags =        SNDRV_TIMER_HW_STOP,
  • GPL/trunk/alsa-kernel/isa/gus/gus_uart.c

    r426 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    34 *  Routines for the GF1 MIDI interface - like UART 6850
    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
     
    2914{
    3015        int count;
    31         unsigned char stat, data, byte;
     16        unsigned char stat, byte;
     17        __always_unused unsigned char data;
    3218        unsigned long flags;
    3319
     
    228214}
    229215
    230 static struct snd_rawmidi_ops snd_gf1_uart_output =
     216static const struct snd_rawmidi_ops snd_gf1_uart_output =
    231217{
    232218        .open =         snd_gf1_uart_output_open,
     
    235221};
    236222
    237 static struct snd_rawmidi_ops snd_gf1_uart_input =
     223static const struct snd_rawmidi_ops snd_gf1_uart_input =
    238224{
    239225        .open =         snd_gf1_uart_input_open,
     
    242228};
    243229
    244 int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi ** rrawmidi)
     230int snd_gf1_rawmidi_new(struct snd_gus_card *gus, int device)
    245231{
    246232        struct snd_rawmidi *rmidi;
    247233        int err;
    248234
    249         if (rrawmidi)
    250                 *rrawmidi = NULL;
    251235        if ((err = snd_rawmidi_new(gus->card, "GF1", device, 1, 1, &rmidi)) < 0)
    252236                return err;
     
    257241        rmidi->private_data = gus;
    258242        gus->midi_uart = rmidi;
    259         if (rrawmidi)
    260                 *rrawmidi = rmidi;
    261243        return err;
    262244}
  • GPL/trunk/alsa-kernel/isa/gus/gus_volume.c

    r305 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    3  *
    4  *
    5  *   This program is free software; you can redistribute it and/or modify
    6  *   it under the terms of the GNU General Public License as published by
    7  *   the Free Software Foundation; either version 2 of the License, or
    8  *   (at your option) any later version.
    9  *
    10  *   This program is distributed in the hope that it will be useful,
    11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  *   GNU General Public License for more details.
    14  *
    15  *   You should have received a copy of the GNU General Public License
    16  *   along with this program; if not, write to the Free Software
    17  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    18  *
    194 */
    205
    216#include <linux/time.h>
     7#include <linux/export.h>
    228#include <sound/core.h>
    239#include <sound/gus.h>
     
    7763                                    unsigned int us)
    7864{
    79         static unsigned char vol_rates[19] =
     65        static const unsigned char vol_rates[19] =
    8066        {
    8167                23, 24, 26, 28, 29, 31, 32, 34,
     
    128114short snd_gf1_compute_vibrato(short cents, unsigned short fc_register)
    129115{
    130         static short vibrato_table[] =
     116        static const short vibrato_table[] =
    131117        {
    132118                0, 0, 32, 592, 61, 1175, 93, 1808,
     
    136122
    137123        long depth;
    138         short *vi1, *vi2, pcents, v1;
     124        const short *vi1, *vi2;
     125        short pcents, v1;
    139126
    140127        pcents = cents < 0 ? -cents : cents;
     
    160147unsigned short snd_gf1_compute_pitchbend(unsigned short pitchbend, unsigned short sens)
    161148{
    162         static long log_table[] = {1024, 1085, 1149, 1218, 1290, 1367, 1448, 1534, 1625, 1722, 1825, 1933};
     149        static const long log_table[] = {1024, 1085, 1149, 1218, 1290, 1367, 1448, 1534, 1625, 1722, 1825, 1933};
    163150        int wheel, sensitivity;
    164151        unsigned int mantissa, f1, f2;
  • GPL/trunk/alsa-kernel/isa/gus/gusclassic.c

    r410 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for Gravis UltraSound Classic soundcard
    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
     
    2510#include <linux/delay.h>
    2611#include <linux/time.h>
    27 #include <linux/moduleparam.h>
     12#include <linux/module.h>
    2813#include <asm/dma.h>
    2914#include <sound/core.h>
     
    4328static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4429static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    45 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;  /* Enable this card */
     30static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
    4631static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x230,0x240,0x250,0x260 */
    4732static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;        /* 3,5,9,11,12,15 */
     
    5944module_param_array(enable, bool, NULL, 0444);
    6045MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
    61 module_param_array(port, long, NULL, 0444);
     46module_param_hw_array(port, long, ioport, NULL, 0444);
    6247MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
    63 module_param_array(irq, int, NULL, 0444);
     48module_param_hw_array(irq, int, irq, NULL, 0444);
    6449MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
    65 module_param_array(dma1, int, NULL, 0444);
     50module_param_hw_array(dma1, int, dma, NULL, 0444);
    6651MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
    67 module_param_array(dma2, int, NULL, 0444);
     52module_param_hw_array(dma2, int, dma, NULL, 0444);
    6853MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver.");
    6954module_param_array(joystick_dac, int, NULL, 0444);
     
    7459MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver.");
    7560
    76 static int __devinit snd_gusclassic_match(struct device *dev, unsigned int n)
     61static int snd_gusclassic_match(struct device *dev, unsigned int n)
    7762{
    7863        return enable[n];
    7964}
    8065
    81 static int __devinit snd_gusclassic_create(struct snd_card *card,
    82                 struct device *dev, unsigned int n, struct snd_gus_card **rgus)
    83 {
    84         static long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260};
    85         static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1};
    86         static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
     66static int snd_gusclassic_create(struct snd_card *card,
     67                                 struct device *dev, unsigned int n,
     68                                 struct snd_gus_card **rgus)
     69{
     70        static const long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260};
     71        static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1};
     72        static const int possible_dmas[] = {5, 6, 7, 1, 3, -1};
    8773
    8874        int i, error;
     
    124110}
    125111
    126 static int __devinit snd_gusclassic_detect(struct snd_gus_card *gus)
     112static int snd_gusclassic_detect(struct snd_gus_card *gus)
    127113{
    128114        unsigned char d;
     
    143129}
    144130
    145 static int __devinit snd_gusclassic_probe(struct device *dev, unsigned int n)
     131static int snd_gusclassic_probe(struct device *dev, unsigned int n)
    146132{
    147133        struct snd_card *card;
     
    149135        int error;
    150136
    151         error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card);
     137        error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
    152138        if (error < 0)
    153139                return error;
     
    181167                goto out;
    182168
    183         error = snd_gf1_pcm_new(gus, 0, 0, NULL);
     169        error = snd_gf1_pcm_new(gus, 0, 0);
    184170        if (error < 0)
    185171                goto out;
    186172
    187173        if (!gus->ace_flag) {
    188                 error = snd_gf1_rawmidi_new(gus, 0, NULL);
     174                error = snd_gf1_rawmidi_new(gus, 0);
    189175                if (error < 0)
    190176                        goto out;
     
    199185                        "&%d", gus->gf1.dma2);
    200186
    201         snd_card_set_dev(card, dev);
    202 
    203187        error = snd_card_register(card);
    204188        if (error < 0)
     
    212196}
    213197
    214 static int __devexit snd_gusclassic_remove(struct device *dev, unsigned int n)
     198static int snd_gusclassic_remove(struct device *dev, unsigned int n)
    215199{
    216200        snd_card_free(dev_get_drvdata(dev));
    217         dev_set_drvdata(dev, NULL);
    218201        return 0;
    219202}
     
    222205        .match          = snd_gusclassic_match,
    223206        .probe          = snd_gusclassic_probe,
    224         .remove         = __devexit_p(snd_gusclassic_remove),
     207        .remove         = snd_gusclassic_remove,
    225208#if 0   /* FIXME */
    226209        .suspend        = snd_gusclassic_suspend,
     
    232215};
    233216
    234 static int __init alsa_card_gusclassic_init(void)
    235 {
    236         return isa_register_driver(&snd_gusclassic_driver, SNDRV_CARDS);
    237 }
    238 
    239 static void __exit alsa_card_gusclassic_exit(void)
    240 {
    241         isa_unregister_driver(&snd_gusclassic_driver);
    242 }
    243 
    244 module_init(alsa_card_gusclassic_init);
    245 module_exit(alsa_card_gusclassic_exit);
     217module_isa_driver(snd_gusclassic_driver, SNDRV_CARDS);
  • GPL/trunk/alsa-kernel/isa/gus/gusextreme.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for Gravis UltraSound Extreme soundcards
    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
     
    2510#include <linux/delay.h>
    2611#include <linux/time.h>
    27 #include <linux/moduleparam.h>
     12#include <linux/module.h>
    2813#include <asm/dma.h>
    2914#include <sound/core.h>
     
    4732static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4833static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    49 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;  /* Enable this card */
     34static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
    5035static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x240,0x260 */
    5136static long gf1_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS) - 1] = -1}; /* 0x210,0x220,0x230,0x240,0x250,0x260,0x270 */
     
    6752module_param_array(enable, bool, NULL, 0444);
    6853MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
    69 module_param_array(port, long, NULL, 0444);
     54module_param_hw_array(port, long, ioport, NULL, 0444);
    7055MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
    71 module_param_array(gf1_port, long, NULL, 0444);
     56module_param_hw_array(gf1_port, long, ioport, NULL, 0444);
    7257MODULE_PARM_DESC(gf1_port, "GF1 port # for " CRD_NAME " driver (optional).");
    73 module_param_array(mpu_port, long, NULL, 0444);
     58module_param_hw_array(mpu_port, long, ioport, NULL, 0444);
    7459MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
    75 module_param_array(irq, int, NULL, 0444);
     60module_param_hw_array(irq, int, irq, NULL, 0444);
    7661MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
    77 module_param_array(mpu_irq, int, NULL, 0444);
     62module_param_hw_array(mpu_irq, int, irq, NULL, 0444);
    7863MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
    79 module_param_array(gf1_irq, int, NULL, 0444);
     64module_param_hw_array(gf1_irq, int, irq, NULL, 0444);
    8065MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for " CRD_NAME " driver.");
    81 module_param_array(dma8, int, NULL, 0444);
     66module_param_hw_array(dma8, int, dma, NULL, 0444);
    8267MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver.");
    83 module_param_array(dma1, int, NULL, 0444);
     68module_param_hw_array(dma1, int, dma, NULL, 0444);
    8469MODULE_PARM_DESC(dma1, "GF1 DMA # for " CRD_NAME " driver.");
    8570module_param_array(joystick_dac, int, NULL, 0444);
     
    9075MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver.");
    9176
    92 static int __devinit snd_gusextreme_match(struct device *dev, unsigned int n)
     77static int snd_gusextreme_match(struct device *dev, unsigned int n)
    9378{
    9479        return enable[n];
    9580}
    9681
    97 static int __devinit snd_gusextreme_es1688_create(struct snd_card *card,
    98                 struct snd_es1688 *chip, struct device *dev, unsigned int n)
    99 {
    100         static long possible_ports[] = {0x220, 0x240, 0x260};
    101         static int possible_irqs[] = {5, 9, 10, 7, -1};
    102         static int possible_dmas[] = {1, 3, 0, -1};
     82static int snd_gusextreme_es1688_create(struct snd_card *card,
     83                                        struct snd_es1688 *chip,
     84                                        struct device *dev, unsigned int n)
     85{
     86        static const long possible_ports[] = {0x220, 0x240, 0x260};
     87        static const int possible_irqs[] = {5, 9, 10, 7, -1};
     88        static const int possible_dmas[] = {1, 3, 0, -1};
    10389
    10490        int i, error;
     
    133119}
    134120
    135 static int __devinit snd_gusextreme_gus_card_create(struct snd_card *card,
    136                 struct device *dev, unsigned int n, struct snd_gus_card **rgus)
    137 {
    138         static int possible_irqs[] = {11, 12, 15, 9, 5, 7, 3, -1};
    139         static int possible_dmas[] = {5, 6, 7, 3, 1, -1};
     121static int snd_gusextreme_gus_card_create(struct snd_card *card,
     122                                          struct device *dev, unsigned int n,
     123                                          struct snd_gus_card **rgus)
     124{
     125        static const int possible_irqs[] = {11, 12, 15, 9, 5, 7, 3, -1};
     126        static const int possible_dmas[] = {5, 6, 7, 3, 1, -1};
    140127
    141128        if (gf1_irq[n] == SNDRV_AUTO_IRQ) {
     
    157144}
    158145
    159 static int __devinit snd_gusextreme_detect(struct snd_gus_card *gus,
    160         struct snd_es1688 *es1688)
     146static int snd_gusextreme_detect(struct snd_gus_card *gus,
     147                                 struct snd_es1688 *es1688)
    161148{
    162149        unsigned long flags;
     
    207194}
    208195
    209 static int __devinit snd_gusextreme_mixer(struct snd_card *card)
     196static int snd_gusextreme_mixer(struct snd_card *card)
    210197{
    211198        struct snd_ctl_elem_id id1, id2;
     
    233220}
    234221
    235 static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n)
     222static int snd_gusextreme_probe(struct device *dev, unsigned int n)
    236223{
    237224        struct snd_card *card;
     
    241228        int error;
    242229
    243         error = snd_card_create(index[n], id[n], THIS_MODULE,
    244                                 sizeof(struct snd_es1688), &card);
     230        error = snd_card_new(dev, index[n], id[n], THIS_MODULE,
     231                             sizeof(struct snd_es1688), &card);
    245232        if (error < 0)
    246233                return error;
     
    283270        gus->codec_flag = 1;
    284271
    285         error = snd_es1688_pcm(card, es1688, 0, NULL);
     272        error = snd_es1688_pcm(card, es1688, 0);
    286273        if (error < 0)
    287274                goto out;
     
    294281
    295282        if (pcm_channels[n] > 0) {
    296                 error = snd_gf1_pcm_new(gus, 1, 1, NULL);
     283                error = snd_gf1_pcm_new(gus, 1, 1);
    297284                if (error < 0)
    298285                        goto out;
     
    318305        if (es1688->mpu_port >= 0x300) {
    319306                error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
    320                                 es1688->mpu_port, 0,
    321                                 mpu_irq[n], IRQF_DISABLED, NULL);
     307                                es1688->mpu_port, 0, mpu_irq[n], NULL);
    322308                if (error < 0)
    323309                        goto out;
     
    328314                gus->gf1.irq, es1688->irq, gus->gf1.dma1, es1688->dma8);
    329315
    330         snd_card_set_dev(card, dev);
    331 
    332316        error = snd_card_register(card);
    333317        if (error < 0)
     
    341325}
    342326
    343 static int __devexit snd_gusextreme_remove(struct device *dev, unsigned int n)
     327static int snd_gusextreme_remove(struct device *dev, unsigned int n)
    344328{
    345329        snd_card_free(dev_get_drvdata(dev));
    346         dev_set_drvdata(dev, NULL);
    347330        return 0;
    348331}
     
    351334        .match          = snd_gusextreme_match,
    352335        .probe          = snd_gusextreme_probe,
    353         .remove         = __devexit_p(snd_gusextreme_remove),
     336        .remove         = snd_gusextreme_remove,
    354337#if 0   /* FIXME */
    355338        .suspend        = snd_gusextreme_suspend,
     
    361344};
    362345
    363 static int __init alsa_card_gusextreme_init(void)
    364 {
    365         return isa_register_driver(&snd_gusextreme_driver, SNDRV_CARDS);
    366 }
    367 
    368 static void __exit alsa_card_gusextreme_exit(void)
    369 {
    370         isa_unregister_driver(&snd_gusextreme_driver);
    371 }
    372 
    373 module_init(alsa_card_gusextreme_init);
    374 module_exit(alsa_card_gusextreme_exit);
     346module_isa_driver(snd_gusextreme_driver, SNDRV_CARDS);
  • GPL/trunk/alsa-kernel/isa/gus/gusmax.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for Gravis UltraSound MAX soundcard
    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
     
    2510#include <linux/delay.h>
    2611#include <linux/time.h>
    27 #include <linux/moduleparam.h>
     12#include <linux/module.h>
    2813#include <asm/dma.h>
    2914#include <sound/core.h>
     
    4126static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4227static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    43 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;  /* Enable this card */
     28static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
    4429static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x230,0x240,0x250,0x260 */
    4530static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;        /* 2,3,5,9,11,12,15 */
     
    5742module_param_array(enable, bool, NULL, 0444);
    5843MODULE_PARM_DESC(enable, "Enable GUS MAX soundcard.");
    59 module_param_array(port, long, NULL, 0444);
     44module_param_hw_array(port, long, ioport, NULL, 0444);
    6045MODULE_PARM_DESC(port, "Port # for GUS MAX driver.");
    61 module_param_array(irq, int, NULL, 0444);
     46module_param_hw_array(irq, int, irq, NULL, 0444);
    6247MODULE_PARM_DESC(irq, "IRQ # for GUS MAX driver.");
    63 module_param_array(dma1, int, NULL, 0444);
     48module_param_hw_array(dma1, int, dma, NULL, 0444);
    6449MODULE_PARM_DESC(dma1, "DMA1 # for GUS MAX driver.");
    65 module_param_array(dma2, int, NULL, 0444);
     50module_param_hw_array(dma2, int, dma, NULL, 0444);
    6651MODULE_PARM_DESC(dma2, "DMA2 # for GUS MAX driver.");
    6752module_param_array(joystick_dac, int, NULL, 0444);
     
    8368#define PFX     "gusmax: "
    8469
    85 static int __devinit snd_gusmax_detect(struct snd_gus_card * gus)
     70static int snd_gusmax_detect(struct snd_gus_card *gus)
    8671{
    8772        unsigned char d;
     
    125110}
    126111
    127 static void __devinit snd_gusmax_init(int dev, struct snd_card *card,
    128                                       struct snd_gus_card * gus)
     112static void snd_gusmax_init(int dev, struct snd_card *card,
     113                            struct snd_gus_card *gus)
    129114{
    130115        gus->equal_irq = 1;
     
    141126}
    142127
    143 static int __devinit snd_gusmax_mixer(struct snd_wss *chip)
     128static int snd_gusmax_mixer(struct snd_wss *chip)
    144129{
    145130        struct snd_card *card = chip->card;
     
    200185}
    201186
    202 static int __devinit snd_gusmax_match(struct device *pdev, unsigned int dev)
     187static int snd_gusmax_match(struct device *pdev, unsigned int dev)
    203188{
    204189        return enable[dev];
    205190}
    206191
    207 static int __devinit snd_gusmax_probe(struct device *pdev, unsigned int dev)
    208 {
    209         static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
    210         static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
     192static int snd_gusmax_probe(struct device *pdev, unsigned int dev)
     193{
     194        static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
     195        static const int possible_dmas[] = {5, 6, 7, 1, 3, -1};
    211196        int xirq, xdma1, xdma2, err;
    212197        struct snd_card *card;
     
    215200        struct snd_gusmax *maxcard;
    216201
    217         err = snd_card_create(index[dev], id[dev], THIS_MODULE,
    218                               sizeof(struct snd_gusmax), &card);
     202        err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
     203                           sizeof(struct snd_gusmax), &card);
    219204        if (err < 0)
    220205                return err;
     
    257242                                     0, &gus);
    258243        } else {
    259                 static unsigned long possible_ports[] = {
     244                static const unsigned long possible_ports[] = {
    260245                        0x220, 0x230, 0x240, 0x250, 0x260
    261246                };
     
    292277        }
    293278
    294         if (request_irq(xirq, snd_gusmax_interrupt, IRQF_DISABLED, "GUS MAX", (void *)maxcard)) {
     279        if (request_irq(xirq, snd_gusmax_interrupt, 0, "GUS MAX", (void *)maxcard)) {
    295280                snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq);
    296281                err = -EBUSY;
     
    298283        }
    299284        maxcard->irq = xirq;
    300        
     285        card->sync_irq = maxcard->irq;
     286
    301287        err = snd_wss_create(card,
    302288                             gus->gf1.port + 0x10c, -1, xirq,
     
    310296                goto _err;
    311297
    312         err = snd_wss_pcm(wss, 0, NULL);
     298        err = snd_wss_pcm(wss, 0);
    313299        if (err < 0)
    314300                goto _err;
     
    318304                goto _err;
    319305
    320         err = snd_wss_timer(wss, 2, NULL);
     306        err = snd_wss_timer(wss, 2);
    321307        if (err < 0)
    322308                goto _err;
    323309
    324310        if (pcm_channels[dev] > 0) {
    325                 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0)
     311                if ((err = snd_gf1_pcm_new(gus, 1, 1)) < 0)
    326312                        goto _err;
    327313        }
     
    330316                goto _err;
    331317
    332         err = snd_gf1_rawmidi_new(gus, 0, NULL);
     318        err = snd_gf1_rawmidi_new(gus, 0);
    333319        if (err < 0)
    334320                goto _err;
     
    338324                sprintf(card->longname + strlen(card->longname), "&%i", xdma2);
    339325
    340         snd_card_set_dev(card, pdev);
    341 
    342326        err = snd_card_register(card);
    343327        if (err < 0)
     
    355339}
    356340
    357 static int __devexit snd_gusmax_remove(struct device *devptr, unsigned int dev)
     341static int snd_gusmax_remove(struct device *devptr, unsigned int dev)
    358342{
    359343        snd_card_free(dev_get_drvdata(devptr));
    360         dev_set_drvdata(devptr, NULL);
    361344        return 0;
    362345}
     
    367350        .match          = snd_gusmax_match,
    368351        .probe          = snd_gusmax_probe,
    369         .remove         = __devexit_p(snd_gusmax_remove),
     352        .remove         = snd_gusmax_remove,
    370353        /* FIXME: suspend/resume */
    371354        .driver         = {
     
    374357};
    375358
    376 static int __init alsa_card_gusmax_init(void)
    377 {
    378         return isa_register_driver(&snd_gusmax_driver, SNDRV_CARDS);
    379 }
    380 
    381 static void __exit alsa_card_gusmax_exit(void)
    382 {
    383         isa_unregister_driver(&snd_gusmax_driver);
    384 }
    385 
    386 module_init(alsa_card_gusmax_init)
    387 module_exit(alsa_card_gusmax_exit)
     359module_isa_driver(snd_gusmax_driver, SNDRV_CARDS);
  • GPL/trunk/alsa-kernel/isa/gus/interwave.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for AMD InterWave soundcard
    34 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    45 *
    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  *
    206 *   1999/07/22         Erik Inge Bolso <knan@mo.himolde.no>
    217 *                      * mixer group handlers
    22  *
    238 */
    249
     
    2813#include <linux/delay.h>
    2914#include <linux/pnp.h>
    30 #include <linux/moduleparam.h>
     15#include <linux/module.h>
    3116#include <asm/dma.h>
    3217#include <sound/core.h>
     
    5641static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    5742static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    58 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
     43static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    5944#ifdef CONFIG_PNP
    60 static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
     45static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
    6146#endif
    6247static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x210,0x220,0x230,0x240,0x250,0x260 */
     
    9378MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard.");
    9479#endif
    95 module_param_array(port, long, NULL, 0444);
     80module_param_hw_array(port, long, ioport, NULL, 0444);
    9681MODULE_PARM_DESC(port, "Port # for InterWave driver.");
    9782#ifdef SNDRV_STB
    98 module_param_array(port_tc, long, NULL, 0444);
     83module_param_hw_array(port_tc, long, ioport, NULL, 0444);
    9984MODULE_PARM_DESC(port_tc, "Tone control (TEA6330T - i2c bus) port # for InterWave driver.");
    10085#endif
    101 module_param_array(irq, int, NULL, 0444);
     86module_param_hw_array(irq, int, irq, NULL, 0444);
    10287MODULE_PARM_DESC(irq, "IRQ # for InterWave driver.");
    103 module_param_array(dma1, int, NULL, 0444);
     88module_param_hw_array(dma1, int, dma, NULL, 0444);
    10489MODULE_PARM_DESC(dma1, "DMA1 # for InterWave driver.");
    105 module_param_array(dma2, int, NULL, 0444);
     90module_param_hw_array(dma2, int, dma, NULL, 0444);
    10691MODULE_PARM_DESC(dma2, "DMA2 # for InterWave driver.");
    10792module_param_array(joystick_dac, int, NULL, 0444);
     
    137122static int pnp_registered;
    138123
    139 static struct pnp_card_device_id snd_interwave_pnpids[] = {
     124static const struct pnp_card_device_id snd_interwave_pnpids[] = {
    140125#ifndef SNDRV_STB
    141126        /* Gravis UltraSound Plug & Play */
     
    208193};
    209194
    210 static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard,
    211                                               struct snd_gus_card * gus, int dev,
    212                                               struct snd_i2c_bus **rbus)
     195static int snd_interwave_detect_stb(struct snd_interwave *iwcard,
     196                                    struct snd_gus_card *gus, int dev,
     197                                    struct snd_i2c_bus **rbus)
    213198{
    214199        unsigned long port;
     
    250235#endif
    251236
    252 static int __devinit snd_interwave_detect(struct snd_interwave *iwcard,
    253                                           struct snd_gus_card * gus,
    254                                           int dev
    255 #ifdef SNDRV_STB
    256                                           , struct snd_i2c_bus **rbus
     237static int snd_interwave_detect(struct snd_interwave *iwcard,
     238                                struct snd_gus_card *gus,
     239                                int dev
     240#ifdef SNDRV_STB
     241                                , struct snd_i2c_bus **rbus
    257242#endif
    258243                                          )
     
    319304}
    320305
    321 static void __devinit snd_interwave_reset(struct snd_gus_card * gus)
     306static void snd_interwave_reset(struct snd_gus_card *gus)
    322307{
    323308        snd_gf1_write8(gus, SNDRV_GF1_GB_RESET, 0x00);
     
    327312}
    328313
    329 static void __devinit snd_interwave_bank_sizes(struct snd_gus_card * gus, int *sizes)
     314static void snd_interwave_bank_sizes(struct snd_gus_card *gus, int *sizes)
    330315{
    331316        unsigned int idx;
     
    378363};
    379364
    380 static void __devinit snd_interwave_detect_memory(struct snd_gus_card * gus)
    381 {
    382         static unsigned int lmc[13] =
     365static void snd_interwave_detect_memory(struct snd_gus_card *gus)
     366{
     367        static const unsigned int lmc[13] =
    383368        {
    384369                0x00000001, 0x00000101, 0x01010101, 0x00000401,
     
    443428                for (i = 0; i < 8; ++i)
    444429                        iwave[i] = snd_gf1_peek(gus, bank_pos + i);
    445 #ifdef CONFIG_SND_DEBUG_ROM
    446                 printk(KERN_DEBUG "ROM at 0x%06x = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", bank_pos,
    447                        iwave[0], iwave[1], iwave[2], iwave[3],
    448                        iwave[4], iwave[5], iwave[6], iwave[7]);
    449 #endif
    450430                if (strncmp(iwave, "INTRWAVE", 8))
    451431                        continue;       /* first check */
     
    453433                for (i = 0; i < sizeof(struct rom_hdr); i++)
    454434                        csum += snd_gf1_peek(gus, bank_pos + i);
    455 #ifdef CONFIG_SND_DEBUG_ROM
    456                 printk(KERN_DEBUG "ROM checksum = 0x%x (computed)\n", csum);
    457 #endif
    458435                if (csum != 0)
    459436                        continue;       /* not valid rom */
     
    477454}
    478455
    479 static void __devinit snd_interwave_init(int dev, struct snd_gus_card * gus)
     456static void snd_interwave_init(int dev, struct snd_gus_card *gus)
    480457{
    481458        unsigned long flags;
     
    499476}
    500477
    501 static struct snd_kcontrol_new snd_interwave_controls[] = {
     478static const struct snd_kcontrol_new snd_interwave_controls[] = {
    502479WSS_DOUBLE("Master Playback Switch", 0,
    503480                CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 7, 7, 1, 1),
     
    510487};
    511488
    512 static int __devinit snd_interwave_mixer(struct snd_wss *chip)
     489static int snd_interwave_mixer(struct snd_wss *chip)
    513490{
    514491        struct snd_card *card = chip->card;
     
    560537#ifdef CONFIG_PNP
    561538
    562 static int __devinit snd_interwave_pnp(int dev, struct snd_interwave *iwcard,
    563                                        struct pnp_card_link *card,
    564                                        const struct pnp_card_device_id *id)
     539static int snd_interwave_pnp(int dev, struct snd_interwave *iwcard,
     540                             struct pnp_card_link *card,
     541                             const struct pnp_card_device_id *id)
    565542{
    566543        struct pnp_dev *pdev;
     
    628605}
    629606
    630 static int snd_interwave_card_new(int dev, struct snd_card **cardp)
     607static int snd_interwave_card_new(struct device *pdev, int dev,
     608                                  struct snd_card **cardp)
    631609{
    632610        struct snd_card *card;
     
    634612        int err;
    635613
    636         err = snd_card_create(index[dev], id[dev], THIS_MODULE,
    637                               sizeof(struct snd_interwave), &card);
     614        err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
     615                           sizeof(struct snd_interwave), &card);
    638616        if (err < 0)
    639617                return err;
     
    646624}
    647625
    648 static int __devinit snd_interwave_probe(struct snd_card *card, int dev)
     626static int snd_interwave_probe(struct snd_card *card, int dev)
    649627{
    650628        int xirq, xdma1, xdma2;
     
    655633        struct snd_i2c_bus *i2c_bus;
    656634#endif
    657         struct snd_pcm *pcm;
    658635        char *str;
    659636        int err;
     
    685662                return err;
    686663
    687         if (request_irq(xirq, snd_interwave_interrupt, IRQF_DISABLED,
     664        if (request_irq(xirq, snd_interwave_interrupt, 0,
    688665                        "InterWave", iwcard)) {
    689666                snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq);
     
    691668        }
    692669        iwcard->irq = xirq;
     670        card->sync_irq = iwcard->irq;
    693671
    694672        err = snd_wss_create(card,
     
    703681                return err;
    704682
    705         err = snd_wss_pcm(wss, 0, &pcm);
     683        err = snd_wss_pcm(wss, 0);
    706684        if (err < 0)
    707685                return err;
    708686
    709         sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A');
    710         strcat(pcm->name, " (codec)");
    711 
    712         err = snd_wss_timer(wss, 2, NULL);
     687        sprintf(wss->pcm->name + strlen(wss->pcm->name), " rev %c",
     688                gus->revision + 'A');
     689        strcat(wss->pcm->name, " (codec)");
     690
     691        err = snd_wss_timer(wss, 2);
    713692        if (err < 0)
    714693                return err;
     
    719698
    720699        if (pcm_channels[dev] > 0) {
    721                 err = snd_gf1_pcm_new(gus, 1, 1, NULL);
     700                err = snd_gf1_pcm_new(gus, 1, 1);
    722701                if (err < 0)
    723702                        return err;
     
    748727
    749728        gus->uart_enable = midi[dev];
    750         if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0)
     729        if ((err = snd_gf1_rawmidi_new(gus, 0)) < 0)
    751730                return err;
    752731
     
    777756}
    778757
    779 static int __devinit snd_interwave_isa_probe1(int dev, struct device *devptr)
     758static int snd_interwave_isa_probe1(int dev, struct device *devptr)
    780759{
    781760        struct snd_card *card;
    782761        int err;
    783762
    784         err = snd_interwave_card_new(dev, &card);
     763        err = snd_interwave_card_new(devptr, dev, &card);
    785764        if (err < 0)
    786765                return err;
    787766
    788         snd_card_set_dev(card, devptr);
    789767        if ((err = snd_interwave_probe(card, dev)) < 0) {
    790768                snd_card_free(card);
     
    795773}
    796774
    797 static int __devinit snd_interwave_isa_match(struct device *pdev,
    798                                              unsigned int dev)
     775static int snd_interwave_isa_match(struct device *pdev,
     776                                   unsigned int dev)
    799777{
    800778        if (!enable[dev])
     
    807785}
    808786
    809 static int __devinit snd_interwave_isa_probe(struct device *pdev,
    810                                              unsigned int dev)
     787static int snd_interwave_isa_probe(struct device *pdev,
     788                                   unsigned int dev)
    811789{
    812790        int err;
    813         static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
    814         static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1};
     791        static const int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
     792        static const int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1};
    815793
    816794        if (irq[dev] == SNDRV_AUTO_IRQ) {
     
    836814                return snd_interwave_isa_probe1(dev, pdev);
    837815        else {
    838                 static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260};
     816                static const long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260};
    839817                int i;
    840818                for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
     
    848826}
    849827
    850 static int __devexit snd_interwave_isa_remove(struct device *devptr, unsigned int dev)
     828static int snd_interwave_isa_remove(struct device *devptr, unsigned int dev)
    851829{
    852830        snd_card_free(dev_get_drvdata(devptr));
    853         dev_set_drvdata(devptr, NULL);
    854831        return 0;
    855832}
     
    858835        .match          = snd_interwave_isa_match,
    859836        .probe          = snd_interwave_isa_probe,
    860         .remove         = __devexit_p(snd_interwave_isa_remove),
     837        .remove         = snd_interwave_isa_remove,
    861838        /* FIXME: suspend,resume */
    862839        .driver         = {
     
    866843
    867844#ifdef CONFIG_PNP
    868 static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard,
    869                                               const struct pnp_card_device_id *pid)
     845static int snd_interwave_pnp_detect(struct pnp_card_link *pcard,
     846                                    const struct pnp_card_device_id *pid)
    870847{
    871848        static int dev;
     
    880857                return -ENODEV;
    881858                               
    882         res = snd_interwave_card_new(dev, &card);
     859        res = snd_interwave_card_new(&pcard->card->dev, dev, &card);
    883860        if (res < 0)
    884861                return res;
     
    888865                return res;
    889866        }
    890         snd_card_set_dev(card, &pcard->card->dev);
    891867        if ((res = snd_interwave_probe(card, dev)) < 0) {
    892868                snd_card_free(card);
     
    898874}
    899875
    900 static void __devexit snd_interwave_pnp_remove(struct pnp_card_link * pcard)
     876static void snd_interwave_pnp_remove(struct pnp_card_link *pcard)
    901877{
    902878        snd_card_free(pnp_get_card_drvdata(pcard));
     
    909885        .id_table = snd_interwave_pnpids,
    910886        .probe = snd_interwave_pnp_detect,
    911         .remove = __devexit_p(snd_interwave_pnp_remove),
     887        .remove = snd_interwave_pnp_remove,
    912888        /* FIXME: suspend,resume */
    913889};
  • GPL/trunk/alsa-kernel/isa/opl3sa2.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for Yamaha OPL3-SA[2,3] soundcards
    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
     
    2611#include <linux/pm.h>
    2712#include <linux/pnp.h>
    28 #include <linux/moduleparam.h>
     13#include <linux/module.h>
     14#include <linux/io.h>
    2915#include <sound/core.h>
    3016#include <sound/wss.h>
     
    3319#include <sound/initval.h>
    3420#include <sound/tlv.h>
    35 
    36 #include <asm/io.h>
    3721
    3822MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
     
    4731static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4832static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    49 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
     33static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    5034#ifdef CONFIG_PNP
    5135#ifndef TARGET_OS2
    52 static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
     36static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
    5337#else
    5438static int isapnp[SNDRV_CARDS] = {1,1,1,1,1,1,1,1};
     
    7559MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard.");
    7660#endif
    77 module_param_array(port, long, NULL, 0444);
     61module_param_hw_array(port, long, ioport, NULL, 0444);
    7862MODULE_PARM_DESC(port, "Port # for OPL3-SA driver.");
    79 module_param_array(sb_port, long, NULL, 0444);
     63module_param_hw_array(sb_port, long, ioport, NULL, 0444);
    8064MODULE_PARM_DESC(sb_port, "SB port # for OPL3-SA driver.");
    81 module_param_array(wss_port, long, NULL, 0444);
     65module_param_hw_array(wss_port, long, ioport, NULL, 0444);
    8266MODULE_PARM_DESC(wss_port, "WSS port # for OPL3-SA driver.");
    83 module_param_array(fm_port, long, NULL, 0444);
     67module_param_hw_array(fm_port, long, ioport, NULL, 0444);
    8468MODULE_PARM_DESC(fm_port, "FM port # for OPL3-SA driver.");
    85 module_param_array(midi_port, long, NULL, 0444);
     69module_param_hw_array(midi_port, long, ioport, NULL, 0444);
    8670MODULE_PARM_DESC(midi_port, "MIDI port # for OPL3-SA driver.");
    87 module_param_array(irq, int, NULL, 0444);
     71module_param_hw_array(irq, int, irq, NULL, 0444);
    8872MODULE_PARM_DESC(irq, "IRQ # for OPL3-SA driver.");
    89 module_param_array(dma1, int, NULL, 0444);
     73module_param_hw_array(dma1, int, dma, NULL, 0444);
    9074MODULE_PARM_DESC(dma1, "DMA1 # for OPL3-SA driver.");
    91 module_param_array(dma2, int, NULL, 0444);
     75module_param_hw_array(dma2, int, dma, NULL, 0444);
    9276MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver.");
    9377module_param_array(opl3sa3_ymode, int, NULL, 0444);
     
    147131#ifdef CONFIG_PNP
    148132
    149 static struct pnp_device_id snd_opl3sa2_pnpbiosids[] = {
     133static const struct pnp_device_id snd_opl3sa2_pnpbiosids[] = {
    150134        { .id = "YMH0021" },
    151135        { .id = "NMX2210" },    /* Gateway Solo 2500 */
     
    155139MODULE_DEVICE_TABLE(pnp, snd_opl3sa2_pnpbiosids);
    156140
    157 static struct pnp_card_device_id snd_opl3sa2_pnpids[] = {
     141static const struct pnp_card_device_id snd_opl3sa2_pnpids[] = {
    158142        /* Yamaha YMF719E-S (Genius Sound Maker 3DX) */
    159143        { .id = "YMH0020", .devs = { { "YMH0021" } } },
     
    226210}
    227211
    228 static int __devinit snd_opl3sa2_detect(struct snd_card *card)
     212static int snd_opl3sa2_detect(struct snd_card *card)
    229213{
    230214        struct snd_opl3sa2 *chip = card->private_data;
     
    478462static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
    479463
    480 static struct snd_kcontrol_new snd_opl3sa2_controls[] = {
     464static const struct snd_kcontrol_new snd_opl3sa2_controls[] = {
    481465OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1),
    482466OPL3SA2_DOUBLE_TLV("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1,
     
    488472};
    489473
    490 static struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = {
     474static const struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = {
    491475OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0),
    492476OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0),
     
    501485}
    502486
    503 static int __devinit snd_opl3sa2_mixer(struct snd_card *card)
     487static int snd_opl3sa2_mixer(struct snd_card *card)
    504488{
    505489        struct snd_opl3sa2 *chip = card->private_data;
     
    601585
    602586#ifdef CONFIG_PNP
    603 static int __devinit snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip,
    604                                      struct pnp_dev *pdev)
     587static int snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip,
     588                           struct pnp_dev *pdev)
    605589{
    606590        if (pnp_activate_dev(pdev) < 0) {
     
    632616}
    633617
    634 static int snd_opl3sa2_card_new(int dev, struct snd_card **cardp)
     618static int snd_opl3sa2_card_new(struct device *pdev, int dev,
     619                                struct snd_card **cardp)
    635620{
    636621        struct snd_card *card;
     
    638623        int err;
    639624
    640         err = snd_card_create(index[dev], id[dev], THIS_MODULE,
    641                               sizeof(struct snd_opl3sa2), &card);
     625        err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
     626                           sizeof(struct snd_opl3sa2), &card);
    642627        if (err < 0)
    643628                return err;
     
    652637}
    653638
    654 static int __devinit snd_opl3sa2_probe(struct snd_card *card, int dev)
     639static int snd_opl3sa2_probe(struct snd_card *card, int dev)
    655640{
    656641        int xirq, xdma1, xdma2;
     
    672657        if (err < 0)
    673658                return err;
    674         err = request_irq(xirq, snd_opl3sa2_interrupt, IRQF_DISABLED,
     659        err = request_irq(xirq, snd_opl3sa2_interrupt, 0,
    675660                          "OPL3-SA2", card);
    676661        if (err) {
     
    679664        }
    680665        chip->irq = xirq;
     666        card->sync_irq = chip->irq;
    681667        err = snd_wss_create(card,
    682668                             wss_port[dev] + 4, -1,
     
    688674        }
    689675        chip->wss = wss;
    690         err = snd_wss_pcm(wss, 0, NULL);
     676        err = snd_wss_pcm(wss, 0);
    691677        if (err < 0)
    692678                return err;
     
    697683        if (err < 0)
    698684                return err;
    699         err = snd_wss_timer(wss, 0, NULL);
     685        err = snd_wss_timer(wss, 0);
    700686        if (err < 0)
    701687                return err;
     
    712698        if (midi_port[dev] >= 0x300 && midi_port[dev] < 0x340) {
    713699                if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2,
    714                                                midi_port[dev], 0,
    715                                                xirq, 0, &chip->rmidi)) < 0)
     700                                               midi_port[dev],
     701                                               MPU401_INFO_IRQ_HOOK, -1,
     702                                               &chip->rmidi)) < 0)
    716703                        return err;
    717704        }
     
    725712
    726713#ifdef CONFIG_PNP
    727 static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev,
    728                                             const struct pnp_device_id *id)
     714static int snd_opl3sa2_pnp_detect(struct pnp_dev *pdev,
     715                                  const struct pnp_device_id *id)
    729716{
    730717        static int dev;
     
    741728                return -ENODEV;
    742729
    743         err = snd_opl3sa2_card_new(dev, &card);
     730        err = snd_opl3sa2_card_new(&pdev->dev, dev, &card);
    744731        if (err < 0)
    745732                return err;
     
    748735                return err;
    749736        }
    750         snd_card_set_dev(card, &pdev->dev);
    751737        if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
    752738                snd_card_free(card);
     
    758744}
    759745
    760 static void __devexit snd_opl3sa2_pnp_remove(struct pnp_dev * pdev)
     746static void snd_opl3sa2_pnp_remove(struct pnp_dev *pdev)
    761747{
    762748        snd_card_free(pnp_get_drvdata(pdev));
    763         pnp_set_drvdata(pdev, NULL);
    764749}
    765750
     
    779764        .id_table = snd_opl3sa2_pnpbiosids,
    780765        .probe = snd_opl3sa2_pnp_detect,
    781         .remove = __devexit_p(snd_opl3sa2_pnp_remove),
     766        .remove = snd_opl3sa2_pnp_remove,
    782767#ifdef CONFIG_PM
    783768        .suspend = snd_opl3sa2_pnp_suspend,
     
    786771};
    787772
    788 static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard,
    789                                              const struct pnp_card_device_id *id)
     773static int snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard,
     774                                   const struct pnp_card_device_id *id)
    790775{
    791776        static int dev;
     
    807792                return -ENODEV;
    808793
    809         err = snd_opl3sa2_card_new(dev, &card);
     794        err = snd_opl3sa2_card_new(&pdev->dev, dev, &card);
    810795        if (err < 0)
    811796                return err;
     
    814799                return err;
    815800        }
    816         snd_card_set_dev(card, &pdev->dev);
    817801        if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
    818802                snd_card_free(card);
     
    824808}
    825809
    826 static void __devexit snd_opl3sa2_pnp_cremove(struct pnp_card_link * pcard)
     810static void snd_opl3sa2_pnp_cremove(struct pnp_card_link *pcard)
    827811{
    828812        snd_card_free(pnp_get_card_drvdata(pcard));
     
    846830        .id_table = snd_opl3sa2_pnpids,
    847831        .probe = snd_opl3sa2_pnp_cdetect,
    848         .remove = __devexit_p(snd_opl3sa2_pnp_cremove),
     832        .remove = snd_opl3sa2_pnp_cremove,
    849833#ifdef CONFIG_PM
    850834        .suspend = snd_opl3sa2_pnp_csuspend,
     
    854838#endif /* CONFIG_PNP */
    855839
    856 static int __devinit snd_opl3sa2_isa_match(struct device *pdev,
    857                                           unsigned int dev)
     840static int snd_opl3sa2_isa_match(struct device *pdev,
     841                                unsigned int dev)
    858842{
    859843        if (!enable[dev])
     
    882866}
    883867
    884 static int __devinit snd_opl3sa2_isa_probe(struct device *pdev,
    885                                           unsigned int dev)
     868static int snd_opl3sa2_isa_probe(struct device *pdev,
     869                                unsigned int dev)
    886870{
    887871        struct snd_card *card;
    888872        int err;
    889873
    890         err = snd_opl3sa2_card_new(dev, &card);
     874        err = snd_opl3sa2_card_new(pdev, dev, &card);
    891875        if (err < 0)
    892876                return err;
    893         snd_card_set_dev(card, pdev);
    894877        if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
    895878                snd_card_free(card);
     
    900883}
    901884
    902 static int __devexit snd_opl3sa2_isa_remove(struct device *devptr,
    903                                             unsigned int dev)
     885static int snd_opl3sa2_isa_remove(struct device *devptr,
     886                                  unsigned int dev)
    904887{
    905888        snd_card_free(dev_get_drvdata(devptr));
    906         dev_set_drvdata(devptr, NULL);
    907889        return 0;
    908890}
     
    926908        .match          = snd_opl3sa2_isa_match,
    927909        .probe          = snd_opl3sa2_isa_probe,
    928         .remove         = __devexit_p(snd_opl3sa2_isa_remove),
     910        .remove         = snd_opl3sa2_isa_remove,
    929911#ifdef CONFIG_PM
    930912        .suspend        = snd_opl3sa2_isa_suspend,
  • GPL/trunk/alsa-kernel/isa/opti9xx/opti92x-ad1848.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23    card-opti92x-ad1848.c - driver for OPTi 82c92x based soundcards.
     
    89    Thanks to Maria Grazia Pollarini, Salvatore Vassallo.
    910
    10     This program is free software; you can redistribute it and/or modify
    11     it under the terms of the GNU General Public License as published by
    12     the Free Software Foundation; either version 2 of the License, or
    13     (at your option) any later version.
    14 
    15     This program is distributed in the hope that it will be useful,
    16     but WITHOUT ANY WARRANTY; without even the implied warranty of
    17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18     GNU General Public License for more details.
    19 
    20     You should have received a copy of the GNU General Public License
    21     along with this program; if not, write to the Free Software
    22     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    2311*/
    2412
     
    2917#include <linux/delay.h>
    3018#include <linux/pnp.h>
    31 #include <linux/moduleparam.h>
    32 #include <asm/io.h>
     19#include <linux/module.h>
     20#include <linux/io.h>
    3321#include <asm/dma.h>
    3422#include <sound/core.h>
     
    4028#include <sound/opl4.h>
    4129#endif
     30#define SNDRV_LEGACY_FIND_FREE_IOPORT
    4231#define SNDRV_LEGACY_FIND_FREE_IRQ
    4332#define SNDRV_LEGACY_FIND_FREE_DMA
     
    6453static int index = SNDRV_DEFAULT_IDX1;  /* Index 0-MAX */
    6554static char *id = SNDRV_DEFAULT_STR1;           /* ID for this card */
    66 //static int enable = SNDRV_DEFAULT_ENABLE1;    /* Enable this card */
     55//static bool enable = SNDRV_DEFAULT_ENABLE1;   /* Enable this card */
    6756#ifdef CONFIG_PNP
    68 static int isapnp = 1;                  /* Enable ISA PnP detection */
     57static bool isapnp = true;                      /* Enable ISA PnP detection */
    6958#endif
    7059static long port = SNDRV_DEFAULT_PORT1;         /* 0x530,0xe80,0xf40,0x604 */
     
    8877MODULE_PARM_DESC(isapnp, "Enable ISA PnP detection for specified soundcard.");
    8978#endif
    90 module_param(port, long, 0444);
     79module_param_hw(port, long, ioport, 0444);
    9180MODULE_PARM_DESC(port, "WSS port # for opti9xx driver.");
    92 module_param(mpu_port, long, 0444);
     81module_param_hw(mpu_port, long, ioport, 0444);
    9382MODULE_PARM_DESC(mpu_port, "MPU-401 port # for opti9xx driver.");
    94 module_param(fm_port, long, 0444);
     83module_param_hw(fm_port, long, ioport, 0444);
    9584MODULE_PARM_DESC(fm_port, "FM port # for opti9xx driver.");
    96 module_param(irq, int, 0444);
     85module_param_hw(irq, int, irq, 0444);
    9786MODULE_PARM_DESC(irq, "WSS irq # for opti9xx driver.");
    98 module_param(mpu_irq, int, 0444);
     87module_param_hw(mpu_irq, int, irq, 0444);
    9988MODULE_PARM_DESC(mpu_irq, "MPU-401 irq # for opti9xx driver.");
    100 module_param(dma1, int, 0444);
     89module_param_hw(dma1, int, dma, 0444);
    10190MODULE_PARM_DESC(dma1, "1st dma # for opti9xx driver.");
    10291#if defined(CS4231) || defined(OPTi93X)
    103 module_param(dma2, int, 0444);
     92module_param_hw(dma2, int, dma, 0444);
    10493MODULE_PARM_DESC(dma2, "2nd dma # for opti9xx driver.");
    10594#endif  /* CS4231 || OPTi93X */
     
    136125#ifdef OPTi93X
    137126        unsigned long mc_indir_index;
    138         unsigned long mc_indir_size;
    139127        struct resource *res_mc_indir;
     128#endif  /* OPTi93X */
    140129        struct snd_wss *codec;
    141 #endif  /* OPTi93X */
    142130        unsigned long pwd_reg;
    143131
     
    152140#ifdef CONFIG_PNP
    153141
    154 static struct pnp_card_device_id snd_opti9xx_pnpids[] = {
     142static const struct pnp_card_device_id snd_opti9xx_pnpids[] = {
    155143#ifndef OPTi93X
    156144        /* OPTi 82C924 */
     
    174162#endif  /* CONFIG_PNP */
    175163
    176 #ifdef OPTi93X
    177 #define DEV_NAME "opti93x"
    178 #else
    179 #define DEV_NAME "opti92x"
    180 #endif
    181 
    182 static char * snd_opti9xx_names[] = {
     164#define DEV_NAME KBUILD_MODNAME
     165
     166static const char * const snd_opti9xx_names[] = {
    183167        "unknown",
    184168        "82C928",       "82C929",
     
    187171};
    188172
    189 
    190 static long __devinit snd_legacy_find_free_ioport(long *port_table, long size)
    191 {
    192         while (*port_table != -1) {
    193                 if (request_region(*port_table, size, "ALSA test")) {
    194                         release_region(*port_table, size);
    195                         return *port_table;
    196                 }
    197                 port_table++;
    198         }
    199         return -1;
    200 }
    201 
    202 static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip,
    203                                       unsigned short hardware)
    204 {
    205         static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
     173static int snd_opti9xx_init(struct snd_opti9xx *chip,
     174                            unsigned short hardware)
     175{
     176        static const int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
    206177
    207178        chip->hardware = hardware;
     
    246217        case OPTi9XX_HW_82C933:
    247218                chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d;
    248                 if (!chip->mc_indir_index) {
     219                if (!chip->mc_indir_index)
    249220                        chip->mc_indir_index = 0xe0e;
    250                         chip->mc_indir_size = 2;
    251                 }
    252221                chip->password = 0xe4;
    253222                chip->pwd_reg = 0;
     
    281250                        break;
    282251                }
     252                fallthrough;
    283253
    284254        case OPTi9XX_HW_82C928:
     
    323293                        break;
    324294                }
     295                fallthrough;
    325296
    326297        case OPTi9XX_HW_82C928:
     
    347318
    348319
    349 #define snd_opti9xx_write_mask(chip, reg, value, mask)  \
    350         snd_opti9xx_write(chip, reg,                    \
    351                 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
    352 
    353 
    354 static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip,
     320static inline void snd_opti9xx_write_mask(struct snd_opti9xx *chip,
     321                unsigned char reg, unsigned char value, unsigned char mask)
     322{
     323        unsigned char oldval = snd_opti9xx_read(chip, reg);
     324
     325        snd_opti9xx_write(chip, reg, (oldval & ~mask) | (value & mask));
     326}
     327
     328static int snd_opti9xx_configure(struct snd_opti9xx *chip,
    355329                                           long port,
    356330                                           int irq, int dma1, int dma2,
     
    370344                /* enable wave audio */
    371345                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02);
     346                fallthrough;
    372347
    373348        case OPTi9XX_HW_82C925:
     
    404379#else   /* OPTi93X */
    405380        case OPTi9XX_HW_82C931:
     381                /* disable 3D sound (set GPIO1 as output, low) */
     382                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(20), 0x04, 0x0c);
     383                fallthrough;
     384
    406385        case OPTi9XX_HW_82C933:
    407386                /*
     
    415394                 */
    416395                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(26), 0x01, 0x01);
    417         case OPTi9XX_HW_82C930: /* FALL THROUGH */
     396                fallthrough;
     397
     398        case OPTi9XX_HW_82C930:
    418399                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x03);
    419400                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0x00, 0xff);
     
    575556static const DECLARE_TLV_DB_SCALE(db_scale_4bit_12db_max, -3300, 300, 0);
    576557
    577 static struct snd_kcontrol_new snd_opti93x_controls[] = {
     558static const struct snd_kcontrol_new snd_opti93x_controls[] = {
    578559WSS_DOUBLE("Master Playback Switch", 0,
    579560                OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
     
    607588};
    608589
    609 static int __devinit snd_opti93x_mixer(struct snd_wss *chip)
     590static int snd_opti93x_mixer(struct snd_wss *chip)
    610591{
    611592        struct snd_card *card;
     
    680661#endif /* OPTi93X */
    681662
    682 static int __devinit snd_opti9xx_read_check(struct snd_opti9xx *chip)
     663static int snd_opti9xx_read_check(struct snd_opti9xx *chip)
    683664{
    684665        unsigned char value;
     
    697678                        return 0;
    698679#else   /* OPTi93X */
    699         chip->res_mc_indir = request_region(chip->mc_indir_index,
    700                                             chip->mc_indir_size,
     680        chip->res_mc_indir = request_region(chip->mc_indir_index, 2,
    701681                                            "OPTi93x MC");
    702682        if (chip->res_mc_indir == NULL)
     
    722702}
    723703
    724 static int __devinit snd_card_opti9xx_detect(struct snd_card *card,
    725                                              struct snd_opti9xx *chip)
     704static int snd_card_opti9xx_detect(struct snd_card *card,
     705                                   struct snd_opti9xx *chip)
    726706{
    727707        int i, err;
     
    747727
    748728#ifdef CONFIG_PNP
    749 static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip,
    750                                           struct pnp_card_link *card,
    751                                           const struct pnp_card_device_id *pid)
     729static int snd_card_opti9xx_pnp(struct snd_opti9xx *chip,
     730                                struct pnp_card_link *card,
     731                                const struct pnp_card_device_id *pid)
    752732{
    753733        struct pnp_dev *pdev;
     
    771751        port = pnp_port_start(pdev, 0) - 4;
    772752        fm_port = pnp_port_start(pdev, 1) + 8;
    773         chip->mc_indir_index = pnp_port_start(pdev, 3) + 2;
    774         chip->mc_indir_size = pnp_port_len(pdev, 3) - 2;
     753        /* adjust mc_indir_index - some cards report it at 0xe?d,
     754           other at 0xe?c but it really is always at 0xe?e */
     755        chip->mc_indir_index = (pnp_port_start(pdev, 3) & ~0xf) | 0xe;
    775756#else
    776757        devmc = pnp_request_card_device(card, pid->devs[2].id, NULL);
     
    831812}
    832813
    833 static int __devinit snd_opti9xx_probe(struct snd_card *card)
    834 {
    835         static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
     814static int snd_opti9xx_probe(struct snd_card *card)
     815{
     816        static const long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
    836817        int error;
    837818        int xdma2;
    838819        struct snd_opti9xx *chip = card->private_data;
    839820        struct snd_wss *codec;
    840 #ifdef CS4231
    841         struct snd_timer *timer;
    842 #endif
    843         struct snd_pcm *pcm;
    844821        struct snd_rawmidi *rmidi;
    845822        struct snd_hwdep *synth;
     
    872849        if (error < 0)
    873850                return error;
    874 #ifdef OPTi93X
    875851        chip->codec = codec;
    876 #endif
    877         error = snd_wss_pcm(codec, 0, &pcm);
     852        error = snd_wss_pcm(codec, 0);
    878853        if (error < 0)
    879854                return error;
     
    887862#endif
    888863#ifdef CS4231
    889         error = snd_wss_timer(codec, 0, &timer);
     864        error = snd_wss_timer(codec, 0);
    890865        if (error < 0)
    891866                return error;
     
    893868#ifdef OPTi93X
    894869        error = request_irq(irq, snd_opti93x_interrupt,
    895                             IRQF_DISABLED, DEV_NAME" - WSS", chip);
     870                            0, DEV_NAME" - WSS", chip);
    896871        if (error < 0) {
    897872                snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", irq);
     
    900875#endif
    901876        chip->irq = irq;
     877        card->sync_irq = chip->irq;
    902878        strcpy(card->driver, chip->name);
    903879        sprintf(card->shortname, "OPTi %s", card->driver);
    904880#if defined(CS4231) || defined(OPTi93X)
    905         sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d",
    906                 card->shortname, pcm->name,
    907                 chip->wss_base + 4, irq, dma1, xdma2);
     881        snprintf(card->longname, sizeof(card->longname),
     882                 "%s, %s at 0x%lx, irq %d, dma %d&%d",
     883                 card->shortname, codec->pcm->name,
     884                 chip->wss_base + 4, irq, dma1, xdma2);
    908885#else
    909         sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d",
    910                 card->shortname, pcm->name, chip->wss_base + 4, irq, dma1);
     886        snprintf(card->longname, sizeof(card->longname),
     887                 "%s, %s at 0x%lx, irq %d, dma %d",
     888                 card->shortname, codec->pcm->name, chip->wss_base + 4, irq,
     889                 dma1);
    911890#endif  /* CS4231 || OPTi93X */
    912891
     
    915894        else {
    916895                error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
    917                                 mpu_port, 0, mpu_irq, IRQF_DISABLED, &rmidi);
     896                                mpu_port, 0, mpu_irq, &rmidi);
    918897                if (error)
    919898                        snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n",
     
    954933}
    955934
    956 static int snd_opti9xx_card_new(struct snd_card **cardp)
     935static int snd_opti9xx_card_new(struct device *pdev, struct snd_card **cardp)
    957936{
    958937        struct snd_card *card;
    959938        int err;
    960939
    961         err = snd_card_create(index, id, THIS_MODULE,
    962                               sizeof(struct snd_opti9xx), &card);
     940        err = snd_card_new(pdev, index, id, THIS_MODULE,
     941                           sizeof(struct snd_opti9xx), &card);
    963942        if (err < 0)
    964943                return err;
     
    968947}
    969948
    970 static int __devinit snd_opti9xx_isa_match(struct device *devptr,
    971                                           unsigned int dev)
     949static int snd_opti9xx_isa_match(struct device *devptr,
     950                                unsigned int dev)
    972951{
    973952#ifdef CONFIG_PNP
     
    980959}
    981960
    982 static int __devinit snd_opti9xx_isa_probe(struct device *devptr,
    983                                           unsigned int dev)
     961static int snd_opti9xx_isa_probe(struct device *devptr,
     962                                unsigned int dev)
    984963{
    985964        struct snd_card *card;
    986965        int error;
    987         static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1};
     966        static const long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1};
    988967#ifdef OPTi93X
    989         static int possible_irqs[] = {5, 9, 10, 11, 7, -1};
     968        static const int possible_irqs[] = {5, 9, 10, 11, 7, -1};
    990969#else
    991         static int possible_irqs[] = {9, 10, 11, 7, -1};
     970        static const int possible_irqs[] = {9, 10, 11, 7, -1};
    992971#endif  /* OPTi93X */
    993         static int possible_mpu_irqs[] = {5, 9, 10, 7, -1};
    994         static int possible_dma1s[] = {3, 1, 0, -1};
     972        static const int possible_mpu_irqs[] = {5, 9, 10, 7, -1};
     973        static const int possible_dma1s[] = {3, 1, 0, -1};
    995974#if defined(CS4231) || defined(OPTi93X)
    996         static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
     975        static const int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
    997976#endif  /* CS4231 || OPTi93X */
    998977
     
    10301009#endif
    10311010
    1032         error = snd_opti9xx_card_new(&card);
     1011        error = snd_opti9xx_card_new(devptr, &card);
    10331012        if (error < 0)
    10341013                return error;
     
    10381017                return error;
    10391018        }
    1040         snd_card_set_dev(card, devptr);
    10411019        if ((error = snd_opti9xx_probe(card)) < 0) {
    10421020                snd_card_free(card);
     
    10471025}
    10481026
    1049 static int __devexit snd_opti9xx_isa_remove(struct device *devptr,
    1050                                             unsigned int dev)
     1027static int snd_opti9xx_isa_remove(struct device *devptr,
     1028                                  unsigned int dev)
    10511029{
    10521030        snd_card_free(dev_get_drvdata(devptr));
    1053         dev_set_drvdata(devptr, NULL);
    10541031        return 0;
    10551032}
     1033
     1034#ifdef CONFIG_PM
     1035static int snd_opti9xx_suspend(struct snd_card *card)
     1036{
     1037        struct snd_opti9xx *chip = card->private_data;
     1038
     1039        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
     1040        chip->codec->suspend(chip->codec);
     1041        return 0;
     1042}
     1043
     1044static int snd_opti9xx_resume(struct snd_card *card)
     1045{
     1046        struct snd_opti9xx *chip = card->private_data;
     1047        int error, xdma2;
     1048#if defined(CS4231) || defined(OPTi93X)
     1049        xdma2 = dma2;
     1050#else
     1051        xdma2 = -1;
     1052#endif
     1053
     1054        error = snd_opti9xx_configure(chip, port, irq, dma1, xdma2,
     1055                                      mpu_port, mpu_irq);
     1056        if (error)
     1057                return error;
     1058        chip->codec->resume(chip->codec);
     1059        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
     1060        return 0;
     1061}
     1062
     1063static int snd_opti9xx_isa_suspend(struct device *dev, unsigned int n,
     1064                                   pm_message_t state)
     1065{
     1066        return snd_opti9xx_suspend(dev_get_drvdata(dev));
     1067}
     1068
     1069static int snd_opti9xx_isa_resume(struct device *dev, unsigned int n)
     1070{
     1071        return snd_opti9xx_resume(dev_get_drvdata(dev));
     1072}
     1073#endif
    10561074
    10571075static struct isa_driver snd_opti9xx_driver = {
    10581076        .match          = snd_opti9xx_isa_match,
    10591077        .probe          = snd_opti9xx_isa_probe,
    1060         .remove         = __devexit_p(snd_opti9xx_isa_remove),
    1061         /* FIXME: suspend/resume */
     1078        .remove         = snd_opti9xx_isa_remove,
     1079#ifdef CONFIG_PM
     1080        .suspend        = snd_opti9xx_isa_suspend,
     1081        .resume         = snd_opti9xx_isa_resume,
     1082#endif
    10621083        .driver         = {
    10631084                .name   = DEV_NAME
     
    10661087
    10671088#ifdef CONFIG_PNP
    1068 static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
    1069                                           const struct pnp_card_device_id *pid)
     1089static int snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
     1090                                const struct pnp_card_device_id *pid)
    10701091{
    10711092        struct snd_card *card;
     
    10771098        if (! isapnp)
    10781099                return -ENODEV;
    1079         error = snd_opti9xx_card_new(&card);
     1100        error = snd_opti9xx_card_new(&pcard->card->dev, &card);
    10801101        if (error < 0)
    10811102                return error;
     
    11081129                return error;
    11091130        }
    1110         snd_card_set_dev(card, &pcard->card->dev);
    11111131        if ((error = snd_opti9xx_probe(card)) < 0) {
    11121132                snd_card_free(card);
     
    11181138}
    11191139
    1120 static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard)
     1140static void snd_opti9xx_pnp_remove(struct pnp_card_link *pcard)
    11211141{
    11221142        snd_card_free(pnp_get_card_drvdata(pcard));
     
    11251145}
    11261146
     1147#ifdef CONFIG_PM
     1148static int snd_opti9xx_pnp_suspend(struct pnp_card_link *pcard,
     1149                                   pm_message_t state)
     1150{
     1151        return snd_opti9xx_suspend(pnp_get_card_drvdata(pcard));
     1152}
     1153
     1154static int snd_opti9xx_pnp_resume(struct pnp_card_link *pcard)
     1155{
     1156        return snd_opti9xx_resume(pnp_get_card_drvdata(pcard));
     1157}
     1158#endif
     1159
    11271160static struct pnp_card_driver opti9xx_pnpc_driver = {
    11281161        .flags          = PNP_DRIVER_RES_DISABLE,
    1129         .name           = "opti9xx",
     1162        .name           = DEV_NAME,
    11301163        .id_table       = snd_opti9xx_pnpids,
    11311164        .probe          = snd_opti9xx_pnp_probe,
    1132         .remove         = __devexit_p(snd_opti9xx_pnp_remove),
     1165        .remove         = snd_opti9xx_pnp_remove,
     1166#ifdef CONFIG_PM
     1167        .suspend        = snd_opti9xx_pnp_suspend,
     1168        .resume         = snd_opti9xx_pnp_resume,
     1169#endif
    11331170};
    11341171#endif
  • GPL/trunk/alsa-kernel/isa/sb/emu8000.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    56 *
    67 *  Routines for control of EMU8000 chip
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    218 */
    229
    2310#include <linux/wait.h>
    24 #include <linux/sched.h>
     11#include <linux/sched/signal.h>
    2512#include <linux/slab.h>
    2613#include <linux/ioport.h>
     14#include <linux/export.h>
    2715#include <linux/delay.h>
     16#include <linux/io.h>
    2817#include <sound/core.h>
    2918#include <sound/emu8000.h>
    3019#include <sound/emu8000_reg.h>
    31 #include <asm/io.h>
    32 #include <asm/uaccess.h>
     20#include <linux/uaccess.h>
    3321#include <linux/init.h>
    3422#include <sound/control.h>
     
    131119/*
    132120 */
    133 static void __devinit
     121static void
    134122snd_emu8000_read_wait(struct snd_emu8000 *emu)
    135123{
     
    143131/*
    144132 */
    145 static void __devinit
     133static void
    146134snd_emu8000_write_wait(struct snd_emu8000 *emu)
    147135{
     
    156144 * detect a card at the given port
    157145 */
    158 static int __devinit
     146static int
    159147snd_emu8000_detect(struct snd_emu8000 *emu)
    160148{
     
    182170 * intiailize audio channels
    183171 */
    184 static void __devinit
     172static void
    185173init_audio(struct snd_emu8000 *emu)
    186174{
     
    223211 * initialize DMA address
    224212 */
    225 static void __devinit
     213static void
    226214init_dma(struct snd_emu8000 *emu)
    227215{
     
    235223 * initialization arrays; from ADIP
    236224 */
    237 static unsigned short init1[128] /*__devinitdata*/ = {
     225static const unsigned short init1[128] = {
    238226        0x03ff, 0x0030,  0x07ff, 0x0130, 0x0bff, 0x0230,  0x0fff, 0x0330,
    239227        0x13ff, 0x0430,  0x17ff, 0x0530, 0x1bff, 0x0630,  0x1fff, 0x0730,
     
    257245};
    258246
    259 static unsigned short init2[128] /*__devinitdata*/ = {
     247static const unsigned short init2[128] = {
    260248        0x03ff, 0x8030, 0x07ff, 0x8130, 0x0bff, 0x8230, 0x0fff, 0x8330,
    261249        0x13ff, 0x8430, 0x17ff, 0x8530, 0x1bff, 0x8630, 0x1fff, 0x8730,
     
    279267};
    280268
    281 static unsigned short init3[128] /*__devinitdata*/ = {
     269static const unsigned short init3[128] = {
    282270        0x0C10, 0x8470, 0x14FE, 0xB488, 0x167F, 0xA470, 0x18E7, 0x84B5,
    283271        0x1B6E, 0x842A, 0x1F1D, 0x852A, 0x0DA3, 0x8F7C, 0x167E, 0xF254,
     
    301289};
    302290
    303 static unsigned short init4[128] /*__devinitdata*/ = {
     291static const unsigned short init4[128] = {
    304292        0x0C10, 0x8470, 0x14FE, 0xB488, 0x167F, 0xA470, 0x18E7, 0x84B5,
    305293        0x1B6E, 0x842A, 0x1F1D, 0x852A, 0x0DA3, 0x0F7C, 0x167E, 0x7254,
     
    327315 * is meant to work
    328316 */
    329 static void __devinit
    330 send_array(struct snd_emu8000 *emu, unsigned short *data, int size)
     317static void
     318send_array(struct snd_emu8000 *emu, const unsigned short *data, int size)
    331319{
    332320        int i;
    333         unsigned short *p;
     321        const unsigned short *p;
    334322
    335323        p = data;
     
    349337 * initialisation sequence in the adip.
    350338 */
    351 static void __devinit
     339static void
    352340init_arrays(struct snd_emu8000 *emu)
    353341{
     
    371359/*
    372360 * Size the onboard memory.
    373  * This is written so as not to need arbitary delays after the write. It
     361 * This is written so as not to need arbitrary delays after the write. It
    374362 * seems that the only way to do this is to use the one channel and keep
    375363 * reallocating between read and write.
    376364 */
    377 static void __devinit
     365static void
    378366size_dram(struct snd_emu8000 *emu)
    379367{
    380         int i, size, detected_size;
     368        int i, size;
    381369
    382370        if (emu->dram_checked)
     
    384372
    385373        size = 0;
    386         detected_size = 0;
    387374
    388375        /* write out a magic number */
     
    392379        EMU8000_SMLD_WRITE(emu, UNIQUE_ID1);
    393380        snd_emu8000_init_fm(emu); /* This must really be here and not 2 lines back even */
    394 
    395         while (size < EMU8000_MAX_DRAM) {
    396 
    397                 size += 512 * 1024;  /* increment 512kbytes */
     381        snd_emu8000_write_wait(emu);
     382
     383        /*
     384         * Detect first 512 KiB.  If a write succeeds at the beginning of a
     385         * 512 KiB page we assume that the whole page is there.
     386         */
     387        EMU8000_SMALR_WRITE(emu, EMU8000_DRAM_OFFSET);
     388        EMU8000_SMLD_READ(emu); /* discard stale data  */
     389        if (EMU8000_SMLD_READ(emu) != UNIQUE_ID1)
     390                goto skip_detect;   /* No RAM */
     391        snd_emu8000_read_wait(emu);
     392
     393        for (size = 512 * 1024; size < EMU8000_MAX_DRAM; size += 512 * 1024) {
    398394
    399395                /* Write a unique data on the test address.
     
    417413                if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2)
    418414                        break; /* no memory at this address */
    419 
    420                 detected_size = size;
    421 
    422415                snd_emu8000_read_wait(emu);
    423416
     
    432425                        break; /* we must have wrapped around */
    433426                snd_emu8000_read_wait(emu);
    434         }
    435 
     427
     428                /* Otherwise, it's valid memory. */
     429        }
     430
     431skip_detect:
    436432        /* wait until FULL bit in SMAxW register is false */
    437433        for (i = 0; i < 10000; i++) {
     
    445441        snd_emu8000_dma_chan(emu, 1, EMU8000_RAM_CLOSE);
    446442
    447         snd_printdd("EMU8000 [0x%lx]: %d Kb on-board memory detected\n",
    448                     emu->port1, detected_size/1024);
    449 
    450         emu->mem_size = detected_size;
     443        pr_info("EMU8000 [0x%lx]: %d KiB on-board DRAM detected\n",
     444                    emu->port1, size/1024);
     445
     446        emu->mem_size = size;
    451447        emu->dram_checked = 1;
    452448}
     
    503499 * The main initialization routine.
    504500 */
    505 static void __devinit
     501static void
    506502snd_emu8000_init_hw(struct snd_emu8000 *emu)
    507503{
     
    553549 *----------------------------------------------------------------*/
    554550
    555 static unsigned short bass_parm[12][3] = {
     551static const unsigned short bass_parm[12][3] = {
    556552        {0xD26A, 0xD36A, 0x0000}, /* -12 dB */
    557553        {0xD25B, 0xD35B, 0x0000}, /*  -8 */
     
    568564};
    569565
    570 static unsigned short treble_parm[12][9] = {
     566static const unsigned short treble_parm[12][9] = {
    571567        {0x821E, 0xC26A, 0x031E, 0xC36A, 0x021E, 0xD208, 0x831E, 0xD308, 0x0001}, /* -12 dB */
    572568        {0x821E, 0xC25B, 0x031E, 0xC35B, 0x021E, 0xD208, 0x831E, 0xD308, 0x0001},
     
    860856}
    861857
    862 static struct snd_kcontrol_new mixer_bass_control =
     858static const struct snd_kcontrol_new mixer_bass_control =
    863859{
    864860        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    870866};
    871867
    872 static struct snd_kcontrol_new mixer_treble_control =
     868static const struct snd_kcontrol_new mixer_treble_control =
    873869{
    874870        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    927923}
    928924
    929 static struct snd_kcontrol_new mixer_chorus_mode_control =
     925static const struct snd_kcontrol_new mixer_chorus_mode_control =
    930926{
    931927        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    937933};
    938934
    939 static struct snd_kcontrol_new mixer_reverb_mode_control =
     935static const struct snd_kcontrol_new mixer_reverb_mode_control =
    940936{
    941937        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    989985}
    990986
    991 static struct snd_kcontrol_new mixer_fm_chorus_depth_control =
     987static const struct snd_kcontrol_new mixer_fm_chorus_depth_control =
    992988{
    993989        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    999995};
    1000996
    1001 static struct snd_kcontrol_new mixer_fm_reverb_depth_control =
     997static const struct snd_kcontrol_new mixer_fm_reverb_depth_control =
    1002998{
    1003999        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    10101006
    10111007
    1012 static struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = {
     1008static const struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = {
    10131009        &mixer_bass_control,
    10141010        &mixer_treble_control,
     
    10221018 * create and attach mixer elements for WaveTable treble/bass controls
    10231019 */
    1024 static int __devinit
     1020static int
    10251021snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu)
    10261022{
     
    10731069 * initialize and register emu8000 synth device.
    10741070 */
    1075 int __devinit
     1071int
    10761072snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports,
    10771073                struct snd_seq_device **awe_ret)
     
    10801076        struct snd_emu8000 *hw;
    10811077        int err;
    1082         static struct snd_device_ops ops = {
     1078        static const struct snd_device_ops ops = {
    10831079                .dev_free = snd_emu8000_dev_free,
    10841080        };
     
    11301126                return err;
    11311127        }
    1132 #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
     1128#if IS_ENABLED(CONFIG_SND_SEQUENCER)
    11331129        if (snd_seq_device_new(card, index, SNDRV_SEQ_DEV_ID_EMU8000,
    11341130                               sizeof(struct snd_emu8000*), &awe) >= 0) {
  • GPL/trunk/alsa-kernel/isa/sb/emu8000_callback.c

    r305 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  synth callback routines for the emu8000 (AWE32/64)
     
    45 *  Copyright (C) 1999 Steve Ratcliffe
    56 *  Copyright (C) 1999-2000 Takashi Iwai <tiwai@suse.de>
    6  *
    7  *   This program is free software; you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation; either version 2 of the License, or
    10  *   (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    207 */
    218
    229#include "emu8000_local.h"
     10#include <linux/export.h>
    2311#include <sound/asoundef.h>
    2412
     
    3624static void sysex(struct snd_emux *emu, char *buf, int len, int parsed,
    3725                  struct snd_midi_channel_set *chset);
    38 #ifdef CONFIG_SND_SEQUENCER_OSS
     26#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
    3927static int oss_ioctl(struct snd_emux *emu, int cmd, int p1, int p2);
    4028#endif
     
    6250 * set up operators
    6351 */
    64 static struct snd_emux_operators emu8000_ops = {
     52static const struct snd_emux_operators emu8000_ops = {
    6553        .owner =        THIS_MODULE,
    6654        .get_voice =    get_voice,
     
    7664        .load_fx =      load_fx,
    7765        .sysex =        sysex,
    78 #ifdef CONFIG_SND_SEQUENCER_OSS
     66#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
    7967        .oss_ioctl =    oss_ioctl,
    8068#endif
     
    175163
    176164        for (i = 0; i < END; i++) {
    177                 best[i].time = (unsigned int)(-1); /* XXX MAX_?INT really */;
     165                best[i].time = (unsigned int)(-1); /* XXX MAX_?INT really */
    178166                best[i].voice = -1;
    179167        }
     
    477465
    478466
    479 #ifdef CONFIG_SND_SEQUENCER_OSS
     467#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
    480468/*
    481469 * OSS ioctl callback
  • GPL/trunk/alsa-kernel/isa/sb/emu8000_local.h

    r305 r679  
     1/* SPDX-License-Identifier: GPL-2.0-or-later */
    12#ifndef __EMU8000_LOCAL_H
    23#define __EMU8000_LOCAL_H
     
    67 *  Copyright (C) 1999 Steve Ratcliffe
    78 *  Copyright (C) 1999-2000 Takashi Iwai <tiwai@suse.de>
    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
    229 */
    2310
  • GPL/trunk/alsa-kernel/isa/sb/emu8000_patch.c

    r399 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Patch routines for the emu8000 (AWE32/64)
     
    45 *  Copyright (C) 1999 Steve Ratcliffe
    56 *  Copyright (C) 1999-2000 Takashi Iwai <tiwai@suse.de>
    6  *
    7  *   This program is free software; you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation; either version 2 of the License, or
    10  *   (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    207 */
    218
    229#include "emu8000_local.h"
    23 #include <asm/uaccess.h>
     10
     11#include <linux/sched/signal.h>
     12#include <linux/uaccess.h>
    2413#include <linux/moduleparam.h>
    2514
     
    164153
    165154        /* be sure loop points start < end */
    166         if (sp->v.loopstart > sp->v.loopend) {
    167                 int tmp = sp->v.loopstart;
    168                 sp->v.loopstart = sp->v.loopend;
    169                 sp->v.loopend = tmp;
    170         }
     155        if (sp->v.loopstart > sp->v.loopend)
     156                swap(sp->v.loopstart, sp->v.loopend);
    171157
    172158        /* compute true data size to be loaded */
     
    185171
    186172        if (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS) {
    187                 if (!access_ok(VERIFY_READ, data, sp->v.size))
     173                if (!access_ok(data, sp->v.size))
    188174                        return -EFAULT;
    189175        } else {
    190                 if (!access_ok(VERIFY_READ, data, sp->v.size * 2))
     176                if (!access_ok(data, sp->v.size * 2))
    191177                        return -EFAULT;
    192178        }
  • GPL/trunk/alsa-kernel/isa/sb/emu8000_synth.c

    r305 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    56 *
    67 *  Emu8000 synth plug-in routine
    7  *
    8  *   This program is free software; you can redistribute it and/or modify
    9  *   it under the terms of the GNU General Public License as published by
    10  *   the Free Software Foundation; either version 2 of the License, or
    11  *   (at your option) any later version.
    12  *
    13  *   This program is distributed in the hope that it will be useful,
    14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  *   GNU General Public License for more details.
    17  *
    18  *   You should have received a copy of the GNU General Public License
    19  *   along with this program; if not, write to the Free Software
    20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    218 */
    229
    2310#include "emu8000_local.h"
    2411#include <linux/init.h>
     12#include <linux/module.h>
    2513#include <sound/initval.h>
    2614
     
    3422 * create a new hardware dependent device for Emu8000
    3523 */
    36 static int snd_emu8000_new_device(struct snd_seq_device *dev)
     24static int snd_emu8000_probe(struct device *_dev)
    3725{
     26        struct snd_seq_device *dev = to_seq_dev(_dev);
    3827        struct snd_emu8000 *hw;
    3928        struct snd_emux *emu;
     
    9382 * free all resources
    9483 */
    95 static int snd_emu8000_delete_device(struct snd_seq_device *dev)
     84static int snd_emu8000_remove(struct device *_dev)
    9685{
     86        struct snd_seq_device *dev = to_seq_dev(_dev);
    9787        struct snd_emu8000 *hw;
    9888
     
    10393        if (hw->pcm)
    10494                snd_device_free(dev->card, hw->pcm);
    105         if (hw->emu)
    106                 snd_emux_free(hw->emu);
    107         if (hw->memhdr)
    108                 snd_util_memhdr_free(hw->memhdr);
     95        snd_emux_free(hw->emu);
     96        snd_util_memhdr_free(hw->memhdr);
    10997        hw->emu = NULL;
    11098        hw->memhdr = NULL;
     
    116104 */
    117105
    118 static int __init alsa_emu8000_init(void)
    119 {
    120        
    121         static struct snd_seq_dev_ops ops = {
    122                 snd_emu8000_new_device,
    123                 snd_emu8000_delete_device,
    124         };
    125         return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU8000, &ops,
    126                                               sizeof(struct snd_emu8000*));
    127 }
     106static struct snd_seq_driver emu8000_driver = {
     107        .driver = {
     108                .name = KBUILD_MODNAME,
     109                .probe = snd_emu8000_probe,
     110                .remove = snd_emu8000_remove,
     111        },
     112        .id = SNDRV_SEQ_DEV_ID_EMU8000,
     113        .argsize = sizeof(struct snd_emu8000 *),
     114};
    128115
    129 static void __exit alsa_emu8000_exit(void)
    130 {
    131         snd_seq_device_unregister_driver(SNDRV_SEQ_DEV_ID_EMU8000);
    132 }
    133 
    134 module_init(alsa_emu8000_init)
    135 module_exit(alsa_emu8000_exit)
     116module_snd_seq_driver(emu8000_driver);
  • GPL/trunk/alsa-kernel/isa/sb/sb16.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for SoundBlaster 16/AWE32/AWE64 soundcards
    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
     
    2510#include <linux/err.h>
    2611#include <linux/isa.h>
    27 #include <linux/moduleparam.h>
     12#include <linux/module.h>
    2813#include <sound/core.h>
    2914#include <sound/sb.h>
     
    6348#endif
    6449
    65 #if defined(SNDRV_SBAWE) && (defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)))
     50#if defined(SNDRV_SBAWE) && IS_ENABLED(CONFIG_SND_SEQUENCER)
    6651#define SNDRV_SBAWE_EMU8000
    6752#endif
     
    6954static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    7055static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    71 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    72 #ifdef CONFIG_PNP
    73 static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
     56static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
     57#ifdef CONFIG_PNP
     58static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
    7459#endif
    7560static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x240,0x260,0x280 */
     
    10085MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard.");
    10186#endif
    102 module_param_array(port, long, NULL, 0444);
     87module_param_hw_array(port, long, ioport, NULL, 0444);
    10388MODULE_PARM_DESC(port, "Port # for SB16 driver.");
    104 module_param_array(mpu_port, long, NULL, 0444);
     89module_param_hw_array(mpu_port, long, ioport, NULL, 0444);
    10590MODULE_PARM_DESC(mpu_port, "MPU-401 port # for SB16 driver.");
    106 module_param_array(fm_port, long, NULL, 0444);
     91module_param_hw_array(fm_port, long, ioport, NULL, 0444);
    10792MODULE_PARM_DESC(fm_port, "FM port # for SB16 PnP driver.");
    10893#ifdef SNDRV_SBAWE_EMU8000
    109 module_param_array(awe_port, long, NULL, 0444);
     94module_param_hw_array(awe_port, long, ioport, NULL, 0444);
    11095MODULE_PARM_DESC(awe_port, "AWE port # for SB16 PnP driver.");
    11196#endif
    112 module_param_array(irq, int, NULL, 0444);
     97module_param_hw_array(irq, int, irq, NULL, 0444);
    11398MODULE_PARM_DESC(irq, "IRQ # for SB16 driver.");
    114 module_param_array(dma8, int, NULL, 0444);
     99module_param_hw_array(dma8, int, dma, NULL, 0444);
    115100MODULE_PARM_DESC(dma8, "8-bit DMA # for SB16 driver.");
    116 module_param_array(dma16, int, NULL, 0444);
     101module_param_hw_array(dma16, int, dma, NULL, 0444);
    117102MODULE_PARM_DESC(dma16, "16-bit DMA # for SB16 driver.");
    118103module_param_array(mic_agc, int, NULL, 0444);
     
    146131#ifdef CONFIG_PNP
    147132
    148 static struct pnp_card_device_id snd_sb16_pnpids[] = {
     133static const struct pnp_card_device_id snd_sb16_pnpids[] = {
    149134#ifndef SNDRV_SBAWE
    150135        /* Sound Blaster 16 PnP */
     
    251236#ifdef CONFIG_PNP
    252237
    253 static int __devinit snd_card_sb16_pnp(int dev, struct snd_card_sb16 *acard,
    254                                        struct pnp_card_link *card,
    255                                        const struct pnp_card_device_id *id)
     238static int snd_card_sb16_pnp(int dev, struct snd_card_sb16 *acard,
     239                             struct pnp_card_link *card,
     240                             const struct pnp_card_device_id *id)
    256241{
    257242        struct pnp_dev *pdev;
     
    324309#endif
    325310
    326 static int snd_sb16_card_new(int dev, struct snd_card **cardp)
     311static int snd_sb16_card_new(struct device *devptr, int dev,
     312                             struct snd_card **cardp)
    327313{
    328314        struct snd_card *card;
    329315        int err;
    330316
    331         err = snd_card_create(index[dev], id[dev], THIS_MODULE,
    332                               sizeof(struct snd_card_sb16), &card);
     317        err = snd_card_new(devptr, index[dev], id[dev], THIS_MODULE,
     318                           sizeof(struct snd_card_sb16), &card);
    333319        if (err < 0)
    334320                return err;
     
    338324}
    339325
    340 static int __devinit snd_sb16_probe(struct snd_card *card, int dev)
     326static int snd_sb16_probe(struct snd_card *card, int dev)
    341327{
    342328        int xirq, xdma8, xdma16;
     
    374360                return err;
    375361
    376         if ((err = snd_sb16dsp_pcm(chip, 0, &chip->pcm)) < 0)
     362        if ((err = snd_sb16dsp_pcm(chip, 0)) < 0)
    377363                return err;
    378364
     
    395381        if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) {
    396382                if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB,
    397                                                chip->mpu_port, 0,
    398                                                xirq, 0, &chip->rmidi)) < 0)
     383                                               chip->mpu_port,
     384                                               MPU401_INFO_IRQ_HOOK, -1,
     385                                               &chip->rmidi)) < 0)
    399386                        return err;
    400387                chip->rmidi_callback = snd_mpu401_uart_interrupt;
     
    470457
    471458        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    472         snd_pcm_suspend_all(chip->pcm);
    473459        snd_sbmixer_suspend(chip);
    474460        return 0;
     
    487473#endif
    488474
    489 static int __devinit snd_sb16_isa_probe1(int dev, struct device *pdev)
     475static int snd_sb16_isa_probe1(int dev, struct device *pdev)
    490476{
    491477        struct snd_card_sb16 *acard;
     
    493479        int err;
    494480
    495         err = snd_sb16_card_new(dev, &card);
     481        err = snd_sb16_card_new(pdev, dev, &card);
    496482        if (err < 0)
    497483                return err;
     
    507493#endif
    508494
    509         snd_card_set_dev(card, pdev);
    510495        if ((err = snd_sb16_probe(card, dev)) < 0) {
    511496                snd_card_free(card);
     
    517502
    518503
    519 static int __devinit snd_sb16_isa_match(struct device *pdev, unsigned int dev)
     504static int snd_sb16_isa_match(struct device *pdev, unsigned int dev)
    520505{
    521506        return enable[dev] && !is_isapnp_selected(dev);
    522507}
    523508
    524 static int __devinit snd_sb16_isa_probe(struct device *pdev, unsigned int dev)
     509static int snd_sb16_isa_probe(struct device *pdev, unsigned int dev)
    525510{
    526511        int err;
    527         static int possible_irqs[] = {5, 9, 10, 7, -1};
    528         static int possible_dmas8[] = {1, 3, 0, -1};
    529         static int possible_dmas16[] = {5, 6, 7, -1};
     512        static const int possible_irqs[] = {5, 9, 10, 7, -1};
     513        static const int possible_dmas8[] = {1, 3, 0, -1};
     514        static const int possible_dmas16[] = {5, 6, 7, -1};
    530515
    531516        if (irq[dev] == SNDRV_AUTO_IRQ) {
     
    551536                return snd_sb16_isa_probe1(dev, pdev);
    552537        else {
    553                 static int possible_ports[] = {0x220, 0x240, 0x260, 0x280};
     538                static const int possible_ports[] = {0x220, 0x240, 0x260, 0x280};
    554539                int i;
    555540                for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
     
    563548}
    564549
    565 static int __devexit snd_sb16_isa_remove(struct device *pdev, unsigned int dev)
     550static int snd_sb16_isa_remove(struct device *pdev, unsigned int dev)
    566551{
    567552        snd_card_free(dev_get_drvdata(pdev));
    568         dev_set_drvdata(pdev, NULL);
    569553        return 0;
    570554}
     
    592576        .match          = snd_sb16_isa_match,
    593577        .probe          = snd_sb16_isa_probe,
    594         .remove         = __devexit_p(snd_sb16_isa_remove),
     578        .remove         = snd_sb16_isa_remove,
    595579#ifdef CONFIG_PM
    596580        .suspend        = snd_sb16_isa_suspend,
     
    604588
    605589#ifdef CONFIG_PNP
    606 static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard,
    607                                         const struct pnp_card_device_id *pid)
     590static int snd_sb16_pnp_detect(struct pnp_card_link *pcard,
     591                              const struct pnp_card_device_id *pid)
    608592{
    609593        static int dev;
     
    614598                if (!enable[dev] || !isapnp[dev])
    615599                        continue;
    616                 res = snd_sb16_card_new(dev, &card);
     600                res = snd_sb16_card_new(&pcard->card->dev, dev, &card);
    617601                if (res < 0)
    618602                        return res;
    619                 snd_card_set_dev(card, &pcard->card->dev);
    620603                if ((res = snd_card_sb16_pnp(dev, card->private_data, pcard, pid)) < 0 ||
    621604                    (res = snd_sb16_probe(card, dev)) < 0) {
     
    631614}
    632615
    633 static void __devexit snd_sb16_pnp_remove(struct pnp_card_link * pcard)
     616static void snd_sb16_pnp_remove(struct pnp_card_link *pcard)
    634617{
    635618        snd_card_free(pnp_get_card_drvdata(pcard));
     
    657640        .id_table = snd_sb16_pnpids,
    658641        .probe = snd_sb16_pnp_detect,
    659         .remove = __devexit_p(snd_sb16_pnp_remove),
     642        .remove = snd_sb16_pnp_remove,
    660643#ifdef CONFIG_PM
    661644        .suspend = snd_sb16_pnp_suspend,
  • GPL/trunk/alsa-kernel/isa/sb/sb16_csp.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) 1999 by Uros Bizjak <uros@kss-loka.si>
     
    67 *
    78 *  CSP microcode loader:
    8  *   alsa-tools/sb16_csp/
    9  *
    10  *   This program is free software; you can redistribute it and/or modify
    11  *   it under the terms of the GNU General Public License as published by
    12  *   the Free Software Foundation; either version 2 of the License, or
    13  *   (at your option) any later version.
    14  *
    15  *   This program is distributed in the hope that it will be useful,
    16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  *   GNU General Public License for more details.
    19  *
    20  *   You should have received a copy of the GNU General Public License
    21  *   along with this program; if not, write to the Free Software
    22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    23  *
     9 *   alsa-tools/sb16_csp/
    2410 */
    2511
     
    2713#include <linux/init.h>
    2814#include <linux/slab.h>
     15#include <linux/module.h>
    2916#include <sound/core.h>
    3017#include <sound/control.h>
     
    6148 */
    6249struct riff_header {
    63         __u32 name;
    64         __u32 len;
     50        __le32 name;
     51        __le32 len;
    6552};
    6653
    6754struct desc_header {
    6855        struct riff_header info;
    69         __u16 func_nr;
    70         __u16 VOC_type;
    71         __u16 flags_play_rec;
    72         __u16 flags_16bit_8bit;
    73         __u16 flags_stereo_mono;
    74         __u16 flags_rates;
     56        __le16 func_nr;
     57        __le16 VOC_type;
     58        __le16 flags_play_rec;
     59        __le16 flags_16bit_8bit;
     60        __le16 flags_stereo_mono;
     61        __le16 flags_rates;
    7562};
    7663
     
    9481static int snd_sb_csp_unload(struct snd_sb_csp * p);
    9582static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags);
    96 static int snd_sb_csp_autoload(struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode);
     83static int snd_sb_csp_autoload(struct snd_sb_csp * p, snd_pcm_format_t pcm_sfmt, int play_rec_mode);
    9784static int snd_sb_csp_check_version(struct snd_sb_csp * p);
    9885
     
    117104{
    118105        struct snd_sb_csp *p;
    119         int uninitialized_var(version);
     106        int version;
    120107        int err;
    121108        struct snd_hwdep *hw;
     
    209196                /* get information */
    210197        case SNDRV_SB_CSP_IOCTL_INFO:
     198                memset(&info, 0, sizeof(info));
    211199                *info.codec_name = *p->codec_name;
    212200                info.func_nr = p->func_nr;
     
    301289
    302290/*
    303  * load microcode via ioctl:
     291 * load microcode via ioctl: 
    304292 * code is user-space pointer
    305293 */
     
    314302
    315303        struct riff_header file_h, item_h, code_h;
    316         __u32 item_type;
     304        __le32 item_type;
    317305        struct desc_header funcdesc_h;
    318306
     
    326314        if (copy_from_user(&file_h, data_ptr, sizeof(file_h)))
    327315                return -EFAULT;
    328         if ((file_h.name != RIFF_HEADER) ||
     316        if ((le32_to_cpu(file_h.name) != RIFF_HEADER) ||
    329317            (le32_to_cpu(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) {
    330318                snd_printd("%s: Invalid RIFF header\n", __func__);
     
    336324        if (copy_from_user(&item_type, data_ptr, sizeof(item_type)))
    337325                return -EFAULT;
    338         if (item_type != CSP__HEADER) {
     326        if (le32_to_cpu(item_type) != CSP__HEADER) {
    339327                snd_printd("%s: Invalid RIFF file type\n", __func__);
    340328                return -EINVAL;
     
    346334                        return -EFAULT;
    347335                data_ptr += sizeof(item_h);
    348                 if (item_h.name != LIST_HEADER)
     336                if (le32_to_cpu(item_h.name) != LIST_HEADER)
    349337                        continue;
    350338
    351339                if (copy_from_user(&item_type, data_ptr, sizeof(item_type)))
    352340                         return -EFAULT;
    353                 switch (item_type) {
     341                switch (le32_to_cpu(item_type)) {
    354342                case FUNC_HEADER:
    355343                        if (copy_from_user(&funcdesc_h, data_ptr + sizeof(item_type), sizeof(funcdesc_h)))
     
    378366
    379367                                /* init microcode blocks */
    380                                 if (code_h.name != INIT_HEADER)
     368                                if (le32_to_cpu(code_h.name) != INIT_HEADER)
    381369                                        break;
    382370                                data_ptr += sizeof(code_h);
     
    391379                                return -EFAULT;
    392380
    393                         if (code_h.name != MAIN_HEADER) {
     381                        if (le32_to_cpu(code_h.name) != MAIN_HEADER) {
    394382                                snd_printd("%s: Missing 'main' microcode\n", __func__);
    395383                                return -EINVAL;
     
    683671        return result;
    684672}
    685 
     673 
    686674static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags)
    687675{
     
    726714 * return 0 if CSP is loaded and ready to run (p->running != 0)
    727715 */
    728 static int snd_sb_csp_autoload(struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode)
     716static int snd_sb_csp_autoload(struct snd_sb_csp * p, snd_pcm_format_t pcm_sfmt, int play_rec_mode)
    729717{
    730718        unsigned long flags;
     
    732720
    733721        /* if CSP is running or manually loaded then exit */
    734         if (p->running & (SNDRV_SB_CSP_ST_RUNNING | SNDRV_SB_CSP_ST_LOADED))
     722        if (p->running & (SNDRV_SB_CSP_ST_RUNNING | SNDRV_SB_CSP_ST_LOADED)) 
    735723                return -EBUSY;
    736724
    737725        /* autoload microcode only if requested hardware codec is not already loaded */
    738         if (((1 << pcm_sfmt) & p->acc_format) && (play_rec_mode & p->mode)) {
     726        if (((1U << (__force int)pcm_sfmt) & p->acc_format) && (play_rec_mode & p->mode)) {
    739727                p->running = SNDRV_SB_CSP_ST_AUTO;
    740728        } else {
     
    765753                        }
    766754                        p->acc_format = SNDRV_PCM_FMTBIT_IMA_ADPCM;
    767                         break;                         
     755                        break;                           
    768756                default:
    769757                        /* Decouple CSP from IRQ and DMAREQ lines */
     
    789777                        p->acc_channels = SNDRV_SB_CSP_MONO | SNDRV_SB_CSP_STEREO;
    790778                        p->acc_rates = SNDRV_SB_CSP_RATE_ALL;   /* HW codecs accept all rates */
    791                 }
     779                }   
    792780
    793781        }
     
    10291017}
    10301018
    1031 static struct snd_kcontrol_new snd_sb_qsound_switch = {
     1019static const struct snd_kcontrol_new snd_sb_qsound_switch = {
    10321020        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    10331021        .name = "3D Control - Switch",
     
    10371025};
    10381026
    1039 static struct snd_kcontrol_new snd_sb_qsound_space = {
     1027static const struct snd_kcontrol_new snd_sb_qsound_space = {
    10401028        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
    10411029        .name = "3D Control - Space",
     
    11261114{
    11271115        char name[16];
    1128         struct snd_info_entry *entry;
     1116
    11291117        sprintf(name, "cspD%d", device);
    1130         if (! snd_card_proc_new(p->chip->card, name, &entry))
    1131                 snd_info_set_text_ops(entry, p, info_read);
     1118        snd_card_ro_proc_new(p->chip->card, name, p, info_read);
    11321119        return 0;
    11331120}
     
    11851172
    11861173EXPORT_SYMBOL(snd_sb_csp_new);
    1187 
    1188 /*
    1189  * INIT part
    1190  */
    1191 
    1192 static int __init alsa_sb_csp_init(void)
    1193 {
    1194         return 0;
    1195 }
    1196 
    1197 static void __exit alsa_sb_csp_exit(void)
    1198 {
    1199 }
    1200 
    1201 module_init(alsa_sb_csp_init)
    1202 module_exit(alsa_sb_csp_exit)
  • GPL/trunk/alsa-kernel/isa/sb/sb16_main.c

    r399 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    1617 *        to DSP chip (playback) starts. This bug can be avoided with
    1718 *        "16bit DMA Allocation" setting set to Playback or Capture.
    18  *
    19  *
    20  *   This program is free software; you can redistribute it and/or modify
    21  *   it under the terms of the GNU General Public License as published by
    22  *   the Free Software Foundation; either version 2 of the License, or
    23  *   (at your option) any later version.
    24  *
    25  *   This program is distributed in the hope that it will be useful,
    26  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    27  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    28  *   GNU General Public License for more details.
    29  *
    30  *   You should have received a copy of the GNU General Public License
    31  *   along with this program; if not, write to the Free Software
    32  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    33  *
    3419 */
    3520
    36 #include <asm/io.h>
     21#include <linux/io.h>
    3722#include <asm/dma.h>
    3823#include <linux/init.h>
    3924#include <linux/time.h>
     25#include <linux/module.h>
    4026#include <sound/core.h>
    4127#include <sound/sb.h>
     
    4935MODULE_LICENSE("GPL");
    5036
     37#define runtime_format_bits(runtime) \
     38        ((unsigned int)pcm_format_to_bits((runtime)->format))
     39
    5140#ifdef CONFIG_SND_SB16_CSP
    5241static void snd_sb16_csp_playback_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
     
    5847                        /* manually loaded codec */
    5948                        if ((csp->mode & SNDRV_SB_CSP_MODE_DSP_WRITE) &&
    60                             ((1U << runtime->format) == csp->acc_format)) {
     49                            (runtime_format_bits(runtime) == csp->acc_format)) {
    6150                                /* Supported runtime PCM format for playback */
    6251                                if (csp->ops.csp_use(csp) == 0) {
     
    6655                        } else if ((csp->mode & SNDRV_SB_CSP_MODE_QSOUND) && (csp->q_enabled)) {
    6756                                /* QSound decoder is loaded and enabled */
    68                                 if ((1 << runtime->format) & (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |
     57                                if (runtime_format_bits(runtime) & (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |
    6958                                                              SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE)) {
    7059                                        /* Only for simple PCM formats */
     
    10695                        /* manually loaded codec */
    10796                        if ((csp->mode & SNDRV_SB_CSP_MODE_DSP_READ) &&
    108                             ((1U << runtime->format) == csp->acc_format)) {
     97                            (runtime_format_bits(runtime) == csp->acc_format)) {
    10998                                /* Supported runtime PCM format for capture */
    11099                                if (csp->ops.csp_use(csp) == 0) {
     
    244233}
    245234
    246 static int snd_sb16_hw_params(struct snd_pcm_substream *substream,
    247                               struct snd_pcm_hw_params *hw_params)
    248 {
    249         return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
    250 }
    251 
    252 static int snd_sb16_hw_free(struct snd_pcm_substream *substream)
    253 {
    254         snd_pcm_lib_free_pages(substream);
    255         return 0;
    256 }
    257 
    258235static int snd_sb16_playback_prepare(struct snd_pcm_substream *substream)
    259236{
     
    473450 */
    474451
    475 static struct snd_pcm_hardware snd_sb16_playback =
     452static const struct snd_pcm_hardware snd_sb16_playback =
    476453{
    477454        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    491468};
    492469
    493 static struct snd_pcm_hardware snd_sb16_capture =
     470static const struct snd_pcm_hardware snd_sb16_capture =
    494471{
    495472        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    702679static int snd_sb16_dma_control_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    703680{
    704         static char *texts[3] = {
     681        static const char * const texts[3] = {
    705682                "Auto", "Playback", "Capture"
    706683        };
    707684
    708         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    709         uinfo->count = 1;
    710         uinfo->value.enumerated.items = 3;
    711         if (uinfo->value.enumerated.item > 2)
    712                 uinfo->value.enumerated.item = 2;
    713         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
    714         return 0;
     685        return snd_ctl_enum_info(uinfo, 1, 3, texts);
    715686}
    716687
     
    743714}
    744715
    745 static struct snd_kcontrol_new snd_sb16_dma_control = {
     716static const struct snd_kcontrol_new snd_sb16_dma_control = {
    746717        .iface = SNDRV_CTL_ELEM_IFACE_CARD,
    747718        .name = "16-bit DMA Allocation",
     
    844815}
    845816
    846 static struct snd_pcm_ops snd_sb16_playback_ops = {
     817static const struct snd_pcm_ops snd_sb16_playback_ops = {
    847818        .open =         snd_sb16_playback_open,
    848819        .close =        snd_sb16_playback_close,
    849         .ioctl =        snd_pcm_lib_ioctl,
    850         .hw_params =    snd_sb16_hw_params,
    851         .hw_free =      snd_sb16_hw_free,
    852820        .prepare =      snd_sb16_playback_prepare,
    853821        .trigger =      snd_sb16_playback_trigger,
     
    855823};
    856824
    857 static struct snd_pcm_ops snd_sb16_capture_ops = {
     825static const struct snd_pcm_ops snd_sb16_capture_ops = {
    858826        .open =         snd_sb16_capture_open,
    859827        .close =        snd_sb16_capture_close,
    860         .ioctl =        snd_pcm_lib_ioctl,
    861         .hw_params =    snd_sb16_hw_params,
    862         .hw_free =      snd_sb16_hw_free,
    863828        .prepare =      snd_sb16_capture_prepare,
    864829        .trigger =      snd_sb16_capture_trigger,
     
    866831};
    867832
    868 int snd_sb16dsp_pcm(struct snd_sb * chip, int device, struct snd_pcm ** rpcm)
     833int snd_sb16dsp_pcm(struct snd_sb *chip, int device)
    869834{
    870835        struct snd_card *card = chip->card;
     
    872837        int err;
    873838
    874         if (rpcm)
    875                 *rpcm = NULL;
    876839        if ((err = snd_pcm_new(card, "SB16 DSP", device, 1, 1, &pcm)) < 0)
    877840                return err;
     
    879842        pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
    880843        pcm->private_data = chip;
     844        chip->pcm = pcm;
    881845
    882846        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb16_playback_ops);
    883847        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb16_capture_ops);
    884848
    885         if (chip->dma16 >= 0 && chip->dma8 != chip->dma16)
    886                 snd_ctl_add(card, snd_ctl_new1(&snd_sb16_dma_control, chip));
    887         else
     849        if (chip->dma16 >= 0 && chip->dma8 != chip->dma16) {
     850                err = snd_ctl_add(card, snd_ctl_new1(
     851                                        &snd_sb16_dma_control, chip));
     852                if (err)
     853                        return err;
     854        } else {
    888855                pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
    889 
    890         snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    891                                               snd_dma_isa_data(),
    892                                               64*1024, 128*1024);
    893 
    894         if (rpcm)
    895                 *rpcm = pcm;
     856        }
     857
     858        snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
     859                                       card->dev, 64*1024, 128*1024);
    896860        return 0;
    897861}
     
    907871EXPORT_SYMBOL(snd_sb16dsp_configure);
    908872EXPORT_SYMBOL(snd_sb16dsp_interrupt);
    909 
    910 /*
    911  *  INIT part
    912  */
    913 
    914 static int __init alsa_sb16_init(void)
    915 {
    916         return 0;
    917 }
    918 
    919 static void __exit alsa_sb16_exit(void)
    920 {
    921 }
    922 
    923 module_init(alsa_sb16_init)
    924 module_exit(alsa_sb16_exit)
  • GPL/trunk/alsa-kernel/isa/sb/sb8.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for SoundBlaster 1.0/2.0/Pro soundcards and compatible
    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
     
    249#include <linux/isa.h>
    2510#include <linux/ioport.h>
    26 #include <linux/moduleparam.h>
     11#include <linux/module.h>
    2712#include <sound/core.h>
    2813#include <sound/sb.h>
     
    3722static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    3823static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    39 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;  /* Enable this card */
     24static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
    4025static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x240,0x260 */
    4126static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;        /* 5,7,9,10 */
     
    4833module_param_array(enable, bool, NULL, 0444);
    4934MODULE_PARM_DESC(enable, "Enable Sound Blaster soundcard.");
    50 module_param_array(port, long, NULL, 0444);
     35module_param_hw_array(port, long, ioport, NULL, 0444);
    5136MODULE_PARM_DESC(port, "Port # for SB8 driver.");
    52 module_param_array(irq, int, NULL, 0444);
     37module_param_hw_array(irq, int, irq, NULL, 0444);
    5338MODULE_PARM_DESC(irq, "IRQ # for SB8 driver.");
    54 module_param_array(dma8, int, NULL, 0444);
     39module_param_hw_array(dma8, int, dma, NULL, 0444);
    5540MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver.");
    5641
     
    8065}
    8166
    82 static int __devinit snd_sb8_match(struct device *pdev, unsigned int dev)
     67static int snd_sb8_match(struct device *pdev, unsigned int dev)
    8368{
    8469        if (!enable[dev])
     
    9580}
    9681
    97 static int __devinit snd_sb8_probe(struct device *pdev, unsigned int dev)
     82static int snd_sb8_probe(struct device *pdev, unsigned int dev)
    9883{
    9984        struct snd_sb *chip;
     
    10388        int err;
    10489
    105         err = snd_card_create(index[dev], id[dev], THIS_MODULE,
    106                               sizeof(struct snd_sb8), &card);
     90        err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
     91                           sizeof(struct snd_sb8), &card);
    10792        if (err < 0)
    10893                return err;
     
    11297        /* block the 0x388 port to avoid PnP conflicts */
    11398        acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
     99        if (!acard->fm_res) {
     100                err = -EBUSY;
     101                goto _err;
     102        }
    114103
    115104        if (port[dev] != SNDRV_AUTO_PORT) {
     
    123112        } else {
    124113                /* auto-probe legacy ports */
    125                 static unsigned long possible_ports[] = {
     114                static const unsigned long possible_ports[] = {
    126115                        0x220, 0x240, 0x260,
    127116                };
     
    158147        }
    159148
    160         if ((err = snd_sb8dsp_pcm(chip, 0, NULL)) < 0)
     149        if ((err = snd_sb8dsp_pcm(chip, 0)) < 0)
    161150                goto _err;
    162151
     
    183172        }
    184173
    185         if ((err = snd_sb8dsp_midi(chip, 0, NULL)) < 0)
     174        if ((err = snd_sb8dsp_midi(chip, 0)) < 0)
    186175                goto _err;
    187176
     
    193182                irq[dev], dma8[dev]);
    194183
    195         snd_card_set_dev(card, pdev);
    196 
    197184        if ((err = snd_card_register(card)) < 0)
    198185                goto _err;
     
    206193}
    207194
    208 static int __devexit snd_sb8_remove(struct device *pdev, unsigned int dev)
     195static int snd_sb8_remove(struct device *pdev, unsigned int dev)
    209196{
    210197        snd_card_free(dev_get_drvdata(pdev));
    211         dev_set_drvdata(pdev, NULL);
    212198        return 0;
    213199}
     
    222208
    223209        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    224         snd_pcm_suspend_all(chip->pcm);
    225210        snd_sbmixer_suspend(chip);
    226211        return 0;
     
    245230        .match          = snd_sb8_match,
    246231        .probe          = snd_sb8_probe,
    247         .remove         = __devexit_p(snd_sb8_remove),
     232        .remove         = snd_sb8_remove,
    248233#ifdef CONFIG_PM
    249234        .suspend        = snd_sb8_suspend,
     
    255240};
    256241
    257 static int __init alsa_card_sb8_init(void)
    258 {
    259         return isa_register_driver(&snd_sb8_driver, SNDRV_CARDS);
    260 }
    261 
    262 static void __exit alsa_card_sb8_exit(void)
    263 {
    264         isa_unregister_driver(&snd_sb8_driver);
    265 }
    266 
    267 module_init(alsa_card_sb8_init)
    268 module_exit(alsa_card_sb8_exit)
     242module_isa_driver(snd_sb8_driver, SNDRV_CARDS);
  • GPL/trunk/alsa-kernel/isa/sb/sb8_main.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    56 *  Routines for control of 8-bit SoundBlaster cards and clones
    67 *  Please note: I don't have access to old SB8 soundcards.
    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
    228 *
    239 * --
     
    3117 */
    3218
    33 #include <asm/io.h>
     19#include <linux/io.h>
    3420#include <asm/dma.h>
    3521#include <linux/init.h>
    3622#include <linux/time.h>
     23#include <linux/module.h>
    3724#include <sound/core.h>
    3825#include <sound/sb.h>
     
    4633#define SB8_RATE(v)     (SB8_CLOCK / SB8_DEN(v))
    4734
    48 static struct snd_ratnum clock = {
     35static const struct snd_ratnum clock = {
    4936        .num = SB8_CLOCK,
    5037        .den_min = 1,
     
    5340};
    5441
    55 static struct snd_pcm_hw_constraint_ratnums hw_constraints_clock = {
     42static const struct snd_pcm_hw_constraint_ratnums hw_constraints_clock = {
    5643        .nrats = 1,
    5744        .rats = &clock,
    5845};
    5946
    60 static struct snd_ratnum stereo_clocks[] = {
     47static const struct snd_ratnum stereo_clocks[] = {
    6148        {
    6249                .num = SB8_CLOCK,
     
    130117                        break;
    131118                }
    132                 /* fallthru */
     119                fallthrough;
    133120        case SB_HW_201:
    134121                if (rate > 23000) {
     
    136123                        break;
    137124                }
    138                 /* fallthru */
     125                fallthrough;
    139126        case SB_HW_20:
    140127                chip->playback_format = SB_DSP_LO_OUTPUT_AUTO;
     
    239226}
    240227
    241 static int snd_sb8_hw_params(struct snd_pcm_substream *substream,
    242                              struct snd_pcm_hw_params *hw_params)
    243 {
    244         return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
    245 }
    246 
    247 static int snd_sb8_hw_free(struct snd_pcm_substream *substream)
    248 {
    249         snd_pcm_lib_free_pages(substream);
    250         return 0;
    251 }
    252 
    253228static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream)
    254229{
     
    287262                        break;
    288263                }
    289                 /* fallthru */
     264                fallthrough;
    290265        case SB_HW_20:
    291266                chip->capture_format = SB_DSP_LO_INPUT_AUTO;
     
    381356{
    382357        struct snd_pcm_substream *substream;
    383         struct snd_pcm_runtime *runtime;
    384358
    385359        snd_sb_ack_8bit(chip);
     
    388362                if (chip->hardware != SB_HW_JAZZ16)
    389363                        break;
    390                 /* fallthru */
     364                fallthrough;
    391365        case SB_MODE_PLAYBACK_8:
    392366                substream = chip->playback_substream;
    393                 runtime = substream->runtime;
    394367                if (chip->playback_format == SB_DSP_OUTPUT)
    395368                        snd_sb8_playback_trigger(substream, SNDRV_PCM_TRIGGER_START);
     
    399372                if (chip->hardware != SB_HW_JAZZ16)
    400373                        break;
    401                 /* fallthru */
     374                fallthrough;
    402375        case SB_MODE_CAPTURE_8:
    403376                substream = chip->capture_substream;
    404                 runtime = substream->runtime;
    405377                if (chip->capture_format == SB_DSP_INPUT)
    406378                        snd_sb8_capture_trigger(substream, SNDRV_PCM_TRIGGER_START);
     
    447419 */
    448420
    449 static struct snd_pcm_hardware snd_sb8_playback =
     421static const struct snd_pcm_hardware snd_sb8_playback =
    450422{
    451423        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    466438};
    467439
    468 static struct snd_pcm_hardware snd_sb8_capture =
     440static const struct snd_pcm_hardware snd_sb8_capture =
    469441{
    470442        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    572544 */
    573545 
    574 static struct snd_pcm_ops snd_sb8_playback_ops = {
     546static const struct snd_pcm_ops snd_sb8_playback_ops = {
    575547        .open =                 snd_sb8_open,
    576548        .close =                snd_sb8_close,
    577         .ioctl =                snd_pcm_lib_ioctl,
    578         .hw_params =            snd_sb8_hw_params,
    579         .hw_free =              snd_sb8_hw_free,
    580549        .prepare =              snd_sb8_playback_prepare,
    581550        .trigger =              snd_sb8_playback_trigger,
     
    583552};
    584553
    585 static struct snd_pcm_ops snd_sb8_capture_ops = {
     554static const struct snd_pcm_ops snd_sb8_capture_ops = {
    586555        .open =                 snd_sb8_open,
    587556        .close =                snd_sb8_close,
    588         .ioctl =                snd_pcm_lib_ioctl,
    589         .hw_params =            snd_sb8_hw_params,
    590         .hw_free =              snd_sb8_hw_free,
    591557        .prepare =              snd_sb8_capture_prepare,
    592558        .trigger =              snd_sb8_capture_trigger,
     
    594560};
    595561
    596 int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm)
     562int snd_sb8dsp_pcm(struct snd_sb *chip, int device)
    597563{
    598564        struct snd_card *card = chip->card;
     
    601567        size_t max_prealloc = 64 * 1024;
    602568
    603         if (rpcm)
    604                 *rpcm = NULL;
    605569        if ((err = snd_pcm_new(card, "SB8 DSP", device, 1, 1, &pcm)) < 0)
    606570                return err;
     
    614578        if (chip->dma8 > 3 || chip->dma16 >= 0)
    615579                max_prealloc = 128 * 1024;
    616         snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    617                                               snd_dma_isa_data(),
    618                                               64*1024, max_prealloc);
    619 
    620         if (rpcm)
    621                 *rpcm = pcm;
     580        snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
     581                                       card->dev, 64*1024, max_prealloc);
     582
    622583        return 0;
    623584}
     
    628589EXPORT_SYMBOL(snd_sb8dsp_midi_interrupt);
    629590EXPORT_SYMBOL(snd_sb8dsp_midi);
    630 
    631 /*
    632  *  INIT part
    633  */
    634 
    635 static int __init alsa_sb8_init(void)
    636 {
    637         return 0;
    638 }
    639 
    640 static void __exit alsa_sb8_exit(void)
    641 {
    642 }
    643 
    644 module_init(alsa_sb8_init)
    645 module_exit(alsa_sb8_exit)
  • GPL/trunk/alsa-kernel/isa/sb/sb8_midi.c

    r305 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    34 *  Routines for control of SoundBlaster cards - MIDI interface
    4  *
    5  *   This program is free software; you can redistribute it and/or modify
    6  *   it under the terms of the GNU General Public License as published by
    7  *   the Free Software Foundation; either version 2 of the License, or
    8  *   (at your option) any later version.
    9  *
    10  *   This program is distributed in the hope that it will be useful,
    11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  *   GNU General Public License for more details.
    14  *
    15  *   You should have received a copy of the GNU General Public License
    16  *   along with this program; if not, write to the Free Software
    17  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    185 *
    196 * --
     
    2714 */
    2815
    29 #include <asm/io.h>
     16#include <linux/io.h>
    3017#include <linux/time.h>
    3118#include <sound/core.h>
     
    139126
    140127        chip = substream->rmidi->private_data;
     128        del_timer_sync(&chip->midi_timer);
    141129        spin_lock_irqsave(&chip->open_lock, flags);
    142130        chip->open &= ~(SB_OPEN_MIDI_OUTPUT | SB_OPEN_MIDI_OUTPUT_TRIGGER);
     
    210198}
    211199
    212 static void snd_sb8dsp_midi_output_timer(unsigned long data)
    213 {
    214         struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *) data;
    215         struct snd_sb * chip = substream->rmidi->private_data;
    216         unsigned long flags;
    217 
    218         spin_lock_irqsave(&chip->open_lock, flags);
    219         chip->midi_timer.expires = 1 + jiffies;
    220         add_timer(&chip->midi_timer);
     200static void snd_sb8dsp_midi_output_timer(struct timer_list *t)
     201{
     202        struct snd_sb *chip = from_timer(chip, t, midi_timer);
     203        struct snd_rawmidi_substream *substream = chip->midi_substream_output;
     204        unsigned long flags;
     205
     206        spin_lock_irqsave(&chip->open_lock, flags);
     207        mod_timer(&chip->midi_timer, 1 + jiffies);
    221208        spin_unlock_irqrestore(&chip->open_lock, flags);       
    222209        snd_sb8dsp_midi_output_write(substream);
     
    232219        if (up) {
    233220                if (!(chip->open & SB_OPEN_MIDI_OUTPUT_TRIGGER)) {
    234                         init_timer(&chip->midi_timer);
    235                         chip->midi_timer.function = snd_sb8dsp_midi_output_timer;
    236                         chip->midi_timer.data = (unsigned long) substream;
    237                         chip->midi_timer.expires = 1 + jiffies;
    238                         add_timer(&chip->midi_timer);
     221                        mod_timer(&chip->midi_timer, 1 + jiffies);
    239222                        chip->open |= SB_OPEN_MIDI_OUTPUT_TRIGGER;
    240223                }
     
    250233}
    251234
    252 static struct snd_rawmidi_ops snd_sb8dsp_midi_output =
     235static const struct snd_rawmidi_ops snd_sb8dsp_midi_output =
    253236{
    254237        .open =         snd_sb8dsp_midi_output_open,
     
    257240};
    258241
    259 static struct snd_rawmidi_ops snd_sb8dsp_midi_input =
     242static const struct snd_rawmidi_ops snd_sb8dsp_midi_input =
    260243{
    261244        .open =         snd_sb8dsp_midi_input_open,
     
    264247};
    265248
    266 int snd_sb8dsp_midi(struct snd_sb *chip, int device, struct snd_rawmidi ** rrawmidi)
     249int snd_sb8dsp_midi(struct snd_sb *chip, int device)
    267250{
    268251        struct snd_rawmidi *rmidi;
    269252        int err;
    270253
    271         if (rrawmidi)
    272                 *rrawmidi = NULL;
    273254        if ((err = snd_rawmidi_new(chip->card, "SB8 MIDI", device, 1, 1, &rmidi)) < 0)
    274255                return err;
     
    280261                rmidi->info_flags |= SNDRV_RAWMIDI_INFO_DUPLEX;
    281262        rmidi->private_data = chip;
     263        timer_setup(&chip->midi_timer, snd_sb8dsp_midi_output_timer, 0);
    282264        chip->rmidi = rmidi;
    283         if (rrawmidi)
    284                 *rrawmidi = rmidi;
    285         return 0;
    286 }
     265        return 0;
     266}
  • GPL/trunk/alsa-kernel/isa/sb/sb_common.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
     
    45 *
    56 *  Lowlevel routines for control of Sound Blaster cards
    6  *
    7  *   This program is free software; you can redistribute it and/or modify
    8  *   it under the terms of the GNU General Public License as published by
    9  *   the Free Software Foundation; either version 2 of the License, or
    10  *   (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    20  *
    217 */
    228
     
    2612#include <linux/slab.h>
    2713#include <linux/ioport.h>
     14#include <linux/module.h>
     15#include <linux/io.h>
    2816#include <sound/core.h>
    2917#include <sound/sb.h>
    3018#include <sound/initval.h>
    3119
    32 #include <asm/io.h>
    3320#include <asm/dma.h>
    3421
     
    9481static int snd_sbdsp_version(struct snd_sb * chip)
    9582{
    96         unsigned int result = -ENODEV;
     83        unsigned int result;
    9784
    9885        snd_sbdsp_command(chip, SB_DSP_GET_VERSION);
     
    184171static int snd_sbdsp_free(struct snd_sb *chip)
    185172{
    186         if (chip->res_port)
    187                 release_and_free_resource(chip->res_port);
     173        release_and_free_resource(chip->res_port);
    188174        if (chip->irq >= 0)
    189175                free_irq(chip->irq, (void *) chip);
     
    219205        struct snd_sb *chip;
    220206        int err;
    221         static struct snd_device_ops ops = {
     207        static const struct snd_device_ops ops = {
    222208                .dev_free =     snd_sbdsp_dev_free,
    223209        };
     
    241227                        (hardware == SB_HW_ALS4000 ||
    242228                         hardware == SB_HW_CS5530) ?
    243                         IRQF_SHARED : IRQF_DISABLED,
     229                        IRQF_SHARED : 0,
    244230                        "SoundBlaster", (void *) chip)) {
    245231                snd_printk(KERN_ERR "sb: can't grab irq %d\n", irq);
     
    248234        }
    249235        chip->irq = irq;
     236        card->sync_irq = chip->irq;
    250237
    251238        if (hardware == SB_HW_ALS4000)
     
    306293EXPORT_SYMBOL(snd_sbmixer_resume);
    307294#endif
    308 
    309 /*
    310  *  INIT part
    311  */
    312 
    313 static int __init alsa_sb_common_init(void)
    314 {
    315         return 0;
    316 }
    317 
    318 static void __exit alsa_sb_common_exit(void)
    319 {
    320 }
    321 
    322 module_init(alsa_sb_common_init)
    323 module_exit(alsa_sb_common_exit)
  • GPL/trunk/alsa-kernel/isa/sb/sb_mixer.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
    34 *  Routines for Sound Blaster mixer control
    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 
    22 #include <asm/io.h>
     5 */
     6
     7#include <linux/io.h>
    238#include <linux/delay.h>
    249#include <linux/time.h>
     
    183168static int snd_dt019x_input_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    184169{
    185         static const char *texts[5] = {
     170        static const char * const texts[5] = {
    186171                "CD", "Mic", "Line", "Synth", "Master"
    187172        };
    188173
    189         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    190         uinfo->count = 1;
    191         uinfo->value.enumerated.items = 5;
    192         if (uinfo->value.enumerated.item > 4)
    193                 uinfo->value.enumerated.item = 4;
    194         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
    195         return 0;
     174        return snd_ctl_enum_info(uinfo, 1, 5, texts);
    196175}
    197176
     
    276255                                             struct snd_ctl_elem_info *uinfo)
    277256{
    278         static const char *texts[3] = {
     257        static const char * const texts[3] = {
    279258                "L chan only", "R chan only", "L ch/2 + R ch/2"
    280259        };
    281260
    282         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    283         uinfo->count = 1;
    284         uinfo->value.enumerated.items = 3;
    285         if (uinfo->value.enumerated.item > 2)
    286                 uinfo->value.enumerated.item = 2;
    287         strcpy(uinfo->value.enumerated.name,
    288                texts[uinfo->value.enumerated.item]);
    289         return 0;
     261        return snd_ctl_enum_info(uinfo, 1, 3, texts);
    290262}
    291263
     
    336308static int snd_sb8mixer_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    337309{
    338         static const char *texts[3] = {
     310        static const char * const texts[3] = {
    339311                "Mic", "CD", "Line"
    340312        };
    341313
    342         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    343         uinfo->count = 1;
    344         uinfo->value.enumerated.items = 3;
    345         if (uinfo->value.enumerated.item > 2)
    346                 uinfo->value.enumerated.item = 2;
    347         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
    348         return 0;
     314        return snd_ctl_enum_info(uinfo, 1, 3, texts);
    349315}
    350316
     
    473439int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int type, unsigned long value)
    474440{
    475         static struct snd_kcontrol_new newctls[] = {
     441        static const struct snd_kcontrol_new newctls[] = {
    476442                [SB_MIX_SINGLE] = {
    477443                        .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
     
    529495 */
    530496
    531 static struct sbmix_elem snd_sb20_controls[] = {
     497static const struct sbmix_elem snd_sb20_controls[] = {
    532498        SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7),
    533499        SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3),
     
    536502};
    537503
    538 static unsigned char snd_sb20_init_values[][2] = {
     504static const unsigned char snd_sb20_init_values[][2] = {
    539505        { SB_DSP20_MASTER_DEV, 0 },
    540506        { SB_DSP20_FM_DEV, 0 },
     
    544510 * SB Pro specific mixer elements
    545511 */
    546 static struct sbmix_elem snd_sbpro_controls[] = {
     512static const struct sbmix_elem snd_sbpro_controls[] = {
    547513        SB_DOUBLE("Master Playback Volume",
    548514                  SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7),
     
    564530};
    565531
    566 static unsigned char snd_sbpro_init_values[][2] = {
     532static const unsigned char snd_sbpro_init_values[][2] = {
    567533        { SB_DSP_MASTER_DEV, 0 },
    568534        { SB_DSP_PCM_DEV, 0 },
     
    573539 * SB16 specific mixer elements
    574540 */
    575 static struct sbmix_elem snd_sb16_controls[] = {
     541static const struct sbmix_elem snd_sb16_controls[] = {
    576542        SB_DOUBLE("Master Playback Volume",
    577543                  SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31),
     
    611577};
    612578
    613 static unsigned char snd_sb16_init_values[][2] = {
     579static const unsigned char snd_sb16_init_values[][2] = {
    614580        { SB_DSP4_MASTER_DEV + 0, 0 },
    615581        { SB_DSP4_MASTER_DEV + 1, 0 },
     
    627593 * DT019x specific mixer elements
    628594 */
    629 static struct sbmix_elem snd_dt019x_controls[] = {
     595static const struct sbmix_elem snd_dt019x_controls[] = {
    630596        /* ALS4000 below has some parts which we might be lacking,
    631597         * e.g. snd_als4000_ctl_mono_playback_switch - check it! */
     
    657623};
    658624
    659 static unsigned char snd_dt019x_init_values[][2] = {
     625static const unsigned char snd_dt019x_init_values[][2] = {
    660626        { SB_DT019X_MASTER_DEV, 0 },
    661627        { SB_DT019X_PCM_DEV, 0 },
     
    672638 * ALS4000 specific mixer elements
    673639 */
    674 static struct sbmix_elem snd_als4000_controls[] = {
     640static const struct sbmix_elem snd_als4000_controls[] = {
    675641        SB_DOUBLE("PCM Playback Switch",
    676642                  SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1),
     
    706672};
    707673
    708 static unsigned char snd_als4000_init_values[][2] = {
     674static const unsigned char snd_als4000_init_values[][2] = {
    709675        { SB_DSP4_MASTER_DEV + 0, 0 },
    710676        { SB_DSP4_MASTER_DEV + 1, 0 },
     
    724690 */
    725691static int snd_sbmixer_init(struct snd_sb *chip,
    726                             struct sbmix_elem *controls,
     692                            const struct sbmix_elem *controls,
    727693                            int controls_count,
    728                             unsigned char map[][2],
     694                            const unsigned char map[][2],
    729695                            int map_count,
    730696                            char *name)
     
    819785                break;
    820786        case SB_HW_DT019X:
    821                 if ((err = snd_sbmixer_init(chip,
    822                                             snd_dt019x_controls,
    823                                             ARRAY_SIZE(snd_dt019x_controls),
    824                                             snd_dt019x_init_values,
    825                                             ARRAY_SIZE(snd_dt019x_init_values),
    826                                             "DT019X")) < 0)
     787                err = snd_sbmixer_init(chip,
     788                                       snd_dt019x_controls,
     789                                       ARRAY_SIZE(snd_dt019x_controls),
     790                                       snd_dt019x_init_values,
     791                                       ARRAY_SIZE(snd_dt019x_init_values),
     792                                       "DT019X");
     793                if (err < 0)
     794                        return err;
    827795                break;
    828796        default:
     
    833801
    834802#ifdef CONFIG_PM
    835 static unsigned char sb20_saved_regs[] = {
     803static const unsigned char sb20_saved_regs[] = {
    836804        SB_DSP20_MASTER_DEV,
    837805        SB_DSP20_PCM_DEV,
     
    840808};
    841809
    842 static unsigned char sbpro_saved_regs[] = {
     810static const unsigned char sbpro_saved_regs[] = {
    843811        SB_DSP_MASTER_DEV,
    844812        SB_DSP_PCM_DEV,
     
    852820};
    853821
    854 static unsigned char sb16_saved_regs[] = {
     822static const unsigned char sb16_saved_regs[] = {
    855823        SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1,
    856824        SB_DSP4_3DSE,
     
    870838};
    871839
    872 static unsigned char dt019x_saved_regs[] = {
     840static const unsigned char dt019x_saved_regs[] = {
    873841        SB_DT019X_MASTER_DEV,
    874842        SB_DT019X_PCM_DEV,
     
    883851};
    884852
    885 static unsigned char als4000_saved_regs[] = {
     853static const unsigned char als4000_saved_regs[] = {
    886854        /* please verify in dsheet whether regs to be added
    887855           are actually real H/W or just dummy */
     
    905873};
    906874
    907 static void save_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs)
     875static void save_mixer(struct snd_sb *chip, const unsigned char *regs, int num_regs)
    908876{
    909877        unsigned char *val = chip->saved_regs;
     
    914882}
    915883
    916 static void restore_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs)
     884static void restore_mixer(struct snd_sb *chip, const unsigned char *regs, int num_regs)
    917885{
    918886        unsigned char *val = chip->saved_regs;
  • GPL/trunk/alsa-kernel/isa/wavefront/wavefront.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  ALSA card-level driver for Turtle Beach Wavefront cards
     
    45 *
    56 *  Copyright (c) 1997-1999 by Paul Barton-Davis <pbd@op.net>
    6  *
    7  *  This program is free software; you can redistribute it and/or modify
    8  *  it under the terms of the GNU General Public License as published by
    9  *  the Free Software Foundation; either version 2 of the License, or
    10  *  (at your option) any later version.
    11  *
    12  *  This program is distributed in the hope that it will be useful,
    13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *  GNU General Public License for more details.
    16  *
    17  *  You should have received a copy of the GNU General Public License
    18  *  along with this program; if not, write to the Free Software
    19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    207 */
    218
     
    2512#include <linux/isa.h>
    2613#include <linux/pnp.h>
    27 #include <linux/moduleparam.h>
     14#include <linux/module.h>
    2815#include <sound/core.h>
    2916#include <sound/initval.h>
     
    3926static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;          /* Index 0-MAX */
    4027static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;           /* ID for this card */
    41 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;      /* Enable this card */
     28static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;     /* Enable this card */
    4229#ifdef CONFIG_PNP
    43 static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
     30static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
    4431#endif
    4532static long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;  /* PnP setup */
     
    5239static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;           /* 0,1,3,5,6,7 */
    5340static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;           /* 0,1,3,5,6,7 */
    54 static int use_cs4232_midi[SNDRV_CARDS];
     41static bool use_cs4232_midi[SNDRV_CARDS];
    5542
    5643module_param_array(index, int, NULL, 0444);
     
    6451MODULE_PARM_DESC(isapnp, "ISA PnP detection for WaveFront soundcards.");
    6552#endif
    66 module_param_array(cs4232_pcm_port, long, NULL, 0444);
     53module_param_hw_array(cs4232_pcm_port, long, ioport, NULL, 0444);
    6754MODULE_PARM_DESC(cs4232_pcm_port, "Port # for CS4232 PCM interface.");
    68 module_param_array(cs4232_pcm_irq, int, NULL, 0444);
     55module_param_hw_array(cs4232_pcm_irq, int, irq, NULL, 0444);
    6956MODULE_PARM_DESC(cs4232_pcm_irq, "IRQ # for CS4232 PCM interface.");
    70 module_param_array(dma1, int, NULL, 0444);
     57module_param_hw_array(dma1, int, dma, NULL, 0444);
    7158MODULE_PARM_DESC(dma1, "DMA1 # for CS4232 PCM interface.");
    72 module_param_array(dma2, int, NULL, 0444);
     59module_param_hw_array(dma2, int, dma, NULL, 0444);
    7360MODULE_PARM_DESC(dma2, "DMA2 # for CS4232 PCM interface.");
    74 module_param_array(cs4232_mpu_port, long, NULL, 0444);
     61module_param_hw_array(cs4232_mpu_port, long, ioport, NULL, 0444);
    7562MODULE_PARM_DESC(cs4232_mpu_port, "port # for CS4232 MPU-401 interface.");
    76 module_param_array(cs4232_mpu_irq, int, NULL, 0444);
     63module_param_hw_array(cs4232_mpu_irq, int, irq, NULL, 0444);
    7764MODULE_PARM_DESC(cs4232_mpu_irq, "IRQ # for CS4232 MPU-401 interface.");
    78 module_param_array(ics2115_irq, int, NULL, 0444);
     65module_param_hw_array(ics2115_irq, int, irq, NULL, 0444);
    7966MODULE_PARM_DESC(ics2115_irq, "IRQ # for ICS2115.");
    80 module_param_array(ics2115_port, long, NULL, 0444);
     67module_param_hw_array(ics2115_port, long, ioport, NULL, 0444);
    8168MODULE_PARM_DESC(ics2115_port, "Port # for ICS2115.");
    82 module_param_array(fm_port, long, NULL, 0444);
     69module_param_hw_array(fm_port, long, ioport, NULL, 0444);
    8370MODULE_PARM_DESC(fm_port, "FM port #.");
    8471module_param_array(use_cs4232_midi, bool, NULL, 0444);
     
    8976static int pnp_registered;
    9077
    91 static struct pnp_card_device_id snd_wavefront_pnpids[] = {
     78static const struct pnp_card_device_id snd_wavefront_pnpids[] = {
    9279        /* Tropez */
    9380        { .id = "CSC7532", .devs = { { "CSC0000" }, { "CSC0010" }, { "PnPb006" }, { "CSC0004" } } },
     
    9986MODULE_DEVICE_TABLE(pnp_card, snd_wavefront_pnpids);
    10087
    101 static int __devinit
     88static int
    10289snd_wavefront_pnp (int dev, snd_wavefront_card_t *acard, struct pnp_card_link *card,
    10390                   const struct pnp_card_device_id *id)
     
    232219}
    233220
    234 static struct snd_hwdep * __devinit
    235 snd_wavefront_new_synth (struct snd_card *card,
    236                          int hw_dev,
    237                          snd_wavefront_card_t *acard)
     221static struct snd_hwdep *snd_wavefront_new_synth(struct snd_card *card,
     222                                                 int hw_dev,
     223                                                 snd_wavefront_card_t *acard)
    238224{
    239225        struct snd_hwdep *wavefront_synth;
     
    258244}
    259245
    260 static struct snd_hwdep * __devinit
    261 snd_wavefront_new_fx (struct snd_card *card,
    262                       int hw_dev,
    263                       snd_wavefront_card_t *acard,
    264                       unsigned long port)
     246static struct snd_hwdep *snd_wavefront_new_fx(struct snd_card *card,
     247                                              int hw_dev,
     248                                              snd_wavefront_card_t *acard,
     249                                              unsigned long port)
    265250
    266251{
     
    285270static snd_wavefront_mpu_id external_id = external_mpu;
    286271
    287 static struct snd_rawmidi *__devinit
    288 snd_wavefront_new_midi (struct snd_card *card,
    289                         int midi_dev,
    290                         snd_wavefront_card_t *acard,
    291                         unsigned long port,
    292                         snd_wavefront_mpu_id mpu)
     272static struct snd_rawmidi *snd_wavefront_new_midi(struct snd_card *card,
     273                                                  int midi_dev,
     274                                                  snd_wavefront_card_t *acard,
     275                                                  unsigned long port,
     276                                                  snd_wavefront_mpu_id mpu)
    293277
    294278{
     
    338322}
    339323
    340 static int snd_wavefront_card_new(int dev, struct snd_card **cardp)
     324static int snd_wavefront_card_new(struct device *pdev, int dev,
     325                                  struct snd_card **cardp)
    341326{
    342327        struct snd_card *card;
     
    344329        int err;
    345330
    346         err = snd_card_create(index[dev], id[dev], THIS_MODULE,
    347                               sizeof(snd_wavefront_card_t), &card);
     331        err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE,
     332                           sizeof(snd_wavefront_card_t), &card);
    348333        if (err < 0)
    349334                return err;
     
    362347}
    363348
    364 static int __devinit
     349static int
    365350snd_wavefront_probe (struct snd_card *card, int dev)
    366351{
     
    383368        }
    384369
    385         err = snd_wss_pcm(chip, 0, NULL);
     370        err = snd_wss_pcm(chip, 0);
    386371        if (err < 0)
    387372                return err;
    388373
    389         err = snd_wss_timer(chip, 0, NULL);
     374        err = snd_wss_timer(chip, 0);
    390375        if (err < 0)
    391376                return err;
     
    419404        }
    420405        if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt,
    421                         IRQF_DISABLED, "ICS2115", acard)) {
     406                        0, "ICS2115", acard)) {
    422407                snd_printk(KERN_ERR "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]);
    423408                return -EBUSY;
     
    425410       
    426411        acard->wavefront.irq = ics2115_irq[dev];
     412        card->sync_irq = acard->wavefront.irq;
    427413        acard->wavefront.base = ics2115_port[dev];
    428414
     
    450436                err = snd_mpu401_uart_new(card, midi_dev, MPU401_HW_CS4232,
    451437                                          cs4232_mpu_port[dev], 0,
    452                                           cs4232_mpu_irq[dev], IRQF_DISABLED,
    453                                           NULL);
     438                                          cs4232_mpu_irq[dev], NULL);
    454439                if (err < 0) {
    455440                        snd_printk (KERN_ERR "can't allocate CS4232 MPU-401 device\n");
     
    543528}       
    544529
    545 static int __devinit snd_wavefront_isa_match(struct device *pdev,
    546                                              unsigned int dev)
     530static int snd_wavefront_isa_match(struct device *pdev,
     531                                   unsigned int dev)
    547532{
    548533        if (!enable[dev])
     
    563548}
    564549
    565 static int __devinit snd_wavefront_isa_probe(struct device *pdev,
    566                                              unsigned int dev)
     550static int snd_wavefront_isa_probe(struct device *pdev,
     551                                   unsigned int dev)
    567552{
    568553        struct snd_card *card;
    569554        int err;
    570555
    571         err = snd_wavefront_card_new(dev, &card);
     556        err = snd_wavefront_card_new(pdev, dev, &card);
    572557        if (err < 0)
    573558                return err;
    574         snd_card_set_dev(card, pdev);
    575559        if ((err = snd_wavefront_probe(card, dev)) < 0) {
    576560                snd_card_free(card);
     
    582566}
    583567
    584 static int __devexit snd_wavefront_isa_remove(struct device *devptr,
    585                                               unsigned int dev)
     568static int snd_wavefront_isa_remove(struct device *devptr,
     569                                    unsigned int dev)
    586570{
    587571        snd_card_free(dev_get_drvdata(devptr));
    588         dev_set_drvdata(devptr, NULL);
    589572        return 0;
    590573}
     
    595578        .match          = snd_wavefront_isa_match,
    596579        .probe          = snd_wavefront_isa_probe,
    597         .remove         = __devexit_p(snd_wavefront_isa_remove),
     580        .remove         = snd_wavefront_isa_remove,
    598581        /* FIXME: suspend, resume */
    599582        .driver         = {
     
    604587
    605588#ifdef CONFIG_PNP
    606 static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
    607                                         const struct pnp_card_device_id *pid)
     589static int snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
     590                                    const struct pnp_card_device_id *pid)
    608591{
    609592        static int dev;
     
    618601                return -ENODEV;
    619602
    620         res = snd_wavefront_card_new(dev, &card);
     603        res = snd_wavefront_card_new(&pcard->card->dev, dev, &card);
    621604        if (res < 0)
    622605                return res;
     
    629612                }
    630613        }
    631         snd_card_set_dev(card, &pcard->card->dev);
    632614
    633615        if ((res = snd_wavefront_probe(card, dev)) < 0)
     
    639621}
    640622
    641 static void __devexit snd_wavefront_pnp_remove(struct pnp_card_link * pcard)
     623static void snd_wavefront_pnp_remove(struct pnp_card_link *pcard)
    642624{
    643625        snd_card_free(pnp_get_card_drvdata(pcard));
     
    650632        .id_table       = snd_wavefront_pnpids,
    651633        .probe          = snd_wavefront_pnp_detect,
    652         .remove         = __devexit_p(snd_wavefront_pnp_remove),
     634        .remove         = snd_wavefront_pnp_remove,
    653635        /* FIXME: suspend,resume */
    654636};
  • GPL/trunk/alsa-kernel/isa/wavefront/wavefront_fx.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Copyright (c) 1998-2002 by Paul Davis <pbd@op.net>
    3  *
    4  *  This program is free software; you can redistribute it and/or modify
    5  *  it under the terms of the GNU General Public License as published by
    6  *  the Free Software Foundation; either version 2 of the License, or
    7  *  (at your option) any later version.
    8  *
    9  *  This program is distributed in the hope that it will be useful,
    10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  *  GNU General Public License for more details.
    13  *
    14  *  You should have received a copy of the GNU General Public License
    15  *  along with this program; if not, write to the Free Software
    16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    174 */
    185
    19 #include <asm/io.h>
     6#include <linux/io.h>
    207#include <linux/init.h>
    218#include <linux/time.h>
    229#include <linux/wait.h>
    2310#include <linux/slab.h>
     11#include <linux/module.h>
    2412#include <linux/firmware.h>
    2513#include <sound/core.h>
    2614#include <sound/snd_wavefront.h>
    2715#include <sound/initval.h>
    28 #include <proto.h>
    2916
    3017/* Control bits for the Load Control Register
     
    8067                snd_printk ("FX memset: "
    8168                        "page must be >= 0 and <= 7\n");
    82                 return -(EINVAL);
     69                return -EINVAL;
    8370        }
    8471
     
    8673                snd_printk ("FX memset: "
    8774                        "addr must be >= 0 and <= 7f\n");
    88                 return -(EINVAL);
     75                return -EINVAL;
    8976        }
    9077
     
    119106                                    "(0x%x, 0x%x, 0x%lx, %d) incomplete\n",
    120107                                    page, addr, (unsigned long) data, cnt);
    121                         return -(EIO);
     108                        return -EIO;
    122109                }
    123110        }
     
    154141}
    155142
    156 int
     143int 
    157144snd_wavefront_fx_release (struct snd_hwdep *hw, struct file *file)
    158145
     
    241228*/
    242229
    243 int __devinit
     230int
    244231snd_wavefront_fx_start (snd_wavefront_t *dev)
    245232{
  • GPL/trunk/alsa-kernel/isa/wavefront/wavefront_midi.c

    r399 r679  
     1// SPDX-License-Identifier: GPL-2.0-only
    12/*
    23 * Copyright (C) by Paul Barton-Davis 1998-1999
    3  *
    4  * This file is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
    5  * Version 2 (June 1991). See the "COPYING" file distributed with this
    6  * software for more info. 
    74 */
    85
     
    4845 */
    4946
    50 #include <asm/io.h>
     47#include <linux/io.h>
    5148#include <linux/init.h>
    5249#include <linux/time.h>
     
    350347}
    351348
    352 static void snd_wavefront_midi_output_timer(unsigned long data)
    353 {
    354         snd_wavefront_card_t *card = (snd_wavefront_card_t *)data;
    355         snd_wavefront_midi_t *midi = &card->wavefront.midi;
     349static void snd_wavefront_midi_output_timer(struct timer_list *t)
     350{
     351        snd_wavefront_midi_t *midi = from_timer(midi, t, timer);
     352        snd_wavefront_card_t *card = midi->timer_card;
    356353        unsigned long flags;
    357354       
    358355        spin_lock_irqsave (&midi->virtual, flags);
    359         midi->timer.expires = 1 + jiffies;
    360         add_timer(&midi->timer);
     356        mod_timer(&midi->timer, 1 + jiffies);
    361357        spin_unlock_irqrestore (&midi->virtual, flags);
    362358        snd_wavefront_midi_output_write(card);
     
    385381                if ((midi->mode[mpu] & MPU401_MODE_OUTPUT_TRIGGER) == 0) {
    386382                        if (!midi->istimer) {
    387                                 init_timer(&midi->timer);
    388                                 midi->timer.function = snd_wavefront_midi_output_timer;
    389                                 midi->timer.data = (unsigned long) substream->rmidi->card->private_data;
    390                                 midi->timer.expires = 1 + jiffies;
    391                                 add_timer(&midi->timer);
     383                                timer_setup(&midi->timer,
     384                                            snd_wavefront_midi_output_timer,
     385                                            0);
     386                                mod_timer(&midi->timer, 1 + jiffies);
    392387                        }
    393388                        midi->istimer++;
     
    482477}
    483478
    484 int __devinit
     479int
    485480snd_wavefront_midi_start (snd_wavefront_card_t *card)
    486481
     
    538533
    539534        /* Turn on Virtual MIDI, but first *always* turn it off,
    540            since otherwise consectutive reloads of the driver will
     535           since otherwise consecutive reloads of the driver will
    541536           never cause the hardware to generate the initial "internal" or
    542537           "external" source bytes in the MIDI data stream. This
     
    562557}
    563558
    564 struct snd_rawmidi_ops snd_wavefront_midi_output =
     559const struct snd_rawmidi_ops snd_wavefront_midi_output =
    565560{
    566561        .open =         snd_wavefront_midi_output_open,
     
    569564};
    570565
    571 struct snd_rawmidi_ops snd_wavefront_midi_input =
     566const struct snd_rawmidi_ops snd_wavefront_midi_input =
    572567{
    573568        .open =         snd_wavefront_midi_input_open,
  • GPL/trunk/alsa-kernel/isa/wavefront/wavefront_synth.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-only
    12/* Copyright (C) by Paul Barton-Davis 1998-1999
    23 *
    34 * Some portions of this file are taken from work that is
    45 * copyright (C) by Hannu Savolainen 1993-1996
    5  *
    6  * This program is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
    7  * Version 2 (June 1991). See the "COPYING" file distributed with this software
    8  * for more info. 
    96 */
    107
     
    2118 */
    2219
    23 #include <asm/io.h>
     20#include <linux/io.h>
    2421#include <linux/interrupt.h>
    2522#include <linux/init.h>
     
    2724#include <linux/time.h>
    2825#include <linux/wait.h>
     26#include <linux/sched/signal.h>
    2927#include <linux/firmware.h>
    3028#include <linux/moduleparam.h>
    3129#include <linux/slab.h>
     30#include <linux/module.h>
    3231#include <sound/core.h>
    3332#include <sound/snd_wavefront.h>
     
    539538
    540539                dst++;
    541         };
     540        }
    542541        return dst;
    543542};
     
    787786                                      header->number);
    788787
     788        if (header->number >= ARRAY_SIZE(dev->patch_status))
     789                return -EINVAL;
     790
    789791        dev->patch_status[header->number] |= WF_SLOT_FILLED;
    790792
    791         bptr = buf;
    792793        bptr = munge_int32 (header->number, buf, 2);
    793794        munge_buf ((unsigned char *)&header->hdr.p, bptr, WF_PATCH_BYTES);
     
    795796        if (snd_wavefront_cmd (dev, WFC_DOWNLOAD_PATCH, NULL, buf)) {
    796797                snd_printk ("download patch failed\n");
    797                 return -(EIO);
     798                return -EIO;
    798799        }
    799800
     
    810811        DPRINT (WF_DEBUG_LOAD_PATCH, "downloading program %d\n",
    811812                header->number);
     813
     814        if (header->number >= ARRAY_SIZE(dev->prog_status))
     815                return -EINVAL;
    812816
    813817        dev->prog_status[header->number] = WF_SLOT_USED;
     
    833837        if (snd_wavefront_cmd (dev, WFC_DOWNLOAD_PROGRAM, NULL, buf)) {
    834838                snd_printk ("download patch failed\n");
    835                 return -(EIO);
     839                return -EIO;
    836840        }
    837841
     
    900904        }
    901905
     906        if (header->number >= WF_MAX_SAMPLE)
     907                return -EINVAL;
     908
    902909        if (header->size) {
    903910
     
    954961                snd_printk ("channel selection only "
    955962                            "possible on 16-bit samples");
    956                 return -(EINVAL);
     963                return -EINVAL;
    957964        }
    958965
     
    10511058                snd_printk ("sample %sdownload refused.\n",
    10521059                            header->size ? "" : "header ");
    1053                 return -(EIO);
     1060                return -EIO;
    10541061        }
    10551062
     
    10771084                        snd_printk ("download block "
    10781085                                    "request refused.\n");
    1079                         return -(EIO);
     1086                        return -EIO;
    10801087                }
    10811088
     
    11371144                                snd_printk ("upload sample "
    11381145                                            "DMA ack timeout\n");
    1139                                 return -(EIO);
     1146                                return -EIO;
    11401147                        } else {
    11411148                                snd_printk ("upload sample "
    11421149                                            "DMA ack error 0x%x\n",
    11431150                                            dma_ack);
    1144                                 return -(EIO);
     1151                                return -EIO;
    11451152                        }
    11461153                }
     
    11671174                                      header->number,
    11681175                                      header->hdr.a.OriginalSample);
    1169    
     1176
     1177        if (header->number >= WF_MAX_SAMPLE)
     1178                return -EINVAL;
     1179
    11701180        munge_int32 (header->number, &alias_hdr[0], 2);
    11711181        munge_int32 (header->hdr.a.OriginalSample, &alias_hdr[2], 2);
     
    11831193        if (snd_wavefront_cmd (dev, WFC_DOWNLOAD_SAMPLE_ALIAS, NULL, alias_hdr)) {
    11841194                snd_printk ("download alias failed.\n");
    1185                 return -(EIO);
     1195                return -EIO;
    11861196        }
    11871197
     
    11981208        unsigned char *msample_hdr;
    11991209
    1200         msample_hdr = kmalloc(sizeof(WF_MSAMPLE_BYTES), GFP_KERNEL);
     1210        if (header->number >= WF_MAX_SAMPLE)
     1211                return -EINVAL;
     1212
     1213        msample_hdr = kmalloc(WF_MSAMPLE_BYTES, GFP_KERNEL);
    12011214        if (! msample_hdr)
    12021215                return -ENOMEM;
     
    12341247                snd_printk ("download of multisample failed.\n");
    12351248                kfree(msample_hdr);
    1236                 return -(EIO);
     1249                return -EIO;
    12371250        }
    12381251
     
    12561269        if (snd_wavefront_cmd (dev, WFC_UPLOAD_MULTISAMPLE, log_ns, number)) {
    12571270                snd_printk ("upload multisample failed.\n");
    1258                 return -(EIO);
     1271                return -EIO;
    12591272        }
    12601273   
     
    12751288                        snd_printk ("upload multisample failed "
    12761289                                    "during sample loop.\n");
    1277                         return -(EIO);
     1290                        return -EIO;
    12781291                }
    12791292                d[0] = val;
     
    12821295                        snd_printk ("upload multisample failed "
    12831296                                    "during sample loop.\n");
    1284                         return -(EIO);
     1297                        return -EIO;
    12851298                }
    12861299                d[1] = val;
     
    13171330        if (snd_wavefront_cmd (dev, WFC_DOWNLOAD_EDRUM_PROGRAM, NULL, drumbuf)) {
    13181331                snd_printk ("download drum failed.\n");
    1319                 return -(EIO);
     1332                return -EIO;
    13201333        }
    13211334
     
    17431756*/
    17441757
    1745 static int __devinit
     1758static int
    17461759snd_wavefront_interrupt_bits (int irq)
    17471760
     
    17711784}
    17721785
    1773 static void __devinit
     1786static void
    17741787wavefront_should_cause_interrupt (snd_wavefront_t *dev,
    17751788                                  int val, int port, unsigned long timeout)
    17761789
    17771790{
    1778         wait_queue_t wait;
     1791        wait_queue_entry_t wait;
    17791792
    17801793        init_waitqueue_entry(&wait, current);
     
    17901803}
    17911804
    1792 static int __devinit
     1805static int
    17931806wavefront_reset_to_cleanliness (snd_wavefront_t *dev)
    17941807
     
    19411954}
    19421955
    1943 static int __devinit
     1956static int
    19441957wavefront_download_firmware (snd_wavefront_t *dev, char *path)
    19451958
     
    20142027
    20152028
    2016 static int __devinit
     2029static int
    20172030wavefront_do_reset (snd_wavefront_t *dev)
    20182031
     
    21032116}
    21042117
    2105 int __devinit
     2118int
    21062119snd_wavefront_start (snd_wavefront_t *dev)
    21072120
     
    21452158}
    21462159
    2147 int __devinit
     2160int
    21482161snd_wavefront_detect (snd_wavefront_card_t *card)
    21492162
Note: See TracChangeset for help on using the changeset viewer.