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

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

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

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 * Driver for audio on multifunction CS5535/6 companion device
     
    56 * Based on Jaroslav Kysela and Takashi Iwai's examples.
    67 * This work was sponsored by CIS(M) Sdn Bhd.
    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  *
    228 */
    239
     
    2713#include <linux/pci.h>
    2814#include <linux/slab.h>
    29 #include <linux/moduleparam.h>
    30 #include <asm/io.h>
     15#include <linux/module.h>
     16#include <linux/io.h>
    3117#include <sound/core.h>
    3218#include <sound/control.h>
     
    3925
    4026#define DRIVER_NAME "cs5535audio"
     27#ifdef TARGET_OS2
     28#define KBUILD_MODNAME DRIVER_NAME
     29#include <linux/dma-mapping.h>
     30#endif
    4131
    4232static char *ac97_quirk;
     
    4434MODULE_PARM_DESC(ac97_quirk, "AC'97 board specific workarounds.");
    4535
    46 static struct ac97_quirk ac97_quirks[] __devinitdata = {
     36static const struct ac97_quirk ac97_quirks[] = {
    4737#if 0 /* Not yet confirmed if all 5536 boards are HP only */
    4838        {
     
    5848static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
    5949static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
    60 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
     50static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
    6151
    6252module_param_array(index, int, NULL, 0444);
     
    6757MODULE_PARM_DESC(enable, "Enable " DRIVER_NAME);
    6858
    69 static DEFINE_PCI_DEVICE_TABLE(snd_cs5535audio_ids) = {
     59static const struct pci_device_id snd_cs5535audio_ids[] = {
    7060        { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO) },
    7161        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO) },
     
    8575        } while (--timeout);
    8676        if (!timeout)
    87                 snd_printk(KERN_ERR "Failure writing to cs5535 codec\n");
     77                dev_err(cs5535au->card->dev,
     78                        "Failure writing to cs5535 codec\n");
    8879}
    8980
     
    110101        } while (--timeout);
    111102        if (!timeout)
    112                 snd_printk(KERN_ERR "Failure reading codec reg 0x%x,"
    113                                         "Last value=0x%x\n", reg, val);
     103                dev_err(cs5535au->card->dev,
     104                        "Failure reading codec reg 0x%x, Last value=0x%x\n",
     105                        reg, val);
    114106
    115107        return (unsigned short) val;
     
    145137}
    146138
    147 static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
     139static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
    148140{
    149141        struct snd_card *card = cs5535au->card;
     
    151143        struct snd_ac97_template ac97;
    152144        int err;
    153         static struct snd_ac97_bus_ops ops = {
     145        static const struct snd_ac97_bus_ops ops = {
    154146                .write = snd_cs5535audio_ac97_codec_write,
    155147                .read = snd_cs5535audio_ac97_codec_read,
     
    169161
    170162        if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) {
    171                 snd_printk(KERN_ERR "mixer failed\n");
     163                dev_err(card->dev, "mixer failed\n");
    172164                return err;
    173165        }
     
    177169        err = olpc_quirks(card, cs5535au->ac97);
    178170        if (err < 0) {
    179                 snd_printk(KERN_ERR "olpc quirks failed\n");
     171                dev_err(card->dev, "olpc quirks failed\n");
    180172                return err;
    181173        }
     
    191183        spin_unlock(&cs5535au->reg_lock);
    192184        if (bm_stat & EOP) {
    193                 struct cs5535audio_dma *dma;
    194                 dma = cs5535au->playback_substream->runtime->private_data;
    195185                snd_pcm_period_elapsed(cs5535au->playback_substream);
    196186        } else {
    197                 snd_printk(KERN_ERR "unexpected bm0 irq src, bm_stat=%x\n",
    198                                         bm_stat);
     187                dev_err(cs5535au->card->dev,
     188                        "unexpected bm0 irq src, bm_stat=%x\n",
     189                        bm_stat);
    199190        }
    200191}
     
    206197        bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS);
    207198        spin_unlock(&cs5535au->reg_lock);
    208         if (bm_stat & EOP) {
    209                 struct cs5535audio_dma *dma;
    210                 dma = cs5535au->capture_substream->runtime->private_data;
     199        if (bm_stat & EOP)
    211200                snd_pcm_period_elapsed(cs5535au->capture_substream);
    212         }
    213201}
    214202
     
    242230                                break;
    243231                        default:
    244                                 snd_printk(KERN_ERR "Unexpected irq src: "
    245                                                 "0x%x\n", acc_irq_stat);
     232                                dev_err(cs5535au->card->dev,
     233                                        "Unexpected irq src: 0x%x\n",
     234                                        acc_irq_stat);
    246235                                break;
    247236                        }
     
    253242static int snd_cs5535audio_free(struct cs5535audio *cs5535au)
    254243{
    255         synchronize_irq(cs5535au->irq);
    256         pci_set_power_state(cs5535au->pci, 3);
     244        pci_set_power_state(cs5535au->pci, PCI_D3hot);
    257245
    258246        if (cs5535au->irq >= 0)
     
    271259}
    272260
    273 static int __devinit snd_cs5535audio_create(struct snd_card *card,
    274                                             struct pci_dev *pci,
    275                                             struct cs5535audio **rcs5535au)
     261static int snd_cs5535audio_create(struct snd_card *card,
     262                                  struct pci_dev *pci,
     263                                  struct cs5535audio **rcs5535au)
    276264{
    277265        struct cs5535audio *cs5535au;
    278266
    279267        int err;
    280         static struct snd_device_ops ops = {
     268        static const struct snd_device_ops ops = {
    281269                .dev_free =     snd_cs5535audio_dev_free,
    282270        };
     
    286274                return err;
    287275
    288         if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
    289             pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
    290                 printk(KERN_WARNING "unable to get 32bit dma\n");
     276        if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0 ||
     277            dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
     278                dev_warn(card->dev, "unable to get 32bit dma\n");
    291279                err = -ENXIO;
    292280                goto pcifail;
     
    312300
    313301        if (request_irq(pci->irq, snd_cs5535audio_interrupt,
    314                         IRQF_SHARED, "CS5535 Audio", cs5535au)) {
    315                 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
     302                        IRQF_SHARED, KBUILD_MODNAME, cs5535au)) {
     303                dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
    316304                err = -EBUSY;
    317305                goto sndfail;
     
    319307
    320308        cs5535au->irq = pci->irq;
     309        card->sync_irq = cs5535au->irq;
    321310        pci_set_master(pci);
    322311
     
    325314                goto sndfail;
    326315
    327         snd_card_set_dev(card, &pci->dev);
    328 
    329316        *rcs5535au = cs5535au;
    330317        return 0;
     
    339326}
    340327
    341 static int __devinit snd_cs5535audio_probe(struct pci_dev *pci,
    342                                           const struct pci_device_id *pci_id)
     328static int snd_cs5535audio_probe(struct pci_dev *pci,
     329                                const struct pci_device_id *pci_id)
    343330{
    344331        static int dev;
     
    354341        }
    355342
    356         err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
     343        err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
     344                           0, &card);
    357345        if (err < 0)
    358346                return err;
     
    388376}
    389377
    390 static void __devexit snd_cs5535audio_remove(struct pci_dev *pci)
     378static void snd_cs5535audio_remove(struct pci_dev *pci)
    391379{
    392380        olpc_quirks_cleanup();
    393381        snd_card_free(pci_get_drvdata(pci));
    394         pci_set_drvdata(pci, NULL);
    395 }
    396 
    397 static struct pci_driver driver = {
    398         .name = DRIVER_NAME,
     382}
     383
     384static struct pci_driver cs5535audio_driver = {
     385        .name = KBUILD_MODNAME,
    399386        .id_table = snd_cs5535audio_ids,
    400387        .probe = snd_cs5535audio_probe,
    401         .remove = __devexit_p(snd_cs5535audio_remove),
    402 #ifdef CONFIG_PM
    403         .suspend = snd_cs5535audio_suspend,
    404         .resume = snd_cs5535audio_resume,
     388        .remove = snd_cs5535audio_remove,
     389#ifdef CONFIG_PM_SLEEP
     390        .driver = {
     391                .pm = &snd_cs5535audio_pm,
     392        },
    405393#endif
    406394};
    407395
    408 static int __init alsa_card_cs5535audio_init(void)
    409 {
    410         return pci_register_driver(&driver);
    411 }
    412 
    413 static void __exit alsa_card_cs5535audio_exit(void)
    414 {
    415         pci_unregister_driver(&driver);
    416 }
    417 
    418 module_init(alsa_card_cs5535audio_init)
    419 module_exit(alsa_card_cs5535audio_exit)
     396module_pci_driver(cs5535audio_driver);
    420397
    421398MODULE_AUTHOR("Jaya Kumar");
Note: See TracChangeset for help on using the changeset viewer.