Ignore:
Timestamp:
Apr 3, 2017, 4:51:56 PM (9 years ago)
Author:
David Azarewicz
Message:

Merged/reintegrated v2 branch into trunk. Trunk is now v2

Location:
GPL/trunk
Files:
9 added
6 deleted
26 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/isa/ad1816a/ad1816a.c

    r426 r598  
    163163        if (error < 0)
    164164                return error;
    165         acard = (struct snd_card_ad1816a *)card->private_data;
     165        acard = card->private_data;
    166166
    167167        if ((error = snd_card_ad1816a_pnp(dev, acard, pcard, pid))) {
  • GPL/trunk/alsa-kernel/isa/als100.c

    r410 r598  
    33    card-als100.c - driver for Avance Logic ALS100 based soundcards.
    44    Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it>
     5    Copyright (C) 1999-2002 by Massimo Piccioni <dafastidio@libero.it>
    56
    67    Thanks to Pierfrancesco 'qM2' Passerini.
     8
     9    Generalised for soundcards based on DT-0196 and ALS-007 chips
     10    by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>: June 2002.
    711
    812    This program is free software; you can redistribute it and/or modify
     
    3438#define PFX "als100: "
    3539
    36 MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
    37 MODULE_DESCRIPTION("Avance Logic ALS1X0");
    38 MODULE_LICENSE("GPL");
    39 MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS100 - PRO16PNP},"
     40MODULE_DESCRIPTION("Avance Logic ALS007/ALS1X0");
     41MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X},"
     42                "{Avance Logic ALS-007}}"
     43                "{{Avance Logic,ALS100 - PRO16PNP},"
    4044                "{Avance Logic,ALS110},"
    4145                "{Avance Logic,ALS120},"
     
    4650                "{RTL,RTL3000}}");
    4751
     52MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
     53MODULE_LICENSE("GPL");
     54
    4855static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4956static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    50 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
     57static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE/* Enable this card */
    5158static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* PnP setup */
    5259static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
     
    5865
    5966module_param_array(index, int, NULL, 0444);
    60 MODULE_PARM_DESC(index, "Index value for als100 based soundcard.");
     67MODULE_PARM_DESC(index, "Index value for Avance Logic based soundcard.");
    6168module_param_array(id, charp, NULL, 0444);
    62 MODULE_PARM_DESC(id, "ID string for als100 based soundcard.");
     69MODULE_PARM_DESC(id, "ID string for Avance Logic based soundcard.");
    6370module_param_array(enable, bool, NULL, 0444);
    64 MODULE_PARM_DESC(enable, "Enable als100 based soundcard.");
     71MODULE_PARM_DESC(enable, "Enable Avance Logic based soundcard.");
     72
     73MODULE_ALIAS("snd-dt019x");
    6574
    6675struct snd_card_als100 {
    67         int dev_no;
    6876        struct pnp_dev *dev;
    6977        struct pnp_dev *devmpu;
     
    7381
    7482static struct pnp_card_device_id snd_als100_pnpids[] = {
     83        /* DT197A30 */
     84        { .id = "RWB1688",
     85          .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } },
     86          .driver_data = SB_HW_DT019X },
     87        /* DT0196 / ALS-007 */
     88        { .id = "ALS0007",
     89          .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } },
     90          .driver_data = SB_HW_DT019X },
    7591        /* ALS100 - PRO16PNP */
    76         { .id = "ALS0001", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } } },
     92        { .id = "ALS0001",
     93          .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" } },
     94          .driver_data = SB_HW_ALS100 },
    7795        /* ALS110 - MF1000 - Digimate 3D Sound */
    78         { .id = "ALS0110", .devs = { { "@@@1001" }, { "@X@1001" }, { "@H@1001" } } },
     96        { .id = "ALS0110",
     97          .devs = { { "@@@1001" }, { "@X@1001" }, { "@H@1001" } },
     98          .driver_data = SB_HW_ALS100 },
    7999        /* ALS120 */
    80         { .id = "ALS0120", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } },
     100        { .id = "ALS0120",
     101          .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } },
     102          .driver_data = SB_HW_ALS100 },
    81103        /* ALS200 */
    82         { .id = "ALS0200", .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0001" } } },
     104        { .id = "ALS0200",
     105          .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0001" } },
     106          .driver_data = SB_HW_ALS100 },
    83107        /* ALS200 OEM */
    84         { .id = "ALS0200", .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0020" } } },
     108        { .id = "ALS0200",
     109          .devs = { { "@@@0020" }, { "@X@0020" }, { "@H@0020" } },
     110          .driver_data = SB_HW_ALS100 },
    85111        /* RTL3000 */
    86         { .id = "RTL3000", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } },
    87         { .id = "", } /* end */
     112        { .id = "RTL3000",
     113          .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } },
     114          .driver_data = SB_HW_ALS100 },
     115        { .id = "" } /* end */
    88116};
    89117
    90118MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids);
    91 
    92 #define DRIVER_NAME     "snd-card-als100"
    93119
    94120static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard,
     
    114140        }
    115141        port[dev] = pnp_port_start(pdev, 0);
    116         dma8[dev] = pnp_dma(pdev, 1);
    117         dma16[dev] = pnp_dma(pdev, 0);
     142        if (id->driver_data == SB_HW_DT019X)
     143                dma8[dev] = pnp_dma(pdev, 0);
     144        else {
     145                dma8[dev] = pnp_dma(pdev, 1);
     146                dma16[dev] = pnp_dma(pdev, 0);
     147        }
    118148        irq[dev] = pnp_irq(pdev, 0);
    119149
     
    176206        snd_card_set_dev(card, &pcard->card->dev);
    177207
    178         if ((error = snd_sbdsp_create(card, port[dev],
    179                                       irq[dev],
    180                                       snd_sb16dsp_interrupt,
    181                                       dma8[dev],
    182                                       dma16[dev],
    183                                       SB_HW_ALS100, &chip)) < 0) {
     208        if (pid->driver_data == SB_HW_DT019X)
     209                dma16[dev] = -1;
     210
     211        error = snd_sbdsp_create(card, port[dev], irq[dev],
     212                                  snd_sb16dsp_interrupt,
     213                                  dma8[dev], dma16[dev],
     214                                  pid->driver_data,
     215                                  &chip);
     216        if (error < 0) {
    184217                snd_card_free(card);
    185218                return error;
     
    187220        acard->chip = chip;
    188221
    189         strcpy(card->driver, "ALS100");
    190         strcpy(card->shortname, "Avance Logic ALS100");
    191         sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d",
    192                 card->shortname, chip->name, chip->port,
    193                 irq[dev], dma8[dev], dma16[dev]);
     222        if (pid->driver_data == SB_HW_DT019X) {
     223                strcpy(card->driver, "DT-019X");
     224                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]);
     228        } else {
     229                strcpy(card->driver, "ALS100");
     230                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        }
    194235
    195236        if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) {
     
    204245
    205246        if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
    206                 if (snd_mpu401_uart_new(card, 0, MPU401_HW_ALS100,
     247                int mpu_type = MPU401_HW_ALS100;
     248
     249                if (mpu_irq[dev] == SNDRV_AUTO_IRQ)
     250                        mpu_irq[dev] = -1;
     251
     252                if (pid->driver_data == SB_HW_DT019X)
     253                        mpu_type = MPU401_HW_MPU401;
     254
     255                if (snd_mpu401_uart_new(card, 0,
     256                                        mpu_type,
    207257                                        mpu_port[dev], 0,
    208                                         mpu_irq[dev], IRQF_DISABLED,
     258                                        mpu_irq[dev],
     259                                        mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0,
    209260                                        NULL) < 0)
    210261                        snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]);
     
    292343static struct pnp_card_driver als100_pnpc_driver = {
    293344        .flags          = PNP_DRIVER_RES_DISABLE,
    294         .name           = "als100",
     345        .name           = "als100",
    295346        .id_table       = snd_als100_pnpids,
    296347        .probe          = snd_als100_pnp_detect,
     
    313364                pnp_unregister_card_driver(&als100_pnpc_driver);
    314365#ifdef MODULE
    315                 snd_printk(KERN_ERR "no ALS100 based soundcards found\n");
     366                snd_printk(KERN_ERR "no Avance Logic based soundcards found\n");
    316367#endif
    317368                return -ENODEV;
  • GPL/trunk/alsa-kernel/isa/azt2320.c

    r410 r598  
    189189        if (error < 0)
    190190                return error;
    191         acard = (struct snd_card_azt2320 *)card->private_data;
     191        acard = card->private_data;
    192192
    193193        if ((error = snd_card_azt2320_pnp(dev, acard, pcard, pid))) {
  • GPL/trunk/alsa-kernel/isa/cmi8330.c

    r464 r598  
    4747#include <linux/err.h>
    4848#include <linux/isa.h>
    49 #include <linux/slab.h>
    5049#include <linux/pnp.h>
    5150#include <linux/moduleparam.h>
     
    238237WSS_SINGLE("3D Control - Switch", 0,
    239238                CMI8330_RMUX3D, 5, 1, 1),
    240 WSS_SINGLE("PC Speaker Playback Volume", 0,
     239WSS_SINGLE("Beep Playback Volume", 0,
    241240                CMI8330_OUTPUTVOL, 3, 3, 0),
    242241WSS_DOUBLE("FM Playback Switch", 0,
     
    263262SB_SINGLE("SB Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1),
    264263SB_SINGLE("SB Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31),
    265 SB_SINGLE("SB PC Speaker Volume", SB_DSP4_SPEAKER_DEV, 6, 3),
     264SB_SINGLE("SB Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3),
    266265SB_DOUBLE("SB Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3),
    267266SB_DOUBLE("SB Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3),
  • GPL/trunk/alsa-kernel/isa/cs423x/cs4236.c

    r426 r598  
    2323#include <linux/err.h>
    2424#include <linux/isa.h>
    25 #include <linux/slab.h>
    2625#include <linux/pnp.h>
    2726#include <linux/moduleparam.h>
     
    178177        /* Digital PC 5000 Onboard - CS4236B */
    179178        { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } },
    180         /* some uknown CS4236B */
     179        /* some unknown CS4236B */
    181180        { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } },
    182181        /* Intel PR440FX Onboard sound */
     
    395394                }
    396395
    397         err = snd_wss_create(card, port[dev], cport[dev],
     396        err = snd_cs4236_create(card, port[dev], cport[dev],
    398397                             irq[dev],
    399398                             dma1[dev], dma2[dev],
     
    401400        if (err < 0)
    402401                return err;
     402
     403        acard->chip = chip;
    403404        if (chip->hardware & WSS_HW_CS4236B_MASK) {
    404                 snd_wss_free(chip);
    405                 err = snd_cs4236_create(card,
    406                                         port[dev], cport[dev],
    407                                         irq[dev], dma1[dev], dma2[dev],
    408                                         WSS_HW_DETECT, 0, &chip);
    409                 if (err < 0)
    410                         return err;
    411                 acard->chip = chip;
    412405
    413406                err = snd_cs4236_pcm(chip, 0, &pcm);
     
    419412                        return err;
    420413        } else {
    421                 acard->chip = chip;
    422414                err = snd_wss_pcm(chip, 0, &pcm);
    423415                if (err < 0)
  • GPL/trunk/alsa-kernel/isa/cs423x/cs4236_lib.c

    r426 r598  
    8888#include <sound/wss.h>
    8989#include <sound/asoundef.h>
     90#include <sound/initval.h>
     91#include <sound/tlv.h>
    9092
    9193/*
     
    265267
    266268#endif /* CONFIG_PM */
    267 
     269/*
     270 * This function does no fail if the chip is not CS4236B or compatible.
     271 * It just an equivalent to the snd_wss_create() then.
     272 */
    268273int snd_cs4236_create(struct snd_card *card,
    269274                      unsigned long port,
     
    282287        if (hardware == WSS_HW_DETECT)
    283288                hardware = WSS_HW_DETECT3;
    284         if (cport < 0x100) {
    285                 snd_printk(KERN_ERR "please, specify control port "
    286                            "for CS4236+ chips\n");
    287                 return -ENODEV;
    288         }
     289
    289290        err = snd_wss_create(card, port, cport,
    290291                             irq, dma1, dma2, hardware, hwshare, &chip);
     
    292293                return err;
    293294
    294         if (!(chip->hardware & WSS_HW_CS4236B_MASK)) {
    295                 snd_printk(KERN_ERR "CS4236+: MODE3 and extended registers "
    296                            "not available, hardware=0x%x\n", chip->hardware);
    297                 snd_device_free(card, chip);
    298                 return -ENODEV;
     295        if ((chip->hardware & WSS_HW_CS4236B_MASK) == 0) {
     296                snd_printd("chip is not CS4236+, hardware=0x%x\n",
     297                           chip->hardware);
     298                *rchip = chip;
     299                return 0;
    299300        }
    300301#if 0
     
    309310        }
    310311#endif
     312        if (cport < 0x100 || cport == SNDRV_AUTO_PORT) {
     313                snd_printk(KERN_ERR "please, specify control port "
     314                           "for CS4236+ chips\n");
     315                snd_device_free(card, chip);
     316                return -ENODEV;
     317        }
    311318        ver1 = snd_cs4236_ctrl_in(chip, 1);
    312319        ver2 = snd_cs4236_ext_in(chip, CS4236_VERSION);
    313         snd_printdd("CS4236: [0x%lx] C1 (version) = 0x%x, ext = 0x%x\n", cport, ver1, ver2);
     320        snd_printdd("CS4236: [0x%lx] C1 (version) = 0x%x, ext = 0x%x\n",
     321                        cport, ver1, ver2);
    314322        if (ver1 != ver2) {
    315323                snd_printk(KERN_ERR "CS4236+ chip detected, but "
     
    322330        snd_cs4236_ctrl_out(chip, 3, 0x00);
    323331        snd_cs4236_ctrl_out(chip, 4, 0x80);
    324         snd_cs4236_ctrl_out(chip, 5, ((IEC958_AES1_CON_PCM_CODER & 3) << 6) | IEC958_AES0_CON_EMPHASIS_NONE);
     332        reg = ((IEC958_AES1_CON_PCM_CODER & 3) << 6) |
     333              IEC958_AES0_CON_EMPHASIS_NONE;
     334        snd_cs4236_ctrl_out(chip, 5, reg);
    325335        snd_cs4236_ctrl_out(chip, 6, IEC958_AES1_CON_PCM_CODER >> 2);
    326336        snd_cs4236_ctrl_out(chip, 7, 0x00);
    327         /* 0x8c for C8 is valid for Turtle Beach Malibu - the IEC-958 output */
    328         /* is working with this setup, other hardware should have */
    329         /* different signal paths and this value should be selectable */
    330         /* in the future */
     337        /*
     338         * 0x8c for C8 is valid for Turtle Beach Malibu - the IEC-958
     339         * output is working with this setup, other hardware should
     340         * have different signal paths and this value should be
     341         * selectable in the future
     342         */
    331343        snd_cs4236_ctrl_out(chip, 8, 0x8c);
    332344        chip->rate_constraint = snd_cs4236_xrate;
     
    340352        /* initialize extended registers */
    341353        for (reg = 0; reg < sizeof(snd_cs4236_ext_map); reg++)
    342                 snd_cs4236_ext_out(chip, CS4236_I23VAL(reg), snd_cs4236_ext_map[reg]);
    343 
    344         /* initialize compatible but more featured registers */
     354                snd_cs4236_ext_out(chip, CS4236_I23VAL(reg),
     355                                   snd_cs4236_ext_map[reg]);
     356
     357        /* initialize compatible but more featured registers */
    345358        snd_wss_out(chip, CS4231_LEFT_INPUT, 0x40);
    346359        snd_wss_out(chip, CS4231_RIGHT_INPUT, 0x40);
     
    388401  .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
    389402
     403#define CS4236_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \
     404{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
     405  .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
     406  .info = snd_cs4236_info_single, \
     407  .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \
     408  .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24), \
     409  .tlv = { .p = (xtlv) } }
     410
    390411static int snd_cs4236_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    391412{
     
    490511  .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \
    491512  .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
     513
     514#define CS4236_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, \
     515                          shift_right, mask, invert, xtlv) \
     516{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
     517  .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
     518  .info = snd_cs4236_info_double, \
     519  .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \
     520  .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | \
     521                   (shift_right << 19) | (mask << 24) | (invert << 22), \
     522  .tlv = { .p = (xtlv) } }
    492523
    493524static int snd_cs4236_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
     
    561592}
    562593
    563 #define CS4236_DOUBLE1(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
     594#define CS4236_DOUBLE1(xname, xindex, left_reg, right_reg, shift_left, \
     595                        shift_right, mask, invert) \
    564596{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
    565597  .info = snd_cs4236_info_double, \
    566598  .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \
    567599  .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
     600
     601#define CS4236_DOUBLE1_TLV(xname, xindex, left_reg, right_reg, shift_left, \
     602                           shift_right, mask, invert, xtlv) \
     603{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
     604  .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
     605  .info = snd_cs4236_info_double, \
     606  .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \
     607  .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | \
     608                   (shift_right << 19) | (mask << 24) | (invert << 22), \
     609  .tlv = { .p = (xtlv) } }
    568610
    569611static int snd_cs4236_get_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
     
    620662}
    621663
    622 #define CS4236_MASTER_DIGITAL(xname, xindex) \
     664#define CS4236_MASTER_DIGITAL(xname, xindex, xtlv) \
    623665{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
     666  .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
    624667  .info = snd_cs4236_info_double, \
    625668  .get = snd_cs4236_get_master_digital, .put = snd_cs4236_put_master_digital, \
    626   .private_value = 71 << 24 }
     669  .private_value = 71 << 24, \
     670  .tlv = { .p = (xtlv) } }
    627671
    628672static inline int snd_cs4236_mixer_master_digital_invert_volume(int vol)
    629673{
    630674        return (vol < 64) ? 63 - vol : 64 + (71 - vol);
    631 }       
     675}
    632676
    633677static int snd_cs4236_get_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
     
    662706}
    663707
    664 #define CS4235_OUTPUT_ACCU(xname, xindex) \
     708#define CS4235_OUTPUT_ACCU(xname, xindex, xtlv) \
    665709{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
     710  .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
    666711  .info = snd_cs4236_info_double, \
    667712  .get = snd_cs4235_get_output_accu, .put = snd_cs4235_put_output_accu, \
    668   .private_value = 3 << 24 }
     713  .private_value = 3 << 24, \
     714  .tlv = { .p = (xtlv) } }
    669715
    670716static inline int snd_cs4235_mixer_output_accu_get_volume(int vol)
     
    721767}
    722768
     769static const DECLARE_TLV_DB_SCALE(db_scale_7bit, -9450, 150, 0);
     770static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
     771static const DECLARE_TLV_DB_SCALE(db_scale_6bit_12db_max, -8250, 150, 0);
     772static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
     773static const DECLARE_TLV_DB_SCALE(db_scale_5bit_22db_max, -2400, 150, 0);
     774static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
     775static const DECLARE_TLV_DB_SCALE(db_scale_2bit, -1800, 600, 0);
     776static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
     777
    723778static struct snd_kcontrol_new snd_cs4236_controls[] = {
    724779
     
    727782CS4236_DOUBLE("Master Digital Capture Switch", 0,
    728783                CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1),
    729 CS4236_MASTER_DIGITAL("Master Digital Volume", 0),
    730 
    731 CS4236_DOUBLE("Capture Boost Volume", 0,
    732                 CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1),
     784CS4236_MASTER_DIGITAL("Master Digital Volume", 0, db_scale_7bit),
     785
     786CS4236_DOUBLE_TLV("Capture Boost Volume", 0,
     787                  CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1,
     788                  db_scale_2bit),
    733789
    734790WSS_DOUBLE("PCM Playback Switch", 0,
    735791                CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
    736 WSS_DOUBLE("PCM Playback Volume", 0,
    737                 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1),
     792WSS_DOUBLE_TLV("PCM Playback Volume", 0,
     793                CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1,
     794                db_scale_6bit),
    738795
    739796CS4236_DOUBLE("DSP Playback Switch", 0,
    740797                CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1),
    741 CS4236_DOUBLE("DSP Playback Volume", 0,
    742                 CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 0, 0, 63, 1),
     798CS4236_DOUBLE_TLV("DSP Playback Volume", 0,
     799                  CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 0, 0, 63, 1,
     800                  db_scale_6bit),
    743801
    744802CS4236_DOUBLE("FM Playback Switch", 0,
    745803                CS4236_LEFT_FM, CS4236_RIGHT_FM, 7, 7, 1, 1),
    746 CS4236_DOUBLE("FM Playback Volume", 0,
    747                 CS4236_LEFT_FM, CS4236_RIGHT_FM, 0, 0, 63, 1),
     804CS4236_DOUBLE_TLV("FM Playback Volume", 0,
     805                  CS4236_LEFT_FM, CS4236_RIGHT_FM, 0, 0, 63, 1,
     806                  db_scale_6bit),
    748807
    749808CS4236_DOUBLE("Wavetable Playback Switch", 0,
    750809                CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 7, 7, 1, 1),
    751 CS4236_DOUBLE("Wavetable Playback Volume", 0,
    752                 CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 0, 0, 63, 1),
     810CS4236_DOUBLE_TLV("Wavetable Playback Volume", 0,
     811                  CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 0, 0, 63, 1,
     812                  db_scale_6bit_12db_max),
    753813
    754814WSS_DOUBLE("Synth Playback Switch", 0,
    755815                CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1),
    756 WSS_DOUBLE("Synth Volume", 0,
    757                 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1),
     816WSS_DOUBLE_TLV("Synth Volume", 0,
     817                CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1,
     818                db_scale_5bit_12db_max),
    758819WSS_DOUBLE("Synth Capture Switch", 0,
    759820                CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1),
     
    765826CS4236_DOUBLE("Mic Capture Switch", 0,
    766827                CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1),
    767 CS4236_DOUBLE("Mic Volume", 0, CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 0, 0, 31, 1),
    768 CS4236_DOUBLE("Mic Playback Boost", 0,
     828CS4236_DOUBLE_TLV("Mic Volume", 0, CS4236_LEFT_MIC, CS4236_RIGHT_MIC,
     829                  0, 0, 31, 1, db_scale_5bit_22db_max),
     830CS4236_DOUBLE("Mic Playback Boost (+20dB)", 0,
    769831                CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 5, 5, 1, 0),
    770832
    771833WSS_DOUBLE("Line Playback Switch", 0,
    772834                CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1),
    773 WSS_DOUBLE("Line Volume", 0,
    774                 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1),
     835WSS_DOUBLE_TLV("Line Volume", 0,
     836                CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1,
     837                db_scale_5bit_12db_max),
    775838WSS_DOUBLE("Line Capture Switch", 0,
    776839                CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1),
     
    780843WSS_DOUBLE("CD Playback Switch", 0,
    781844                CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
    782 WSS_DOUBLE("CD Volume", 0,
    783                 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1),
     845WSS_DOUBLE_TLV("CD Volume", 0,
     846                CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1,
     847                db_scale_5bit_12db_max),
    784848WSS_DOUBLE("CD Capture Switch", 0,
    785849                CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1),
     
    787851CS4236_DOUBLE1("Mono Output Playback Switch", 0,
    788852                CS4231_MONO_CTRL, CS4236_RIGHT_MIX_CTRL, 6, 7, 1, 1),
    789 CS4236_DOUBLE1("Mono Playback Switch", 0,
     853CS4236_DOUBLE1("Beep Playback Switch", 0,
    790854                CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1),
    791 WSS_SINGLE("Mono Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1),
    792 WSS_SINGLE("Mono Playback Bypass", 0, CS4231_MONO_CTRL, 5, 1, 0),
    793 
    794 WSS_DOUBLE("Capture Volume", 0,
    795                 CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0),
     855WSS_SINGLE_TLV("Beep Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1,
     856                db_scale_4bit),
     857WSS_SINGLE("Beep Bypass Playback Switch", 0, CS4231_MONO_CTRL, 5, 1, 0),
     858
     859WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT,
     860                0, 0, 15, 0, db_scale_rec_gain),
    796861WSS_DOUBLE("Analog Loopback Capture Switch", 0,
    797862                CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0),
    798863
    799 WSS_SINGLE("Digital Loopback Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0),
    800 CS4236_DOUBLE1("Digital Loopback Playback Volume", 0,
    801                 CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1)
     864WSS_SINGLE("Loopback Digital Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0),
     865CS4236_DOUBLE1_TLV("Loopback Digital Playback Volume", 0,
     866                   CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1,
     867                   db_scale_6bit),
    802868};
    803869
     870static const DECLARE_TLV_DB_SCALE(db_scale_5bit_6db_max, -5600, 200, 0);
     871static const DECLARE_TLV_DB_SCALE(db_scale_2bit_16db_max, -2400, 800, 0);
     872
    804873static struct snd_kcontrol_new snd_cs4235_controls[] = {
    805874
    806 WSS_DOUBLE("Master Switch", 0,
     875WSS_DOUBLE("Master Playback Switch", 0,
    807876                CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1),
    808 WSS_DOUBLE("Master Volume", 0,
    809                 CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1),
    810 
    811 CS4235_OUTPUT_ACCU("Playback Volume", 0),
    812 
    813 CS4236_DOUBLE("Master Digital Playback Switch", 0,
    814                 CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1),
    815 CS4236_DOUBLE("Master Digital Capture Switch", 0,
     877WSS_DOUBLE_TLV("Master Playback Volume", 0,
     878                CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1,
     879                db_scale_5bit_6db_max),
     880
     881CS4235_OUTPUT_ACCU("Playback Volume", 0, db_scale_2bit_16db_max),
     882
     883WSS_DOUBLE("Synth Playback Switch", 1,
     884                CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1),
     885WSS_DOUBLE("Synth Capture Switch", 1,
     886                CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1),
     887WSS_DOUBLE_TLV("Synth Volume", 1,
     888                CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1,
     889                db_scale_5bit_12db_max),
     890
     891CS4236_DOUBLE_TLV("Capture Volume", 0,
     892                  CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1,
     893                  db_scale_2bit),
     894
     895WSS_DOUBLE("PCM Playback Switch", 0,
     896                CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
     897WSS_DOUBLE("PCM Capture Switch", 0,
    816898                CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1),
    817 CS4236_MASTER_DIGITAL("Master Digital Volume", 0),
    818 
    819 WSS_DOUBLE("Master Digital Playback Switch", 1,
    820                 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1),
    821 WSS_DOUBLE("Master Digital Capture Switch", 1,
    822                 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1),
    823 WSS_DOUBLE("Master Digital Volume", 1,
    824                 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1),
    825 
    826 CS4236_DOUBLE("Capture Volume", 0,
    827                 CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1),
    828 
    829 WSS_DOUBLE("PCM Switch", 0,
    830                 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
    831 WSS_DOUBLE("PCM Volume", 0,
    832                 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1),
     899WSS_DOUBLE_TLV("PCM Volume", 0,
     900                CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1,
     901                db_scale_6bit),
    833902
    834903CS4236_DOUBLE("DSP Switch", 0, CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1),
     
    843912CS4236_DOUBLE("Mic Playback Switch", 0,
    844913                CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1),
    845 CS4236_SINGLE("Mic Volume", 0, CS4236_LEFT_MIC, 0, 31, 1),
    846 CS4236_SINGLE("Mic Playback Boost", 0, CS4236_LEFT_MIC, 5, 1, 0),
    847 
    848 WSS_DOUBLE("Aux Playback Switch", 0,
     914CS4236_SINGLE_TLV("Mic Volume", 0, CS4236_LEFT_MIC, 0, 31, 1,
     915                  db_scale_5bit_22db_max),
     916CS4236_SINGLE("Mic Boost (+20dB)", 0, CS4236_LEFT_MIC, 5, 1, 0),
     917
     918WSS_DOUBLE("Line Playback Switch", 0,
    849919                CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1),
    850 WSS_DOUBLE("Aux Capture Switch", 0,
     920WSS_DOUBLE("Line Capture Switch", 0,
    851921                CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1),
    852 WSS_DOUBLE("Aux Volume", 0,
    853                 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1),
    854 
    855 WSS_DOUBLE("Aux Playback Switch", 1,
     922WSS_DOUBLE_TLV("Line Volume", 0,
     923                CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1,
     924                db_scale_5bit_12db_max),
     925
     926WSS_DOUBLE("CD Playback Switch", 1,
    856927                CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
    857 WSS_DOUBLE("Aux Capture Switch", 1,
     928WSS_DOUBLE("CD Capture Switch", 1,
    858929                CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1),
    859 WSS_DOUBLE("Aux Volume", 1,
    860                 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1),
    861 
    862 CS4236_DOUBLE1("Master Mono Switch", 0,
    863                 CS4231_MONO_CTRL, CS4236_RIGHT_MIX_CTRL, 6, 7, 1, 1),
    864 
    865 CS4236_DOUBLE1("Mono Switch", 0,
     930WSS_DOUBLE_TLV("CD Volume", 1,
     931                CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1,
     932                db_scale_5bit_12db_max),
     933
     934CS4236_DOUBLE1("Beep Playback Switch", 0,
    866935                CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1),
    867 WSS_SINGLE("Mono Volume", 0, CS4231_MONO_CTRL, 0, 15, 1),
     936WSS_SINGLE("Beep Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1),
    868937
    869938WSS_DOUBLE("Analog Loopback Switch", 0,
  • GPL/trunk/alsa-kernel/isa/es1688/es1688.c

    r464 r598  
    2323#include <linux/err.h>
    2424#include <linux/isa.h>
     25#include <linux/isapnp.h>
    2526#include <linux/time.h>
    2627#include <linux/wait.h>
     
    4647                "{ESS,ES1688 AudioDrive,pnp:ESS1681}}");
    4748
     49MODULE_ALIAS("snd_es968");
     50
    4851static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    4952static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
     53#ifdef CONFIG_PNP
     54static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
     55#endif
    5056static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;  /* Enable this card */
    5157static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x240,0x260 */
     
    6167MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
    6268module_param_array(enable, bool, NULL, 0444);
     69#ifdef CONFIG_PNP
     70module_param_array(isapnp, bool, NULL, 0444);
     71MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard.");
     72#endif
    6373MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
    6474module_param_array(port, long, NULL, 0444);
     
    7585MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver.");
    7686
     87#ifdef CONFIG_PNP
     88#define is_isapnp_selected(dev)         isapnp[dev]
     89#else
     90#define is_isapnp_selected(dev)         0
     91#endif
     92
    7793static int __devinit snd_es1688_match(struct device *dev, unsigned int n)
    7894{
    79         return enable[n];
    80 }
    81 
    82 static int __devinit snd_es1688_legacy_create(struct snd_card *card,
    83                 struct device *dev, unsigned int n, struct snd_es1688 **rchip)
    84 {
     95        return enable[n] && !is_isapnp_selected(n);
     96}
     97
     98static int __devinit snd_es1688_legacy_create(struct snd_card *card,
     99                                        struct device *dev, unsigned int n)
     100{
     101        struct snd_es1688 *chip = card->private_data;
    85102        static long possible_ports[] = {0x220, 0x240, 0x260};
    86103        static int possible_irqs[] = {5, 9, 10, 7, -1};
     
    105122
    106123        if (port[n] != SNDRV_AUTO_PORT)
    107                 return snd_es1688_create(card, port[n], mpu_port[n], irq[n],
    108                                 mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip);
     124                return snd_es1688_create(card, chip, port[n], mpu_port[n],
     125                                irq[n], mpu_irq[n], dma8[n], ES1688_HW_AUTO);
    109126
    110127        i = 0;
    111128        do {
    112129                port[n] = possible_ports[i];
    113                 error = snd_es1688_create(card, port[n], mpu_port[n], irq[n],
    114                                 mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip);
     130                error = snd_es1688_create(card, chip, port[n], mpu_port[n],
     131                                irq[n], mpu_irq[n], dma8[n], ES1688_HW_AUTO);
    115132        } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
    116133
     
    118135}
    119136
    120 static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
    121 {
    122         struct snd_card *card;
    123         struct snd_es1688 *chip;
     137static int __devinit snd_es1688_probe(struct snd_card *card, unsigned int n)
     138{
     139        struct snd_es1688 *chip = card->private_data;
    124140        struct snd_opl3 *opl3;
    125141        struct snd_pcm *pcm;
    126142        int error;
    127143
    128         error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card);
    129         if (error < 0)
    130                 return error;
    131 
    132         error = snd_es1688_legacy_create(card, dev, n, &chip);
    133         if (error < 0)
    134                 goto out;
    135 
    136         error = snd_es1688_pcm(chip, 0, &pcm);
    137         if (error < 0)
    138                 goto out;
    139 
    140         error = snd_es1688_mixer(chip);
    141         if (error < 0)
    142                 goto out;
    143 
    144         strcpy(card->driver, "ES1688");
    145         strcpy(card->shortname, pcm->name);
    146         sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name,
    147                 chip->port, chip->irq, chip->dma8);
     144        error = snd_es1688_pcm(card, chip, 0, &pcm);
     145        if (error < 0)
     146                return error;
     147
     148        error = snd_es1688_mixer(card, chip);
     149        if (error < 0)
     150                return error;
     151
     152        strlcpy(card->driver, "ES1688", sizeof(card->driver));
     153        strlcpy(card->shortname, pcm->name, sizeof(card->shortname));
     154        snprintf(card->longname, sizeof(card->longname),
     155                "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port,
     156                 chip->irq, chip->dma8);
    148157
    149158        if (fm_port[n] == SNDRV_AUTO_PORT)
     
    153162                if (snd_opl3_create(card, fm_port[n], fm_port[n] + 2,
    154163                                OPL3_HW_OPL3, 0, &opl3) < 0)
    155                         dev_warn(dev,
     164                        dev_warn(card->dev,
    156165                                 "opl3 not detected at 0x%lx\n", fm_port[n]);
    157166                else {
    158167                        error = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
    159168                        if (error < 0)
    160                                 goto out;
     169                                return error;
    161170                }
    162171        }
     
    168177                                mpu_irq[n], IRQF_DISABLED, NULL);
    169178                if (error < 0)
    170                         goto out;
    171         }
     179                        return error;
     180        }
     181
     182        return snd_card_register(card);
     183}
     184
     185static int __devinit snd_es1688_isa_probe(struct device *dev, unsigned int n)
     186{
     187        struct snd_card *card;
     188        int error;
     189
     190        error = snd_card_create(index[n], id[n], THIS_MODULE,
     191                                sizeof(struct snd_es1688), &card);
     192        if (error < 0)
     193                return error;
     194
     195        error = snd_es1688_legacy_create(card, dev, n);
     196        if (error < 0)
     197                goto out;
    172198
    173199        snd_card_set_dev(card, dev);
    174200
    175         error = snd_card_register(card);
     201        error = snd_es1688_probe(card, n);
    176202        if (error < 0)
    177203                goto out;
    178204
    179205        dev_set_drvdata(dev, card);
    180         return 0;
    181 
    182 out:    snd_card_free(card);
     206
     207        return 0;
     208out:
     209        snd_card_free(card);
    183210        return error;
    184211}
    185212
    186 static int __devexit snd_es1688_remove(struct device *dev, unsigned int n)
     213static int __devexit snd_es1688_isa_remove(struct device *dev, unsigned int n)
    187214{
    188215        snd_card_free(dev_get_drvdata(dev));
     
    193220static struct isa_driver snd_es1688_driver = {
    194221        .match          = snd_es1688_match,
    195         .probe          = snd_es1688_probe,
    196         .remove         = __devexit_p(snd_es1688_remove),
     222        .probe          = snd_es1688_isa_probe,
     223        .remove         = __devexit_p(snd_es1688_isa_remove),
    197224#if 0   /* FIXME */
    198225        .suspend        = snd_es1688_suspend,
     
    204231};
    205232
     233static int snd_es968_pnp_is_probed;
     234
     235#ifdef CONFIG_PNP
     236static 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)
     239{
     240        struct snd_es1688 *chip = card->private_data;
     241        struct pnp_dev *pdev;
     242        int error;
     243
     244        pdev = pnp_request_card_device(pcard, pid->devs[0].id, NULL);
     245        if (pdev == NULL)
     246                return -ENODEV;
     247
     248        error = pnp_activate_dev(pdev);
     249        if (error < 0) {
     250                snd_printk(KERN_ERR "ES968 pnp configure failure\n");
     251                return error;
     252        }
     253        port[n] = pnp_port_start(pdev, 0);
     254        dma8[n] = pnp_dma(pdev, 0);
     255        irq[n] = pnp_irq(pdev, 0);
     256
     257        return snd_es1688_create(card, chip, port[n], mpu_port[n], irq[n],
     258                                 mpu_irq[n], dma8[n], ES1688_HW_AUTO);
     259}
     260
     261static int __devinit snd_es968_pnp_detect(struct pnp_card_link *pcard,
     262                                          const struct pnp_card_device_id *pid)
     263{
     264        struct snd_card *card;
     265        static unsigned int dev;
     266        int error;
     267        struct snd_es1688 *chip;
     268
     269        if (snd_es968_pnp_is_probed)
     270                return -EBUSY;
     271        for ( ; dev < SNDRV_CARDS; dev++) {
     272                if (enable[dev] && isapnp[dev])
     273                        break;
     274        }
     275        if (dev == SNDRV_CARDS)
     276                return -ENODEV;
     277
     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;
     283
     284        error = snd_card_es968_pnp(card, dev, pcard, pid);
     285        if (error < 0) {
     286                snd_card_free(card);
     287                return error;
     288        }
     289        snd_card_set_dev(card, &pcard->card->dev);
     290        error = snd_es1688_probe(card, dev);
     291        if (error < 0)
     292                return error;
     293        pnp_set_card_drvdata(pcard, card);
     294        snd_es968_pnp_is_probed = 1;
     295        return 0;
     296}
     297
     298static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard)
     299{
     300        snd_card_free(pnp_get_card_drvdata(pcard));
     301        pnp_set_card_drvdata(pcard, NULL);
     302        snd_es968_pnp_is_probed = 0;
     303}
     304
     305#ifdef CONFIG_PM
     306static int snd_es968_pnp_suspend(struct pnp_card_link *pcard,
     307                                 pm_message_t state)
     308{
     309        struct snd_card *card = pnp_get_card_drvdata(pcard);
     310        struct snd_es1688 *chip = card->private_data;
     311
     312        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
     313        snd_pcm_suspend_all(chip->pcm);
     314        return 0;
     315}
     316
     317static int snd_es968_pnp_resume(struct pnp_card_link *pcard)
     318{
     319        struct snd_card *card = pnp_get_card_drvdata(pcard);
     320        struct snd_es1688 *chip = card->private_data;
     321
     322        snd_es1688_reset(chip);
     323        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
     324        return 0;
     325}
     326#endif
     327
     328static struct pnp_card_device_id snd_es968_pnpids[] = {
     329        { .id = "ESS0968", .devs = { { "@@@0968" }, } },
     330        { .id = "ESS0968", .devs = { { "ESS0968" }, } },
     331        { .id = "", } /* end */
     332};
     333
     334MODULE_DEVICE_TABLE(pnp_card, snd_es968_pnpids);
     335
     336static struct pnp_card_driver es968_pnpc_driver = {
     337        .flags          = PNP_DRIVER_RES_DISABLE,
     338        .name           = DEV_NAME " PnP",
     339        .id_table       = snd_es968_pnpids,
     340        .probe          = snd_es968_pnp_detect,
     341        .remove         = __devexit_p(snd_es968_pnp_remove),
     342#ifdef CONFIG_PM
     343        .suspend        = snd_es968_pnp_suspend,
     344        .resume         = snd_es968_pnp_resume,
     345#endif
     346};
     347#endif
     348
    206349static int __init alsa_card_es1688_init(void)
    207350{
     351#ifdef CONFIG_PNP
     352        pnp_register_card_driver(&es968_pnpc_driver);
     353        if (snd_es968_pnp_is_probed)
     354                return 0;
     355        pnp_unregister_card_driver(&es968_pnpc_driver);
     356#endif
    208357        return isa_register_driver(&snd_es1688_driver, SNDRV_CARDS);
    209358}
     
    211360static void __exit alsa_card_es1688_exit(void)
    212361{
    213         isa_unregister_driver(&snd_es1688_driver);
     362        if (!snd_es968_pnp_is_probed) {
     363                isa_unregister_driver(&snd_es1688_driver);
     364                return;
     365        }
     366#ifdef CONFIG_PNP
     367        pnp_unregister_card_driver(&es968_pnpc_driver);
     368#endif
    214369}
    215370
  • GPL/trunk/alsa-kernel/isa/es1688/es1688_lib.c

    r426 r598  
    100100}
    101101
    102 static int snd_es1688_reset(struct snd_es1688 *chip)
     102int snd_es1688_reset(struct snd_es1688 *chip)
    103103{
    104104        int i;
     
    116116        return 0;
    117117}
     118EXPORT_SYMBOL(snd_es1688_reset);
    118119
    119120static int snd_es1688_probe(struct snd_es1688 *chip)
     
    621622                free_dma(chip->dma8);
    622623        }
    623         kfree(chip);
    624624        return 0;
    625625}
     
    639639
    640640int snd_es1688_create(struct snd_card *card,
     641                      struct snd_es1688 *chip,
    641642                      unsigned long port,
    642643                      unsigned long mpu_port,
     
    644645                      int mpu_irq,
    645646                      int dma8,
    646                       unsigned short hardware,
    647                       struct snd_es1688 **rchip)
     647                      unsigned short hardware)
    648648{
    649649        static struct snd_device_ops ops = {
     
    651651        };
    652652                               
    653         struct snd_es1688 *chip;
    654653        int err;
    655654
    656         *rchip = NULL;
    657         chip = kzalloc(sizeof(*chip), GFP_KERNEL);
    658655        if (chip == NULL)
    659656                return -ENOMEM;
     
    663660        if ((chip->res_port = request_region(port + 4, 12, "ES1688")) == NULL) {
    664661                snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4);
    665                 snd_es1688_free(chip);
    666662                return -EBUSY;
    667663        }
    668664        if (request_irq(irq, snd_es1688_interrupt, IRQF_DISABLED, "ES1688", (void *) chip)) {
    669665                snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq);
    670                 snd_es1688_free(chip);
    671666                return -EBUSY;
    672667        }
     
    674669        if (request_dma(dma8, "ES1688")) {
    675670                snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8);
    676                 snd_es1688_free(chip);
    677671                return -EBUSY;
    678672        }
     
    681675        spin_lock_init(&chip->reg_lock);
    682676        spin_lock_init(&chip->mixer_lock);
    683         chip->card = card;
    684677        chip->port = port;
    685678        mpu_port &= ~0x000f;
     
    690683        chip->hardware = hardware;
    691684
    692         if ((err = snd_es1688_probe(chip)) < 0) {
    693                 snd_es1688_free(chip);
     685        err = snd_es1688_probe(chip);
     686        if (err < 0)
    694687                return err;
    695         }
    696         if ((err = snd_es1688_init(chip, 1)) < 0) {
    697                 snd_es1688_free(chip);
     688
     689        err = snd_es1688_init(chip, 1);
     690        if (err < 0)
    698691                return err;
    699         }
    700692
    701693        /* Register device */
    702         if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
    703                 snd_es1688_free(chip);
    704                 return err;
    705         }
    706 
    707         *rchip = chip;
    708         return 0;
     694        return snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
    709695}
    710696
     
    731717};
    732718
    733 int snd_es1688_pcm(struct snd_es1688 * chip, int device, struct snd_pcm ** rpcm)
     719int snd_es1688_pcm(struct snd_card *card, struct snd_es1688 *chip,
     720                   int device, struct snd_pcm **rpcm)
    734721{
    735722        struct snd_pcm *pcm;
    736723        int err;
    737724
    738         if ((err = snd_pcm_new(chip->card, "ESx688", device, 1, 1, &pcm)) < 0)
     725        err = snd_pcm_new(card, "ESx688", device, 1, 1, &pcm);
     726        if (err < 0)
    739727                return err;
    740728
     
    983971ES1688_DOUBLE("Mic Playback Volume", 0, ES1688_MIC_DEV, ES1688_MIC_DEV, 4, 0, 15, 0),
    984972ES1688_DOUBLE("Aux Playback Volume", 0, ES1688_AUX_DEV, ES1688_AUX_DEV, 4, 0, 15, 0),
    985 ES1688_SINGLE("PC Speaker Playback Volume", 0, ES1688_SPEAKER_DEV, 0, 7, 0),
     973ES1688_SINGLE("Beep Playback Volume", 0, ES1688_SPEAKER_DEV, 0, 7, 0),
    986974ES1688_DOUBLE("Capture Volume", 0, ES1688_RECLEV_DEV, ES1688_RECLEV_DEV, 4, 0, 15, 0),
    987975ES1688_SINGLE("Capture Switch", 0, ES1688_REC_DEV, 4, 1, 1),
     
    1010998};
    1011999                                       
    1012 int snd_es1688_mixer(struct snd_es1688 *chip)
    1013 {
    1014         struct snd_card *card;
     1000int snd_es1688_mixer(struct snd_card *card, struct snd_es1688 *chip)
     1001{
    10151002        unsigned int idx;
    10161003        int err;
    10171004        unsigned char reg, val;
    10181005
    1019         if (snd_BUG_ON(!chip || !chip->card))
     1006        if (snd_BUG_ON(!chip || !card))
    10201007                return -EINVAL;
    1021 
    1022         card = chip->card;
    10231008
    10241009        strcpy(card->mixername, snd_es1688_chip_id(chip));
  • GPL/trunk/alsa-kernel/isa/es18xx.c

    r410 r598  
    8181#include <linux/err.h>
    8282#include <linux/isa.h>
    83 #include <linux/slab.h>
    8483#include <linux/pnp.h>
    8584#include <linux/isapnp.h>
     
    103102struct snd_es18xx {
    104103        unsigned long port;             /* port of ESS chip */
    105         unsigned long mpu_port;         /* MPU-401 port of ESS chip */
    106         unsigned long fm_port;          /* FM port */
    107104        unsigned long ctrl_port;        /* Control port of ESS chip */
    108105        struct resource *res_port;
     
    117114
    118115        unsigned short active;          /* active channel mask */
    119         unsigned int dma1_size;
    120         unsigned int dma2_size;
    121116        unsigned int dma1_shift;
    122117        unsigned int dma2_shift;
    123118
    124         struct snd_card *card;
    125119        struct snd_pcm *pcm;
    126120        struct snd_pcm_substream *playback_a_substream;
     
    137131        spinlock_t reg_lock;
    138132        spinlock_t mixer_lock;
    139         spinlock_t ctrl_lock;
    140133#ifdef CONFIG_PM
    141134        unsigned char pm_reg;
    142135#endif
    143 };
    144 
    145 struct snd_audiodrive {
    146         struct snd_es18xx *chip;
    147136#ifdef CONFIG_PNP
    148137        struct pnp_dev *dev;
     
    360349
    361350
    362 static int snd_es18xx_reset(struct snd_es18xx *chip)
     351static int __devinit snd_es18xx_reset(struct snd_es18xx *chip)
    363352{
    364353        int i;
     
    495484        unsigned int size = snd_pcm_lib_buffer_bytes(substream);
    496485        unsigned int count = snd_pcm_lib_period_bytes(substream);
    497 
    498         chip->dma2_size = size;
    499486
    500487        snd_es18xx_rate_set(chip, substream, DAC2);
     
    597584        unsigned int count = snd_pcm_lib_period_bytes(substream);
    598585
    599         chip->dma1_size = size;
    600 
    601586        snd_es18xx_reset_fifo(chip);
    602587
     
    665650        unsigned int count = snd_pcm_lib_period_bytes(substream);
    666651
    667         chip->dma1_size = size;
    668 
    669652        snd_es18xx_reset_fifo(chip);
    670653
     
    756739static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id)
    757740{
    758         struct snd_es18xx *chip = dev_id;
     741        struct snd_card *card = dev_id;
     742        struct snd_es18xx *chip = card->private_data;
    759743        unsigned char status;
    760744
     
    806790                if (chip->caps & ES18XX_HWV) {
    807791                        split = snd_es18xx_mixer_read(chip, 0x64) & 0x80;
    808                         snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id);
    809                         snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id);
     792                        snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
     793                                        &chip->hw_switch->id);
     794                        snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
     795                                        &chip->hw_volume->id);
    810796                }
    811797                if (!split) {
    812                         snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_switch->id);
    813                         snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id);
     798                        snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
     799                                        &chip->master_switch->id);
     800                        snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
     801                                        &chip->master_volume->id);
    814802                }
    815803                /* ack interrupt */
     
    822810{
    823811        struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
     812        unsigned int size = snd_pcm_lib_buffer_bytes(substream);
    824813        int pos;
    825814
     
    827816                if (!(chip->active & DAC2))
    828817                        return 0;
    829                 pos = snd_dma_pointer(chip->dma2, chip->dma2_size);
     818                pos = snd_dma_pointer(chip->dma2, size);
    830819                return pos >> chip->dma2_shift;
    831820        } else {
    832821                if (!(chip->active & DAC1))
    833822                        return 0;
    834                 pos = snd_dma_pointer(chip->dma1, chip->dma1_size);
     823                pos = snd_dma_pointer(chip->dma1, size);
    835824                return pos >> chip->dma1_shift;
    836825        }
     
    840829{
    841830        struct snd_es18xx *chip = snd_pcm_substream_chip(substream);
     831        unsigned int size = snd_pcm_lib_buffer_bytes(substream);
    842832        int pos;
    843833
    844834        if (!(chip->active & ADC1))
    845835                return 0;
    846         pos = snd_dma_pointer(chip->dma1, chip->dma1_size);
     836        pos = snd_dma_pointer(chip->dma1, size);
    847837        return pos >> chip->dma1_shift;
    848838}
     
    975965static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
    976966{
    977         static char *texts4Source[4] = {
    978                 "Mic", "CD", "Line", "Master"
    979         };
    980967        static char *texts5Source[5] = {
    981968                "Mic", "CD", "Line", "Master", "Mix"
     
    995982                if (uinfo->value.enumerated.item > 3)
    996983                        uinfo->value.enumerated.item = 3;
    997                 strcpy(uinfo->value.enumerated.name, texts4Source[uinfo->value.enumerated.item]);
     984                strcpy(uinfo->value.enumerated.name,
     985                        texts5Source[uinfo->value.enumerated.item]);
    998986                break;
    999987        case 0x1887:
     
    13141302 */
    13151303static struct snd_kcontrol_new snd_es18xx_opt_speaker =
    1316         ES18XX_SINGLE("PC Speaker Playback Volume", 0, 0x3c, 0, 7, 0);
     1304        ES18XX_SINGLE("Beep Playback Volume", 0, 0x3c, 0, 7, 0);
    13171305
    13181306static struct snd_kcontrol_new snd_es18xx_opt_1869[] = {
     
    13791367{
    13801368        int data;
    1381         unsigned long flags;
    1382         spin_lock_irqsave(&chip->ctrl_lock, flags);
     1369
    13831370        outb(reg, chip->ctrl_port);
    13841371        data = inb(chip->ctrl_port + 1);
    1385         spin_unlock_irqrestore(&chip->ctrl_lock, flags);
    13861372        return data;
    13871373}
     
    13991385}
    14001386
    1401 static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip)
     1387static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip,
     1388                                           unsigned long mpu_port,
     1389                                           unsigned long fm_port)
    14021390{
    14031391        int mask = 0;
     
    14131401                /* Hardware volume IRQ */
    14141402                snd_es18xx_config_write(chip, 0x27, chip->irq);
    1415                 if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) {
     1403                if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) {
    14161404                        /* FM I/O */
    1417                         snd_es18xx_config_write(chip, 0x62, chip->fm_port >> 8);
    1418                         snd_es18xx_config_write(chip, 0x63, chip->fm_port & 0xff);
     1405                        snd_es18xx_config_write(chip, 0x62, fm_port >> 8);
     1406                        snd_es18xx_config_write(chip, 0x63, fm_port & 0xff);
    14191407                }
    1420                 if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) {
     1408                if (mpu_port > 0 && mpu_port != SNDRV_AUTO_PORT) {
    14211409                        /* MPU-401 I/O */
    1422                         snd_es18xx_config_write(chip, 0x64, chip->mpu_port >> 8);
    1423                         snd_es18xx_config_write(chip, 0x65, chip->mpu_port & 0xff);
     1410                        snd_es18xx_config_write(chip, 0x64, mpu_port >> 8);
     1411                        snd_es18xx_config_write(chip, 0x65, mpu_port & 0xff);
    14241412                        /* MPU-401 IRQ */
    14251413                        snd_es18xx_config_write(chip, 0x28, chip->irq);
     
    15081496                /* Enable and set hardware volume interrupt */
    15091497                snd_es18xx_mixer_write(chip, 0x64, 0x06);
    1510                 if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) {
     1498                if (mpu_port > 0 && mpu_port != SNDRV_AUTO_PORT) {
    15111499                        /* MPU401 share irq with audio
    15121500                           Joystick enabled
    15131501                           FM enabled */
    1514                         snd_es18xx_mixer_write(chip, 0x40, 0x43 | (chip->mpu_port & 0xf0) >> 1);
     1502                        snd_es18xx_mixer_write(chip, 0x40,
     1503                                               0x43 | (mpu_port & 0xf0) >> 1);
    15151504                }
    15161505                snd_es18xx_mixer_write(chip, 0x7f, ((irqmask + 1) << 1) | 0x01);
     
    16301619}
    16311620
    1632 static int __devinit snd_es18xx_probe(struct snd_es18xx *chip)
     1621static int __devinit snd_es18xx_probe(struct snd_es18xx *chip,
     1622                                        unsigned long mpu_port,
     1623                                        unsigned long fm_port)
    16331624{
    16341625        if (snd_es18xx_identify(chip) < 0) {
     
    16511642                break;
    16521643        case 0x1887:
    1653                 chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME;
    1654                 break;
    16551644        case 0x1888:
    16561645                chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME;
     
    16671656                chip->caps &= ~(ES18XX_PCM2 | ES18XX_DUPLEX_SAME);
    16681657
    1669         return snd_es18xx_initialize(chip);
     1658        return snd_es18xx_initialize(chip, mpu_port, fm_port);
    16701659}
    16711660
     
    16921681};
    16931682
    1694 static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct snd_pcm ** rpcm)
    1695 {
     1683static int __devinit snd_es18xx_pcm(struct snd_card *card, int device,
     1684                                    struct snd_pcm **rpcm)
     1685{
     1686        struct snd_es18xx *chip = card->private_data;
    16961687        struct snd_pcm *pcm;
    16971688        char str[16];
     
    17021693        sprintf(str, "ES%x", chip->version);
    17031694        if (chip->caps & ES18XX_PCM2)
    1704                 err = snd_pcm_new(chip->card, str, device, 2, 1, &pcm);
     1695                err = snd_pcm_new(card, str, device, 2, 1, &pcm);
    17051696        else
    1706                 err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm);
     1697                err = snd_pcm_new(card, str, device, 1, 1, &pcm);
    17071698        if (err < 0)
    17081699                return err;
     
    17351726static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state)
    17361727{
    1737         struct snd_audiodrive *acard = card->private_data;
    1738         struct snd_es18xx *chip = acard->chip;
    1739 
    1740         snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
     1728        struct snd_es18xx *chip = card->private_data;
     1729
     1730        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    17411731
    17421732        snd_pcm_suspend_all(chip->pcm);
     
    17531743static int snd_es18xx_resume(struct snd_card *card)
    17541744{
    1755         struct snd_audiodrive *acard = card->private_data;
    1756         struct snd_es18xx *chip = acard->chip;
     1745        struct snd_es18xx *chip = card->private_data;
    17571746
    17581747        /* restore PM register, we won't wake till (not 0x07) i/o activity though */
    17591748        snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM);
    17601749
    1761         snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
     1750        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
    17621751        return 0;
    17631752}
    17641753#endif /* CONFIG_PM */
    17651754
    1766 static int snd_es18xx_free(struct snd_es18xx *chip)
    1767 {
     1755static int snd_es18xx_free(struct snd_card *card)
     1756{
     1757        struct snd_es18xx *chip = card->private_data;
     1758
    17681759        release_and_free_resource(chip->res_port);
    17691760        release_and_free_resource(chip->res_ctrl_port);
    17701761        release_and_free_resource(chip->res_mpu_port);
    17711762        if (chip->irq >= 0)
    1772                 free_irq(chip->irq, (void *) chip);
     1763                free_irq(chip->irq, (void *) card);
    17731764        if (chip->dma1 >= 0) {
    17741765                disable_dma(chip->dma1);
     
    17791770                free_dma(chip->dma2);
    17801771        }
    1781         kfree(chip);
    17821772        return 0;
    17831773}
     
    17851775static int snd_es18xx_dev_free(struct snd_device *device)
    17861776{
    1787         struct snd_es18xx *chip = device->device_data;
    1788         return snd_es18xx_free(chip);
     1777        return snd_es18xx_free(device->card);
    17891778}
    17901779
     
    17931782                                           unsigned long mpu_port,
    17941783                                           unsigned long fm_port,
    1795                                            int irq, int dma1, int dma2,
    1796                                            struct snd_es18xx ** rchip)
    1797 {
    1798         struct snd_es18xx *chip;
     1784                                           int irq, int dma1, int dma2)
     1785{
     1786        struct snd_es18xx *chip = card->private_data;
    17991787        static struct snd_device_ops ops = {
    18001788                .dev_free =     snd_es18xx_dev_free,
     
    18021790        int err;
    18031791
    1804         *rchip = NULL;
    1805         chip = kzalloc(sizeof(*chip), GFP_KERNEL);
    1806         if (chip == NULL)
    1807                 return -ENOMEM;
    18081792        spin_lock_init(&chip->reg_lock);
    18091793        spin_lock_init(&chip->mixer_lock);
    1810         spin_lock_init(&chip->ctrl_lock);
    1811         chip->card = card;
    18121794        chip->port = port;
    1813         chip->mpu_port = mpu_port;
    1814         chip->fm_port = fm_port;
    18151795        chip->irq = -1;
    18161796        chip->dma1 = -1;
     
    18191799        chip->active = 0;
    18201800
    1821         if ((chip->res_port = request_region(port, 16, "ES18xx")) == NULL) {
    1822                 snd_es18xx_free(chip);
     1801        chip->res_port = request_region(port, 16, "ES18xx");
     1802        if (chip->res_port == NULL) {
     1803                snd_es18xx_free(card);
    18231804                snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1);
    18241805                return -EBUSY;
    18251806        }
    18261807
    1827         if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", (void *) chip)) {
    1828                 snd_es18xx_free(chip);
     1808        if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx",
     1809                        (void *) card)) {
     1810                snd_es18xx_free(card);
    18291811                snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq);
    18301812                return -EBUSY;
     
    18331815
    18341816        if (request_dma(dma1, "ES18xx DMA 1")) {
    1835                 snd_es18xx_free(chip);
     1817                snd_es18xx_free(card);
    18361818                snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1);
    18371819                return -EBUSY;
     
    18401822
    18411823        if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) {
    1842                 snd_es18xx_free(chip);
     1824                snd_es18xx_free(card);
    18431825                snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2);
    18441826                return -EBUSY;
     
    18461828        chip->dma2 = dma2;
    18471829
    1848         if (snd_es18xx_probe(chip) < 0) {
    1849                 snd_es18xx_free(chip);
    1850                 return -ENODEV;
    1851         }
    1852         if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
    1853                 snd_es18xx_free(chip);
     1830        if (snd_es18xx_probe(chip, mpu_port, fm_port) < 0) {
     1831                snd_es18xx_free(card);
     1832                return -ENODEV;
     1833        }
     1834        err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
     1835        if (err < 0) {
     1836                snd_es18xx_free(card);
    18541837                return err;
    18551838        }
    1856         *rchip = chip;
    18571839        return 0;
    18581840}
    18591841
    1860 static int __devinit snd_es18xx_mixer(struct snd_es18xx *chip)
    1861 {
    1862         struct snd_card *card;
     1842static int __devinit snd_es18xx_mixer(struct snd_card *card)
     1843{
     1844        struct snd_es18xx *chip = card->private_data;
    18631845        int err;
    18641846        unsigned int idx;
    1865 
    1866         card = chip->card;
    18671847
    18681848        strcpy(card->mixername, chip->pcm->name);
     
    19871967static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
    19881968#ifdef CONFIG_PNP
    1989 static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
     1969static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP;
    19901970#endif
    19911971static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;     /* 0x220,0x240,0x260,0x280 */
     
    20642044}
    20652045
    2066 static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard,
     2046static int __devinit snd_audiodrive_pnp(int dev, struct snd_es18xx *chip,
    20672047                                        struct pnp_dev *pdev)
    20682048{
    2069         acard->dev = pdev;
    2070         if (snd_audiodrive_pnp_init_main(dev, acard->dev) < 0)
     2049        chip->dev = pdev;
     2050        if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0)
    20712051                return -EBUSY;
    20722052        return 0;
     
    20942074MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids);
    20952075
    2096 static int __devinit snd_audiodrive_pnpc(int dev, struct snd_audiodrive *acard,
     2076static int __devinit snd_audiodrive_pnpc(int dev, struct snd_es18xx *chip,
    20972077                                        struct pnp_card_link *card,
    20982078                                        const struct pnp_card_device_id *id)
    20992079{
    2100         acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
    2101         if (acard->dev == NULL)
     2080        chip->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
     2081        if (chip->dev == NULL)
    21022082                return -EBUSY;
    21032083
    2104         acard->devc = pnp_request_card_device(card, id->devs[1].id, NULL);
    2105         if (acard->devc == NULL)
     2084        chip->devc = pnp_request_card_device(card, id->devs[1].id, NULL);
     2085        if (chip->devc == NULL)
    21062086                return -EBUSY;
    21072087
    21082088        /* Control port initialization */
    2109         if (pnp_activate_dev(acard->devc) < 0) {
     2089        if (pnp_activate_dev(chip->devc) < 0) {
    21102090                snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n");
    21112091                return -EAGAIN;
    21122092        }
    21132093        snd_printdd("pnp: port=0x%llx\n",
    2114                         (unsigned long long)pnp_port_start(acard->devc, 0));
    2115         if (snd_audiodrive_pnp_init_main(dev, acard->dev) < 0)
     2094                        (unsigned long long)pnp_port_start(chip->devc, 0));
     2095        if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0)
    21162096                return -EBUSY;
    21172097
     
    21292109{
    21302110        return snd_card_create(index[dev], id[dev], THIS_MODULE,
    2131                                sizeof(struct snd_audiodrive), cardp);
     2111                               sizeof(struct snd_es18xx), cardp);
    21322112}
    21332113
    21342114static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev)
    21352115{
    2136         struct snd_audiodrive *acard = card->private_data;
    2137         struct snd_es18xx *chip;
     2116        struct snd_es18xx *chip = card->private_data;
    21382117        struct snd_opl3 *opl3;
    21392118        int err;
    21402119
    2141         if ((err = snd_es18xx_new_device(card,
    2142                                          port[dev],
    2143                                          mpu_port[dev],
    2144                                          fm_port[dev],
    2145                                          irq[dev], dma1[dev], dma2[dev],
    2146                                          &chip)) < 0)
     2120        err = snd_es18xx_new_device(card,
     2121                                    port[dev], mpu_port[dev], fm_port[dev],
     2122                                    irq[dev], dma1[dev], dma2[dev]);
     2123        if (err < 0)
    21472124                return err;
    2148         acard->chip = chip;
    21492125
    21502126        sprintf(card->driver, "ES%x", chip->version);
     
    21622138                        irq[dev], dma1[dev]);
    21632139
    2164         if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0)
     2140        err = snd_es18xx_pcm(card, 0, NULL);
     2141        if (err < 0)
    21652142                return err;
    21662143
    2167         if ((err = snd_es18xx_mixer(chip)) < 0)
     2144        err = snd_es18xx_mixer(card);
     2145        if (err < 0)
    21682146                return err;
    21692147
    21702148        if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
    2171                 if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) {
    2172                         snd_printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->fm_port);
     2149                if (snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2,
     2150                                    OPL3_HW_OPL3, 0, &opl3) < 0) {
     2151                        snd_printk(KERN_WARNING PFX
     2152                                   "opl3 not detected at 0x%lx\n",
     2153                                   fm_port[dev]);
    21732154                } else {
    2174                         if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0)
     2155                        err = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
     2156                        if (err < 0)
    21752157                                return err;
    21762158                }
     
    21782160
    21792161        if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
    2180                 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX,
    2181                                                chip->mpu_port, 0,
    2182                                                irq[dev], 0,
    2183                                                &chip->rmidi)) < 0)
     2162                err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX,
     2163                                          mpu_port[dev], 0,
     2164                                          irq[dev], 0, &chip->rmidi);
     2165                if (err < 0)
    21842166                        return err;
    21852167        }
  • GPL/trunk/alsa-kernel/isa/gus/gus_mem.c

    r305 r598  
    128128                return NULL;
    129129        for (block = alloc->first; block; block = block->next)
    130                 if (!memcmp(share_id, block->share_id, sizeof(share_id)))
     130                if (!memcmp(share_id, block->share_id,
     131                                sizeof(block->share_id)))
    131132                        return block;
    132133        return NULL;
  • GPL/trunk/alsa-kernel/isa/gus/gus_mem_proc.c

    r305 r598  
    3232};
    3333
    34 static long snd_gf1_mem_proc_dump(struct snd_info_entry *entry, void *file_private_data,
    35                                   struct file *file, char __user *buf,
    36                                   unsigned long count, unsigned long pos)
     34static ssize_t snd_gf1_mem_proc_dump(struct snd_info_entry *entry,
     35                                     void *file_private_data,
     36                                     struct file *file, char __user *buf,
     37                                     size_t count, loff_t pos)
    3738{
    38         long size;
    3939        struct gus_proc_private *priv = entry->private_data;
    4040        struct snd_gus_card *gus = priv->gus;
    4141        int err;
    4242
    43         size = count;
    44         if (pos + size > priv->size)
    45                 size = (long)priv->size - pos;
    46         if (size > 0) {
    47                 if ((err = snd_gus_dram_read(gus, buf, pos, size, priv->rom)) < 0)
    48                         return err;
    49                 return size;
    50         }
    51         return 0;
     43        err = snd_gus_dram_read(gus, buf, pos, count, priv->rom);
     44        if (err < 0)
     45                return err;
     46        return count;
    5247}                       
    53 
    54 static long long snd_gf1_mem_proc_llseek(struct snd_info_entry *entry,
    55                                         void *private_file_data,
    56                                         struct file *file,
    57                                         long long offset,
    58                                         int orig)
    59 {
    60         struct gus_proc_private *priv = entry->private_data;
    61 
    62         switch (orig) {
    63         case SEEK_SET:
    64                 file->f_pos = offset;
    65                 break;
    66         case SEEK_CUR:
    67                 file->f_pos += offset;
    68                 break;
    69         case SEEK_END: /* offset is negative */
    70                 file->f_pos = priv->size + offset;
    71                 break;
    72         default:
    73                 return -EINVAL;
    74         }
    75         if (file->f_pos > priv->size)
    76                 file->f_pos = priv->size;
    77         return file->f_pos;
    78 }
    7948
    8049static void snd_gf1_mem_proc_free(struct snd_info_entry *entry)
     
    8655static struct snd_info_entry_ops snd_gf1_mem_proc_ops = {
    8756        .read = snd_gf1_mem_proc_dump,
    88         .llseek = snd_gf1_mem_proc_llseek,
    8957};
    9058
  • GPL/trunk/alsa-kernel/isa/gus/gusextreme.c

    r464 r598  
    9696
    9797static int __devinit snd_gusextreme_es1688_create(struct snd_card *card,
    98                 struct device *dev, unsigned int n, struct snd_es1688 **rchip)
     98                struct snd_es1688 *chip, struct device *dev, unsigned int n)
    9999{
    100100        static long possible_ports[] = {0x220, 0x240, 0x260};
     
    120120
    121121        if (port[n] != SNDRV_AUTO_PORT)
    122                 return snd_es1688_create(card, port[n], mpu_port[n], irq[n],
    123                                 mpu_irq[n], dma8[n], ES1688_HW_1688, rchip);
     122                return snd_es1688_create(card, chip, port[n], mpu_port[n],
     123                                irq[n], mpu_irq[n], dma8[n], ES1688_HW_1688);
    124124
    125125        i = 0;
    126126        do {
    127127                port[n] = possible_ports[i];
    128                 error = snd_es1688_create(card, port[n], mpu_port[n], irq[n],
    129                                 mpu_irq[n], dma8[n], ES1688_HW_1688, rchip);
     128                error = snd_es1688_create(card, chip, port[n], mpu_port[n],
     129                                irq[n], mpu_irq[n], dma8[n], ES1688_HW_1688);
    130130        } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
    131131
     
    207207}
    208208
    209 static int __devinit snd_gusextreme_mixer(struct snd_es1688 *chip)
    210 {
    211         struct snd_card *card = chip->card;
     209static int __devinit snd_gusextreme_mixer(struct snd_card *card)
     210{
    212211        struct snd_ctl_elem_id id1, id2;
    213212        int error;
     
    242241        int error;
    243242
    244         error = snd_card_create(index[n], id[n], THIS_MODULE, 0, &card);
     243        error = snd_card_create(index[n], id[n], THIS_MODULE,
     244                                sizeof(struct snd_es1688), &card);
    245245        if (error < 0)
    246246                return error;
     247
     248        es1688 = card->private_data;
    247249
    248250        if (mpu_port[n] == SNDRV_AUTO_PORT)
     
    252254                mpu_irq[n] = -1;
    253255
    254         error = snd_gusextreme_es1688_create(card, dev, n, &es1688);
     256        error = snd_gusextreme_es1688_create(card, es1688, dev, n);
    255257        if (error < 0)
    256258                goto out;
     
    281283        gus->codec_flag = 1;
    282284
    283         error = snd_es1688_pcm(es1688, 0, NULL);
    284         if (error < 0)
    285                 goto out;
    286 
    287         error = snd_es1688_mixer(es1688);
     285        error = snd_es1688_pcm(card, es1688, 0, NULL);
     286        if (error < 0)
     287                goto out;
     288
     289        error = snd_es1688_mixer(card, es1688);
    288290        if (error < 0)
    289291                goto out;
     
    301303                goto out;
    302304
    303         error = snd_gusextreme_mixer(es1688);
     305        error = snd_gusextreme_mixer(card);
    304306        if (error < 0)
    305307                goto out;
  • GPL/trunk/alsa-kernel/isa/gus/gusmax.c

    r410 r598  
    192192static void snd_gusmax_free(struct snd_card *card)
    193193{
    194         struct snd_gusmax *maxcard = (struct snd_gusmax *)card->private_data;
     194        struct snd_gusmax *maxcard = card->private_data;
    195195       
    196196        if (maxcard == NULL)
     
    220220                return err;
    221221        card->private_free = snd_gusmax_free;
    222         maxcard = (struct snd_gusmax *)card->private_data;
     222        maxcard = card->private_data;
    223223        maxcard->card = card;
    224224        maxcard->irq = -1;
  • GPL/trunk/alsa-kernel/isa/gus/interwave.c

    r426 r598  
    2727#include <linux/isa.h>
    2828#include <linux/delay.h>
    29 #include <linux/slab.h>
    3029#include <linux/pnp.h>
    3130#include <linux/moduleparam.h>
  • GPL/trunk/alsa-kernel/isa/opl3sa2.c

    r426 r598  
    2525#include <linux/interrupt.h>
    2626#include <linux/pm.h>
    27 #include <linux/slab.h>
    2827#include <linux/pnp.h>
    2928#include <linux/moduleparam.h>
     
    270269                return -ENODEV;
    271270        }
    272         /* try if the MIC register is accesible */
     271        /* try if the MIC register is accessible */
    273272        tmp = snd_opl3sa2_read(chip, OPL3SA2_MIC);
    274273        snd_opl3sa2_write(chip, OPL3SA2_MIC, 0x8a);
  • GPL/trunk/alsa-kernel/isa/opti9xx/opti92x-ad1848.c

    r426 r598  
    2828#include <linux/isa.h>
    2929#include <linux/delay.h>
    30 #include <linux/slab.h>
    3130#include <linux/pnp.h>
    3231#include <linux/moduleparam.h>
     
    3433#include <asm/dma.h>
    3534#include <sound/core.h>
     35#include <sound/tlv.h>
    3636#include <sound/wss.h>
    3737#include <sound/mpu401.h>
     
    136136#ifdef OPTi93X
    137137        unsigned long mc_indir_index;
     138        unsigned long mc_indir_size;
     139        struct resource *res_mc_indir;
    138140        struct snd_wss *codec;
    139141#endif  /* OPTi93X */
     
    144146        long wss_base;
    145147        int irq;
    146         int dma1;
    147         int dma2;
    148 
    149         long fm_port;
    150 
    151         long mpu_port;
    152         int mpu_irq;
    153 
    154 #ifdef CONFIG_PNP
    155         struct pnp_dev *dev;
    156         struct pnp_dev *devmpu;
    157 #endif  /* CONFIG_PNP */
    158148};
    159149
     
    165155#ifndef OPTi93X
    166156        /* OPTi 82C924 */
    167         { .id = "OPT0924", .devs = { { "OPT0000" }, { "OPT0002" } }, .driver_data = 0x0924 },
     157        { .id = "OPT0924",
     158          .devs = { { "OPT0000" }, { "OPT0002" }, { "OPT0005" } },
     159          .driver_data = 0x0924 },
    168160        /* OPTi 82C925 */
    169         { .id = "OPT0925", .devs = { { "OPT9250" }, { "OPT0002" } }, .driver_data = 0x0925 },
     161        { .id = "OPT0925",
     162          .devs = { { "OPT9250" }, { "OPT0002" }, { "OPT0005" } },
     163          .driver_data = 0x0925 },
    170164#else
    171165        /* OPTi 82C931/3 */
    172         { .id = "OPT0931", .devs = { { "OPT9310" }, { "OPT0002" } }, .driver_data = 0x0931 },
     166        { .id = "OPT0931", .devs = { { "OPT9310" }, { "OPT0002" } },
     167          .driver_data = 0x0931 },
    173168#endif  /* OPTi93X */
    174169        { .id = "" }
     
    186181
    187182static char * snd_opti9xx_names[] = {
    188         "unkown",
     183        "unknown",
    189184        "82C928",       "82C929",
    190185        "82C924",       "82C925",
     
    213208        strcpy(chip->name, snd_opti9xx_names[hardware]);
    214209
    215         chip->mc_base_size = opti9xx_mc_size[hardware]; 
    216 
    217210        spin_lock_init(&chip->lock);
    218211
    219         chip->wss_base = -1;
    220212        chip->irq = -1;
    221         chip->dma1 = -1;
    222         chip->dma2 = -1;
    223         chip->fm_port = -1;
    224         chip->mpu_port = -1;
    225         chip->mpu_irq = -1;
     213
     214#ifndef OPTi93X
     215#ifdef CONFIG_PNP
     216        if (isapnp && chip->mc_base)
     217                /* PnP resource gives the least 10 bits */
     218                chip->mc_base |= 0xc00;
     219        else
     220#endif  /* CONFIG_PNP */
     221        {
     222                chip->mc_base = 0xf8c;
     223                chip->mc_base_size = opti9xx_mc_size[hardware];
     224        }
     225#else
     226                chip->mc_base_size = opti9xx_mc_size[hardware];
     227#endif
    226228
    227229        switch (hardware) {
     
    229231        case OPTi9XX_HW_82C928:
    230232        case OPTi9XX_HW_82C929:
    231                 chip->mc_base = 0xf8c;
    232233                chip->password = (hardware == OPTi9XX_HW_82C928) ? 0xe2 : 0xe3;
    233234                chip->pwd_reg = 3;
     
    236237        case OPTi9XX_HW_82C924:
    237238        case OPTi9XX_HW_82C925:
    238                 chip->mc_base = 0xf8c;
    239239                chip->password = 0xe5;
    240240                chip->pwd_reg = 3;
     
    246246        case OPTi9XX_HW_82C933:
    247247                chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d;
    248                 chip->mc_indir_index = 0xe0e;
     248                if (!chip->mc_indir_index) {
     249                        chip->mc_indir_index = 0xe0e;
     250                        chip->mc_indir_size = 2;
     251                }
    249252                chip->password = 0xe4;
    250253                chip->pwd_reg = 0;
     
    301304        return retval;
    302305}
    303        
     306
    304307static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
    305308                              unsigned char value)
     
    349352
    350353
    351 static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip)
     354static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip,
     355                                           long port,
     356                                           int irq, int dma1, int dma2,
     357                                           long mpu_port, int mpu_irq)
    352358{
    353359        unsigned char wss_base_bits;
     
    360366#ifndef OPTi93X
    361367        case OPTi9XX_HW_82C924:
     368                /* opti 929 mode (?), OPL3 clock output, audio enable */
    362369                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0xf0, 0xfc);
     370                /* enable wave audio */
    363371                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02);
    364372
    365373        case OPTi9XX_HW_82C925:
     374                /* enable WSS mode */
    366375                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80);
     376                /* OPL3 FM synthesis */
    367377                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x00, 0x20);
     378                /* disable Sound Blaster IRQ and DMA */
    368379                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff);
    369380#ifdef CS4231
     381                /* cs4231/4248 fix enabled */
    370382                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02);
    371383#else
     384                /* cs4231/4248 fix disabled */
    372385                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x00, 0x02);
    373386#endif  /* CS4231 */
     
    417430        }
    418431
    419         switch (chip->wss_base) {
    420         case 0x530:
     432        /* PnP resource says it decodes only 10 bits of address */
     433        switch (port & 0x3ff) {
     434        case 0x130:
     435                chip->wss_base = 0x530;
    421436                wss_base_bits = 0x00;
    422437                break;
    423         case 0x604:
     438        case 0x204:
     439                chip->wss_base = 0x604;
    424440                wss_base_bits = 0x03;
    425441                break;
    426         case 0xe80:
     442        case 0x280:
     443                chip->wss_base = 0xe80;
    427444                wss_base_bits = 0x01;
    428445                break;
    429         case 0xf40:
     446        case 0x340:
     447                chip->wss_base = 0xf40;
    430448                wss_base_bits = 0x02;
    431449                break;
    432450        default:
    433                 snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n",
    434                            chip->wss_base);
     451                snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", port);
    435452                goto __skip_base;
    436453        }
     
    438455
    439456__skip_base:
    440         switch (chip->irq) {
     457        switch (irq) {
    441458//#ifdef OPTi93X
    442459        case 5:
     
    457474                break;
    458475        default:
    459                 snd_printk(KERN_WARNING "WSS irq # %d not valid\n", chip->irq);
     476                snd_printk(KERN_WARNING "WSS irq # %d not valid\n", irq);
    460477                goto __skip_resources;
    461478        }
    462479
    463         switch (chip->dma1) {
     480        switch (dma1) {
    464481        case 0:
    465482                dma_bits = 0x01;
     
    472489                break;
    473490        default:
    474                 snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n",
    475                            chip->dma1);
     491                snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", dma1);
    476492                goto __skip_resources;
    477493        }
    478494
    479495#if defined(CS4231) || defined(OPTi93X)
    480         if (chip->dma1 == chip->dma2) {
     496        if (dma1 == dma2) {
    481497                snd_printk(KERN_ERR "don't want to share dmas\n");
    482498                return -EBUSY;
    483499        }
    484500
    485         switch (chip->dma2) {
     501        switch (dma2) {
    486502        case 0:
    487503        case 1:
    488504                break;
    489505        default:
    490                 snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n",
    491                            chip->dma2);
     506                snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", dma2);
    492507                goto __skip_resources;
    493508        }
     
    503518__skip_resources:
    504519        if (chip->hardware > OPTi9XX_HW_82C928) {
    505                 switch (chip->mpu_port) {
     520                switch (mpu_port) {
    506521                case 0:
    507522                case -1:
     
    521536                default:
    522537                        snd_printk(KERN_WARNING
    523                                    "MPU-401 port 0x%lx not valid\n",
    524                                 chip->mpu_port);
     538                                   "MPU-401 port 0x%lx not valid\n", mpu_port);
    525539                        goto __skip_mpu;
    526540                }
    527541
    528                 switch (chip->mpu_irq) {
     542                switch (mpu_irq) {
    529543                case 5:
    530544                        mpu_irq_bits = 0x02;
     
    541555                default:
    542556                        snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n",
    543                                 chip->mpu_irq);
     557                                mpu_irq);
    544558                        goto __skip_mpu;
    545559                }
    546560
    547561                snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6),
    548                         (chip->mpu_port <= 0) ? 0x00 :
     562                        (mpu_port <= 0) ? 0x00 :
    549563                                0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3,
    550564                        0xf8);
     
    557571#ifdef OPTi93X
    558572
     573static const DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_step, -9300, 300, 0);
     574static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0);
     575static const DECLARE_TLV_DB_SCALE(db_scale_4bit_12db_max, -3300, 300, 0);
     576
     577static struct snd_kcontrol_new snd_opti93x_controls[] = {
     578WSS_DOUBLE("Master Playback Switch", 0,
     579                OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
     580WSS_DOUBLE_TLV("Master Playback Volume", 0,
     581                OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1,
     582                db_scale_5bit_3db_step),
     583WSS_DOUBLE_TLV("PCM Playback Volume", 0,
     584                CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1,
     585                db_scale_5bit),
     586WSS_DOUBLE_TLV("FM Playback Volume", 0,
     587                CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1,
     588                db_scale_4bit_12db_max),
     589WSS_DOUBLE("Line Playback Switch", 0,
     590                CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1),
     591WSS_DOUBLE_TLV("Line Playback Volume", 0,
     592                CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1,
     593                db_scale_4bit_12db_max),
     594WSS_DOUBLE("Mic Playback Switch", 0,
     595                OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1),
     596WSS_DOUBLE_TLV("Mic Playback Volume", 0,
     597                OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1,
     598                db_scale_4bit_12db_max),
     599WSS_DOUBLE_TLV("CD Playback Volume", 0,
     600                CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1,
     601                db_scale_4bit_12db_max),
     602WSS_DOUBLE("Aux Playback Switch", 0,
     603                OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1),
     604WSS_DOUBLE_TLV("Aux Playback Volume", 0,
     605                OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1,
     606                db_scale_4bit_12db_max),
     607};
     608
     609static int __devinit snd_opti93x_mixer(struct snd_wss *chip)
     610{
     611        struct snd_card *card;
     612        unsigned int idx;
     613        struct snd_ctl_elem_id id1, id2;
     614        int err;
     615
     616        if (snd_BUG_ON(!chip || !chip->pcm))
     617                return -EINVAL;
     618
     619        card = chip->card;
     620
     621        strcpy(card->mixername, chip->pcm->name);
     622
     623        memset(&id1, 0, sizeof(id1));
     624        memset(&id2, 0, sizeof(id2));
     625        id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
     626        /* reassign AUX0 switch to CD */
     627        strcpy(id1.name, "Aux Playback Switch");
     628        strcpy(id2.name, "CD Playback Switch");
     629        err = snd_ctl_rename_id(card, &id1, &id2);
     630        if (err < 0) {
     631                snd_printk(KERN_ERR "Cannot rename opti93x control\n");
     632                return err;
     633        }
     634        /* reassign AUX1 switch to FM */
     635        strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
     636        strcpy(id2.name, "FM Playback Switch");
     637        err = snd_ctl_rename_id(card, &id1, &id2);
     638        if (err < 0) {
     639                snd_printk(KERN_ERR "Cannot rename opti93x control\n");
     640                return err;
     641        }
     642        /* remove AUX1 volume */
     643        strcpy(id1.name, "Aux Playback Volume"); id1.index = 1;
     644        snd_ctl_remove_id(card, &id1);
     645
     646        /* Replace WSS volume controls with OPTi93x volume controls */
     647        id1.index = 0;
     648        for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) {
     649                strcpy(id1.name, snd_opti93x_controls[idx].name);
     650                snd_ctl_remove_id(card, &id1);
     651
     652                err = snd_ctl_add(card,
     653                                snd_ctl_new1(&snd_opti93x_controls[idx], chip));
     654                if (err < 0)
     655                        return err;
     656        }
     657        return 0;
     658}
     659
    559660static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id)
    560661{
    561         struct snd_wss *codec = dev_id;
    562         struct snd_opti9xx *chip = codec->card->private_data;
     662        struct snd_opti9xx *chip = dev_id;
     663        struct snd_wss *codec = chip->codec;
    563664        unsigned char status;
     665
     666        if (!codec)
     667                return IRQ_HANDLED;
    564668
    565669        status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11));
     
    576680#endif /* OPTi93X */
    577681
     682static int __devinit snd_opti9xx_read_check(struct snd_opti9xx *chip)
     683{
     684        unsigned char value;
     685#ifdef OPTi93X
     686        unsigned long flags;
     687#endif
     688
     689        chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size,
     690                                           "OPTi9xx MC");
     691        if (chip->res_mc_base == NULL)
     692                return -EBUSY;
     693#ifndef OPTi93X
     694        value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1));
     695        if (value != 0xff && value != inb(chip->mc_base + OPTi9XX_MC_REG(1)))
     696                if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)))
     697                        return 0;
     698#else   /* OPTi93X */
     699        chip->res_mc_indir = request_region(chip->mc_indir_index,
     700                                            chip->mc_indir_size,
     701                                            "OPTi93x MC");
     702        if (chip->res_mc_indir == NULL)
     703                return -EBUSY;
     704
     705        spin_lock_irqsave(&chip->lock, flags);
     706        outb(chip->password, chip->mc_base + chip->pwd_reg);
     707        outb(((chip->mc_indir_index & 0x1f0) >> 4), chip->mc_base);
     708        spin_unlock_irqrestore(&chip->lock, flags);
     709
     710        value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(7));
     711        snd_opti9xx_write(chip, OPTi9XX_MC_REG(7), 0xff - value);
     712        if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value)
     713                return 0;
     714
     715        release_and_free_resource(chip->res_mc_indir);
     716        chip->res_mc_indir = NULL;
     717#endif  /* OPTi93X */
     718        release_and_free_resource(chip->res_mc_base);
     719        chip->res_mc_base = NULL;
     720
     721        return -ENODEV;
     722}
     723
    578724static int __devinit snd_card_opti9xx_detect(struct snd_card *card,
    579725                                             struct snd_opti9xx *chip)
     
    583729#ifndef OPTi93X
    584730        for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) {
    585                 unsigned char value;
    586 
    587                 if ((err = snd_opti9xx_init(chip, i)) < 0)
     731#else
     732        for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) {
     733#endif
     734                err = snd_opti9xx_init(chip, i);
     735                if (err < 0)
    588736                        return err;
    589737
    590                 if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL)
    591                         continue;
    592 
    593                 value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1));
    594                 if ((value != 0xff) && (value != inb(chip->mc_base + 1)))
    595                         if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)))
    596                                 return 1;
    597 
    598                 release_and_free_resource(chip->res_mc_base);
    599                 chip->res_mc_base = NULL;
    600 
    601         }
    602 #else   /* OPTi93X */
    603         for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) {
    604                 unsigned long flags;
    605                 unsigned char value;
    606 
    607                 if ((err = snd_opti9xx_init(chip, i)) < 0)
    608                         return err;
    609 
    610                 if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL)
    611                         continue;
    612 
    613                 spin_lock_irqsave(&chip->lock, flags);
    614                 outb(chip->password, chip->mc_base + chip->pwd_reg);
    615                 outb(((chip->mc_indir_index & (1 << 8)) >> 4) |
    616                         ((chip->mc_indir_index & 0xf0) >> 4), chip->mc_base);
    617                 spin_unlock_irqrestore(&chip->lock, flags);
    618 
    619                 value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(7));
    620                 snd_opti9xx_write(chip, OPTi9XX_MC_REG(7), 0xff - value);
    621                 if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value)
     738                err = snd_opti9xx_read_check(chip);
     739                if (err == 0)
    622740                        return 1;
    623 
    624                 release_and_free_resource(chip->res_mc_base);
    625                 chip->res_mc_base = NULL;
    626         }
    627 #endif  /* OPTi93X */
    628 
     741#ifdef OPTi93X
     742                chip->mc_indir_index = 0;
     743#endif
     744        }
    629745        return -ENODEV;
    630746}
     
    637753        struct pnp_dev *pdev;
    638754        int err;
    639 
    640         chip->dev = pnp_request_card_device(card, pid->devs[0].id, NULL);
    641         if (chip->dev == NULL)
     755        struct pnp_dev *devmpu;
     756#ifndef OPTi93X
     757        struct pnp_dev *devmc;
     758#endif
     759
     760        pdev = pnp_request_card_device(card, pid->devs[0].id, NULL);
     761        if (pdev == NULL)
    642762                return -EBUSY;
    643 
    644         chip->devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL);
    645 
    646         pdev = chip->dev;
    647763
    648764        err = pnp_activate_dev(pdev);
     
    655771        port = pnp_port_start(pdev, 0) - 4;
    656772        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;
    657775#else
    658         if (pid->driver_data != 0x0924)
    659                 port = pnp_port_start(pdev, 1);
     776        devmc = pnp_request_card_device(card, pid->devs[2].id, NULL);
     777        if (devmc == NULL)
     778                return -EBUSY;
     779
     780        err = pnp_activate_dev(devmc);
     781        if (err < 0) {
     782                snd_printk(KERN_ERR "MC pnp configure failure: %d\n", err);
     783                return err;
     784        }
     785
     786        port = pnp_port_start(pdev, 1);
    660787        fm_port = pnp_port_start(pdev, 2) + 8;
     788        /*
     789         * The MC(0) is never accessed and card does not
     790         * include it in the PnP resource range. OPTI93x include it.
     791         */
     792        chip->mc_base = pnp_port_start(devmc, 0) - 1;
     793        chip->mc_base_size = pnp_port_len(devmc, 0) + 1;
    661794#endif  /* OPTi93X */
    662795        irq = pnp_irq(pdev, 0);
     
    666799#endif  /* CS4231 || OPTi93X */
    667800
    668         pdev = chip->devmpu;
    669         if (pdev && mpu_port > 0) {
    670                 err = pnp_activate_dev(pdev);
     801        devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL);
     802
     803        if (devmpu && mpu_port > 0) {
     804                err = pnp_activate_dev(devmpu);
    671805                if (err < 0) {
    672                         snd_printk(KERN_ERR "AUDIO pnp configure failure\n");
     806                        snd_printk(KERN_ERR "MPU401 pnp configure failure\n");
    673807                        mpu_port = -1;
    674                         chip->devmpu = NULL;
    675808                } else {
    676                         mpu_port = pnp_port_start(pdev, 0);
    677                         mpu_irq = pnp_irq(pdev, 0);
     809                        mpu_port = pnp_port_start(devmpu, 0);
     810                        mpu_irq = pnp_irq(devmpu, 0);
    678811                }
    679812        }
     
    685818{
    686819        struct snd_opti9xx *chip = card->private_data;
    687        
     820
    688821        if (chip) {
    689822#ifdef OPTi93X
    690                 struct snd_wss *codec = chip->codec;
    691                 if (codec && codec->irq > 0) {
    692                         disable_irq(codec->irq);
    693                         free_irq(codec->irq, codec);
    694                 }
     823                if (chip->irq > 0) {
     824                        disable_irq(chip->irq);
     825                        free_irq(chip->irq, chip);
     826                }
     827                release_and_free_resource(chip->res_mc_indir);
    695828#endif
    696829                release_and_free_resource(chip->res_mc_base);
     
    702835        static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
    703836        int error;
     837        int xdma2;
    704838        struct snd_opti9xx *chip = card->private_data;
    705839        struct snd_wss *codec;
     
    711845        struct snd_hwdep *synth;
    712846
    713         if (! chip->res_mc_base &&
    714             (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size,
    715                                                 "OPTi9xx MC")) == NULL)
    716                 return -ENOMEM;
    717 
    718         chip->wss_base = port;
    719         chip->fm_port = fm_port;
    720         chip->mpu_port = mpu_port;
    721         chip->irq = irq;
    722         chip->mpu_irq = mpu_irq;
    723         chip->dma1 = dma1;
    724847#if defined(CS4231) || defined(OPTi93X)
    725         chip->dma2 = dma2;
     848        xdma2 = dma2;
    726849#else
    727         chip->dma2 = -1;
    728 #endif
    729 
    730         if (chip->wss_base == SNDRV_AUTO_PORT) {
    731                 chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4);
    732                 if (chip->wss_base < 0) {
     850        xdma2 = -1;
     851#endif
     852
     853        if (port == SNDRV_AUTO_PORT) {
     854                port = snd_legacy_find_free_ioport(possible_ports, 4);
     855                if (port < 0) {
    733856                        snd_printk(KERN_ERR "unable to find a free WSS port\n");
    734857                        return -EBUSY;
    735858                }
    736859        }
    737         error = snd_opti9xx_configure(chip);
     860        error = snd_opti9xx_configure(chip, port, irq, dma1, xdma2,
     861                                      mpu_port, mpu_irq);
    738862        if (error)
    739863                return error;
    740864
    741         error = snd_wss_create(card, chip->wss_base + 4, -1,
    742                                chip->irq, chip->dma1, chip->dma2,
     865        error = snd_wss_create(card, chip->wss_base + 4, -1, irq, dma1, xdma2,
    743866#ifdef OPTi93X
    744867                               WSS_HW_OPTI93X, WSS_HWSHARE_IRQ,
     
    758881        if (error < 0)
    759882                return error;
     883#ifdef OPTi93X
     884        error = snd_opti93x_mixer(codec);
     885        if (error < 0)
     886                return error;
     887#endif
    760888#ifdef CS4231
    761889        error = snd_wss_timer(codec, 0, &timer);
     
    764892#endif
    765893#ifdef OPTi93X
    766         error = request_irq(chip->irq, snd_opti93x_interrupt,
    767                             IRQF_DISABLED, DEV_NAME" - WSS", codec);
     894        error = request_irq(irq, snd_opti93x_interrupt,
     895                            IRQF_DISABLED, DEV_NAME" - WSS", chip);
    768896        if (error < 0) {
    769                 snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq);
    770                 return error;
    771         }
    772 #endif
     897                snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", irq);
     898                return error;
     899        }
     900#endif
     901        chip->irq = irq;
    773902        strcpy(card->driver, chip->name);
    774903        sprintf(card->shortname, "OPTi %s", card->driver);
    775904#if defined(CS4231) || defined(OPTi93X)
    776905        sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d",
    777                 card->shortname, pcm->name, chip->wss_base + 4,
    778                 chip->irq, chip->dma1, chip->dma2);
     906                card->shortname, pcm->name,
     907                chip->wss_base + 4, irq, dma1, xdma2);
    779908#else
    780909        sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d",
    781                 card->shortname, pcm->name, chip->wss_base + 4,
    782                 chip->irq, chip->dma1);
     910                card->shortname, pcm->name, chip->wss_base + 4, irq, dma1);
    783911#endif  /* CS4231 || OPTi93X */
    784912
    785         if (chip->mpu_port <= 0 || chip->mpu_port == SNDRV_AUTO_PORT)
     913        if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT)
    786914                rmidi = NULL;
    787         else
    788                 if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
    789                                 chip->mpu_port, 0, chip->mpu_irq, IRQF_DISABLED,
    790                                 &rmidi)))
     915        else {
     916                error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
     917                                mpu_port, 0, mpu_irq, IRQF_DISABLED, &rmidi);
     918                if (error)
    791919                        snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n",
    792                                    chip->mpu_port);
    793 
    794         if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) {
     920                                   mpu_port);
     921        }
     922
     923        if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) {
    795924                struct snd_opl3 *opl3 = NULL;
    796925#ifndef OPTi93X
     
    802931                        snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2),
    803932                                               0x20, 0x20);
    804                         if (snd_opl4_create(card,
    805                                             chip->fm_port,
    806                                             chip->fm_port - 8,
     933                        if (snd_opl4_create(card, fm_port, fm_port - 8,
    807934                                            2, &opl3, &opl4) < 0) {
    808935                                /* no luck, use OPL3 instead */
     
    812939                }
    813940#endif  /* !OPTi93X */
    814                 if (!opl3 && snd_opl3_create(card,
    815                                              chip->fm_port,
    816                                              chip->fm_port + 2,
     941                if (!opl3 && snd_opl3_create(card, fm_port, fm_port + 2,
    817942                                             OPL3_HW_AUTO, 0, &opl3) < 0) {
    818943                        snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n",
    819                                    chip->fm_port, chip->fm_port + 4 - 1);
     944                                   fm_port, fm_port + 4 - 1);
    820945                }
    821946                if (opl3) {
     
    9771102                return error;
    9781103        }
    979         if (hw <= OPTi9XX_HW_82C930)
    980                 chip->mc_base -= 0x80;
     1104        error = snd_opti9xx_read_check(chip);
     1105        if (error) {
     1106                snd_printk(KERN_ERR "OPTI chip not found\n");
     1107                snd_card_free(card);
     1108                return error;
     1109        }
    9811110        snd_card_set_dev(card, &pcard->card->dev);
    9821111        if ((error = snd_opti9xx_probe(card)) < 0) {
  • GPL/trunk/alsa-kernel/isa/sb/emu8000.c

    r399 r598  
    378378size_dram(struct snd_emu8000 *emu)
    379379{
    380         int i, size;
     380        int i, size, detected_size;
    381381
    382382        if (emu->dram_checked)
     
    384384
    385385        size = 0;
     386        detected_size = 0;
    386387
    387388        /* write out a magic number */
     
    415416                EMU8000_SMLD_READ(emu); /* discard stale data  */
    416417                if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2)
    417                         break; /* we must have wrapped around */
     418                        break; /* no memory at this address */
     419
     420                detected_size = size;
    418421
    419422                snd_emu8000_read_wait(emu);
     
    443446
    444447        snd_printdd("EMU8000 [0x%lx]: %d Kb on-board memory detected\n",
    445                     emu->port1, size/1024);
    446 
    447         emu->mem_size = size;
     448                    emu->port1, detected_size/1024);
     449
     450        emu->mem_size = detected_size;
    448451        emu->dram_checked = 1;
    449452}
  • GPL/trunk/alsa-kernel/isa/sb/sb16.c

    r410 r598  
    2222#include <asm/dma.h>
    2323#include <linux/init.h>
    24 #include <linux/slab.h>
    2524#include <linux/pnp.h>
    2625#include <linux/err.h>
  • GPL/trunk/alsa-kernel/isa/sb/sb8.c

    r410 r598  
    2323#include <linux/err.h>
    2424#include <linux/isa.h>
    25 #include <linux/slab.h>
    2625#include <linux/ioport.h>
    2726#include <linux/moduleparam.h>
     
    7473static void snd_sb8_free(struct snd_card *card)
    7574{
    76         struct snd_sb8 *acard = (struct snd_sb8 *)card->private_data;
     75        struct snd_sb8 *acard = card->private_data;
    7776
    7877        if (acard == NULL)
  • GPL/trunk/alsa-kernel/isa/sb/sb8_main.c

    r399 r598  
    107107        struct snd_pcm_runtime *runtime = substream->runtime;
    108108        unsigned int mixreg, rate, size, count;
     109        unsigned char format;
     110        unsigned char stereo = runtime->channels > 1;
     111        int dma;
    109112
    110113        rate = runtime->rate;
    111114        switch (chip->hardware) {
     115        case SB_HW_JAZZ16:
     116                if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) {
     117                        if (chip->mode & SB_MODE_CAPTURE_16)
     118                                return -EBUSY;
     119                        else
     120                                chip->mode |= SB_MODE_PLAYBACK_16;
     121                }
     122                chip->playback_format = SB_DSP_LO_OUTPUT_AUTO;
     123                break;
    112124        case SB_HW_PRO:
    113125                if (runtime->channels > 1) {
     
    134146                return -EINVAL;
    135147        }
     148        if (chip->mode & SB_MODE_PLAYBACK_16) {
     149                format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT;
     150                dma = chip->dma16;
     151        } else {
     152                format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT;
     153                chip->mode |= SB_MODE_PLAYBACK_8;
     154                dma = chip->dma8;
     155        }
    136156        size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream);
    137157        count = chip->p_period_size = snd_pcm_lib_period_bytes(substream);
    138158        spin_lock_irqsave(&chip->reg_lock, flags);
    139159        snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON);
    140         if (runtime->channels > 1) {
     160        if (chip->hardware == SB_HW_JAZZ16)
     161                snd_sbdsp_command(chip, format);
     162        else if (stereo) {
    141163                /* set playback stereo mode */
    142164                spin_lock(&chip->mixer_lock);
     
    148170                snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT);
    149171                runtime->dma_area[0] = 0x80;
    150                 snd_dma_program(chip->dma8, runtime->dma_addr, 1, DMA_MODE_WRITE);
     172                snd_dma_program(dma, runtime->dma_addr, 1, DMA_MODE_WRITE);
    151173                /* force interrupt */
    152                 chip->mode = SB_MODE_HALT;
    153174                snd_sbdsp_command(chip, SB_DSP_OUTPUT);
    154175                snd_sbdsp_command(chip, 0);
     
    156177        }
    157178        snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE);
    158         if (runtime->channels > 1) {
     179        if (stereo) {
    159180                snd_sbdsp_command(chip, 256 - runtime->rate_den / 2);
    160181                spin_lock(&chip->mixer_lock);
     
    169190        }
    170191        if (chip->playback_format != SB_DSP_OUTPUT) {
     192                if (chip->mode & SB_MODE_PLAYBACK_16)
     193                        count /= 2;
    171194                count--;
    172195                snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE);
     
    175198        }
    176199        spin_unlock_irqrestore(&chip->reg_lock, flags);
    177         snd_dma_program(chip->dma8, runtime->dma_addr,
     200        snd_dma_program(dma, runtime->dma_addr,
    178201                        size, DMA_MODE_WRITE | DMA_AUTOINIT);
    179202        return 0;
     
    213236        }
    214237        spin_unlock_irqrestore(&chip->reg_lock, flags);
    215         chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_PLAYBACK_8 : SB_MODE_HALT;
    216238        return 0;
    217239}
     
    235257        struct snd_pcm_runtime *runtime = substream->runtime;
    236258        unsigned int mixreg, rate, size, count;
     259        unsigned char format;
     260        unsigned char stereo = runtime->channels > 1;
     261        int dma;
    237262
    238263        rate = runtime->rate;
    239264        switch (chip->hardware) {
     265        case SB_HW_JAZZ16:
     266                if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) {
     267                        if (chip->mode & SB_MODE_PLAYBACK_16)
     268                                return -EBUSY;
     269                        else
     270                                chip->mode |= SB_MODE_CAPTURE_16;
     271                }
     272                chip->capture_format = SB_DSP_LO_INPUT_AUTO;
     273                break;
    240274        case SB_HW_PRO:
    241275                if (runtime->channels > 1) {
     
    263297                return -EINVAL;
    264298        }
     299        if (chip->mode & SB_MODE_CAPTURE_16) {
     300                format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT;
     301                dma = chip->dma16;
     302        } else {
     303                format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT;
     304                chip->mode |= SB_MODE_CAPTURE_8;
     305                dma = chip->dma8;
     306        }
    265307        size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream);
    266308        count = chip->c_period_size = snd_pcm_lib_period_bytes(substream);
    267309        spin_lock_irqsave(&chip->reg_lock, flags);
    268310        snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF);
    269         if (runtime->channels > 1)
     311        if (chip->hardware == SB_HW_JAZZ16)
     312                snd_sbdsp_command(chip, format);
     313        else if (stereo)
    270314                snd_sbdsp_command(chip, SB_DSP_STEREO_8BIT);
    271315        snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE);
    272         if (runtime->channels > 1) {
     316        if (stereo) {
    273317                snd_sbdsp_command(chip, 256 - runtime->rate_den / 2);
    274318                spin_lock(&chip->mixer_lock);
     
    283327        }
    284328        if (chip->capture_format != SB_DSP_INPUT) {
     329                if (chip->mode & SB_MODE_PLAYBACK_16)
     330                        count /= 2;
    285331                count--;
    286332                snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE);
     
    289335        }
    290336        spin_unlock_irqrestore(&chip->reg_lock, flags);
    291         snd_dma_program(chip->dma8, runtime->dma_addr,
     337        snd_dma_program(dma, runtime->dma_addr,
    292338                        size, DMA_MODE_READ | DMA_AUTOINIT);
    293339        return 0;
     
    329375        }
    330376        spin_unlock_irqrestore(&chip->reg_lock, flags);
    331         chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_CAPTURE_8 : SB_MODE_HALT;
    332377        return 0;
    333378}
     
    340385        snd_sb_ack_8bit(chip);
    341386        switch (chip->mode) {
    342         case SB_MODE_PLAYBACK_8:        /* ok.. playback is active */
     387        case SB_MODE_PLAYBACK_16:       /* ok.. playback is active */
     388                if (chip->hardware != SB_HW_JAZZ16)
     389                        break;
     390                /* fallthru */
     391        case SB_MODE_PLAYBACK_8:
    343392                substream = chip->playback_substream;
    344393                runtime = substream->runtime;
     
    347396                snd_pcm_period_elapsed(substream);
    348397                break;
     398        case SB_MODE_CAPTURE_16:
     399                if (chip->hardware != SB_HW_JAZZ16)
     400                        break;
     401                /* fallthru */
    349402        case SB_MODE_CAPTURE_8:
    350403                substream = chip->capture_substream;
     
    362415        struct snd_sb *chip = snd_pcm_substream_chip(substream);
    363416        size_t ptr;
    364 
    365         if (chip->mode != SB_MODE_PLAYBACK_8)
     417        int dma;
     418
     419        if (chip->mode & SB_MODE_PLAYBACK_8)
     420                dma = chip->dma8;
     421        else if (chip->mode & SB_MODE_PLAYBACK_16)
     422                dma = chip->dma16;
     423        else
    366424                return 0;
    367         ptr = snd_dma_pointer(chip->dma8, chip->p_dma_size);
     425        ptr = snd_dma_pointer(dma, chip->p_dma_size);
    368426        return bytes_to_frames(substream->runtime, ptr);
    369427}
     
    373431        struct snd_sb *chip = snd_pcm_substream_chip(substream);
    374432        size_t ptr;
    375 
    376         if (chip->mode != SB_MODE_CAPTURE_8)
     433        int dma;
     434
     435        if (chip->mode & SB_MODE_CAPTURE_8)
     436                dma = chip->dma8;
     437        else if (chip->mode & SB_MODE_CAPTURE_16)
     438                dma = chip->dma16;
     439        else
    377440                return 0;
    378         ptr = snd_dma_pointer(chip->dma8, chip->c_dma_size);
     441        ptr = snd_dma_pointer(dma, chip->c_dma_size);
    379442        return bytes_to_frames(substream->runtime, ptr);
    380443}
     
    447510        }
    448511        switch (chip->hardware) {
     512        case SB_HW_JAZZ16:
     513                if (chip->dma16 == 5 || chip->dma16 == 7)
     514                        runtime->hw.formats |= SNDRV_PCM_FMTBIT_S16_LE;
     515                runtime->hw.rates |= SNDRV_PCM_RATE_8000_48000;
     516                runtime->hw.rate_min = 4000;
     517                runtime->hw.rate_max = 50000;
     518                runtime->hw.channels_max = 2;
     519                break;
    449520        case SB_HW_PRO:
    450521                runtime->hw.rate_max = 44100;
     
    469540        snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
    470541                                      &hw_constraints_clock);
     542        if (chip->dma8 > 3 || chip->dma16 >= 0) {
     543                snd_pcm_hw_constraint_step(runtime, 0,
     544                                           SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 2);
     545                snd_pcm_hw_constraint_step(runtime, 0,
     546                                           SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 2);
     547                runtime->hw.buffer_bytes_max = 128 * 1024 * 1024;
     548                runtime->hw.period_bytes_max = 128 * 1024 * 1024;
     549        }
    471550        return 0;       
    472551}
     
    481560        spin_lock_irqsave(&chip->open_lock, flags);
    482561        chip->open &= ~SB_OPEN_PCM;
     562        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
     563                chip->mode &= ~SB_MODE_PLAYBACK;
     564        else
     565                chip->mode &= ~SB_MODE_CAPTURE;
    483566        spin_unlock_irqrestore(&chip->open_lock, flags);
    484567        return 0;
     
    516599        struct snd_pcm *pcm;
    517600        int err;
     601        size_t max_prealloc = 64 * 1024;
    518602
    519603        if (rpcm)
     
    528612        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops);
    529613
     614        if (chip->dma8 > 3 || chip->dma16 >= 0)
     615                max_prealloc = 128 * 1024;
    530616        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    531617                                              snd_dma_isa_data(),
    532                                               64*1024, 64*1024);
     618                                              64*1024, max_prealloc);
    533619
    534620        if (rpcm)
  • GPL/trunk/alsa-kernel/isa/sb/sb_common.c

    r399 r598  
    171171                str = "16 (CS5530)";
    172172                break;
     173        case SB_HW_JAZZ16:
     174                str = "Pro (Jazz16)";
     175                break;
    173176        default:
    174177                return -ENODEV;
  • GPL/trunk/alsa-kernel/isa/sb/sb_mixer.c

    r426 r598  
    529529 */
    530530
    531 static struct sbmix_elem snd_sb20_ctl_master_play_vol =
    532         SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7);
    533 static struct sbmix_elem snd_sb20_ctl_pcm_play_vol =
    534         SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3);
    535 static struct sbmix_elem snd_sb20_ctl_synth_play_vol =
    536         SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7);
    537 static struct sbmix_elem snd_sb20_ctl_cd_play_vol =
    538         SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7);
    539 
    540 static struct sbmix_elem *snd_sb20_controls[] = {
    541         &snd_sb20_ctl_master_play_vol,
    542         &snd_sb20_ctl_pcm_play_vol,
    543         &snd_sb20_ctl_synth_play_vol,
    544         &snd_sb20_ctl_cd_play_vol
     531static struct sbmix_elem snd_sb20_controls[] = {
     532        SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7),
     533        SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3),
     534        SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7),
     535        SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7)
    545536};
    546537
     
    553544 * SB Pro specific mixer elements
    554545 */
    555 static struct sbmix_elem snd_sbpro_ctl_master_play_vol =
    556         SB_DOUBLE("Master Playback Volume", SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7);
    557 static struct sbmix_elem snd_sbpro_ctl_pcm_play_vol =
    558         SB_DOUBLE("PCM Playback Volume", SB_DSP_PCM_DEV, SB_DSP_PCM_DEV, 5, 1, 7);
    559 static struct sbmix_elem snd_sbpro_ctl_pcm_play_filter =
    560         SB_SINGLE("PCM Playback Filter", SB_DSP_PLAYBACK_FILT, 5, 1);
    561 static struct sbmix_elem snd_sbpro_ctl_synth_play_vol =
    562         SB_DOUBLE("Synth Playback Volume", SB_DSP_FM_DEV, SB_DSP_FM_DEV, 5, 1, 7);
    563 static struct sbmix_elem snd_sbpro_ctl_cd_play_vol =
    564         SB_DOUBLE("CD Playback Volume", SB_DSP_CD_DEV, SB_DSP_CD_DEV, 5, 1, 7);
    565 static struct sbmix_elem snd_sbpro_ctl_line_play_vol =
    566         SB_DOUBLE("Line Playback Volume", SB_DSP_LINE_DEV, SB_DSP_LINE_DEV, 5, 1, 7);
    567 static struct sbmix_elem snd_sbpro_ctl_mic_play_vol =
    568         SB_SINGLE("Mic Playback Volume", SB_DSP_MIC_DEV, 1, 3);
    569 static struct sbmix_elem snd_sbpro_ctl_capture_source =
     546static struct sbmix_elem snd_sbpro_controls[] = {
     547        SB_DOUBLE("Master Playback Volume",
     548                  SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7),
     549        SB_DOUBLE("PCM Playback Volume",
     550                  SB_DSP_PCM_DEV, SB_DSP_PCM_DEV, 5, 1, 7),
     551        SB_SINGLE("PCM Playback Filter", SB_DSP_PLAYBACK_FILT, 5, 1),
     552        SB_DOUBLE("Synth Playback Volume",
     553                  SB_DSP_FM_DEV, SB_DSP_FM_DEV, 5, 1, 7),
     554        SB_DOUBLE("CD Playback Volume", SB_DSP_CD_DEV, SB_DSP_CD_DEV, 5, 1, 7),
     555        SB_DOUBLE("Line Playback Volume",
     556                  SB_DSP_LINE_DEV, SB_DSP_LINE_DEV, 5, 1, 7),
     557        SB_SINGLE("Mic Playback Volume", SB_DSP_MIC_DEV, 1, 3),
    570558        {
    571559                .name = "Capture Source",
    572560                .type = SB_MIX_CAPTURE_PRO
    573         };
    574 static struct sbmix_elem snd_sbpro_ctl_capture_filter =
    575         SB_SINGLE("Capture Filter", SB_DSP_CAPTURE_FILT, 5, 1);
    576 static struct sbmix_elem snd_sbpro_ctl_capture_low_filter =
    577         SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 1);
    578 
    579 static struct sbmix_elem *snd_sbpro_controls[] = {
    580         &snd_sbpro_ctl_master_play_vol,
    581         &snd_sbpro_ctl_pcm_play_vol,
    582         &snd_sbpro_ctl_pcm_play_filter,
    583         &snd_sbpro_ctl_synth_play_vol,
    584         &snd_sbpro_ctl_cd_play_vol,
    585         &snd_sbpro_ctl_line_play_vol,
    586         &snd_sbpro_ctl_mic_play_vol,
    587         &snd_sbpro_ctl_capture_source,
    588         &snd_sbpro_ctl_capture_filter,
    589         &snd_sbpro_ctl_capture_low_filter
     561        },
     562        SB_SINGLE("Capture Filter", SB_DSP_CAPTURE_FILT, 5, 1),
     563        SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 1)
    590564};
    591565
     
    599573 * SB16 specific mixer elements
    600574 */
    601 static struct sbmix_elem snd_sb16_ctl_master_play_vol =
    602         SB_DOUBLE("Master Playback Volume", SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31);
    603 static struct sbmix_elem snd_sb16_ctl_3d_enhance_switch =
    604         SB_SINGLE("3D Enhancement Switch", SB_DSP4_3DSE, 0, 1);
    605 static struct sbmix_elem snd_sb16_ctl_tone_bass =
    606         SB_DOUBLE("Tone Control - Bass", SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15);
    607 static struct sbmix_elem snd_sb16_ctl_tone_treble =
    608         SB_DOUBLE("Tone Control - Treble", SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15);
    609 static struct sbmix_elem snd_sb16_ctl_pcm_play_vol =
    610         SB_DOUBLE("PCM Playback Volume", SB_DSP4_PCM_DEV, (SB_DSP4_PCM_DEV + 1), 3, 3, 31);
    611 static struct sbmix_elem snd_sb16_ctl_synth_capture_route =
    612         SB16_INPUT_SW("Synth Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 6, 5);
    613 static struct sbmix_elem snd_sb16_ctl_synth_play_vol =
    614         SB_DOUBLE("Synth Playback Volume", SB_DSP4_SYNTH_DEV, (SB_DSP4_SYNTH_DEV + 1), 3, 3, 31);
    615 static struct sbmix_elem snd_sb16_ctl_cd_capture_route =
    616         SB16_INPUT_SW("CD Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 2, 1);
    617 static struct sbmix_elem snd_sb16_ctl_cd_play_switch =
    618         SB_DOUBLE("CD Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1);
    619 static struct sbmix_elem snd_sb16_ctl_cd_play_vol =
    620         SB_DOUBLE("CD Playback Volume", SB_DSP4_CD_DEV, (SB_DSP4_CD_DEV + 1), 3, 3, 31);
    621 static struct sbmix_elem snd_sb16_ctl_line_capture_route =
    622         SB16_INPUT_SW("Line Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 4, 3);
    623 static struct sbmix_elem snd_sb16_ctl_line_play_switch =
    624         SB_DOUBLE("Line Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1);
    625 static struct sbmix_elem snd_sb16_ctl_line_play_vol =
    626         SB_DOUBLE("Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31);
    627 static struct sbmix_elem snd_sb16_ctl_mic_capture_route =
    628         SB16_INPUT_SW("Mic Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0);
    629 static struct sbmix_elem snd_sb16_ctl_mic_play_switch =
    630         SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1);
    631 static struct sbmix_elem snd_sb16_ctl_mic_play_vol =
    632         SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31);
    633 static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol =
    634         SB_SINGLE("PC Speaker Volume", SB_DSP4_SPEAKER_DEV, 6, 3);
    635 static struct sbmix_elem snd_sb16_ctl_capture_vol =
    636         SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3);
    637 static struct sbmix_elem snd_sb16_ctl_play_vol =
    638         SB_DOUBLE("Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3);
    639 static struct sbmix_elem snd_sb16_ctl_auto_mic_gain =
    640         SB_SINGLE("Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1);
    641 
    642 static struct sbmix_elem *snd_sb16_controls[] = {
    643         &snd_sb16_ctl_master_play_vol,
    644         &snd_sb16_ctl_3d_enhance_switch,
    645         &snd_sb16_ctl_tone_bass,
    646         &snd_sb16_ctl_tone_treble,
    647         &snd_sb16_ctl_pcm_play_vol,
    648         &snd_sb16_ctl_synth_capture_route,
    649         &snd_sb16_ctl_synth_play_vol,
    650         &snd_sb16_ctl_cd_capture_route,
    651         &snd_sb16_ctl_cd_play_switch,
    652         &snd_sb16_ctl_cd_play_vol,
    653         &snd_sb16_ctl_line_capture_route,
    654         &snd_sb16_ctl_line_play_switch,
    655         &snd_sb16_ctl_line_play_vol,
    656         &snd_sb16_ctl_mic_capture_route,
    657         &snd_sb16_ctl_mic_play_switch,
    658         &snd_sb16_ctl_mic_play_vol,
    659         &snd_sb16_ctl_pc_speaker_vol,
    660         &snd_sb16_ctl_capture_vol,
    661         &snd_sb16_ctl_play_vol,
    662         &snd_sb16_ctl_auto_mic_gain
     575static struct sbmix_elem snd_sb16_controls[] = {
     576        SB_DOUBLE("Master Playback Volume",
     577                  SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31),
     578        SB_DOUBLE("PCM Playback Volume",
     579                  SB_DSP4_PCM_DEV, (SB_DSP4_PCM_DEV + 1), 3, 3, 31),
     580        SB16_INPUT_SW("Synth Capture Route",
     581                      SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 6, 5),
     582        SB_DOUBLE("Synth Playback Volume",
     583                  SB_DSP4_SYNTH_DEV, (SB_DSP4_SYNTH_DEV + 1), 3, 3, 31),
     584        SB16_INPUT_SW("CD Capture Route",
     585                      SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 2, 1),
     586        SB_DOUBLE("CD Playback Switch",
     587                  SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1),
     588        SB_DOUBLE("CD Playback Volume",
     589                  SB_DSP4_CD_DEV, (SB_DSP4_CD_DEV + 1), 3, 3, 31),
     590        SB16_INPUT_SW("Mic Capture Route",
     591                      SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0),
     592        SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1),
     593        SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31),
     594        SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3),
     595        SB_DOUBLE("Capture Volume",
     596                  SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3),
     597        SB_DOUBLE("Playback Volume",
     598                  SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3),
     599        SB16_INPUT_SW("Line Capture Route",
     600                      SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 4, 3),
     601        SB_DOUBLE("Line Playback Switch",
     602                  SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1),
     603        SB_DOUBLE("Line Playback Volume",
     604                  SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31),
     605        SB_SINGLE("Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1),
     606        SB_SINGLE("3D Enhancement Switch", SB_DSP4_3DSE, 0, 1),
     607        SB_DOUBLE("Tone Control - Bass",
     608                  SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15),
     609        SB_DOUBLE("Tone Control - Treble",
     610                  SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15)
    663611};
    664612
     
    679627 * DT019x specific mixer elements
    680628 */
    681 static struct sbmix_elem snd_dt019x_ctl_master_play_vol =
    682         SB_DOUBLE("Master Playback Volume", SB_DT019X_MASTER_DEV, SB_DT019X_MASTER_DEV, 4,0, 15);
    683 static struct sbmix_elem snd_dt019x_ctl_pcm_play_vol =
    684         SB_DOUBLE("PCM Playback Volume", SB_DT019X_PCM_DEV, SB_DT019X_PCM_DEV, 4,0, 15);
    685 static struct sbmix_elem snd_dt019x_ctl_synth_play_vol =
    686         SB_DOUBLE("Synth Playback Volume", SB_DT019X_SYNTH_DEV, SB_DT019X_SYNTH_DEV, 4,0, 15);
    687 static struct sbmix_elem snd_dt019x_ctl_cd_play_vol =
    688         SB_DOUBLE("CD Playback Volume", SB_DT019X_CD_DEV, SB_DT019X_CD_DEV, 4,0, 15);
    689 static struct sbmix_elem snd_dt019x_ctl_mic_play_vol =
    690         SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7);
    691 static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol =
    692         SB_SINGLE("PC Speaker Volume", SB_DT019X_SPKR_DEV, 0,  7);
    693 static struct sbmix_elem snd_dt019x_ctl_line_play_vol =
    694         SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15);
    695 static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch =
    696         SB_DOUBLE("PCM Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2,1, 1);
    697 static struct sbmix_elem snd_dt019x_ctl_synth_play_switch =
    698         SB_DOUBLE("Synth Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4,3, 1);
    699 static struct sbmix_elem snd_dt019x_ctl_capture_source =
     629static struct sbmix_elem snd_dt019x_controls[] = {
     630        /* ALS4000 below has some parts which we might be lacking,
     631         * e.g. snd_als4000_ctl_mono_playback_switch - check it! */
     632        SB_DOUBLE("Master Playback Volume",
     633                  SB_DT019X_MASTER_DEV, SB_DT019X_MASTER_DEV, 4, 0, 15),
     634        SB_DOUBLE("PCM Playback Switch",
     635                  SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1),
     636        SB_DOUBLE("PCM Playback Volume",
     637                  SB_DT019X_PCM_DEV, SB_DT019X_PCM_DEV, 4, 0, 15),
     638        SB_DOUBLE("Synth Playback Switch",
     639                  SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4, 3, 1),
     640        SB_DOUBLE("Synth Playback Volume",
     641                  SB_DT019X_SYNTH_DEV, SB_DT019X_SYNTH_DEV, 4, 0, 15),
     642        SB_DOUBLE("CD Playback Switch",
     643                  SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1),
     644        SB_DOUBLE("CD Playback Volume",
     645                  SB_DT019X_CD_DEV, SB_DT019X_CD_DEV, 4, 0, 15),
     646        SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1),
     647        SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7),
     648        SB_SINGLE("Beep Volume", SB_DT019X_SPKR_DEV, 0,  7),
     649        SB_DOUBLE("Line Playback Switch",
     650                  SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1),
     651        SB_DOUBLE("Line Playback Volume",
     652                  SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4, 0, 15),
    700653        {
    701654                .name = "Capture Source",
    702655                .type = SB_MIX_CAPTURE_DT019X
    703         };
    704 
    705 static struct sbmix_elem *snd_dt019x_controls[] = {
    706         /* ALS4000 below has some parts which we might be lacking,
    707          * e.g. snd_als4000_ctl_mono_playback_switch - check it! */
    708         &snd_dt019x_ctl_master_play_vol,
    709         &snd_dt019x_ctl_pcm_play_vol,
    710         &snd_dt019x_ctl_synth_play_vol,
    711         &snd_dt019x_ctl_cd_play_vol,
    712         &snd_dt019x_ctl_mic_play_vol,
    713         &snd_dt019x_ctl_pc_speaker_vol,
    714         &snd_dt019x_ctl_line_play_vol,
    715         &snd_sb16_ctl_mic_play_switch,
    716         &snd_sb16_ctl_cd_play_switch,
    717         &snd_sb16_ctl_line_play_switch,
    718         &snd_dt019x_ctl_pcm_play_switch,
    719         &snd_dt019x_ctl_synth_play_switch,
    720         &snd_dt019x_ctl_capture_source
     656        }
    721657};
    722658
     
    736672 * ALS4000 specific mixer elements
    737673 */
    738 static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch =
    739         SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1);
    740 static struct sbmix_elem snd_als4k_ctl_master_mono_capture_route = {
     674static struct sbmix_elem snd_als4000_controls[] = {
     675        SB_DOUBLE("PCM Playback Switch",
     676                  SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1),
     677        SB_DOUBLE("Synth Playback Switch",
     678                  SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4, 3, 1),
     679        SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03),
     680        SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1),
     681        {
    741682                .name = "Master Mono Capture Route",
    742683                .type = SB_MIX_MONO_CAPTURE_ALS4K
    743         };
    744 static struct sbmix_elem snd_als4000_ctl_mono_playback_switch =
    745         SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1);
    746 static struct sbmix_elem snd_als4000_ctl_mic_20db_boost =
    747         SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03);
    748 static struct sbmix_elem snd_als4000_ctl_mixer_analog_loopback =
    749         SB_SINGLE("Analog Loopback Switch", SB_ALS4000_MIC_IN_GAIN, 7, 0x01);
    750 static struct sbmix_elem snd_als4000_ctl_mixer_digital_loopback =
     684        },
     685        SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1),
     686        SB_SINGLE("Analog Loopback Switch", SB_ALS4000_MIC_IN_GAIN, 7, 0x01),
     687        SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01),
    751688        SB_SINGLE("Digital Loopback Switch",
    752                   SB_ALS4000_CR3_CONFIGURATION, 7, 0x01);
    753 /* FIXME: functionality of 3D controls might be swapped, I didn't find
    754  * a description of how to identify what is supposed to be what */
    755 static struct sbmix_elem snd_als4000_3d_control_switch =
    756         SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01);
    757 static struct sbmix_elem snd_als4000_3d_control_ratio =
    758         SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07);
    759 static struct sbmix_elem snd_als4000_3d_control_freq =
     689                  SB_ALS4000_CR3_CONFIGURATION, 7, 0x01),
     690        /* FIXME: functionality of 3D controls might be swapped, I didn't find
     691         * a description of how to identify what is supposed to be what */
     692        SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07),
    760693        /* FIXME: maybe there's actually some standard 3D ctrl name for it?? */
    761         SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03);
    762 static struct sbmix_elem snd_als4000_3d_control_delay =
     694        SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03),
    763695        /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay,
    764696         * but what ALSA 3D attribute is that actually? "Center", "Depth",
    765697         * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */
    766         SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f);
    767 static struct sbmix_elem snd_als4000_3d_control_poweroff_switch =
    768         SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01);
    769 static struct sbmix_elem snd_als4000_ctl_3db_freq_control_switch =
     698        SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f),
     699        SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01),
    770700        SB_SINGLE("Master Playback 8kHz / 20kHz LPF Switch",
    771                   SB_ALS4000_FMDAC, 5, 0x01);
     701                  SB_ALS4000_FMDAC, 5, 0x01),
    772702#ifdef NOT_AVAILABLE
    773 static struct sbmix_elem snd_als4000_ctl_fmdac =
    774         SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01);
    775 static struct sbmix_elem snd_als4000_ctl_qsound =
    776         SB_SINGLE("QSound Mode", SB_ALS4000_QSOUND, 1, 0x1f);
    777 #endif
    778 
    779 static struct sbmix_elem *snd_als4000_controls[] = {
    780                                                 /* ALS4000a.PDF regs page */
    781         &snd_sb16_ctl_master_play_vol,          /* MX30/31 12 */
    782         &snd_dt019x_ctl_pcm_play_switch,        /* MX4C    16 */
    783         &snd_sb16_ctl_pcm_play_vol,             /* MX32/33 12 */
    784         &snd_sb16_ctl_synth_capture_route,      /* MX3D/3E 14 */
    785         &snd_dt019x_ctl_synth_play_switch,      /* MX4C    16 */
    786         &snd_sb16_ctl_synth_play_vol,           /* MX34/35 12/13 */
    787         &snd_sb16_ctl_cd_capture_route,         /* MX3D/3E 14 */
    788         &snd_sb16_ctl_cd_play_switch,           /* MX3C    14 */
    789         &snd_sb16_ctl_cd_play_vol,              /* MX36/37 13 */
    790         &snd_sb16_ctl_line_capture_route,       /* MX3D/3E 14 */
    791         &snd_sb16_ctl_line_play_switch,         /* MX3C    14 */
    792         &snd_sb16_ctl_line_play_vol,            /* MX38/39 13 */
    793         &snd_sb16_ctl_mic_capture_route,        /* MX3D/3E 14 */
    794         &snd_als4000_ctl_mic_20db_boost,        /* MX4D    16 */
    795         &snd_sb16_ctl_mic_play_switch,          /* MX3C    14 */
    796         &snd_sb16_ctl_mic_play_vol,             /* MX3A    13 */
    797         &snd_sb16_ctl_pc_speaker_vol,           /* MX3B    14 */
    798         &snd_sb16_ctl_capture_vol,              /* MX3F/40 15 */
    799         &snd_sb16_ctl_play_vol,                 /* MX41/42 15 */
    800         &snd_als4000_ctl_master_mono_playback_switch, /* MX4C 16 */
    801         &snd_als4k_ctl_master_mono_capture_route, /* MX4B  16 */
    802         &snd_als4000_ctl_mono_playback_switch,  /* MX4C    16 */
    803         &snd_als4000_ctl_mixer_analog_loopback, /* MX4D    16 */
    804         &snd_als4000_ctl_mixer_digital_loopback, /* CR3    21 */
    805         &snd_als4000_3d_control_switch,          /* MX50   17 */
    806         &snd_als4000_3d_control_ratio,           /* MX50   17 */
    807         &snd_als4000_3d_control_freq,            /* MX50   17 */
    808         &snd_als4000_3d_control_delay,           /* MX51   18 */
    809         &snd_als4000_3d_control_poweroff_switch,        /* MX51    18 */
    810         &snd_als4000_ctl_3db_freq_control_switch,       /* MX4F    17 */
    811 #ifdef NOT_AVAILABLE
    812         &snd_als4000_ctl_fmdac,
    813         &snd_als4000_ctl_qsound,
     703        SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01),
     704        SB_SINGLE("QSound Mode", SB_ALS4000_QSOUND, 1, 0x1f),
    814705#endif
    815706};
     
    830721};
    831722
    832 
    833723/*
    834724 */
    835725static int snd_sbmixer_init(struct snd_sb *chip,
    836                             struct sbmix_elem **controls,
     726                            struct sbmix_elem *controls,
    837727                            int controls_count,
    838728                            unsigned char map[][2],
     
    857747
    858748        for (idx = 0; idx < controls_count; idx++) {
    859                 if ((err = snd_sbmixer_add_ctl_elem(chip, controls[idx])) < 0)
     749                err = snd_sbmixer_add_ctl_elem(chip, &controls[idx]);
     750                if (err < 0)
    860751                        return err;
    861752        }
     
    889780                break;
    890781        case SB_HW_PRO:
     782        case SB_HW_JAZZ16:
    891783                if ((err = snd_sbmixer_init(chip,
    892784                                            snd_sbpro_controls,
     
    909801                break;
    910802        case SB_HW_ALS4000:
     803                /* use only the first 16 controls from SB16 */
     804                err = snd_sbmixer_init(chip,
     805                                        snd_sb16_controls,
     806                                        16,
     807                                        snd_sb16_init_values,
     808                                        ARRAY_SIZE(snd_sb16_init_values),
     809                                        "ALS4000");
     810                if (err < 0)
     811                        return err;
    911812                if ((err = snd_sbmixer_init(chip,
    912813                                            snd_als4000_controls,
     
    1030931                break;
    1031932        case SB_HW_PRO:
     933        case SB_HW_JAZZ16:
    1032934                save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs));
    1033935                break;
     
    1056958                break;
    1057959        case SB_HW_PRO:
     960        case SB_HW_JAZZ16:
    1058961                restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs));
    1059962                break;
  • GPL/trunk/alsa-kernel/isa/wavefront/wavefront.c

    r426 r598  
    2222#include <linux/init.h>
    2323#include <linux/interrupt.h>
    24 #include <linux/slab.h>
    2524#include <linux/err.h>
    2625#include <linux/isa.h>
  • GPL/trunk/alsa-kernel/isa/wavefront/wavefront_fx.c

    r479 r598  
    2121#include <linux/time.h>
    2222#include <linux/wait.h>
     23#include <linux/slab.h>
    2324#include <linux/firmware.h>
    2425#include <sound/core.h>
  • GPL/trunk/alsa-kernel/isa/wavefront/wavefront_synth.c

    r426 r598  
    2929#include <linux/firmware.h>
    3030#include <linux/moduleparam.h>
     31#include <linux/slab.h>
    3132#include <sound/core.h>
    3233#include <sound/snd_wavefront.h>
Note: See TracChangeset for help on using the changeset viewer.