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