diff options
Diffstat (limited to 'sound/isa')
31 files changed, 2181 insertions, 1872 deletions
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 51a7e3777e17..755a0a5f0e3f 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig | |||
| @@ -63,15 +63,16 @@ config SND_AD1848 | |||
| 63 | will be called snd-ad1848. | 63 | will be called snd-ad1848. |
| 64 | 64 | ||
| 65 | config SND_ALS100 | 65 | config SND_ALS100 |
| 66 | tristate "Avance Logic ALS100/ALS120" | 66 | tristate "Diamond Tech. DT-019x and Avance Logic ALSxxx" |
| 67 | depends on PNP | 67 | depends on PNP |
| 68 | select ISAPNP | 68 | select ISAPNP |
| 69 | select SND_OPL3_LIB | 69 | select SND_OPL3_LIB |
| 70 | select SND_MPU401_UART | 70 | select SND_MPU401_UART |
| 71 | select SND_SB16_DSP | 71 | select SND_SB16_DSP |
| 72 | help | 72 | help |
| 73 | Say Y here to include support for soundcards based on Avance | 73 | Say Y here to include support for soundcards based on the |
| 74 | Logic ALS100, ALS110, ALS120 and ALS200 chips. | 74 | Diamond Technologies DT-019X or Avance Logic chips: ALS007, |
| 75 | ALS100, ALS110, ALS120 and ALS200 chips. | ||
| 75 | 76 | ||
| 76 | To compile this driver as a module, choose M here: the module | 77 | To compile this driver as a module, choose M here: the module |
| 77 | will be called snd-als100. | 78 | will be called snd-als100. |
| @@ -127,20 +128,6 @@ config SND_CS4236 | |||
| 127 | To compile this driver as a module, choose M here: the module | 128 | To compile this driver as a module, choose M here: the module |
| 128 | will be called snd-cs4236. | 129 | will be called snd-cs4236. |
| 129 | 130 | ||
| 130 | config SND_DT019X | ||
| 131 | tristate "Diamond Technologies DT-019X, Avance Logic ALS-007" | ||
| 132 | depends on PNP | ||
| 133 | select ISAPNP | ||
| 134 | select SND_OPL3_LIB | ||
| 135 | select SND_MPU401_UART | ||
| 136 | select SND_SB16_DSP | ||
| 137 | help | ||
| 138 | Say Y here to include support for soundcards based on the | ||
| 139 | Diamond Technologies DT-019X or Avance Logic ALS-007 chips. | ||
| 140 | |||
| 141 | To compile this driver as a module, choose M here: the module | ||
| 142 | will be called snd-dt019x. | ||
| 143 | |||
| 144 | config SND_ES968 | 131 | config SND_ES968 |
| 145 | tristate "Generic ESS ES968 driver" | 132 | tristate "Generic ESS ES968 driver" |
| 146 | depends on PNP | 133 | depends on PNP |
| @@ -252,6 +239,22 @@ config SND_INTERWAVE_STB | |||
| 252 | To compile this driver as a module, choose M here: the module | 239 | To compile this driver as a module, choose M here: the module |
| 253 | will be called snd-interwave-stb. | 240 | will be called snd-interwave-stb. |
| 254 | 241 | ||
| 242 | config SND_JAZZ16 | ||
| 243 | tristate "Media Vision Jazz16 card and compatibles" | ||
| 244 | select SND_OPL3_LIB | ||
| 245 | select SND_MPU401_UART | ||
| 246 | select SND_SB8_DSP | ||
| 247 | help | ||
| 248 | Say Y here to include support for soundcards based on the | ||
| 249 | Media Vision Jazz16 chipset: digital chip MVD1216 (Jazz16), | ||
| 250 | codec MVA416 (CS4216) and mixer MVA514 (ICS2514). | ||
| 251 | Media Vision's Jazz16 cards were sold under names Pro Sonic 16, | ||
| 252 | Premium 3-D and Pro 3-D. There were also OEMs cards with the | ||
| 253 | Jazz16 chipset. | ||
| 254 | |||
| 255 | To compile this driver as a module, choose M here: the module | ||
| 256 | will be called snd-jazz16. | ||
| 257 | |||
| 255 | config SND_OPL3SA2 | 258 | config SND_OPL3SA2 |
| 256 | tristate "Yamaha OPL3-SA2/SA3" | 259 | tristate "Yamaha OPL3-SA2/SA3" |
| 257 | select SND_OPL3_LIB | 260 | select SND_OPL3_LIB |
| @@ -372,15 +375,21 @@ config SND_SGALAXY | |||
| 372 | 375 | ||
| 373 | config SND_SSCAPE | 376 | config SND_SSCAPE |
| 374 | tristate "Ensoniq SoundScape driver" | 377 | tristate "Ensoniq SoundScape driver" |
| 375 | select SND_HWDEP | ||
| 376 | select SND_MPU401_UART | 378 | select SND_MPU401_UART |
| 377 | select SND_WSS_LIB | 379 | select SND_WSS_LIB |
| 380 | select FW_LOADER | ||
| 378 | help | 381 | help |
| 379 | Say Y here to include support for Ensoniq SoundScape | 382 | Say Y here to include support for Ensoniq SoundScape |
| 380 | soundcards. | 383 | and Ensoniq OEM soundcards. |
| 381 | 384 | ||
| 382 | The PCM audio is supported on SoundScape Classic, Elite, PnP | 385 | The PCM audio is supported on SoundScape Classic, Elite, PnP |
| 383 | and VIVO cards. The MIDI support is very experimental. | 386 | and VIVO cards. The supported OEM cards are SPEA Media FX and |
| 387 | Reveal SC-600. | ||
| 388 | The MIDI support is very experimental and requires binary | ||
| 389 | firmware files called "scope.cod" and "sndscape.co?" where the | ||
| 390 | ? is digit 0, 1, 2, 3 or 4. The firmware files can be found | ||
| 391 | in DOS or Windows driver packages. One has to put the firmware | ||
| 392 | files into the /lib/firmware directory. | ||
| 384 | 393 | ||
| 385 | To compile this driver as a module, choose M here: the module | 394 | To compile this driver as a module, choose M here: the module |
| 386 | will be called snd-sscape. | 395 | will be called snd-sscape. |
diff --git a/sound/isa/Makefile b/sound/isa/Makefile index b906b9a1a81e..c73d30c4f462 100644 --- a/sound/isa/Makefile +++ b/sound/isa/Makefile | |||
| @@ -7,7 +7,6 @@ snd-adlib-objs := adlib.o | |||
| 7 | snd-als100-objs := als100.o | 7 | snd-als100-objs := als100.o |
| 8 | snd-azt2320-objs := azt2320.o | 8 | snd-azt2320-objs := azt2320.o |
| 9 | snd-cmi8330-objs := cmi8330.o | 9 | snd-cmi8330-objs := cmi8330.o |
| 10 | snd-dt019x-objs := dt019x.o | ||
| 11 | snd-es18xx-objs := es18xx.o | 10 | snd-es18xx-objs := es18xx.o |
| 12 | snd-opl3sa2-objs := opl3sa2.o | 11 | snd-opl3sa2-objs := opl3sa2.o |
| 13 | snd-sc6000-objs := sc6000.o | 12 | snd-sc6000-objs := sc6000.o |
| @@ -19,7 +18,6 @@ obj-$(CONFIG_SND_ADLIB) += snd-adlib.o | |||
| 19 | obj-$(CONFIG_SND_ALS100) += snd-als100.o | 18 | obj-$(CONFIG_SND_ALS100) += snd-als100.o |
| 20 | obj-$(CONFIG_SND_AZT2320) += snd-azt2320.o | 19 | obj-$(CONFIG_SND_AZT2320) += snd-azt2320.o |
| 21 | obj-$(CONFIG_SND_CMI8330) += snd-cmi8330.o | 20 | obj-$(CONFIG_SND_CMI8330) += snd-cmi8330.o |
| 22 | obj-$(CONFIG_SND_DT019X) += snd-dt019x.o | ||
| 23 | obj-$(CONFIG_SND_ES18XX) += snd-es18xx.o | 21 | obj-$(CONFIG_SND_ES18XX) += snd-es18xx.o |
| 24 | obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o | 22 | obj-$(CONFIG_SND_OPL3SA2) += snd-opl3sa2.o |
| 25 | obj-$(CONFIG_SND_SC6000) += snd-sc6000.o | 23 | obj-$(CONFIG_SND_SC6000) += snd-sc6000.o |
diff --git a/sound/isa/als100.c b/sound/isa/als100.c index 5fd52e4d7079..20becc89f6f6 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c | |||
| @@ -2,9 +2,13 @@ | |||
| 2 | /* | 2 | /* |
| 3 | card-als100.c - driver for Avance Logic ALS100 based soundcards. | 3 | card-als100.c - driver for Avance Logic ALS100 based soundcards. |
| 4 | Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it> | 4 | Copyright (C) 1999-2000 by Massimo Piccioni <dafastidio@libero.it> |
| 5 | Copyright (C) 1999-2002 by Massimo Piccioni <dafastidio@libero.it> | ||
| 5 | 6 | ||
| 6 | Thanks to Pierfrancesco 'qM2' Passerini. | 7 | Thanks to Pierfrancesco 'qM2' Passerini. |
| 7 | 8 | ||
| 9 | Generalised for soundcards based on DT-0196 and ALS-007 chips | ||
| 10 | by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>: June 2002. | ||
| 11 | |||
| 8 | This program is free software; you can redistribute it and/or modify | 12 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by | 13 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 2 of the License, or | 14 | the Free Software Foundation; either version 2 of the License, or |
| @@ -33,10 +37,10 @@ | |||
| 33 | 37 | ||
| 34 | #define PFX "als100: " | 38 | #define PFX "als100: " |
| 35 | 39 | ||
| 36 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); | 40 | MODULE_DESCRIPTION("Avance Logic ALS007/ALS1X0"); |
| 37 | MODULE_DESCRIPTION("Avance Logic ALS1X0"); | 41 | MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X}," |
| 38 | MODULE_LICENSE("GPL"); | 42 | "{Avance Logic ALS-007}}" |
| 39 | MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS100 - PRO16PNP}," | 43 | "{{Avance Logic,ALS100 - PRO16PNP}," |
| 40 | "{Avance Logic,ALS110}," | 44 | "{Avance Logic,ALS110}," |
| 41 | "{Avance Logic,ALS120}," | 45 | "{Avance Logic,ALS120}," |
| 42 | "{Avance Logic,ALS200}," | 46 | "{Avance Logic,ALS200}," |
| @@ -45,9 +49,12 @@ MODULE_SUPPORTED_DEVICE("{{Avance Logic,ALS100 - PRO16PNP}," | |||
| 45 | "{Avance Logic,ALS120}," | 49 | "{Avance Logic,ALS120}," |
| 46 | "{RTL,RTL3000}}"); | 50 | "{RTL,RTL3000}}"); |
| 47 | 51 | ||
| 52 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); | ||
| 53 | MODULE_LICENSE("GPL"); | ||
| 54 | |||
| 48 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | 55 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
| 49 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 56 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
| 50 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ | 57 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ |
| 51 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 58 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
| 52 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 59 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
| 53 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | 60 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ |
| @@ -57,14 +64,15 @@ static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ | |||
| 57 | static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ | 64 | static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ |
| 58 | 65 | ||
| 59 | module_param_array(index, int, NULL, 0444); | 66 | module_param_array(index, int, NULL, 0444); |
| 60 | MODULE_PARM_DESC(index, "Index value for als100 based soundcard."); | 67 | MODULE_PARM_DESC(index, "Index value for Avance Logic based soundcard."); |
| 61 | module_param_array(id, charp, NULL, 0444); | 68 | module_param_array(id, charp, NULL, 0444); |
| 62 | MODULE_PARM_DESC(id, "ID string for als100 based soundcard."); | 69 | MODULE_PARM_DESC(id, "ID string for Avance Logic based soundcard."); |
| 63 | module_param_array(enable, bool, NULL, 0444); | 70 | module_param_array(enable, bool, NULL, 0444); |
| 64 | MODULE_PARM_DESC(enable, "Enable als100 based soundcard."); | 71 | MODULE_PARM_DESC(enable, "Enable Avance Logic based soundcard."); |
| 72 | |||
| 73 | MODULE_ALIAS("snd-dt019x"); | ||
| 65 | 74 | ||
| 66 | struct snd_card_als100 { | 75 | struct snd_card_als100 { |
| 67 | int dev_no; | ||
| 68 | struct pnp_dev *dev; | 76 | struct pnp_dev *dev; |
| 69 | struct pnp_dev *devmpu; | 77 | struct pnp_dev *devmpu; |
| 70 | struct pnp_dev *devopl; | 78 | struct pnp_dev *devopl; |
| @@ -72,25 +80,43 @@ struct snd_card_als100 { | |||
| 72 | }; | 80 | }; |
| 73 | 81 | ||
| 74 | static struct pnp_card_device_id snd_als100_pnpids[] = { | 82 | static 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 }, | ||
| 75 | /* ALS100 - PRO16PNP */ | 91 | /* 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 }, | ||
| 77 | /* ALS110 - MF1000 - Digimate 3D Sound */ | 95 | /* 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 }, | ||
| 79 | /* ALS120 */ | 99 | /* 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 }, | ||
| 81 | /* ALS200 */ | 103 | /* 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 }, | ||
| 83 | /* ALS200 OEM */ | 107 | /* 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 }, | ||
| 85 | /* RTL3000 */ | 111 | /* RTL3000 */ |
| 86 | { .id = "RTL3000", .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } } }, | 112 | { .id = "RTL3000", |
| 87 | { .id = "", } /* end */ | 113 | .devs = { { "@@@2001" }, { "@X@2001" }, { "@H@2001" } }, |
| 114 | .driver_data = SB_HW_ALS100 }, | ||
| 115 | { .id = "" } /* end */ | ||
| 88 | }; | 116 | }; |
| 89 | 117 | ||
| 90 | MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids); | 118 | MODULE_DEVICE_TABLE(pnp_card, snd_als100_pnpids); |
| 91 | 119 | ||
| 92 | #define DRIVER_NAME "snd-card-als100" | ||
| 93 | |||
| 94 | static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, | 120 | static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, |
| 95 | struct pnp_card_link *card, | 121 | struct pnp_card_link *card, |
| 96 | const struct pnp_card_device_id *id) | 122 | const struct pnp_card_device_id *id) |
| @@ -113,8 +139,12 @@ static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, | |||
| 113 | return err; | 139 | return err; |
| 114 | } | 140 | } |
| 115 | port[dev] = pnp_port_start(pdev, 0); | 141 | port[dev] = pnp_port_start(pdev, 0); |
| 116 | dma8[dev] = pnp_dma(pdev, 1); | 142 | if (id->driver_data == SB_HW_DT019X) |
| 117 | dma16[dev] = pnp_dma(pdev, 0); | 143 | dma8[dev] = pnp_dma(pdev, 0); |
| 144 | else { | ||
| 145 | dma8[dev] = pnp_dma(pdev, 1); | ||
| 146 | dma16[dev] = pnp_dma(pdev, 0); | ||
| 147 | } | ||
| 118 | irq[dev] = pnp_irq(pdev, 0); | 148 | irq[dev] = pnp_irq(pdev, 0); |
| 119 | 149 | ||
| 120 | pdev = acard->devmpu; | 150 | pdev = acard->devmpu; |
| @@ -175,22 +205,33 @@ static int __devinit snd_card_als100_probe(int dev, | |||
| 175 | } | 205 | } |
| 176 | snd_card_set_dev(card, &pcard->card->dev); | 206 | snd_card_set_dev(card, &pcard->card->dev); |
| 177 | 207 | ||
| 178 | if ((error = snd_sbdsp_create(card, port[dev], | 208 | if (pid->driver_data == SB_HW_DT019X) |
| 179 | irq[dev], | 209 | dma16[dev] = -1; |
| 180 | snd_sb16dsp_interrupt, | 210 | |
| 181 | dma8[dev], | 211 | error = snd_sbdsp_create(card, port[dev], irq[dev], |
| 182 | dma16[dev], | 212 | snd_sb16dsp_interrupt, |
| 183 | SB_HW_ALS100, &chip)) < 0) { | 213 | dma8[dev], dma16[dev], |
| 214 | pid->driver_data, | ||
| 215 | &chip); | ||
| 216 | if (error < 0) { | ||
| 184 | snd_card_free(card); | 217 | snd_card_free(card); |
| 185 | return error; | 218 | return error; |
| 186 | } | 219 | } |
| 187 | acard->chip = chip; | 220 | acard->chip = chip; |
| 188 | 221 | ||
| 189 | strcpy(card->driver, "ALS100"); | 222 | if (pid->driver_data == SB_HW_DT019X) { |
| 190 | strcpy(card->shortname, "Avance Logic ALS100"); | 223 | strcpy(card->driver, "DT-019X"); |
| 191 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", | 224 | strcpy(card->shortname, "Diamond Tech. DT-019X"); |
| 192 | card->shortname, chip->name, chip->port, | 225 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", |
| 193 | irq[dev], dma8[dev], dma16[dev]); | 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 | } | ||
| 194 | 235 | ||
| 195 | if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { | 236 | if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { |
| 196 | snd_card_free(card); | 237 | snd_card_free(card); |
| @@ -203,9 +244,19 @@ static int __devinit snd_card_als100_probe(int dev, | |||
| 203 | } | 244 | } |
| 204 | 245 | ||
| 205 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | 246 | 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, | ||
| 207 | mpu_port[dev], 0, | 257 | mpu_port[dev], 0, |
| 208 | mpu_irq[dev], IRQF_DISABLED, | 258 | mpu_irq[dev], |
| 259 | mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, | ||
| 209 | NULL) < 0) | 260 | NULL) < 0) |
| 210 | snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]); | 261 | snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]); |
| 211 | } | 262 | } |
| @@ -291,7 +342,7 @@ static int snd_als100_pnp_resume(struct pnp_card_link *pcard) | |||
| 291 | 342 | ||
| 292 | static struct pnp_card_driver als100_pnpc_driver = { | 343 | static struct pnp_card_driver als100_pnpc_driver = { |
| 293 | .flags = PNP_DRIVER_RES_DISABLE, | 344 | .flags = PNP_DRIVER_RES_DISABLE, |
| 294 | .name = "als100", | 345 | .name = "als100", |
| 295 | .id_table = snd_als100_pnpids, | 346 | .id_table = snd_als100_pnpids, |
| 296 | .probe = snd_als100_pnp_detect, | 347 | .probe = snd_als100_pnp_detect, |
| 297 | .remove = __devexit_p(snd_als100_pnp_remove), | 348 | .remove = __devexit_p(snd_als100_pnp_remove), |
| @@ -312,7 +363,7 @@ static int __init alsa_card_als100_init(void) | |||
| 312 | if (!als100_devices) { | 363 | if (!als100_devices) { |
| 313 | pnp_unregister_card_driver(&als100_pnpc_driver); | 364 | pnp_unregister_card_driver(&als100_pnpc_driver); |
| 314 | #ifdef MODULE | 365 | #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"); |
| 316 | #endif | 367 | #endif |
| 317 | return -ENODEV; | 368 | return -ENODEV; |
| 318 | } | 369 | } |
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index 02f79d252718..fe79a169acb5 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c | |||
| @@ -46,7 +46,6 @@ | |||
| 46 | #include <linux/init.h> | 46 | #include <linux/init.h> |
| 47 | #include <linux/err.h> | 47 | #include <linux/err.h> |
| 48 | #include <linux/isa.h> | 48 | #include <linux/isa.h> |
| 49 | #include <linux/slab.h> | ||
| 50 | #include <linux/pnp.h> | 49 | #include <linux/pnp.h> |
| 51 | #include <linux/moduleparam.h> | 50 | #include <linux/moduleparam.h> |
| 52 | #include <sound/core.h> | 51 | #include <sound/core.h> |
| @@ -237,7 +236,7 @@ WSS_DOUBLE("Wavetable Capture Volume", 0, | |||
| 237 | CMI8330_WAVGAIN, CMI8330_WAVGAIN, 4, 0, 15, 0), | 236 | CMI8330_WAVGAIN, CMI8330_WAVGAIN, 4, 0, 15, 0), |
| 238 | WSS_SINGLE("3D Control - Switch", 0, | 237 | WSS_SINGLE("3D Control - Switch", 0, |
| 239 | CMI8330_RMUX3D, 5, 1, 1), | 238 | CMI8330_RMUX3D, 5, 1, 1), |
| 240 | WSS_SINGLE("PC Speaker Playback Volume", 0, | 239 | WSS_SINGLE("Beep Playback Volume", 0, |
| 241 | CMI8330_OUTPUTVOL, 3, 3, 0), | 240 | CMI8330_OUTPUTVOL, 3, 3, 0), |
| 242 | WSS_DOUBLE("FM Playback Switch", 0, | 241 | WSS_DOUBLE("FM Playback Switch", 0, |
| 243 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 242 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
| @@ -262,7 +261,7 @@ SB_DOUBLE("SB Line Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, | |||
| 262 | SB_DOUBLE("SB Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31), | 261 | SB_DOUBLE("SB Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31), |
| 263 | SB_SINGLE("SB Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), | 262 | SB_SINGLE("SB Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), |
| 264 | SB_SINGLE("SB Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), | 263 | SB_SINGLE("SB Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), |
| 265 | SB_SINGLE("SB PC Speaker Volume", SB_DSP4_SPEAKER_DEV, 6, 3), | 264 | SB_SINGLE("SB Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3), |
| 266 | SB_DOUBLE("SB Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3), | 265 | SB_DOUBLE("SB Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3), |
| 267 | SB_DOUBLE("SB Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3), | 266 | SB_DOUBLE("SB Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3), |
| 268 | SB_SINGLE("SB Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1), | 267 | SB_SINGLE("SB Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1), |
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index a076a6ce8071..999dc1e0fdbd 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
| 23 | #include <linux/err.h> | 23 | #include <linux/err.h> |
| 24 | #include <linux/isa.h> | 24 | #include <linux/isa.h> |
| 25 | #include <linux/slab.h> | ||
| 26 | #include <linux/pnp.h> | 25 | #include <linux/pnp.h> |
| 27 | #include <linux/moduleparam.h> | 26 | #include <linux/moduleparam.h> |
| 28 | #include <sound/core.h> | 27 | #include <sound/core.h> |
| @@ -177,7 +176,7 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = { | |||
| 177 | { .id = "CSC0437", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, | 176 | { .id = "CSC0437", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 178 | /* Digital PC 5000 Onboard - CS4236B */ | 177 | /* Digital PC 5000 Onboard - CS4236B */ |
| 179 | { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } }, | 178 | { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } }, |
| 180 | /* some uknown CS4236B */ | 179 | /* some unknown CS4236B */ |
| 181 | { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, | 180 | { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| 182 | /* Intel PR440FX Onboard sound */ | 181 | /* Intel PR440FX Onboard sound */ |
| 183 | { .id = "CSC0b36", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, | 182 | { .id = "CSC0b36", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
| @@ -394,21 +393,15 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev) | |||
| 394 | return -EBUSY; | 393 | return -EBUSY; |
| 395 | } | 394 | } |
| 396 | 395 | ||
| 397 | err = snd_wss_create(card, port[dev], cport[dev], | 396 | err = snd_cs4236_create(card, port[dev], cport[dev], |
| 398 | irq[dev], | 397 | irq[dev], |
| 399 | dma1[dev], dma2[dev], | 398 | dma1[dev], dma2[dev], |
| 400 | WSS_HW_DETECT3, 0, &chip); | 399 | WSS_HW_DETECT3, 0, &chip); |
| 401 | if (err < 0) | 400 | if (err < 0) |
| 402 | return err; | 401 | return err; |
| 402 | |||
| 403 | acard->chip = chip; | ||
| 403 | if (chip->hardware & WSS_HW_CS4236B_MASK) { | 404 | 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; | ||
| 412 | 405 | ||
| 413 | err = snd_cs4236_pcm(chip, 0, &pcm); | 406 | err = snd_cs4236_pcm(chip, 0, &pcm); |
| 414 | if (err < 0) | 407 | if (err < 0) |
| @@ -418,7 +411,6 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev) | |||
| 418 | if (err < 0) | 411 | if (err < 0) |
| 419 | return err; | 412 | return err; |
| 420 | } else { | 413 | } else { |
| 421 | acard->chip = chip; | ||
| 422 | err = snd_wss_pcm(chip, 0, &pcm); | 414 | err = snd_wss_pcm(chip, 0, &pcm); |
| 423 | if (err < 0) | 415 | if (err < 0) |
| 424 | return err; | 416 | return err; |
diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index 38835f31298b..c5adca300632 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c | |||
| @@ -87,6 +87,8 @@ | |||
| 87 | #include <sound/core.h> | 87 | #include <sound/core.h> |
| 88 | #include <sound/wss.h> | 88 | #include <sound/wss.h> |
| 89 | #include <sound/asoundef.h> | 89 | #include <sound/asoundef.h> |
| 90 | #include <sound/initval.h> | ||
| 91 | #include <sound/tlv.h> | ||
| 90 | 92 | ||
| 91 | /* | 93 | /* |
| 92 | * | 94 | * |
| @@ -264,7 +266,10 @@ static void snd_cs4236_resume(struct snd_wss *chip) | |||
| 264 | } | 266 | } |
| 265 | 267 | ||
| 266 | #endif /* CONFIG_PM */ | 268 | #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 | */ | ||
| 268 | int snd_cs4236_create(struct snd_card *card, | 273 | int snd_cs4236_create(struct snd_card *card, |
| 269 | unsigned long port, | 274 | unsigned long port, |
| 270 | unsigned long cport, | 275 | unsigned long cport, |
| @@ -281,21 +286,17 @@ int snd_cs4236_create(struct snd_card *card, | |||
| 281 | *rchip = NULL; | 286 | *rchip = NULL; |
| 282 | if (hardware == WSS_HW_DETECT) | 287 | if (hardware == WSS_HW_DETECT) |
| 283 | hardware = WSS_HW_DETECT3; | 288 | hardware = WSS_HW_DETECT3; |
| 284 | if (cport < 0x100) { | 289 | |
| 285 | snd_printk(KERN_ERR "please, specify control port " | ||
| 286 | "for CS4236+ chips\n"); | ||
| 287 | return -ENODEV; | ||
| 288 | } | ||
| 289 | err = snd_wss_create(card, port, cport, | 290 | err = snd_wss_create(card, port, cport, |
| 290 | irq, dma1, dma2, hardware, hwshare, &chip); | 291 | irq, dma1, dma2, hardware, hwshare, &chip); |
| 291 | if (err < 0) | 292 | if (err < 0) |
| 292 | return err; | 293 | return err; |
| 293 | 294 | ||
| 294 | if (!(chip->hardware & WSS_HW_CS4236B_MASK)) { | 295 | if ((chip->hardware & WSS_HW_CS4236B_MASK) == 0) { |
| 295 | snd_printk(KERN_ERR "CS4236+: MODE3 and extended registers " | 296 | snd_printd("chip is not CS4236+, hardware=0x%x\n", |
| 296 | "not available, hardware=0x%x\n", chip->hardware); | 297 | chip->hardware); |
| 297 | snd_device_free(card, chip); | 298 | *rchip = chip; |
| 298 | return -ENODEV; | 299 | return 0; |
| 299 | } | 300 | } |
| 300 | #if 0 | 301 | #if 0 |
| 301 | { | 302 | { |
| @@ -308,9 +309,16 @@ int snd_cs4236_create(struct snd_card *card, | |||
| 308 | idx, snd_cs4236_ctrl_in(chip, idx)); | 309 | idx, snd_cs4236_ctrl_in(chip, idx)); |
| 309 | } | 310 | } |
| 310 | #endif | 311 | #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 | } | ||
| 311 | ver1 = snd_cs4236_ctrl_in(chip, 1); | 318 | ver1 = snd_cs4236_ctrl_in(chip, 1); |
| 312 | ver2 = snd_cs4236_ext_in(chip, CS4236_VERSION); | 319 | 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); | ||
| 314 | if (ver1 != ver2) { | 322 | if (ver1 != ver2) { |
| 315 | snd_printk(KERN_ERR "CS4236+ chip detected, but " | 323 | snd_printk(KERN_ERR "CS4236+ chip detected, but " |
| 316 | "control port 0x%lx is not valid\n", cport); | 324 | "control port 0x%lx is not valid\n", cport); |
| @@ -321,13 +329,17 @@ int snd_cs4236_create(struct snd_card *card, | |||
| 321 | snd_cs4236_ctrl_out(chip, 2, 0xff); | 329 | snd_cs4236_ctrl_out(chip, 2, 0xff); |
| 322 | snd_cs4236_ctrl_out(chip, 3, 0x00); | 330 | snd_cs4236_ctrl_out(chip, 3, 0x00); |
| 323 | snd_cs4236_ctrl_out(chip, 4, 0x80); | 331 | 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); | ||
| 325 | snd_cs4236_ctrl_out(chip, 6, IEC958_AES1_CON_PCM_CODER >> 2); | 335 | snd_cs4236_ctrl_out(chip, 6, IEC958_AES1_CON_PCM_CODER >> 2); |
| 326 | snd_cs4236_ctrl_out(chip, 7, 0x00); | 336 | snd_cs4236_ctrl_out(chip, 7, 0x00); |
| 327 | /* 0x8c for C8 is valid for Turtle Beach Malibu - the IEC-958 output */ | 337 | /* |
| 328 | /* is working with this setup, other hardware should have */ | 338 | * 0x8c for C8 is valid for Turtle Beach Malibu - the IEC-958 |
| 329 | /* different signal paths and this value should be selectable */ | 339 | * output is working with this setup, other hardware should |
| 330 | /* in the future */ | 340 | * have different signal paths and this value should be |
| 341 | * selectable in the future | ||
| 342 | */ | ||
| 331 | snd_cs4236_ctrl_out(chip, 8, 0x8c); | 343 | snd_cs4236_ctrl_out(chip, 8, 0x8c); |
| 332 | chip->rate_constraint = snd_cs4236_xrate; | 344 | chip->rate_constraint = snd_cs4236_xrate; |
| 333 | chip->set_playback_format = snd_cs4236_playback_format; | 345 | chip->set_playback_format = snd_cs4236_playback_format; |
| @@ -339,9 +351,10 @@ int snd_cs4236_create(struct snd_card *card, | |||
| 339 | 351 | ||
| 340 | /* initialize extended registers */ | 352 | /* initialize extended registers */ |
| 341 | for (reg = 0; reg < sizeof(snd_cs4236_ext_map); reg++) | 353 | for (reg = 0; reg < sizeof(snd_cs4236_ext_map); reg++) |
| 342 | snd_cs4236_ext_out(chip, CS4236_I23VAL(reg), snd_cs4236_ext_map[reg]); | 354 | snd_cs4236_ext_out(chip, CS4236_I23VAL(reg), |
| 355 | snd_cs4236_ext_map[reg]); | ||
| 343 | 356 | ||
| 344 | /* initialize compatible but more featured registers */ | 357 | /* initialize compatible but more featured registers */ |
| 345 | snd_wss_out(chip, CS4231_LEFT_INPUT, 0x40); | 358 | snd_wss_out(chip, CS4231_LEFT_INPUT, 0x40); |
| 346 | snd_wss_out(chip, CS4231_RIGHT_INPUT, 0x40); | 359 | snd_wss_out(chip, CS4231_RIGHT_INPUT, 0x40); |
| 347 | snd_wss_out(chip, CS4231_AUX1_LEFT_INPUT, 0xff); | 360 | snd_wss_out(chip, CS4231_AUX1_LEFT_INPUT, 0xff); |
| @@ -387,6 +400,14 @@ int snd_cs4236_pcm(struct snd_wss *chip, int device, struct snd_pcm **rpcm) | |||
| 387 | .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ | 400 | .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ |
| 388 | .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } | 401 | .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } |
| 389 | 402 | ||
| 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 | |||
| 390 | static int snd_cs4236_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 411 | static int snd_cs4236_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
| 391 | { | 412 | { |
| 392 | int mask = (kcontrol->private_value >> 16) & 0xff; | 413 | int mask = (kcontrol->private_value >> 16) & 0xff; |
| @@ -490,6 +511,16 @@ static int snd_cs4236_put_singlec(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
| 490 | .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ | 511 | .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ |
| 491 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } | 512 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } |
| 492 | 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) } } | ||
| 523 | |||
| 493 | static int snd_cs4236_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 524 | static int snd_cs4236_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
| 494 | { | 525 | { |
| 495 | int mask = (kcontrol->private_value >> 24) & 0xff; | 526 | int mask = (kcontrol->private_value >> 24) & 0xff; |
| @@ -560,12 +591,23 @@ static int snd_cs4236_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_e | |||
| 560 | return change; | 591 | return change; |
| 561 | } | 592 | } |
| 562 | 593 | ||
| 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) \ | ||
| 564 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 596 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
| 565 | .info = snd_cs4236_info_double, \ | 597 | .info = snd_cs4236_info_double, \ |
| 566 | .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ | 598 | .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ |
| 567 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } | 599 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } |
| 568 | 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) } } | ||
| 610 | |||
| 569 | static int snd_cs4236_get_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 611 | static int snd_cs4236_get_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 570 | { | 612 | { |
| 571 | struct snd_wss *chip = snd_kcontrol_chip(kcontrol); | 613 | struct snd_wss *chip = snd_kcontrol_chip(kcontrol); |
| @@ -619,16 +661,18 @@ static int snd_cs4236_put_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
| 619 | return change; | 661 | return change; |
| 620 | } | 662 | } |
| 621 | 663 | ||
| 622 | #define CS4236_MASTER_DIGITAL(xname, xindex) \ | 664 | #define CS4236_MASTER_DIGITAL(xname, xindex, xtlv) \ |
| 623 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 665 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
| 666 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
| 624 | .info = snd_cs4236_info_double, \ | 667 | .info = snd_cs4236_info_double, \ |
| 625 | .get = snd_cs4236_get_master_digital, .put = snd_cs4236_put_master_digital, \ | 668 | .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) } } | ||
| 627 | 671 | ||
| 628 | static inline int snd_cs4236_mixer_master_digital_invert_volume(int vol) | 672 | static inline int snd_cs4236_mixer_master_digital_invert_volume(int vol) |
| 629 | { | 673 | { |
| 630 | return (vol < 64) ? 63 - vol : 64 + (71 - vol); | 674 | return (vol < 64) ? 63 - vol : 64 + (71 - vol); |
| 631 | } | 675 | } |
| 632 | 676 | ||
| 633 | static int snd_cs4236_get_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 677 | static int snd_cs4236_get_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 634 | { | 678 | { |
| @@ -661,11 +705,13 @@ static int snd_cs4236_put_master_digital(struct snd_kcontrol *kcontrol, struct s | |||
| 661 | return change; | 705 | return change; |
| 662 | } | 706 | } |
| 663 | 707 | ||
| 664 | #define CS4235_OUTPUT_ACCU(xname, xindex) \ | 708 | #define CS4235_OUTPUT_ACCU(xname, xindex, xtlv) \ |
| 665 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 709 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
| 710 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
| 666 | .info = snd_cs4236_info_double, \ | 711 | .info = snd_cs4236_info_double, \ |
| 667 | .get = snd_cs4235_get_output_accu, .put = snd_cs4235_put_output_accu, \ | 712 | .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) } } | ||
| 669 | 715 | ||
| 670 | static inline int snd_cs4235_mixer_output_accu_get_volume(int vol) | 716 | static inline int snd_cs4235_mixer_output_accu_get_volume(int vol) |
| 671 | { | 717 | { |
| @@ -720,41 +766,56 @@ static int snd_cs4235_put_output_accu(struct snd_kcontrol *kcontrol, struct snd_ | |||
| 720 | return change; | 766 | return change; |
| 721 | } | 767 | } |
| 722 | 768 | ||
| 769 | static const DECLARE_TLV_DB_SCALE(db_scale_7bit, -9450, 150, 0); | ||
| 770 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); | ||
| 771 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit_12db_max, -8250, 150, 0); | ||
| 772 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); | ||
| 773 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_22db_max, -2400, 150, 0); | ||
| 774 | static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0); | ||
| 775 | static const DECLARE_TLV_DB_SCALE(db_scale_2bit, -1800, 600, 0); | ||
| 776 | static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); | ||
| 777 | |||
| 723 | static struct snd_kcontrol_new snd_cs4236_controls[] = { | 778 | static struct snd_kcontrol_new snd_cs4236_controls[] = { |
| 724 | 779 | ||
| 725 | CS4236_DOUBLE("Master Digital Playback Switch", 0, | 780 | CS4236_DOUBLE("Master Digital Playback Switch", 0, |
| 726 | CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), | 781 | CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), |
| 727 | CS4236_DOUBLE("Master Digital Capture Switch", 0, | 782 | CS4236_DOUBLE("Master Digital Capture Switch", 0, |
| 728 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), | 783 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), |
| 729 | CS4236_MASTER_DIGITAL("Master Digital Volume", 0), | 784 | CS4236_MASTER_DIGITAL("Master Digital Volume", 0, db_scale_7bit), |
| 730 | 785 | ||
| 731 | CS4236_DOUBLE("Capture Boost Volume", 0, | 786 | CS4236_DOUBLE_TLV("Capture Boost Volume", 0, |
| 732 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1), | 787 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1, |
| 788 | db_scale_2bit), | ||
| 733 | 789 | ||
| 734 | WSS_DOUBLE("PCM Playback Switch", 0, | 790 | WSS_DOUBLE("PCM Playback Switch", 0, |
| 735 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | 791 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
| 736 | WSS_DOUBLE("PCM Playback Volume", 0, | 792 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, |
| 737 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), | 793 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, |
| 794 | db_scale_6bit), | ||
| 738 | 795 | ||
| 739 | CS4236_DOUBLE("DSP Playback Switch", 0, | 796 | CS4236_DOUBLE("DSP Playback Switch", 0, |
| 740 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), | 797 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), |
| 741 | CS4236_DOUBLE("DSP Playback Volume", 0, | 798 | CS4236_DOUBLE_TLV("DSP Playback Volume", 0, |
| 742 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 0, 0, 63, 1), | 799 | CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 0, 0, 63, 1, |
| 800 | db_scale_6bit), | ||
| 743 | 801 | ||
| 744 | CS4236_DOUBLE("FM Playback Switch", 0, | 802 | CS4236_DOUBLE("FM Playback Switch", 0, |
| 745 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 7, 7, 1, 1), | 803 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 7, 7, 1, 1), |
| 746 | CS4236_DOUBLE("FM Playback Volume", 0, | 804 | CS4236_DOUBLE_TLV("FM Playback Volume", 0, |
| 747 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 0, 0, 63, 1), | 805 | CS4236_LEFT_FM, CS4236_RIGHT_FM, 0, 0, 63, 1, |
| 806 | db_scale_6bit), | ||
| 748 | 807 | ||
| 749 | CS4236_DOUBLE("Wavetable Playback Switch", 0, | 808 | CS4236_DOUBLE("Wavetable Playback Switch", 0, |
| 750 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 7, 7, 1, 1), | 809 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 7, 7, 1, 1), |
| 751 | CS4236_DOUBLE("Wavetable Playback Volume", 0, | 810 | CS4236_DOUBLE_TLV("Wavetable Playback Volume", 0, |
| 752 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 0, 0, 63, 1), | 811 | CS4236_LEFT_WAVE, CS4236_RIGHT_WAVE, 0, 0, 63, 1, |
| 812 | db_scale_6bit_12db_max), | ||
| 753 | 813 | ||
| 754 | WSS_DOUBLE("Synth Playback Switch", 0, | 814 | WSS_DOUBLE("Synth Playback Switch", 0, |
| 755 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | 815 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), |
| 756 | WSS_DOUBLE("Synth Volume", 0, | 816 | WSS_DOUBLE_TLV("Synth Volume", 0, |
| 757 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), | 817 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1, |
| 818 | db_scale_5bit_12db_max), | ||
| 758 | WSS_DOUBLE("Synth Capture Switch", 0, | 819 | WSS_DOUBLE("Synth Capture Switch", 0, |
| 759 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), | 820 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), |
| 760 | WSS_DOUBLE("Synth Capture Bypass", 0, | 821 | WSS_DOUBLE("Synth Capture Bypass", 0, |
| @@ -764,14 +825,16 @@ CS4236_DOUBLE("Mic Playback Switch", 0, | |||
| 764 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), | 825 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), |
| 765 | CS4236_DOUBLE("Mic Capture Switch", 0, | 826 | CS4236_DOUBLE("Mic Capture Switch", 0, |
| 766 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), | 827 | 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), | 828 | CS4236_DOUBLE_TLV("Mic Volume", 0, CS4236_LEFT_MIC, CS4236_RIGHT_MIC, |
| 768 | CS4236_DOUBLE("Mic Playback Boost", 0, | 829 | 0, 0, 31, 1, db_scale_5bit_22db_max), |
| 830 | CS4236_DOUBLE("Mic Playback Boost (+20dB)", 0, | ||
| 769 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 5, 5, 1, 0), | 831 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 5, 5, 1, 0), |
| 770 | 832 | ||
| 771 | WSS_DOUBLE("Line Playback Switch", 0, | 833 | WSS_DOUBLE("Line Playback Switch", 0, |
| 772 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 834 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), |
| 773 | WSS_DOUBLE("Line Volume", 0, | 835 | WSS_DOUBLE_TLV("Line Volume", 0, |
| 774 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), | 836 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, |
| 837 | db_scale_5bit_12db_max), | ||
| 775 | WSS_DOUBLE("Line Capture Switch", 0, | 838 | WSS_DOUBLE("Line Capture Switch", 0, |
| 776 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), | 839 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), |
| 777 | WSS_DOUBLE("Line Capture Bypass", 0, | 840 | WSS_DOUBLE("Line Capture Bypass", 0, |
| @@ -779,57 +842,63 @@ WSS_DOUBLE("Line Capture Bypass", 0, | |||
| 779 | 842 | ||
| 780 | WSS_DOUBLE("CD Playback Switch", 0, | 843 | WSS_DOUBLE("CD Playback Switch", 0, |
| 781 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 844 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
| 782 | WSS_DOUBLE("CD Volume", 0, | 845 | WSS_DOUBLE_TLV("CD Volume", 0, |
| 783 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), | 846 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, |
| 847 | db_scale_5bit_12db_max), | ||
| 784 | WSS_DOUBLE("CD Capture Switch", 0, | 848 | WSS_DOUBLE("CD Capture Switch", 0, |
| 785 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), | 849 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), |
| 786 | 850 | ||
| 787 | CS4236_DOUBLE1("Mono Output Playback Switch", 0, | 851 | CS4236_DOUBLE1("Mono Output Playback Switch", 0, |
| 788 | CS4231_MONO_CTRL, CS4236_RIGHT_MIX_CTRL, 6, 7, 1, 1), | 852 | CS4231_MONO_CTRL, CS4236_RIGHT_MIX_CTRL, 6, 7, 1, 1), |
| 789 | CS4236_DOUBLE1("Mono Playback Switch", 0, | 853 | CS4236_DOUBLE1("Beep Playback Switch", 0, |
| 790 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), | 854 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), |
| 791 | WSS_SINGLE("Mono Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1), | 855 | WSS_SINGLE_TLV("Beep Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1, |
| 792 | WSS_SINGLE("Mono Playback Bypass", 0, CS4231_MONO_CTRL, 5, 1, 0), | 856 | db_scale_4bit), |
| 857 | WSS_SINGLE("Beep Bypass Playback Switch", 0, CS4231_MONO_CTRL, 5, 1, 0), | ||
| 793 | 858 | ||
| 794 | WSS_DOUBLE("Capture Volume", 0, | 859 | WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, |
| 795 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), | 860 | 0, 0, 15, 0, db_scale_rec_gain), |
| 796 | WSS_DOUBLE("Analog Loopback Capture Switch", 0, | 861 | WSS_DOUBLE("Analog Loopback Capture Switch", 0, |
| 797 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0), | 862 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0), |
| 798 | 863 | ||
| 799 | WSS_SINGLE("Digital Loopback Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0), | 864 | WSS_SINGLE("Loopback Digital Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0), |
| 800 | CS4236_DOUBLE1("Digital Loopback Playback Volume", 0, | 865 | CS4236_DOUBLE1_TLV("Loopback Digital Playback Volume", 0, |
| 801 | CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1) | 866 | CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1, |
| 867 | db_scale_6bit), | ||
| 802 | }; | 868 | }; |
| 803 | 869 | ||
| 870 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_6db_max, -5600, 200, 0); | ||
| 871 | static const DECLARE_TLV_DB_SCALE(db_scale_2bit_16db_max, -2400, 800, 0); | ||
| 872 | |||
| 804 | static struct snd_kcontrol_new snd_cs4235_controls[] = { | 873 | static struct snd_kcontrol_new snd_cs4235_controls[] = { |
| 805 | 874 | ||
| 806 | WSS_DOUBLE("Master Switch", 0, | 875 | WSS_DOUBLE("Master Playback Switch", 0, |
| 807 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1), | 876 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1), |
| 808 | WSS_DOUBLE("Master Volume", 0, | 877 | WSS_DOUBLE_TLV("Master Playback Volume", 0, |
| 809 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1), | 878 | CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1, |
| 810 | 879 | db_scale_5bit_6db_max), | |
| 811 | CS4235_OUTPUT_ACCU("Playback Volume", 0), | ||
| 812 | 880 | ||
| 813 | CS4236_DOUBLE("Master Digital Playback Switch", 0, | 881 | CS4235_OUTPUT_ACCU("Playback Volume", 0, db_scale_2bit_16db_max), |
| 814 | CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), | ||
| 815 | CS4236_DOUBLE("Master Digital Capture Switch", 0, | ||
| 816 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), | ||
| 817 | CS4236_MASTER_DIGITAL("Master Digital Volume", 0), | ||
| 818 | 882 | ||
| 819 | WSS_DOUBLE("Master Digital Playback Switch", 1, | 883 | WSS_DOUBLE("Synth Playback Switch", 1, |
| 820 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | 884 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), |
| 821 | WSS_DOUBLE("Master Digital Capture Switch", 1, | 885 | WSS_DOUBLE("Synth Capture Switch", 1, |
| 822 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), | 886 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 6, 6, 1, 1), |
| 823 | WSS_DOUBLE("Master Digital Volume", 1, | 887 | WSS_DOUBLE_TLV("Synth Volume", 1, |
| 824 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), | 888 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1, |
| 889 | db_scale_5bit_12db_max), | ||
| 825 | 890 | ||
| 826 | CS4236_DOUBLE("Capture Volume", 0, | 891 | CS4236_DOUBLE_TLV("Capture Volume", 0, |
| 827 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1), | 892 | CS4236_LEFT_MIX_CTRL, CS4236_RIGHT_MIX_CTRL, 5, 5, 3, 1, |
| 893 | db_scale_2bit), | ||
| 828 | 894 | ||
| 829 | WSS_DOUBLE("PCM Switch", 0, | 895 | WSS_DOUBLE("PCM Playback Switch", 0, |
| 830 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | 896 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
| 831 | WSS_DOUBLE("PCM Volume", 0, | 897 | WSS_DOUBLE("PCM Capture Switch", 0, |
| 832 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), | 898 | CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), |
| 899 | WSS_DOUBLE_TLV("PCM Volume", 0, | ||
| 900 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, | ||
| 901 | db_scale_6bit), | ||
| 833 | 902 | ||
| 834 | CS4236_DOUBLE("DSP Switch", 0, CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), | 903 | CS4236_DOUBLE("DSP Switch", 0, CS4236_LEFT_DSP, CS4236_RIGHT_DSP, 7, 7, 1, 1), |
| 835 | 904 | ||
| @@ -842,29 +911,29 @@ CS4236_DOUBLE("Mic Capture Switch", 0, | |||
| 842 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), | 911 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 7, 7, 1, 1), |
| 843 | CS4236_DOUBLE("Mic Playback Switch", 0, | 912 | CS4236_DOUBLE("Mic Playback Switch", 0, |
| 844 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), | 913 | CS4236_LEFT_MIC, CS4236_RIGHT_MIC, 6, 6, 1, 1), |
| 845 | CS4236_SINGLE("Mic Volume", 0, CS4236_LEFT_MIC, 0, 31, 1), | 914 | CS4236_SINGLE_TLV("Mic Volume", 0, CS4236_LEFT_MIC, 0, 31, 1, |
| 846 | CS4236_SINGLE("Mic Playback Boost", 0, CS4236_LEFT_MIC, 5, 1, 0), | 915 | db_scale_5bit_22db_max), |
| 916 | CS4236_SINGLE("Mic Boost (+20dB)", 0, CS4236_LEFT_MIC, 5, 1, 0), | ||
| 847 | 917 | ||
| 848 | WSS_DOUBLE("Aux Playback Switch", 0, | 918 | WSS_DOUBLE("Line Playback Switch", 0, |
| 849 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 919 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), |
| 850 | WSS_DOUBLE("Aux Capture Switch", 0, | 920 | WSS_DOUBLE("Line Capture Switch", 0, |
| 851 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), | 921 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 6, 6, 1, 1), |
| 852 | WSS_DOUBLE("Aux Volume", 0, | 922 | WSS_DOUBLE_TLV("Line Volume", 0, |
| 853 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), | 923 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, |
| 924 | db_scale_5bit_12db_max), | ||
| 854 | 925 | ||
| 855 | WSS_DOUBLE("Aux Playback Switch", 1, | 926 | WSS_DOUBLE("CD Playback Switch", 1, |
| 856 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 927 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
| 857 | WSS_DOUBLE("Aux Capture Switch", 1, | 928 | WSS_DOUBLE("CD Capture Switch", 1, |
| 858 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), | 929 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 6, 6, 1, 1), |
| 859 | WSS_DOUBLE("Aux Volume", 1, | 930 | WSS_DOUBLE_TLV("CD Volume", 1, |
| 860 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), | 931 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, |
| 861 | 932 | db_scale_5bit_12db_max), | |
| 862 | CS4236_DOUBLE1("Master Mono Switch", 0, | ||
| 863 | CS4231_MONO_CTRL, CS4236_RIGHT_MIX_CTRL, 6, 7, 1, 1), | ||
| 864 | 933 | ||
| 865 | CS4236_DOUBLE1("Mono Switch", 0, | 934 | CS4236_DOUBLE1("Beep Playback Switch", 0, |
| 866 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), | 935 | CS4231_MONO_CTRL, CS4236_LEFT_MIX_CTRL, 7, 7, 1, 1), |
| 867 | WSS_SINGLE("Mono Volume", 0, CS4231_MONO_CTRL, 0, 15, 1), | 936 | WSS_SINGLE("Beep Playback Volume", 0, CS4231_MONO_CTRL, 0, 15, 1), |
| 868 | 937 | ||
| 869 | WSS_DOUBLE("Analog Loopback Switch", 0, | 938 | WSS_DOUBLE("Analog Loopback Switch", 0, |
| 870 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0), | 939 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 7, 7, 1, 0), |
diff --git a/sound/isa/dt019x.c b/sound/isa/dt019x.c deleted file mode 100644 index 80f5b1af9be8..000000000000 --- a/sound/isa/dt019x.c +++ /dev/null | |||
| @@ -1,321 +0,0 @@ | |||
| 1 | |||
| 2 | /* | ||
| 3 | dt019x.c - driver for Diamond Technologies DT-0197H based soundcards. | ||
| 4 | Copyright (C) 1999, 2002 by Massimo Piccioni <dafastidio@libero.it> | ||
| 5 | |||
| 6 | Generalised for soundcards based on DT-0196 and ALS-007 chips | ||
| 7 | by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>: June 2002. | ||
| 8 | |||
| 9 | This program is free software; you can redistribute it and/or modify | ||
| 10 | it under the terms of the GNU General Public License as published by | ||
| 11 | the Free Software Foundation; either version 2 of the License, or | ||
| 12 | (at your option) any later version. | ||
| 13 | |||
| 14 | This program is distributed in the hope that it will be useful, | ||
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | GNU General Public License for more details. | ||
| 18 | |||
| 19 | You should have received a copy of the GNU General Public License | ||
| 20 | along with this program; if not, write to the Free Software | ||
| 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 22 | */ | ||
| 23 | |||
| 24 | #include <linux/init.h> | ||
| 25 | #include <linux/wait.h> | ||
| 26 | #include <linux/pnp.h> | ||
| 27 | #include <linux/moduleparam.h> | ||
| 28 | #include <sound/core.h> | ||
| 29 | #include <sound/initval.h> | ||
| 30 | #include <sound/mpu401.h> | ||
| 31 | #include <sound/opl3.h> | ||
| 32 | #include <sound/sb.h> | ||
| 33 | |||
| 34 | #define PFX "dt019x: " | ||
| 35 | |||
| 36 | MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); | ||
| 37 | MODULE_DESCRIPTION("Diamond Technologies DT-019X / Avance Logic ALS-007"); | ||
| 38 | MODULE_LICENSE("GPL"); | ||
| 39 | MODULE_SUPPORTED_DEVICE("{{Diamond Technologies DT-019X}," | ||
| 40 | "{Avance Logic ALS-007}}"); | ||
| 41 | |||
| 42 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | ||
| 43 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | ||
| 44 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ | ||
| 45 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | ||
| 46 | static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | ||
| 47 | static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ | ||
| 48 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* PnP setup */ | ||
| 49 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* PnP setup */ | ||
| 50 | static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* PnP setup */ | ||
| 51 | |||
| 52 | module_param_array(index, int, NULL, 0444); | ||
| 53 | MODULE_PARM_DESC(index, "Index value for DT-019X based soundcard."); | ||
| 54 | module_param_array(id, charp, NULL, 0444); | ||
| 55 | MODULE_PARM_DESC(id, "ID string for DT-019X based soundcard."); | ||
| 56 | module_param_array(enable, bool, NULL, 0444); | ||
| 57 | MODULE_PARM_DESC(enable, "Enable DT-019X based soundcard."); | ||
| 58 | |||
| 59 | struct snd_card_dt019x { | ||
| 60 | struct pnp_dev *dev; | ||
| 61 | struct pnp_dev *devmpu; | ||
| 62 | struct pnp_dev *devopl; | ||
| 63 | struct snd_sb *chip; | ||
| 64 | }; | ||
| 65 | |||
| 66 | static struct pnp_card_device_id snd_dt019x_pnpids[] = { | ||
| 67 | /* DT197A30 */ | ||
| 68 | { .id = "RWB1688", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, | ||
| 69 | /* DT0196 / ALS-007 */ | ||
| 70 | { .id = "ALS0007", .devs = { { "@@@0001" }, { "@X@0001" }, { "@H@0001" }, } }, | ||
| 71 | { .id = "", } | ||
| 72 | }; | ||
| 73 | |||
| 74 | MODULE_DEVICE_TABLE(pnp_card, snd_dt019x_pnpids); | ||
| 75 | |||
| 76 | |||
| 77 | #define DRIVER_NAME "snd-card-dt019x" | ||
| 78 | |||
| 79 | |||
| 80 | static int __devinit snd_card_dt019x_pnp(int dev, struct snd_card_dt019x *acard, | ||
| 81 | struct pnp_card_link *card, | ||
| 82 | const struct pnp_card_device_id *pid) | ||
| 83 | { | ||
| 84 | struct pnp_dev *pdev; | ||
| 85 | int err; | ||
| 86 | |||
| 87 | acard->dev = pnp_request_card_device(card, pid->devs[0].id, NULL); | ||
| 88 | if (acard->dev == NULL) | ||
| 89 | return -ENODEV; | ||
| 90 | |||
| 91 | acard->devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); | ||
| 92 | acard->devopl = pnp_request_card_device(card, pid->devs[2].id, NULL); | ||
| 93 | |||
| 94 | pdev = acard->dev; | ||
| 95 | |||
| 96 | err = pnp_activate_dev(pdev); | ||
| 97 | if (err < 0) { | ||
| 98 | snd_printk(KERN_ERR PFX "DT-019X AUDIO pnp configure failure\n"); | ||
| 99 | return err; | ||
| 100 | } | ||
| 101 | |||
| 102 | port[dev] = pnp_port_start(pdev, 0); | ||
| 103 | dma8[dev] = pnp_dma(pdev, 0); | ||
| 104 | irq[dev] = pnp_irq(pdev, 0); | ||
| 105 | snd_printdd("dt019x: found audio interface: port=0x%lx, irq=0x%x, dma=0x%x\n", | ||
| 106 | port[dev],irq[dev],dma8[dev]); | ||
| 107 | |||
| 108 | pdev = acard->devmpu; | ||
| 109 | if (pdev != NULL) { | ||
| 110 | err = pnp_activate_dev(pdev); | ||
| 111 | if (err < 0) { | ||
| 112 | pnp_release_card_device(pdev); | ||
| 113 | snd_printk(KERN_ERR PFX "DT-019X MPU401 pnp configure failure, skipping\n"); | ||
| 114 | goto __mpu_error; | ||
| 115 | } | ||
| 116 | mpu_port[dev] = pnp_port_start(pdev, 0); | ||
| 117 | mpu_irq[dev] = pnp_irq(pdev, 0); | ||
| 118 | snd_printdd("dt019x: found MPU-401: port=0x%lx, irq=0x%x\n", | ||
| 119 | mpu_port[dev],mpu_irq[dev]); | ||
| 120 | } else { | ||
| 121 | __mpu_error: | ||
| 122 | acard->devmpu = NULL; | ||
| 123 | mpu_port[dev] = -1; | ||
| 124 | } | ||
| 125 | |||
| 126 | pdev = acard->devopl; | ||
| 127 | if (pdev != NULL) { | ||
| 128 | err = pnp_activate_dev(pdev); | ||
| 129 | if (err < 0) { | ||
| 130 | pnp_release_card_device(pdev); | ||
| 131 | snd_printk(KERN_ERR PFX "DT-019X OPL3 pnp configure failure, skipping\n"); | ||
| 132 | goto __fm_error; | ||
| 133 | } | ||
| 134 | fm_port[dev] = pnp_port_start(pdev, 0); | ||
| 135 | snd_printdd("dt019x: found OPL3 synth: port=0x%lx\n",fm_port[dev]); | ||
| 136 | } else { | ||
| 137 | __fm_error: | ||
| 138 | acard->devopl = NULL; | ||
| 139 | fm_port[dev] = -1; | ||
| 140 | } | ||
| 141 | |||
| 142 | return 0; | ||
| 143 | } | ||
| 144 | |||
| 145 | static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) | ||
| 146 | { | ||
| 147 | int error; | ||
| 148 | struct snd_sb *chip; | ||
| 149 | struct snd_card *card; | ||
| 150 | struct snd_card_dt019x *acard; | ||
| 151 | struct snd_opl3 *opl3; | ||
| 152 | |||
| 153 | error = snd_card_create(index[dev], id[dev], THIS_MODULE, | ||
| 154 | sizeof(struct snd_card_dt019x), &card); | ||
| 155 | if (error < 0) | ||
| 156 | return error; | ||
| 157 | acard = card->private_data; | ||
| 158 | |||
| 159 | snd_card_set_dev(card, &pcard->card->dev); | ||
| 160 | if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) { | ||
| 161 | snd_card_free(card); | ||
| 162 | return error; | ||
| 163 | } | ||
| 164 | |||
| 165 | if ((error = snd_sbdsp_create(card, port[dev], | ||
| 166 | irq[dev], | ||
| 167 | snd_sb16dsp_interrupt, | ||
| 168 | dma8[dev], | ||
| 169 | -1, | ||
| 170 | SB_HW_DT019X, | ||
| 171 | &chip)) < 0) { | ||
| 172 | snd_card_free(card); | ||
| 173 | return error; | ||
| 174 | } | ||
| 175 | acard->chip = chip; | ||
| 176 | |||
| 177 | strcpy(card->driver, "DT-019X"); | ||
| 178 | strcpy(card->shortname, "Diamond Tech. DT-019X"); | ||
| 179 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", | ||
| 180 | card->shortname, chip->name, chip->port, | ||
| 181 | irq[dev], dma8[dev]); | ||
| 182 | |||
| 183 | if ((error = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) { | ||
| 184 | snd_card_free(card); | ||
| 185 | return error; | ||
| 186 | } | ||
| 187 | if ((error = snd_sbmixer_new(chip)) < 0) { | ||
| 188 | snd_card_free(card); | ||
| 189 | return error; | ||
| 190 | } | ||
| 191 | |||
| 192 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | ||
| 193 | if (mpu_irq[dev] == SNDRV_AUTO_IRQ) | ||
| 194 | mpu_irq[dev] = -1; | ||
| 195 | if (snd_mpu401_uart_new(card, 0, | ||
| 196 | /* MPU401_HW_SB,*/ | ||
| 197 | MPU401_HW_MPU401, | ||
| 198 | mpu_port[dev], 0, | ||
| 199 | mpu_irq[dev], | ||
| 200 | mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, | ||
| 201 | NULL) < 0) | ||
| 202 | snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx ?\n", mpu_port[dev]); | ||
| 203 | } | ||
| 204 | |||
| 205 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { | ||
| 206 | if (snd_opl3_create(card, | ||
| 207 | fm_port[dev], | ||
| 208 | fm_port[dev] + 2, | ||
| 209 | OPL3_HW_AUTO, 0, &opl3) < 0) { | ||
| 210 | snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx ?\n", | ||
| 211 | fm_port[dev], fm_port[dev] + 2); | ||
| 212 | } else { | ||
| 213 | if ((error = snd_opl3_timer_new(opl3, 0, 1)) < 0) { | ||
| 214 | snd_card_free(card); | ||
| 215 | return error; | ||
| 216 | } | ||
| 217 | if ((error = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { | ||
| 218 | snd_card_free(card); | ||
| 219 | return error; | ||
| 220 | } | ||
| 221 | } | ||
| 222 | } | ||
| 223 | |||
| 224 | if ((error = snd_card_register(card)) < 0) { | ||
| 225 | snd_card_free(card); | ||
| 226 | return error; | ||
| 227 | } | ||
| 228 | pnp_set_card_drvdata(pcard, card); | ||
| 229 | return 0; | ||
| 230 | } | ||
| 231 | |||
| 232 | static unsigned int __devinitdata dt019x_devices; | ||
| 233 | |||
| 234 | static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card, | ||
| 235 | const struct pnp_card_device_id *pid) | ||
| 236 | { | ||
| 237 | static int dev; | ||
| 238 | int res; | ||
| 239 | |||
| 240 | for ( ; dev < SNDRV_CARDS; dev++) { | ||
| 241 | if (!enable[dev]) | ||
| 242 | continue; | ||
| 243 | res = snd_card_dt019x_probe(dev, card, pid); | ||
| 244 | if (res < 0) | ||
| 245 | return res; | ||
| 246 | dev++; | ||
| 247 | dt019x_devices++; | ||
| 248 | return 0; | ||
| 249 | } | ||
| 250 | return -ENODEV; | ||
| 251 | } | ||
| 252 | |||
| 253 | static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard) | ||
| 254 | { | ||
| 255 | snd_card_free(pnp_get_card_drvdata(pcard)); | ||
| 256 | pnp_set_card_drvdata(pcard, NULL); | ||
| 257 | } | ||
| 258 | |||
| 259 | #ifdef CONFIG_PM | ||
| 260 | static int snd_dt019x_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) | ||
| 261 | { | ||
| 262 | struct snd_card *card = pnp_get_card_drvdata(pcard); | ||
| 263 | struct snd_card_dt019x *acard = card->private_data; | ||
| 264 | struct snd_sb *chip = acard->chip; | ||
| 265 | |||
| 266 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
| 267 | snd_pcm_suspend_all(chip->pcm); | ||
| 268 | snd_sbmixer_suspend(chip); | ||
| 269 | return 0; | ||
| 270 | } | ||
| 271 | |||
| 272 | static int snd_dt019x_pnp_resume(struct pnp_card_link *pcard) | ||
| 273 | { | ||
| 274 | struct snd_card *card = pnp_get_card_drvdata(pcard); | ||
| 275 | struct snd_card_dt019x *acard = card->private_data; | ||
| 276 | struct snd_sb *chip = acard->chip; | ||
| 277 | |||
| 278 | snd_sbdsp_reset(chip); | ||
| 279 | snd_sbmixer_resume(chip); | ||
| 280 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
| 281 | return 0; | ||
| 282 | } | ||
| 283 | #endif | ||
| 284 | |||
| 285 | static struct pnp_card_driver dt019x_pnpc_driver = { | ||
| 286 | .flags = PNP_DRIVER_RES_DISABLE, | ||
| 287 | .name = "dt019x", | ||
| 288 | .id_table = snd_dt019x_pnpids, | ||
| 289 | .probe = snd_dt019x_pnp_probe, | ||
| 290 | .remove = __devexit_p(snd_dt019x_pnp_remove), | ||
| 291 | #ifdef CONFIG_PM | ||
| 292 | .suspend = snd_dt019x_pnp_suspend, | ||
| 293 | .resume = snd_dt019x_pnp_resume, | ||
| 294 | #endif | ||
| 295 | }; | ||
| 296 | |||
| 297 | static int __init alsa_card_dt019x_init(void) | ||
| 298 | { | ||
| 299 | int err; | ||
| 300 | |||
| 301 | err = pnp_register_card_driver(&dt019x_pnpc_driver); | ||
| 302 | if (err) | ||
| 303 | return err; | ||
| 304 | |||
| 305 | if (!dt019x_devices) { | ||
| 306 | pnp_unregister_card_driver(&dt019x_pnpc_driver); | ||
| 307 | #ifdef MODULE | ||
| 308 | snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n"); | ||
| 309 | #endif | ||
| 310 | return -ENODEV; | ||
| 311 | } | ||
| 312 | return 0; | ||
| 313 | } | ||
| 314 | |||
| 315 | static void __exit alsa_card_dt019x_exit(void) | ||
| 316 | { | ||
| 317 | pnp_unregister_card_driver(&dt019x_pnpc_driver); | ||
| 318 | } | ||
| 319 | |||
| 320 | module_init(alsa_card_dt019x_init) | ||
| 321 | module_exit(alsa_card_dt019x_exit) | ||
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 4c6e14f87f2d..c76bb00c9d15 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c | |||
| @@ -982,7 +982,7 @@ ES1688_DOUBLE("CD Playback Volume", 0, ES1688_CD_DEV, ES1688_CD_DEV, 4, 0, 15, 0 | |||
| 982 | ES1688_DOUBLE("FM Playback Volume", 0, ES1688_FM_DEV, ES1688_FM_DEV, 4, 0, 15, 0), | 982 | ES1688_DOUBLE("FM Playback Volume", 0, ES1688_FM_DEV, ES1688_FM_DEV, 4, 0, 15, 0), |
| 983 | ES1688_DOUBLE("Mic Playback Volume", 0, ES1688_MIC_DEV, ES1688_MIC_DEV, 4, 0, 15, 0), | 983 | ES1688_DOUBLE("Mic Playback Volume", 0, ES1688_MIC_DEV, ES1688_MIC_DEV, 4, 0, 15, 0), |
| 984 | ES1688_DOUBLE("Aux Playback Volume", 0, ES1688_AUX_DEV, ES1688_AUX_DEV, 4, 0, 15, 0), | 984 | ES1688_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), | 985 | ES1688_SINGLE("Beep Playback Volume", 0, ES1688_SPEAKER_DEV, 0, 7, 0), |
| 986 | ES1688_DOUBLE("Capture Volume", 0, ES1688_RECLEV_DEV, ES1688_RECLEV_DEV, 4, 0, 15, 0), | 986 | ES1688_DOUBLE("Capture Volume", 0, ES1688_RECLEV_DEV, ES1688_RECLEV_DEV, 4, 0, 15, 0), |
| 987 | ES1688_SINGLE("Capture Switch", 0, ES1688_REC_DEV, 4, 1, 1), | 987 | ES1688_SINGLE("Capture Switch", 0, ES1688_REC_DEV, 4, 1, 1), |
| 988 | { | 988 | { |
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 8cfbff73a835..fb4d6b34bbca 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c | |||
| @@ -80,7 +80,6 @@ | |||
| 80 | #include <linux/init.h> | 80 | #include <linux/init.h> |
| 81 | #include <linux/err.h> | 81 | #include <linux/err.h> |
| 82 | #include <linux/isa.h> | 82 | #include <linux/isa.h> |
| 83 | #include <linux/slab.h> | ||
| 84 | #include <linux/pnp.h> | 83 | #include <linux/pnp.h> |
| 85 | #include <linux/isapnp.h> | 84 | #include <linux/isapnp.h> |
| 86 | #include <linux/moduleparam.h> | 85 | #include <linux/moduleparam.h> |
| @@ -102,8 +101,6 @@ | |||
| 102 | 101 | ||
| 103 | struct snd_es18xx { | 102 | struct snd_es18xx { |
| 104 | unsigned long port; /* port of ESS chip */ | 103 | 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 */ | ||
| 107 | unsigned long ctrl_port; /* Control port of ESS chip */ | 104 | unsigned long ctrl_port; /* Control port of ESS chip */ |
| 108 | struct resource *res_port; | 105 | struct resource *res_port; |
| 109 | struct resource *res_mpu_port; | 106 | struct resource *res_mpu_port; |
| @@ -116,12 +113,9 @@ struct snd_es18xx { | |||
| 116 | unsigned short audio2_vol; /* volume level of audio2 */ | 113 | unsigned short audio2_vol; /* volume level of audio2 */ |
| 117 | 114 | ||
| 118 | unsigned short active; /* active channel mask */ | 115 | unsigned short active; /* active channel mask */ |
| 119 | unsigned int dma1_size; | ||
| 120 | unsigned int dma2_size; | ||
| 121 | unsigned int dma1_shift; | 116 | unsigned int dma1_shift; |
| 122 | unsigned int dma2_shift; | 117 | unsigned int dma2_shift; |
| 123 | 118 | ||
| 124 | struct snd_card *card; | ||
| 125 | struct snd_pcm *pcm; | 119 | struct snd_pcm *pcm; |
| 126 | struct snd_pcm_substream *playback_a_substream; | 120 | struct snd_pcm_substream *playback_a_substream; |
| 127 | struct snd_pcm_substream *capture_a_substream; | 121 | struct snd_pcm_substream *capture_a_substream; |
| @@ -136,14 +130,9 @@ struct snd_es18xx { | |||
| 136 | 130 | ||
| 137 | spinlock_t reg_lock; | 131 | spinlock_t reg_lock; |
| 138 | spinlock_t mixer_lock; | 132 | spinlock_t mixer_lock; |
| 139 | spinlock_t ctrl_lock; | ||
| 140 | #ifdef CONFIG_PM | 133 | #ifdef CONFIG_PM |
| 141 | unsigned char pm_reg; | 134 | unsigned char pm_reg; |
| 142 | #endif | 135 | #endif |
| 143 | }; | ||
| 144 | |||
| 145 | struct snd_audiodrive { | ||
| 146 | struct snd_es18xx *chip; | ||
| 147 | #ifdef CONFIG_PNP | 136 | #ifdef CONFIG_PNP |
| 148 | struct pnp_dev *dev; | 137 | struct pnp_dev *dev; |
| 149 | struct pnp_dev *devc; | 138 | struct pnp_dev *devc; |
| @@ -359,7 +348,7 @@ static inline int snd_es18xx_mixer_writable(struct snd_es18xx *chip, unsigned ch | |||
| 359 | } | 348 | } |
| 360 | 349 | ||
| 361 | 350 | ||
| 362 | static int snd_es18xx_reset(struct snd_es18xx *chip) | 351 | static int __devinit snd_es18xx_reset(struct snd_es18xx *chip) |
| 363 | { | 352 | { |
| 364 | int i; | 353 | int i; |
| 365 | outb(0x03, chip->port + 0x06); | 354 | outb(0x03, chip->port + 0x06); |
| @@ -495,8 +484,6 @@ static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip, | |||
| 495 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 484 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
| 496 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 485 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
| 497 | 486 | ||
| 498 | chip->dma2_size = size; | ||
| 499 | |||
| 500 | snd_es18xx_rate_set(chip, substream, DAC2); | 487 | snd_es18xx_rate_set(chip, substream, DAC2); |
| 501 | 488 | ||
| 502 | /* Transfer Count Reload */ | 489 | /* Transfer Count Reload */ |
| @@ -596,8 +583,6 @@ static int snd_es18xx_capture_prepare(struct snd_pcm_substream *substream) | |||
| 596 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 583 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
| 597 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 584 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
| 598 | 585 | ||
| 599 | chip->dma1_size = size; | ||
| 600 | |||
| 601 | snd_es18xx_reset_fifo(chip); | 586 | snd_es18xx_reset_fifo(chip); |
| 602 | 587 | ||
| 603 | /* Set stereo/mono */ | 588 | /* Set stereo/mono */ |
| @@ -664,8 +649,6 @@ static int snd_es18xx_playback2_prepare(struct snd_es18xx *chip, | |||
| 664 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 649 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
| 665 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 650 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
| 666 | 651 | ||
| 667 | chip->dma1_size = size; | ||
| 668 | |||
| 669 | snd_es18xx_reset_fifo(chip); | 652 | snd_es18xx_reset_fifo(chip); |
| 670 | 653 | ||
| 671 | /* Set stereo/mono */ | 654 | /* Set stereo/mono */ |
| @@ -755,7 +738,8 @@ static int snd_es18xx_playback_trigger(struct snd_pcm_substream *substream, | |||
| 755 | 738 | ||
| 756 | static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) | 739 | static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) |
| 757 | { | 740 | { |
| 758 | struct snd_es18xx *chip = dev_id; | 741 | struct snd_card *card = dev_id; |
| 742 | struct snd_es18xx *chip = card->private_data; | ||
| 759 | unsigned char status; | 743 | unsigned char status; |
| 760 | 744 | ||
| 761 | if (chip->caps & ES18XX_CONTROL) { | 745 | if (chip->caps & ES18XX_CONTROL) { |
| @@ -805,12 +789,16 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) | |||
| 805 | int split = 0; | 789 | int split = 0; |
| 806 | if (chip->caps & ES18XX_HWV) { | 790 | if (chip->caps & ES18XX_HWV) { |
| 807 | split = snd_es18xx_mixer_read(chip, 0x64) & 0x80; | 791 | split = snd_es18xx_mixer_read(chip, 0x64) & 0x80; |
| 808 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id); | 792 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, |
| 809 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id); | 793 | &chip->hw_switch->id); |
| 794 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
| 795 | &chip->hw_volume->id); | ||
| 810 | } | 796 | } |
| 811 | if (!split) { | 797 | if (!split) { |
| 812 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_switch->id); | 798 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, |
| 813 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id); | 799 | &chip->master_switch->id); |
| 800 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
| 801 | &chip->master_volume->id); | ||
| 814 | } | 802 | } |
| 815 | /* ack interrupt */ | 803 | /* ack interrupt */ |
| 816 | snd_es18xx_mixer_write(chip, 0x66, 0x00); | 804 | snd_es18xx_mixer_write(chip, 0x66, 0x00); |
| @@ -821,17 +809,18 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) | |||
| 821 | static snd_pcm_uframes_t snd_es18xx_playback_pointer(struct snd_pcm_substream *substream) | 809 | static snd_pcm_uframes_t snd_es18xx_playback_pointer(struct snd_pcm_substream *substream) |
| 822 | { | 810 | { |
| 823 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); | 811 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); |
| 812 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | ||
| 824 | int pos; | 813 | int pos; |
| 825 | 814 | ||
| 826 | if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { | 815 | if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { |
| 827 | if (!(chip->active & DAC2)) | 816 | if (!(chip->active & DAC2)) |
| 828 | return 0; | 817 | return 0; |
| 829 | pos = snd_dma_pointer(chip->dma2, chip->dma2_size); | 818 | pos = snd_dma_pointer(chip->dma2, size); |
| 830 | return pos >> chip->dma2_shift; | 819 | return pos >> chip->dma2_shift; |
| 831 | } else { | 820 | } else { |
| 832 | if (!(chip->active & DAC1)) | 821 | if (!(chip->active & DAC1)) |
| 833 | return 0; | 822 | return 0; |
| 834 | pos = snd_dma_pointer(chip->dma1, chip->dma1_size); | 823 | pos = snd_dma_pointer(chip->dma1, size); |
| 835 | return pos >> chip->dma1_shift; | 824 | return pos >> chip->dma1_shift; |
| 836 | } | 825 | } |
| 837 | } | 826 | } |
| @@ -839,11 +828,12 @@ static snd_pcm_uframes_t snd_es18xx_playback_pointer(struct snd_pcm_substream *s | |||
| 839 | static snd_pcm_uframes_t snd_es18xx_capture_pointer(struct snd_pcm_substream *substream) | 828 | static snd_pcm_uframes_t snd_es18xx_capture_pointer(struct snd_pcm_substream *substream) |
| 840 | { | 829 | { |
| 841 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); | 830 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); |
| 831 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | ||
| 842 | int pos; | 832 | int pos; |
| 843 | 833 | ||
| 844 | if (!(chip->active & ADC1)) | 834 | if (!(chip->active & ADC1)) |
| 845 | return 0; | 835 | return 0; |
| 846 | pos = snd_dma_pointer(chip->dma1, chip->dma1_size); | 836 | pos = snd_dma_pointer(chip->dma1, size); |
| 847 | return pos >> chip->dma1_shift; | 837 | return pos >> chip->dma1_shift; |
| 848 | } | 838 | } |
| 849 | 839 | ||
| @@ -974,9 +964,6 @@ static int snd_es18xx_capture_close(struct snd_pcm_substream *substream) | |||
| 974 | 964 | ||
| 975 | static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 965 | static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
| 976 | { | 966 | { |
| 977 | static char *texts4Source[4] = { | ||
| 978 | "Mic", "CD", "Line", "Master" | ||
| 979 | }; | ||
| 980 | static char *texts5Source[5] = { | 967 | static char *texts5Source[5] = { |
| 981 | "Mic", "CD", "Line", "Master", "Mix" | 968 | "Mic", "CD", "Line", "Master", "Mix" |
| 982 | }; | 969 | }; |
| @@ -994,7 +981,8 @@ static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_ele | |||
| 994 | uinfo->value.enumerated.items = 4; | 981 | uinfo->value.enumerated.items = 4; |
| 995 | if (uinfo->value.enumerated.item > 3) | 982 | if (uinfo->value.enumerated.item > 3) |
| 996 | uinfo->value.enumerated.item = 3; | 983 | 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]); | ||
| 998 | break; | 986 | break; |
| 999 | case 0x1887: | 987 | case 0x1887: |
| 1000 | case 0x1888: | 988 | case 0x1888: |
| @@ -1313,7 +1301,7 @@ ES18XX_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0) | |||
| 1313 | * The chipset specific mixer controls | 1301 | * The chipset specific mixer controls |
| 1314 | */ | 1302 | */ |
| 1315 | static struct snd_kcontrol_new snd_es18xx_opt_speaker = | 1303 | static 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); |
| 1317 | 1305 | ||
| 1318 | static struct snd_kcontrol_new snd_es18xx_opt_1869[] = { | 1306 | static struct snd_kcontrol_new snd_es18xx_opt_1869[] = { |
| 1319 | ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), | 1307 | ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), |
| @@ -1378,11 +1366,9 @@ ES18XX_SINGLE("Hardware Master Volume Split", 0, 0x64, 7, 1, 0), | |||
| 1378 | static int __devinit snd_es18xx_config_read(struct snd_es18xx *chip, unsigned char reg) | 1366 | static int __devinit snd_es18xx_config_read(struct snd_es18xx *chip, unsigned char reg) |
| 1379 | { | 1367 | { |
| 1380 | int data; | 1368 | int data; |
| 1381 | unsigned long flags; | 1369 | |
| 1382 | spin_lock_irqsave(&chip->ctrl_lock, flags); | ||
| 1383 | outb(reg, chip->ctrl_port); | 1370 | outb(reg, chip->ctrl_port); |
| 1384 | data = inb(chip->ctrl_port + 1); | 1371 | data = inb(chip->ctrl_port + 1); |
| 1385 | spin_unlock_irqrestore(&chip->ctrl_lock, flags); | ||
| 1386 | return data; | 1372 | return data; |
| 1387 | } | 1373 | } |
| 1388 | 1374 | ||
| @@ -1398,7 +1384,9 @@ static void __devinit snd_es18xx_config_write(struct snd_es18xx *chip, | |||
| 1398 | #endif | 1384 | #endif |
| 1399 | } | 1385 | } |
| 1400 | 1386 | ||
| 1401 | static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) | 1387 | static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip, |
| 1388 | unsigned long mpu_port, | ||
| 1389 | unsigned long fm_port) | ||
| 1402 | { | 1390 | { |
| 1403 | int mask = 0; | 1391 | int mask = 0; |
| 1404 | 1392 | ||
| @@ -1412,15 +1400,15 @@ static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) | |||
| 1412 | if (chip->caps & ES18XX_CONTROL) { | 1400 | if (chip->caps & ES18XX_CONTROL) { |
| 1413 | /* Hardware volume IRQ */ | 1401 | /* Hardware volume IRQ */ |
| 1414 | snd_es18xx_config_write(chip, 0x27, chip->irq); | 1402 | 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) { |
| 1416 | /* FM I/O */ | 1404 | /* FM I/O */ |
| 1417 | snd_es18xx_config_write(chip, 0x62, chip->fm_port >> 8); | 1405 | snd_es18xx_config_write(chip, 0x62, fm_port >> 8); |
| 1418 | snd_es18xx_config_write(chip, 0x63, chip->fm_port & 0xff); | 1406 | snd_es18xx_config_write(chip, 0x63, fm_port & 0xff); |
| 1419 | } | 1407 | } |
| 1420 | if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) { | 1408 | if (mpu_port > 0 && mpu_port != SNDRV_AUTO_PORT) { |
| 1421 | /* MPU-401 I/O */ | 1409 | /* MPU-401 I/O */ |
| 1422 | snd_es18xx_config_write(chip, 0x64, chip->mpu_port >> 8); | 1410 | snd_es18xx_config_write(chip, 0x64, mpu_port >> 8); |
| 1423 | snd_es18xx_config_write(chip, 0x65, chip->mpu_port & 0xff); | 1411 | snd_es18xx_config_write(chip, 0x65, mpu_port & 0xff); |
| 1424 | /* MPU-401 IRQ */ | 1412 | /* MPU-401 IRQ */ |
| 1425 | snd_es18xx_config_write(chip, 0x28, chip->irq); | 1413 | snd_es18xx_config_write(chip, 0x28, chip->irq); |
| 1426 | } | 1414 | } |
| @@ -1507,11 +1495,12 @@ static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) | |||
| 1507 | snd_es18xx_mixer_write(chip, 0x7A, 0x68); | 1495 | snd_es18xx_mixer_write(chip, 0x7A, 0x68); |
| 1508 | /* Enable and set hardware volume interrupt */ | 1496 | /* Enable and set hardware volume interrupt */ |
| 1509 | snd_es18xx_mixer_write(chip, 0x64, 0x06); | 1497 | 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) { |
| 1511 | /* MPU401 share irq with audio | 1499 | /* MPU401 share irq with audio |
| 1512 | Joystick enabled | 1500 | Joystick enabled |
| 1513 | FM enabled */ | 1501 | 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); | ||
| 1515 | } | 1504 | } |
| 1516 | snd_es18xx_mixer_write(chip, 0x7f, ((irqmask + 1) << 1) | 0x01); | 1505 | snd_es18xx_mixer_write(chip, 0x7f, ((irqmask + 1) << 1) | 0x01); |
| 1517 | } | 1506 | } |
| @@ -1629,7 +1618,9 @@ static int __devinit snd_es18xx_identify(struct snd_es18xx *chip) | |||
| 1629 | return 0; | 1618 | return 0; |
| 1630 | } | 1619 | } |
| 1631 | 1620 | ||
| 1632 | static int __devinit snd_es18xx_probe(struct snd_es18xx *chip) | 1621 | static int __devinit snd_es18xx_probe(struct snd_es18xx *chip, |
| 1622 | unsigned long mpu_port, | ||
| 1623 | unsigned long fm_port) | ||
| 1633 | { | 1624 | { |
| 1634 | if (snd_es18xx_identify(chip) < 0) { | 1625 | if (snd_es18xx_identify(chip) < 0) { |
| 1635 | snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); | 1626 | snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); |
| @@ -1650,8 +1641,6 @@ static int __devinit snd_es18xx_probe(struct snd_es18xx *chip) | |||
| 1650 | chip->caps = ES18XX_PCM2 | ES18XX_SPATIALIZER | ES18XX_RECMIX | ES18XX_NEW_RATE | ES18XX_AUXB | ES18XX_I2S | ES18XX_CONTROL | ES18XX_HWV; | 1641 | chip->caps = ES18XX_PCM2 | ES18XX_SPATIALIZER | ES18XX_RECMIX | ES18XX_NEW_RATE | ES18XX_AUXB | ES18XX_I2S | ES18XX_CONTROL | ES18XX_HWV; |
| 1651 | break; | 1642 | break; |
| 1652 | case 0x1887: | 1643 | case 0x1887: |
| 1653 | chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME; | ||
| 1654 | break; | ||
| 1655 | case 0x1888: | 1644 | case 0x1888: |
| 1656 | chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME; | 1645 | chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME; |
| 1657 | break; | 1646 | break; |
| @@ -1666,7 +1655,7 @@ static int __devinit snd_es18xx_probe(struct snd_es18xx *chip) | |||
| 1666 | if (chip->dma1 == chip->dma2) | 1655 | if (chip->dma1 == chip->dma2) |
| 1667 | chip->caps &= ~(ES18XX_PCM2 | ES18XX_DUPLEX_SAME); | 1656 | chip->caps &= ~(ES18XX_PCM2 | ES18XX_DUPLEX_SAME); |
| 1668 | 1657 | ||
| 1669 | return snd_es18xx_initialize(chip); | 1658 | return snd_es18xx_initialize(chip, mpu_port, fm_port); |
| 1670 | } | 1659 | } |
| 1671 | 1660 | ||
| 1672 | static struct snd_pcm_ops snd_es18xx_playback_ops = { | 1661 | static struct snd_pcm_ops snd_es18xx_playback_ops = { |
| @@ -1691,8 +1680,10 @@ static struct snd_pcm_ops snd_es18xx_capture_ops = { | |||
| 1691 | .pointer = snd_es18xx_capture_pointer, | 1680 | .pointer = snd_es18xx_capture_pointer, |
| 1692 | }; | 1681 | }; |
| 1693 | 1682 | ||
| 1694 | static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct snd_pcm ** rpcm) | 1683 | static int __devinit snd_es18xx_pcm(struct snd_card *card, int device, |
| 1684 | struct snd_pcm **rpcm) | ||
| 1695 | { | 1685 | { |
| 1686 | struct snd_es18xx *chip = card->private_data; | ||
| 1696 | struct snd_pcm *pcm; | 1687 | struct snd_pcm *pcm; |
| 1697 | char str[16]; | 1688 | char str[16]; |
| 1698 | int err; | 1689 | int err; |
| @@ -1701,9 +1692,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct | |||
| 1701 | *rpcm = NULL; | 1692 | *rpcm = NULL; |
| 1702 | sprintf(str, "ES%x", chip->version); | 1693 | sprintf(str, "ES%x", chip->version); |
| 1703 | if (chip->caps & ES18XX_PCM2) | 1694 | 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); |
| 1705 | else | 1696 | else |
| 1706 | err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm); | 1697 | err = snd_pcm_new(card, str, device, 1, 1, &pcm); |
| 1707 | if (err < 0) | 1698 | if (err < 0) |
| 1708 | return err; | 1699 | return err; |
| 1709 | 1700 | ||
| @@ -1734,10 +1725,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct | |||
| 1734 | #ifdef CONFIG_PM | 1725 | #ifdef CONFIG_PM |
| 1735 | static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) | 1726 | static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) |
| 1736 | { | 1727 | { |
| 1737 | struct snd_audiodrive *acard = card->private_data; | 1728 | struct snd_es18xx *chip = card->private_data; |
| 1738 | struct snd_es18xx *chip = acard->chip; | ||
| 1739 | 1729 | ||
| 1740 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); | 1730 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
| 1741 | 1731 | ||
| 1742 | snd_pcm_suspend_all(chip->pcm); | 1732 | snd_pcm_suspend_all(chip->pcm); |
| 1743 | 1733 | ||
| @@ -1752,24 +1742,25 @@ static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) | |||
| 1752 | 1742 | ||
| 1753 | static int snd_es18xx_resume(struct snd_card *card) | 1743 | static int snd_es18xx_resume(struct snd_card *card) |
| 1754 | { | 1744 | { |
| 1755 | struct snd_audiodrive *acard = card->private_data; | 1745 | struct snd_es18xx *chip = card->private_data; |
| 1756 | struct snd_es18xx *chip = acard->chip; | ||
| 1757 | 1746 | ||
| 1758 | /* restore PM register, we won't wake till (not 0x07) i/o activity though */ | 1747 | /* restore PM register, we won't wake till (not 0x07) i/o activity though */ |
| 1759 | snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); | 1748 | snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); |
| 1760 | 1749 | ||
| 1761 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); | 1750 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
| 1762 | return 0; | 1751 | return 0; |
| 1763 | } | 1752 | } |
| 1764 | #endif /* CONFIG_PM */ | 1753 | #endif /* CONFIG_PM */ |
| 1765 | 1754 | ||
| 1766 | static int snd_es18xx_free(struct snd_es18xx *chip) | 1755 | static int snd_es18xx_free(struct snd_card *card) |
| 1767 | { | 1756 | { |
| 1757 | struct snd_es18xx *chip = card->private_data; | ||
| 1758 | |||
| 1768 | release_and_free_resource(chip->res_port); | 1759 | release_and_free_resource(chip->res_port); |
| 1769 | release_and_free_resource(chip->res_ctrl_port); | 1760 | release_and_free_resource(chip->res_ctrl_port); |
| 1770 | release_and_free_resource(chip->res_mpu_port); | 1761 | release_and_free_resource(chip->res_mpu_port); |
| 1771 | if (chip->irq >= 0) | 1762 | if (chip->irq >= 0) |
| 1772 | free_irq(chip->irq, (void *) chip); | 1763 | free_irq(chip->irq, (void *) card); |
| 1773 | if (chip->dma1 >= 0) { | 1764 | if (chip->dma1 >= 0) { |
| 1774 | disable_dma(chip->dma1); | 1765 | disable_dma(chip->dma1); |
| 1775 | free_dma(chip->dma1); | 1766 | free_dma(chip->dma1); |
| @@ -1778,93 +1769,82 @@ static int snd_es18xx_free(struct snd_es18xx *chip) | |||
| 1778 | disable_dma(chip->dma2); | 1769 | disable_dma(chip->dma2); |
| 1779 | free_dma(chip->dma2); | 1770 | free_dma(chip->dma2); |
| 1780 | } | 1771 | } |
| 1781 | kfree(chip); | ||
| 1782 | return 0; | 1772 | return 0; |
| 1783 | } | 1773 | } |
| 1784 | 1774 | ||
| 1785 | static int snd_es18xx_dev_free(struct snd_device *device) | 1775 | static int snd_es18xx_dev_free(struct snd_device *device) |
| 1786 | { | 1776 | { |
| 1787 | struct snd_es18xx *chip = device->device_data; | 1777 | return snd_es18xx_free(device->card); |
| 1788 | return snd_es18xx_free(chip); | ||
| 1789 | } | 1778 | } |
| 1790 | 1779 | ||
| 1791 | static int __devinit snd_es18xx_new_device(struct snd_card *card, | 1780 | static int __devinit snd_es18xx_new_device(struct snd_card *card, |
| 1792 | unsigned long port, | 1781 | unsigned long port, |
| 1793 | unsigned long mpu_port, | 1782 | unsigned long mpu_port, |
| 1794 | unsigned long fm_port, | 1783 | unsigned long fm_port, |
| 1795 | int irq, int dma1, int dma2, | 1784 | int irq, int dma1, int dma2) |
| 1796 | struct snd_es18xx ** rchip) | ||
| 1797 | { | 1785 | { |
| 1798 | struct snd_es18xx *chip; | 1786 | struct snd_es18xx *chip = card->private_data; |
| 1799 | static struct snd_device_ops ops = { | 1787 | static struct snd_device_ops ops = { |
| 1800 | .dev_free = snd_es18xx_dev_free, | 1788 | .dev_free = snd_es18xx_dev_free, |
| 1801 | }; | 1789 | }; |
| 1802 | int err; | 1790 | int err; |
| 1803 | 1791 | ||
| 1804 | *rchip = NULL; | ||
| 1805 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
| 1806 | if (chip == NULL) | ||
| 1807 | return -ENOMEM; | ||
| 1808 | spin_lock_init(&chip->reg_lock); | 1792 | spin_lock_init(&chip->reg_lock); |
| 1809 | spin_lock_init(&chip->mixer_lock); | 1793 | spin_lock_init(&chip->mixer_lock); |
| 1810 | spin_lock_init(&chip->ctrl_lock); | ||
| 1811 | chip->card = card; | ||
| 1812 | chip->port = port; | 1794 | chip->port = port; |
| 1813 | chip->mpu_port = mpu_port; | ||
| 1814 | chip->fm_port = fm_port; | ||
| 1815 | chip->irq = -1; | 1795 | chip->irq = -1; |
| 1816 | chip->dma1 = -1; | 1796 | chip->dma1 = -1; |
| 1817 | chip->dma2 = -1; | 1797 | chip->dma2 = -1; |
| 1818 | chip->audio2_vol = 0x00; | 1798 | chip->audio2_vol = 0x00; |
| 1819 | chip->active = 0; | 1799 | chip->active = 0; |
| 1820 | 1800 | ||
| 1821 | if ((chip->res_port = request_region(port, 16, "ES18xx")) == NULL) { | 1801 | chip->res_port = request_region(port, 16, "ES18xx"); |
| 1822 | snd_es18xx_free(chip); | 1802 | if (chip->res_port == NULL) { |
| 1803 | snd_es18xx_free(card); | ||
| 1823 | snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); | 1804 | snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); |
| 1824 | return -EBUSY; | 1805 | return -EBUSY; |
| 1825 | } | 1806 | } |
| 1826 | 1807 | ||
| 1827 | if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", (void *) chip)) { | 1808 | if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", |
| 1828 | snd_es18xx_free(chip); | 1809 | (void *) card)) { |
| 1810 | snd_es18xx_free(card); | ||
| 1829 | snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); | 1811 | snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); |
| 1830 | return -EBUSY; | 1812 | return -EBUSY; |
| 1831 | } | 1813 | } |
| 1832 | chip->irq = irq; | 1814 | chip->irq = irq; |
| 1833 | 1815 | ||
| 1834 | if (request_dma(dma1, "ES18xx DMA 1")) { | 1816 | if (request_dma(dma1, "ES18xx DMA 1")) { |
| 1835 | snd_es18xx_free(chip); | 1817 | snd_es18xx_free(card); |
| 1836 | snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); | 1818 | snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); |
| 1837 | return -EBUSY; | 1819 | return -EBUSY; |
| 1838 | } | 1820 | } |
| 1839 | chip->dma1 = dma1; | 1821 | chip->dma1 = dma1; |
| 1840 | 1822 | ||
| 1841 | if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { | 1823 | if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { |
| 1842 | snd_es18xx_free(chip); | 1824 | snd_es18xx_free(card); |
| 1843 | snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); | 1825 | snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); |
| 1844 | return -EBUSY; | 1826 | return -EBUSY; |
| 1845 | } | 1827 | } |
| 1846 | chip->dma2 = dma2; | 1828 | chip->dma2 = dma2; |
| 1847 | 1829 | ||
| 1848 | if (snd_es18xx_probe(chip) < 0) { | 1830 | if (snd_es18xx_probe(chip, mpu_port, fm_port) < 0) { |
| 1849 | snd_es18xx_free(chip); | 1831 | snd_es18xx_free(card); |
| 1850 | return -ENODEV; | 1832 | return -ENODEV; |
| 1851 | } | 1833 | } |
| 1852 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 1834 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); |
| 1853 | snd_es18xx_free(chip); | 1835 | if (err < 0) { |
| 1836 | snd_es18xx_free(card); | ||
| 1854 | return err; | 1837 | return err; |
| 1855 | } | 1838 | } |
| 1856 | *rchip = chip; | ||
| 1857 | return 0; | 1839 | return 0; |
| 1858 | } | 1840 | } |
| 1859 | 1841 | ||
| 1860 | static int __devinit snd_es18xx_mixer(struct snd_es18xx *chip) | 1842 | static int __devinit snd_es18xx_mixer(struct snd_card *card) |
| 1861 | { | 1843 | { |
| 1862 | struct snd_card *card; | 1844 | struct snd_es18xx *chip = card->private_data; |
| 1863 | int err; | 1845 | int err; |
| 1864 | unsigned int idx; | 1846 | unsigned int idx; |
| 1865 | 1847 | ||
| 1866 | card = chip->card; | ||
| 1867 | |||
| 1868 | strcpy(card->mixername, chip->pcm->name); | 1848 | strcpy(card->mixername, chip->pcm->name); |
| 1869 | 1849 | ||
| 1870 | for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { | 1850 | for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { |
| @@ -1986,7 +1966,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | |||
| 1986 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 1966 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
| 1987 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ | 1967 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ |
| 1988 | #ifdef CONFIG_PNP | 1968 | #ifdef CONFIG_PNP |
| 1989 | static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; | 1969 | static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; |
| 1990 | #endif | 1970 | #endif |
| 1991 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */ | 1971 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */ |
| 1992 | #ifndef CONFIG_PNP | 1972 | #ifndef CONFIG_PNP |
| @@ -2063,11 +2043,11 @@ static int __devinit snd_audiodrive_pnp_init_main(int dev, struct pnp_dev *pdev) | |||
| 2063 | return 0; | 2043 | return 0; |
| 2064 | } | 2044 | } |
| 2065 | 2045 | ||
| 2066 | static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard, | 2046 | static int __devinit snd_audiodrive_pnp(int dev, struct snd_es18xx *chip, |
| 2067 | struct pnp_dev *pdev) | 2047 | struct pnp_dev *pdev) |
| 2068 | { | 2048 | { |
| 2069 | acard->dev = pdev; | 2049 | chip->dev = pdev; |
| 2070 | if (snd_audiodrive_pnp_init_main(dev, acard->dev) < 0) | 2050 | if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0) |
| 2071 | return -EBUSY; | 2051 | return -EBUSY; |
| 2072 | return 0; | 2052 | return 0; |
| 2073 | } | 2053 | } |
| @@ -2093,26 +2073,26 @@ static struct pnp_card_device_id snd_audiodrive_pnpids[] = { | |||
| 2093 | 2073 | ||
| 2094 | MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids); | 2074 | MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids); |
| 2095 | 2075 | ||
| 2096 | static int __devinit snd_audiodrive_pnpc(int dev, struct snd_audiodrive *acard, | 2076 | static int __devinit snd_audiodrive_pnpc(int dev, struct snd_es18xx *chip, |
| 2097 | struct pnp_card_link *card, | 2077 | struct pnp_card_link *card, |
| 2098 | const struct pnp_card_device_id *id) | 2078 | const struct pnp_card_device_id *id) |
| 2099 | { | 2079 | { |
| 2100 | acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); | 2080 | chip->dev = pnp_request_card_device(card, id->devs[0].id, NULL); |
| 2101 | if (acard->dev == NULL) | 2081 | if (chip->dev == NULL) |
| 2102 | return -EBUSY; | 2082 | return -EBUSY; |
| 2103 | 2083 | ||
| 2104 | acard->devc = pnp_request_card_device(card, id->devs[1].id, NULL); | 2084 | chip->devc = pnp_request_card_device(card, id->devs[1].id, NULL); |
| 2105 | if (acard->devc == NULL) | 2085 | if (chip->devc == NULL) |
| 2106 | return -EBUSY; | 2086 | return -EBUSY; |
| 2107 | 2087 | ||
| 2108 | /* Control port initialization */ | 2088 | /* Control port initialization */ |
| 2109 | if (pnp_activate_dev(acard->devc) < 0) { | 2089 | if (pnp_activate_dev(chip->devc) < 0) { |
| 2110 | snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n"); | 2090 | snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n"); |
| 2111 | return -EAGAIN; | 2091 | return -EAGAIN; |
| 2112 | } | 2092 | } |
| 2113 | snd_printdd("pnp: port=0x%llx\n", | 2093 | snd_printdd("pnp: port=0x%llx\n", |
| 2114 | (unsigned long long)pnp_port_start(acard->devc, 0)); | 2094 | (unsigned long long)pnp_port_start(chip->devc, 0)); |
| 2115 | if (snd_audiodrive_pnp_init_main(dev, acard->dev) < 0) | 2095 | if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0) |
| 2116 | return -EBUSY; | 2096 | return -EBUSY; |
| 2117 | 2097 | ||
| 2118 | return 0; | 2098 | return 0; |
| @@ -2128,24 +2108,20 @@ static int __devinit snd_audiodrive_pnpc(int dev, struct snd_audiodrive *acard, | |||
| 2128 | static int snd_es18xx_card_new(int dev, struct snd_card **cardp) | 2108 | static int snd_es18xx_card_new(int dev, struct snd_card **cardp) |
| 2129 | { | 2109 | { |
| 2130 | return snd_card_create(index[dev], id[dev], THIS_MODULE, | 2110 | return snd_card_create(index[dev], id[dev], THIS_MODULE, |
| 2131 | sizeof(struct snd_audiodrive), cardp); | 2111 | sizeof(struct snd_es18xx), cardp); |
| 2132 | } | 2112 | } |
| 2133 | 2113 | ||
| 2134 | static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) | 2114 | static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) |
| 2135 | { | 2115 | { |
| 2136 | struct snd_audiodrive *acard = card->private_data; | 2116 | struct snd_es18xx *chip = card->private_data; |
| 2137 | struct snd_es18xx *chip; | ||
| 2138 | struct snd_opl3 *opl3; | 2117 | struct snd_opl3 *opl3; |
| 2139 | int err; | 2118 | int err; |
| 2140 | 2119 | ||
| 2141 | if ((err = snd_es18xx_new_device(card, | 2120 | err = snd_es18xx_new_device(card, |
| 2142 | port[dev], | 2121 | port[dev], mpu_port[dev], fm_port[dev], |
| 2143 | mpu_port[dev], | 2122 | irq[dev], dma1[dev], dma2[dev]); |
| 2144 | fm_port[dev], | 2123 | if (err < 0) |
| 2145 | irq[dev], dma1[dev], dma2[dev], | ||
| 2146 | &chip)) < 0) | ||
| 2147 | return err; | 2124 | return err; |
| 2148 | acard->chip = chip; | ||
| 2149 | 2125 | ||
| 2150 | sprintf(card->driver, "ES%x", chip->version); | 2126 | sprintf(card->driver, "ES%x", chip->version); |
| 2151 | 2127 | ||
| @@ -2161,26 +2137,32 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) | |||
| 2161 | chip->port, | 2137 | chip->port, |
| 2162 | irq[dev], dma1[dev]); | 2138 | irq[dev], dma1[dev]); |
| 2163 | 2139 | ||
| 2164 | if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) | 2140 | err = snd_es18xx_pcm(card, 0, NULL); |
| 2141 | if (err < 0) | ||
| 2165 | return err; | 2142 | return err; |
| 2166 | 2143 | ||
| 2167 | if ((err = snd_es18xx_mixer(chip)) < 0) | 2144 | err = snd_es18xx_mixer(card); |
| 2145 | if (err < 0) | ||
| 2168 | return err; | 2146 | return err; |
| 2169 | 2147 | ||
| 2170 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { | 2148 | 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) { | 2149 | if (snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2, |
| 2172 | snd_printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->fm_port); | 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]); | ||
| 2173 | } else { | 2154 | } 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) | ||
| 2175 | return err; | 2157 | return err; |
| 2176 | } | 2158 | } |
| 2177 | } | 2159 | } |
| 2178 | 2160 | ||
| 2179 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | 2161 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { |
| 2180 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, | 2162 | err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, |
| 2181 | chip->mpu_port, 0, | 2163 | mpu_port[dev], 0, |
| 2182 | irq[dev], 0, | 2164 | irq[dev], 0, &chip->rmidi); |
| 2183 | &chip->rmidi)) < 0) | 2165 | if (err < 0) |
| 2184 | return err; | 2166 | return err; |
| 2185 | } | 2167 | } |
| 2186 | 2168 | ||
diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c index 661205c4dcea..af888a022fc0 100644 --- a/sound/isa/gus/gus_mem.c +++ b/sound/isa/gus/gus_mem.c | |||
| @@ -127,7 +127,8 @@ static struct snd_gf1_mem_block *snd_gf1_mem_share(struct snd_gf1_mem * alloc, | |||
| 127 | !share_id[2] && !share_id[3]) | 127 | !share_id[2] && !share_id[3]) |
| 128 | return NULL; | 128 | return NULL; |
| 129 | for (block = alloc->first; block; block = block->next) | 129 | 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))) | ||
| 131 | return block; | 132 | return block; |
| 132 | return NULL; | 133 | return NULL; |
| 133 | } | 134 | } |
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 534a6eced2b8..c7b80e4730fc 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c | |||
| @@ -26,7 +26,6 @@ | |||
| 26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
| 27 | #include <linux/isa.h> | 27 | #include <linux/isa.h> |
| 28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
| 29 | #include <linux/slab.h> | ||
| 30 | #include <linux/pnp.h> | 29 | #include <linux/pnp.h> |
| 31 | #include <linux/moduleparam.h> | 30 | #include <linux/moduleparam.h> |
| 32 | #include <asm/dma.h> | 31 | #include <asm/dma.h> |
diff --git a/sound/isa/msnd/msnd_midi.c b/sound/isa/msnd/msnd_midi.c index cb9aa4c4edd0..787495674235 100644 --- a/sound/isa/msnd/msnd_midi.c +++ b/sound/isa/msnd/msnd_midi.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | */ | 25 | */ |
| 26 | 26 | ||
| 27 | #include <linux/io.h> | 27 | #include <linux/io.h> |
| 28 | #include <linux/slab.h> | ||
| 28 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
| 29 | #include <linux/ioport.h> | 30 | #include <linux/ioport.h> |
| 30 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
| @@ -162,7 +163,7 @@ int snd_msndmidi_new(struct snd_card *card, int device) | |||
| 162 | err = snd_rawmidi_new(card, "MSND-MIDI", device, 1, 1, &rmidi); | 163 | err = snd_rawmidi_new(card, "MSND-MIDI", device, 1, 1, &rmidi); |
| 163 | if (err < 0) | 164 | if (err < 0) |
| 164 | return err; | 165 | return err; |
| 165 | mpu = kcalloc(1, sizeof(*mpu), GFP_KERNEL); | 166 | mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); |
| 166 | if (mpu == NULL) { | 167 | if (mpu == NULL) { |
| 167 | snd_device_free(card, rmidi); | 168 | snd_device_free(card, rmidi); |
| 168 | return -ENOMEM; | 169 | return -ENOMEM; |
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 0481a55334b9..265abcce9dba 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | #include <linux/isa.h> | 24 | #include <linux/isa.h> |
| 25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
| 26 | #include <linux/pm.h> | 26 | #include <linux/pm.h> |
| 27 | #include <linux/slab.h> | ||
| 28 | #include <linux/pnp.h> | 27 | #include <linux/pnp.h> |
| 29 | #include <linux/moduleparam.h> | 28 | #include <linux/moduleparam.h> |
| 30 | #include <sound/core.h> | 29 | #include <sound/core.h> |
diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index 02e30d7c6a93..8c24102d0d93 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c | |||
| @@ -25,8 +25,8 @@ | |||
| 25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
| 26 | #include <linux/err.h> | 26 | #include <linux/err.h> |
| 27 | #include <linux/isa.h> | 27 | #include <linux/isa.h> |
| 28 | #include <linux/pnp.h> | ||
| 28 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
| 29 | #include <linux/slab.h> | ||
| 30 | #include <linux/ioport.h> | 30 | #include <linux/ioport.h> |
| 31 | #include <linux/moduleparam.h> | 31 | #include <linux/moduleparam.h> |
| 32 | #include <asm/io.h> | 32 | #include <asm/io.h> |
| @@ -40,7 +40,7 @@ | |||
| 40 | #define SNDRV_LEGACY_FIND_FREE_IRQ | 40 | #define SNDRV_LEGACY_FIND_FREE_IRQ |
| 41 | #define SNDRV_LEGACY_FIND_FREE_DMA | 41 | #define SNDRV_LEGACY_FIND_FREE_DMA |
| 42 | #include <sound/initval.h> | 42 | #include <sound/initval.h> |
| 43 | #include "miro.h" | 43 | #include <sound/aci.h> |
| 44 | 44 | ||
| 45 | MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>"); | 45 | MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>"); |
| 46 | MODULE_LICENSE("GPL"); | 46 | MODULE_LICENSE("GPL"); |
| @@ -60,6 +60,9 @@ static int dma1 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ | |||
| 60 | static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ | 60 | static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ |
| 61 | static int wss; | 61 | static int wss; |
| 62 | static int ide; | 62 | static int ide; |
| 63 | #ifdef CONFIG_PNP | ||
| 64 | static int isapnp = 1; /* Enable ISA PnP detection */ | ||
| 65 | #endif | ||
| 63 | 66 | ||
| 64 | module_param(index, int, 0444); | 67 | module_param(index, int, 0444); |
| 65 | MODULE_PARM_DESC(index, "Index value for miro soundcard."); | 68 | MODULE_PARM_DESC(index, "Index value for miro soundcard."); |
| @@ -83,6 +86,10 @@ module_param(wss, int, 0444); | |||
| 83 | MODULE_PARM_DESC(wss, "wss mode"); | 86 | MODULE_PARM_DESC(wss, "wss mode"); |
| 84 | module_param(ide, int, 0444); | 87 | module_param(ide, int, 0444); |
| 85 | MODULE_PARM_DESC(ide, "enable ide port"); | 88 | MODULE_PARM_DESC(ide, "enable ide port"); |
| 89 | #ifdef CONFIG_PNP | ||
| 90 | module_param(isapnp, bool, 0444); | ||
| 91 | MODULE_PARM_DESC(isapnp, "Enable ISA PnP detection for specified soundcard."); | ||
| 92 | #endif | ||
| 86 | 93 | ||
| 87 | #define OPTi9XX_HW_DETECT 0 | 94 | #define OPTi9XX_HW_DETECT 0 |
| 88 | #define OPTi9XX_HW_82C928 1 | 95 | #define OPTi9XX_HW_82C928 1 |
| @@ -96,7 +103,6 @@ MODULE_PARM_DESC(ide, "enable ide port"); | |||
| 96 | 103 | ||
| 97 | #define OPTi9XX_MC_REG(n) n | 104 | #define OPTi9XX_MC_REG(n) n |
| 98 | 105 | ||
| 99 | |||
| 100 | struct snd_miro { | 106 | struct snd_miro { |
| 101 | unsigned short hardware; | 107 | unsigned short hardware; |
| 102 | unsigned char password; | 108 | unsigned char password; |
| @@ -110,7 +116,6 @@ struct snd_miro { | |||
| 110 | unsigned long pwd_reg; | 116 | unsigned long pwd_reg; |
| 111 | 117 | ||
| 112 | spinlock_t lock; | 118 | spinlock_t lock; |
| 113 | struct snd_card *card; | ||
| 114 | struct snd_pcm *pcm; | 119 | struct snd_pcm *pcm; |
| 115 | 120 | ||
| 116 | long wss_base; | 121 | long wss_base; |
| @@ -118,42 +123,48 @@ struct snd_miro { | |||
| 118 | int dma1; | 123 | int dma1; |
| 119 | int dma2; | 124 | int dma2; |
| 120 | 125 | ||
| 121 | long fm_port; | ||
| 122 | |||
| 123 | long mpu_port; | 126 | long mpu_port; |
| 124 | int mpu_irq; | 127 | int mpu_irq; |
| 125 | 128 | ||
| 126 | unsigned long aci_port; | 129 | struct snd_miro_aci *aci; |
| 127 | int aci_vendor; | ||
| 128 | int aci_product; | ||
| 129 | int aci_version; | ||
| 130 | int aci_amp; | ||
| 131 | int aci_preamp; | ||
| 132 | int aci_solomode; | ||
| 133 | |||
| 134 | struct mutex aci_mutex; | ||
| 135 | }; | 130 | }; |
| 136 | 131 | ||
| 137 | static void snd_miro_proc_init(struct snd_miro * miro); | 132 | static struct snd_miro_aci aci_device; |
| 138 | 133 | ||
| 139 | static char * snd_opti9xx_names[] = { | 134 | static char * snd_opti9xx_names[] = { |
| 140 | "unkown", | 135 | "unknown", |
| 141 | "82C928", "82C929", | 136 | "82C928", "82C929", |
| 142 | "82C924", "82C925", | 137 | "82C924", "82C925", |
| 143 | "82C930", "82C931", "82C933" | 138 | "82C930", "82C931", "82C933" |
| 144 | }; | 139 | }; |
| 145 | 140 | ||
| 141 | static int snd_miro_pnp_is_probed; | ||
| 142 | |||
| 143 | #ifdef CONFIG_PNP | ||
| 144 | |||
| 145 | static struct pnp_card_device_id snd_miro_pnpids[] = { | ||
| 146 | /* PCM20 and PCM12 in PnP mode */ | ||
| 147 | { .id = "MIR0924", | ||
| 148 | .devs = { { "MIR0000" }, { "MIR0002" }, { "MIR0005" } }, }, | ||
| 149 | { .id = "" } | ||
| 150 | }; | ||
| 151 | |||
| 152 | MODULE_DEVICE_TABLE(pnp_card, snd_miro_pnpids); | ||
| 153 | |||
| 154 | #endif /* CONFIG_PNP */ | ||
| 155 | |||
| 146 | /* | 156 | /* |
| 147 | * ACI control | 157 | * ACI control |
| 148 | */ | 158 | */ |
| 149 | 159 | ||
| 150 | static int aci_busy_wait(struct snd_miro * miro) | 160 | static int aci_busy_wait(struct snd_miro_aci *aci) |
| 151 | { | 161 | { |
| 152 | long timeout; | 162 | long timeout; |
| 153 | unsigned char byte; | 163 | unsigned char byte; |
| 154 | 164 | ||
| 155 | for (timeout = 1; timeout <= ACI_MINTIME+30; timeout++) { | 165 | for (timeout = 1; timeout <= ACI_MINTIME + 30; timeout++) { |
| 156 | if (((byte=inb(miro->aci_port + ACI_REG_BUSY)) & 1) == 0) { | 166 | byte = inb(aci->aci_port + ACI_REG_BUSY); |
| 167 | if ((byte & 1) == 0) { | ||
| 157 | if (timeout >= ACI_MINTIME) | 168 | if (timeout >= ACI_MINTIME) |
| 158 | snd_printd("aci ready in round %ld.\n", | 169 | snd_printd("aci ready in round %ld.\n", |
| 159 | timeout-ACI_MINTIME); | 170 | timeout-ACI_MINTIME); |
| @@ -179,10 +190,10 @@ static int aci_busy_wait(struct snd_miro * miro) | |||
| 179 | return -EBUSY; | 190 | return -EBUSY; |
| 180 | } | 191 | } |
| 181 | 192 | ||
| 182 | static inline int aci_write(struct snd_miro * miro, unsigned char byte) | 193 | static inline int aci_write(struct snd_miro_aci *aci, unsigned char byte) |
| 183 | { | 194 | { |
| 184 | if (aci_busy_wait(miro) >= 0) { | 195 | if (aci_busy_wait(aci) >= 0) { |
| 185 | outb(byte, miro->aci_port + ACI_REG_COMMAND); | 196 | outb(byte, aci->aci_port + ACI_REG_COMMAND); |
| 186 | return 0; | 197 | return 0; |
| 187 | } else { | 198 | } else { |
| 188 | snd_printk(KERN_ERR "aci busy, aci_write(0x%x) stopped.\n", byte); | 199 | snd_printk(KERN_ERR "aci busy, aci_write(0x%x) stopped.\n", byte); |
| @@ -190,12 +201,12 @@ static inline int aci_write(struct snd_miro * miro, unsigned char byte) | |||
| 190 | } | 201 | } |
| 191 | } | 202 | } |
| 192 | 203 | ||
| 193 | static inline int aci_read(struct snd_miro * miro) | 204 | static inline int aci_read(struct snd_miro_aci *aci) |
| 194 | { | 205 | { |
| 195 | unsigned char byte; | 206 | unsigned char byte; |
| 196 | 207 | ||
| 197 | if (aci_busy_wait(miro) >= 0) { | 208 | if (aci_busy_wait(aci) >= 0) { |
| 198 | byte=inb(miro->aci_port + ACI_REG_STATUS); | 209 | byte = inb(aci->aci_port + ACI_REG_STATUS); |
| 199 | return byte; | 210 | return byte; |
| 200 | } else { | 211 | } else { |
| 201 | snd_printk(KERN_ERR "aci busy, aci_read() stopped.\n"); | 212 | snd_printk(KERN_ERR "aci busy, aci_read() stopped.\n"); |
| @@ -203,39 +214,49 @@ static inline int aci_read(struct snd_miro * miro) | |||
| 203 | } | 214 | } |
| 204 | } | 215 | } |
| 205 | 216 | ||
| 206 | static int aci_cmd(struct snd_miro * miro, int write1, int write2, int write3) | 217 | int snd_aci_cmd(struct snd_miro_aci *aci, int write1, int write2, int write3) |
| 207 | { | 218 | { |
| 208 | int write[] = {write1, write2, write3}; | 219 | int write[] = {write1, write2, write3}; |
| 209 | int value, i; | 220 | int value, i; |
| 210 | 221 | ||
| 211 | if (mutex_lock_interruptible(&miro->aci_mutex)) | 222 | if (mutex_lock_interruptible(&aci->aci_mutex)) |
| 212 | return -EINTR; | 223 | return -EINTR; |
| 213 | 224 | ||
| 214 | for (i=0; i<3; i++) { | 225 | for (i=0; i<3; i++) { |
| 215 | if (write[i]< 0 || write[i] > 255) | 226 | if (write[i]< 0 || write[i] > 255) |
| 216 | break; | 227 | break; |
| 217 | else { | 228 | else { |
| 218 | value = aci_write(miro, write[i]); | 229 | value = aci_write(aci, write[i]); |
| 219 | if (value < 0) | 230 | if (value < 0) |
| 220 | goto out; | 231 | goto out; |
| 221 | } | 232 | } |
| 222 | } | 233 | } |
| 223 | 234 | ||
| 224 | value = aci_read(miro); | 235 | value = aci_read(aci); |
| 225 | 236 | ||
| 226 | out: mutex_unlock(&miro->aci_mutex); | 237 | out: mutex_unlock(&aci->aci_mutex); |
| 227 | return value; | 238 | return value; |
| 228 | } | 239 | } |
| 240 | EXPORT_SYMBOL(snd_aci_cmd); | ||
| 241 | |||
| 242 | static int aci_getvalue(struct snd_miro_aci *aci, unsigned char index) | ||
| 243 | { | ||
| 244 | return snd_aci_cmd(aci, ACI_STATUS, index, -1); | ||
| 245 | } | ||
| 229 | 246 | ||
| 230 | static int aci_getvalue(struct snd_miro * miro, unsigned char index) | 247 | static int aci_setvalue(struct snd_miro_aci *aci, unsigned char index, |
| 248 | int value) | ||
| 231 | { | 249 | { |
| 232 | return aci_cmd(miro, ACI_STATUS, index, -1); | 250 | return snd_aci_cmd(aci, index, value, -1); |
| 233 | } | 251 | } |
| 234 | 252 | ||
| 235 | static int aci_setvalue(struct snd_miro * miro, unsigned char index, int value) | 253 | struct snd_miro_aci *snd_aci_get_aci(void) |
| 236 | { | 254 | { |
| 237 | return aci_cmd(miro, index, value, -1); | 255 | if (aci_device.aci_port == 0) |
| 256 | return NULL; | ||
| 257 | return &aci_device; | ||
| 238 | } | 258 | } |
| 259 | EXPORT_SYMBOL(snd_aci_get_aci); | ||
| 239 | 260 | ||
| 240 | /* | 261 | /* |
| 241 | * MIXER part | 262 | * MIXER part |
| @@ -249,8 +270,10 @@ static int snd_miro_get_capture(struct snd_kcontrol *kcontrol, | |||
| 249 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 270 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
| 250 | int value; | 271 | int value; |
| 251 | 272 | ||
| 252 | if ((value = aci_getvalue(miro, ACI_S_GENERAL)) < 0) { | 273 | value = aci_getvalue(miro->aci, ACI_S_GENERAL); |
| 253 | snd_printk(KERN_ERR "snd_miro_get_capture() failed: %d\n", value); | 274 | if (value < 0) { |
| 275 | snd_printk(KERN_ERR "snd_miro_get_capture() failed: %d\n", | ||
| 276 | value); | ||
| 254 | return value; | 277 | return value; |
| 255 | } | 278 | } |
| 256 | 279 | ||
| @@ -267,13 +290,15 @@ static int snd_miro_put_capture(struct snd_kcontrol *kcontrol, | |||
| 267 | 290 | ||
| 268 | value = !(ucontrol->value.integer.value[0]); | 291 | value = !(ucontrol->value.integer.value[0]); |
| 269 | 292 | ||
| 270 | if ((error = aci_setvalue(miro, ACI_SET_SOLOMODE, value)) < 0) { | 293 | error = aci_setvalue(miro->aci, ACI_SET_SOLOMODE, value); |
| 271 | snd_printk(KERN_ERR "snd_miro_put_capture() failed: %d\n", error); | 294 | if (error < 0) { |
| 295 | snd_printk(KERN_ERR "snd_miro_put_capture() failed: %d\n", | ||
| 296 | error); | ||
| 272 | return error; | 297 | return error; |
| 273 | } | 298 | } |
| 274 | 299 | ||
| 275 | change = (value != miro->aci_solomode); | 300 | change = (value != miro->aci->aci_solomode); |
| 276 | miro->aci_solomode = value; | 301 | miro->aci->aci_solomode = value; |
| 277 | 302 | ||
| 278 | return change; | 303 | return change; |
| 279 | } | 304 | } |
| @@ -295,7 +320,7 @@ static int snd_miro_get_preamp(struct snd_kcontrol *kcontrol, | |||
| 295 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 320 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
| 296 | int value; | 321 | int value; |
| 297 | 322 | ||
| 298 | if (miro->aci_version <= 176) { | 323 | if (miro->aci->aci_version <= 176) { |
| 299 | 324 | ||
| 300 | /* | 325 | /* |
| 301 | OSS says it's not readable with versions < 176. | 326 | OSS says it's not readable with versions < 176. |
| @@ -303,12 +328,14 @@ static int snd_miro_get_preamp(struct snd_kcontrol *kcontrol, | |||
| 303 | which is a PCM12 with aci_version = 176. | 328 | which is a PCM12 with aci_version = 176. |
| 304 | */ | 329 | */ |
| 305 | 330 | ||
| 306 | ucontrol->value.integer.value[0] = miro->aci_preamp; | 331 | ucontrol->value.integer.value[0] = miro->aci->aci_preamp; |
| 307 | return 0; | 332 | return 0; |
| 308 | } | 333 | } |
| 309 | 334 | ||
| 310 | if ((value = aci_getvalue(miro, ACI_GET_PREAMP)) < 0) { | 335 | value = aci_getvalue(miro->aci, ACI_GET_PREAMP); |
| 311 | snd_printk(KERN_ERR "snd_miro_get_preamp() failed: %d\n", value); | 336 | if (value < 0) { |
| 337 | snd_printk(KERN_ERR "snd_miro_get_preamp() failed: %d\n", | ||
| 338 | value); | ||
| 312 | return value; | 339 | return value; |
| 313 | } | 340 | } |
| 314 | 341 | ||
| @@ -325,13 +352,15 @@ static int snd_miro_put_preamp(struct snd_kcontrol *kcontrol, | |||
| 325 | 352 | ||
| 326 | value = ucontrol->value.integer.value[0]; | 353 | value = ucontrol->value.integer.value[0]; |
| 327 | 354 | ||
| 328 | if ((error = aci_setvalue(miro, ACI_SET_PREAMP, value)) < 0) { | 355 | error = aci_setvalue(miro->aci, ACI_SET_PREAMP, value); |
| 329 | snd_printk(KERN_ERR "snd_miro_put_preamp() failed: %d\n", error); | 356 | if (error < 0) { |
| 357 | snd_printk(KERN_ERR "snd_miro_put_preamp() failed: %d\n", | ||
| 358 | error); | ||
| 330 | return error; | 359 | return error; |
| 331 | } | 360 | } |
| 332 | 361 | ||
| 333 | change = (value != miro->aci_preamp); | 362 | change = (value != miro->aci->aci_preamp); |
| 334 | miro->aci_preamp = value; | 363 | miro->aci->aci_preamp = value; |
| 335 | 364 | ||
| 336 | return change; | 365 | return change; |
| 337 | } | 366 | } |
| @@ -342,7 +371,7 @@ static int snd_miro_get_amp(struct snd_kcontrol *kcontrol, | |||
| 342 | struct snd_ctl_elem_value *ucontrol) | 371 | struct snd_ctl_elem_value *ucontrol) |
| 343 | { | 372 | { |
| 344 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 373 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
| 345 | ucontrol->value.integer.value[0] = miro->aci_amp; | 374 | ucontrol->value.integer.value[0] = miro->aci->aci_amp; |
| 346 | 375 | ||
| 347 | return 0; | 376 | return 0; |
| 348 | } | 377 | } |
| @@ -355,13 +384,14 @@ static int snd_miro_put_amp(struct snd_kcontrol *kcontrol, | |||
| 355 | 384 | ||
| 356 | value = ucontrol->value.integer.value[0]; | 385 | value = ucontrol->value.integer.value[0]; |
| 357 | 386 | ||
| 358 | if ((error = aci_setvalue(miro, ACI_SET_POWERAMP, value)) < 0) { | 387 | error = aci_setvalue(miro->aci, ACI_SET_POWERAMP, value); |
| 388 | if (error < 0) { | ||
| 359 | snd_printk(KERN_ERR "snd_miro_put_amp() to %d failed: %d\n", value, error); | 389 | snd_printk(KERN_ERR "snd_miro_put_amp() to %d failed: %d\n", value, error); |
| 360 | return error; | 390 | return error; |
| 361 | } | 391 | } |
| 362 | 392 | ||
| 363 | change = (value != miro->aci_amp); | 393 | change = (value != miro->aci->aci_amp); |
| 364 | miro->aci_amp = value; | 394 | miro->aci->aci_amp = value; |
| 365 | 395 | ||
| 366 | return change; | 396 | return change; |
| 367 | } | 397 | } |
| @@ -410,12 +440,14 @@ static int snd_miro_get_double(struct snd_kcontrol *kcontrol, | |||
| 410 | int right_reg = kcontrol->private_value & 0xff; | 440 | int right_reg = kcontrol->private_value & 0xff; |
| 411 | int left_reg = right_reg + 1; | 441 | int left_reg = right_reg + 1; |
| 412 | 442 | ||
| 413 | if ((right_val = aci_getvalue(miro, right_reg)) < 0) { | 443 | right_val = aci_getvalue(miro->aci, right_reg); |
| 444 | if (right_val < 0) { | ||
| 414 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", right_reg, right_val); | 445 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", right_reg, right_val); |
| 415 | return right_val; | 446 | return right_val; |
| 416 | } | 447 | } |
| 417 | 448 | ||
| 418 | if ((left_val = aci_getvalue(miro, left_reg)) < 0) { | 449 | left_val = aci_getvalue(miro->aci, left_reg); |
| 450 | if (left_val < 0) { | ||
| 419 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", left_reg, left_val); | 451 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", left_reg, left_val); |
| 420 | return left_val; | 452 | return left_val; |
| 421 | } | 453 | } |
| @@ -451,6 +483,7 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
| 451 | struct snd_ctl_elem_value *ucontrol) | 483 | struct snd_ctl_elem_value *ucontrol) |
| 452 | { | 484 | { |
| 453 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 485 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
| 486 | struct snd_miro_aci *aci = miro->aci; | ||
| 454 | int left, right, left_old, right_old; | 487 | int left, right, left_old, right_old; |
| 455 | int setreg_left, setreg_right, getreg_left, getreg_right; | 488 | int setreg_left, setreg_right, getreg_left, getreg_right; |
| 456 | int change, error; | 489 | int change, error; |
| @@ -459,21 +492,21 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
| 459 | right = ucontrol->value.integer.value[1]; | 492 | right = ucontrol->value.integer.value[1]; |
| 460 | 493 | ||
| 461 | setreg_right = (kcontrol->private_value >> 8) & 0xff; | 494 | setreg_right = (kcontrol->private_value >> 8) & 0xff; |
| 462 | if (setreg_right == ACI_SET_MASTER) { | 495 | setreg_left = setreg_right + 8; |
| 463 | setreg_left = setreg_right + 1; | 496 | if (setreg_right == ACI_SET_MASTER) |
| 464 | } else { | 497 | setreg_left -= 7; |
| 465 | setreg_left = setreg_right + 8; | ||
| 466 | } | ||
| 467 | 498 | ||
| 468 | getreg_right = kcontrol->private_value & 0xff; | 499 | getreg_right = kcontrol->private_value & 0xff; |
| 469 | getreg_left = getreg_right + 1; | 500 | getreg_left = getreg_right + 1; |
| 470 | 501 | ||
| 471 | if ((left_old = aci_getvalue(miro, getreg_left)) < 0) { | 502 | left_old = aci_getvalue(aci, getreg_left); |
| 503 | if (left_old < 0) { | ||
| 472 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_left, left_old); | 504 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_left, left_old); |
| 473 | return left_old; | 505 | return left_old; |
| 474 | } | 506 | } |
| 475 | 507 | ||
| 476 | if ((right_old = aci_getvalue(miro, getreg_right)) < 0) { | 508 | right_old = aci_getvalue(aci, getreg_right); |
| 509 | if (right_old < 0) { | ||
| 477 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_right, right_old); | 510 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_right, right_old); |
| 478 | return right_old; | 511 | return right_old; |
| 479 | } | 512 | } |
| @@ -492,13 +525,15 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
| 492 | right_old = 0x80 - right_old; | 525 | right_old = 0x80 - right_old; |
| 493 | 526 | ||
| 494 | if (left >= 0) { | 527 | if (left >= 0) { |
| 495 | if ((error = aci_setvalue(miro, setreg_left, left)) < 0) { | 528 | error = aci_setvalue(aci, setreg_left, left); |
| 529 | if (error < 0) { | ||
| 496 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 530 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
| 497 | left, error); | 531 | left, error); |
| 498 | return error; | 532 | return error; |
| 499 | } | 533 | } |
| 500 | } else { | 534 | } else { |
| 501 | if ((error = aci_setvalue(miro, setreg_left, 0x80 - left)) < 0) { | 535 | error = aci_setvalue(aci, setreg_left, 0x80 - left); |
| 536 | if (error < 0) { | ||
| 502 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 537 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
| 503 | 0x80 - left, error); | 538 | 0x80 - left, error); |
| 504 | return error; | 539 | return error; |
| @@ -506,13 +541,15 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
| 506 | } | 541 | } |
| 507 | 542 | ||
| 508 | if (right >= 0) { | 543 | if (right >= 0) { |
| 509 | if ((error = aci_setvalue(miro, setreg_right, right)) < 0) { | 544 | error = aci_setvalue(aci, setreg_right, right); |
| 545 | if (error < 0) { | ||
| 510 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 546 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
| 511 | right, error); | 547 | right, error); |
| 512 | return error; | 548 | return error; |
| 513 | } | 549 | } |
| 514 | } else { | 550 | } else { |
| 515 | if ((error = aci_setvalue(miro, setreg_right, 0x80 - right)) < 0) { | 551 | error = aci_setvalue(aci, setreg_right, 0x80 - right); |
| 552 | if (error < 0) { | ||
| 516 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 553 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
| 517 | 0x80 - right, error); | 554 | 0x80 - right, error); |
| 518 | return error; | 555 | return error; |
| @@ -530,12 +567,14 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
| 530 | left_old = 0x20 - left_old; | 567 | left_old = 0x20 - left_old; |
| 531 | right_old = 0x20 - right_old; | 568 | right_old = 0x20 - right_old; |
| 532 | 569 | ||
| 533 | if ((error = aci_setvalue(miro, setreg_left, 0x20 - left)) < 0) { | 570 | error = aci_setvalue(aci, setreg_left, 0x20 - left); |
| 571 | if (error < 0) { | ||
| 534 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 572 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
| 535 | 0x20 - left, error); | 573 | 0x20 - left, error); |
| 536 | return error; | 574 | return error; |
| 537 | } | 575 | } |
| 538 | if ((error = aci_setvalue(miro, setreg_right, 0x20 - right)) < 0) { | 576 | error = aci_setvalue(aci, setreg_right, 0x20 - right); |
| 577 | if (error < 0) { | ||
| 539 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 578 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
| 540 | 0x20 - right, error); | 579 | 0x20 - right, error); |
| 541 | return error; | 580 | return error; |
| @@ -633,11 +672,13 @@ static unsigned char aci_init_values[][2] __devinitdata = { | |||
| 633 | static int __devinit snd_set_aci_init_values(struct snd_miro *miro) | 672 | static int __devinit snd_set_aci_init_values(struct snd_miro *miro) |
| 634 | { | 673 | { |
| 635 | int idx, error; | 674 | int idx, error; |
| 675 | struct snd_miro_aci *aci = miro->aci; | ||
| 636 | 676 | ||
| 637 | /* enable WSS on PCM1 */ | 677 | /* enable WSS on PCM1 */ |
| 638 | 678 | ||
| 639 | if ((miro->aci_product == 'A') && wss) { | 679 | if ((aci->aci_product == 'A') && wss) { |
| 640 | if ((error = aci_setvalue(miro, ACI_SET_WSS, wss)) < 0) { | 680 | error = aci_setvalue(aci, ACI_SET_WSS, wss); |
| 681 | if (error < 0) { | ||
| 641 | snd_printk(KERN_ERR "enabling WSS mode failed\n"); | 682 | snd_printk(KERN_ERR "enabling WSS mode failed\n"); |
| 642 | return error; | 683 | return error; |
| 643 | } | 684 | } |
| @@ -646,7 +687,8 @@ static int __devinit snd_set_aci_init_values(struct snd_miro *miro) | |||
| 646 | /* enable IDE port */ | 687 | /* enable IDE port */ |
| 647 | 688 | ||
| 648 | if (ide) { | 689 | if (ide) { |
| 649 | if ((error = aci_setvalue(miro, ACI_SET_IDE, ide)) < 0) { | 690 | error = aci_setvalue(aci, ACI_SET_IDE, ide); |
| 691 | if (error < 0) { | ||
| 650 | snd_printk(KERN_ERR "enabling IDE port failed\n"); | 692 | snd_printk(KERN_ERR "enabling IDE port failed\n"); |
| 651 | return error; | 693 | return error; |
| 652 | } | 694 | } |
| @@ -654,32 +696,31 @@ static int __devinit snd_set_aci_init_values(struct snd_miro *miro) | |||
| 654 | 696 | ||
| 655 | /* set common aci values */ | 697 | /* set common aci values */ |
| 656 | 698 | ||
| 657 | for (idx = 0; idx < ARRAY_SIZE(aci_init_values); idx++) | 699 | for (idx = 0; idx < ARRAY_SIZE(aci_init_values); idx++) { |
| 658 | if ((error = aci_setvalue(miro, aci_init_values[idx][0], | 700 | error = aci_setvalue(aci, aci_init_values[idx][0], |
| 659 | aci_init_values[idx][1])) < 0) { | 701 | aci_init_values[idx][1]); |
| 702 | if (error < 0) { | ||
| 660 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 703 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
| 661 | aci_init_values[idx][0], error); | 704 | aci_init_values[idx][0], error); |
| 662 | return error; | 705 | return error; |
| 663 | } | 706 | } |
| 664 | 707 | } | |
| 665 | miro->aci_amp = 0; | 708 | aci->aci_amp = 0; |
| 666 | miro->aci_preamp = 0; | 709 | aci->aci_preamp = 0; |
| 667 | miro->aci_solomode = 1; | 710 | aci->aci_solomode = 1; |
| 668 | 711 | ||
| 669 | return 0; | 712 | return 0; |
| 670 | } | 713 | } |
| 671 | 714 | ||
| 672 | static int __devinit snd_miro_mixer(struct snd_miro *miro) | 715 | static int __devinit snd_miro_mixer(struct snd_card *card, |
| 716 | struct snd_miro *miro) | ||
| 673 | { | 717 | { |
| 674 | struct snd_card *card; | ||
| 675 | unsigned int idx; | 718 | unsigned int idx; |
| 676 | int err; | 719 | int err; |
| 677 | 720 | ||
| 678 | if (snd_BUG_ON(!miro || !miro->card)) | 721 | if (snd_BUG_ON(!miro || !card)) |
| 679 | return -EINVAL; | 722 | return -EINVAL; |
| 680 | 723 | ||
| 681 | card = miro->card; | ||
| 682 | |||
| 683 | switch (miro->hardware) { | 724 | switch (miro->hardware) { |
| 684 | case OPTi9XX_HW_82C924: | 725 | case OPTi9XX_HW_82C924: |
| 685 | strcpy(card->mixername, "ACI & OPTi924"); | 726 | strcpy(card->mixername, "ACI & OPTi924"); |
| @@ -697,7 +738,8 @@ static int __devinit snd_miro_mixer(struct snd_miro *miro) | |||
| 697 | return err; | 738 | return err; |
| 698 | } | 739 | } |
| 699 | 740 | ||
| 700 | if ((miro->aci_product == 'A') || (miro->aci_product == 'B')) { | 741 | if ((miro->aci->aci_product == 'A') || |
| 742 | (miro->aci->aci_product == 'B')) { | ||
| 701 | /* PCM1/PCM12 with power-amp and Line 2 */ | 743 | /* PCM1/PCM12 with power-amp and Line 2 */ |
| 702 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_line_control[0], miro))) < 0) | 744 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_line_control[0], miro))) < 0) |
| 703 | return err; | 745 | return err; |
| @@ -705,16 +747,17 @@ static int __devinit snd_miro_mixer(struct snd_miro *miro) | |||
| 705 | return err; | 747 | return err; |
| 706 | } | 748 | } |
| 707 | 749 | ||
| 708 | if ((miro->aci_product == 'B') || (miro->aci_product == 'C')) { | 750 | if ((miro->aci->aci_product == 'B') || |
| 751 | (miro->aci->aci_product == 'C')) { | ||
| 709 | /* PCM12/PCM20 with mic-preamp */ | 752 | /* PCM12/PCM20 with mic-preamp */ |
| 710 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_preamp_control[0], miro))) < 0) | 753 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_preamp_control[0], miro))) < 0) |
| 711 | return err; | 754 | return err; |
| 712 | if (miro->aci_version >= 176) | 755 | if (miro->aci->aci_version >= 176) |
| 713 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_capture_control[0], miro))) < 0) | 756 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_capture_control[0], miro))) < 0) |
| 714 | return err; | 757 | return err; |
| 715 | } | 758 | } |
| 716 | 759 | ||
| 717 | if (miro->aci_product == 'C') { | 760 | if (miro->aci->aci_product == 'C') { |
| 718 | /* PCM20 with radio and 7 band equalizer */ | 761 | /* PCM20 with radio and 7 band equalizer */ |
| 719 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_radio_control[0], miro))) < 0) | 762 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_radio_control[0], miro))) < 0) |
| 720 | return err; | 763 | return err; |
| @@ -757,21 +800,26 @@ static int __devinit snd_miro_init(struct snd_miro *chip, | |||
| 757 | chip->irq = -1; | 800 | chip->irq = -1; |
| 758 | chip->dma1 = -1; | 801 | chip->dma1 = -1; |
| 759 | chip->dma2 = -1; | 802 | chip->dma2 = -1; |
| 760 | chip->fm_port = -1; | ||
| 761 | chip->mpu_port = -1; | 803 | chip->mpu_port = -1; |
| 762 | chip->mpu_irq = -1; | 804 | chip->mpu_irq = -1; |
| 763 | 805 | ||
| 806 | chip->pwd_reg = 3; | ||
| 807 | |||
| 808 | #ifdef CONFIG_PNP | ||
| 809 | if (isapnp && chip->mc_base) | ||
| 810 | /* PnP resource gives the least 10 bits */ | ||
| 811 | chip->mc_base |= 0xc00; | ||
| 812 | else | ||
| 813 | #endif | ||
| 814 | chip->mc_base = 0xf8c; | ||
| 815 | |||
| 764 | switch (hardware) { | 816 | switch (hardware) { |
| 765 | case OPTi9XX_HW_82C929: | 817 | case OPTi9XX_HW_82C929: |
| 766 | chip->mc_base = 0xf8c; | ||
| 767 | chip->password = 0xe3; | 818 | chip->password = 0xe3; |
| 768 | chip->pwd_reg = 3; | ||
| 769 | break; | 819 | break; |
| 770 | 820 | ||
| 771 | case OPTi9XX_HW_82C924: | 821 | case OPTi9XX_HW_82C924: |
| 772 | chip->mc_base = 0xf8c; | ||
| 773 | chip->password = 0xe5; | 822 | chip->password = 0xe5; |
| 774 | chip->pwd_reg = 3; | ||
| 775 | break; | 823 | break; |
| 776 | 824 | ||
| 777 | default: | 825 | default: |
| @@ -853,14 +901,15 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
| 853 | struct snd_info_buffer *buffer) | 901 | struct snd_info_buffer *buffer) |
| 854 | { | 902 | { |
| 855 | struct snd_miro *miro = (struct snd_miro *) entry->private_data; | 903 | struct snd_miro *miro = (struct snd_miro *) entry->private_data; |
| 904 | struct snd_miro_aci *aci = miro->aci; | ||
| 856 | char* model = "unknown"; | 905 | char* model = "unknown"; |
| 857 | 906 | ||
| 858 | /* miroSOUND PCM1 pro, early PCM12 */ | 907 | /* miroSOUND PCM1 pro, early PCM12 */ |
| 859 | 908 | ||
| 860 | if ((miro->hardware == OPTi9XX_HW_82C929) && | 909 | if ((miro->hardware == OPTi9XX_HW_82C929) && |
| 861 | (miro->aci_vendor == 'm') && | 910 | (aci->aci_vendor == 'm') && |
| 862 | (miro->aci_product == 'A')) { | 911 | (aci->aci_product == 'A')) { |
| 863 | switch(miro->aci_version) { | 912 | switch (aci->aci_version) { |
| 864 | case 3: | 913 | case 3: |
| 865 | model = "miroSOUND PCM1 pro"; | 914 | model = "miroSOUND PCM1 pro"; |
| 866 | break; | 915 | break; |
| @@ -873,9 +922,9 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
| 873 | /* miroSOUND PCM12, PCM12 (Rev. E), PCM12 pnp */ | 922 | /* miroSOUND PCM12, PCM12 (Rev. E), PCM12 pnp */ |
| 874 | 923 | ||
| 875 | if ((miro->hardware == OPTi9XX_HW_82C924) && | 924 | if ((miro->hardware == OPTi9XX_HW_82C924) && |
| 876 | (miro->aci_vendor == 'm') && | 925 | (aci->aci_vendor == 'm') && |
| 877 | (miro->aci_product == 'B')) { | 926 | (aci->aci_product == 'B')) { |
| 878 | switch(miro->aci_version) { | 927 | switch (aci->aci_version) { |
| 879 | case 4: | 928 | case 4: |
| 880 | model = "miroSOUND PCM12"; | 929 | model = "miroSOUND PCM12"; |
| 881 | break; | 930 | break; |
| @@ -891,9 +940,9 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
| 891 | /* miroSOUND PCM20 radio */ | 940 | /* miroSOUND PCM20 radio */ |
| 892 | 941 | ||
| 893 | if ((miro->hardware == OPTi9XX_HW_82C924) && | 942 | if ((miro->hardware == OPTi9XX_HW_82C924) && |
| 894 | (miro->aci_vendor == 'm') && | 943 | (aci->aci_vendor == 'm') && |
| 895 | (miro->aci_product == 'C')) { | 944 | (aci->aci_product == 'C')) { |
| 896 | switch(miro->aci_version) { | 945 | switch (aci->aci_version) { |
| 897 | case 7: | 946 | case 7: |
| 898 | model = "miroSOUND PCM20 radio (Rev. E)"; | 947 | model = "miroSOUND PCM20 radio (Rev. E)"; |
| 899 | break; | 948 | break; |
| @@ -917,17 +966,17 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
| 917 | 966 | ||
| 918 | snd_iprintf(buffer, "ACI information:\n"); | 967 | snd_iprintf(buffer, "ACI information:\n"); |
| 919 | snd_iprintf(buffer, " vendor : "); | 968 | snd_iprintf(buffer, " vendor : "); |
| 920 | switch(miro->aci_vendor) { | 969 | switch (aci->aci_vendor) { |
| 921 | case 'm': | 970 | case 'm': |
| 922 | snd_iprintf(buffer, "Miro\n"); | 971 | snd_iprintf(buffer, "Miro\n"); |
| 923 | break; | 972 | break; |
| 924 | default: | 973 | default: |
| 925 | snd_iprintf(buffer, "unknown (0x%x)\n", miro->aci_vendor); | 974 | snd_iprintf(buffer, "unknown (0x%x)\n", aci->aci_vendor); |
| 926 | break; | 975 | break; |
| 927 | } | 976 | } |
| 928 | 977 | ||
| 929 | snd_iprintf(buffer, " product : "); | 978 | snd_iprintf(buffer, " product : "); |
| 930 | switch(miro->aci_product) { | 979 | switch (aci->aci_product) { |
| 931 | case 'A': | 980 | case 'A': |
| 932 | snd_iprintf(buffer, "miroSOUND PCM1 pro / (early) PCM12\n"); | 981 | snd_iprintf(buffer, "miroSOUND PCM1 pro / (early) PCM12\n"); |
| 933 | break; | 982 | break; |
| @@ -938,26 +987,27 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
| 938 | snd_iprintf(buffer, "miroSOUND PCM20 radio\n"); | 987 | snd_iprintf(buffer, "miroSOUND PCM20 radio\n"); |
| 939 | break; | 988 | break; |
| 940 | default: | 989 | default: |
| 941 | snd_iprintf(buffer, "unknown (0x%x)\n", miro->aci_product); | 990 | snd_iprintf(buffer, "unknown (0x%x)\n", aci->aci_product); |
| 942 | break; | 991 | break; |
| 943 | } | 992 | } |
| 944 | 993 | ||
| 945 | snd_iprintf(buffer, " firmware: %d (0x%x)\n", | 994 | snd_iprintf(buffer, " firmware: %d (0x%x)\n", |
| 946 | miro->aci_version, miro->aci_version); | 995 | aci->aci_version, aci->aci_version); |
| 947 | snd_iprintf(buffer, " port : 0x%lx-0x%lx\n", | 996 | snd_iprintf(buffer, " port : 0x%lx-0x%lx\n", |
| 948 | miro->aci_port, miro->aci_port+2); | 997 | aci->aci_port, aci->aci_port+2); |
| 949 | snd_iprintf(buffer, " wss : 0x%x\n", wss); | 998 | snd_iprintf(buffer, " wss : 0x%x\n", wss); |
| 950 | snd_iprintf(buffer, " ide : 0x%x\n", ide); | 999 | snd_iprintf(buffer, " ide : 0x%x\n", ide); |
| 951 | snd_iprintf(buffer, " solomode: 0x%x\n", miro->aci_solomode); | 1000 | snd_iprintf(buffer, " solomode: 0x%x\n", aci->aci_solomode); |
| 952 | snd_iprintf(buffer, " amp : 0x%x\n", miro->aci_amp); | 1001 | snd_iprintf(buffer, " amp : 0x%x\n", aci->aci_amp); |
| 953 | snd_iprintf(buffer, " preamp : 0x%x\n", miro->aci_preamp); | 1002 | snd_iprintf(buffer, " preamp : 0x%x\n", aci->aci_preamp); |
| 954 | } | 1003 | } |
| 955 | 1004 | ||
| 956 | static void __devinit snd_miro_proc_init(struct snd_miro * miro) | 1005 | static void __devinit snd_miro_proc_init(struct snd_card *card, |
| 1006 | struct snd_miro *miro) | ||
| 957 | { | 1007 | { |
| 958 | struct snd_info_entry *entry; | 1008 | struct snd_info_entry *entry; |
| 959 | 1009 | ||
| 960 | if (! snd_card_proc_new(miro->card, "miro", &entry)) | 1010 | if (!snd_card_proc_new(card, "miro", &entry)) |
| 961 | snd_info_set_text_ops(entry, miro, snd_miro_proc_read); | 1011 | snd_info_set_text_ops(entry, miro, snd_miro_proc_read); |
| 962 | } | 1012 | } |
| 963 | 1013 | ||
| @@ -974,37 +1024,40 @@ static int __devinit snd_miro_configure(struct snd_miro *chip) | |||
| 974 | unsigned char mpu_irq_bits; | 1024 | unsigned char mpu_irq_bits; |
| 975 | unsigned long flags; | 1025 | unsigned long flags; |
| 976 | 1026 | ||
| 1027 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); | ||
| 1028 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(2), 0x20, 0x20); /* OPL4 */ | ||
| 1029 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); | ||
| 1030 | |||
| 977 | switch (chip->hardware) { | 1031 | switch (chip->hardware) { |
| 978 | case OPTi9XX_HW_82C924: | 1032 | case OPTi9XX_HW_82C924: |
| 979 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); | 1033 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); |
| 980 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); | ||
| 981 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(2), 0x20, 0x20); /* OPL4 */ | ||
| 982 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); | 1034 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); |
| 983 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); | ||
| 984 | break; | 1035 | break; |
| 985 | case OPTi9XX_HW_82C929: | 1036 | case OPTi9XX_HW_82C929: |
| 986 | /* untested init commands for OPTi929 */ | 1037 | /* untested init commands for OPTi929 */ |
| 987 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); | ||
| 988 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(2), 0x20, 0x20); /* OPL4 */ | ||
| 989 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(4), 0x00, 0x0c); | 1038 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(4), 0x00, 0x0c); |
| 990 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); | ||
| 991 | break; | 1039 | break; |
| 992 | default: | 1040 | default: |
| 993 | snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); | 1041 | snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); |
| 994 | return -EINVAL; | 1042 | return -EINVAL; |
| 995 | } | 1043 | } |
| 996 | 1044 | ||
| 997 | switch (chip->wss_base) { | 1045 | /* PnP resource says it decodes only 10 bits of address */ |
| 998 | case 0x530: | 1046 | switch (chip->wss_base & 0x3ff) { |
| 1047 | case 0x130: | ||
| 1048 | chip->wss_base = 0x530; | ||
| 999 | wss_base_bits = 0x00; | 1049 | wss_base_bits = 0x00; |
| 1000 | break; | 1050 | break; |
| 1001 | case 0x604: | 1051 | case 0x204: |
| 1052 | chip->wss_base = 0x604; | ||
| 1002 | wss_base_bits = 0x03; | 1053 | wss_base_bits = 0x03; |
| 1003 | break; | 1054 | break; |
| 1004 | case 0xe80: | 1055 | case 0x280: |
| 1056 | chip->wss_base = 0xe80; | ||
| 1005 | wss_base_bits = 0x01; | 1057 | wss_base_bits = 0x01; |
| 1006 | break; | 1058 | break; |
| 1007 | case 0xf40: | 1059 | case 0x340: |
| 1060 | chip->wss_base = 0xf40; | ||
| 1008 | wss_base_bits = 0x02; | 1061 | wss_base_bits = 0x02; |
| 1009 | break; | 1062 | break; |
| 1010 | default: | 1063 | default: |
| @@ -1122,75 +1175,92 @@ __skip_mpu: | |||
| 1122 | return 0; | 1175 | return 0; |
| 1123 | } | 1176 | } |
| 1124 | 1177 | ||
| 1178 | static int __devinit snd_miro_opti_check(struct snd_miro *chip) | ||
| 1179 | { | ||
| 1180 | unsigned char value; | ||
| 1181 | |||
| 1182 | chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, | ||
| 1183 | "OPTi9xx MC"); | ||
| 1184 | if (chip->res_mc_base == NULL) | ||
| 1185 | return -ENOMEM; | ||
| 1186 | |||
| 1187 | value = snd_miro_read(chip, OPTi9XX_MC_REG(1)); | ||
| 1188 | if (value != 0xff && value != inb(chip->mc_base + OPTi9XX_MC_REG(1))) | ||
| 1189 | if (value == snd_miro_read(chip, OPTi9XX_MC_REG(1))) | ||
| 1190 | return 0; | ||
| 1191 | |||
| 1192 | release_and_free_resource(chip->res_mc_base); | ||
| 1193 | chip->res_mc_base = NULL; | ||
| 1194 | |||
| 1195 | return -ENODEV; | ||
| 1196 | } | ||
| 1197 | |||
| 1125 | static int __devinit snd_card_miro_detect(struct snd_card *card, | 1198 | static int __devinit snd_card_miro_detect(struct snd_card *card, |
| 1126 | struct snd_miro *chip) | 1199 | struct snd_miro *chip) |
| 1127 | { | 1200 | { |
| 1128 | int i, err; | 1201 | int i, err; |
| 1129 | unsigned char value; | ||
| 1130 | 1202 | ||
| 1131 | for (i = OPTi9XX_HW_82C929; i <= OPTi9XX_HW_82C924; i++) { | 1203 | for (i = OPTi9XX_HW_82C929; i <= OPTi9XX_HW_82C924; i++) { |
| 1132 | 1204 | ||
| 1133 | if ((err = snd_miro_init(chip, i)) < 0) | 1205 | if ((err = snd_miro_init(chip, i)) < 0) |
| 1134 | return err; | 1206 | return err; |
| 1135 | 1207 | ||
| 1136 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) | 1208 | err = snd_miro_opti_check(chip); |
| 1137 | continue; | 1209 | if (err == 0) |
| 1138 | 1210 | return 1; | |
| 1139 | value = snd_miro_read(chip, OPTi9XX_MC_REG(1)); | ||
| 1140 | if ((value != 0xff) && (value != inb(chip->mc_base + 1))) | ||
| 1141 | if (value == snd_miro_read(chip, OPTi9XX_MC_REG(1))) | ||
| 1142 | return 1; | ||
| 1143 | |||
| 1144 | release_and_free_resource(chip->res_mc_base); | ||
| 1145 | chip->res_mc_base = NULL; | ||
| 1146 | |||
| 1147 | } | 1211 | } |
| 1148 | 1212 | ||
| 1149 | return -ENODEV; | 1213 | return -ENODEV; |
| 1150 | } | 1214 | } |
| 1151 | 1215 | ||
| 1152 | static int __devinit snd_card_miro_aci_detect(struct snd_card *card, | 1216 | static int __devinit snd_card_miro_aci_detect(struct snd_card *card, |
| 1153 | struct snd_miro * miro) | 1217 | struct snd_miro *miro) |
| 1154 | { | 1218 | { |
| 1155 | unsigned char regval; | 1219 | unsigned char regval; |
| 1156 | int i; | 1220 | int i; |
| 1221 | struct snd_miro_aci *aci = &aci_device; | ||
| 1222 | |||
| 1223 | miro->aci = aci; | ||
| 1157 | 1224 | ||
| 1158 | mutex_init(&miro->aci_mutex); | 1225 | mutex_init(&aci->aci_mutex); |
| 1159 | 1226 | ||
| 1160 | /* get ACI port from OPTi9xx MC 4 */ | 1227 | /* get ACI port from OPTi9xx MC 4 */ |
| 1161 | 1228 | ||
| 1162 | miro->mc_base = 0xf8c; | ||
| 1163 | regval=inb(miro->mc_base + 4); | 1229 | regval=inb(miro->mc_base + 4); |
| 1164 | miro->aci_port = (regval & 0x10) ? 0x344: 0x354; | 1230 | aci->aci_port = (regval & 0x10) ? 0x344 : 0x354; |
| 1165 | 1231 | ||
| 1166 | if ((miro->res_aci_port = request_region(miro->aci_port, 3, "miro aci")) == NULL) { | 1232 | miro->res_aci_port = request_region(aci->aci_port, 3, "miro aci"); |
| 1233 | if (miro->res_aci_port == NULL) { | ||
| 1167 | snd_printk(KERN_ERR "aci i/o area 0x%lx-0x%lx already used.\n", | 1234 | snd_printk(KERN_ERR "aci i/o area 0x%lx-0x%lx already used.\n", |
| 1168 | miro->aci_port, miro->aci_port+2); | 1235 | aci->aci_port, aci->aci_port+2); |
| 1169 | return -ENOMEM; | 1236 | return -ENOMEM; |
| 1170 | } | 1237 | } |
| 1171 | 1238 | ||
| 1172 | /* force ACI into a known state */ | 1239 | /* force ACI into a known state */ |
| 1173 | for (i = 0; i < 3; i++) | 1240 | for (i = 0; i < 3; i++) |
| 1174 | if (aci_cmd(miro, ACI_ERROR_OP, -1, -1) < 0) { | 1241 | if (snd_aci_cmd(aci, ACI_ERROR_OP, -1, -1) < 0) { |
| 1175 | snd_printk(KERN_ERR "can't force aci into known state.\n"); | 1242 | snd_printk(KERN_ERR "can't force aci into known state.\n"); |
| 1176 | return -ENXIO; | 1243 | return -ENXIO; |
| 1177 | } | 1244 | } |
| 1178 | 1245 | ||
| 1179 | if ((miro->aci_vendor=aci_cmd(miro, ACI_READ_IDCODE, -1, -1)) < 0 || | 1246 | aci->aci_vendor = snd_aci_cmd(aci, ACI_READ_IDCODE, -1, -1); |
| 1180 | (miro->aci_product=aci_cmd(miro, ACI_READ_IDCODE, -1, -1)) < 0) { | 1247 | aci->aci_product = snd_aci_cmd(aci, ACI_READ_IDCODE, -1, -1); |
| 1181 | snd_printk(KERN_ERR "can't read aci id on 0x%lx.\n", miro->aci_port); | 1248 | if (aci->aci_vendor < 0 || aci->aci_product < 0) { |
| 1249 | snd_printk(KERN_ERR "can't read aci id on 0x%lx.\n", | ||
| 1250 | aci->aci_port); | ||
| 1182 | return -ENXIO; | 1251 | return -ENXIO; |
| 1183 | } | 1252 | } |
| 1184 | 1253 | ||
| 1185 | if ((miro->aci_version=aci_cmd(miro, ACI_READ_VERSION, -1, -1)) < 0) { | 1254 | aci->aci_version = snd_aci_cmd(aci, ACI_READ_VERSION, -1, -1); |
| 1255 | if (aci->aci_version < 0) { | ||
| 1186 | snd_printk(KERN_ERR "can't read aci version on 0x%lx.\n", | 1256 | snd_printk(KERN_ERR "can't read aci version on 0x%lx.\n", |
| 1187 | miro->aci_port); | 1257 | aci->aci_port); |
| 1188 | return -ENXIO; | 1258 | return -ENXIO; |
| 1189 | } | 1259 | } |
| 1190 | 1260 | ||
| 1191 | if (aci_cmd(miro, ACI_INIT, -1, -1) < 0 || | 1261 | if (snd_aci_cmd(aci, ACI_INIT, -1, -1) < 0 || |
| 1192 | aci_cmd(miro, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0 || | 1262 | snd_aci_cmd(aci, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0 || |
| 1193 | aci_cmd(miro, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0) { | 1263 | snd_aci_cmd(aci, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0) { |
| 1194 | snd_printk(KERN_ERR "can't initialize aci.\n"); | 1264 | snd_printk(KERN_ERR "can't initialize aci.\n"); |
| 1195 | return -ENXIO; | 1265 | return -ENXIO; |
| 1196 | } | 1266 | } |
| @@ -1201,157 +1271,80 @@ static int __devinit snd_card_miro_aci_detect(struct snd_card *card, | |||
| 1201 | static void snd_card_miro_free(struct snd_card *card) | 1271 | static void snd_card_miro_free(struct snd_card *card) |
| 1202 | { | 1272 | { |
| 1203 | struct snd_miro *miro = card->private_data; | 1273 | struct snd_miro *miro = card->private_data; |
| 1204 | 1274 | ||
| 1205 | release_and_free_resource(miro->res_aci_port); | 1275 | release_and_free_resource(miro->res_aci_port); |
| 1276 | if (miro->aci) | ||
| 1277 | miro->aci->aci_port = 0; | ||
| 1206 | release_and_free_resource(miro->res_mc_base); | 1278 | release_and_free_resource(miro->res_mc_base); |
| 1207 | } | 1279 | } |
| 1208 | 1280 | ||
| 1209 | static int __devinit snd_miro_match(struct device *devptr, unsigned int n) | 1281 | static int __devinit snd_miro_probe(struct snd_card *card) |
| 1210 | { | ||
| 1211 | return 1; | ||
| 1212 | } | ||
| 1213 | |||
| 1214 | static int __devinit snd_miro_probe(struct device *devptr, unsigned int n) | ||
| 1215 | { | 1282 | { |
| 1216 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; | ||
| 1217 | static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1}; | ||
| 1218 | static int possible_irqs[] = {11, 9, 10, 7, -1}; | ||
| 1219 | static int possible_mpu_irqs[] = {10, 5, 9, 7, -1}; | ||
| 1220 | static int possible_dma1s[] = {3, 1, 0, -1}; | ||
| 1221 | static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; | ||
| 1222 | |||
| 1223 | int error; | 1283 | int error; |
| 1224 | struct snd_miro *miro; | 1284 | struct snd_miro *miro = card->private_data; |
| 1225 | struct snd_wss *codec; | 1285 | struct snd_wss *codec; |
| 1226 | struct snd_timer *timer; | 1286 | struct snd_timer *timer; |
| 1227 | struct snd_card *card; | ||
| 1228 | struct snd_pcm *pcm; | 1287 | struct snd_pcm *pcm; |
| 1229 | struct snd_rawmidi *rmidi; | 1288 | struct snd_rawmidi *rmidi; |
| 1230 | 1289 | ||
| 1231 | error = snd_card_create(index, id, THIS_MODULE, | 1290 | if (!miro->res_mc_base) { |
| 1232 | sizeof(struct snd_miro), &card); | 1291 | miro->res_mc_base = request_region(miro->mc_base, |
| 1233 | if (error < 0) | 1292 | miro->mc_base_size, |
| 1234 | return error; | 1293 | "miro (OPTi9xx MC)"); |
| 1235 | 1294 | if (miro->res_mc_base == NULL) { | |
| 1236 | card->private_free = snd_card_miro_free; | 1295 | snd_printk(KERN_ERR "request for OPTI9xx MC failed\n"); |
| 1237 | miro = card->private_data; | 1296 | return -ENOMEM; |
| 1238 | miro->card = card; | 1297 | } |
| 1239 | |||
| 1240 | if ((error = snd_card_miro_aci_detect(card, miro)) < 0) { | ||
| 1241 | snd_card_free(card); | ||
| 1242 | snd_printk(KERN_ERR "unable to detect aci chip\n"); | ||
| 1243 | return -ENODEV; | ||
| 1244 | } | 1298 | } |
| 1245 | 1299 | ||
| 1246 | /* init proc interface */ | 1300 | error = snd_card_miro_aci_detect(card, miro); |
| 1247 | snd_miro_proc_init(miro); | 1301 | if (error < 0) { |
| 1248 | |||
| 1249 | if ((error = snd_card_miro_detect(card, miro)) < 0) { | ||
| 1250 | snd_card_free(card); | 1302 | snd_card_free(card); |
| 1251 | snd_printk(KERN_ERR "unable to detect OPTi9xx chip\n"); | 1303 | snd_printk(KERN_ERR "unable to detect aci chip\n"); |
| 1252 | return -ENODEV; | 1304 | return -ENODEV; |
| 1253 | } | 1305 | } |
| 1254 | 1306 | ||
| 1255 | if (! miro->res_mc_base && | ||
| 1256 | (miro->res_mc_base = request_region(miro->mc_base, miro->mc_base_size, | ||
| 1257 | "miro (OPTi9xx MC)")) == NULL) { | ||
| 1258 | snd_card_free(card); | ||
| 1259 | snd_printk(KERN_ERR "request for OPTI9xx MC failed\n"); | ||
| 1260 | return -ENOMEM; | ||
| 1261 | } | ||
| 1262 | |||
| 1263 | miro->wss_base = port; | 1307 | miro->wss_base = port; |
| 1264 | miro->fm_port = fm_port; | ||
| 1265 | miro->mpu_port = mpu_port; | 1308 | miro->mpu_port = mpu_port; |
| 1266 | miro->irq = irq; | 1309 | miro->irq = irq; |
| 1267 | miro->mpu_irq = mpu_irq; | 1310 | miro->mpu_irq = mpu_irq; |
| 1268 | miro->dma1 = dma1; | 1311 | miro->dma1 = dma1; |
| 1269 | miro->dma2 = dma2; | 1312 | miro->dma2 = dma2; |
| 1270 | 1313 | ||
| 1271 | if (miro->wss_base == SNDRV_AUTO_PORT) { | 1314 | /* init proc interface */ |
| 1272 | if ((miro->wss_base = snd_legacy_find_free_ioport(possible_ports, 4)) < 0) { | 1315 | snd_miro_proc_init(card, miro); |
| 1273 | snd_card_free(card); | ||
| 1274 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); | ||
| 1275 | return -EBUSY; | ||
| 1276 | } | ||
| 1277 | } | ||
| 1278 | |||
| 1279 | if (miro->mpu_port == SNDRV_AUTO_PORT) { | ||
| 1280 | if ((miro->mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { | ||
| 1281 | snd_card_free(card); | ||
| 1282 | snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); | ||
| 1283 | return -EBUSY; | ||
| 1284 | } | ||
| 1285 | } | ||
| 1286 | if (miro->irq == SNDRV_AUTO_IRQ) { | ||
| 1287 | if ((miro->irq = snd_legacy_find_free_irq(possible_irqs)) < 0) { | ||
| 1288 | snd_card_free(card); | ||
| 1289 | snd_printk(KERN_ERR "unable to find a free IRQ\n"); | ||
| 1290 | return -EBUSY; | ||
| 1291 | } | ||
| 1292 | } | ||
| 1293 | if (miro->mpu_irq == SNDRV_AUTO_IRQ) { | ||
| 1294 | if ((miro->mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) { | ||
| 1295 | snd_card_free(card); | ||
| 1296 | snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n"); | ||
| 1297 | return -EBUSY; | ||
| 1298 | } | ||
| 1299 | } | ||
| 1300 | if (miro->dma1 == SNDRV_AUTO_DMA) { | ||
| 1301 | if ((miro->dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) { | ||
| 1302 | snd_card_free(card); | ||
| 1303 | snd_printk(KERN_ERR "unable to find a free DMA1\n"); | ||
| 1304 | return -EBUSY; | ||
| 1305 | } | ||
| 1306 | } | ||
| 1307 | if (miro->dma2 == SNDRV_AUTO_DMA) { | ||
| 1308 | if ((miro->dma2 = snd_legacy_find_free_dma(possible_dma2s[miro->dma1 % 4])) < 0) { | ||
| 1309 | snd_card_free(card); | ||
| 1310 | snd_printk(KERN_ERR "unable to find a free DMA2\n"); | ||
| 1311 | return -EBUSY; | ||
| 1312 | } | ||
| 1313 | } | ||
| 1314 | 1316 | ||
| 1315 | error = snd_miro_configure(miro); | 1317 | error = snd_miro_configure(miro); |
| 1316 | if (error) { | 1318 | if (error) |
| 1317 | snd_card_free(card); | ||
| 1318 | return error; | 1319 | return error; |
| 1319 | } | ||
| 1320 | 1320 | ||
| 1321 | error = snd_wss_create(card, miro->wss_base + 4, -1, | 1321 | error = snd_wss_create(card, miro->wss_base + 4, -1, |
| 1322 | miro->irq, miro->dma1, miro->dma2, | 1322 | miro->irq, miro->dma1, miro->dma2, |
| 1323 | WSS_HW_AD1845, 0, &codec); | 1323 | WSS_HW_DETECT, 0, &codec); |
| 1324 | if (error < 0) { | 1324 | if (error < 0) |
| 1325 | snd_card_free(card); | ||
| 1326 | return error; | 1325 | return error; |
| 1327 | } | ||
| 1328 | 1326 | ||
| 1329 | error = snd_wss_pcm(codec, 0, &pcm); | 1327 | error = snd_wss_pcm(codec, 0, &pcm); |
| 1330 | if (error < 0) { | 1328 | if (error < 0) |
| 1331 | snd_card_free(card); | ||
| 1332 | return error; | 1329 | return error; |
| 1333 | } | 1330 | |
| 1334 | error = snd_wss_mixer(codec); | 1331 | error = snd_wss_mixer(codec); |
| 1335 | if (error < 0) { | 1332 | if (error < 0) |
| 1336 | snd_card_free(card); | ||
| 1337 | return error; | 1333 | return error; |
| 1338 | } | 1334 | |
| 1339 | error = snd_wss_timer(codec, 0, &timer); | 1335 | error = snd_wss_timer(codec, 0, &timer); |
| 1340 | if (error < 0) { | 1336 | if (error < 0) |
| 1341 | snd_card_free(card); | ||
| 1342 | return error; | 1337 | return error; |
| 1343 | } | ||
| 1344 | 1338 | ||
| 1345 | miro->pcm = pcm; | 1339 | miro->pcm = pcm; |
| 1346 | 1340 | ||
| 1347 | if ((error = snd_miro_mixer(miro)) < 0) { | 1341 | error = snd_miro_mixer(card, miro); |
| 1348 | snd_card_free(card); | 1342 | if (error < 0) |
| 1349 | return error; | 1343 | return error; |
| 1350 | } | ||
| 1351 | 1344 | ||
| 1352 | if (miro->aci_vendor == 'm') { | 1345 | if (miro->aci->aci_vendor == 'm') { |
| 1353 | /* It looks like a miro sound card. */ | 1346 | /* It looks like a miro sound card. */ |
| 1354 | switch (miro->aci_product) { | 1347 | switch (miro->aci->aci_product) { |
| 1355 | case 'A': | 1348 | case 'A': |
| 1356 | sprintf(card->shortname, | 1349 | sprintf(card->shortname, |
| 1357 | "miroSOUND PCM1 pro / PCM12"); | 1350 | "miroSOUND PCM1 pro / PCM12"); |
| @@ -1380,30 +1373,131 @@ static int __devinit snd_miro_probe(struct device *devptr, unsigned int n) | |||
| 1380 | card->shortname, miro->name, pcm->name, miro->wss_base + 4, | 1373 | card->shortname, miro->name, pcm->name, miro->wss_base + 4, |
| 1381 | miro->irq, miro->dma1, miro->dma2); | 1374 | miro->irq, miro->dma1, miro->dma2); |
| 1382 | 1375 | ||
| 1383 | if (miro->mpu_port <= 0 || miro->mpu_port == SNDRV_AUTO_PORT) | 1376 | if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) |
| 1384 | rmidi = NULL; | 1377 | rmidi = NULL; |
| 1385 | else | 1378 | else { |
| 1386 | if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, | 1379 | error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, |
| 1387 | miro->mpu_port, 0, miro->mpu_irq, IRQF_DISABLED, | 1380 | mpu_port, 0, miro->mpu_irq, IRQF_DISABLED, |
| 1388 | &rmidi))) | 1381 | &rmidi); |
| 1389 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", miro->mpu_port); | 1382 | if (error < 0) |
| 1383 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", | ||
| 1384 | mpu_port); | ||
| 1385 | } | ||
| 1390 | 1386 | ||
| 1391 | if (miro->fm_port > 0 && miro->fm_port != SNDRV_AUTO_PORT) { | 1387 | if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) { |
| 1392 | struct snd_opl3 *opl3 = NULL; | 1388 | struct snd_opl3 *opl3 = NULL; |
| 1393 | struct snd_opl4 *opl4; | 1389 | struct snd_opl4 *opl4; |
| 1394 | if (snd_opl4_create(card, miro->fm_port, miro->fm_port - 8, | 1390 | |
| 1391 | if (snd_opl4_create(card, fm_port, fm_port - 8, | ||
| 1395 | 2, &opl3, &opl4) < 0) | 1392 | 2, &opl3, &opl4) < 0) |
| 1396 | snd_printk(KERN_WARNING "no OPL4 device at 0x%lx\n", miro->fm_port); | 1393 | snd_printk(KERN_WARNING "no OPL4 device at 0x%lx\n", |
| 1394 | fm_port); | ||
| 1397 | } | 1395 | } |
| 1398 | 1396 | ||
| 1399 | if ((error = snd_set_aci_init_values(miro)) < 0) { | 1397 | error = snd_set_aci_init_values(miro); |
| 1400 | snd_card_free(card); | 1398 | if (error < 0) |
| 1401 | return error; | 1399 | return error; |
| 1400 | |||
| 1401 | return snd_card_register(card); | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | static int __devinit snd_miro_isa_match(struct device *devptr, unsigned int n) | ||
| 1405 | { | ||
| 1406 | #ifdef CONFIG_PNP | ||
| 1407 | if (snd_miro_pnp_is_probed) | ||
| 1408 | return 0; | ||
| 1409 | if (isapnp) | ||
| 1410 | return 0; | ||
| 1411 | #endif | ||
| 1412 | return 1; | ||
| 1413 | } | ||
| 1414 | |||
| 1415 | static int __devinit snd_miro_isa_probe(struct device *devptr, unsigned int n) | ||
| 1416 | { | ||
| 1417 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; | ||
| 1418 | static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1}; | ||
| 1419 | static int possible_irqs[] = {11, 9, 10, 7, -1}; | ||
| 1420 | static int possible_mpu_irqs[] = {10, 5, 9, 7, -1}; | ||
| 1421 | static int possible_dma1s[] = {3, 1, 0, -1}; | ||
| 1422 | static int possible_dma2s[][2] = { {1, -1}, {0, -1}, {-1, -1}, | ||
| 1423 | {0, -1} }; | ||
| 1424 | |||
| 1425 | int error; | ||
| 1426 | struct snd_miro *miro; | ||
| 1427 | struct snd_card *card; | ||
| 1428 | |||
| 1429 | error = snd_card_create(index, id, THIS_MODULE, | ||
| 1430 | sizeof(struct snd_miro), &card); | ||
| 1431 | if (error < 0) | ||
| 1432 | return error; | ||
| 1433 | |||
| 1434 | card->private_free = snd_card_miro_free; | ||
| 1435 | miro = card->private_data; | ||
| 1436 | |||
| 1437 | error = snd_card_miro_detect(card, miro); | ||
| 1438 | if (error < 0) { | ||
| 1439 | snd_card_free(card); | ||
| 1440 | snd_printk(KERN_ERR "unable to detect OPTi9xx chip\n"); | ||
| 1441 | return -ENODEV; | ||
| 1442 | } | ||
| 1443 | |||
| 1444 | if (port == SNDRV_AUTO_PORT) { | ||
| 1445 | port = snd_legacy_find_free_ioport(possible_ports, 4); | ||
| 1446 | if (port < 0) { | ||
| 1447 | snd_card_free(card); | ||
| 1448 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); | ||
| 1449 | return -EBUSY; | ||
| 1450 | } | ||
| 1451 | } | ||
| 1452 | |||
| 1453 | if (mpu_port == SNDRV_AUTO_PORT) { | ||
| 1454 | mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2); | ||
| 1455 | if (mpu_port < 0) { | ||
| 1456 | snd_card_free(card); | ||
| 1457 | snd_printk(KERN_ERR | ||
| 1458 | "unable to find a free MPU401 port\n"); | ||
| 1459 | return -EBUSY; | ||
| 1460 | } | ||
| 1461 | } | ||
| 1462 | |||
| 1463 | if (irq == SNDRV_AUTO_IRQ) { | ||
| 1464 | irq = snd_legacy_find_free_irq(possible_irqs); | ||
| 1465 | if (irq < 0) { | ||
| 1466 | snd_card_free(card); | ||
| 1467 | snd_printk(KERN_ERR "unable to find a free IRQ\n"); | ||
| 1468 | return -EBUSY; | ||
| 1469 | } | ||
| 1470 | } | ||
| 1471 | if (mpu_irq == SNDRV_AUTO_IRQ) { | ||
| 1472 | mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs); | ||
| 1473 | if (mpu_irq < 0) { | ||
| 1474 | snd_card_free(card); | ||
| 1475 | snd_printk(KERN_ERR | ||
| 1476 | "unable to find a free MPU401 IRQ\n"); | ||
| 1477 | return -EBUSY; | ||
| 1478 | } | ||
| 1479 | } | ||
| 1480 | if (dma1 == SNDRV_AUTO_DMA) { | ||
| 1481 | dma1 = snd_legacy_find_free_dma(possible_dma1s); | ||
| 1482 | if (dma1 < 0) { | ||
| 1483 | snd_card_free(card); | ||
| 1484 | snd_printk(KERN_ERR "unable to find a free DMA1\n"); | ||
| 1485 | return -EBUSY; | ||
| 1486 | } | ||
| 1487 | } | ||
| 1488 | if (dma2 == SNDRV_AUTO_DMA) { | ||
| 1489 | dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4]); | ||
| 1490 | if (dma2 < 0) { | ||
| 1491 | snd_card_free(card); | ||
| 1492 | snd_printk(KERN_ERR "unable to find a free DMA2\n"); | ||
| 1493 | return -EBUSY; | ||
| 1494 | } | ||
| 1402 | } | 1495 | } |
| 1403 | 1496 | ||
| 1404 | snd_card_set_dev(card, devptr); | 1497 | snd_card_set_dev(card, devptr); |
| 1405 | 1498 | ||
| 1406 | if ((error = snd_card_register(card))) { | 1499 | error = snd_miro_probe(card); |
| 1500 | if (error < 0) { | ||
| 1407 | snd_card_free(card); | 1501 | snd_card_free(card); |
| 1408 | return error; | 1502 | return error; |
| 1409 | } | 1503 | } |
| @@ -1412,7 +1506,8 @@ static int __devinit snd_miro_probe(struct device *devptr, unsigned int n) | |||
| 1412 | return 0; | 1506 | return 0; |
| 1413 | } | 1507 | } |
| 1414 | 1508 | ||
| 1415 | static int __devexit snd_miro_remove(struct device *devptr, unsigned int dev) | 1509 | static int __devexit snd_miro_isa_remove(struct device *devptr, |
| 1510 | unsigned int dev) | ||
| 1416 | { | 1511 | { |
| 1417 | snd_card_free(dev_get_drvdata(devptr)); | 1512 | snd_card_free(dev_get_drvdata(devptr)); |
| 1418 | dev_set_drvdata(devptr, NULL); | 1513 | dev_set_drvdata(devptr, NULL); |
| @@ -1422,23 +1517,164 @@ static int __devexit snd_miro_remove(struct device *devptr, unsigned int dev) | |||
| 1422 | #define DEV_NAME "miro" | 1517 | #define DEV_NAME "miro" |
| 1423 | 1518 | ||
| 1424 | static struct isa_driver snd_miro_driver = { | 1519 | static struct isa_driver snd_miro_driver = { |
| 1425 | .match = snd_miro_match, | 1520 | .match = snd_miro_isa_match, |
| 1426 | .probe = snd_miro_probe, | 1521 | .probe = snd_miro_isa_probe, |
| 1427 | .remove = __devexit_p(snd_miro_remove), | 1522 | .remove = __devexit_p(snd_miro_isa_remove), |
| 1428 | /* FIXME: suspend/resume */ | 1523 | /* FIXME: suspend/resume */ |
| 1429 | .driver = { | 1524 | .driver = { |
| 1430 | .name = DEV_NAME | 1525 | .name = DEV_NAME |
| 1431 | }, | 1526 | }, |
| 1432 | }; | 1527 | }; |
| 1433 | 1528 | ||
| 1529 | #ifdef CONFIG_PNP | ||
| 1530 | |||
| 1531 | static int __devinit snd_card_miro_pnp(struct snd_miro *chip, | ||
| 1532 | struct pnp_card_link *card, | ||
| 1533 | const struct pnp_card_device_id *pid) | ||
| 1534 | { | ||
| 1535 | struct pnp_dev *pdev; | ||
| 1536 | int err; | ||
| 1537 | struct pnp_dev *devmpu; | ||
| 1538 | struct pnp_dev *devmc; | ||
| 1539 | |||
| 1540 | pdev = pnp_request_card_device(card, pid->devs[0].id, NULL); | ||
| 1541 | if (pdev == NULL) | ||
| 1542 | return -EBUSY; | ||
| 1543 | |||
| 1544 | devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); | ||
| 1545 | if (devmpu == NULL) | ||
| 1546 | return -EBUSY; | ||
| 1547 | |||
| 1548 | devmc = pnp_request_card_device(card, pid->devs[2].id, NULL); | ||
| 1549 | if (devmc == NULL) | ||
| 1550 | return -EBUSY; | ||
| 1551 | |||
| 1552 | err = pnp_activate_dev(pdev); | ||
| 1553 | if (err < 0) { | ||
| 1554 | snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err); | ||
| 1555 | return err; | ||
| 1556 | } | ||
| 1557 | |||
| 1558 | err = pnp_activate_dev(devmc); | ||
| 1559 | if (err < 0) { | ||
| 1560 | snd_printk(KERN_ERR "MC pnp configure failure: %d\n", | ||
| 1561 | err); | ||
| 1562 | return err; | ||
| 1563 | } | ||
| 1564 | |||
| 1565 | port = pnp_port_start(pdev, 1); | ||
| 1566 | fm_port = pnp_port_start(pdev, 2) + 8; | ||
| 1567 | |||
| 1568 | /* | ||
| 1569 | * The MC(0) is never accessed and the miroSOUND PCM20 card does not | ||
| 1570 | * include it in the PnP resource range. OPTI93x include it. | ||
| 1571 | */ | ||
| 1572 | chip->mc_base = pnp_port_start(devmc, 0) - 1; | ||
| 1573 | chip->mc_base_size = pnp_port_len(devmc, 0) + 1; | ||
| 1574 | |||
| 1575 | irq = pnp_irq(pdev, 0); | ||
| 1576 | dma1 = pnp_dma(pdev, 0); | ||
| 1577 | dma2 = pnp_dma(pdev, 1); | ||
| 1578 | |||
| 1579 | if (mpu_port > 0) { | ||
| 1580 | err = pnp_activate_dev(devmpu); | ||
| 1581 | if (err < 0) { | ||
| 1582 | snd_printk(KERN_ERR "MPU401 pnp configure failure\n"); | ||
| 1583 | mpu_port = -1; | ||
| 1584 | return err; | ||
| 1585 | } | ||
| 1586 | mpu_port = pnp_port_start(devmpu, 0); | ||
| 1587 | mpu_irq = pnp_irq(devmpu, 0); | ||
| 1588 | } | ||
| 1589 | return 0; | ||
| 1590 | } | ||
| 1591 | |||
| 1592 | static int __devinit snd_miro_pnp_probe(struct pnp_card_link *pcard, | ||
| 1593 | const struct pnp_card_device_id *pid) | ||
| 1594 | { | ||
| 1595 | struct snd_card *card; | ||
| 1596 | int err; | ||
| 1597 | struct snd_miro *miro; | ||
| 1598 | |||
| 1599 | if (snd_miro_pnp_is_probed) | ||
| 1600 | return -EBUSY; | ||
| 1601 | if (!isapnp) | ||
| 1602 | return -ENODEV; | ||
| 1603 | err = snd_card_create(index, id, THIS_MODULE, | ||
| 1604 | sizeof(struct snd_miro), &card); | ||
| 1605 | if (err < 0) | ||
| 1606 | return err; | ||
| 1607 | |||
| 1608 | card->private_free = snd_card_miro_free; | ||
| 1609 | miro = card->private_data; | ||
| 1610 | |||
| 1611 | err = snd_card_miro_pnp(miro, pcard, pid); | ||
| 1612 | if (err) { | ||
| 1613 | snd_card_free(card); | ||
| 1614 | return err; | ||
| 1615 | } | ||
| 1616 | |||
| 1617 | /* only miroSOUND PCM20 and PCM12 == OPTi924 */ | ||
| 1618 | err = snd_miro_init(miro, OPTi9XX_HW_82C924); | ||
| 1619 | if (err) { | ||
| 1620 | snd_card_free(card); | ||
| 1621 | return err; | ||
| 1622 | } | ||
| 1623 | |||
| 1624 | err = snd_miro_opti_check(miro); | ||
| 1625 | if (err) { | ||
| 1626 | snd_printk(KERN_ERR "OPTI chip not found\n"); | ||
| 1627 | snd_card_free(card); | ||
| 1628 | return err; | ||
| 1629 | } | ||
| 1630 | |||
| 1631 | snd_card_set_dev(card, &pcard->card->dev); | ||
| 1632 | err = snd_miro_probe(card); | ||
| 1633 | if (err < 0) { | ||
| 1634 | snd_card_free(card); | ||
| 1635 | return err; | ||
| 1636 | } | ||
| 1637 | pnp_set_card_drvdata(pcard, card); | ||
| 1638 | snd_miro_pnp_is_probed = 1; | ||
| 1639 | return 0; | ||
| 1640 | } | ||
| 1641 | |||
| 1642 | static void __devexit snd_miro_pnp_remove(struct pnp_card_link * pcard) | ||
| 1643 | { | ||
| 1644 | snd_card_free(pnp_get_card_drvdata(pcard)); | ||
| 1645 | pnp_set_card_drvdata(pcard, NULL); | ||
| 1646 | snd_miro_pnp_is_probed = 0; | ||
| 1647 | } | ||
| 1648 | |||
| 1649 | static struct pnp_card_driver miro_pnpc_driver = { | ||
| 1650 | .flags = PNP_DRIVER_RES_DISABLE, | ||
| 1651 | .name = "miro", | ||
| 1652 | .id_table = snd_miro_pnpids, | ||
| 1653 | .probe = snd_miro_pnp_probe, | ||
| 1654 | .remove = __devexit_p(snd_miro_pnp_remove), | ||
| 1655 | }; | ||
| 1656 | #endif | ||
| 1657 | |||
| 1434 | static int __init alsa_card_miro_init(void) | 1658 | static int __init alsa_card_miro_init(void) |
| 1435 | { | 1659 | { |
| 1660 | #ifdef CONFIG_PNP | ||
| 1661 | pnp_register_card_driver(&miro_pnpc_driver); | ||
| 1662 | if (snd_miro_pnp_is_probed) | ||
| 1663 | return 0; | ||
| 1664 | pnp_unregister_card_driver(&miro_pnpc_driver); | ||
| 1665 | #endif | ||
| 1436 | return isa_register_driver(&snd_miro_driver, 1); | 1666 | return isa_register_driver(&snd_miro_driver, 1); |
| 1437 | } | 1667 | } |
| 1438 | 1668 | ||
| 1439 | static void __exit alsa_card_miro_exit(void) | 1669 | static void __exit alsa_card_miro_exit(void) |
| 1440 | { | 1670 | { |
| 1441 | isa_unregister_driver(&snd_miro_driver); | 1671 | if (!snd_miro_pnp_is_probed) { |
| 1672 | isa_unregister_driver(&snd_miro_driver); | ||
| 1673 | return; | ||
| 1674 | } | ||
| 1675 | #ifdef CONFIG_PNP | ||
| 1676 | pnp_unregister_card_driver(&miro_pnpc_driver); | ||
| 1677 | #endif | ||
| 1442 | } | 1678 | } |
| 1443 | 1679 | ||
| 1444 | module_init(alsa_card_miro_init) | 1680 | module_init(alsa_card_miro_init) |
diff --git a/sound/isa/opti9xx/miro.h b/sound/isa/opti9xx/miro.h deleted file mode 100644 index 6e1385b8e07e..000000000000 --- a/sound/isa/opti9xx/miro.h +++ /dev/null | |||
| @@ -1,73 +0,0 @@ | |||
| 1 | #ifndef _MIRO_H_ | ||
| 2 | #define _MIRO_H_ | ||
| 3 | |||
| 4 | #define ACI_REG_COMMAND 0 /* write register offset */ | ||
| 5 | #define ACI_REG_STATUS 1 /* read register offset */ | ||
| 6 | #define ACI_REG_BUSY 2 /* busy register offset */ | ||
| 7 | #define ACI_REG_RDS 2 /* PCM20: RDS register offset */ | ||
| 8 | #define ACI_MINTIME 500 /* ACI time out limit */ | ||
| 9 | |||
| 10 | #define ACI_SET_MUTE 0x0d | ||
| 11 | #define ACI_SET_POWERAMP 0x0f | ||
| 12 | #define ACI_SET_TUNERMUTE 0xa3 | ||
| 13 | #define ACI_SET_TUNERMONO 0xa4 | ||
| 14 | #define ACI_SET_IDE 0xd0 | ||
| 15 | #define ACI_SET_WSS 0xd1 | ||
| 16 | #define ACI_SET_SOLOMODE 0xd2 | ||
| 17 | #define ACI_SET_PREAMP 0x03 | ||
| 18 | #define ACI_GET_PREAMP 0x21 | ||
| 19 | #define ACI_WRITE_TUNE 0xa7 | ||
| 20 | #define ACI_READ_TUNERSTEREO 0xa8 | ||
| 21 | #define ACI_READ_TUNERSTATION 0xa9 | ||
| 22 | #define ACI_READ_VERSION 0xf1 | ||
| 23 | #define ACI_READ_IDCODE 0xf2 | ||
| 24 | #define ACI_INIT 0xff | ||
| 25 | #define ACI_STATUS 0xf0 | ||
| 26 | #define ACI_S_GENERAL 0x00 | ||
| 27 | #define ACI_ERROR_OP 0xdf | ||
| 28 | |||
| 29 | /* ACI Mixer */ | ||
| 30 | |||
| 31 | /* These are the values for the right channel GET registers. | ||
| 32 | Add an offset of 0x01 for the left channel register. | ||
| 33 | (left=right+0x01) */ | ||
| 34 | |||
| 35 | #define ACI_GET_MASTER 0x03 | ||
| 36 | #define ACI_GET_MIC 0x05 | ||
| 37 | #define ACI_GET_LINE 0x07 | ||
| 38 | #define ACI_GET_CD 0x09 | ||
| 39 | #define ACI_GET_SYNTH 0x0b | ||
| 40 | #define ACI_GET_PCM 0x0d | ||
| 41 | #define ACI_GET_LINE1 0x10 /* Radio on PCM20 */ | ||
| 42 | #define ACI_GET_LINE2 0x12 | ||
| 43 | |||
| 44 | #define ACI_GET_EQ1 0x22 /* from Bass ... */ | ||
| 45 | #define ACI_GET_EQ2 0x24 | ||
| 46 | #define ACI_GET_EQ3 0x26 | ||
| 47 | #define ACI_GET_EQ4 0x28 | ||
| 48 | #define ACI_GET_EQ5 0x2a | ||
| 49 | #define ACI_GET_EQ6 0x2c | ||
| 50 | #define ACI_GET_EQ7 0x2e /* ... to Treble */ | ||
| 51 | |||
| 52 | /* And these are the values for the right channel SET registers. | ||
| 53 | For left channel access you have to add an offset of 0x08. | ||
| 54 | MASTER is an exception, which needs an offset of 0x01 */ | ||
| 55 | |||
| 56 | #define ACI_SET_MASTER 0x00 | ||
| 57 | #define ACI_SET_MIC 0x30 | ||
| 58 | #define ACI_SET_LINE 0x31 | ||
| 59 | #define ACI_SET_CD 0x34 | ||
| 60 | #define ACI_SET_SYNTH 0x33 | ||
| 61 | #define ACI_SET_PCM 0x32 | ||
| 62 | #define ACI_SET_LINE1 0x35 /* Radio on PCM20 */ | ||
| 63 | #define ACI_SET_LINE2 0x36 | ||
| 64 | |||
| 65 | #define ACI_SET_EQ1 0x40 /* from Bass ... */ | ||
| 66 | #define ACI_SET_EQ2 0x41 | ||
| 67 | #define ACI_SET_EQ3 0x42 | ||
| 68 | #define ACI_SET_EQ4 0x43 | ||
| 69 | #define ACI_SET_EQ5 0x44 | ||
| 70 | #define ACI_SET_EQ6 0x45 | ||
| 71 | #define ACI_SET_EQ7 0x46 /* ... to Treble */ | ||
| 72 | |||
| 73 | #endif /* _MIRO_H_ */ | ||
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 5cd555325b9d..c35dc68930dc 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c | |||
| @@ -27,12 +27,12 @@ | |||
| 27 | #include <linux/err.h> | 27 | #include <linux/err.h> |
| 28 | #include <linux/isa.h> | 28 | #include <linux/isa.h> |
| 29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
| 30 | #include <linux/slab.h> | ||
| 31 | #include <linux/pnp.h> | 30 | #include <linux/pnp.h> |
| 32 | #include <linux/moduleparam.h> | 31 | #include <linux/moduleparam.h> |
| 33 | #include <asm/io.h> | 32 | #include <asm/io.h> |
| 34 | #include <asm/dma.h> | 33 | #include <asm/dma.h> |
| 35 | #include <sound/core.h> | 34 | #include <sound/core.h> |
| 35 | #include <sound/tlv.h> | ||
| 36 | #include <sound/wss.h> | 36 | #include <sound/wss.h> |
| 37 | #include <sound/mpu401.h> | 37 | #include <sound/mpu401.h> |
| 38 | #include <sound/opl3.h> | 38 | #include <sound/opl3.h> |
| @@ -135,6 +135,8 @@ struct snd_opti9xx { | |||
| 135 | unsigned long mc_base_size; | 135 | unsigned long mc_base_size; |
| 136 | #ifdef OPTi93X | 136 | #ifdef OPTi93X |
| 137 | unsigned long mc_indir_index; | 137 | unsigned long mc_indir_index; |
| 138 | unsigned long mc_indir_size; | ||
| 139 | struct resource *res_mc_indir; | ||
| 138 | struct snd_wss *codec; | 140 | struct snd_wss *codec; |
| 139 | #endif /* OPTi93X */ | 141 | #endif /* OPTi93X */ |
| 140 | unsigned long pwd_reg; | 142 | unsigned long pwd_reg; |
| @@ -143,18 +145,6 @@ struct snd_opti9xx { | |||
| 143 | 145 | ||
| 144 | long wss_base; | 146 | long wss_base; |
| 145 | int irq; | 147 | 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 */ | ||
| 158 | }; | 148 | }; |
| 159 | 149 | ||
| 160 | static int snd_opti9xx_pnp_is_probed; | 150 | static int snd_opti9xx_pnp_is_probed; |
| @@ -164,12 +154,17 @@ static int snd_opti9xx_pnp_is_probed; | |||
| 164 | static struct pnp_card_device_id snd_opti9xx_pnpids[] = { | 154 | static struct pnp_card_device_id snd_opti9xx_pnpids[] = { |
| 165 | #ifndef OPTi93X | 155 | #ifndef OPTi93X |
| 166 | /* OPTi 82C924 */ | 156 | /* OPTi 82C924 */ |
| 167 | { .id = "OPT0924", .devs = { { "OPT0000" }, { "OPT0002" } }, .driver_data = 0x0924 }, | 157 | { .id = "OPT0924", |
| 158 | .devs = { { "OPT0000" }, { "OPT0002" }, { "OPT0005" } }, | ||
| 159 | .driver_data = 0x0924 }, | ||
| 168 | /* OPTi 82C925 */ | 160 | /* OPTi 82C925 */ |
| 169 | { .id = "OPT0925", .devs = { { "OPT9250" }, { "OPT0002" } }, .driver_data = 0x0925 }, | 161 | { .id = "OPT0925", |
| 162 | .devs = { { "OPT9250" }, { "OPT0002" }, { "OPT0005" } }, | ||
| 163 | .driver_data = 0x0925 }, | ||
| 170 | #else | 164 | #else |
| 171 | /* OPTi 82C931/3 */ | 165 | /* OPTi 82C931/3 */ |
| 172 | { .id = "OPT0931", .devs = { { "OPT9310" }, { "OPT0002" } }, .driver_data = 0x0931 }, | 166 | { .id = "OPT0931", .devs = { { "OPT9310" }, { "OPT0002" } }, |
| 167 | .driver_data = 0x0931 }, | ||
| 173 | #endif /* OPTi93X */ | 168 | #endif /* OPTi93X */ |
| 174 | { .id = "" } | 169 | { .id = "" } |
| 175 | }; | 170 | }; |
| @@ -185,7 +180,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids); | |||
| 185 | #endif | 180 | #endif |
| 186 | 181 | ||
| 187 | static char * snd_opti9xx_names[] = { | 182 | static char * snd_opti9xx_names[] = { |
| 188 | "unkown", | 183 | "unknown", |
| 189 | "82C928", "82C929", | 184 | "82C928", "82C929", |
| 190 | "82C924", "82C925", | 185 | "82C924", "82C925", |
| 191 | "82C930", "82C931", "82C933" | 186 | "82C930", "82C931", "82C933" |
| @@ -212,30 +207,35 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, | |||
| 212 | chip->hardware = hardware; | 207 | chip->hardware = hardware; |
| 213 | strcpy(chip->name, snd_opti9xx_names[hardware]); | 208 | strcpy(chip->name, snd_opti9xx_names[hardware]); |
| 214 | 209 | ||
| 215 | chip->mc_base_size = opti9xx_mc_size[hardware]; | ||
| 216 | |||
| 217 | spin_lock_init(&chip->lock); | 210 | spin_lock_init(&chip->lock); |
| 218 | 211 | ||
| 219 | chip->wss_base = -1; | ||
| 220 | chip->irq = -1; | 212 | chip->irq = -1; |
| 221 | chip->dma1 = -1; | 213 | |
| 222 | chip->dma2 = -1; | 214 | #ifndef OPTi93X |
| 223 | chip->fm_port = -1; | 215 | #ifdef CONFIG_PNP |
| 224 | chip->mpu_port = -1; | 216 | if (isapnp && chip->mc_base) |
| 225 | chip->mpu_irq = -1; | 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 | ||
| 226 | 228 | ||
| 227 | switch (hardware) { | 229 | switch (hardware) { |
| 228 | #ifndef OPTi93X | 230 | #ifndef OPTi93X |
| 229 | case OPTi9XX_HW_82C928: | 231 | case OPTi9XX_HW_82C928: |
| 230 | case OPTi9XX_HW_82C929: | 232 | case OPTi9XX_HW_82C929: |
| 231 | chip->mc_base = 0xf8c; | ||
| 232 | chip->password = (hardware == OPTi9XX_HW_82C928) ? 0xe2 : 0xe3; | 233 | chip->password = (hardware == OPTi9XX_HW_82C928) ? 0xe2 : 0xe3; |
| 233 | chip->pwd_reg = 3; | 234 | chip->pwd_reg = 3; |
| 234 | break; | 235 | break; |
| 235 | 236 | ||
| 236 | case OPTi9XX_HW_82C924: | 237 | case OPTi9XX_HW_82C924: |
| 237 | case OPTi9XX_HW_82C925: | 238 | case OPTi9XX_HW_82C925: |
| 238 | chip->mc_base = 0xf8c; | ||
| 239 | chip->password = 0xe5; | 239 | chip->password = 0xe5; |
| 240 | chip->pwd_reg = 3; | 240 | chip->pwd_reg = 3; |
| 241 | break; | 241 | break; |
| @@ -245,7 +245,10 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, | |||
| 245 | case OPTi9XX_HW_82C931: | 245 | case OPTi9XX_HW_82C931: |
| 246 | case OPTi9XX_HW_82C933: | 246 | case OPTi9XX_HW_82C933: |
| 247 | chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d; | 247 | 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 | } | ||
| 249 | chip->password = 0xe4; | 252 | chip->password = 0xe4; |
| 250 | chip->pwd_reg = 0; | 253 | chip->pwd_reg = 0; |
| 251 | break; | 254 | break; |
| @@ -300,7 +303,7 @@ static unsigned char snd_opti9xx_read(struct snd_opti9xx *chip, | |||
| 300 | spin_unlock_irqrestore(&chip->lock, flags); | 303 | spin_unlock_irqrestore(&chip->lock, flags); |
| 301 | return retval; | 304 | return retval; |
| 302 | } | 305 | } |
| 303 | 306 | ||
| 304 | static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, | 307 | static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, |
| 305 | unsigned char value) | 308 | unsigned char value) |
| 306 | { | 309 | { |
| @@ -348,7 +351,10 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, | |||
| 348 | (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) | 351 | (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) |
| 349 | 352 | ||
| 350 | 353 | ||
| 351 | static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) | 354 | static 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) | ||
| 352 | { | 358 | { |
| 353 | unsigned char wss_base_bits; | 359 | unsigned char wss_base_bits; |
| 354 | unsigned char irq_bits; | 360 | unsigned char irq_bits; |
| @@ -359,16 +365,23 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) | |||
| 359 | switch (chip->hardware) { | 365 | switch (chip->hardware) { |
| 360 | #ifndef OPTi93X | 366 | #ifndef OPTi93X |
| 361 | case OPTi9XX_HW_82C924: | 367 | case OPTi9XX_HW_82C924: |
| 368 | /* opti 929 mode (?), OPL3 clock output, audio enable */ | ||
| 362 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0xf0, 0xfc); | 369 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0xf0, 0xfc); |
| 370 | /* enable wave audio */ | ||
| 363 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); | 371 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); |
| 364 | 372 | ||
| 365 | case OPTi9XX_HW_82C925: | 373 | case OPTi9XX_HW_82C925: |
| 374 | /* enable WSS mode */ | ||
| 366 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); | 375 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); |
| 376 | /* OPL3 FM synthesis */ | ||
| 367 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x00, 0x20); | 377 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x00, 0x20); |
| 378 | /* disable Sound Blaster IRQ and DMA */ | ||
| 368 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); | 379 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff); |
| 369 | #ifdef CS4231 | 380 | #ifdef CS4231 |
| 381 | /* cs4231/4248 fix enabled */ | ||
| 370 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); | 382 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); |
| 371 | #else | 383 | #else |
| 384 | /* cs4231/4248 fix disabled */ | ||
| 372 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x00, 0x02); | 385 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x00, 0x02); |
| 373 | #endif /* CS4231 */ | 386 | #endif /* CS4231 */ |
| 374 | break; | 387 | break; |
| @@ -416,28 +429,32 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) | |||
| 416 | return -EINVAL; | 429 | return -EINVAL; |
| 417 | } | 430 | } |
| 418 | 431 | ||
| 419 | switch (chip->wss_base) { | 432 | /* PnP resource says it decodes only 10 bits of address */ |
| 420 | case 0x530: | 433 | switch (port & 0x3ff) { |
| 434 | case 0x130: | ||
| 435 | chip->wss_base = 0x530; | ||
| 421 | wss_base_bits = 0x00; | 436 | wss_base_bits = 0x00; |
| 422 | break; | 437 | break; |
| 423 | case 0x604: | 438 | case 0x204: |
| 439 | chip->wss_base = 0x604; | ||
| 424 | wss_base_bits = 0x03; | 440 | wss_base_bits = 0x03; |
| 425 | break; | 441 | break; |
| 426 | case 0xe80: | 442 | case 0x280: |
| 443 | chip->wss_base = 0xe80; | ||
| 427 | wss_base_bits = 0x01; | 444 | wss_base_bits = 0x01; |
| 428 | break; | 445 | break; |
| 429 | case 0xf40: | 446 | case 0x340: |
| 447 | chip->wss_base = 0xf40; | ||
| 430 | wss_base_bits = 0x02; | 448 | wss_base_bits = 0x02; |
| 431 | break; | 449 | break; |
| 432 | default: | 450 | default: |
| 433 | snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", | 451 | snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", port); |
| 434 | chip->wss_base); | ||
| 435 | goto __skip_base; | 452 | goto __skip_base; |
| 436 | } | 453 | } |
| 437 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); | 454 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); |
| 438 | 455 | ||
| 439 | __skip_base: | 456 | __skip_base: |
| 440 | switch (chip->irq) { | 457 | switch (irq) { |
| 441 | //#ifdef OPTi93X | 458 | //#ifdef OPTi93X |
| 442 | case 5: | 459 | case 5: |
| 443 | irq_bits = 0x05; | 460 | irq_bits = 0x05; |
| @@ -456,11 +473,11 @@ __skip_base: | |||
| 456 | irq_bits = 0x04; | 473 | irq_bits = 0x04; |
| 457 | break; | 474 | break; |
| 458 | default: | 475 | 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); |
| 460 | goto __skip_resources; | 477 | goto __skip_resources; |
| 461 | } | 478 | } |
| 462 | 479 | ||
| 463 | switch (chip->dma1) { | 480 | switch (dma1) { |
| 464 | case 0: | 481 | case 0: |
| 465 | dma_bits = 0x01; | 482 | dma_bits = 0x01; |
| 466 | break; | 483 | break; |
| @@ -471,24 +488,22 @@ __skip_base: | |||
| 471 | dma_bits = 0x03; | 488 | dma_bits = 0x03; |
| 472 | break; | 489 | break; |
| 473 | default: | 490 | default: |
| 474 | snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", | 491 | snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", dma1); |
| 475 | chip->dma1); | ||
| 476 | goto __skip_resources; | 492 | goto __skip_resources; |
| 477 | } | 493 | } |
| 478 | 494 | ||
| 479 | #if defined(CS4231) || defined(OPTi93X) | 495 | #if defined(CS4231) || defined(OPTi93X) |
| 480 | if (chip->dma1 == chip->dma2) { | 496 | if (dma1 == dma2) { |
| 481 | snd_printk(KERN_ERR "don't want to share dmas\n"); | 497 | snd_printk(KERN_ERR "don't want to share dmas\n"); |
| 482 | return -EBUSY; | 498 | return -EBUSY; |
| 483 | } | 499 | } |
| 484 | 500 | ||
| 485 | switch (chip->dma2) { | 501 | switch (dma2) { |
| 486 | case 0: | 502 | case 0: |
| 487 | case 1: | 503 | case 1: |
| 488 | break; | 504 | break; |
| 489 | default: | 505 | default: |
| 490 | snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", | 506 | snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", dma2); |
| 491 | chip->dma2); | ||
| 492 | goto __skip_resources; | 507 | goto __skip_resources; |
| 493 | } | 508 | } |
| 494 | dma_bits |= 0x04; | 509 | dma_bits |= 0x04; |
| @@ -502,7 +517,7 @@ __skip_base: | |||
| 502 | 517 | ||
| 503 | __skip_resources: | 518 | __skip_resources: |
| 504 | if (chip->hardware > OPTi9XX_HW_82C928) { | 519 | if (chip->hardware > OPTi9XX_HW_82C928) { |
| 505 | switch (chip->mpu_port) { | 520 | switch (mpu_port) { |
| 506 | case 0: | 521 | case 0: |
| 507 | case -1: | 522 | case -1: |
| 508 | break; | 523 | break; |
| @@ -520,12 +535,11 @@ __skip_resources: | |||
| 520 | break; | 535 | break; |
| 521 | default: | 536 | default: |
| 522 | snd_printk(KERN_WARNING | 537 | snd_printk(KERN_WARNING |
| 523 | "MPU-401 port 0x%lx not valid\n", | 538 | "MPU-401 port 0x%lx not valid\n", mpu_port); |
| 524 | chip->mpu_port); | ||
| 525 | goto __skip_mpu; | 539 | goto __skip_mpu; |
| 526 | } | 540 | } |
| 527 | 541 | ||
| 528 | switch (chip->mpu_irq) { | 542 | switch (mpu_irq) { |
| 529 | case 5: | 543 | case 5: |
| 530 | mpu_irq_bits = 0x02; | 544 | mpu_irq_bits = 0x02; |
| 531 | break; | 545 | break; |
| @@ -540,12 +554,12 @@ __skip_resources: | |||
| 540 | break; | 554 | break; |
| 541 | default: | 555 | default: |
| 542 | snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n", | 556 | snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n", |
| 543 | chip->mpu_irq); | 557 | mpu_irq); |
| 544 | goto __skip_mpu; | 558 | goto __skip_mpu; |
| 545 | } | 559 | } |
| 546 | 560 | ||
| 547 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), | 561 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), |
| 548 | (chip->mpu_port <= 0) ? 0x00 : | 562 | (mpu_port <= 0) ? 0x00 : |
| 549 | 0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3, | 563 | 0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3, |
| 550 | 0xf8); | 564 | 0xf8); |
| 551 | } | 565 | } |
| @@ -556,12 +570,102 @@ __skip_mpu: | |||
| 556 | 570 | ||
| 557 | #ifdef OPTi93X | 571 | #ifdef OPTi93X |
| 558 | 572 | ||
| 573 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_step, -9300, 300, 0); | ||
| 574 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0); | ||
| 575 | static const DECLARE_TLV_DB_SCALE(db_scale_4bit_12db_max, -3300, 300, 0); | ||
| 576 | |||
| 577 | static struct snd_kcontrol_new snd_opti93x_controls[] = { | ||
| 578 | WSS_DOUBLE("Master Playback Switch", 0, | ||
| 579 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), | ||
| 580 | WSS_DOUBLE_TLV("Master Playback Volume", 0, | ||
| 581 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1, | ||
| 582 | db_scale_5bit_3db_step), | ||
| 583 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, | ||
| 584 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1, | ||
| 585 | db_scale_5bit), | ||
| 586 | WSS_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), | ||
| 589 | WSS_DOUBLE("Line Playback Switch", 0, | ||
| 590 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | ||
| 591 | WSS_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), | ||
| 594 | WSS_DOUBLE("Mic Playback Switch", 0, | ||
| 595 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1), | ||
| 596 | WSS_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), | ||
| 599 | WSS_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), | ||
| 602 | WSS_DOUBLE("Aux Playback Switch", 0, | ||
| 603 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1), | ||
| 604 | WSS_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 | |||
| 609 | static 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 | |||
| 559 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) | 660 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) |
| 560 | { | 661 | { |
| 561 | struct snd_wss *codec = dev_id; | 662 | struct snd_opti9xx *chip = dev_id; |
| 562 | struct snd_opti9xx *chip = codec->card->private_data; | 663 | struct snd_wss *codec = chip->codec; |
| 563 | unsigned char status; | 664 | unsigned char status; |
| 564 | 665 | ||
| 666 | if (!codec) | ||
| 667 | return IRQ_HANDLED; | ||
| 668 | |||
| 565 | status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11)); | 669 | status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11)); |
| 566 | if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream) | 670 | if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream) |
| 567 | snd_pcm_period_elapsed(codec->playback_substream); | 671 | snd_pcm_period_elapsed(codec->playback_substream); |
| @@ -575,57 +679,69 @@ static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) | |||
| 575 | 679 | ||
| 576 | #endif /* OPTi93X */ | 680 | #endif /* OPTi93X */ |
| 577 | 681 | ||
| 578 | static int __devinit snd_card_opti9xx_detect(struct snd_card *card, | 682 | static int __devinit snd_opti9xx_read_check(struct snd_opti9xx *chip) |
| 579 | struct snd_opti9xx *chip) | ||
| 580 | { | 683 | { |
| 581 | int i, err; | 684 | unsigned char value; |
| 685 | #ifdef OPTi93X | ||
| 686 | unsigned long flags; | ||
| 687 | #endif | ||
| 582 | 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; | ||
| 583 | #ifndef OPTi93X | 693 | #ifndef OPTi93X |
| 584 | for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) { | 694 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)); |
| 585 | unsigned char value; | 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; | ||
| 586 | 704 | ||
| 587 | if ((err = snd_opti9xx_init(chip, i)) < 0) | 705 | spin_lock_irqsave(&chip->lock, flags); |
| 588 | return err; | 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); | ||
| 589 | 709 | ||
| 590 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) | 710 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)); |
| 591 | continue; | 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; | ||
| 592 | 714 | ||
| 593 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)); | 715 | release_and_free_resource(chip->res_mc_indir); |
| 594 | if ((value != 0xff) && (value != inb(chip->mc_base + 1))) | 716 | chip->res_mc_indir = NULL; |
| 595 | if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) | 717 | #endif /* OPTi93X */ |
| 596 | return 1; | 718 | release_and_free_resource(chip->res_mc_base); |
| 719 | chip->res_mc_base = NULL; | ||
| 597 | 720 | ||
| 598 | release_and_free_resource(chip->res_mc_base); | 721 | return -ENODEV; |
| 599 | chip->res_mc_base = NULL; | 722 | } |
| 600 | 723 | ||
| 601 | } | 724 | static int __devinit snd_card_opti9xx_detect(struct snd_card *card, |
| 602 | #else /* OPTi93X */ | 725 | struct snd_opti9xx *chip) |
| 603 | for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) { | 726 | { |
| 604 | unsigned long flags; | 727 | int i, err; |
| 605 | unsigned char value; | ||
| 606 | 728 | ||
| 607 | if ((err = snd_opti9xx_init(chip, i)) < 0) | 729 | #ifndef OPTi93X |
| 730 | for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) { | ||
| 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) | ||
| 608 | return err; | 736 | return err; |
| 609 | 737 | ||
| 610 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) | 738 | err = snd_opti9xx_read_check(chip); |
| 611 | continue; | 739 | if (err == 0) |
| 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) | ||
| 622 | return 1; | 740 | return 1; |
| 623 | 741 | #ifdef OPTi93X | |
| 624 | release_and_free_resource(chip->res_mc_base); | 742 | chip->mc_indir_index = 0; |
| 625 | chip->res_mc_base = NULL; | 743 | #endif |
| 626 | } | 744 | } |
| 627 | #endif /* OPTi93X */ | ||
| 628 | |||
| 629 | return -ENODEV; | 745 | return -ENODEV; |
| 630 | } | 746 | } |
| 631 | 747 | ||
| @@ -636,15 +752,15 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
| 636 | { | 752 | { |
| 637 | struct pnp_dev *pdev; | 753 | struct pnp_dev *pdev; |
| 638 | int err; | 754 | int err; |
| 755 | struct pnp_dev *devmpu; | ||
| 756 | #ifndef OPTi93X | ||
| 757 | struct pnp_dev *devmc; | ||
| 758 | #endif | ||
| 639 | 759 | ||
| 640 | chip->dev = pnp_request_card_device(card, pid->devs[0].id, NULL); | 760 | pdev = pnp_request_card_device(card, pid->devs[0].id, NULL); |
| 641 | if (chip->dev == NULL) | 761 | if (pdev == NULL) |
| 642 | return -EBUSY; | 762 | return -EBUSY; |
| 643 | 763 | ||
| 644 | chip->devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); | ||
| 645 | |||
| 646 | pdev = chip->dev; | ||
| 647 | |||
| 648 | err = pnp_activate_dev(pdev); | 764 | err = pnp_activate_dev(pdev); |
| 649 | if (err < 0) { | 765 | if (err < 0) { |
| 650 | snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err); | 766 | snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err); |
| @@ -654,10 +770,27 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
| 654 | #ifdef OPTi93X | 770 | #ifdef OPTi93X |
| 655 | port = pnp_port_start(pdev, 0) - 4; | 771 | port = pnp_port_start(pdev, 0) - 4; |
| 656 | fm_port = pnp_port_start(pdev, 1) + 8; | 772 | 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; | ||
| 657 | #else | 775 | #else |
| 658 | if (pid->driver_data != 0x0924) | 776 | devmc = pnp_request_card_device(card, pid->devs[2].id, NULL); |
| 659 | port = pnp_port_start(pdev, 1); | 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); | ||
| 660 | fm_port = pnp_port_start(pdev, 2) + 8; | 787 | 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; | ||
| 661 | #endif /* OPTi93X */ | 794 | #endif /* OPTi93X */ |
| 662 | irq = pnp_irq(pdev, 0); | 795 | irq = pnp_irq(pdev, 0); |
| 663 | dma1 = pnp_dma(pdev, 0); | 796 | dma1 = pnp_dma(pdev, 0); |
| @@ -665,16 +798,16 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
| 665 | dma2 = pnp_dma(pdev, 1); | 798 | dma2 = pnp_dma(pdev, 1); |
| 666 | #endif /* CS4231 || OPTi93X */ | 799 | #endif /* CS4231 || OPTi93X */ |
| 667 | 800 | ||
| 668 | pdev = chip->devmpu; | 801 | devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); |
| 669 | if (pdev && mpu_port > 0) { | 802 | |
| 670 | err = pnp_activate_dev(pdev); | 803 | if (devmpu && mpu_port > 0) { |
| 804 | err = pnp_activate_dev(devmpu); | ||
| 671 | if (err < 0) { | 805 | if (err < 0) { |
| 672 | snd_printk(KERN_ERR "AUDIO pnp configure failure\n"); | 806 | snd_printk(KERN_ERR "MPU401 pnp configure failure\n"); |
| 673 | mpu_port = -1; | 807 | mpu_port = -1; |
| 674 | chip->devmpu = NULL; | ||
| 675 | } else { | 808 | } else { |
| 676 | mpu_port = pnp_port_start(pdev, 0); | 809 | mpu_port = pnp_port_start(devmpu, 0); |
| 677 | mpu_irq = pnp_irq(pdev, 0); | 810 | mpu_irq = pnp_irq(devmpu, 0); |
| 678 | } | 811 | } |
| 679 | } | 812 | } |
| 680 | return pid->driver_data; | 813 | return pid->driver_data; |
| @@ -684,14 +817,14 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
| 684 | static void snd_card_opti9xx_free(struct snd_card *card) | 817 | static void snd_card_opti9xx_free(struct snd_card *card) |
| 685 | { | 818 | { |
| 686 | struct snd_opti9xx *chip = card->private_data; | 819 | struct snd_opti9xx *chip = card->private_data; |
| 687 | 820 | ||
| 688 | if (chip) { | 821 | if (chip) { |
| 689 | #ifdef OPTi93X | 822 | #ifdef OPTi93X |
| 690 | struct snd_wss *codec = chip->codec; | 823 | if (chip->irq > 0) { |
| 691 | if (codec && codec->irq > 0) { | 824 | disable_irq(chip->irq); |
| 692 | disable_irq(codec->irq); | 825 | free_irq(chip->irq, chip); |
| 693 | free_irq(codec->irq, codec); | ||
| 694 | } | 826 | } |
| 827 | release_and_free_resource(chip->res_mc_indir); | ||
| 695 | #endif | 828 | #endif |
| 696 | release_and_free_resource(chip->res_mc_base); | 829 | release_and_free_resource(chip->res_mc_base); |
| 697 | } | 830 | } |
| @@ -701,6 +834,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
| 701 | { | 834 | { |
| 702 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; | 835 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; |
| 703 | int error; | 836 | int error; |
| 837 | int xdma2; | ||
| 704 | struct snd_opti9xx *chip = card->private_data; | 838 | struct snd_opti9xx *chip = card->private_data; |
| 705 | struct snd_wss *codec; | 839 | struct snd_wss *codec; |
| 706 | #ifdef CS4231 | 840 | #ifdef CS4231 |
| @@ -710,36 +844,25 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
| 710 | struct snd_rawmidi *rmidi; | 844 | struct snd_rawmidi *rmidi; |
| 711 | struct snd_hwdep *synth; | 845 | struct snd_hwdep *synth; |
| 712 | 846 | ||
| 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; | ||
| 724 | #if defined(CS4231) || defined(OPTi93X) | 847 | #if defined(CS4231) || defined(OPTi93X) |
| 725 | chip->dma2 = dma2; | 848 | xdma2 = dma2; |
| 726 | #else | 849 | #else |
| 727 | chip->dma2 = -1; | 850 | xdma2 = -1; |
| 728 | #endif | 851 | #endif |
| 729 | 852 | ||
| 730 | if (chip->wss_base == SNDRV_AUTO_PORT) { | 853 | if (port == SNDRV_AUTO_PORT) { |
| 731 | chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4); | 854 | port = snd_legacy_find_free_ioport(possible_ports, 4); |
| 732 | if (chip->wss_base < 0) { | 855 | if (port < 0) { |
| 733 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); | 856 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); |
| 734 | return -EBUSY; | 857 | return -EBUSY; |
| 735 | } | 858 | } |
| 736 | } | 859 | } |
| 737 | error = snd_opti9xx_configure(chip); | 860 | error = snd_opti9xx_configure(chip, port, irq, dma1, xdma2, |
| 861 | mpu_port, mpu_irq); | ||
| 738 | if (error) | 862 | if (error) |
| 739 | return error; | 863 | return error; |
| 740 | 864 | ||
| 741 | error = snd_wss_create(card, chip->wss_base + 4, -1, | 865 | error = snd_wss_create(card, chip->wss_base + 4, -1, irq, dma1, xdma2, |
| 742 | chip->irq, chip->dma1, chip->dma2, | ||
| 743 | #ifdef OPTi93X | 866 | #ifdef OPTi93X |
| 744 | WSS_HW_OPTI93X, WSS_HWSHARE_IRQ, | 867 | WSS_HW_OPTI93X, WSS_HWSHARE_IRQ, |
| 745 | #else | 868 | #else |
| @@ -757,41 +880,47 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
| 757 | error = snd_wss_mixer(codec); | 880 | error = snd_wss_mixer(codec); |
| 758 | if (error < 0) | 881 | if (error < 0) |
| 759 | return error; | 882 | return error; |
| 883 | #ifdef OPTi93X | ||
| 884 | error = snd_opti93x_mixer(codec); | ||
| 885 | if (error < 0) | ||
| 886 | return error; | ||
| 887 | #endif | ||
| 760 | #ifdef CS4231 | 888 | #ifdef CS4231 |
| 761 | error = snd_wss_timer(codec, 0, &timer); | 889 | error = snd_wss_timer(codec, 0, &timer); |
| 762 | if (error < 0) | 890 | if (error < 0) |
| 763 | return error; | 891 | return error; |
| 764 | #endif | 892 | #endif |
| 765 | #ifdef OPTi93X | 893 | #ifdef OPTi93X |
| 766 | error = request_irq(chip->irq, snd_opti93x_interrupt, | 894 | error = request_irq(irq, snd_opti93x_interrupt, |
| 767 | IRQF_DISABLED, DEV_NAME" - WSS", codec); | 895 | IRQF_DISABLED, DEV_NAME" - WSS", chip); |
| 768 | if (error < 0) { | 896 | if (error < 0) { |
| 769 | snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq); | 897 | snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", irq); |
| 770 | return error; | 898 | return error; |
| 771 | } | 899 | } |
| 772 | #endif | 900 | #endif |
| 901 | chip->irq = irq; | ||
| 773 | strcpy(card->driver, chip->name); | 902 | strcpy(card->driver, chip->name); |
| 774 | sprintf(card->shortname, "OPTi %s", card->driver); | 903 | sprintf(card->shortname, "OPTi %s", card->driver); |
| 775 | #if defined(CS4231) || defined(OPTi93X) | 904 | #if defined(CS4231) || defined(OPTi93X) |
| 776 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", | 905 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", |
| 777 | card->shortname, pcm->name, chip->wss_base + 4, | 906 | card->shortname, pcm->name, |
| 778 | chip->irq, chip->dma1, chip->dma2); | 907 | chip->wss_base + 4, irq, dma1, xdma2); |
| 779 | #else | 908 | #else |
| 780 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", | 909 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", |
| 781 | card->shortname, pcm->name, chip->wss_base + 4, | 910 | card->shortname, pcm->name, chip->wss_base + 4, irq, dma1); |
| 782 | chip->irq, chip->dma1); | ||
| 783 | #endif /* CS4231 || OPTi93X */ | 911 | #endif /* CS4231 || OPTi93X */ |
| 784 | 912 | ||
| 785 | if (chip->mpu_port <= 0 || chip->mpu_port == SNDRV_AUTO_PORT) | 913 | if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) |
| 786 | rmidi = NULL; | 914 | rmidi = NULL; |
| 787 | else | 915 | else { |
| 788 | if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, | 916 | error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, |
| 789 | chip->mpu_port, 0, chip->mpu_irq, IRQF_DISABLED, | 917 | mpu_port, 0, mpu_irq, IRQF_DISABLED, &rmidi); |
| 790 | &rmidi))) | 918 | if (error) |
| 791 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", | 919 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", |
| 792 | chip->mpu_port); | 920 | mpu_port); |
| 921 | } | ||
| 793 | 922 | ||
| 794 | if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) { | 923 | if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) { |
| 795 | struct snd_opl3 *opl3 = NULL; | 924 | struct snd_opl3 *opl3 = NULL; |
| 796 | #ifndef OPTi93X | 925 | #ifndef OPTi93X |
| 797 | if (chip->hardware == OPTi9XX_HW_82C928 || | 926 | if (chip->hardware == OPTi9XX_HW_82C928 || |
| @@ -801,9 +930,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
| 801 | /* assume we have an OPL4 */ | 930 | /* assume we have an OPL4 */ |
| 802 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), | 931 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), |
| 803 | 0x20, 0x20); | 932 | 0x20, 0x20); |
| 804 | if (snd_opl4_create(card, | 933 | if (snd_opl4_create(card, fm_port, fm_port - 8, |
| 805 | chip->fm_port, | ||
| 806 | chip->fm_port - 8, | ||
| 807 | 2, &opl3, &opl4) < 0) { | 934 | 2, &opl3, &opl4) < 0) { |
| 808 | /* no luck, use OPL3 instead */ | 935 | /* no luck, use OPL3 instead */ |
| 809 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), | 936 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), |
| @@ -811,12 +938,10 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
| 811 | } | 938 | } |
| 812 | } | 939 | } |
| 813 | #endif /* !OPTi93X */ | 940 | #endif /* !OPTi93X */ |
| 814 | if (!opl3 && snd_opl3_create(card, | 941 | if (!opl3 && snd_opl3_create(card, fm_port, fm_port + 2, |
| 815 | chip->fm_port, | ||
| 816 | chip->fm_port + 2, | ||
| 817 | OPL3_HW_AUTO, 0, &opl3) < 0) { | 942 | OPL3_HW_AUTO, 0, &opl3) < 0) { |
| 818 | snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", | 943 | 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); |
| 820 | } | 945 | } |
| 821 | if (opl3) { | 946 | if (opl3) { |
| 822 | error = snd_opl3_hwdep_new(opl3, 0, 1, &synth); | 947 | error = snd_opl3_hwdep_new(opl3, 0, 1, &synth); |
| @@ -976,8 +1101,12 @@ static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, | |||
| 976 | snd_card_free(card); | 1101 | snd_card_free(card); |
| 977 | return error; | 1102 | return error; |
| 978 | } | 1103 | } |
| 979 | if (hw <= OPTi9XX_HW_82C930) | 1104 | error = snd_opti9xx_read_check(chip); |
| 980 | chip->mc_base -= 0x80; | 1105 | if (error) { |
| 1106 | snd_printk(KERN_ERR "OPTI chip not found\n"); | ||
| 1107 | snd_card_free(card); | ||
| 1108 | return error; | ||
| 1109 | } | ||
| 981 | snd_card_set_dev(card, &pcard->card->dev); | 1110 | snd_card_set_dev(card, &pcard->card->dev); |
| 982 | if ((error = snd_opti9xx_probe(card)) < 0) { | 1111 | if ((error = snd_opti9xx_probe(card)) < 0) { |
| 983 | snd_card_free(card); | 1112 | snd_card_free(card); |
diff --git a/sound/isa/sb/Makefile b/sound/isa/sb/Makefile index faeffceb01b7..af3669681788 100644 --- a/sound/isa/sb/Makefile +++ b/sound/isa/sb/Makefile | |||
| @@ -12,6 +12,7 @@ snd-sb16-objs := sb16.o | |||
| 12 | snd-sbawe-objs := sbawe.o emu8000.o | 12 | snd-sbawe-objs := sbawe.o emu8000.o |
| 13 | snd-emu8000-synth-objs := emu8000_synth.o emu8000_callback.o emu8000_patch.o emu8000_pcm.o | 13 | snd-emu8000-synth-objs := emu8000_synth.o emu8000_callback.o emu8000_patch.o emu8000_pcm.o |
| 14 | snd-es968-objs := es968.o | 14 | snd-es968-objs := es968.o |
| 15 | snd-jazz16-objs := jazz16.o | ||
| 15 | 16 | ||
| 16 | # Toplevel Module Dependency | 17 | # Toplevel Module Dependency |
| 17 | obj-$(CONFIG_SND_SB_COMMON) += snd-sb-common.o | 18 | obj-$(CONFIG_SND_SB_COMMON) += snd-sb-common.o |
| @@ -21,6 +22,7 @@ obj-$(CONFIG_SND_SB8) += snd-sb8.o | |||
| 21 | obj-$(CONFIG_SND_SB16) += snd-sb16.o | 22 | obj-$(CONFIG_SND_SB16) += snd-sb16.o |
| 22 | obj-$(CONFIG_SND_SBAWE) += snd-sbawe.o | 23 | obj-$(CONFIG_SND_SBAWE) += snd-sbawe.o |
| 23 | obj-$(CONFIG_SND_ES968) += snd-es968.o | 24 | obj-$(CONFIG_SND_ES968) += snd-es968.o |
| 25 | obj-$(CONFIG_SND_JAZZ16) += snd-jazz16.o | ||
| 24 | ifeq ($(CONFIG_SND_SB16_CSP),y) | 26 | ifeq ($(CONFIG_SND_SB16_CSP),y) |
| 25 | obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o | 27 | obj-$(CONFIG_SND_SB16) += snd-sb16-csp.o |
| 26 | obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o | 28 | obj-$(CONFIG_SND_SBAWE) += snd-sb16-csp.o |
diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 96678d5d3834..0c40951b6523 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c | |||
| @@ -377,12 +377,13 @@ init_arrays(struct snd_emu8000 *emu) | |||
| 377 | static void __devinit | 377 | static void __devinit |
| 378 | size_dram(struct snd_emu8000 *emu) | 378 | size_dram(struct snd_emu8000 *emu) |
| 379 | { | 379 | { |
| 380 | int i, size; | 380 | int i, size, detected_size; |
| 381 | 381 | ||
| 382 | if (emu->dram_checked) | 382 | if (emu->dram_checked) |
| 383 | return; | 383 | return; |
| 384 | 384 | ||
| 385 | size = 0; | 385 | size = 0; |
| 386 | detected_size = 0; | ||
| 386 | 387 | ||
| 387 | /* write out a magic number */ | 388 | /* write out a magic number */ |
| 388 | snd_emu8000_dma_chan(emu, 0, EMU8000_RAM_WRITE); | 389 | snd_emu8000_dma_chan(emu, 0, EMU8000_RAM_WRITE); |
| @@ -414,7 +415,9 @@ size_dram(struct snd_emu8000 *emu) | |||
| 414 | /*snd_emu8000_read_wait(emu);*/ | 415 | /*snd_emu8000_read_wait(emu);*/ |
| 415 | EMU8000_SMLD_READ(emu); /* discard stale data */ | 416 | EMU8000_SMLD_READ(emu); /* discard stale data */ |
| 416 | if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2) | 417 | 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; | ||
| 418 | 421 | ||
| 419 | snd_emu8000_read_wait(emu); | 422 | snd_emu8000_read_wait(emu); |
| 420 | 423 | ||
| @@ -442,9 +445,9 @@ size_dram(struct snd_emu8000 *emu) | |||
| 442 | snd_emu8000_dma_chan(emu, 1, EMU8000_RAM_CLOSE); | 445 | snd_emu8000_dma_chan(emu, 1, EMU8000_RAM_CLOSE); |
| 443 | 446 | ||
| 444 | snd_printdd("EMU8000 [0x%lx]: %d Kb on-board memory detected\n", | 447 | snd_printdd("EMU8000 [0x%lx]: %d Kb on-board memory detected\n", |
| 445 | emu->port1, size/1024); | 448 | emu->port1, detected_size/1024); |
| 446 | 449 | ||
| 447 | emu->mem_size = size; | 450 | emu->mem_size = detected_size; |
| 448 | emu->dram_checked = 1; | 451 | emu->dram_checked = 1; |
| 449 | } | 452 | } |
| 450 | 453 | ||
diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index 91dc3d83e2cf..ccedbfed061a 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | #include "emu8000_local.h" | 21 | #include "emu8000_local.h" |
| 22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
| 23 | #include <linux/slab.h> | ||
| 23 | #include <sound/initval.h> | 24 | #include <sound/initval.h> |
| 24 | #include <sound/pcm.h> | 25 | #include <sound/pcm.h> |
| 25 | 26 | ||
diff --git a/sound/isa/sb/es968.c b/sound/isa/sb/es968.c index cafc3a7316a8..ff18286fef9d 100644 --- a/sound/isa/sb/es968.c +++ b/sound/isa/sb/es968.c | |||
| @@ -93,7 +93,7 @@ static int __devinit snd_card_es968_pnp(int dev, struct snd_card_es968 *acard, | |||
| 93 | return err; | 93 | return err; |
| 94 | } | 94 | } |
| 95 | port[dev] = pnp_port_start(pdev, 0); | 95 | port[dev] = pnp_port_start(pdev, 0); |
| 96 | dma8[dev] = pnp_dma(pdev, 1); | 96 | dma8[dev] = pnp_dma(pdev, 0); |
| 97 | irq[dev] = pnp_irq(pdev, 0); | 97 | irq[dev] = pnp_irq(pdev, 0); |
| 98 | 98 | ||
| 99 | return 0; | 99 | return 0; |
diff --git a/sound/isa/sb/jazz16.c b/sound/isa/sb/jazz16.c new file mode 100644 index 000000000000..8ccbcddf08e1 --- /dev/null +++ b/sound/isa/sb/jazz16.c | |||
| @@ -0,0 +1,405 @@ | |||
| 1 | |||
| 2 | /* | ||
| 3 | * jazz16.c - driver for Media Vision Jazz16 based soundcards. | ||
| 4 | * Copyright (C) 2009 Krzysztof Helt <krzysztof.h1@wp.pl> | ||
| 5 | * Based on patches posted by Rask Ingemann Lambertsen and Rene Herman. | ||
| 6 | * Based on OSS Sound Blaster driver. | ||
| 7 | * | ||
| 8 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 9 | * License. See the file COPYING in the main directory of this archive for | ||
| 10 | * more details. | ||
| 11 | * | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/init.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/io.h> | ||
| 17 | #include <linux/delay.h> | ||
| 18 | #include <asm/dma.h> | ||
| 19 | #include <linux/isa.h> | ||
| 20 | #include <sound/core.h> | ||
| 21 | #include <sound/mpu401.h> | ||
| 22 | #include <sound/opl3.h> | ||
| 23 | #include <sound/sb.h> | ||
| 24 | #define SNDRV_LEGACY_FIND_FREE_IRQ | ||
| 25 | #define SNDRV_LEGACY_FIND_FREE_DMA | ||
| 26 | #include <sound/initval.h> | ||
| 27 | |||
| 28 | #define PFX "jazz16: " | ||
| 29 | |||
| 30 | MODULE_DESCRIPTION("Media Vision Jazz16"); | ||
| 31 | MODULE_SUPPORTED_DEVICE("{{Media Vision ??? }," | ||
| 32 | "{RTL,RTL3000}}"); | ||
| 33 | |||
| 34 | MODULE_AUTHOR("Krzysztof Helt <krzysztof.h1@wp.pl>"); | ||
| 35 | MODULE_LICENSE("GPL"); | ||
| 36 | |||
| 37 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | ||
| 38 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | ||
| 39 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ | ||
| 40 | static unsigned long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
| 41 | static unsigned long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
| 42 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
| 43 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
| 44 | static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
| 45 | static int dma16[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
| 46 | |||
| 47 | module_param_array(index, int, NULL, 0444); | ||
| 48 | MODULE_PARM_DESC(index, "Index value for Media Vision Jazz16 based soundcard."); | ||
| 49 | module_param_array(id, charp, NULL, 0444); | ||
| 50 | MODULE_PARM_DESC(id, "ID string for Media Vision Jazz16 based soundcard."); | ||
| 51 | module_param_array(enable, bool, NULL, 0444); | ||
| 52 | MODULE_PARM_DESC(enable, "Enable Media Vision Jazz16 based soundcard."); | ||
| 53 | module_param_array(port, long, NULL, 0444); | ||
| 54 | MODULE_PARM_DESC(port, "Port # for jazz16 driver."); | ||
| 55 | module_param_array(mpu_port, long, NULL, 0444); | ||
| 56 | MODULE_PARM_DESC(mpu_port, "MPU-401 port # for jazz16 driver."); | ||
| 57 | module_param_array(irq, int, NULL, 0444); | ||
| 58 | MODULE_PARM_DESC(irq, "IRQ # for jazz16 driver."); | ||
| 59 | module_param_array(mpu_irq, int, NULL, 0444); | ||
| 60 | MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for jazz16 driver."); | ||
| 61 | module_param_array(dma8, int, NULL, 0444); | ||
| 62 | MODULE_PARM_DESC(dma8, "DMA8 # for jazz16 driver."); | ||
| 63 | module_param_array(dma16, int, NULL, 0444); | ||
| 64 | MODULE_PARM_DESC(dma16, "DMA16 # for jazz16 driver."); | ||
| 65 | |||
| 66 | #define SB_JAZZ16_WAKEUP 0xaf | ||
| 67 | #define SB_JAZZ16_SET_PORTS 0x50 | ||
| 68 | #define SB_DSP_GET_JAZZ_BRD_REV 0xfa | ||
| 69 | #define SB_JAZZ16_SET_DMAINTR 0xfb | ||
| 70 | #define SB_DSP_GET_JAZZ_MODEL 0xfe | ||
| 71 | |||
| 72 | struct snd_card_jazz16 { | ||
| 73 | struct snd_sb *chip; | ||
| 74 | }; | ||
| 75 | |||
| 76 | static irqreturn_t jazz16_interrupt(int irq, void *chip) | ||
| 77 | { | ||
| 78 | return snd_sb8dsp_interrupt(chip); | ||
| 79 | } | ||
| 80 | |||
| 81 | static int __devinit jazz16_configure_ports(unsigned long port, | ||
| 82 | unsigned long mpu_port, int idx) | ||
| 83 | { | ||
| 84 | unsigned char val; | ||
| 85 | |||
| 86 | if (!request_region(0x201, 1, "jazz16 config")) { | ||
| 87 | snd_printk(KERN_ERR "config port region is already in use.\n"); | ||
| 88 | return -EBUSY; | ||
| 89 | } | ||
| 90 | outb(SB_JAZZ16_WAKEUP - idx, 0x201); | ||
| 91 | udelay(100); | ||
| 92 | outb(SB_JAZZ16_SET_PORTS + idx, 0x201); | ||
| 93 | udelay(100); | ||
| 94 | val = port & 0x70; | ||
| 95 | val |= (mpu_port & 0x30) >> 4; | ||
| 96 | outb(val, 0x201); | ||
| 97 | |||
| 98 | release_region(0x201, 1); | ||
| 99 | return 0; | ||
| 100 | } | ||
| 101 | |||
| 102 | static int __devinit jazz16_detect_board(unsigned long port, | ||
| 103 | unsigned long mpu_port) | ||
| 104 | { | ||
| 105 | int err; | ||
| 106 | int val; | ||
| 107 | struct snd_sb chip; | ||
| 108 | |||
| 109 | if (!request_region(port, 0x10, "jazz16")) { | ||
| 110 | snd_printk(KERN_ERR "I/O port region is already in use.\n"); | ||
| 111 | return -EBUSY; | ||
| 112 | } | ||
| 113 | /* just to call snd_sbdsp_command/reset/get_byte() */ | ||
| 114 | chip.port = port; | ||
| 115 | |||
| 116 | err = snd_sbdsp_reset(&chip); | ||
| 117 | if (err < 0) | ||
| 118 | for (val = 0; val < 4; val++) { | ||
| 119 | err = jazz16_configure_ports(port, mpu_port, val); | ||
| 120 | if (err < 0) | ||
| 121 | break; | ||
| 122 | |||
| 123 | err = snd_sbdsp_reset(&chip); | ||
| 124 | if (!err) | ||
| 125 | break; | ||
| 126 | } | ||
| 127 | if (err < 0) { | ||
| 128 | err = -ENODEV; | ||
| 129 | goto err_unmap; | ||
| 130 | } | ||
| 131 | if (!snd_sbdsp_command(&chip, SB_DSP_GET_JAZZ_BRD_REV)) { | ||
| 132 | err = -EBUSY; | ||
| 133 | goto err_unmap; | ||
| 134 | } | ||
| 135 | val = snd_sbdsp_get_byte(&chip); | ||
| 136 | if (val >= 0x30) | ||
| 137 | snd_sbdsp_get_byte(&chip); | ||
| 138 | |||
| 139 | if ((val & 0xf0) != 0x10) { | ||
| 140 | err = -ENODEV; | ||
| 141 | goto err_unmap; | ||
| 142 | } | ||
| 143 | if (!snd_sbdsp_command(&chip, SB_DSP_GET_JAZZ_MODEL)) { | ||
| 144 | err = -EBUSY; | ||
| 145 | goto err_unmap; | ||
| 146 | } | ||
| 147 | snd_sbdsp_get_byte(&chip); | ||
| 148 | err = snd_sbdsp_get_byte(&chip); | ||
| 149 | snd_printd("Media Vision Jazz16 board detected: rev 0x%x, model 0x%x\n", | ||
| 150 | val, err); | ||
| 151 | |||
| 152 | err = 0; | ||
| 153 | |||
| 154 | err_unmap: | ||
| 155 | release_region(port, 0x10); | ||
| 156 | return err; | ||
| 157 | } | ||
| 158 | |||
| 159 | static int __devinit jazz16_configure_board(struct snd_sb *chip, int mpu_irq) | ||
| 160 | { | ||
| 161 | static unsigned char jazz_irq_bits[] = { 0, 0, 2, 3, 0, 1, 0, 4, | ||
| 162 | 0, 2, 5, 0, 0, 0, 0, 6 }; | ||
| 163 | static unsigned char jazz_dma_bits[] = { 0, 1, 0, 2, 0, 3, 0, 4 }; | ||
| 164 | |||
| 165 | if (jazz_dma_bits[chip->dma8] == 0 || | ||
| 166 | jazz_dma_bits[chip->dma16] == 0 || | ||
| 167 | jazz_irq_bits[chip->irq] == 0) | ||
| 168 | return -EINVAL; | ||
| 169 | |||
| 170 | if (!snd_sbdsp_command(chip, SB_JAZZ16_SET_DMAINTR)) | ||
| 171 | return -EBUSY; | ||
| 172 | |||
| 173 | if (!snd_sbdsp_command(chip, | ||
| 174 | jazz_dma_bits[chip->dma8] | | ||
| 175 | (jazz_dma_bits[chip->dma16] << 4))) | ||
| 176 | return -EBUSY; | ||
| 177 | |||
| 178 | if (!snd_sbdsp_command(chip, | ||
| 179 | jazz_irq_bits[chip->irq] | | ||
| 180 | (jazz_irq_bits[mpu_irq] << 4))) | ||
| 181 | return -EBUSY; | ||
| 182 | |||
| 183 | return 0; | ||
| 184 | } | ||
| 185 | |||
| 186 | static int __devinit snd_jazz16_match(struct device *devptr, unsigned int dev) | ||
| 187 | { | ||
| 188 | if (!enable[dev]) | ||
| 189 | return 0; | ||
| 190 | if (port[dev] == SNDRV_AUTO_PORT) { | ||
| 191 | snd_printk(KERN_ERR "please specify port\n"); | ||
| 192 | return 0; | ||
| 193 | } else if (port[dev] == 0x200 || (port[dev] & ~0x270)) { | ||
| 194 | snd_printk(KERN_ERR "incorrect port specified\n"); | ||
| 195 | return 0; | ||
| 196 | } | ||
| 197 | if (dma8[dev] != SNDRV_AUTO_DMA && | ||
| 198 | dma8[dev] != 1 && dma8[dev] != 3) { | ||
| 199 | snd_printk(KERN_ERR "dma8 must be 1 or 3\n"); | ||
| 200 | return 0; | ||
| 201 | } | ||
| 202 | if (dma16[dev] != SNDRV_AUTO_DMA && | ||
| 203 | dma16[dev] != 5 && dma16[dev] != 7) { | ||
| 204 | snd_printk(KERN_ERR "dma16 must be 5 or 7\n"); | ||
| 205 | return 0; | ||
| 206 | } | ||
| 207 | if (mpu_port[dev] != SNDRV_AUTO_PORT && | ||
| 208 | (mpu_port[dev] & ~0x030) != 0x300) { | ||
| 209 | snd_printk(KERN_ERR "incorrect mpu_port specified\n"); | ||
| 210 | return 0; | ||
| 211 | } | ||
| 212 | if (mpu_irq[dev] != SNDRV_AUTO_DMA && | ||
| 213 | mpu_irq[dev] != 2 && mpu_irq[dev] != 3 && | ||
| 214 | mpu_irq[dev] != 5 && mpu_irq[dev] != 7) { | ||
| 215 | snd_printk(KERN_ERR "mpu_irq must be 2, 3, 5 or 7\n"); | ||
| 216 | return 0; | ||
| 217 | } | ||
| 218 | return 1; | ||
| 219 | } | ||
| 220 | |||
| 221 | static int __devinit snd_jazz16_probe(struct device *devptr, unsigned int dev) | ||
| 222 | { | ||
| 223 | struct snd_card *card; | ||
| 224 | struct snd_card_jazz16 *jazz16; | ||
| 225 | struct snd_sb *chip; | ||
| 226 | struct snd_opl3 *opl3; | ||
| 227 | static int possible_irqs[] = {2, 3, 5, 7, 9, 10, 15, -1}; | ||
| 228 | static int possible_dmas8[] = {1, 3, -1}; | ||
| 229 | static int possible_dmas16[] = {5, 7, -1}; | ||
| 230 | int err, xirq, xdma8, xdma16, xmpu_port, xmpu_irq; | ||
| 231 | |||
| 232 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, | ||
| 233 | sizeof(struct snd_card_jazz16), &card); | ||
| 234 | if (err < 0) | ||
| 235 | return err; | ||
| 236 | |||
| 237 | jazz16 = card->private_data; | ||
| 238 | |||
| 239 | xirq = irq[dev]; | ||
| 240 | if (xirq == SNDRV_AUTO_IRQ) { | ||
| 241 | xirq = snd_legacy_find_free_irq(possible_irqs); | ||
| 242 | if (xirq < 0) { | ||
| 243 | snd_printk(KERN_ERR "unable to find a free IRQ\n"); | ||
| 244 | err = -EBUSY; | ||
| 245 | goto err_free; | ||
| 246 | } | ||
| 247 | } | ||
| 248 | xdma8 = dma8[dev]; | ||
| 249 | if (xdma8 == SNDRV_AUTO_DMA) { | ||
| 250 | xdma8 = snd_legacy_find_free_dma(possible_dmas8); | ||
| 251 | if (xdma8 < 0) { | ||
| 252 | snd_printk(KERN_ERR "unable to find a free DMA8\n"); | ||
| 253 | err = -EBUSY; | ||
| 254 | goto err_free; | ||
| 255 | } | ||
| 256 | } | ||
| 257 | xdma16 = dma16[dev]; | ||
| 258 | if (xdma16 == SNDRV_AUTO_DMA) { | ||
| 259 | xdma16 = snd_legacy_find_free_dma(possible_dmas16); | ||
| 260 | if (xdma16 < 0) { | ||
| 261 | snd_printk(KERN_ERR "unable to find a free DMA16\n"); | ||
| 262 | err = -EBUSY; | ||
| 263 | goto err_free; | ||
| 264 | } | ||
| 265 | } | ||
| 266 | |||
| 267 | xmpu_port = mpu_port[dev]; | ||
| 268 | if (xmpu_port == SNDRV_AUTO_PORT) | ||
| 269 | xmpu_port = 0; | ||
| 270 | err = jazz16_detect_board(port[dev], xmpu_port); | ||
| 271 | if (err < 0) { | ||
| 272 | printk(KERN_ERR "Media Vision Jazz16 board not detected\n"); | ||
| 273 | goto err_free; | ||
| 274 | } | ||
| 275 | err = snd_sbdsp_create(card, port[dev], irq[dev], | ||
| 276 | jazz16_interrupt, | ||
| 277 | dma8[dev], dma16[dev], | ||
| 278 | SB_HW_JAZZ16, | ||
| 279 | &chip); | ||
| 280 | if (err < 0) | ||
| 281 | goto err_free; | ||
| 282 | |||
| 283 | xmpu_irq = mpu_irq[dev]; | ||
| 284 | if (xmpu_irq == SNDRV_AUTO_IRQ || mpu_port[dev] == SNDRV_AUTO_PORT) | ||
| 285 | xmpu_irq = 0; | ||
| 286 | err = jazz16_configure_board(chip, xmpu_irq); | ||
| 287 | if (err < 0) { | ||
| 288 | printk(KERN_ERR "Media Vision Jazz16 configuration failed\n"); | ||
| 289 | goto err_free; | ||
| 290 | } | ||
| 291 | |||
| 292 | jazz16->chip = chip; | ||
| 293 | |||
| 294 | strcpy(card->driver, "jazz16"); | ||
| 295 | strcpy(card->shortname, "Media Vision Jazz16"); | ||
| 296 | sprintf(card->longname, | ||
| 297 | "Media Vision Jazz16 at 0x%lx, irq %d, dma8 %d, dma16 %d", | ||
| 298 | port[dev], xirq, xdma8, xdma16); | ||
| 299 | |||
| 300 | err = snd_sb8dsp_pcm(chip, 0, NULL); | ||
| 301 | if (err < 0) | ||
| 302 | goto err_free; | ||
| 303 | err = snd_sbmixer_new(chip); | ||
| 304 | if (err < 0) | ||
| 305 | goto err_free; | ||
| 306 | |||
| 307 | err = snd_opl3_create(card, chip->port, chip->port + 2, | ||
| 308 | OPL3_HW_AUTO, 1, &opl3); | ||
| 309 | if (err < 0) | ||
| 310 | snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", | ||
| 311 | chip->port, chip->port + 2); | ||
| 312 | else { | ||
| 313 | err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); | ||
| 314 | if (err < 0) | ||
| 315 | goto err_free; | ||
| 316 | } | ||
| 317 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | ||
| 318 | if (mpu_irq[dev] == SNDRV_AUTO_IRQ) | ||
| 319 | mpu_irq[dev] = -1; | ||
| 320 | |||
| 321 | if (snd_mpu401_uart_new(card, 0, | ||
| 322 | MPU401_HW_MPU401, | ||
| 323 | mpu_port[dev], 0, | ||
| 324 | mpu_irq[dev], | ||
| 325 | mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0, | ||
| 326 | NULL) < 0) | ||
| 327 | snd_printk(KERN_ERR "no MPU-401 device at 0x%lx\n", | ||
| 328 | mpu_port[dev]); | ||
| 329 | } | ||
| 330 | |||
| 331 | snd_card_set_dev(card, devptr); | ||
| 332 | |||
| 333 | err = snd_card_register(card); | ||
| 334 | if (err < 0) | ||
| 335 | goto err_free; | ||
| 336 | |||
| 337 | dev_set_drvdata(devptr, card); | ||
| 338 | return 0; | ||
| 339 | |||
| 340 | err_free: | ||
| 341 | snd_card_free(card); | ||
| 342 | return err; | ||
| 343 | } | ||
| 344 | |||
| 345 | static int __devexit snd_jazz16_remove(struct device *devptr, unsigned int dev) | ||
| 346 | { | ||
| 347 | struct snd_card *card = dev_get_drvdata(devptr); | ||
| 348 | |||
| 349 | dev_set_drvdata(devptr, NULL); | ||
| 350 | snd_card_free(card); | ||
| 351 | return 0; | ||
| 352 | } | ||
| 353 | |||
| 354 | #ifdef CONFIG_PM | ||
| 355 | static int snd_jazz16_suspend(struct device *pdev, unsigned int n, | ||
| 356 | pm_message_t state) | ||
| 357 | { | ||
| 358 | struct snd_card *card = dev_get_drvdata(pdev); | ||
| 359 | struct snd_card_jazz16 *acard = card->private_data; | ||
| 360 | struct snd_sb *chip = acard->chip; | ||
| 361 | |||
| 362 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | ||
| 363 | snd_pcm_suspend_all(chip->pcm); | ||
| 364 | snd_sbmixer_suspend(chip); | ||
| 365 | return 0; | ||
| 366 | } | ||
| 367 | |||
| 368 | static int snd_jazz16_resume(struct device *pdev, unsigned int n) | ||
| 369 | { | ||
| 370 | struct snd_card *card = dev_get_drvdata(pdev); | ||
| 371 | struct snd_card_jazz16 *acard = card->private_data; | ||
| 372 | struct snd_sb *chip = acard->chip; | ||
| 373 | |||
| 374 | snd_sbdsp_reset(chip); | ||
| 375 | snd_sbmixer_resume(chip); | ||
| 376 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | ||
| 377 | return 0; | ||
| 378 | } | ||
| 379 | #endif | ||
| 380 | |||
| 381 | static struct isa_driver snd_jazz16_driver = { | ||
| 382 | .match = snd_jazz16_match, | ||
| 383 | .probe = snd_jazz16_probe, | ||
| 384 | .remove = __devexit_p(snd_jazz16_remove), | ||
| 385 | #ifdef CONFIG_PM | ||
| 386 | .suspend = snd_jazz16_suspend, | ||
| 387 | .resume = snd_jazz16_resume, | ||
| 388 | #endif | ||
| 389 | .driver = { | ||
| 390 | .name = "jazz16" | ||
| 391 | }, | ||
| 392 | }; | ||
| 393 | |||
| 394 | static int __init alsa_card_jazz16_init(void) | ||
| 395 | { | ||
| 396 | return isa_register_driver(&snd_jazz16_driver, SNDRV_CARDS); | ||
| 397 | } | ||
| 398 | |||
| 399 | static void __exit alsa_card_jazz16_exit(void) | ||
| 400 | { | ||
| 401 | isa_unregister_driver(&snd_jazz16_driver); | ||
| 402 | } | ||
| 403 | |||
| 404 | module_init(alsa_card_jazz16_init) | ||
| 405 | module_exit(alsa_card_jazz16_exit) | ||
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 519c36346dec..4d1c5a300ff8 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c | |||
| @@ -21,7 +21,6 @@ | |||
| 21 | 21 | ||
| 22 | #include <asm/dma.h> | 22 | #include <asm/dma.h> |
| 23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
| 24 | #include <linux/slab.h> | ||
| 25 | #include <linux/pnp.h> | 24 | #include <linux/pnp.h> |
| 26 | #include <linux/err.h> | 25 | #include <linux/err.h> |
| 27 | #include <linux/isa.h> | 26 | #include <linux/isa.h> |
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index 3cd57ee54660..81284a8fa0ce 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
| 23 | #include <linux/err.h> | 23 | #include <linux/err.h> |
| 24 | #include <linux/isa.h> | 24 | #include <linux/isa.h> |
| 25 | #include <linux/slab.h> | ||
| 26 | #include <linux/ioport.h> | 25 | #include <linux/ioport.h> |
| 27 | #include <linux/moduleparam.h> | 26 | #include <linux/moduleparam.h> |
| 28 | #include <sound/core.h> | 27 | #include <sound/core.h> |
diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 658d55769c9c..7d84c9f34dc9 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c | |||
| @@ -106,9 +106,21 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
| 106 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 106 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
| 107 | struct snd_pcm_runtime *runtime = substream->runtime; | 107 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 108 | unsigned int mixreg, rate, size, count; | 108 | unsigned int mixreg, rate, size, count; |
| 109 | unsigned char format; | ||
| 110 | unsigned char stereo = runtime->channels > 1; | ||
| 111 | int dma; | ||
| 109 | 112 | ||
| 110 | rate = runtime->rate; | 113 | rate = runtime->rate; |
| 111 | switch (chip->hardware) { | 114 | 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; | ||
| 112 | case SB_HW_PRO: | 124 | case SB_HW_PRO: |
| 113 | if (runtime->channels > 1) { | 125 | if (runtime->channels > 1) { |
| 114 | if (snd_BUG_ON(rate != SB8_RATE(11025) && | 126 | if (snd_BUG_ON(rate != SB8_RATE(11025) && |
| @@ -133,11 +145,21 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
| 133 | default: | 145 | default: |
| 134 | return -EINVAL; | 146 | return -EINVAL; |
| 135 | } | 147 | } |
| 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 | } | ||
| 136 | size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream); | 156 | size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream); |
| 137 | count = chip->p_period_size = snd_pcm_lib_period_bytes(substream); | 157 | count = chip->p_period_size = snd_pcm_lib_period_bytes(substream); |
| 138 | spin_lock_irqsave(&chip->reg_lock, flags); | 158 | spin_lock_irqsave(&chip->reg_lock, flags); |
| 139 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON); | 159 | 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) { | ||
| 141 | /* set playback stereo mode */ | 163 | /* set playback stereo mode */ |
| 142 | spin_lock(&chip->mixer_lock); | 164 | spin_lock(&chip->mixer_lock); |
| 143 | mixreg = snd_sbmixer_read(chip, SB_DSP_STEREO_SW); | 165 | mixreg = snd_sbmixer_read(chip, SB_DSP_STEREO_SW); |
| @@ -147,15 +169,14 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
| 147 | /* Soundblaster hardware programming reference guide, 3-23 */ | 169 | /* Soundblaster hardware programming reference guide, 3-23 */ |
| 148 | snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT); | 170 | snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT); |
| 149 | runtime->dma_area[0] = 0x80; | 171 | 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); |
| 151 | /* force interrupt */ | 173 | /* force interrupt */ |
| 152 | chip->mode = SB_MODE_HALT; | ||
| 153 | snd_sbdsp_command(chip, SB_DSP_OUTPUT); | 174 | snd_sbdsp_command(chip, SB_DSP_OUTPUT); |
| 154 | snd_sbdsp_command(chip, 0); | 175 | snd_sbdsp_command(chip, 0); |
| 155 | snd_sbdsp_command(chip, 0); | 176 | snd_sbdsp_command(chip, 0); |
| 156 | } | 177 | } |
| 157 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); | 178 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); |
| 158 | if (runtime->channels > 1) { | 179 | if (stereo) { |
| 159 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); | 180 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); |
| 160 | spin_lock(&chip->mixer_lock); | 181 | spin_lock(&chip->mixer_lock); |
| 161 | /* save output filter status and turn it off */ | 182 | /* save output filter status and turn it off */ |
| @@ -168,13 +189,15 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
| 168 | snd_sbdsp_command(chip, 256 - runtime->rate_den); | 189 | snd_sbdsp_command(chip, 256 - runtime->rate_den); |
| 169 | } | 190 | } |
| 170 | if (chip->playback_format != SB_DSP_OUTPUT) { | 191 | if (chip->playback_format != SB_DSP_OUTPUT) { |
| 192 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
| 193 | count /= 2; | ||
| 171 | count--; | 194 | count--; |
| 172 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); | 195 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); |
| 173 | snd_sbdsp_command(chip, count & 0xff); | 196 | snd_sbdsp_command(chip, count & 0xff); |
| 174 | snd_sbdsp_command(chip, count >> 8); | 197 | snd_sbdsp_command(chip, count >> 8); |
| 175 | } | 198 | } |
| 176 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 199 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
| 177 | snd_dma_program(chip->dma8, runtime->dma_addr, | 200 | snd_dma_program(dma, runtime->dma_addr, |
| 178 | size, DMA_MODE_WRITE | DMA_AUTOINIT); | 201 | size, DMA_MODE_WRITE | DMA_AUTOINIT); |
| 179 | return 0; | 202 | return 0; |
| 180 | } | 203 | } |
| @@ -212,7 +235,6 @@ static int snd_sb8_playback_trigger(struct snd_pcm_substream *substream, | |||
| 212 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 235 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
| 213 | } | 236 | } |
| 214 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 237 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
| 215 | chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_PLAYBACK_8 : SB_MODE_HALT; | ||
| 216 | return 0; | 238 | return 0; |
| 217 | } | 239 | } |
| 218 | 240 | ||
| @@ -234,9 +256,21 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
| 234 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 256 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
| 235 | struct snd_pcm_runtime *runtime = substream->runtime; | 257 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 236 | unsigned int mixreg, rate, size, count; | 258 | unsigned int mixreg, rate, size, count; |
| 259 | unsigned char format; | ||
| 260 | unsigned char stereo = runtime->channels > 1; | ||
| 261 | int dma; | ||
| 237 | 262 | ||
| 238 | rate = runtime->rate; | 263 | rate = runtime->rate; |
| 239 | switch (chip->hardware) { | 264 | 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; | ||
| 240 | case SB_HW_PRO: | 274 | case SB_HW_PRO: |
| 241 | if (runtime->channels > 1) { | 275 | if (runtime->channels > 1) { |
| 242 | if (snd_BUG_ON(rate != SB8_RATE(11025) && | 276 | if (snd_BUG_ON(rate != SB8_RATE(11025) && |
| @@ -262,14 +296,24 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
| 262 | default: | 296 | default: |
| 263 | return -EINVAL; | 297 | return -EINVAL; |
| 264 | } | 298 | } |
| 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 | } | ||
| 265 | size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream); | 307 | size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream); |
| 266 | count = chip->c_period_size = snd_pcm_lib_period_bytes(substream); | 308 | count = chip->c_period_size = snd_pcm_lib_period_bytes(substream); |
| 267 | spin_lock_irqsave(&chip->reg_lock, flags); | 309 | spin_lock_irqsave(&chip->reg_lock, flags); |
| 268 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 310 | 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) | ||
| 270 | snd_sbdsp_command(chip, SB_DSP_STEREO_8BIT); | 314 | snd_sbdsp_command(chip, SB_DSP_STEREO_8BIT); |
| 271 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); | 315 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); |
| 272 | if (runtime->channels > 1) { | 316 | if (stereo) { |
| 273 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); | 317 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); |
| 274 | spin_lock(&chip->mixer_lock); | 318 | spin_lock(&chip->mixer_lock); |
| 275 | /* save input filter status and turn it off */ | 319 | /* save input filter status and turn it off */ |
| @@ -282,13 +326,15 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
| 282 | snd_sbdsp_command(chip, 256 - runtime->rate_den); | 326 | snd_sbdsp_command(chip, 256 - runtime->rate_den); |
| 283 | } | 327 | } |
| 284 | if (chip->capture_format != SB_DSP_INPUT) { | 328 | if (chip->capture_format != SB_DSP_INPUT) { |
| 329 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
| 330 | count /= 2; | ||
| 285 | count--; | 331 | count--; |
| 286 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); | 332 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); |
| 287 | snd_sbdsp_command(chip, count & 0xff); | 333 | snd_sbdsp_command(chip, count & 0xff); |
| 288 | snd_sbdsp_command(chip, count >> 8); | 334 | snd_sbdsp_command(chip, count >> 8); |
| 289 | } | 335 | } |
| 290 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 336 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
| 291 | snd_dma_program(chip->dma8, runtime->dma_addr, | 337 | snd_dma_program(dma, runtime->dma_addr, |
| 292 | size, DMA_MODE_READ | DMA_AUTOINIT); | 338 | size, DMA_MODE_READ | DMA_AUTOINIT); |
| 293 | return 0; | 339 | return 0; |
| 294 | } | 340 | } |
| @@ -328,7 +374,6 @@ static int snd_sb8_capture_trigger(struct snd_pcm_substream *substream, | |||
| 328 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 374 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
| 329 | } | 375 | } |
| 330 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 376 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
| 331 | chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_CAPTURE_8 : SB_MODE_HALT; | ||
| 332 | return 0; | 377 | return 0; |
| 333 | } | 378 | } |
| 334 | 379 | ||
| @@ -339,13 +384,21 @@ irqreturn_t snd_sb8dsp_interrupt(struct snd_sb *chip) | |||
| 339 | 384 | ||
| 340 | snd_sb_ack_8bit(chip); | 385 | snd_sb_ack_8bit(chip); |
| 341 | switch (chip->mode) { | 386 | 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: | ||
| 343 | substream = chip->playback_substream; | 392 | substream = chip->playback_substream; |
| 344 | runtime = substream->runtime; | 393 | runtime = substream->runtime; |
| 345 | if (chip->playback_format == SB_DSP_OUTPUT) | 394 | if (chip->playback_format == SB_DSP_OUTPUT) |
| 346 | snd_sb8_playback_trigger(substream, SNDRV_PCM_TRIGGER_START); | 395 | snd_sb8_playback_trigger(substream, SNDRV_PCM_TRIGGER_START); |
| 347 | snd_pcm_period_elapsed(substream); | 396 | snd_pcm_period_elapsed(substream); |
| 348 | break; | 397 | break; |
| 398 | case SB_MODE_CAPTURE_16: | ||
| 399 | if (chip->hardware != SB_HW_JAZZ16) | ||
| 400 | break; | ||
| 401 | /* fallthru */ | ||
| 349 | case SB_MODE_CAPTURE_8: | 402 | case SB_MODE_CAPTURE_8: |
| 350 | substream = chip->capture_substream; | 403 | substream = chip->capture_substream; |
| 351 | runtime = substream->runtime; | 404 | runtime = substream->runtime; |
| @@ -361,10 +414,15 @@ static snd_pcm_uframes_t snd_sb8_playback_pointer(struct snd_pcm_substream *subs | |||
| 361 | { | 414 | { |
| 362 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 415 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
| 363 | size_t ptr; | 416 | size_t ptr; |
| 417 | int dma; | ||
| 364 | 418 | ||
| 365 | if (chip->mode != SB_MODE_PLAYBACK_8) | 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 | ||
| 366 | return 0; | 424 | return 0; |
| 367 | ptr = snd_dma_pointer(chip->dma8, chip->p_dma_size); | 425 | ptr = snd_dma_pointer(dma, chip->p_dma_size); |
| 368 | return bytes_to_frames(substream->runtime, ptr); | 426 | return bytes_to_frames(substream->runtime, ptr); |
| 369 | } | 427 | } |
| 370 | 428 | ||
| @@ -372,10 +430,15 @@ static snd_pcm_uframes_t snd_sb8_capture_pointer(struct snd_pcm_substream *subst | |||
| 372 | { | 430 | { |
| 373 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 431 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
| 374 | size_t ptr; | 432 | size_t ptr; |
| 433 | int dma; | ||
| 375 | 434 | ||
| 376 | if (chip->mode != SB_MODE_CAPTURE_8) | 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 | ||
| 377 | return 0; | 440 | return 0; |
| 378 | ptr = snd_dma_pointer(chip->dma8, chip->c_dma_size); | 441 | ptr = snd_dma_pointer(dma, chip->c_dma_size); |
| 379 | return bytes_to_frames(substream->runtime, ptr); | 442 | return bytes_to_frames(substream->runtime, ptr); |
| 380 | } | 443 | } |
| 381 | 444 | ||
| @@ -446,6 +509,14 @@ static int snd_sb8_open(struct snd_pcm_substream *substream) | |||
| 446 | runtime->hw = snd_sb8_capture; | 509 | runtime->hw = snd_sb8_capture; |
| 447 | } | 510 | } |
| 448 | switch (chip->hardware) { | 511 | 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; | ||
| 449 | case SB_HW_PRO: | 520 | case SB_HW_PRO: |
| 450 | runtime->hw.rate_max = 44100; | 521 | runtime->hw.rate_max = 44100; |
| 451 | runtime->hw.channels_max = 2; | 522 | runtime->hw.channels_max = 2; |
| @@ -468,6 +539,14 @@ static int snd_sb8_open(struct snd_pcm_substream *substream) | |||
| 468 | } | 539 | } |
| 469 | snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 540 | snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
| 470 | &hw_constraints_clock); | 541 | &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 | } | ||
| 471 | return 0; | 550 | return 0; |
| 472 | } | 551 | } |
| 473 | 552 | ||
| @@ -480,6 +559,10 @@ static int snd_sb8_close(struct snd_pcm_substream *substream) | |||
| 480 | chip->capture_substream = NULL; | 559 | chip->capture_substream = NULL; |
| 481 | spin_lock_irqsave(&chip->open_lock, flags); | 560 | spin_lock_irqsave(&chip->open_lock, flags); |
| 482 | chip->open &= ~SB_OPEN_PCM; | 561 | 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; | ||
| 483 | spin_unlock_irqrestore(&chip->open_lock, flags); | 566 | spin_unlock_irqrestore(&chip->open_lock, flags); |
| 484 | return 0; | 567 | return 0; |
| 485 | } | 568 | } |
| @@ -515,6 +598,7 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) | |||
| 515 | struct snd_card *card = chip->card; | 598 | struct snd_card *card = chip->card; |
| 516 | struct snd_pcm *pcm; | 599 | struct snd_pcm *pcm; |
| 517 | int err; | 600 | int err; |
| 601 | size_t max_prealloc = 64 * 1024; | ||
| 518 | 602 | ||
| 519 | if (rpcm) | 603 | if (rpcm) |
| 520 | *rpcm = NULL; | 604 | *rpcm = NULL; |
| @@ -527,9 +611,11 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) | |||
| 527 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); | 611 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); |
| 528 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); | 612 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); |
| 529 | 613 | ||
| 614 | if (chip->dma8 > 3 || chip->dma16 >= 0) | ||
| 615 | max_prealloc = 128 * 1024; | ||
| 530 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 616 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
| 531 | snd_dma_isa_data(), | 617 | snd_dma_isa_data(), |
| 532 | 64*1024, 64*1024); | 618 | 64*1024, max_prealloc); |
| 533 | 619 | ||
| 534 | if (rpcm) | 620 | if (rpcm) |
| 535 | *rpcm = pcm; | 621 | *rpcm = pcm; |
diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index 27a651502251..eae6c1c0eff9 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c | |||
| @@ -170,6 +170,9 @@ static int snd_sbdsp_probe(struct snd_sb * chip) | |||
| 170 | case SB_HW_CS5530: | 170 | case SB_HW_CS5530: |
| 171 | str = "16 (CS5530)"; | 171 | str = "16 (CS5530)"; |
| 172 | break; | 172 | break; |
| 173 | case SB_HW_JAZZ16: | ||
| 174 | str = "Pro (Jazz16)"; | ||
| 175 | break; | ||
| 173 | default: | 176 | default: |
| 174 | return -ENODEV; | 177 | return -ENODEV; |
| 175 | } | 178 | } |
diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 475220bbcc96..6496822c1808 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c | |||
| @@ -528,20 +528,11 @@ int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int ty | |||
| 528 | * SB 2.0 specific mixer elements | 528 | * SB 2.0 specific mixer elements |
| 529 | */ | 529 | */ |
| 530 | 530 | ||
| 531 | static struct sbmix_elem snd_sb20_ctl_master_play_vol = | 531 | static struct sbmix_elem snd_sb20_controls[] = { |
| 532 | SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7); | 532 | SB_SINGLE("Master Playback Volume", SB_DSP20_MASTER_DEV, 1, 7), |
| 533 | static struct sbmix_elem snd_sb20_ctl_pcm_play_vol = | 533 | SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3), |
| 534 | SB_SINGLE("PCM Playback Volume", SB_DSP20_PCM_DEV, 1, 3); | 534 | SB_SINGLE("Synth Playback Volume", SB_DSP20_FM_DEV, 1, 7), |
| 535 | static struct sbmix_elem snd_sb20_ctl_synth_play_vol = | 535 | SB_SINGLE("CD Playback Volume", SB_DSP20_CD_DEV, 1, 7) |
| 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 | ||
| 545 | }; | 536 | }; |
| 546 | 537 | ||
| 547 | static unsigned char snd_sb20_init_values[][2] = { | 538 | static unsigned char snd_sb20_init_values[][2] = { |
| @@ -552,41 +543,24 @@ static unsigned char snd_sb20_init_values[][2] = { | |||
| 552 | /* | 543 | /* |
| 553 | * SB Pro specific mixer elements | 544 | * SB Pro specific mixer elements |
| 554 | */ | 545 | */ |
| 555 | static struct sbmix_elem snd_sbpro_ctl_master_play_vol = | 546 | static struct sbmix_elem snd_sbpro_controls[] = { |
| 556 | SB_DOUBLE("Master Playback Volume", SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7); | 547 | SB_DOUBLE("Master Playback Volume", |
| 557 | static struct sbmix_elem snd_sbpro_ctl_pcm_play_vol = | 548 | SB_DSP_MASTER_DEV, SB_DSP_MASTER_DEV, 5, 1, 7), |
| 558 | SB_DOUBLE("PCM Playback Volume", SB_DSP_PCM_DEV, SB_DSP_PCM_DEV, 5, 1, 7); | 549 | SB_DOUBLE("PCM Playback Volume", |
| 559 | static struct sbmix_elem snd_sbpro_ctl_pcm_play_filter = | 550 | SB_DSP_PCM_DEV, SB_DSP_PCM_DEV, 5, 1, 7), |
| 560 | SB_SINGLE("PCM Playback Filter", SB_DSP_PLAYBACK_FILT, 5, 1); | 551 | SB_SINGLE("PCM Playback Filter", SB_DSP_PLAYBACK_FILT, 5, 1), |
| 561 | static struct sbmix_elem snd_sbpro_ctl_synth_play_vol = | 552 | SB_DOUBLE("Synth Playback Volume", |
| 562 | SB_DOUBLE("Synth Playback Volume", SB_DSP_FM_DEV, SB_DSP_FM_DEV, 5, 1, 7); | 553 | SB_DSP_FM_DEV, SB_DSP_FM_DEV, 5, 1, 7), |
| 563 | static struct sbmix_elem snd_sbpro_ctl_cd_play_vol = | 554 | SB_DOUBLE("CD Playback Volume", SB_DSP_CD_DEV, SB_DSP_CD_DEV, 5, 1, 7), |
| 564 | SB_DOUBLE("CD Playback Volume", SB_DSP_CD_DEV, SB_DSP_CD_DEV, 5, 1, 7); | 555 | SB_DOUBLE("Line Playback Volume", |
| 565 | static struct sbmix_elem snd_sbpro_ctl_line_play_vol = | 556 | SB_DSP_LINE_DEV, SB_DSP_LINE_DEV, 5, 1, 7), |
| 566 | SB_DOUBLE("Line Playback Volume", SB_DSP_LINE_DEV, SB_DSP_LINE_DEV, 5, 1, 7); | 557 | SB_SINGLE("Mic Playback Volume", SB_DSP_MIC_DEV, 1, 3), |
| 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 = | ||
| 570 | { | 558 | { |
| 571 | .name = "Capture Source", | 559 | .name = "Capture Source", |
| 572 | .type = SB_MIX_CAPTURE_PRO | 560 | .type = SB_MIX_CAPTURE_PRO |
| 573 | }; | 561 | }, |
| 574 | static struct sbmix_elem snd_sbpro_ctl_capture_filter = | 562 | SB_SINGLE("Capture Filter", SB_DSP_CAPTURE_FILT, 5, 1), |
| 575 | SB_SINGLE("Capture Filter", SB_DSP_CAPTURE_FILT, 5, 1); | 563 | SB_SINGLE("Capture Low-Pass Filter", SB_DSP_CAPTURE_FILT, 3, 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 | ||
| 590 | }; | 564 | }; |
| 591 | 565 | ||
| 592 | static unsigned char snd_sbpro_init_values[][2] = { | 566 | static unsigned char snd_sbpro_init_values[][2] = { |
| @@ -598,68 +572,42 @@ static unsigned char snd_sbpro_init_values[][2] = { | |||
| 598 | /* | 572 | /* |
| 599 | * SB16 specific mixer elements | 573 | * SB16 specific mixer elements |
| 600 | */ | 574 | */ |
| 601 | static struct sbmix_elem snd_sb16_ctl_master_play_vol = | 575 | static struct sbmix_elem snd_sb16_controls[] = { |
| 602 | SB_DOUBLE("Master Playback Volume", SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31); | 576 | SB_DOUBLE("Master Playback Volume", |
| 603 | static struct sbmix_elem snd_sb16_ctl_3d_enhance_switch = | 577 | SB_DSP4_MASTER_DEV, (SB_DSP4_MASTER_DEV + 1), 3, 3, 31), |
| 604 | SB_SINGLE("3D Enhancement Switch", SB_DSP4_3DSE, 0, 1); | 578 | SB_DOUBLE("PCM Playback Volume", |
| 605 | static struct sbmix_elem snd_sb16_ctl_tone_bass = | 579 | SB_DSP4_PCM_DEV, (SB_DSP4_PCM_DEV + 1), 3, 3, 31), |
| 606 | SB_DOUBLE("Tone Control - Bass", SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15); | 580 | SB16_INPUT_SW("Synth Capture Route", |
| 607 | static struct sbmix_elem snd_sb16_ctl_tone_treble = | 581 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 6, 5), |
| 608 | SB_DOUBLE("Tone Control - Treble", SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15); | 582 | SB_DOUBLE("Synth Playback Volume", |
| 609 | static struct sbmix_elem snd_sb16_ctl_pcm_play_vol = | 583 | SB_DSP4_SYNTH_DEV, (SB_DSP4_SYNTH_DEV + 1), 3, 3, 31), |
| 610 | SB_DOUBLE("PCM Playback Volume", SB_DSP4_PCM_DEV, (SB_DSP4_PCM_DEV + 1), 3, 3, 31); | 584 | SB16_INPUT_SW("CD Capture Route", |
| 611 | static struct sbmix_elem snd_sb16_ctl_synth_capture_route = | 585 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 2, 1), |
| 612 | SB16_INPUT_SW("Synth Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 6, 5); | 586 | SB_DOUBLE("CD Playback Switch", |
| 613 | static struct sbmix_elem snd_sb16_ctl_synth_play_vol = | 587 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1), |
| 614 | SB_DOUBLE("Synth Playback Volume", SB_DSP4_SYNTH_DEV, (SB_DSP4_SYNTH_DEV + 1), 3, 3, 31); | 588 | SB_DOUBLE("CD Playback Volume", |
| 615 | static struct sbmix_elem snd_sb16_ctl_cd_capture_route = | 589 | SB_DSP4_CD_DEV, (SB_DSP4_CD_DEV + 1), 3, 3, 31), |
| 616 | SB16_INPUT_SW("CD Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 2, 1); | 590 | SB16_INPUT_SW("Mic Capture Route", |
| 617 | static struct sbmix_elem snd_sb16_ctl_cd_play_switch = | 591 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0), |
| 618 | SB_DOUBLE("CD Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1); | 592 | SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), |
| 619 | static struct sbmix_elem snd_sb16_ctl_cd_play_vol = | 593 | SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), |
| 620 | SB_DOUBLE("CD Playback Volume", SB_DSP4_CD_DEV, (SB_DSP4_CD_DEV + 1), 3, 3, 31); | 594 | SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3), |
| 621 | static struct sbmix_elem snd_sb16_ctl_line_capture_route = | 595 | SB_DOUBLE("Capture Volume", |
| 622 | SB16_INPUT_SW("Line Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 4, 3); | 596 | SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3), |
| 623 | static struct sbmix_elem snd_sb16_ctl_line_play_switch = | 597 | SB_DOUBLE("Playback Volume", |
| 624 | SB_DOUBLE("Line Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1); | 598 | SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3), |
| 625 | static struct sbmix_elem snd_sb16_ctl_line_play_vol = | 599 | SB16_INPUT_SW("Line Capture Route", |
| 626 | SB_DOUBLE("Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31); | 600 | SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 4, 3), |
| 627 | static struct sbmix_elem snd_sb16_ctl_mic_capture_route = | 601 | SB_DOUBLE("Line Playback Switch", |
| 628 | SB16_INPUT_SW("Mic Capture Route", SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, 0, 0); | 602 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3, 1), |
| 629 | static struct sbmix_elem snd_sb16_ctl_mic_play_switch = | 603 | SB_DOUBLE("Line Playback Volume", |
| 630 | SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1); | 604 | SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31), |
| 631 | static struct sbmix_elem snd_sb16_ctl_mic_play_vol = | 605 | SB_SINGLE("Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1), |
| 632 | SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31); | 606 | SB_SINGLE("3D Enhancement Switch", SB_DSP4_3DSE, 0, 1), |
| 633 | static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol = | 607 | SB_DOUBLE("Tone Control - Bass", |
| 634 | SB_SINGLE("PC Speaker Volume", SB_DSP4_SPEAKER_DEV, 6, 3); | 608 | SB_DSP4_BASS_DEV, (SB_DSP4_BASS_DEV + 1), 4, 4, 15), |
| 635 | static struct sbmix_elem snd_sb16_ctl_capture_vol = | 609 | SB_DOUBLE("Tone Control - Treble", |
| 636 | SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3); | 610 | SB_DSP4_TREBLE_DEV, (SB_DSP4_TREBLE_DEV + 1), 4, 4, 15) |
| 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 | ||
| 663 | }; | 611 | }; |
| 664 | 612 | ||
| 665 | static unsigned char snd_sb16_init_values[][2] = { | 613 | static unsigned char snd_sb16_init_values[][2] = { |
| @@ -678,46 +626,34 @@ static unsigned char snd_sb16_init_values[][2] = { | |||
| 678 | /* | 626 | /* |
| 679 | * DT019x specific mixer elements | 627 | * DT019x specific mixer elements |
| 680 | */ | 628 | */ |
| 681 | static struct sbmix_elem snd_dt019x_ctl_master_play_vol = | 629 | static struct sbmix_elem snd_dt019x_controls[] = { |
| 682 | SB_DOUBLE("Master Playback Volume", SB_DT019X_MASTER_DEV, SB_DT019X_MASTER_DEV, 4,0, 15); | 630 | /* ALS4000 below has some parts which we might be lacking, |
| 683 | static struct sbmix_elem snd_dt019x_ctl_pcm_play_vol = | 631 | * e.g. snd_als4000_ctl_mono_playback_switch - check it! */ |
| 684 | SB_DOUBLE("PCM Playback Volume", SB_DT019X_PCM_DEV, SB_DT019X_PCM_DEV, 4,0, 15); | 632 | SB_DOUBLE("Master Playback Volume", |
| 685 | static struct sbmix_elem snd_dt019x_ctl_synth_play_vol = | 633 | SB_DT019X_MASTER_DEV, SB_DT019X_MASTER_DEV, 4, 0, 15), |
| 686 | SB_DOUBLE("Synth Playback Volume", SB_DT019X_SYNTH_DEV, SB_DT019X_SYNTH_DEV, 4,0, 15); | 634 | SB_DOUBLE("PCM Playback Switch", |
| 687 | static struct sbmix_elem snd_dt019x_ctl_cd_play_vol = | 635 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2, 1, 1), |
| 688 | SB_DOUBLE("CD Playback Volume", SB_DT019X_CD_DEV, SB_DT019X_CD_DEV, 4,0, 15); | 636 | SB_DOUBLE("PCM Playback Volume", |
| 689 | static struct sbmix_elem snd_dt019x_ctl_mic_play_vol = | 637 | SB_DT019X_PCM_DEV, SB_DT019X_PCM_DEV, 4, 0, 15), |
| 690 | SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7); | 638 | SB_DOUBLE("Synth Playback Switch", |
| 691 | static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol = | 639 | SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4, 3, 1), |
| 692 | SB_SINGLE("PC Speaker Volume", SB_DT019X_SPKR_DEV, 0, 7); | 640 | SB_DOUBLE("Synth Playback Volume", |
| 693 | static struct sbmix_elem snd_dt019x_ctl_line_play_vol = | 641 | SB_DT019X_SYNTH_DEV, SB_DT019X_SYNTH_DEV, 4, 0, 15), |
| 694 | SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15); | 642 | SB_DOUBLE("CD Playback Switch", |
| 695 | static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch = | 643 | SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 2, 1, 1), |
| 696 | SB_DOUBLE("PCM Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 2,1, 1); | 644 | SB_DOUBLE("CD Playback Volume", |
| 697 | static struct sbmix_elem snd_dt019x_ctl_synth_play_switch = | 645 | SB_DT019X_CD_DEV, SB_DT019X_CD_DEV, 4, 0, 15), |
| 698 | SB_DOUBLE("Synth Playback Switch", SB_DT019X_OUTPUT_SW2, SB_DT019X_OUTPUT_SW2, 4,3, 1); | 646 | SB_SINGLE("Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), |
| 699 | static struct sbmix_elem snd_dt019x_ctl_capture_source = | 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), | ||
| 700 | { | 653 | { |
| 701 | .name = "Capture Source", | 654 | .name = "Capture Source", |
| 702 | .type = SB_MIX_CAPTURE_DT019X | 655 | .type = SB_MIX_CAPTURE_DT019X |
| 703 | }; | 656 | } |
| 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 | ||
| 721 | }; | 657 | }; |
| 722 | 658 | ||
| 723 | static unsigned char snd_dt019x_init_values[][2] = { | 659 | static unsigned char snd_dt019x_init_values[][2] = { |
| @@ -735,82 +671,37 @@ static unsigned char snd_dt019x_init_values[][2] = { | |||
| 735 | /* | 671 | /* |
| 736 | * ALS4000 specific mixer elements | 672 | * ALS4000 specific mixer elements |
| 737 | */ | 673 | */ |
| 738 | static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch = | 674 | static struct sbmix_elem snd_als4000_controls[] = { |
| 739 | SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1); | 675 | SB_DOUBLE("PCM Playback Switch", |
| 740 | static struct sbmix_elem snd_als4k_ctl_master_mono_capture_route = { | 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 | { | ||
| 741 | .name = "Master Mono Capture Route", | 682 | .name = "Master Mono Capture Route", |
| 742 | .type = SB_MIX_MONO_CAPTURE_ALS4K | 683 | .type = SB_MIX_MONO_CAPTURE_ALS4K |
| 743 | }; | 684 | }, |
| 744 | static struct sbmix_elem snd_als4000_ctl_mono_playback_switch = | 685 | SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1), |
| 745 | SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1); | 686 | SB_SINGLE("Analog Loopback Switch", SB_ALS4000_MIC_IN_GAIN, 7, 0x01), |
| 746 | static struct sbmix_elem snd_als4000_ctl_mic_20db_boost = | 687 | SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01), |
| 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 = | ||
| 751 | SB_SINGLE("Digital Loopback Switch", | 688 | SB_SINGLE("Digital Loopback Switch", |
| 752 | SB_ALS4000_CR3_CONFIGURATION, 7, 0x01); | 689 | SB_ALS4000_CR3_CONFIGURATION, 7, 0x01), |
| 753 | /* FIXME: functionality of 3D controls might be swapped, I didn't find | 690 | /* 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 */ | 691 | * a description of how to identify what is supposed to be what */ |
| 755 | static struct sbmix_elem snd_als4000_3d_control_switch = | 692 | SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07), |
| 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 = | ||
| 760 | /* FIXME: maybe there's actually some standard 3D ctrl name for it?? */ | 693 | /* 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); | 694 | SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03), |
| 762 | static struct sbmix_elem snd_als4000_3d_control_delay = | ||
| 763 | /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay, | 695 | /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay, |
| 764 | * but what ALSA 3D attribute is that actually? "Center", "Depth", | 696 | * but what ALSA 3D attribute is that actually? "Center", "Depth", |
| 765 | * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */ | 697 | * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */ |
| 766 | SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f); | 698 | SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f), |
| 767 | static struct sbmix_elem snd_als4000_3d_control_poweroff_switch = | 699 | SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01), |
| 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 = | ||
| 770 | SB_SINGLE("Master Playback 8kHz / 20kHz LPF Switch", | 700 | SB_SINGLE("Master Playback 8kHz / 20kHz LPF Switch", |
| 771 | SB_ALS4000_FMDAC, 5, 0x01); | 701 | SB_ALS4000_FMDAC, 5, 0x01), |
| 772 | #ifdef NOT_AVAILABLE | 702 | #ifdef NOT_AVAILABLE |
| 773 | static struct sbmix_elem snd_als4000_ctl_fmdac = | 703 | SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01), |
| 774 | SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01); | 704 | SB_SINGLE("QSound Mode", SB_ALS4000_QSOUND, 1, 0x1f), |
| 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, | ||
| 814 | #endif | 705 | #endif |
| 815 | }; | 706 | }; |
| 816 | 707 | ||
| @@ -829,11 +720,10 @@ static unsigned char snd_als4000_init_values[][2] = { | |||
| 829 | { SB_ALS4000_MIC_IN_GAIN, 0 }, | 720 | { SB_ALS4000_MIC_IN_GAIN, 0 }, |
| 830 | }; | 721 | }; |
| 831 | 722 | ||
| 832 | |||
| 833 | /* | 723 | /* |
| 834 | */ | 724 | */ |
| 835 | static int snd_sbmixer_init(struct snd_sb *chip, | 725 | static int snd_sbmixer_init(struct snd_sb *chip, |
| 836 | struct sbmix_elem **controls, | 726 | struct sbmix_elem *controls, |
| 837 | int controls_count, | 727 | int controls_count, |
| 838 | unsigned char map[][2], | 728 | unsigned char map[][2], |
| 839 | int map_count, | 729 | int map_count, |
| @@ -856,7 +746,8 @@ static int snd_sbmixer_init(struct snd_sb *chip, | |||
| 856 | } | 746 | } |
| 857 | 747 | ||
| 858 | for (idx = 0; idx < controls_count; idx++) { | 748 | 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) | ||
| 860 | return err; | 751 | return err; |
| 861 | } | 752 | } |
| 862 | snd_component_add(card, name); | 753 | snd_component_add(card, name); |
| @@ -888,6 +779,7 @@ int snd_sbmixer_new(struct snd_sb *chip) | |||
| 888 | return err; | 779 | return err; |
| 889 | break; | 780 | break; |
| 890 | case SB_HW_PRO: | 781 | case SB_HW_PRO: |
| 782 | case SB_HW_JAZZ16: | ||
| 891 | if ((err = snd_sbmixer_init(chip, | 783 | if ((err = snd_sbmixer_init(chip, |
| 892 | snd_sbpro_controls, | 784 | snd_sbpro_controls, |
| 893 | ARRAY_SIZE(snd_sbpro_controls), | 785 | ARRAY_SIZE(snd_sbpro_controls), |
| @@ -908,6 +800,15 @@ int snd_sbmixer_new(struct snd_sb *chip) | |||
| 908 | return err; | 800 | return err; |
| 909 | break; | 801 | break; |
| 910 | case SB_HW_ALS4000: | 802 | 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; | ||
| 911 | if ((err = snd_sbmixer_init(chip, | 812 | if ((err = snd_sbmixer_init(chip, |
| 912 | snd_als4000_controls, | 813 | snd_als4000_controls, |
| 913 | ARRAY_SIZE(snd_als4000_controls), | 814 | ARRAY_SIZE(snd_als4000_controls), |
| @@ -1029,6 +930,7 @@ void snd_sbmixer_suspend(struct snd_sb *chip) | |||
| 1029 | save_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); | 930 | save_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); |
| 1030 | break; | 931 | break; |
| 1031 | case SB_HW_PRO: | 932 | case SB_HW_PRO: |
| 933 | case SB_HW_JAZZ16: | ||
| 1032 | save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); | 934 | save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); |
| 1033 | break; | 935 | break; |
| 1034 | case SB_HW_16: | 936 | case SB_HW_16: |
| @@ -1055,6 +957,7 @@ void snd_sbmixer_resume(struct snd_sb *chip) | |||
| 1055 | restore_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); | 957 | restore_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); |
| 1056 | break; | 958 | break; |
| 1057 | case SB_HW_PRO: | 959 | case SB_HW_PRO: |
| 960 | case SB_HW_JAZZ16: | ||
| 1058 | restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); | 961 | restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); |
| 1059 | break; | 962 | break; |
| 1060 | case SB_HW_16: | 963 | case SB_HW_16: |
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 66187122377c..e2d5d2d3ed96 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Low-level ALSA driver for the ENSONIQ SoundScape PnP | 2 | * Low-level ALSA driver for the ENSONIQ SoundScape |
| 3 | * Copyright (c) by Chris Rankin | 3 | * Copyright (c) by Chris Rankin |
| 4 | * | 4 | * |
| 5 | * This driver was written in part using information obtained from | 5 | * This driver was written in part using information obtained from |
| @@ -25,31 +25,36 @@ | |||
| 25 | #include <linux/err.h> | 25 | #include <linux/err.h> |
| 26 | #include <linux/isa.h> | 26 | #include <linux/isa.h> |
| 27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
| 28 | #include <linux/firmware.h> | ||
| 28 | #include <linux/pnp.h> | 29 | #include <linux/pnp.h> |
| 29 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
| 30 | #include <linux/moduleparam.h> | 31 | #include <linux/moduleparam.h> |
| 31 | #include <asm/dma.h> | 32 | #include <asm/dma.h> |
| 32 | #include <sound/core.h> | 33 | #include <sound/core.h> |
| 33 | #include <sound/hwdep.h> | ||
| 34 | #include <sound/wss.h> | 34 | #include <sound/wss.h> |
| 35 | #include <sound/mpu401.h> | 35 | #include <sound/mpu401.h> |
| 36 | #include <sound/initval.h> | 36 | #include <sound/initval.h> |
| 37 | 37 | ||
| 38 | #include <sound/sscape_ioctl.h> | ||
| 39 | |||
| 40 | 38 | ||
| 41 | MODULE_AUTHOR("Chris Rankin"); | 39 | MODULE_AUTHOR("Chris Rankin"); |
| 42 | MODULE_DESCRIPTION("ENSONIQ SoundScape PnP driver"); | 40 | MODULE_DESCRIPTION("ENSONIQ SoundScape driver"); |
| 43 | MODULE_LICENSE("GPL"); | 41 | MODULE_LICENSE("GPL"); |
| 44 | 42 | MODULE_FIRMWARE("sndscape.co0"); | |
| 45 | static int index[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IDX; | 43 | MODULE_FIRMWARE("sndscape.co1"); |
| 46 | static char* id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_STR; | 44 | MODULE_FIRMWARE("sndscape.co2"); |
| 47 | static long port[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PORT; | 45 | MODULE_FIRMWARE("sndscape.co3"); |
| 48 | static long wss_port[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PORT; | 46 | MODULE_FIRMWARE("sndscape.co4"); |
| 49 | static int irq[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IRQ; | 47 | MODULE_FIRMWARE("scope.cod"); |
| 50 | static int mpu_irq[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IRQ; | 48 | |
| 51 | static int dma[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_DMA; | 49 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
| 52 | static int dma2[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_DMA; | 50 | static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
| 51 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
| 52 | static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; | ||
| 53 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
| 54 | static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; | ||
| 55 | static int dma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
| 56 | static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; | ||
| 57 | static bool joystick[SNDRV_CARDS]; | ||
| 53 | 58 | ||
| 54 | module_param_array(index, int, NULL, 0444); | 59 | module_param_array(index, int, NULL, 0444); |
| 55 | MODULE_PARM_DESC(index, "Index number for SoundScape soundcard"); | 60 | MODULE_PARM_DESC(index, "Index number for SoundScape soundcard"); |
| @@ -75,6 +80,9 @@ MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); | |||
| 75 | module_param_array(dma2, int, NULL, 0444); | 80 | module_param_array(dma2, int, NULL, 0444); |
| 76 | MODULE_PARM_DESC(dma2, "DMA2 # for SoundScape driver."); | 81 | MODULE_PARM_DESC(dma2, "DMA2 # for SoundScape driver."); |
| 77 | 82 | ||
| 83 | module_param_array(joystick, bool, NULL, 0444); | ||
| 84 | MODULE_PARM_DESC(joystick, "Enable gameport."); | ||
| 85 | |||
| 78 | #ifdef CONFIG_PNP | 86 | #ifdef CONFIG_PNP |
| 79 | static int isa_registered; | 87 | static int isa_registered; |
| 80 | static int pnp_registered; | 88 | static int pnp_registered; |
| @@ -101,14 +109,14 @@ MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids); | |||
| 101 | #define RX_READY 0x01 | 109 | #define RX_READY 0x01 |
| 102 | #define TX_READY 0x02 | 110 | #define TX_READY 0x02 |
| 103 | 111 | ||
| 104 | #define CMD_ACK 0x80 | 112 | #define CMD_ACK 0x80 |
| 105 | #define CMD_SET_MIDI_VOL 0x84 | 113 | #define CMD_SET_MIDI_VOL 0x84 |
| 106 | #define CMD_GET_MIDI_VOL 0x85 | 114 | #define CMD_GET_MIDI_VOL 0x85 |
| 107 | #define CMD_XXX_MIDI_VOL 0x86 | 115 | #define CMD_XXX_MIDI_VOL 0x86 |
| 108 | #define CMD_SET_EXTMIDI 0x8a | 116 | #define CMD_SET_EXTMIDI 0x8a |
| 109 | #define CMD_GET_EXTMIDI 0x8b | 117 | #define CMD_GET_EXTMIDI 0x8b |
| 110 | #define CMD_SET_MT32 0x8c | 118 | #define CMD_SET_MT32 0x8c |
| 111 | #define CMD_GET_MT32 0x8d | 119 | #define CMD_GET_MT32 0x8d |
| 112 | 120 | ||
| 113 | enum GA_REG { | 121 | enum GA_REG { |
| 114 | GA_INTSTAT_REG = 0, | 122 | GA_INTSTAT_REG = 0, |
| @@ -127,7 +135,8 @@ enum GA_REG { | |||
| 127 | 135 | ||
| 128 | 136 | ||
| 129 | enum card_type { | 137 | enum card_type { |
| 130 | SSCAPE, | 138 | MEDIA_FX, /* Sequoia S-1000 */ |
| 139 | SSCAPE, /* Sequoia S-2000 */ | ||
| 131 | SSCAPE_PNP, | 140 | SSCAPE_PNP, |
| 132 | SSCAPE_VIVO, | 141 | SSCAPE_VIVO, |
| 133 | }; | 142 | }; |
| @@ -140,16 +149,7 @@ struct soundscape { | |||
| 140 | struct resource *io_res; | 149 | struct resource *io_res; |
| 141 | struct resource *wss_res; | 150 | struct resource *wss_res; |
| 142 | struct snd_wss *chip; | 151 | struct snd_wss *chip; |
| 143 | struct snd_mpu401 *mpu; | ||
| 144 | struct snd_hwdep *hw; | ||
| 145 | 152 | ||
| 146 | /* | ||
| 147 | * The MIDI device won't work until we've loaded | ||
| 148 | * its firmware via a hardware-dependent device IOCTL | ||
| 149 | */ | ||
| 150 | spinlock_t fwlock; | ||
| 151 | int hw_in_use; | ||
| 152 | unsigned long midi_usage; | ||
| 153 | unsigned char midi_vol; | 153 | unsigned char midi_vol; |
| 154 | }; | 154 | }; |
| 155 | 155 | ||
| @@ -161,28 +161,21 @@ static inline struct soundscape *get_card_soundscape(struct snd_card *c) | |||
| 161 | return (struct soundscape *) (c->private_data); | 161 | return (struct soundscape *) (c->private_data); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | static inline struct soundscape *get_mpu401_soundscape(struct snd_mpu401 * mpu) | ||
| 165 | { | ||
| 166 | return (struct soundscape *) (mpu->private_data); | ||
| 167 | } | ||
| 168 | |||
| 169 | static inline struct soundscape *get_hwdep_soundscape(struct snd_hwdep * hw) | ||
| 170 | { | ||
| 171 | return (struct soundscape *) (hw->private_data); | ||
| 172 | } | ||
| 173 | |||
| 174 | |||
| 175 | /* | 164 | /* |
| 176 | * Allocates some kernel memory that we can use for DMA. | 165 | * Allocates some kernel memory that we can use for DMA. |
| 177 | * I think this means that the memory has to map to | 166 | * I think this means that the memory has to map to |
| 178 | * contiguous pages of physical memory. | 167 | * contiguous pages of physical memory. |
| 179 | */ | 168 | */ |
| 180 | static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, unsigned long size) | 169 | static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, |
| 170 | unsigned long size) | ||
| 181 | { | 171 | { |
| 182 | if (buf) { | 172 | if (buf) { |
| 183 | if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), | 173 | if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, |
| 174 | snd_dma_isa_data(), | ||
| 184 | size, buf) < 0) { | 175 | size, buf) < 0) { |
| 185 | snd_printk(KERN_ERR "sscape: Failed to allocate %lu bytes for DMA\n", size); | 176 | snd_printk(KERN_ERR "sscape: Failed to allocate " |
| 177 | "%lu bytes for DMA\n", | ||
| 178 | size); | ||
| 186 | return NULL; | 179 | return NULL; |
| 187 | } | 180 | } |
| 188 | } | 181 | } |
| @@ -199,13 +192,13 @@ static void free_dmabuf(struct snd_dma_buffer *buf) | |||
| 199 | snd_dma_free_pages(buf); | 192 | snd_dma_free_pages(buf); |
| 200 | } | 193 | } |
| 201 | 194 | ||
| 202 | |||
| 203 | /* | 195 | /* |
| 204 | * This function writes to the SoundScape's control registers, | 196 | * This function writes to the SoundScape's control registers, |
| 205 | * but doesn't do any locking. It's up to the caller to do that. | 197 | * but doesn't do any locking. It's up to the caller to do that. |
| 206 | * This is why this function is "unsafe" ... | 198 | * This is why this function is "unsafe" ... |
| 207 | */ | 199 | */ |
| 208 | static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsigned char val) | 200 | static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, |
| 201 | unsigned char val) | ||
| 209 | { | 202 | { |
| 210 | outb(reg, ODIE_ADDR_IO(io_base)); | 203 | outb(reg, ODIE_ADDR_IO(io_base)); |
| 211 | outb(val, ODIE_DATA_IO(io_base)); | 204 | outb(val, ODIE_DATA_IO(io_base)); |
| @@ -215,7 +208,8 @@ static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsign | |||
| 215 | * Write to the SoundScape's control registers, and do the | 208 | * Write to the SoundScape's control registers, and do the |
| 216 | * necessary locking ... | 209 | * necessary locking ... |
| 217 | */ | 210 | */ |
| 218 | static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char val) | 211 | static void sscape_write(struct soundscape *s, enum GA_REG reg, |
| 212 | unsigned char val) | ||
| 219 | { | 213 | { |
| 220 | unsigned long flags; | 214 | unsigned long flags; |
| 221 | 215 | ||
| @@ -228,7 +222,8 @@ static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char va | |||
| 228 | * Read from the SoundScape's control registers, but leave any | 222 | * Read from the SoundScape's control registers, but leave any |
| 229 | * locking to the caller. This is why the function is "unsafe" ... | 223 | * locking to the caller. This is why the function is "unsafe" ... |
| 230 | */ | 224 | */ |
| 231 | static inline unsigned char sscape_read_unsafe(unsigned io_base, enum GA_REG reg) | 225 | static inline unsigned char sscape_read_unsafe(unsigned io_base, |
| 226 | enum GA_REG reg) | ||
| 232 | { | 227 | { |
| 233 | outb(reg, ODIE_ADDR_IO(io_base)); | 228 | outb(reg, ODIE_ADDR_IO(io_base)); |
| 234 | return inb(ODIE_DATA_IO(io_base)); | 229 | return inb(ODIE_DATA_IO(io_base)); |
| @@ -257,9 +252,8 @@ static inline void set_midi_mode_unsafe(unsigned io_base) | |||
| 257 | static inline int host_read_unsafe(unsigned io_base) | 252 | static inline int host_read_unsafe(unsigned io_base) |
| 258 | { | 253 | { |
| 259 | int data = -1; | 254 | int data = -1; |
| 260 | if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0) { | 255 | if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0) |
| 261 | data = inb(HOST_DATA_IO(io_base)); | 256 | data = inb(HOST_DATA_IO(io_base)); |
| 262 | } | ||
| 263 | 257 | ||
| 264 | return data; | 258 | return data; |
| 265 | } | 259 | } |
| @@ -301,7 +295,7 @@ static inline int host_write_unsafe(unsigned io_base, unsigned char data) | |||
| 301 | * Also leaves all locking-issues to the caller ... | 295 | * Also leaves all locking-issues to the caller ... |
| 302 | */ | 296 | */ |
| 303 | static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, | 297 | static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, |
| 304 | unsigned timeout) | 298 | unsigned timeout) |
| 305 | { | 299 | { |
| 306 | int err; | 300 | int err; |
| 307 | 301 | ||
| @@ -320,7 +314,7 @@ static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, | |||
| 320 | * | 314 | * |
| 321 | * NOTE: This check is based upon observation, not documentation. | 315 | * NOTE: This check is based upon observation, not documentation. |
| 322 | */ | 316 | */ |
| 323 | static inline int verify_mpu401(const struct snd_mpu401 * mpu) | 317 | static inline int verify_mpu401(const struct snd_mpu401 *mpu) |
| 324 | { | 318 | { |
| 325 | return ((inb(MPU401C(mpu)) & 0xc0) == 0x80); | 319 | return ((inb(MPU401C(mpu)) & 0xc0) == 0x80); |
| 326 | } | 320 | } |
| @@ -328,7 +322,7 @@ static inline int verify_mpu401(const struct snd_mpu401 * mpu) | |||
| 328 | /* | 322 | /* |
| 329 | * This is apparently the standard way to initailise an MPU-401 | 323 | * This is apparently the standard way to initailise an MPU-401 |
| 330 | */ | 324 | */ |
| 331 | static inline void initialise_mpu401(const struct snd_mpu401 * mpu) | 325 | static inline void initialise_mpu401(const struct snd_mpu401 *mpu) |
| 332 | { | 326 | { |
| 333 | outb(0, MPU401D(mpu)); | 327 | outb(0, MPU401D(mpu)); |
| 334 | } | 328 | } |
| @@ -338,9 +332,10 @@ static inline void initialise_mpu401(const struct snd_mpu401 * mpu) | |||
| 338 | * The AD1845 detection fails if we *don't* do this, so I | 332 | * The AD1845 detection fails if we *don't* do this, so I |
| 339 | * think that this is a good idea ... | 333 | * think that this is a good idea ... |
| 340 | */ | 334 | */ |
| 341 | static inline void activate_ad1845_unsafe(unsigned io_base) | 335 | static void activate_ad1845_unsafe(unsigned io_base) |
| 342 | { | 336 | { |
| 343 | sscape_write_unsafe(io_base, GA_HMCTL_REG, (sscape_read_unsafe(io_base, GA_HMCTL_REG) & 0xcf) | 0x10); | 337 | unsigned char val = sscape_read_unsafe(io_base, GA_HMCTL_REG); |
| 338 | sscape_write_unsafe(io_base, GA_HMCTL_REG, (val & 0xcf) | 0x10); | ||
| 344 | sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80); | 339 | sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80); |
| 345 | } | 340 | } |
| 346 | 341 | ||
| @@ -359,24 +354,27 @@ static void soundscape_free(struct snd_card *c) | |||
| 359 | * Tell the SoundScape to begin a DMA tranfer using the given channel. | 354 | * Tell the SoundScape to begin a DMA tranfer using the given channel. |
| 360 | * All locking issues are left to the caller. | 355 | * All locking issues are left to the caller. |
| 361 | */ | 356 | */ |
| 362 | static inline void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg) | 357 | static void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg) |
| 363 | { | 358 | { |
| 364 | sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) | 0x01); | 359 | sscape_write_unsafe(io_base, reg, |
| 365 | sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) & 0xfe); | 360 | sscape_read_unsafe(io_base, reg) | 0x01); |
| 361 | sscape_write_unsafe(io_base, reg, | ||
| 362 | sscape_read_unsafe(io_base, reg) & 0xfe); | ||
| 366 | } | 363 | } |
| 367 | 364 | ||
| 368 | /* | 365 | /* |
| 369 | * Wait for a DMA transfer to complete. This is a "limited busy-wait", | 366 | * Wait for a DMA transfer to complete. This is a "limited busy-wait", |
| 370 | * and all locking issues are left to the caller. | 367 | * and all locking issues are left to the caller. |
| 371 | */ | 368 | */ |
| 372 | static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, unsigned timeout) | 369 | static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, |
| 370 | unsigned timeout) | ||
| 373 | { | 371 | { |
| 374 | while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) { | 372 | while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) { |
| 375 | udelay(100); | 373 | udelay(100); |
| 376 | --timeout; | 374 | --timeout; |
| 377 | } /* while */ | 375 | } /* while */ |
| 378 | 376 | ||
| 379 | return (sscape_read_unsafe(io_base, reg) & 0x01); | 377 | return sscape_read_unsafe(io_base, reg) & 0x01; |
| 380 | } | 378 | } |
| 381 | 379 | ||
| 382 | /* | 380 | /* |
| @@ -392,12 +390,12 @@ static int obp_startup_ack(struct soundscape *s, unsigned timeout) | |||
| 392 | 390 | ||
| 393 | do { | 391 | do { |
| 394 | unsigned long flags; | 392 | unsigned long flags; |
| 395 | unsigned char x; | 393 | int x; |
| 396 | 394 | ||
| 397 | spin_lock_irqsave(&s->lock, flags); | 395 | spin_lock_irqsave(&s->lock, flags); |
| 398 | x = inb(HOST_DATA_IO(s->io_base)); | 396 | x = host_read_unsafe(s->io_base); |
| 399 | spin_unlock_irqrestore(&s->lock, flags); | 397 | spin_unlock_irqrestore(&s->lock, flags); |
| 400 | if ((x & 0xfe) == 0xfe) | 398 | if (x == 0xfe || x == 0xff) |
| 401 | return 1; | 399 | return 1; |
| 402 | 400 | ||
| 403 | msleep(10); | 401 | msleep(10); |
| @@ -419,10 +417,10 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout) | |||
| 419 | 417 | ||
| 420 | do { | 418 | do { |
| 421 | unsigned long flags; | 419 | unsigned long flags; |
| 422 | unsigned char x; | 420 | int x; |
| 423 | 421 | ||
| 424 | spin_lock_irqsave(&s->lock, flags); | 422 | spin_lock_irqsave(&s->lock, flags); |
| 425 | x = inb(HOST_DATA_IO(s->io_base)); | 423 | x = host_read_unsafe(s->io_base); |
| 426 | spin_unlock_irqrestore(&s->lock, flags); | 424 | spin_unlock_irqrestore(&s->lock, flags); |
| 427 | if (x == 0xfe) | 425 | if (x == 0xfe) |
| 428 | return 1; | 426 | return 1; |
| @@ -436,15 +434,15 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout) | |||
| 436 | /* | 434 | /* |
| 437 | * Upload a byte-stream into the SoundScape using DMA channel A. | 435 | * Upload a byte-stream into the SoundScape using DMA channel A. |
| 438 | */ | 436 | */ |
| 439 | static int upload_dma_data(struct soundscape *s, | 437 | static int upload_dma_data(struct soundscape *s, const unsigned char *data, |
| 440 | const unsigned char __user *data, | 438 | size_t size) |
| 441 | size_t size) | ||
| 442 | { | 439 | { |
| 443 | unsigned long flags; | 440 | unsigned long flags; |
| 444 | struct snd_dma_buffer dma; | 441 | struct snd_dma_buffer dma; |
| 445 | int ret; | 442 | int ret; |
| 443 | unsigned char val; | ||
| 446 | 444 | ||
| 447 | if (!get_dmabuf(&dma, PAGE_ALIGN(size))) | 445 | if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024))) |
| 448 | return -ENOMEM; | 446 | return -ENOMEM; |
| 449 | 447 | ||
| 450 | spin_lock_irqsave(&s->lock, flags); | 448 | spin_lock_irqsave(&s->lock, flags); |
| @@ -452,70 +450,57 @@ static int upload_dma_data(struct soundscape *s, | |||
| 452 | /* | 450 | /* |
| 453 | * Reset the board ... | 451 | * Reset the board ... |
| 454 | */ | 452 | */ |
| 455 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f); | 453 | val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); |
| 454 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val & 0x3f); | ||
| 456 | 455 | ||
| 457 | /* | 456 | /* |
| 458 | * Enable the DMA channels and configure them ... | 457 | * Enable the DMA channels and configure them ... |
| 459 | */ | 458 | */ |
| 460 | sscape_write_unsafe(s->io_base, GA_DMACFG_REG, 0x50); | 459 | val = (s->chip->dma1 << 4) | DMA_8BIT; |
| 461 | sscape_write_unsafe(s->io_base, GA_DMAA_REG, (s->chip->dma1 << 4) | DMA_8BIT); | 460 | sscape_write_unsafe(s->io_base, GA_DMAA_REG, val); |
| 462 | sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20); | 461 | sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20); |
| 463 | 462 | ||
| 464 | /* | 463 | /* |
| 465 | * Take the board out of reset ... | 464 | * Take the board out of reset ... |
| 466 | */ | 465 | */ |
| 467 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x80); | 466 | val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); |
| 467 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x80); | ||
| 468 | 468 | ||
| 469 | /* | 469 | /* |
| 470 | * Upload the user's data (firmware?) to the SoundScape | 470 | * Upload the firmware to the SoundScape |
| 471 | * board through the DMA channel ... | 471 | * board through the DMA channel ... |
| 472 | */ | 472 | */ |
| 473 | while (size != 0) { | 473 | while (size != 0) { |
| 474 | unsigned long len; | 474 | unsigned long len; |
| 475 | 475 | ||
| 476 | /* | ||
| 477 | * Apparently, copying to/from userspace can sleep. | ||
| 478 | * We are therefore forbidden from holding any | ||
| 479 | * spinlocks while we copy ... | ||
| 480 | */ | ||
| 481 | spin_unlock_irqrestore(&s->lock, flags); | ||
| 482 | |||
| 483 | /* | ||
| 484 | * Remember that the data that we want to DMA | ||
| 485 | * comes from USERSPACE. We have already verified | ||
| 486 | * the userspace pointer ... | ||
| 487 | */ | ||
| 488 | len = min(size, dma.bytes); | 476 | len = min(size, dma.bytes); |
| 489 | len -= __copy_from_user(dma.area, data, len); | 477 | memcpy(dma.area, data, len); |
| 490 | data += len; | 478 | data += len; |
| 491 | size -= len; | 479 | size -= len; |
| 492 | 480 | ||
| 493 | /* | ||
| 494 | * Grab that spinlock again, now that we've | ||
| 495 | * finished copying! | ||
| 496 | */ | ||
| 497 | spin_lock_irqsave(&s->lock, flags); | ||
| 498 | |||
| 499 | snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE); | 481 | snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE); |
| 500 | sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG); | 482 | sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG); |
| 501 | if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) { | 483 | if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) { |
| 502 | /* | 484 | /* |
| 503 | * Don't forget to release this spinlock we're holding ... | 485 | * Don't forget to release this spinlock we're holding |
| 504 | */ | 486 | */ |
| 505 | spin_unlock_irqrestore(&s->lock, flags); | 487 | spin_unlock_irqrestore(&s->lock, flags); |
| 506 | 488 | ||
| 507 | snd_printk(KERN_ERR "sscape: DMA upload has timed out\n"); | 489 | snd_printk(KERN_ERR |
| 490 | "sscape: DMA upload has timed out\n"); | ||
| 508 | ret = -EAGAIN; | 491 | ret = -EAGAIN; |
| 509 | goto _release_dma; | 492 | goto _release_dma; |
| 510 | } | 493 | } |
| 511 | } /* while */ | 494 | } /* while */ |
| 512 | 495 | ||
| 513 | set_host_mode_unsafe(s->io_base); | 496 | set_host_mode_unsafe(s->io_base); |
| 497 | outb(0x0, s->io_base); | ||
| 514 | 498 | ||
| 515 | /* | 499 | /* |
| 516 | * Boot the board ... (I think) | 500 | * Boot the board ... (I think) |
| 517 | */ | 501 | */ |
| 518 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x40); | 502 | val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); |
| 503 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x40); | ||
| 519 | spin_unlock_irqrestore(&s->lock, flags); | 504 | spin_unlock_irqrestore(&s->lock, flags); |
| 520 | 505 | ||
| 521 | /* | 506 | /* |
| @@ -525,10 +510,12 @@ static int upload_dma_data(struct soundscape *s, | |||
| 525 | */ | 510 | */ |
| 526 | ret = 0; | 511 | ret = 0; |
| 527 | if (!obp_startup_ack(s, 5000)) { | 512 | if (!obp_startup_ack(s, 5000)) { |
| 528 | snd_printk(KERN_ERR "sscape: No response from on-board processor after upload\n"); | 513 | snd_printk(KERN_ERR "sscape: No response " |
| 514 | "from on-board processor after upload\n"); | ||
| 529 | ret = -EAGAIN; | 515 | ret = -EAGAIN; |
| 530 | } else if (!host_startup_ack(s, 5000)) { | 516 | } else if (!host_startup_ack(s, 5000)) { |
| 531 | snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n"); | 517 | snd_printk(KERN_ERR |
| 518 | "sscape: SoundScape failed to initialise\n"); | ||
| 532 | ret = -EAGAIN; | 519 | ret = -EAGAIN; |
| 533 | } | 520 | } |
| 534 | 521 | ||
| @@ -536,7 +523,7 @@ _release_dma: | |||
| 536 | /* | 523 | /* |
| 537 | * NOTE!!! We are NOT holding any spinlocks at this point !!! | 524 | * NOTE!!! We are NOT holding any spinlocks at this point !!! |
| 538 | */ | 525 | */ |
| 539 | sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_ODIE ? 0x70 : 0x40)); | 526 | sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_OPUS ? 0x40 : 0x70)); |
| 540 | free_dmabuf(&dma); | 527 | free_dmabuf(&dma); |
| 541 | 528 | ||
| 542 | return ret; | 529 | return ret; |
| @@ -546,167 +533,76 @@ _release_dma: | |||
| 546 | * Upload the bootblock(?) into the SoundScape. The only | 533 | * Upload the bootblock(?) into the SoundScape. The only |
| 547 | * purpose of this block of code seems to be to tell | 534 | * purpose of this block of code seems to be to tell |
| 548 | * us which version of the microcode we should be using. | 535 | * us which version of the microcode we should be using. |
| 549 | * | ||
| 550 | * NOTE: The boot-block data resides in USER-SPACE!!! | ||
| 551 | * However, we have already verified its memory | ||
| 552 | * addresses by the time we get here. | ||
| 553 | */ | 536 | */ |
| 554 | static int sscape_upload_bootblock(struct soundscape *sscape, struct sscape_bootblock __user *bb) | 537 | static int sscape_upload_bootblock(struct snd_card *card) |
| 555 | { | 538 | { |
| 539 | struct soundscape *sscape = get_card_soundscape(card); | ||
| 556 | unsigned long flags; | 540 | unsigned long flags; |
| 541 | const struct firmware *init_fw = NULL; | ||
| 557 | int data = 0; | 542 | int data = 0; |
| 558 | int ret; | 543 | int ret; |
| 559 | 544 | ||
| 560 | ret = upload_dma_data(sscape, bb->code, sizeof(bb->code)); | 545 | ret = request_firmware(&init_fw, "scope.cod", card->dev); |
| 561 | 546 | if (ret < 0) { | |
| 562 | spin_lock_irqsave(&sscape->lock, flags); | 547 | snd_printk(KERN_ERR "sscape: Error loading scope.cod"); |
| 563 | if (ret == 0) { | 548 | return ret; |
| 564 | data = host_read_ctrl_unsafe(sscape->io_base, 100); | ||
| 565 | } | ||
| 566 | set_midi_mode_unsafe(sscape->io_base); | ||
| 567 | spin_unlock_irqrestore(&sscape->lock, flags); | ||
| 568 | |||
| 569 | if (ret == 0) { | ||
| 570 | if (data < 0) { | ||
| 571 | snd_printk(KERN_ERR "sscape: timeout reading firmware version\n"); | ||
| 572 | ret = -EAGAIN; | ||
| 573 | } | ||
| 574 | else if (__copy_to_user(&bb->version, &data, sizeof(bb->version))) { | ||
| 575 | ret = -EFAULT; | ||
| 576 | } | ||
| 577 | } | 549 | } |
| 550 | ret = upload_dma_data(sscape, init_fw->data, init_fw->size); | ||
| 578 | 551 | ||
| 579 | return ret; | 552 | release_firmware(init_fw); |
| 580 | } | ||
| 581 | |||
| 582 | /* | ||
| 583 | * Upload the microcode into the SoundScape. The | ||
| 584 | * microcode is 64K of data, and if we try to copy | ||
| 585 | * it into a local variable then we will SMASH THE | ||
| 586 | * KERNEL'S STACK! We therefore leave it in USER | ||
| 587 | * SPACE, and save ourselves from copying it at all. | ||
| 588 | */ | ||
| 589 | static int sscape_upload_microcode(struct soundscape *sscape, | ||
| 590 | const struct sscape_microcode __user *mc) | ||
| 591 | { | ||
| 592 | unsigned long flags; | ||
| 593 | char __user *code; | ||
| 594 | int err; | ||
| 595 | 553 | ||
| 596 | /* | 554 | spin_lock_irqsave(&sscape->lock, flags); |
| 597 | * We are going to have to copy this data into a special | 555 | if (ret == 0) |
| 598 | * DMA-able buffer before we can upload it. We shall therefore | 556 | data = host_read_ctrl_unsafe(sscape->io_base, 100); |
| 599 | * just check that the data pointer is valid for now. | ||
| 600 | * | ||
| 601 | * NOTE: This buffer is 64K long! That's WAY too big to | ||
| 602 | * copy into a stack-temporary anyway. | ||
| 603 | */ | ||
| 604 | if ( get_user(code, &mc->code) || | ||
| 605 | !access_ok(VERIFY_READ, code, SSCAPE_MICROCODE_SIZE) ) | ||
| 606 | return -EFAULT; | ||
| 607 | 557 | ||
| 608 | if ((err = upload_dma_data(sscape, code, SSCAPE_MICROCODE_SIZE)) == 0) { | 558 | if (data & 0x10) |
| 609 | snd_printk(KERN_INFO "sscape: MIDI firmware loaded\n"); | 559 | sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2f); |
| 610 | } | ||
| 611 | 560 | ||
| 612 | spin_lock_irqsave(&sscape->lock, flags); | ||
| 613 | set_midi_mode_unsafe(sscape->io_base); | ||
| 614 | spin_unlock_irqrestore(&sscape->lock, flags); | 561 | spin_unlock_irqrestore(&sscape->lock, flags); |
| 615 | 562 | ||
| 616 | initialise_mpu401(sscape->mpu); | 563 | data &= 0xf; |
| 564 | if (ret == 0 && data > 7) { | ||
| 565 | snd_printk(KERN_ERR | ||
| 566 | "sscape: timeout reading firmware version\n"); | ||
| 567 | ret = -EAGAIN; | ||
| 568 | } | ||
| 617 | 569 | ||
| 618 | return err; | 570 | return (ret == 0) ? data : ret; |
| 619 | } | 571 | } |
| 620 | 572 | ||
| 621 | /* | 573 | /* |
| 622 | * Hardware-specific device functions, to implement special | 574 | * Upload the microcode into the SoundScape. |
| 623 | * IOCTLs for the SoundScape card. This is how we upload | ||
| 624 | * the microcode into the card, for example, and so we | ||
| 625 | * must ensure that no two processes can open this device | ||
| 626 | * simultaneously, and that we can't open it at all if | ||
| 627 | * someone is using the MIDI device. | ||
| 628 | */ | 575 | */ |
| 629 | static int sscape_hw_open(struct snd_hwdep * hw, struct file *file) | 576 | static int sscape_upload_microcode(struct snd_card *card, int version) |
| 630 | { | 577 | { |
| 631 | register struct soundscape *sscape = get_hwdep_soundscape(hw); | 578 | struct soundscape *sscape = get_card_soundscape(card); |
| 632 | unsigned long flags; | 579 | const struct firmware *init_fw = NULL; |
| 580 | char name[14]; | ||
| 633 | int err; | 581 | int err; |
| 634 | 582 | ||
| 635 | spin_lock_irqsave(&sscape->fwlock, flags); | 583 | snprintf(name, sizeof(name), "sndscape.co%d", version); |
| 636 | 584 | ||
| 637 | if ((sscape->midi_usage != 0) || sscape->hw_in_use) { | 585 | err = request_firmware(&init_fw, name, card->dev); |
| 638 | err = -EBUSY; | 586 | if (err < 0) { |
| 639 | } else { | 587 | snd_printk(KERN_ERR "sscape: Error loading sndscape.co%d", |
| 640 | sscape->hw_in_use = 1; | 588 | version); |
| 641 | err = 0; | 589 | return err; |
| 642 | } | 590 | } |
| 591 | err = upload_dma_data(sscape, init_fw->data, init_fw->size); | ||
| 592 | if (err == 0) | ||
| 593 | snd_printk(KERN_INFO "sscape: MIDI firmware loaded %d KBs\n", | ||
| 594 | init_fw->size >> 10); | ||
| 643 | 595 | ||
| 644 | spin_unlock_irqrestore(&sscape->fwlock, flags); | 596 | release_firmware(init_fw); |
| 645 | return err; | ||
| 646 | } | ||
| 647 | |||
| 648 | static int sscape_hw_release(struct snd_hwdep * hw, struct file *file) | ||
| 649 | { | ||
| 650 | register struct soundscape *sscape = get_hwdep_soundscape(hw); | ||
| 651 | unsigned long flags; | ||
| 652 | |||
| 653 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
| 654 | sscape->hw_in_use = 0; | ||
| 655 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
| 656 | return 0; | ||
| 657 | } | ||
| 658 | |||
| 659 | static int sscape_hw_ioctl(struct snd_hwdep * hw, struct file *file, | ||
| 660 | unsigned int cmd, unsigned long arg) | ||
| 661 | { | ||
| 662 | struct soundscape *sscape = get_hwdep_soundscape(hw); | ||
| 663 | int err = -EBUSY; | ||
| 664 | |||
| 665 | switch (cmd) { | ||
| 666 | case SND_SSCAPE_LOAD_BOOTB: | ||
| 667 | { | ||
| 668 | register struct sscape_bootblock __user *bb = (struct sscape_bootblock __user *) arg; | ||
| 669 | |||
| 670 | /* | ||
| 671 | * We are going to have to copy this data into a special | ||
| 672 | * DMA-able buffer before we can upload it. We shall therefore | ||
| 673 | * just check that the data pointer is valid for now ... | ||
| 674 | */ | ||
| 675 | if ( !access_ok(VERIFY_READ, bb->code, sizeof(bb->code)) ) | ||
| 676 | return -EFAULT; | ||
| 677 | |||
| 678 | /* | ||
| 679 | * Now check that we can write the firmware version number too... | ||
| 680 | */ | ||
| 681 | if ( !access_ok(VERIFY_WRITE, &bb->version, sizeof(bb->version)) ) | ||
| 682 | return -EFAULT; | ||
| 683 | |||
| 684 | err = sscape_upload_bootblock(sscape, bb); | ||
| 685 | } | ||
| 686 | break; | ||
| 687 | |||
| 688 | case SND_SSCAPE_LOAD_MCODE: | ||
| 689 | { | ||
| 690 | register const struct sscape_microcode __user *mc = (const struct sscape_microcode __user *) arg; | ||
| 691 | |||
| 692 | err = sscape_upload_microcode(sscape, mc); | ||
| 693 | } | ||
| 694 | break; | ||
| 695 | |||
| 696 | default: | ||
| 697 | err = -EINVAL; | ||
| 698 | break; | ||
| 699 | } /* switch */ | ||
| 700 | 597 | ||
| 701 | return err; | 598 | return err; |
| 702 | } | 599 | } |
| 703 | 600 | ||
| 704 | |||
| 705 | /* | 601 | /* |
| 706 | * Mixer control for the SoundScape's MIDI device. | 602 | * Mixer control for the SoundScape's MIDI device. |
| 707 | */ | 603 | */ |
| 708 | static int sscape_midi_info(struct snd_kcontrol *ctl, | 604 | static int sscape_midi_info(struct snd_kcontrol *ctl, |
| 709 | struct snd_ctl_elem_info *uinfo) | 605 | struct snd_ctl_elem_info *uinfo) |
| 710 | { | 606 | { |
| 711 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 607 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
| 712 | uinfo->count = 1; | 608 | uinfo->count = 1; |
| @@ -716,7 +612,7 @@ static int sscape_midi_info(struct snd_kcontrol *ctl, | |||
| 716 | } | 612 | } |
| 717 | 613 | ||
| 718 | static int sscape_midi_get(struct snd_kcontrol *kctl, | 614 | static int sscape_midi_get(struct snd_kcontrol *kctl, |
| 719 | struct snd_ctl_elem_value *uctl) | 615 | struct snd_ctl_elem_value *uctl) |
| 720 | { | 616 | { |
| 721 | struct snd_wss *chip = snd_kcontrol_chip(kctl); | 617 | struct snd_wss *chip = snd_kcontrol_chip(kctl); |
| 722 | struct snd_card *card = chip->card; | 618 | struct snd_card *card = chip->card; |
| @@ -730,16 +626,18 @@ static int sscape_midi_get(struct snd_kcontrol *kctl, | |||
| 730 | } | 626 | } |
| 731 | 627 | ||
| 732 | static int sscape_midi_put(struct snd_kcontrol *kctl, | 628 | static int sscape_midi_put(struct snd_kcontrol *kctl, |
| 733 | struct snd_ctl_elem_value *uctl) | 629 | struct snd_ctl_elem_value *uctl) |
| 734 | { | 630 | { |
| 735 | struct snd_wss *chip = snd_kcontrol_chip(kctl); | 631 | struct snd_wss *chip = snd_kcontrol_chip(kctl); |
| 736 | struct snd_card *card = chip->card; | 632 | struct snd_card *card = chip->card; |
| 737 | register struct soundscape *s = get_card_soundscape(card); | 633 | struct soundscape *s = get_card_soundscape(card); |
| 738 | unsigned long flags; | 634 | unsigned long flags; |
| 739 | int change; | 635 | int change; |
| 636 | unsigned char new_val; | ||
| 740 | 637 | ||
| 741 | spin_lock_irqsave(&s->lock, flags); | 638 | spin_lock_irqsave(&s->lock, flags); |
| 742 | 639 | ||
| 640 | new_val = uctl->value.integer.value[0] & 127; | ||
| 743 | /* | 641 | /* |
| 744 | * We need to put the board into HOST mode before we | 642 | * We need to put the board into HOST mode before we |
| 745 | * can send any volume-changing HOST commands ... | 643 | * can send any volume-changing HOST commands ... |
| @@ -752,15 +650,16 @@ static int sscape_midi_put(struct snd_kcontrol *kctl, | |||
| 752 | * and then perform another volume-related command. Perhaps the | 650 | * and then perform another volume-related command. Perhaps the |
| 753 | * first command is an "open" and the second command is a "close"? | 651 | * first command is an "open" and the second command is a "close"? |
| 754 | */ | 652 | */ |
| 755 | if (s->midi_vol == ((unsigned char) uctl->value.integer. value[0] & 127)) { | 653 | if (s->midi_vol == new_val) { |
| 756 | change = 0; | 654 | change = 0; |
| 757 | goto __skip_change; | 655 | goto __skip_change; |
| 758 | } | 656 | } |
| 759 | change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100) | 657 | change = host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100) |
| 760 | && host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100) | 658 | && host_write_ctrl_unsafe(s->io_base, new_val, 100) |
| 761 | && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100)); | 659 | && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100) |
| 762 | s->midi_vol = (unsigned char) uctl->value.integer.value[0] & 127; | 660 | && host_write_ctrl_unsafe(s->io_base, new_val, 100); |
| 763 | __skip_change: | 661 | s->midi_vol = new_val; |
| 662 | __skip_change: | ||
| 764 | 663 | ||
| 765 | /* | 664 | /* |
| 766 | * Take the board out of HOST mode and back into MIDI mode ... | 665 | * Take the board out of HOST mode and back into MIDI mode ... |
| @@ -784,20 +683,25 @@ static struct snd_kcontrol_new midi_mixer_ctl = { | |||
| 784 | * These IRQs are encoded as bit patterns so that they can be | 683 | * These IRQs are encoded as bit patterns so that they can be |
| 785 | * written to the control registers. | 684 | * written to the control registers. |
| 786 | */ | 685 | */ |
| 787 | static unsigned __devinit get_irq_config(int irq) | 686 | static unsigned __devinit get_irq_config(int sscape_type, int irq) |
| 788 | { | 687 | { |
| 789 | static const int valid_irq[] = { 9, 5, 7, 10 }; | 688 | static const int valid_irq[] = { 9, 5, 7, 10 }; |
| 689 | static const int old_irq[] = { 9, 7, 5, 15 }; | ||
| 790 | unsigned cfg; | 690 | unsigned cfg; |
| 791 | 691 | ||
| 792 | for (cfg = 0; cfg < ARRAY_SIZE(valid_irq); ++cfg) { | 692 | if (sscape_type == MEDIA_FX) { |
| 793 | if (irq == valid_irq[cfg]) | 693 | for (cfg = 0; cfg < ARRAY_SIZE(old_irq); ++cfg) |
| 794 | return cfg; | 694 | if (irq == old_irq[cfg]) |
| 795 | } /* for */ | 695 | return cfg; |
| 696 | } else { | ||
| 697 | for (cfg = 0; cfg < ARRAY_SIZE(valid_irq); ++cfg) | ||
| 698 | if (irq == valid_irq[cfg]) | ||
| 699 | return cfg; | ||
| 700 | } | ||
| 796 | 701 | ||
| 797 | return INVALID_IRQ; | 702 | return INVALID_IRQ; |
| 798 | } | 703 | } |
| 799 | 704 | ||
| 800 | |||
| 801 | /* | 705 | /* |
| 802 | * Perform certain arcane port-checks to see whether there | 706 | * Perform certain arcane port-checks to see whether there |
| 803 | * is a SoundScape board lurking behind the given ports. | 707 | * is a SoundScape board lurking behind the given ports. |
| @@ -842,11 +746,38 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
| 842 | if (s->type != SSCAPE_VIVO && (d & 0x9f) != 0x0e) | 746 | if (s->type != SSCAPE_VIVO && (d & 0x9f) != 0x0e) |
| 843 | goto _done; | 747 | goto _done; |
| 844 | 748 | ||
| 845 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f; | 749 | if (s->ic_type == IC_OPUS) |
| 846 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); | 750 | activate_ad1845_unsafe(s->io_base); |
| 847 | 751 | ||
| 848 | if (s->type == SSCAPE_VIVO) | 752 | if (s->type == SSCAPE_VIVO) |
| 849 | wss_io += 4; | 753 | wss_io += 4; |
| 754 | |||
| 755 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); | ||
| 756 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); | ||
| 757 | |||
| 758 | /* wait for WSS codec */ | ||
| 759 | for (d = 0; d < 500; d++) { | ||
| 760 | if ((inb(wss_io) & 0x80) == 0) | ||
| 761 | break; | ||
| 762 | spin_unlock_irqrestore(&s->lock, flags); | ||
| 763 | msleep(1); | ||
| 764 | spin_lock_irqsave(&s->lock, flags); | ||
| 765 | } | ||
| 766 | |||
| 767 | if ((inb(wss_io) & 0x80) != 0) | ||
| 768 | goto _done; | ||
| 769 | |||
| 770 | if (inb(wss_io + 2) == 0xff) | ||
| 771 | goto _done; | ||
| 772 | |||
| 773 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f; | ||
| 774 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d); | ||
| 775 | |||
| 776 | if ((inb(wss_io) & 0x80) != 0) | ||
| 777 | s->type = MEDIA_FX; | ||
| 778 | |||
| 779 | d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG); | ||
| 780 | sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); | ||
| 850 | /* wait for WSS codec */ | 781 | /* wait for WSS codec */ |
| 851 | for (d = 0; d < 500; d++) { | 782 | for (d = 0; d < 500; d++) { |
| 852 | if ((inb(wss_io) & 0x80) == 0) | 783 | if ((inb(wss_io) & 0x80) == 0) |
| @@ -855,14 +786,13 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
| 855 | msleep(1); | 786 | msleep(1); |
| 856 | spin_lock_irqsave(&s->lock, flags); | 787 | spin_lock_irqsave(&s->lock, flags); |
| 857 | } | 788 | } |
| 858 | snd_printd(KERN_INFO "init delay = %d ms\n", d); | ||
| 859 | 789 | ||
| 860 | /* | 790 | /* |
| 861 | * SoundScape successfully detected! | 791 | * SoundScape successfully detected! |
| 862 | */ | 792 | */ |
| 863 | retval = 1; | 793 | retval = 1; |
| 864 | 794 | ||
| 865 | _done: | 795 | _done: |
| 866 | spin_unlock_irqrestore(&s->lock, flags); | 796 | spin_unlock_irqrestore(&s->lock, flags); |
| 867 | return retval; | 797 | return retval; |
| 868 | } | 798 | } |
| @@ -873,63 +803,35 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
| 873 | * to crash the machine. Also check that someone isn't using the hardware | 803 | * to crash the machine. Also check that someone isn't using the hardware |
| 874 | * IOCTL device. | 804 | * IOCTL device. |
| 875 | */ | 805 | */ |
| 876 | static int mpu401_open(struct snd_mpu401 * mpu) | 806 | static int mpu401_open(struct snd_mpu401 *mpu) |
| 877 | { | 807 | { |
| 878 | int err; | ||
| 879 | |||
| 880 | if (!verify_mpu401(mpu)) { | 808 | if (!verify_mpu401(mpu)) { |
| 881 | snd_printk(KERN_ERR "sscape: MIDI disabled, please load firmware\n"); | 809 | snd_printk(KERN_ERR "sscape: MIDI disabled, " |
| 882 | err = -ENODEV; | 810 | "please load firmware\n"); |
| 883 | } else { | 811 | return -ENODEV; |
| 884 | register struct soundscape *sscape = get_mpu401_soundscape(mpu); | ||
| 885 | unsigned long flags; | ||
| 886 | |||
| 887 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
| 888 | |||
| 889 | if (sscape->hw_in_use || (sscape->midi_usage == ULONG_MAX)) { | ||
| 890 | err = -EBUSY; | ||
| 891 | } else { | ||
| 892 | ++(sscape->midi_usage); | ||
| 893 | err = 0; | ||
| 894 | } | ||
| 895 | |||
| 896 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
| 897 | } | 812 | } |
| 898 | 813 | ||
| 899 | return err; | 814 | return 0; |
| 900 | } | ||
| 901 | |||
| 902 | static void mpu401_close(struct snd_mpu401 * mpu) | ||
| 903 | { | ||
| 904 | register struct soundscape *sscape = get_mpu401_soundscape(mpu); | ||
| 905 | unsigned long flags; | ||
| 906 | |||
| 907 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
| 908 | --(sscape->midi_usage); | ||
| 909 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
| 910 | } | 815 | } |
| 911 | 816 | ||
| 912 | /* | 817 | /* |
| 913 | * Initialse an MPU-401 subdevice for MIDI support on the SoundScape. | 818 | * Initialse an MPU-401 subdevice for MIDI support on the SoundScape. |
| 914 | */ | 819 | */ |
| 915 | static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned long port, int irq) | 820 | static int __devinit create_mpu401(struct snd_card *card, int devnum, |
| 821 | unsigned long port, int irq) | ||
| 916 | { | 822 | { |
| 917 | struct soundscape *sscape = get_card_soundscape(card); | 823 | struct soundscape *sscape = get_card_soundscape(card); |
| 918 | struct snd_rawmidi *rawmidi; | 824 | struct snd_rawmidi *rawmidi; |
| 919 | int err; | 825 | int err; |
| 920 | 826 | ||
| 921 | if ((err = snd_mpu401_uart_new(card, devnum, | 827 | err = snd_mpu401_uart_new(card, devnum, MPU401_HW_MPU401, port, |
| 922 | MPU401_HW_MPU401, | 828 | MPU401_INFO_INTEGRATED, irq, IRQF_DISABLED, |
| 923 | port, MPU401_INFO_INTEGRATED, | 829 | &rawmidi); |
| 924 | irq, IRQF_DISABLED, | 830 | if (err == 0) { |
| 925 | &rawmidi)) == 0) { | 831 | struct snd_mpu401 *mpu = rawmidi->private_data; |
| 926 | struct snd_mpu401 *mpu = (struct snd_mpu401 *) rawmidi->private_data; | ||
| 927 | mpu->open_input = mpu401_open; | 832 | mpu->open_input = mpu401_open; |
| 928 | mpu->open_output = mpu401_open; | 833 | mpu->open_output = mpu401_open; |
| 929 | mpu->close_input = mpu401_close; | ||
| 930 | mpu->close_output = mpu401_close; | ||
| 931 | mpu->private_data = sscape; | 834 | mpu->private_data = sscape; |
| 932 | sscape->mpu = mpu; | ||
| 933 | 835 | ||
| 934 | initialise_mpu401(mpu); | 836 | initialise_mpu401(mpu); |
| 935 | } | 837 | } |
| @@ -950,32 +852,34 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port, | |||
| 950 | register struct soundscape *sscape = get_card_soundscape(card); | 852 | register struct soundscape *sscape = get_card_soundscape(card); |
| 951 | struct snd_wss *chip; | 853 | struct snd_wss *chip; |
| 952 | int err; | 854 | int err; |
| 855 | int codec_type = WSS_HW_DETECT; | ||
| 953 | 856 | ||
| 954 | if (sscape->type == SSCAPE_VIVO) | 857 | switch (sscape->type) { |
| 955 | port += 4; | 858 | case MEDIA_FX: |
| 859 | case SSCAPE: | ||
| 860 | /* | ||
| 861 | * There are some freak examples of early Soundscape cards | ||
| 862 | * with CS4231 instead of AD1848/CS4248. Unfortunately, the | ||
| 863 | * CS4231 works only in CS4248 compatibility mode on | ||
| 864 | * these cards so force it. | ||
| 865 | */ | ||
| 866 | if (sscape->ic_type != IC_OPUS) | ||
| 867 | codec_type = WSS_HW_AD1848; | ||
| 868 | break; | ||
| 956 | 869 | ||
| 957 | if (dma1 == dma2) | 870 | case SSCAPE_VIVO: |
| 958 | dma2 = -1; | 871 | port += 4; |
| 872 | break; | ||
| 873 | default: | ||
| 874 | break; | ||
| 875 | } | ||
| 959 | 876 | ||
| 960 | err = snd_wss_create(card, port, -1, irq, dma1, dma2, | 877 | err = snd_wss_create(card, port, -1, irq, dma1, dma2, |
| 961 | WSS_HW_DETECT, WSS_HWSHARE_DMA1, &chip); | 878 | codec_type, WSS_HWSHARE_DMA1, &chip); |
| 962 | if (!err) { | 879 | if (!err) { |
| 963 | unsigned long flags; | 880 | unsigned long flags; |
| 964 | struct snd_pcm *pcm; | 881 | struct snd_pcm *pcm; |
| 965 | 882 | ||
| 966 | /* | ||
| 967 | * It turns out that the PLAYBACK_ENABLE bit is set | ||
| 968 | * by the lowlevel driver ... | ||
| 969 | * | ||
| 970 | #define AD1845_IFACE_CONFIG \ | ||
| 971 | (CS4231_AUTOCALIB | CS4231_RECORD_ENABLE | CS4231_PLAYBACK_ENABLE) | ||
| 972 | snd_wss_mce_up(chip); | ||
| 973 | spin_lock_irqsave(&chip->reg_lock, flags); | ||
| 974 | snd_wss_out(chip, CS4231_IFACE_CTRL, AD1845_IFACE_CONFIG); | ||
| 975 | spin_unlock_irqrestore(&chip->reg_lock, flags); | ||
| 976 | snd_wss_mce_down(chip); | ||
| 977 | */ | ||
| 978 | |||
| 979 | if (sscape->type != SSCAPE_VIVO) { | 883 | if (sscape->type != SSCAPE_VIVO) { |
| 980 | /* | 884 | /* |
| 981 | * The input clock frequency on the SoundScape must | 885 | * The input clock frequency on the SoundScape must |
| @@ -1022,17 +926,10 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port, | |||
| 1022 | } | 926 | } |
| 1023 | } | 927 | } |
| 1024 | 928 | ||
| 1025 | strcpy(card->driver, "SoundScape"); | ||
| 1026 | strcpy(card->shortname, pcm->name); | ||
| 1027 | snprintf(card->longname, sizeof(card->longname), | ||
| 1028 | "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n", | ||
| 1029 | pcm->name, chip->port, chip->irq, | ||
| 1030 | chip->dma1, chip->dma2); | ||
| 1031 | |||
| 1032 | sscape->chip = chip; | 929 | sscape->chip = chip; |
| 1033 | } | 930 | } |
| 1034 | 931 | ||
| 1035 | _error: | 932 | _error: |
| 1036 | return err; | 933 | return err; |
| 1037 | } | 934 | } |
| 1038 | 935 | ||
| @@ -1051,21 +948,8 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
| 1051 | struct resource *wss_res; | 948 | struct resource *wss_res; |
| 1052 | unsigned long flags; | 949 | unsigned long flags; |
| 1053 | int err; | 950 | int err; |
| 1054 | 951 | int val; | |
| 1055 | /* | 952 | const char *name; |
| 1056 | * Check that the user didn't pass us garbage data ... | ||
| 1057 | */ | ||
| 1058 | irq_cfg = get_irq_config(irq[dev]); | ||
| 1059 | if (irq_cfg == INVALID_IRQ) { | ||
| 1060 | snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]); | ||
| 1061 | return -ENXIO; | ||
| 1062 | } | ||
| 1063 | |||
| 1064 | mpu_irq_cfg = get_irq_config(mpu_irq[dev]); | ||
| 1065 | if (mpu_irq_cfg == INVALID_IRQ) { | ||
| 1066 | printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); | ||
| 1067 | return -ENXIO; | ||
| 1068 | } | ||
| 1069 | 953 | ||
| 1070 | /* | 954 | /* |
| 1071 | * Grab IO ports that we will need to probe so that we | 955 | * Grab IO ports that we will need to probe so that we |
| @@ -1098,41 +982,51 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
| 1098 | } | 982 | } |
| 1099 | 983 | ||
| 1100 | spin_lock_init(&sscape->lock); | 984 | spin_lock_init(&sscape->lock); |
| 1101 | spin_lock_init(&sscape->fwlock); | ||
| 1102 | sscape->io_res = io_res; | 985 | sscape->io_res = io_res; |
| 1103 | sscape->wss_res = wss_res; | 986 | sscape->wss_res = wss_res; |
| 1104 | sscape->io_base = port[dev]; | 987 | sscape->io_base = port[dev]; |
| 1105 | 988 | ||
| 1106 | if (!detect_sscape(sscape, wss_port[dev])) { | 989 | if (!detect_sscape(sscape, wss_port[dev])) { |
| 1107 | printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base); | 990 | printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", |
| 991 | sscape->io_base); | ||
| 1108 | err = -ENODEV; | 992 | err = -ENODEV; |
| 1109 | goto _release_dma; | 993 | goto _release_dma; |
| 1110 | } | 994 | } |
| 1111 | 995 | ||
| 1112 | printk(KERN_INFO "sscape: hardware detected at 0x%x, using IRQ %d, DMA %d\n", | 996 | switch (sscape->type) { |
| 1113 | sscape->io_base, irq[dev], dma[dev]); | 997 | case MEDIA_FX: |
| 998 | name = "MediaFX/SoundFX"; | ||
| 999 | break; | ||
| 1000 | case SSCAPE: | ||
| 1001 | name = "Soundscape"; | ||
| 1002 | break; | ||
| 1003 | case SSCAPE_PNP: | ||
| 1004 | name = "Soundscape PnP"; | ||
| 1005 | break; | ||
| 1006 | case SSCAPE_VIVO: | ||
| 1007 | name = "Soundscape VIVO"; | ||
| 1008 | break; | ||
| 1009 | default: | ||
| 1010 | name = "unknown Soundscape"; | ||
| 1011 | break; | ||
| 1012 | } | ||
| 1114 | 1013 | ||
| 1115 | if (sscape->type != SSCAPE_VIVO) { | 1014 | printk(KERN_INFO "sscape: %s card detected at 0x%x, using IRQ %d, DMA %d\n", |
| 1116 | /* | 1015 | name, sscape->io_base, irq[dev], dma[dev]); |
| 1117 | * Now create the hardware-specific device so that we can | 1016 | |
| 1118 | * load the microcode into the on-board processor. | 1017 | /* |
| 1119 | * We cannot use the MPU-401 MIDI system until this firmware | 1018 | * Check that the user didn't pass us garbage data ... |
| 1120 | * has been loaded into the card. | 1019 | */ |
| 1121 | */ | 1020 | irq_cfg = get_irq_config(sscape->type, irq[dev]); |
| 1122 | err = snd_hwdep_new(card, "MC68EC000", 0, &(sscape->hw)); | 1021 | if (irq_cfg == INVALID_IRQ) { |
| 1123 | if (err < 0) { | 1022 | snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]); |
| 1124 | printk(KERN_ERR "sscape: Failed to create " | 1023 | return -ENXIO; |
| 1125 | "firmware device\n"); | 1024 | } |
| 1126 | goto _release_dma; | 1025 | |
| 1127 | } | 1026 | mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]); |
| 1128 | strlcpy(sscape->hw->name, "SoundScape M68K", | 1027 | if (mpu_irq_cfg == INVALID_IRQ) { |
| 1129 | sizeof(sscape->hw->name)); | 1028 | snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); |
| 1130 | sscape->hw->name[sizeof(sscape->hw->name) - 1] = '\0'; | 1029 | return -ENXIO; |
| 1131 | sscape->hw->iface = SNDRV_HWDEP_IFACE_SSCAPE; | ||
| 1132 | sscape->hw->ops.open = sscape_hw_open; | ||
| 1133 | sscape->hw->ops.release = sscape_hw_release; | ||
| 1134 | sscape->hw->ops.ioctl = sscape_hw_ioctl; | ||
| 1135 | sscape->hw->private_data = sscape; | ||
| 1136 | } | 1030 | } |
| 1137 | 1031 | ||
| 1138 | /* | 1032 | /* |
| @@ -1141,9 +1035,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
| 1141 | */ | 1035 | */ |
| 1142 | spin_lock_irqsave(&sscape->lock, flags); | 1036 | spin_lock_irqsave(&sscape->lock, flags); |
| 1143 | 1037 | ||
| 1144 | activate_ad1845_unsafe(sscape->io_base); | ||
| 1145 | |||
| 1146 | sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x00); /* disable */ | ||
| 1147 | sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2e); | 1038 | sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2e); |
| 1148 | sscape_write_unsafe(sscape->io_base, GA_SMCFGB_REG, 0x00); | 1039 | sscape_write_unsafe(sscape->io_base, GA_SMCFGB_REG, 0x00); |
| 1149 | 1040 | ||
| @@ -1151,15 +1042,23 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
| 1151 | * Enable and configure the DMA channels ... | 1042 | * Enable and configure the DMA channels ... |
| 1152 | */ | 1043 | */ |
| 1153 | sscape_write_unsafe(sscape->io_base, GA_DMACFG_REG, 0x50); | 1044 | sscape_write_unsafe(sscape->io_base, GA_DMACFG_REG, 0x50); |
| 1154 | dma_cfg = (sscape->ic_type == IC_ODIE ? 0x70 : 0x40); | 1045 | dma_cfg = (sscape->ic_type == IC_OPUS ? 0x40 : 0x70); |
| 1155 | sscape_write_unsafe(sscape->io_base, GA_DMAA_REG, dma_cfg); | 1046 | sscape_write_unsafe(sscape->io_base, GA_DMAA_REG, dma_cfg); |
| 1156 | sscape_write_unsafe(sscape->io_base, GA_DMAB_REG, 0x20); | 1047 | sscape_write_unsafe(sscape->io_base, GA_DMAB_REG, 0x20); |
| 1157 | 1048 | ||
| 1158 | sscape_write_unsafe(sscape->io_base, | 1049 | mpu_irq_cfg |= mpu_irq_cfg << 2; |
| 1159 | GA_INTCFG_REG, 0xf0 | (mpu_irq_cfg << 2) | mpu_irq_cfg); | 1050 | val = sscape_read_unsafe(sscape->io_base, GA_HMCTL_REG) & 0xF7; |
| 1051 | if (joystick[dev]) | ||
| 1052 | val |= 8; | ||
| 1053 | sscape_write_unsafe(sscape->io_base, GA_HMCTL_REG, val | 0x10); | ||
| 1054 | sscape_write_unsafe(sscape->io_base, GA_INTCFG_REG, 0xf0 | mpu_irq_cfg); | ||
| 1160 | sscape_write_unsafe(sscape->io_base, | 1055 | sscape_write_unsafe(sscape->io_base, |
| 1161 | GA_CDCFG_REG, 0x09 | DMA_8BIT | 1056 | GA_CDCFG_REG, 0x09 | DMA_8BIT |
| 1162 | | (dma[dev] << 4) | (irq_cfg << 1)); | 1057 | | (dma[dev] << 4) | (irq_cfg << 1)); |
| 1058 | /* | ||
| 1059 | * Enable the master IRQ ... | ||
| 1060 | */ | ||
| 1061 | sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x80); | ||
| 1163 | 1062 | ||
| 1164 | spin_unlock_irqrestore(&sscape->lock, flags); | 1063 | spin_unlock_irqrestore(&sscape->lock, flags); |
| 1165 | 1064 | ||
| @@ -1170,32 +1069,56 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
| 1170 | err = create_ad1845(card, wss_port[dev], irq[dev], | 1069 | err = create_ad1845(card, wss_port[dev], irq[dev], |
| 1171 | dma[dev], dma2[dev]); | 1070 | dma[dev], dma2[dev]); |
| 1172 | if (err < 0) { | 1071 | if (err < 0) { |
| 1173 | printk(KERN_ERR "sscape: No AD1845 device at 0x%lx, IRQ %d\n", | 1072 | snd_printk(KERN_ERR |
| 1174 | wss_port[dev], irq[dev]); | 1073 | "sscape: No AD1845 device at 0x%lx, IRQ %d\n", |
| 1074 | wss_port[dev], irq[dev]); | ||
| 1175 | goto _release_dma; | 1075 | goto _release_dma; |
| 1176 | } | 1076 | } |
| 1077 | strcpy(card->driver, "SoundScape"); | ||
| 1078 | strcpy(card->shortname, name); | ||
| 1079 | snprintf(card->longname, sizeof(card->longname), | ||
| 1080 | "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n", | ||
| 1081 | name, sscape->chip->port, sscape->chip->irq, | ||
| 1082 | sscape->chip->dma1, sscape->chip->dma2); | ||
| 1083 | |||
| 1177 | #define MIDI_DEVNUM 0 | 1084 | #define MIDI_DEVNUM 0 |
| 1178 | if (sscape->type != SSCAPE_VIVO) { | 1085 | if (sscape->type != SSCAPE_VIVO) { |
| 1179 | err = create_mpu401(card, MIDI_DEVNUM, port[dev], mpu_irq[dev]); | 1086 | err = sscape_upload_bootblock(card); |
| 1180 | if (err < 0) { | 1087 | if (err >= 0) |
| 1181 | printk(KERN_ERR "sscape: Failed to create " | 1088 | err = sscape_upload_microcode(card, err); |
| 1182 | "MPU-401 device at 0x%lx\n", | ||
| 1183 | port[dev]); | ||
| 1184 | goto _release_dma; | ||
| 1185 | } | ||
| 1186 | 1089 | ||
| 1187 | /* | 1090 | if (err == 0) { |
| 1188 | * Enable the master IRQ ... | 1091 | err = create_mpu401(card, MIDI_DEVNUM, port[dev], |
| 1189 | */ | 1092 | mpu_irq[dev]); |
| 1190 | sscape_write(sscape, GA_INTENA_REG, 0x80); | 1093 | if (err < 0) { |
| 1094 | snd_printk(KERN_ERR "sscape: Failed to create " | ||
| 1095 | "MPU-401 device at 0x%lx\n", | ||
| 1096 | port[dev]); | ||
| 1097 | goto _release_dma; | ||
| 1098 | } | ||
| 1191 | 1099 | ||
| 1192 | /* | 1100 | /* |
| 1193 | * Initialize mixer | 1101 | * Initialize mixer |
| 1194 | */ | 1102 | */ |
| 1195 | sscape->midi_vol = 0; | 1103 | spin_lock_irqsave(&sscape->lock, flags); |
| 1196 | host_write_ctrl_unsafe(sscape->io_base, CMD_SET_MIDI_VOL, 100); | 1104 | sscape->midi_vol = 0; |
| 1197 | host_write_ctrl_unsafe(sscape->io_base, 0, 100); | 1105 | host_write_ctrl_unsafe(sscape->io_base, |
| 1198 | host_write_ctrl_unsafe(sscape->io_base, CMD_XXX_MIDI_VOL, 100); | 1106 | CMD_SET_MIDI_VOL, 100); |
| 1107 | host_write_ctrl_unsafe(sscape->io_base, | ||
| 1108 | sscape->midi_vol, 100); | ||
| 1109 | host_write_ctrl_unsafe(sscape->io_base, | ||
| 1110 | CMD_XXX_MIDI_VOL, 100); | ||
| 1111 | host_write_ctrl_unsafe(sscape->io_base, | ||
| 1112 | sscape->midi_vol, 100); | ||
| 1113 | host_write_ctrl_unsafe(sscape->io_base, | ||
| 1114 | CMD_SET_EXTMIDI, 100); | ||
| 1115 | host_write_ctrl_unsafe(sscape->io_base, | ||
| 1116 | 0, 100); | ||
| 1117 | host_write_ctrl_unsafe(sscape->io_base, CMD_ACK, 100); | ||
| 1118 | |||
| 1119 | set_midi_mode_unsafe(sscape->io_base); | ||
| 1120 | spin_unlock_irqrestore(&sscape->lock, flags); | ||
| 1121 | } | ||
| 1199 | } | 1122 | } |
| 1200 | 1123 | ||
| 1201 | /* | 1124 | /* |
| @@ -1231,7 +1154,8 @@ static int __devinit snd_sscape_match(struct device *pdev, unsigned int i) | |||
| 1231 | mpu_irq[i] == SNDRV_AUTO_IRQ || | 1154 | mpu_irq[i] == SNDRV_AUTO_IRQ || |
| 1232 | dma[i] == SNDRV_AUTO_DMA) { | 1155 | dma[i] == SNDRV_AUTO_DMA) { |
| 1233 | printk(KERN_INFO | 1156 | printk(KERN_INFO |
| 1234 | "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); | 1157 | "sscape: insufficient parameters, " |
| 1158 | "need IO, IRQ, MPU-IRQ and DMA\n"); | ||
| 1235 | return 0; | 1159 | return 0; |
| 1236 | } | 1160 | } |
| 1237 | 1161 | ||
| @@ -1253,13 +1177,15 @@ static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev) | |||
| 1253 | sscape->type = SSCAPE; | 1177 | sscape->type = SSCAPE; |
| 1254 | 1178 | ||
| 1255 | dma[dev] &= 0x03; | 1179 | dma[dev] &= 0x03; |
| 1180 | snd_card_set_dev(card, pdev); | ||
| 1181 | |||
| 1256 | ret = create_sscape(dev, card); | 1182 | ret = create_sscape(dev, card); |
| 1257 | if (ret < 0) | 1183 | if (ret < 0) |
| 1258 | goto _release_card; | 1184 | goto _release_card; |
| 1259 | 1185 | ||
| 1260 | snd_card_set_dev(card, pdev); | 1186 | ret = snd_card_register(card); |
| 1261 | if ((ret = snd_card_register(card)) < 0) { | 1187 | if (ret < 0) { |
| 1262 | printk(KERN_ERR "sscape: Failed to register sound card\n"); | 1188 | snd_printk(KERN_ERR "sscape: Failed to register sound card\n"); |
| 1263 | goto _release_card; | 1189 | goto _release_card; |
| 1264 | } | 1190 | } |
| 1265 | dev_set_drvdata(pdev, card); | 1191 | dev_set_drvdata(pdev, card); |
| @@ -1311,36 +1237,20 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, | |||
| 1311 | * Allow this function to fail *quietly* if all the ISA PnP | 1237 | * Allow this function to fail *quietly* if all the ISA PnP |
| 1312 | * devices were configured using module parameters instead. | 1238 | * devices were configured using module parameters instead. |
| 1313 | */ | 1239 | */ |
| 1314 | if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) | 1240 | idx = get_next_autoindex(idx); |
| 1241 | if (idx >= SNDRV_CARDS) | ||
| 1315 | return -ENOSPC; | 1242 | return -ENOSPC; |
| 1316 | 1243 | ||
| 1317 | /* | 1244 | /* |
| 1318 | * We have found a candidate ISA PnP card. Now we | ||
| 1319 | * have to check that it has the devices that we | ||
| 1320 | * expect it to have. | ||
| 1321 | * | ||
| 1322 | * We will NOT try and autoconfigure all of the resources | ||
| 1323 | * needed and then activate the card as we are assuming that | ||
| 1324 | * has already been done at boot-time using /proc/isapnp. | ||
| 1325 | * We shall simply try to give each active card the resources | ||
| 1326 | * that it wants. This is a sensible strategy for a modular | ||
| 1327 | * system where unused modules are unloaded regularly. | ||
| 1328 | * | ||
| 1329 | * This strategy is utterly useless if we compile the driver | ||
| 1330 | * into the kernel, of course. | ||
| 1331 | */ | ||
| 1332 | // printk(KERN_INFO "sscape: %s\n", card->name); | ||
| 1333 | |||
| 1334 | /* | ||
| 1335 | * Check that we still have room for another sound card ... | 1245 | * Check that we still have room for another sound card ... |
| 1336 | */ | 1246 | */ |
| 1337 | dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); | 1247 | dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); |
| 1338 | if (! dev) | 1248 | if (!dev) |
| 1339 | return -ENODEV; | 1249 | return -ENODEV; |
| 1340 | 1250 | ||
| 1341 | if (!pnp_is_active(dev)) { | 1251 | if (!pnp_is_active(dev)) { |
| 1342 | if (pnp_activate_dev(dev) < 0) { | 1252 | if (pnp_activate_dev(dev) < 0) { |
| 1343 | printk(KERN_INFO "sscape: device is inactive\n"); | 1253 | snd_printk(KERN_INFO "sscape: device is inactive\n"); |
| 1344 | return -EBUSY; | 1254 | return -EBUSY; |
| 1345 | } | 1255 | } |
| 1346 | } | 1256 | } |
| @@ -1378,14 +1288,15 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, | |||
| 1378 | wss_port[idx] = pnp_port_start(dev, 1); | 1288 | wss_port[idx] = pnp_port_start(dev, 1); |
| 1379 | dma2[idx] = pnp_dma(dev, 1); | 1289 | dma2[idx] = pnp_dma(dev, 1); |
| 1380 | } | 1290 | } |
| 1291 | snd_card_set_dev(card, &pcard->card->dev); | ||
| 1381 | 1292 | ||
| 1382 | ret = create_sscape(idx, card); | 1293 | ret = create_sscape(idx, card); |
| 1383 | if (ret < 0) | 1294 | if (ret < 0) |
| 1384 | goto _release_card; | 1295 | goto _release_card; |
| 1385 | 1296 | ||
| 1386 | snd_card_set_dev(card, &pcard->card->dev); | 1297 | ret = snd_card_register(card); |
| 1387 | if ((ret = snd_card_register(card)) < 0) { | 1298 | if (ret < 0) { |
| 1388 | printk(KERN_ERR "sscape: Failed to register sound card\n"); | 1299 | snd_printk(KERN_ERR "sscape: Failed to register sound card\n"); |
| 1389 | goto _release_card; | 1300 | goto _release_card; |
| 1390 | } | 1301 | } |
| 1391 | 1302 | ||
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index a34ae7b1f7d0..711670e4a425 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c | |||
| @@ -21,7 +21,6 @@ | |||
| 21 | 21 | ||
| 22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
| 23 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
| 24 | #include <linux/slab.h> | ||
| 25 | #include <linux/err.h> | 24 | #include <linux/err.h> |
| 26 | #include <linux/isa.h> | 25 | #include <linux/isa.h> |
| 27 | #include <linux/pnp.h> | 26 | #include <linux/pnp.h> |
diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index 2bb1cee09255..657e2d6c01ac 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| 21 | #include <linux/time.h> | 21 | #include <linux/time.h> |
| 22 | #include <linux/wait.h> | 22 | #include <linux/wait.h> |
| 23 | #include <linux/slab.h> | ||
| 23 | #include <linux/firmware.h> | 24 | #include <linux/firmware.h> |
| 24 | #include <sound/core.h> | 25 | #include <sound/core.h> |
| 25 | #include <sound/snd_wavefront.h> | 26 | #include <sound/snd_wavefront.h> |
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index 5d4ff48c4345..4fb7b19ff393 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/wait.h> | 28 | #include <linux/wait.h> |
| 29 | #include <linux/firmware.h> | 29 | #include <linux/firmware.h> |
| 30 | #include <linux/moduleparam.h> | 30 | #include <linux/moduleparam.h> |
| 31 | #include <linux/slab.h> | ||
| 31 | #include <sound/core.h> | 32 | #include <sound/core.h> |
| 32 | #include <sound/snd_wavefront.h> | 33 | #include <sound/snd_wavefront.h> |
| 33 | #include <sound/initval.h> | 34 | #include <sound/initval.h> |
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 5d2ba1b749ab..9191b32d9130 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c | |||
| @@ -1682,7 +1682,7 @@ static void snd_wss_resume(struct snd_wss *chip) | |||
| 1682 | } | 1682 | } |
| 1683 | #endif /* CONFIG_PM */ | 1683 | #endif /* CONFIG_PM */ |
| 1684 | 1684 | ||
| 1685 | int snd_wss_free(struct snd_wss *chip) | 1685 | static int snd_wss_free(struct snd_wss *chip) |
| 1686 | { | 1686 | { |
| 1687 | release_and_free_resource(chip->res_port); | 1687 | release_and_free_resource(chip->res_port); |
| 1688 | release_and_free_resource(chip->res_cport); | 1688 | release_and_free_resource(chip->res_cport); |
| @@ -1705,7 +1705,6 @@ int snd_wss_free(struct snd_wss *chip) | |||
| 1705 | kfree(chip); | 1705 | kfree(chip); |
| 1706 | return 0; | 1706 | return 0; |
| 1707 | } | 1707 | } |
| 1708 | EXPORT_SYMBOL(snd_wss_free); | ||
| 1709 | 1708 | ||
| 1710 | static int snd_wss_dev_free(struct snd_device *device) | 1709 | static int snd_wss_dev_free(struct snd_device *device) |
| 1711 | { | 1710 | { |
| @@ -2015,6 +2014,7 @@ static int snd_wss_info_mux(struct snd_kcontrol *kcontrol, | |||
| 2015 | case WSS_HW_INTERWAVE: | 2014 | case WSS_HW_INTERWAVE: |
| 2016 | ptexts = gusmax_texts; | 2015 | ptexts = gusmax_texts; |
| 2017 | break; | 2016 | break; |
| 2017 | case WSS_HW_OPTI93X: | ||
| 2018 | case WSS_HW_OPL3SA2: | 2018 | case WSS_HW_OPL3SA2: |
| 2019 | ptexts = opl3sa_texts; | 2019 | ptexts = opl3sa_texts; |
| 2020 | break; | 2020 | break; |
| @@ -2198,64 +2198,26 @@ EXPORT_SYMBOL(snd_wss_put_double); | |||
| 2198 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); | 2198 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); |
| 2199 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); | 2199 | static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); |
| 2200 | static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); | 2200 | static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); |
| 2201 | 2201 | static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0); | |
| 2202 | static struct snd_kcontrol_new snd_ad1848_controls[] = { | ||
| 2203 | WSS_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, | ||
| 2204 | 7, 7, 1, 1), | ||
| 2205 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, | ||
| 2206 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, | ||
| 2207 | db_scale_6bit), | ||
| 2208 | WSS_DOUBLE("Aux Playback Switch", 0, | ||
| 2209 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | ||
| 2210 | WSS_DOUBLE_TLV("Aux Playback Volume", 0, | ||
| 2211 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, | ||
| 2212 | db_scale_5bit_12db_max), | ||
| 2213 | WSS_DOUBLE("Aux Playback Switch", 1, | ||
| 2214 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | ||
| 2215 | WSS_DOUBLE_TLV("Aux Playback Volume", 1, | ||
| 2216 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, | ||
| 2217 | db_scale_5bit_12db_max), | ||
| 2218 | WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, | ||
| 2219 | 0, 0, 15, 0, db_scale_rec_gain), | ||
| 2220 | { | ||
| 2221 | .name = "Capture Source", | ||
| 2222 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
| 2223 | .info = snd_wss_info_mux, | ||
| 2224 | .get = snd_wss_get_mux, | ||
| 2225 | .put = snd_wss_put_mux, | ||
| 2226 | }, | ||
| 2227 | WSS_SINGLE("Loopback Capture Switch", 0, CS4231_LOOPBACK, 0, 1, 0), | ||
| 2228 | WSS_SINGLE_TLV("Loopback Capture Volume", 0, CS4231_LOOPBACK, 1, 63, 0, | ||
| 2229 | db_scale_6bit), | ||
| 2230 | }; | ||
| 2231 | 2202 | ||
| 2232 | static struct snd_kcontrol_new snd_wss_controls[] = { | 2203 | static struct snd_kcontrol_new snd_wss_controls[] = { |
| 2233 | WSS_DOUBLE("PCM Playback Switch", 0, | 2204 | WSS_DOUBLE("PCM Playback Switch", 0, |
| 2234 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | 2205 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
| 2235 | WSS_DOUBLE("PCM Playback Volume", 0, | 2206 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, |
| 2236 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), | 2207 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, |
| 2237 | WSS_DOUBLE("Line Playback Switch", 0, | 2208 | db_scale_6bit), |
| 2238 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | ||
| 2239 | WSS_DOUBLE("Line Playback Volume", 0, | ||
| 2240 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), | ||
| 2241 | WSS_DOUBLE("Aux Playback Switch", 0, | 2209 | WSS_DOUBLE("Aux Playback Switch", 0, |
| 2242 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 2210 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), |
| 2243 | WSS_DOUBLE("Aux Playback Volume", 0, | 2211 | WSS_DOUBLE_TLV("Aux Playback Volume", 0, |
| 2244 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), | 2212 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, |
| 2213 | db_scale_5bit_12db_max), | ||
| 2245 | WSS_DOUBLE("Aux Playback Switch", 1, | 2214 | WSS_DOUBLE("Aux Playback Switch", 1, |
| 2246 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 2215 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
| 2247 | WSS_DOUBLE("Aux Playback Volume", 1, | 2216 | WSS_DOUBLE_TLV("Aux Playback Volume", 1, |
| 2248 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), | 2217 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, |
| 2249 | WSS_SINGLE("Mono Playback Switch", 0, | 2218 | db_scale_5bit_12db_max), |
| 2250 | CS4231_MONO_CTRL, 7, 1, 1), | 2219 | WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, |
| 2251 | WSS_SINGLE("Mono Playback Volume", 0, | 2220 | 0, 0, 15, 0, db_scale_rec_gain), |
| 2252 | CS4231_MONO_CTRL, 0, 15, 1), | ||
| 2253 | WSS_SINGLE("Mono Output Playback Switch", 0, | ||
| 2254 | CS4231_MONO_CTRL, 6, 1, 1), | ||
| 2255 | WSS_SINGLE("Mono Output Playback Bypass", 0, | ||
| 2256 | CS4231_MONO_CTRL, 5, 1, 0), | ||
| 2257 | WSS_DOUBLE("Capture Volume", 0, | ||
| 2258 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), | ||
| 2259 | { | 2221 | { |
| 2260 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2222 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2261 | .name = "Capture Source", | 2223 | .name = "Capture Source", |
| @@ -2263,54 +2225,26 @@ WSS_DOUBLE("Capture Volume", 0, | |||
| 2263 | .get = snd_wss_get_mux, | 2225 | .get = snd_wss_get_mux, |
| 2264 | .put = snd_wss_put_mux, | 2226 | .put = snd_wss_put_mux, |
| 2265 | }, | 2227 | }, |
| 2266 | WSS_DOUBLE("Mic Boost", 0, | 2228 | WSS_DOUBLE("Mic Boost (+20dB)", 0, |
| 2267 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), | 2229 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), |
| 2268 | WSS_SINGLE("Loopback Capture Switch", 0, | 2230 | WSS_SINGLE("Loopback Capture Switch", 0, |
| 2269 | CS4231_LOOPBACK, 0, 1, 0), | 2231 | CS4231_LOOPBACK, 0, 1, 0), |
| 2270 | WSS_SINGLE("Loopback Capture Volume", 0, | 2232 | WSS_SINGLE_TLV("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1, |
| 2271 | CS4231_LOOPBACK, 2, 63, 1) | 2233 | db_scale_6bit), |
| 2272 | }; | ||
| 2273 | |||
| 2274 | static struct snd_kcontrol_new snd_opti93x_controls[] = { | ||
| 2275 | WSS_DOUBLE("Master Playback Switch", 0, | ||
| 2276 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), | ||
| 2277 | WSS_DOUBLE("Master Playback Volume", 0, | ||
| 2278 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), | ||
| 2279 | WSS_DOUBLE("PCM Playback Switch", 0, | ||
| 2280 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | ||
| 2281 | WSS_DOUBLE("PCM Playback Volume", 0, | ||
| 2282 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1), | ||
| 2283 | WSS_DOUBLE("FM Playback Switch", 0, | ||
| 2284 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | ||
| 2285 | WSS_DOUBLE("FM Playback Volume", 0, | ||
| 2286 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1), | ||
| 2287 | WSS_DOUBLE("Line Playback Switch", 0, | 2234 | WSS_DOUBLE("Line Playback Switch", 0, |
| 2288 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | 2235 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), |
| 2289 | WSS_DOUBLE("Line Playback Volume", 0, | 2236 | WSS_DOUBLE_TLV("Line Playback Volume", 0, |
| 2290 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1), | 2237 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1, |
| 2291 | WSS_DOUBLE("Mic Playback Switch", 0, | 2238 | db_scale_5bit_12db_max), |
| 2292 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1), | 2239 | WSS_SINGLE("Beep Playback Switch", 0, |
| 2293 | WSS_DOUBLE("Mic Playback Volume", 0, | 2240 | CS4231_MONO_CTRL, 7, 1, 1), |
| 2294 | OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1), | 2241 | WSS_SINGLE_TLV("Beep Playback Volume", 0, |
| 2295 | WSS_DOUBLE("Mic Boost", 0, | 2242 | CS4231_MONO_CTRL, 0, 15, 1, |
| 2296 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), | 2243 | db_scale_4bit), |
| 2297 | WSS_DOUBLE("CD Playback Switch", 0, | 2244 | WSS_SINGLE("Mono Output Playback Switch", 0, |
| 2298 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 2245 | CS4231_MONO_CTRL, 6, 1, 1), |
| 2299 | WSS_DOUBLE("CD Playback Volume", 0, | 2246 | WSS_SINGLE("Beep Bypass Playback Switch", 0, |
| 2300 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1), | 2247 | CS4231_MONO_CTRL, 5, 1, 0), |
| 2301 | WSS_DOUBLE("Aux Playback Switch", 0, | ||
| 2302 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1), | ||
| 2303 | WSS_DOUBLE("Aux Playback Volume", 0, | ||
| 2304 | OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1), | ||
| 2305 | WSS_DOUBLE("Capture Volume", 0, | ||
| 2306 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), | ||
| 2307 | { | ||
| 2308 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
| 2309 | .name = "Capture Source", | ||
| 2310 | .info = snd_wss_info_mux, | ||
| 2311 | .get = snd_wss_get_mux, | ||
| 2312 | .put = snd_wss_put_mux, | ||
| 2313 | } | ||
| 2314 | }; | 2248 | }; |
| 2315 | 2249 | ||
| 2316 | int snd_wss_mixer(struct snd_wss *chip) | 2250 | int snd_wss_mixer(struct snd_wss *chip) |
| @@ -2318,6 +2252,7 @@ int snd_wss_mixer(struct snd_wss *chip) | |||
| 2318 | struct snd_card *card; | 2252 | struct snd_card *card; |
| 2319 | unsigned int idx; | 2253 | unsigned int idx; |
| 2320 | int err; | 2254 | int err; |
| 2255 | int count = ARRAY_SIZE(snd_wss_controls); | ||
| 2321 | 2256 | ||
| 2322 | if (snd_BUG_ON(!chip || !chip->pcm)) | 2257 | if (snd_BUG_ON(!chip || !chip->pcm)) |
| 2323 | return -EINVAL; | 2258 | return -EINVAL; |
| @@ -2326,30 +2261,20 @@ int snd_wss_mixer(struct snd_wss *chip) | |||
| 2326 | 2261 | ||
| 2327 | strcpy(card->mixername, chip->pcm->name); | 2262 | strcpy(card->mixername, chip->pcm->name); |
| 2328 | 2263 | ||
| 2329 | if (chip->hardware == WSS_HW_OPTI93X) | 2264 | /* Use only the first 11 entries on AD1848 */ |
| 2330 | for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) { | 2265 | if (chip->hardware & WSS_HW_AD1848_MASK) |
| 2331 | err = snd_ctl_add(card, | 2266 | count = 11; |
| 2332 | snd_ctl_new1(&snd_opti93x_controls[idx], | 2267 | /* There is no loopback on OPTI93X */ |
| 2333 | chip)); | 2268 | else if (chip->hardware == WSS_HW_OPTI93X) |
| 2334 | if (err < 0) | 2269 | count = 9; |
| 2335 | return err; | 2270 | |
| 2336 | } | 2271 | for (idx = 0; idx < count; idx++) { |
| 2337 | else if (chip->hardware & WSS_HW_AD1848_MASK) | 2272 | err = snd_ctl_add(card, |
| 2338 | for (idx = 0; idx < ARRAY_SIZE(snd_ad1848_controls); idx++) { | 2273 | snd_ctl_new1(&snd_wss_controls[idx], |
| 2339 | err = snd_ctl_add(card, | 2274 | chip)); |
| 2340 | snd_ctl_new1(&snd_ad1848_controls[idx], | 2275 | if (err < 0) |
| 2341 | chip)); | 2276 | return err; |
| 2342 | if (err < 0) | 2277 | } |
| 2343 | return err; | ||
| 2344 | } | ||
| 2345 | else | ||
| 2346 | for (idx = 0; idx < ARRAY_SIZE(snd_wss_controls); idx++) { | ||
| 2347 | err = snd_ctl_add(card, | ||
| 2348 | snd_ctl_new1(&snd_wss_controls[idx], | ||
| 2349 | chip)); | ||
| 2350 | if (err < 0) | ||
| 2351 | return err; | ||
| 2352 | } | ||
| 2353 | return 0; | 2278 | return 0; |
| 2354 | } | 2279 | } |
| 2355 | EXPORT_SYMBOL(snd_wss_mixer); | 2280 | EXPORT_SYMBOL(snd_wss_mixer); |
