Ignore:
Timestamp:
Jan 1, 2021, 5:31:48 AM (5 years ago)
Author:
Paul Smedley
Message:

Add source for uniaud32 based on code from linux kernel 5.4.86

Location:
GPL/branches/uniaud32-next
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-next/alsa-kernel/pci/sonicvibes.c

    r612 r615  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *  Driver for S3 SonicVibes soundcard
     
    67 *    It looks like 86c617 rev 3 doesn't supports DDMA buffers above 16MB?
    78 *    Driver sometimes hangs... Nobody knows why at this moment...
    8  *
    9  *   This program is free software; you can redistribute it and/or modify
    10  *   it under the terms of the GNU General Public License as published by
    11  *   the Free Software Foundation; either version 2 of the License, or
    12  *   (at your option) any later version.
    13  *
    14  *   This program is distributed in the hope that it will be useful,
    15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  *   GNU General Public License for more details.
    18  *
    19  *   You should have received a copy of the GNU General Public License
    20  *   along with this program; if not, write to the Free Software
    21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    22  *
    239 */
    2410
     
    3117#include <linux/module.h>
    3218#include <linux/dma-mapping.h>
     19#include <linux/io.h>
    3320
    3421#include <sound/core.h>
     
    4027#include <sound/initval.h>
    4128
    42 #include <asm/io.h>
    43 
    4429MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
    4530MODULE_DESCRIPTION("S3 SonicVibes PCI");
     
    4732MODULE_SUPPORTED_DEVICE("{{S3,SonicVibes PCI}}");
    4833
    49 #if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
     34#if IS_REACHABLE(CONFIG_GAMEPORT)
    5035#define SUPPORT_JOYSTICK 1
    5136#endif
     
    5338static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    5439static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    55 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;      /* Enable this card */
    56 static int reverb[SNDRV_CARDS];
    57 static int mge[SNDRV_CARDS];
     40static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
     41static bool reverb[SNDRV_CARDS];
     42static bool mge[SNDRV_CARDS];
    5843static unsigned int dmaio = 0x7a00;     /* DDMA i/o address */
    5944
     
    6853module_param_array(mge, bool, NULL, 0444);
    6954MODULE_PARM_DESC(mge, "MIC Gain Enable for S3 SonicVibes soundcard.");
    70 module_param(dmaio, uint, 0444);
     55module_param_hw(dmaio, uint, ioport, 0444);
    7156MODULE_PARM_DESC(dmaio, "DDMA i/o base address for S3 SonicVibes soundcard.");
    7257
     
    243228};
    244229
    245 static DEFINE_PCI_DEVICE_TABLE(snd_sonic_ids) = {
     230static const struct pci_device_id snd_sonic_ids[] = {
    246231        { PCI_VDEVICE(S3, 0xca00), 0, },
    247232        { 0, }
     
    250235MODULE_DEVICE_TABLE(pci, snd_sonic_ids);
    251236
    252 static struct snd_ratden sonicvibes_adc_clock = {
     237static const struct snd_ratden sonicvibes_adc_clock = {
    253238        .num_min = 4000 * 65536,
    254239        .num_max = 48000UL * 65536,
     
    256241        .den = 65536,
    257242};
    258 static struct snd_pcm_hw_constraint_ratdens snd_sonicvibes_hw_constraints_adc_clock = {
     243static const struct snd_pcm_hw_constraint_ratdens snd_sonicvibes_hw_constraints_adc_clock = {
    259244        .nrats = 1,
    260245        .rats = &sonicvibes_adc_clock,
     
    274259        outb(0x18, sonic->dmaa_port + SV_DMA_MODE);
    275260#if 0
    276         printk(KERN_DEBUG "program dmaa: addr = 0x%x, paddr = 0x%x\n",
     261        dev_dbg(sonic->card->dev, "program dmaa: addr = 0x%x, paddr = 0x%x\n",
    277262               addr, inl(sonic->dmaa_port + SV_DMA_ADDR0));
    278263#endif
     
    290275        outb(0x14, sonic->dmac_port + SV_DMA_MODE);
    291276#if 0
    292         printk(KERN_DEBUG "program dmac: addr = 0x%x, paddr = 0x%x\n",
     277        dev_dbg(sonic->card->dev, "program dmac: addr = 0x%x, paddr = 0x%x\n",
    293278               addr, inl(sonic->dmac_port + SV_DMA_ADDR0));
    294279#endif
     
    358343static void snd_sonicvibes_debug(struct sonicvibes * sonic)
    359344{
    360         printk(KERN_DEBUG
    361                "SV REGS:          INDEX = 0x%02x  ", inb(SV_REG(sonic, INDEX)));
    362         printk("                 STATUS = 0x%02x\n", inb(SV_REG(sonic, STATUS)));
    363         printk(KERN_DEBUG
    364                "  0x00: left input      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x00));
    365         printk("  0x20: synth rate low  = 0x%02x\n", snd_sonicvibes_in(sonic, 0x20));
    366         printk(KERN_DEBUG
    367                "  0x01: right input     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x01));
    368         printk("  0x21: synth rate high = 0x%02x\n", snd_sonicvibes_in(sonic, 0x21));
    369         printk(KERN_DEBUG
    370                "  0x02: left AUX1       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x02));
    371         printk("  0x22: ADC clock       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x22));
    372         printk(KERN_DEBUG
    373                "  0x03: right AUX1      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x03));
    374         printk("  0x23: ADC alt rate    = 0x%02x\n", snd_sonicvibes_in(sonic, 0x23));
    375         printk(KERN_DEBUG
    376                "  0x04: left CD         = 0x%02x  ", snd_sonicvibes_in(sonic, 0x04));
    377         printk("  0x24: ADC pll M       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x24));
    378         printk(KERN_DEBUG
    379                "  0x05: right CD        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x05));
    380         printk("  0x25: ADC pll N       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x25));
    381         printk(KERN_DEBUG
    382                "  0x06: left line       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x06));
    383         printk("  0x26: Synth pll M     = 0x%02x\n", snd_sonicvibes_in(sonic, 0x26));
    384         printk(KERN_DEBUG
    385                "  0x07: right line      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x07));
    386         printk("  0x27: Synth pll N     = 0x%02x\n", snd_sonicvibes_in(sonic, 0x27));
    387         printk(KERN_DEBUG
    388                "  0x08: MIC             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x08));
    389         printk("  0x28: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x28));
    390         printk(KERN_DEBUG
    391                "  0x09: Game port       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x09));
    392         printk("  0x29: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x29));
    393         printk(KERN_DEBUG
    394                "  0x0a: left synth      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0a));
    395         printk("  0x2a: MPU401          = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2a));
    396         printk(KERN_DEBUG
    397                "  0x0b: right synth     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0b));
    398         printk("  0x2b: drive ctrl      = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2b));
    399         printk(KERN_DEBUG
    400                "  0x0c: left AUX2       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0c));
    401         printk("  0x2c: SRS space       = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2c));
    402         printk(KERN_DEBUG
    403                "  0x0d: right AUX2      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0d));
    404         printk("  0x2d: SRS center      = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2d));
    405         printk(KERN_DEBUG
    406                "  0x0e: left analog     = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0e));
    407         printk("  0x2e: wave source     = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2e));
    408         printk(KERN_DEBUG
    409                "  0x0f: right analog    = 0x%02x  ", snd_sonicvibes_in(sonic, 0x0f));
    410         printk("  0x2f: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2f));
    411         printk(KERN_DEBUG
    412                "  0x10: left PCM        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x10));
    413         printk("  0x30: analog power    = 0x%02x\n", snd_sonicvibes_in(sonic, 0x30));
    414         printk(KERN_DEBUG
    415                "  0x11: right PCM       = 0x%02x  ", snd_sonicvibes_in(sonic, 0x11));
    416         printk("  0x31: analog power    = 0x%02x\n", snd_sonicvibes_in(sonic, 0x31));
    417         printk(KERN_DEBUG
    418                "  0x12: DMA data format = 0x%02x  ", snd_sonicvibes_in(sonic, 0x12));
    419         printk("  0x32: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x32));
    420         printk(KERN_DEBUG
    421                "  0x13: P/C enable      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x13));
    422         printk("  0x33: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x33));
    423         printk(KERN_DEBUG
    424                "  0x14: U/D button      = 0x%02x  ", snd_sonicvibes_in(sonic, 0x14));
    425         printk("  0x34: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x34));
    426         printk(KERN_DEBUG
    427                "  0x15: revision        = 0x%02x  ", snd_sonicvibes_in(sonic, 0x15));
    428         printk("  0x35: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x35));
    429         printk(KERN_DEBUG
    430                "  0x16: ADC output ctrl = 0x%02x  ", snd_sonicvibes_in(sonic, 0x16));
    431         printk("  0x36: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x36));
    432         printk(KERN_DEBUG
    433                "  0x17: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x17));
    434         printk("  0x37: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x37));
    435         printk(KERN_DEBUG
    436                "  0x18: DMA A upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x18));
    437         printk("  0x38: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x38));
    438         printk(KERN_DEBUG
    439                "  0x19: DMA A lower cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x19));
    440         printk("  0x39: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x39));
    441         printk(KERN_DEBUG
    442                "  0x1a: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1a));
    443         printk("  0x3a: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3a));
    444         printk(KERN_DEBUG
    445                "  0x1b: ---             = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1b));
    446         printk("  0x3b: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3b));
    447         printk(KERN_DEBUG
    448                "  0x1c: DMA C upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1c));
    449         printk("  0x3c: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3c));
    450         printk(KERN_DEBUG
    451                "  0x1d: DMA C upper cnt = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1d));
    452         printk("  0x3d: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3d));
    453         printk(KERN_DEBUG
    454                "  0x1e: PCM rate low    = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1e));
    455         printk("  0x3e: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3e));
    456         printk(KERN_DEBUG
    457                "  0x1f: PCM rate high   = 0x%02x  ", snd_sonicvibes_in(sonic, 0x1f));
    458         printk("  0x3f: ---             = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3f));
     345        dev_dbg(sonic->card->dev,
     346                "SV REGS:          INDEX = 0x%02x                   STATUS = 0x%02x\n",
     347                inb(SV_REG(sonic, INDEX)), inb(SV_REG(sonic, STATUS)));
     348        dev_dbg(sonic->card->dev,
     349                "  0x00: left input      = 0x%02x    0x20: synth rate low  = 0x%02x\n",
     350                snd_sonicvibes_in(sonic, 0x00), snd_sonicvibes_in(sonic, 0x20));
     351        dev_dbg(sonic->card->dev,
     352                "  0x01: right input     = 0x%02x    0x21: synth rate high = 0x%02x\n",
     353                snd_sonicvibes_in(sonic, 0x01), snd_sonicvibes_in(sonic, 0x21));
     354        dev_dbg(sonic->card->dev,
     355                "  0x02: left AUX1       = 0x%02x    0x22: ADC clock       = 0x%02x\n",
     356                snd_sonicvibes_in(sonic, 0x02), snd_sonicvibes_in(sonic, 0x22));
     357        dev_dbg(sonic->card->dev,
     358                "  0x03: right AUX1      = 0x%02x    0x23: ADC alt rate    = 0x%02x\n",
     359                snd_sonicvibes_in(sonic, 0x03), snd_sonicvibes_in(sonic, 0x23));
     360        dev_dbg(sonic->card->dev,
     361                "  0x04: left CD         = 0x%02x    0x24: ADC pll M       = 0x%02x\n",
     362                snd_sonicvibes_in(sonic, 0x04), snd_sonicvibes_in(sonic, 0x24));
     363        dev_dbg(sonic->card->dev,
     364                "  0x05: right CD        = 0x%02x    0x25: ADC pll N       = 0x%02x\n",
     365                snd_sonicvibes_in(sonic, 0x05), snd_sonicvibes_in(sonic, 0x25));
     366        dev_dbg(sonic->card->dev,
     367                "  0x06: left line       = 0x%02x    0x26: Synth pll M     = 0x%02x\n",
     368                snd_sonicvibes_in(sonic, 0x06), snd_sonicvibes_in(sonic, 0x26));
     369        dev_dbg(sonic->card->dev,
     370                "  0x07: right line      = 0x%02x    0x27: Synth pll N     = 0x%02x\n",
     371                snd_sonicvibes_in(sonic, 0x07), snd_sonicvibes_in(sonic, 0x27));
     372        dev_dbg(sonic->card->dev,
     373                "  0x08: MIC             = 0x%02x    0x28: ---             = 0x%02x\n",
     374                snd_sonicvibes_in(sonic, 0x08), snd_sonicvibes_in(sonic, 0x28));
     375        dev_dbg(sonic->card->dev,
     376                "  0x09: Game port       = 0x%02x    0x29: ---             = 0x%02x\n",
     377                snd_sonicvibes_in(sonic, 0x09), snd_sonicvibes_in(sonic, 0x29));
     378        dev_dbg(sonic->card->dev,
     379                "  0x0a: left synth      = 0x%02x    0x2a: MPU401          = 0x%02x\n",
     380                snd_sonicvibes_in(sonic, 0x0a), snd_sonicvibes_in(sonic, 0x2a));
     381        dev_dbg(sonic->card->dev,
     382                "  0x0b: right synth     = 0x%02x    0x2b: drive ctrl      = 0x%02x\n",
     383                snd_sonicvibes_in(sonic, 0x0b), snd_sonicvibes_in(sonic, 0x2b));
     384        dev_dbg(sonic->card->dev,
     385                "  0x0c: left AUX2       = 0x%02x    0x2c: SRS space       = 0x%02x\n",
     386                snd_sonicvibes_in(sonic, 0x0c), snd_sonicvibes_in(sonic, 0x2c));
     387        dev_dbg(sonic->card->dev,
     388                "  0x0d: right AUX2      = 0x%02x    0x2d: SRS center      = 0x%02x\n",
     389                snd_sonicvibes_in(sonic, 0x0d), snd_sonicvibes_in(sonic, 0x2d));
     390        dev_dbg(sonic->card->dev,
     391                "  0x0e: left analog     = 0x%02x    0x2e: wave source     = 0x%02x\n",
     392                snd_sonicvibes_in(sonic, 0x0e), snd_sonicvibes_in(sonic, 0x2e));
     393        dev_dbg(sonic->card->dev,
     394                "  0x0f: right analog    = 0x%02x    0x2f: ---             = 0x%02x\n",
     395                snd_sonicvibes_in(sonic, 0x0f), snd_sonicvibes_in(sonic, 0x2f));
     396        dev_dbg(sonic->card->dev,
     397                "  0x10: left PCM        = 0x%02x    0x30: analog power    = 0x%02x\n",
     398                snd_sonicvibes_in(sonic, 0x10), snd_sonicvibes_in(sonic, 0x30));
     399        dev_dbg(sonic->card->dev,
     400                "  0x11: right PCM       = 0x%02x    0x31: analog power    = 0x%02x\n",
     401                snd_sonicvibes_in(sonic, 0x11), snd_sonicvibes_in(sonic, 0x31));
     402        dev_dbg(sonic->card->dev,
     403                "  0x12: DMA data format = 0x%02x    0x32: ---             = 0x%02x\n",
     404                snd_sonicvibes_in(sonic, 0x12), snd_sonicvibes_in(sonic, 0x32));
     405        dev_dbg(sonic->card->dev,
     406                "  0x13: P/C enable      = 0x%02x    0x33: ---             = 0x%02x\n",
     407                snd_sonicvibes_in(sonic, 0x13), snd_sonicvibes_in(sonic, 0x33));
     408        dev_dbg(sonic->card->dev,
     409                "  0x14: U/D button      = 0x%02x    0x34: ---             = 0x%02x\n",
     410                snd_sonicvibes_in(sonic, 0x14), snd_sonicvibes_in(sonic, 0x34));
     411        dev_dbg(sonic->card->dev,
     412                "  0x15: revision        = 0x%02x    0x35: ---             = 0x%02x\n",
     413                snd_sonicvibes_in(sonic, 0x15), snd_sonicvibes_in(sonic, 0x35));
     414        dev_dbg(sonic->card->dev,
     415                "  0x16: ADC output ctrl = 0x%02x    0x36: ---             = 0x%02x\n",
     416                snd_sonicvibes_in(sonic, 0x16), snd_sonicvibes_in(sonic, 0x36));
     417        dev_dbg(sonic->card->dev,
     418                "  0x17: ---             = 0x%02x    0x37: ---             = 0x%02x\n",
     419                snd_sonicvibes_in(sonic, 0x17), snd_sonicvibes_in(sonic, 0x37));
     420        dev_dbg(sonic->card->dev,
     421                "  0x18: DMA A upper cnt = 0x%02x    0x38: ---             = 0x%02x\n",
     422                snd_sonicvibes_in(sonic, 0x18), snd_sonicvibes_in(sonic, 0x38));
     423        dev_dbg(sonic->card->dev,
     424                "  0x19: DMA A lower cnt = 0x%02x    0x39: ---             = 0x%02x\n",
     425                snd_sonicvibes_in(sonic, 0x19), snd_sonicvibes_in(sonic, 0x39));
     426        dev_dbg(sonic->card->dev,
     427                "  0x1a: ---             = 0x%02x    0x3a: ---             = 0x%02x\n",
     428                snd_sonicvibes_in(sonic, 0x1a), snd_sonicvibes_in(sonic, 0x3a));
     429        dev_dbg(sonic->card->dev,
     430                "  0x1b: ---             = 0x%02x    0x3b: ---             = 0x%02x\n",
     431                snd_sonicvibes_in(sonic, 0x1b), snd_sonicvibes_in(sonic, 0x3b));
     432        dev_dbg(sonic->card->dev,
     433                "  0x1c: DMA C upper cnt = 0x%02x    0x3c: ---             = 0x%02x\n",
     434                snd_sonicvibes_in(sonic, 0x1c), snd_sonicvibes_in(sonic, 0x3c));
     435        dev_dbg(sonic->card->dev,
     436                "  0x1d: DMA C upper cnt = 0x%02x    0x3d: ---             = 0x%02x\n",
     437                snd_sonicvibes_in(sonic, 0x1d), snd_sonicvibes_in(sonic, 0x3d));
     438        dev_dbg(sonic->card->dev,
     439                "  0x1e: PCM rate low    = 0x%02x    0x3e: ---             = 0x%02x\n",
     440                snd_sonicvibes_in(sonic, 0x1e), snd_sonicvibes_in(sonic, 0x3e));
     441        dev_dbg(sonic->card->dev,
     442                "  0x1f: PCM rate high   = 0x%02x    0x3f: ---             = 0x%02x\n",
     443                snd_sonicvibes_in(sonic, 0x1f), snd_sonicvibes_in(sonic, 0x3f));
    459444}
    460445
     
    512497        *res_n = n;
    513498#if 0
    514         printk(KERN_DEBUG "metric = %i, xm = %i, xn = %i\n", metric, xm, xn);
    515         printk(KERN_DEBUG "pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n);
     499        dev_dbg(sonic->card->dev,
     500                "metric = %i, xm = %i, xn = %i\n", metric, xm, xn);
     501        dev_dbg(sonic->card->dev,
     502                "pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n);
    516503#endif
    517504}
     
    625612        if (status == 0xff) {   /* failure */
    626613                outb(sonic->irqmask = ~0, SV_REG(sonic, IRQMASK));
    627                 snd_printk(KERN_ERR "IRQ failure - interrupts disabled!!\n");
     614                dev_err(sonic->card->dev,
     615                        "IRQ failure - interrupts disabled!!\n");
    628616                return IRQ_HANDLED;
    629617        }
     
    775763}
    776764
    777 static struct snd_pcm_hardware snd_sonicvibes_playback =
     765static const struct snd_pcm_hardware snd_sonicvibes_playback =
    778766{
    779767        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    794782};
    795783
    796 static struct snd_pcm_hardware snd_sonicvibes_capture =
     784static const struct snd_pcm_hardware snd_sonicvibes_capture =
    797785{
    798786        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    856844}
    857845
    858 static struct snd_pcm_ops snd_sonicvibes_playback_ops = {
     846static const struct snd_pcm_ops snd_sonicvibes_playback_ops = {
    859847        .open =         snd_sonicvibes_playback_open,
    860848        .close =        snd_sonicvibes_playback_close,
     
    867855};
    868856
    869 static struct snd_pcm_ops snd_sonicvibes_capture_ops = {
     857static const struct snd_pcm_ops snd_sonicvibes_capture_ops = {
    870858        .open =         snd_sonicvibes_capture_open,
    871859        .close =        snd_sonicvibes_capture_close,
     
    878866};
    879867
    880 static int __devinit snd_sonicvibes_pcm(struct sonicvibes * sonic, int device, struct snd_pcm ** rpcm)
     868static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device)
    881869{
    882870        struct snd_pcm *pcm;
     
    899887                                              snd_dma_pci_data(sonic->pci), 64*1024, 128*1024);
    900888
    901         if (rpcm)
    902                 *rpcm = pcm;
    903889        return 0;
    904890}
     
    915901static int snd_sonicvibes_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    916902{
    917         static char *texts[7] = {
     903        static const char * const texts[7] = {
    918904                "CD", "PCM", "Aux1", "Line", "Aux0", "Mic", "Mix"
    919905        };
    920906
    921         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
    922         uinfo->count = 2;
    923         uinfo->value.enumerated.items = 7;
    924         if (uinfo->value.enumerated.item >= 7)
    925                 uinfo->value.enumerated.item = 6;
    926         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
    927         return 0;
     907        return snd_ctl_enum_info(uinfo, 2, 7, texts);
    928908}
    929909
     
    10881068}
    10891069
    1090 static struct snd_kcontrol_new snd_sonicvibes_controls[] __devinitdata = {
     1070static struct snd_kcontrol_new snd_sonicvibes_controls[] = {
    10911071SONICVIBES_DOUBLE("Capture Volume", 0, SV_IREG_LEFT_ADC, SV_IREG_RIGHT_ADC, 0, 0, 15, 0),
    10921072SONICVIBES_DOUBLE("Aux Playback Switch", 0, SV_IREG_LEFT_AUX1, SV_IREG_RIGHT_AUX1, 7, 7, 1, 1),
     
    11191099}
    11201100
    1121 static int __devinit snd_sonicvibes_mixer(struct sonicvibes * sonic)
     1101static int snd_sonicvibes_mixer(struct sonicvibes *sonic)
    11221102{
    11231103        struct snd_card *card;
     
    11761156}
    11771157
    1178 static void __devinit snd_sonicvibes_proc_init(struct sonicvibes * sonic)
    1179 {
    1180         struct snd_info_entry *entry;
    1181 
    1182         if (! snd_card_proc_new(sonic->card, "sonicvibes", &entry))
    1183                 snd_info_set_text_ops(entry, sonic, snd_sonicvibes_proc_read);
     1158static void snd_sonicvibes_proc_init(struct sonicvibes *sonic)
     1159{
     1160        snd_card_ro_proc_new(sonic->card, "sonicvibes", sonic,
     1161                             snd_sonicvibes_proc_read);
    11841162}
    11851163
     
    11891167
    11901168#ifdef SUPPORT_JOYSTICK
    1191 static struct snd_kcontrol_new snd_sonicvibes_game_control __devinitdata =
     1169static struct snd_kcontrol_new snd_sonicvibes_game_control =
    11921170SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0);
    11931171
    1194 static int __devinit snd_sonicvibes_create_gameport(struct sonicvibes *sonic)
     1172static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic)
    11951173{
    11961174        struct gameport *gp;
     1175        int err;
    11971176
    11981177        sonic->gameport = gp = gameport_allocate_port();
    11991178        if (!gp) {
    1200                 printk(KERN_ERR "sonicvibes: cannot allocate memory for gameport\n");
     1179                dev_err(sonic->card->dev,
     1180                        "sonicvibes: cannot allocate memory for gameport\n");
    12011181                return -ENOMEM;
    12021182        }
     
    12091189        gameport_register_port(gp);
    12101190
    1211         snd_ctl_add(sonic->card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic));
     1191        err = snd_ctl_add(sonic->card,
     1192                snd_ctl_new1(&snd_sonicvibes_game_control, sonic));
     1193        if (err < 0)
     1194                return err;
    12121195
    12131196        return 0;
     
    12471230}
    12481231
    1249 static int __devinit snd_sonicvibes_create(struct snd_card *card,
    1250                                         struct pci_dev *pci,
    1251                                         int reverb,
    1252                                         int mge,
    1253                                         struct sonicvibes ** rsonic)
     1232static int snd_sonicvibes_create(struct snd_card *card,
     1233                                 struct pci_dev *pci,
     1234                                 int reverb,
     1235                                 int mge,
     1236                                 struct sonicvibes **rsonic)
    12541237{
    12551238        struct sonicvibes *sonic;
     
    12651248                return err;
    12661249        /* check, if we can restrict PCI DMA transfers to 24 bits */
    1267         if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
    1268             pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
    1269                 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n");
     1250        if (dma_set_mask(&pci->dev, DMA_BIT_MASK(24)) < 0 ||
     1251            dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(24)) < 0) {
     1252                dev_err(card->dev,
     1253                        "architecture does not support 24bit PCI busmaster DMA\n");
    12701254                pci_disable_device(pci);
    12711255                return -ENXIO;
     
    12961280        if (request_irq(pci->irq, snd_sonicvibes_interrupt, IRQF_SHARED,
    12971281                        KBUILD_MODNAME, sonic)) {
    1298                 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
     1282                dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
    12991283                snd_sonicvibes_free(sonic);
    13001284                return -EBUSY;
     
    13101294                dmaa = dmaio;
    13111295                dmaio += 0x10;
    1312                 snd_printk(KERN_INFO "BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n", dmaa);
     1296                dev_info(card->dev,
     1297                         "BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n",
     1298                         dmaa);
    13131299        }
    13141300        if (!dmac) {
    13151301                dmac = dmaio;
    13161302                dmaio += 0x10;
    1317                 snd_printk(KERN_INFO "BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n", dmac);
     1303                dev_info(card->dev,
     1304                         "BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n",
     1305                         dmac);
    13181306        }
    13191307        pci_write_config_dword(pci, 0x40, dmaa);
     
    13221310        if ((sonic->res_dmaa = request_region(dmaa, 0x10, "S3 SonicVibes DDMA-A")) == NULL) {
    13231311                snd_sonicvibes_free(sonic);
    1324                 snd_printk(KERN_ERR "unable to grab DDMA-A port at 0x%x-0x%x\n", dmaa, dmaa + 0x10 - 1);
     1312                dev_err(card->dev,
     1313                        "unable to grab DDMA-A port at 0x%x-0x%x\n",
     1314                        dmaa, dmaa + 0x10 - 1);
    13251315                return -EBUSY;
    13261316        }
    13271317        if ((sonic->res_dmac = request_region(dmac, 0x10, "S3 SonicVibes DDMA-C")) == NULL) {
    13281318                snd_sonicvibes_free(sonic);
    1329                 snd_printk(KERN_ERR "unable to grab DDMA-C port at 0x%x-0x%x\n", dmac, dmac + 0x10 - 1);
     1319                dev_err(card->dev,
     1320                        "unable to grab DDMA-C port at 0x%x-0x%x\n",
     1321                        dmac, dmac + 0x10 - 1);
    13301322                return -EBUSY;
    13311323        }
     
    13921384        snd_sonicvibes_proc_init(sonic);
    13931385
    1394         snd_card_set_dev(card, &pci->dev);
    1395 
    13961386        *rsonic = sonic;
    13971387        return 0;
     
    14021392 */
    14031393
    1404 static struct snd_kcontrol_new snd_sonicvibes_midi_controls[] __devinitdata = {
     1394static struct snd_kcontrol_new snd_sonicvibes_midi_controls[] = {
    14051395SONICVIBES_SINGLE("SonicVibes Wave Source RAM", 0, SV_IREG_WAVE_SOURCE, 0, 1, 0),
    14061396SONICVIBES_SINGLE("SonicVibes Wave Source RAM+ROM", 0, SV_IREG_WAVE_SOURCE, 1, 1, 0),
     
    14231413}
    14241414
    1425 static int __devinit snd_sonicvibes_midi(struct sonicvibes * sonic,
    1426                                         struct snd_rawmidi *rmidi)
     1415static int snd_sonicvibes_midi(struct sonicvibes *sonic,
     1416                              struct snd_rawmidi *rmidi)
    14271417{
    14281418        struct snd_mpu401 * mpu = rmidi->private_data;
    14291419        struct snd_card *card = sonic->card;
    1430         struct snd_rawmidi_str *dir;
    14311420        unsigned int idx;
    14321421        int err;
     
    14351424        mpu->open_input = snd_sonicvibes_midi_input_open;
    14361425        mpu->close_input = snd_sonicvibes_midi_input_close;
    1437         dir = &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT];
    14381426        for (idx = 0; idx < ARRAY_SIZE(snd_sonicvibes_midi_controls); idx++)
    14391427                if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_sonicvibes_midi_controls[idx], sonic))) < 0)
     
    14421430}
    14431431
    1444 static int __devinit snd_sonic_probe(struct pci_dev *pci,
    1445                                      const struct pci_device_id *pci_id)
     1432static int snd_sonic_probe(struct pci_dev *pci,
     1433                           const struct pci_device_id *pci_id)
    14461434{
    14471435        static int dev;
     
    14591447        }
    14601448 
    1461         err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
     1449        err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
     1450                           0, &card);
    14621451        if (err < 0)
    14631452                return err;
     
    14851474                sonic->irq);
    14861475
    1487         if ((err = snd_sonicvibes_pcm(sonic, 0, NULL)) < 0) {
     1476        if ((err = snd_sonicvibes_pcm(sonic, 0)) < 0) {
    14881477                snd_card_free(card);
    14891478                return err;
     
    15131502        }
    15141503
    1515         snd_sonicvibes_create_gameport(sonic);
     1504        err = snd_sonicvibes_create_gameport(sonic);
     1505        if (err < 0) {
     1506                snd_card_free(card);
     1507                return err;
     1508        }
    15161509
    15171510        if ((err = snd_card_register(card)) < 0) {
     
    15251518}
    15261519
    1527 static void __devexit snd_sonic_remove(struct pci_dev *pci)
     1520static void snd_sonic_remove(struct pci_dev *pci)
    15281521{
    15291522        snd_card_free(pci_get_drvdata(pci));
    1530         pci_set_drvdata(pci, NULL);
    1531 }
    1532 
    1533 static struct pci_driver driver = {
     1523}
     1524
     1525static struct pci_driver sonicvibes_driver = {
    15341526        .name = KBUILD_MODNAME,
    15351527        .id_table = snd_sonic_ids,
    15361528        .probe = snd_sonic_probe,
    1537         .remove = __devexit_p(snd_sonic_remove),
     1529        .remove = snd_sonic_remove,
    15381530};
    15391531
    1540 static int __init alsa_card_sonicvibes_init(void)
    1541 {
    1542         return pci_register_driver(&driver);
    1543 }
    1544 
    1545 static void __exit alsa_card_sonicvibes_exit(void)
    1546 {
    1547         pci_unregister_driver(&driver);
    1548 }
    1549 
    1550 module_init(alsa_card_sonicvibes_init)
    1551 module_exit(alsa_card_sonicvibes_exit)
     1532module_pci_driver(sonicvibes_driver);
Note: See TracChangeset for help on using the changeset viewer.