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

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/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,
Note: See TracChangeset for help on using the changeset viewer.