diff options
Diffstat (limited to 'sound/isa')
-rw-r--r-- | sound/isa/Kconfig | 12 | ||||
-rw-r--r-- | sound/isa/cmi8330.c | 4 | ||||
-rw-r--r-- | sound/isa/cs423x/cs4236.c | 15 | ||||
-rw-r--r-- | sound/isa/cs423x/cs4236_lib.c | 241 | ||||
-rw-r--r-- | sound/isa/es1688/es1688_lib.c | 2 | ||||
-rw-r--r-- | sound/isa/es18xx.c | 221 | ||||
-rw-r--r-- | sound/isa/gus/gus_mem.c | 3 | ||||
-rw-r--r-- | sound/isa/msnd/msnd_midi.c | 2 | ||||
-rw-r--r-- | sound/isa/opti9xx/miro.c | 785 | ||||
-rw-r--r-- | sound/isa/opti9xx/miro.h | 73 | ||||
-rw-r--r-- | sound/isa/opti9xx/opti92x-ad1848.c | 242 | ||||
-rw-r--r-- | sound/isa/sb/emu8000.c | 6 | ||||
-rw-r--r-- | sound/isa/sb/sb_mixer.c | 4 | ||||
-rw-r--r-- | sound/isa/sscape.c | 727 | ||||
-rw-r--r-- | sound/isa/wss/wss_lib.c | 105 |
15 files changed, 1272 insertions, 1170 deletions
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 51a7e3777e17..02fe81ca88fd 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig | |||
@@ -372,15 +372,21 @@ config SND_SGALAXY | |||
372 | 372 | ||
373 | config SND_SSCAPE | 373 | config SND_SSCAPE |
374 | tristate "Ensoniq SoundScape driver" | 374 | tristate "Ensoniq SoundScape driver" |
375 | select SND_HWDEP | ||
376 | select SND_MPU401_UART | 375 | select SND_MPU401_UART |
377 | select SND_WSS_LIB | 376 | select SND_WSS_LIB |
377 | select FW_LOADER | ||
378 | help | 378 | help |
379 | Say Y here to include support for Ensoniq SoundScape | 379 | Say Y here to include support for Ensoniq SoundScape |
380 | soundcards. | 380 | and Ensoniq OEM soundcards. |
381 | 381 | ||
382 | The PCM audio is supported on SoundScape Classic, Elite, PnP | 382 | The PCM audio is supported on SoundScape Classic, Elite, PnP |
383 | and VIVO cards. The MIDI support is very experimental. | 383 | and VIVO cards. The supported OEM cards are SPEA Media FX and |
384 | Reveal SC-600. | ||
385 | The MIDI support is very experimental and requires binary | ||
386 | firmware files called "scope.cod" and "sndscape.co?" where the | ||
387 | ? is digit 0, 1, 2, 3 or 4. The firmware files can be found | ||
388 | in DOS or Windows driver packages. One has to put the firmware | ||
389 | files into the /lib/firmware directory. | ||
384 | 390 | ||
385 | To compile this driver as a module, choose M here: the module | 391 | To compile this driver as a module, choose M here: the module |
386 | will be called snd-sscape. | 392 | will be called snd-sscape. |
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index 02f79d252718..8246aae32ab4 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c | |||
@@ -237,7 +237,7 @@ WSS_DOUBLE("Wavetable Capture Volume", 0, | |||
237 | CMI8330_WAVGAIN, CMI8330_WAVGAIN, 4, 0, 15, 0), | 237 | CMI8330_WAVGAIN, CMI8330_WAVGAIN, 4, 0, 15, 0), |
238 | WSS_SINGLE("3D Control - Switch", 0, | 238 | WSS_SINGLE("3D Control - Switch", 0, |
239 | CMI8330_RMUX3D, 5, 1, 1), | 239 | CMI8330_RMUX3D, 5, 1, 1), |
240 | WSS_SINGLE("PC Speaker Playback Volume", 0, | 240 | WSS_SINGLE("Beep Playback Volume", 0, |
241 | CMI8330_OUTPUTVOL, 3, 3, 0), | 241 | CMI8330_OUTPUTVOL, 3, 3, 0), |
242 | WSS_DOUBLE("FM Playback Switch", 0, | 242 | WSS_DOUBLE("FM Playback Switch", 0, |
243 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 243 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
@@ -262,7 +262,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), | 262 | 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), | 263 | 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), | 264 | 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), | 265 | 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), | 266 | 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), | 267 | 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), | 268 | 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..cc15d1d65a22 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c | |||
@@ -177,7 +177,7 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = { | |||
177 | { .id = "CSC0437", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, | 177 | { .id = "CSC0437", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
178 | /* Digital PC 5000 Onboard - CS4236B */ | 178 | /* Digital PC 5000 Onboard - CS4236B */ |
179 | { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } }, | 179 | { .id = "CSC0735", .devs = { { "CSC0000" }, { "CSC0010" } } }, |
180 | /* some uknown CS4236B */ | 180 | /* some unknown CS4236B */ |
181 | { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, | 181 | { .id = "CSC0b35", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
182 | /* Intel PR440FX Onboard sound */ | 182 | /* Intel PR440FX Onboard sound */ |
183 | { .id = "CSC0b36", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, | 183 | { .id = "CSC0b36", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, |
@@ -394,21 +394,15 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev) | |||
394 | return -EBUSY; | 394 | return -EBUSY; |
395 | } | 395 | } |
396 | 396 | ||
397 | err = snd_wss_create(card, port[dev], cport[dev], | 397 | err = snd_cs4236_create(card, port[dev], cport[dev], |
398 | irq[dev], | 398 | irq[dev], |
399 | dma1[dev], dma2[dev], | 399 | dma1[dev], dma2[dev], |
400 | WSS_HW_DETECT3, 0, &chip); | 400 | WSS_HW_DETECT3, 0, &chip); |
401 | if (err < 0) | 401 | if (err < 0) |
402 | return err; | 402 | return err; |
403 | |||
404 | acard->chip = chip; | ||
403 | if (chip->hardware & WSS_HW_CS4236B_MASK) { | 405 | 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 | 406 | ||
413 | err = snd_cs4236_pcm(chip, 0, &pcm); | 407 | err = snd_cs4236_pcm(chip, 0, &pcm); |
414 | if (err < 0) | 408 | if (err < 0) |
@@ -418,7 +412,6 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev) | |||
418 | if (err < 0) | 412 | if (err < 0) |
419 | return err; | 413 | return err; |
420 | } else { | 414 | } else { |
421 | acard->chip = chip; | ||
422 | err = snd_wss_pcm(chip, 0, &pcm); | 415 | err = snd_wss_pcm(chip, 0, &pcm); |
423 | if (err < 0) | 416 | if (err < 0) |
424 | return err; | 417 | 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/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..9a43baae7250 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c | |||
@@ -102,8 +102,6 @@ | |||
102 | 102 | ||
103 | struct snd_es18xx { | 103 | struct snd_es18xx { |
104 | unsigned long port; /* port of ESS chip */ | 104 | 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 */ | 105 | unsigned long ctrl_port; /* Control port of ESS chip */ |
108 | struct resource *res_port; | 106 | struct resource *res_port; |
109 | struct resource *res_mpu_port; | 107 | struct resource *res_mpu_port; |
@@ -116,12 +114,9 @@ struct snd_es18xx { | |||
116 | unsigned short audio2_vol; /* volume level of audio2 */ | 114 | unsigned short audio2_vol; /* volume level of audio2 */ |
117 | 115 | ||
118 | unsigned short active; /* active channel mask */ | 116 | unsigned short active; /* active channel mask */ |
119 | unsigned int dma1_size; | ||
120 | unsigned int dma2_size; | ||
121 | unsigned int dma1_shift; | 117 | unsigned int dma1_shift; |
122 | unsigned int dma2_shift; | 118 | unsigned int dma2_shift; |
123 | 119 | ||
124 | struct snd_card *card; | ||
125 | struct snd_pcm *pcm; | 120 | struct snd_pcm *pcm; |
126 | struct snd_pcm_substream *playback_a_substream; | 121 | struct snd_pcm_substream *playback_a_substream; |
127 | struct snd_pcm_substream *capture_a_substream; | 122 | struct snd_pcm_substream *capture_a_substream; |
@@ -136,14 +131,9 @@ struct snd_es18xx { | |||
136 | 131 | ||
137 | spinlock_t reg_lock; | 132 | spinlock_t reg_lock; |
138 | spinlock_t mixer_lock; | 133 | spinlock_t mixer_lock; |
139 | spinlock_t ctrl_lock; | ||
140 | #ifdef CONFIG_PM | 134 | #ifdef CONFIG_PM |
141 | unsigned char pm_reg; | 135 | unsigned char pm_reg; |
142 | #endif | 136 | #endif |
143 | }; | ||
144 | |||
145 | struct snd_audiodrive { | ||
146 | struct snd_es18xx *chip; | ||
147 | #ifdef CONFIG_PNP | 137 | #ifdef CONFIG_PNP |
148 | struct pnp_dev *dev; | 138 | struct pnp_dev *dev; |
149 | struct pnp_dev *devc; | 139 | struct pnp_dev *devc; |
@@ -359,7 +349,7 @@ static inline int snd_es18xx_mixer_writable(struct snd_es18xx *chip, unsigned ch | |||
359 | } | 349 | } |
360 | 350 | ||
361 | 351 | ||
362 | static int snd_es18xx_reset(struct snd_es18xx *chip) | 352 | static int __devinit snd_es18xx_reset(struct snd_es18xx *chip) |
363 | { | 353 | { |
364 | int i; | 354 | int i; |
365 | outb(0x03, chip->port + 0x06); | 355 | outb(0x03, chip->port + 0x06); |
@@ -495,8 +485,6 @@ static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip, | |||
495 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 485 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
496 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 486 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
497 | 487 | ||
498 | chip->dma2_size = size; | ||
499 | |||
500 | snd_es18xx_rate_set(chip, substream, DAC2); | 488 | snd_es18xx_rate_set(chip, substream, DAC2); |
501 | 489 | ||
502 | /* Transfer Count Reload */ | 490 | /* Transfer Count Reload */ |
@@ -596,8 +584,6 @@ static int snd_es18xx_capture_prepare(struct snd_pcm_substream *substream) | |||
596 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 584 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
597 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 585 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
598 | 586 | ||
599 | chip->dma1_size = size; | ||
600 | |||
601 | snd_es18xx_reset_fifo(chip); | 587 | snd_es18xx_reset_fifo(chip); |
602 | 588 | ||
603 | /* Set stereo/mono */ | 589 | /* Set stereo/mono */ |
@@ -664,8 +650,6 @@ static int snd_es18xx_playback2_prepare(struct snd_es18xx *chip, | |||
664 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | 650 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); |
665 | unsigned int count = snd_pcm_lib_period_bytes(substream); | 651 | unsigned int count = snd_pcm_lib_period_bytes(substream); |
666 | 652 | ||
667 | chip->dma1_size = size; | ||
668 | |||
669 | snd_es18xx_reset_fifo(chip); | 653 | snd_es18xx_reset_fifo(chip); |
670 | 654 | ||
671 | /* Set stereo/mono */ | 655 | /* Set stereo/mono */ |
@@ -755,7 +739,8 @@ static int snd_es18xx_playback_trigger(struct snd_pcm_substream *substream, | |||
755 | 739 | ||
756 | static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) | 740 | static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) |
757 | { | 741 | { |
758 | struct snd_es18xx *chip = dev_id; | 742 | struct snd_card *card = dev_id; |
743 | struct snd_es18xx *chip = card->private_data; | ||
759 | unsigned char status; | 744 | unsigned char status; |
760 | 745 | ||
761 | if (chip->caps & ES18XX_CONTROL) { | 746 | if (chip->caps & ES18XX_CONTROL) { |
@@ -805,12 +790,16 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) | |||
805 | int split = 0; | 790 | int split = 0; |
806 | if (chip->caps & ES18XX_HWV) { | 791 | if (chip->caps & ES18XX_HWV) { |
807 | split = snd_es18xx_mixer_read(chip, 0x64) & 0x80; | 792 | split = snd_es18xx_mixer_read(chip, 0x64) & 0x80; |
808 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id); | 793 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, |
809 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id); | 794 | &chip->hw_switch->id); |
795 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
796 | &chip->hw_volume->id); | ||
810 | } | 797 | } |
811 | if (!split) { | 798 | if (!split) { |
812 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_switch->id); | 799 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, |
813 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id); | 800 | &chip->master_switch->id); |
801 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
802 | &chip->master_volume->id); | ||
814 | } | 803 | } |
815 | /* ack interrupt */ | 804 | /* ack interrupt */ |
816 | snd_es18xx_mixer_write(chip, 0x66, 0x00); | 805 | snd_es18xx_mixer_write(chip, 0x66, 0x00); |
@@ -821,17 +810,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) | 810 | static snd_pcm_uframes_t snd_es18xx_playback_pointer(struct snd_pcm_substream *substream) |
822 | { | 811 | { |
823 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); | 812 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); |
813 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | ||
824 | int pos; | 814 | int pos; |
825 | 815 | ||
826 | if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { | 816 | if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { |
827 | if (!(chip->active & DAC2)) | 817 | if (!(chip->active & DAC2)) |
828 | return 0; | 818 | return 0; |
829 | pos = snd_dma_pointer(chip->dma2, chip->dma2_size); | 819 | pos = snd_dma_pointer(chip->dma2, size); |
830 | return pos >> chip->dma2_shift; | 820 | return pos >> chip->dma2_shift; |
831 | } else { | 821 | } else { |
832 | if (!(chip->active & DAC1)) | 822 | if (!(chip->active & DAC1)) |
833 | return 0; | 823 | return 0; |
834 | pos = snd_dma_pointer(chip->dma1, chip->dma1_size); | 824 | pos = snd_dma_pointer(chip->dma1, size); |
835 | return pos >> chip->dma1_shift; | 825 | return pos >> chip->dma1_shift; |
836 | } | 826 | } |
837 | } | 827 | } |
@@ -839,11 +829,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) | 829 | static snd_pcm_uframes_t snd_es18xx_capture_pointer(struct snd_pcm_substream *substream) |
840 | { | 830 | { |
841 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); | 831 | struct snd_es18xx *chip = snd_pcm_substream_chip(substream); |
832 | unsigned int size = snd_pcm_lib_buffer_bytes(substream); | ||
842 | int pos; | 833 | int pos; |
843 | 834 | ||
844 | if (!(chip->active & ADC1)) | 835 | if (!(chip->active & ADC1)) |
845 | return 0; | 836 | return 0; |
846 | pos = snd_dma_pointer(chip->dma1, chip->dma1_size); | 837 | pos = snd_dma_pointer(chip->dma1, size); |
847 | return pos >> chip->dma1_shift; | 838 | return pos >> chip->dma1_shift; |
848 | } | 839 | } |
849 | 840 | ||
@@ -974,9 +965,6 @@ static int snd_es18xx_capture_close(struct snd_pcm_substream *substream) | |||
974 | 965 | ||
975 | static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 966 | static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
976 | { | 967 | { |
977 | static char *texts4Source[4] = { | ||
978 | "Mic", "CD", "Line", "Master" | ||
979 | }; | ||
980 | static char *texts5Source[5] = { | 968 | static char *texts5Source[5] = { |
981 | "Mic", "CD", "Line", "Master", "Mix" | 969 | "Mic", "CD", "Line", "Master", "Mix" |
982 | }; | 970 | }; |
@@ -994,7 +982,8 @@ static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_ele | |||
994 | uinfo->value.enumerated.items = 4; | 982 | uinfo->value.enumerated.items = 4; |
995 | if (uinfo->value.enumerated.item > 3) | 983 | if (uinfo->value.enumerated.item > 3) |
996 | uinfo->value.enumerated.item = 3; | 984 | uinfo->value.enumerated.item = 3; |
997 | strcpy(uinfo->value.enumerated.name, texts4Source[uinfo->value.enumerated.item]); | 985 | strcpy(uinfo->value.enumerated.name, |
986 | texts5Source[uinfo->value.enumerated.item]); | ||
998 | break; | 987 | break; |
999 | case 0x1887: | 988 | case 0x1887: |
1000 | case 0x1888: | 989 | case 0x1888: |
@@ -1313,7 +1302,7 @@ ES18XX_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0) | |||
1313 | * The chipset specific mixer controls | 1302 | * The chipset specific mixer controls |
1314 | */ | 1303 | */ |
1315 | static struct snd_kcontrol_new snd_es18xx_opt_speaker = | 1304 | static struct snd_kcontrol_new snd_es18xx_opt_speaker = |
1316 | ES18XX_SINGLE("PC Speaker Playback Volume", 0, 0x3c, 0, 7, 0); | 1305 | ES18XX_SINGLE("Beep Playback Volume", 0, 0x3c, 0, 7, 0); |
1317 | 1306 | ||
1318 | static struct snd_kcontrol_new snd_es18xx_opt_1869[] = { | 1307 | static struct snd_kcontrol_new snd_es18xx_opt_1869[] = { |
1319 | ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), | 1308 | ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), |
@@ -1378,11 +1367,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) | 1367 | static int __devinit snd_es18xx_config_read(struct snd_es18xx *chip, unsigned char reg) |
1379 | { | 1368 | { |
1380 | int data; | 1369 | int data; |
1381 | unsigned long flags; | 1370 | |
1382 | spin_lock_irqsave(&chip->ctrl_lock, flags); | ||
1383 | outb(reg, chip->ctrl_port); | 1371 | outb(reg, chip->ctrl_port); |
1384 | data = inb(chip->ctrl_port + 1); | 1372 | data = inb(chip->ctrl_port + 1); |
1385 | spin_unlock_irqrestore(&chip->ctrl_lock, flags); | ||
1386 | return data; | 1373 | return data; |
1387 | } | 1374 | } |
1388 | 1375 | ||
@@ -1398,7 +1385,9 @@ static void __devinit snd_es18xx_config_write(struct snd_es18xx *chip, | |||
1398 | #endif | 1385 | #endif |
1399 | } | 1386 | } |
1400 | 1387 | ||
1401 | static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) | 1388 | static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip, |
1389 | unsigned long mpu_port, | ||
1390 | unsigned long fm_port) | ||
1402 | { | 1391 | { |
1403 | int mask = 0; | 1392 | int mask = 0; |
1404 | 1393 | ||
@@ -1412,15 +1401,15 @@ static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) | |||
1412 | if (chip->caps & ES18XX_CONTROL) { | 1401 | if (chip->caps & ES18XX_CONTROL) { |
1413 | /* Hardware volume IRQ */ | 1402 | /* Hardware volume IRQ */ |
1414 | snd_es18xx_config_write(chip, 0x27, chip->irq); | 1403 | snd_es18xx_config_write(chip, 0x27, chip->irq); |
1415 | if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) { | 1404 | if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) { |
1416 | /* FM I/O */ | 1405 | /* FM I/O */ |
1417 | snd_es18xx_config_write(chip, 0x62, chip->fm_port >> 8); | 1406 | snd_es18xx_config_write(chip, 0x62, fm_port >> 8); |
1418 | snd_es18xx_config_write(chip, 0x63, chip->fm_port & 0xff); | 1407 | snd_es18xx_config_write(chip, 0x63, fm_port & 0xff); |
1419 | } | 1408 | } |
1420 | if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) { | 1409 | if (mpu_port > 0 && mpu_port != SNDRV_AUTO_PORT) { |
1421 | /* MPU-401 I/O */ | 1410 | /* MPU-401 I/O */ |
1422 | snd_es18xx_config_write(chip, 0x64, chip->mpu_port >> 8); | 1411 | snd_es18xx_config_write(chip, 0x64, mpu_port >> 8); |
1423 | snd_es18xx_config_write(chip, 0x65, chip->mpu_port & 0xff); | 1412 | snd_es18xx_config_write(chip, 0x65, mpu_port & 0xff); |
1424 | /* MPU-401 IRQ */ | 1413 | /* MPU-401 IRQ */ |
1425 | snd_es18xx_config_write(chip, 0x28, chip->irq); | 1414 | snd_es18xx_config_write(chip, 0x28, chip->irq); |
1426 | } | 1415 | } |
@@ -1507,11 +1496,12 @@ static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) | |||
1507 | snd_es18xx_mixer_write(chip, 0x7A, 0x68); | 1496 | snd_es18xx_mixer_write(chip, 0x7A, 0x68); |
1508 | /* Enable and set hardware volume interrupt */ | 1497 | /* Enable and set hardware volume interrupt */ |
1509 | snd_es18xx_mixer_write(chip, 0x64, 0x06); | 1498 | snd_es18xx_mixer_write(chip, 0x64, 0x06); |
1510 | if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) { | 1499 | if (mpu_port > 0 && mpu_port != SNDRV_AUTO_PORT) { |
1511 | /* MPU401 share irq with audio | 1500 | /* MPU401 share irq with audio |
1512 | Joystick enabled | 1501 | Joystick enabled |
1513 | FM enabled */ | 1502 | FM enabled */ |
1514 | snd_es18xx_mixer_write(chip, 0x40, 0x43 | (chip->mpu_port & 0xf0) >> 1); | 1503 | snd_es18xx_mixer_write(chip, 0x40, |
1504 | 0x43 | (mpu_port & 0xf0) >> 1); | ||
1515 | } | 1505 | } |
1516 | snd_es18xx_mixer_write(chip, 0x7f, ((irqmask + 1) << 1) | 0x01); | 1506 | snd_es18xx_mixer_write(chip, 0x7f, ((irqmask + 1) << 1) | 0x01); |
1517 | } | 1507 | } |
@@ -1629,7 +1619,9 @@ static int __devinit snd_es18xx_identify(struct snd_es18xx *chip) | |||
1629 | return 0; | 1619 | return 0; |
1630 | } | 1620 | } |
1631 | 1621 | ||
1632 | static int __devinit snd_es18xx_probe(struct snd_es18xx *chip) | 1622 | static int __devinit snd_es18xx_probe(struct snd_es18xx *chip, |
1623 | unsigned long mpu_port, | ||
1624 | unsigned long fm_port) | ||
1633 | { | 1625 | { |
1634 | if (snd_es18xx_identify(chip) < 0) { | 1626 | if (snd_es18xx_identify(chip) < 0) { |
1635 | snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); | 1627 | snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); |
@@ -1650,8 +1642,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; | 1642 | chip->caps = ES18XX_PCM2 | ES18XX_SPATIALIZER | ES18XX_RECMIX | ES18XX_NEW_RATE | ES18XX_AUXB | ES18XX_I2S | ES18XX_CONTROL | ES18XX_HWV; |
1651 | break; | 1643 | break; |
1652 | case 0x1887: | 1644 | case 0x1887: |
1653 | chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME; | ||
1654 | break; | ||
1655 | case 0x1888: | 1645 | case 0x1888: |
1656 | chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME; | 1646 | chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME; |
1657 | break; | 1647 | break; |
@@ -1666,7 +1656,7 @@ static int __devinit snd_es18xx_probe(struct snd_es18xx *chip) | |||
1666 | if (chip->dma1 == chip->dma2) | 1656 | if (chip->dma1 == chip->dma2) |
1667 | chip->caps &= ~(ES18XX_PCM2 | ES18XX_DUPLEX_SAME); | 1657 | chip->caps &= ~(ES18XX_PCM2 | ES18XX_DUPLEX_SAME); |
1668 | 1658 | ||
1669 | return snd_es18xx_initialize(chip); | 1659 | return snd_es18xx_initialize(chip, mpu_port, fm_port); |
1670 | } | 1660 | } |
1671 | 1661 | ||
1672 | static struct snd_pcm_ops snd_es18xx_playback_ops = { | 1662 | static struct snd_pcm_ops snd_es18xx_playback_ops = { |
@@ -1691,8 +1681,10 @@ static struct snd_pcm_ops snd_es18xx_capture_ops = { | |||
1691 | .pointer = snd_es18xx_capture_pointer, | 1681 | .pointer = snd_es18xx_capture_pointer, |
1692 | }; | 1682 | }; |
1693 | 1683 | ||
1694 | static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct snd_pcm ** rpcm) | 1684 | static int __devinit snd_es18xx_pcm(struct snd_card *card, int device, |
1685 | struct snd_pcm **rpcm) | ||
1695 | { | 1686 | { |
1687 | struct snd_es18xx *chip = card->private_data; | ||
1696 | struct snd_pcm *pcm; | 1688 | struct snd_pcm *pcm; |
1697 | char str[16]; | 1689 | char str[16]; |
1698 | int err; | 1690 | int err; |
@@ -1701,9 +1693,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct | |||
1701 | *rpcm = NULL; | 1693 | *rpcm = NULL; |
1702 | sprintf(str, "ES%x", chip->version); | 1694 | sprintf(str, "ES%x", chip->version); |
1703 | if (chip->caps & ES18XX_PCM2) | 1695 | if (chip->caps & ES18XX_PCM2) |
1704 | err = snd_pcm_new(chip->card, str, device, 2, 1, &pcm); | 1696 | err = snd_pcm_new(card, str, device, 2, 1, &pcm); |
1705 | else | 1697 | else |
1706 | err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm); | 1698 | err = snd_pcm_new(card, str, device, 1, 1, &pcm); |
1707 | if (err < 0) | 1699 | if (err < 0) |
1708 | return err; | 1700 | return err; |
1709 | 1701 | ||
@@ -1734,10 +1726,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct | |||
1734 | #ifdef CONFIG_PM | 1726 | #ifdef CONFIG_PM |
1735 | static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) | 1727 | static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) |
1736 | { | 1728 | { |
1737 | struct snd_audiodrive *acard = card->private_data; | 1729 | struct snd_es18xx *chip = card->private_data; |
1738 | struct snd_es18xx *chip = acard->chip; | ||
1739 | 1730 | ||
1740 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); | 1731 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
1741 | 1732 | ||
1742 | snd_pcm_suspend_all(chip->pcm); | 1733 | snd_pcm_suspend_all(chip->pcm); |
1743 | 1734 | ||
@@ -1752,24 +1743,25 @@ static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) | |||
1752 | 1743 | ||
1753 | static int snd_es18xx_resume(struct snd_card *card) | 1744 | static int snd_es18xx_resume(struct snd_card *card) |
1754 | { | 1745 | { |
1755 | struct snd_audiodrive *acard = card->private_data; | 1746 | struct snd_es18xx *chip = card->private_data; |
1756 | struct snd_es18xx *chip = acard->chip; | ||
1757 | 1747 | ||
1758 | /* restore PM register, we won't wake till (not 0x07) i/o activity though */ | 1748 | /* 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); | 1749 | snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); |
1760 | 1750 | ||
1761 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); | 1751 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
1762 | return 0; | 1752 | return 0; |
1763 | } | 1753 | } |
1764 | #endif /* CONFIG_PM */ | 1754 | #endif /* CONFIG_PM */ |
1765 | 1755 | ||
1766 | static int snd_es18xx_free(struct snd_es18xx *chip) | 1756 | static int snd_es18xx_free(struct snd_card *card) |
1767 | { | 1757 | { |
1758 | struct snd_es18xx *chip = card->private_data; | ||
1759 | |||
1768 | release_and_free_resource(chip->res_port); | 1760 | release_and_free_resource(chip->res_port); |
1769 | release_and_free_resource(chip->res_ctrl_port); | 1761 | release_and_free_resource(chip->res_ctrl_port); |
1770 | release_and_free_resource(chip->res_mpu_port); | 1762 | release_and_free_resource(chip->res_mpu_port); |
1771 | if (chip->irq >= 0) | 1763 | if (chip->irq >= 0) |
1772 | free_irq(chip->irq, (void *) chip); | 1764 | free_irq(chip->irq, (void *) card); |
1773 | if (chip->dma1 >= 0) { | 1765 | if (chip->dma1 >= 0) { |
1774 | disable_dma(chip->dma1); | 1766 | disable_dma(chip->dma1); |
1775 | free_dma(chip->dma1); | 1767 | free_dma(chip->dma1); |
@@ -1778,93 +1770,82 @@ static int snd_es18xx_free(struct snd_es18xx *chip) | |||
1778 | disable_dma(chip->dma2); | 1770 | disable_dma(chip->dma2); |
1779 | free_dma(chip->dma2); | 1771 | free_dma(chip->dma2); |
1780 | } | 1772 | } |
1781 | kfree(chip); | ||
1782 | return 0; | 1773 | return 0; |
1783 | } | 1774 | } |
1784 | 1775 | ||
1785 | static int snd_es18xx_dev_free(struct snd_device *device) | 1776 | static int snd_es18xx_dev_free(struct snd_device *device) |
1786 | { | 1777 | { |
1787 | struct snd_es18xx *chip = device->device_data; | 1778 | return snd_es18xx_free(device->card); |
1788 | return snd_es18xx_free(chip); | ||
1789 | } | 1779 | } |
1790 | 1780 | ||
1791 | static int __devinit snd_es18xx_new_device(struct snd_card *card, | 1781 | static int __devinit snd_es18xx_new_device(struct snd_card *card, |
1792 | unsigned long port, | 1782 | unsigned long port, |
1793 | unsigned long mpu_port, | 1783 | unsigned long mpu_port, |
1794 | unsigned long fm_port, | 1784 | unsigned long fm_port, |
1795 | int irq, int dma1, int dma2, | 1785 | int irq, int dma1, int dma2) |
1796 | struct snd_es18xx ** rchip) | ||
1797 | { | 1786 | { |
1798 | struct snd_es18xx *chip; | 1787 | struct snd_es18xx *chip = card->private_data; |
1799 | static struct snd_device_ops ops = { | 1788 | static struct snd_device_ops ops = { |
1800 | .dev_free = snd_es18xx_dev_free, | 1789 | .dev_free = snd_es18xx_dev_free, |
1801 | }; | 1790 | }; |
1802 | int err; | 1791 | int err; |
1803 | 1792 | ||
1804 | *rchip = NULL; | ||
1805 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
1806 | if (chip == NULL) | ||
1807 | return -ENOMEM; | ||
1808 | spin_lock_init(&chip->reg_lock); | 1793 | spin_lock_init(&chip->reg_lock); |
1809 | spin_lock_init(&chip->mixer_lock); | 1794 | spin_lock_init(&chip->mixer_lock); |
1810 | spin_lock_init(&chip->ctrl_lock); | ||
1811 | chip->card = card; | ||
1812 | chip->port = port; | 1795 | chip->port = port; |
1813 | chip->mpu_port = mpu_port; | ||
1814 | chip->fm_port = fm_port; | ||
1815 | chip->irq = -1; | 1796 | chip->irq = -1; |
1816 | chip->dma1 = -1; | 1797 | chip->dma1 = -1; |
1817 | chip->dma2 = -1; | 1798 | chip->dma2 = -1; |
1818 | chip->audio2_vol = 0x00; | 1799 | chip->audio2_vol = 0x00; |
1819 | chip->active = 0; | 1800 | chip->active = 0; |
1820 | 1801 | ||
1821 | if ((chip->res_port = request_region(port, 16, "ES18xx")) == NULL) { | 1802 | chip->res_port = request_region(port, 16, "ES18xx"); |
1822 | snd_es18xx_free(chip); | 1803 | if (chip->res_port == NULL) { |
1804 | snd_es18xx_free(card); | ||
1823 | snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); | 1805 | snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); |
1824 | return -EBUSY; | 1806 | return -EBUSY; |
1825 | } | 1807 | } |
1826 | 1808 | ||
1827 | if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", (void *) chip)) { | 1809 | if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", |
1828 | snd_es18xx_free(chip); | 1810 | (void *) card)) { |
1811 | snd_es18xx_free(card); | ||
1829 | snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); | 1812 | snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); |
1830 | return -EBUSY; | 1813 | return -EBUSY; |
1831 | } | 1814 | } |
1832 | chip->irq = irq; | 1815 | chip->irq = irq; |
1833 | 1816 | ||
1834 | if (request_dma(dma1, "ES18xx DMA 1")) { | 1817 | if (request_dma(dma1, "ES18xx DMA 1")) { |
1835 | snd_es18xx_free(chip); | 1818 | snd_es18xx_free(card); |
1836 | snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); | 1819 | snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); |
1837 | return -EBUSY; | 1820 | return -EBUSY; |
1838 | } | 1821 | } |
1839 | chip->dma1 = dma1; | 1822 | chip->dma1 = dma1; |
1840 | 1823 | ||
1841 | if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { | 1824 | if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { |
1842 | snd_es18xx_free(chip); | 1825 | snd_es18xx_free(card); |
1843 | snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); | 1826 | snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); |
1844 | return -EBUSY; | 1827 | return -EBUSY; |
1845 | } | 1828 | } |
1846 | chip->dma2 = dma2; | 1829 | chip->dma2 = dma2; |
1847 | 1830 | ||
1848 | if (snd_es18xx_probe(chip) < 0) { | 1831 | if (snd_es18xx_probe(chip, mpu_port, fm_port) < 0) { |
1849 | snd_es18xx_free(chip); | 1832 | snd_es18xx_free(card); |
1850 | return -ENODEV; | 1833 | return -ENODEV; |
1851 | } | 1834 | } |
1852 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 1835 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); |
1853 | snd_es18xx_free(chip); | 1836 | if (err < 0) { |
1837 | snd_es18xx_free(card); | ||
1854 | return err; | 1838 | return err; |
1855 | } | 1839 | } |
1856 | *rchip = chip; | ||
1857 | return 0; | 1840 | return 0; |
1858 | } | 1841 | } |
1859 | 1842 | ||
1860 | static int __devinit snd_es18xx_mixer(struct snd_es18xx *chip) | 1843 | static int __devinit snd_es18xx_mixer(struct snd_card *card) |
1861 | { | 1844 | { |
1862 | struct snd_card *card; | 1845 | struct snd_es18xx *chip = card->private_data; |
1863 | int err; | 1846 | int err; |
1864 | unsigned int idx; | 1847 | unsigned int idx; |
1865 | 1848 | ||
1866 | card = chip->card; | ||
1867 | |||
1868 | strcpy(card->mixername, chip->pcm->name); | 1849 | strcpy(card->mixername, chip->pcm->name); |
1869 | 1850 | ||
1870 | for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { | 1851 | for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { |
@@ -1986,7 +1967,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 */ | 1967 | 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 */ | 1968 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ |
1988 | #ifdef CONFIG_PNP | 1969 | #ifdef CONFIG_PNP |
1989 | static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; | 1970 | static int isapnp[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; |
1990 | #endif | 1971 | #endif |
1991 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */ | 1972 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260,0x280 */ |
1992 | #ifndef CONFIG_PNP | 1973 | #ifndef CONFIG_PNP |
@@ -2063,11 +2044,11 @@ static int __devinit snd_audiodrive_pnp_init_main(int dev, struct pnp_dev *pdev) | |||
2063 | return 0; | 2044 | return 0; |
2064 | } | 2045 | } |
2065 | 2046 | ||
2066 | static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard, | 2047 | static int __devinit snd_audiodrive_pnp(int dev, struct snd_es18xx *chip, |
2067 | struct pnp_dev *pdev) | 2048 | struct pnp_dev *pdev) |
2068 | { | 2049 | { |
2069 | acard->dev = pdev; | 2050 | chip->dev = pdev; |
2070 | if (snd_audiodrive_pnp_init_main(dev, acard->dev) < 0) | 2051 | if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0) |
2071 | return -EBUSY; | 2052 | return -EBUSY; |
2072 | return 0; | 2053 | return 0; |
2073 | } | 2054 | } |
@@ -2093,26 +2074,26 @@ static struct pnp_card_device_id snd_audiodrive_pnpids[] = { | |||
2093 | 2074 | ||
2094 | MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids); | 2075 | MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids); |
2095 | 2076 | ||
2096 | static int __devinit snd_audiodrive_pnpc(int dev, struct snd_audiodrive *acard, | 2077 | static int __devinit snd_audiodrive_pnpc(int dev, struct snd_es18xx *chip, |
2097 | struct pnp_card_link *card, | 2078 | struct pnp_card_link *card, |
2098 | const struct pnp_card_device_id *id) | 2079 | const struct pnp_card_device_id *id) |
2099 | { | 2080 | { |
2100 | acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); | 2081 | chip->dev = pnp_request_card_device(card, id->devs[0].id, NULL); |
2101 | if (acard->dev == NULL) | 2082 | if (chip->dev == NULL) |
2102 | return -EBUSY; | 2083 | return -EBUSY; |
2103 | 2084 | ||
2104 | acard->devc = pnp_request_card_device(card, id->devs[1].id, NULL); | 2085 | chip->devc = pnp_request_card_device(card, id->devs[1].id, NULL); |
2105 | if (acard->devc == NULL) | 2086 | if (chip->devc == NULL) |
2106 | return -EBUSY; | 2087 | return -EBUSY; |
2107 | 2088 | ||
2108 | /* Control port initialization */ | 2089 | /* Control port initialization */ |
2109 | if (pnp_activate_dev(acard->devc) < 0) { | 2090 | if (pnp_activate_dev(chip->devc) < 0) { |
2110 | snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n"); | 2091 | snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n"); |
2111 | return -EAGAIN; | 2092 | return -EAGAIN; |
2112 | } | 2093 | } |
2113 | snd_printdd("pnp: port=0x%llx\n", | 2094 | snd_printdd("pnp: port=0x%llx\n", |
2114 | (unsigned long long)pnp_port_start(acard->devc, 0)); | 2095 | (unsigned long long)pnp_port_start(chip->devc, 0)); |
2115 | if (snd_audiodrive_pnp_init_main(dev, acard->dev) < 0) | 2096 | if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0) |
2116 | return -EBUSY; | 2097 | return -EBUSY; |
2117 | 2098 | ||
2118 | return 0; | 2099 | return 0; |
@@ -2128,24 +2109,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) | 2109 | static int snd_es18xx_card_new(int dev, struct snd_card **cardp) |
2129 | { | 2110 | { |
2130 | return snd_card_create(index[dev], id[dev], THIS_MODULE, | 2111 | return snd_card_create(index[dev], id[dev], THIS_MODULE, |
2131 | sizeof(struct snd_audiodrive), cardp); | 2112 | sizeof(struct snd_es18xx), cardp); |
2132 | } | 2113 | } |
2133 | 2114 | ||
2134 | static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) | 2115 | static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) |
2135 | { | 2116 | { |
2136 | struct snd_audiodrive *acard = card->private_data; | 2117 | struct snd_es18xx *chip = card->private_data; |
2137 | struct snd_es18xx *chip; | ||
2138 | struct snd_opl3 *opl3; | 2118 | struct snd_opl3 *opl3; |
2139 | int err; | 2119 | int err; |
2140 | 2120 | ||
2141 | if ((err = snd_es18xx_new_device(card, | 2121 | err = snd_es18xx_new_device(card, |
2142 | port[dev], | 2122 | port[dev], mpu_port[dev], fm_port[dev], |
2143 | mpu_port[dev], | 2123 | irq[dev], dma1[dev], dma2[dev]); |
2144 | fm_port[dev], | 2124 | if (err < 0) |
2145 | irq[dev], dma1[dev], dma2[dev], | ||
2146 | &chip)) < 0) | ||
2147 | return err; | 2125 | return err; |
2148 | acard->chip = chip; | ||
2149 | 2126 | ||
2150 | sprintf(card->driver, "ES%x", chip->version); | 2127 | sprintf(card->driver, "ES%x", chip->version); |
2151 | 2128 | ||
@@ -2161,26 +2138,32 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) | |||
2161 | chip->port, | 2138 | chip->port, |
2162 | irq[dev], dma1[dev]); | 2139 | irq[dev], dma1[dev]); |
2163 | 2140 | ||
2164 | if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) | 2141 | err = snd_es18xx_pcm(card, 0, NULL); |
2142 | if (err < 0) | ||
2165 | return err; | 2143 | return err; |
2166 | 2144 | ||
2167 | if ((err = snd_es18xx_mixer(chip)) < 0) | 2145 | err = snd_es18xx_mixer(card); |
2146 | if (err < 0) | ||
2168 | return err; | 2147 | return err; |
2169 | 2148 | ||
2170 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { | 2149 | 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) { | 2150 | 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); | 2151 | OPL3_HW_OPL3, 0, &opl3) < 0) { |
2152 | snd_printk(KERN_WARNING PFX | ||
2153 | "opl3 not detected at 0x%lx\n", | ||
2154 | fm_port[dev]); | ||
2173 | } else { | 2155 | } else { |
2174 | if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) | 2156 | err = snd_opl3_hwdep_new(opl3, 0, 1, NULL); |
2157 | if (err < 0) | ||
2175 | return err; | 2158 | return err; |
2176 | } | 2159 | } |
2177 | } | 2160 | } |
2178 | 2161 | ||
2179 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { | 2162 | if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { |
2180 | if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, | 2163 | err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, |
2181 | chip->mpu_port, 0, | 2164 | mpu_port[dev], 0, |
2182 | irq[dev], 0, | 2165 | irq[dev], 0, &chip->rmidi); |
2183 | &chip->rmidi)) < 0) | 2166 | if (err < 0) |
2184 | return err; | 2167 | return err; |
2185 | } | 2168 | } |
2186 | 2169 | ||
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/msnd/msnd_midi.c b/sound/isa/msnd/msnd_midi.c index cb9aa4c4edd0..4be562b2cf21 100644 --- a/sound/isa/msnd/msnd_midi.c +++ b/sound/isa/msnd/msnd_midi.c | |||
@@ -162,7 +162,7 @@ int snd_msndmidi_new(struct snd_card *card, int device) | |||
162 | err = snd_rawmidi_new(card, "MSND-MIDI", device, 1, 1, &rmidi); | 162 | err = snd_rawmidi_new(card, "MSND-MIDI", device, 1, 1, &rmidi); |
163 | if (err < 0) | 163 | if (err < 0) |
164 | return err; | 164 | return err; |
165 | mpu = kcalloc(1, sizeof(*mpu), GFP_KERNEL); | 165 | mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); |
166 | if (mpu == NULL) { | 166 | if (mpu == NULL) { |
167 | snd_device_free(card, rmidi); | 167 | snd_device_free(card, rmidi); |
168 | return -ENOMEM; | 168 | return -ENOMEM; |
diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index 02e30d7c6a93..b865e45a8f9b 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c | |||
@@ -25,6 +25,7 @@ | |||
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/slab.h> |
30 | #include <linux/ioport.h> | 31 | #include <linux/ioport.h> |
@@ -40,7 +41,7 @@ | |||
40 | #define SNDRV_LEGACY_FIND_FREE_IRQ | 41 | #define SNDRV_LEGACY_FIND_FREE_IRQ |
41 | #define SNDRV_LEGACY_FIND_FREE_DMA | 42 | #define SNDRV_LEGACY_FIND_FREE_DMA |
42 | #include <sound/initval.h> | 43 | #include <sound/initval.h> |
43 | #include "miro.h" | 44 | #include <sound/aci.h> |
44 | 45 | ||
45 | MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>"); | 46 | MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>"); |
46 | MODULE_LICENSE("GPL"); | 47 | MODULE_LICENSE("GPL"); |
@@ -60,6 +61,9 @@ static int dma1 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ | |||
60 | static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ | 61 | static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */ |
61 | static int wss; | 62 | static int wss; |
62 | static int ide; | 63 | static int ide; |
64 | #ifdef CONFIG_PNP | ||
65 | static int isapnp = 1; /* Enable ISA PnP detection */ | ||
66 | #endif | ||
63 | 67 | ||
64 | module_param(index, int, 0444); | 68 | module_param(index, int, 0444); |
65 | MODULE_PARM_DESC(index, "Index value for miro soundcard."); | 69 | MODULE_PARM_DESC(index, "Index value for miro soundcard."); |
@@ -83,6 +87,10 @@ module_param(wss, int, 0444); | |||
83 | MODULE_PARM_DESC(wss, "wss mode"); | 87 | MODULE_PARM_DESC(wss, "wss mode"); |
84 | module_param(ide, int, 0444); | 88 | module_param(ide, int, 0444); |
85 | MODULE_PARM_DESC(ide, "enable ide port"); | 89 | MODULE_PARM_DESC(ide, "enable ide port"); |
90 | #ifdef CONFIG_PNP | ||
91 | module_param(isapnp, bool, 0444); | ||
92 | MODULE_PARM_DESC(isapnp, "Enable ISA PnP detection for specified soundcard."); | ||
93 | #endif | ||
86 | 94 | ||
87 | #define OPTi9XX_HW_DETECT 0 | 95 | #define OPTi9XX_HW_DETECT 0 |
88 | #define OPTi9XX_HW_82C928 1 | 96 | #define OPTi9XX_HW_82C928 1 |
@@ -96,7 +104,6 @@ MODULE_PARM_DESC(ide, "enable ide port"); | |||
96 | 104 | ||
97 | #define OPTi9XX_MC_REG(n) n | 105 | #define OPTi9XX_MC_REG(n) n |
98 | 106 | ||
99 | |||
100 | struct snd_miro { | 107 | struct snd_miro { |
101 | unsigned short hardware; | 108 | unsigned short hardware; |
102 | unsigned char password; | 109 | unsigned char password; |
@@ -110,7 +117,6 @@ struct snd_miro { | |||
110 | unsigned long pwd_reg; | 117 | unsigned long pwd_reg; |
111 | 118 | ||
112 | spinlock_t lock; | 119 | spinlock_t lock; |
113 | struct snd_card *card; | ||
114 | struct snd_pcm *pcm; | 120 | struct snd_pcm *pcm; |
115 | 121 | ||
116 | long wss_base; | 122 | long wss_base; |
@@ -118,42 +124,48 @@ struct snd_miro { | |||
118 | int dma1; | 124 | int dma1; |
119 | int dma2; | 125 | int dma2; |
120 | 126 | ||
121 | long fm_port; | ||
122 | |||
123 | long mpu_port; | 127 | long mpu_port; |
124 | int mpu_irq; | 128 | int mpu_irq; |
125 | 129 | ||
126 | unsigned long aci_port; | 130 | 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 | }; | 131 | }; |
136 | 132 | ||
137 | static void snd_miro_proc_init(struct snd_miro * miro); | 133 | static struct snd_miro_aci aci_device; |
138 | 134 | ||
139 | static char * snd_opti9xx_names[] = { | 135 | static char * snd_opti9xx_names[] = { |
140 | "unkown", | 136 | "unknown", |
141 | "82C928", "82C929", | 137 | "82C928", "82C929", |
142 | "82C924", "82C925", | 138 | "82C924", "82C925", |
143 | "82C930", "82C931", "82C933" | 139 | "82C930", "82C931", "82C933" |
144 | }; | 140 | }; |
145 | 141 | ||
142 | static int snd_miro_pnp_is_probed; | ||
143 | |||
144 | #ifdef CONFIG_PNP | ||
145 | |||
146 | static struct pnp_card_device_id snd_miro_pnpids[] = { | ||
147 | /* PCM20 and PCM12 in PnP mode */ | ||
148 | { .id = "MIR0924", | ||
149 | .devs = { { "MIR0000" }, { "MIR0002" }, { "MIR0005" } }, }, | ||
150 | { .id = "" } | ||
151 | }; | ||
152 | |||
153 | MODULE_DEVICE_TABLE(pnp_card, snd_miro_pnpids); | ||
154 | |||
155 | #endif /* CONFIG_PNP */ | ||
156 | |||
146 | /* | 157 | /* |
147 | * ACI control | 158 | * ACI control |
148 | */ | 159 | */ |
149 | 160 | ||
150 | static int aci_busy_wait(struct snd_miro * miro) | 161 | static int aci_busy_wait(struct snd_miro_aci *aci) |
151 | { | 162 | { |
152 | long timeout; | 163 | long timeout; |
153 | unsigned char byte; | 164 | unsigned char byte; |
154 | 165 | ||
155 | for (timeout = 1; timeout <= ACI_MINTIME+30; timeout++) { | 166 | for (timeout = 1; timeout <= ACI_MINTIME + 30; timeout++) { |
156 | if (((byte=inb(miro->aci_port + ACI_REG_BUSY)) & 1) == 0) { | 167 | byte = inb(aci->aci_port + ACI_REG_BUSY); |
168 | if ((byte & 1) == 0) { | ||
157 | if (timeout >= ACI_MINTIME) | 169 | if (timeout >= ACI_MINTIME) |
158 | snd_printd("aci ready in round %ld.\n", | 170 | snd_printd("aci ready in round %ld.\n", |
159 | timeout-ACI_MINTIME); | 171 | timeout-ACI_MINTIME); |
@@ -179,10 +191,10 @@ static int aci_busy_wait(struct snd_miro * miro) | |||
179 | return -EBUSY; | 191 | return -EBUSY; |
180 | } | 192 | } |
181 | 193 | ||
182 | static inline int aci_write(struct snd_miro * miro, unsigned char byte) | 194 | static inline int aci_write(struct snd_miro_aci *aci, unsigned char byte) |
183 | { | 195 | { |
184 | if (aci_busy_wait(miro) >= 0) { | 196 | if (aci_busy_wait(aci) >= 0) { |
185 | outb(byte, miro->aci_port + ACI_REG_COMMAND); | 197 | outb(byte, aci->aci_port + ACI_REG_COMMAND); |
186 | return 0; | 198 | return 0; |
187 | } else { | 199 | } else { |
188 | snd_printk(KERN_ERR "aci busy, aci_write(0x%x) stopped.\n", byte); | 200 | snd_printk(KERN_ERR "aci busy, aci_write(0x%x) stopped.\n", byte); |
@@ -190,12 +202,12 @@ static inline int aci_write(struct snd_miro * miro, unsigned char byte) | |||
190 | } | 202 | } |
191 | } | 203 | } |
192 | 204 | ||
193 | static inline int aci_read(struct snd_miro * miro) | 205 | static inline int aci_read(struct snd_miro_aci *aci) |
194 | { | 206 | { |
195 | unsigned char byte; | 207 | unsigned char byte; |
196 | 208 | ||
197 | if (aci_busy_wait(miro) >= 0) { | 209 | if (aci_busy_wait(aci) >= 0) { |
198 | byte=inb(miro->aci_port + ACI_REG_STATUS); | 210 | byte = inb(aci->aci_port + ACI_REG_STATUS); |
199 | return byte; | 211 | return byte; |
200 | } else { | 212 | } else { |
201 | snd_printk(KERN_ERR "aci busy, aci_read() stopped.\n"); | 213 | snd_printk(KERN_ERR "aci busy, aci_read() stopped.\n"); |
@@ -203,39 +215,49 @@ static inline int aci_read(struct snd_miro * miro) | |||
203 | } | 215 | } |
204 | } | 216 | } |
205 | 217 | ||
206 | static int aci_cmd(struct snd_miro * miro, int write1, int write2, int write3) | 218 | int snd_aci_cmd(struct snd_miro_aci *aci, int write1, int write2, int write3) |
207 | { | 219 | { |
208 | int write[] = {write1, write2, write3}; | 220 | int write[] = {write1, write2, write3}; |
209 | int value, i; | 221 | int value, i; |
210 | 222 | ||
211 | if (mutex_lock_interruptible(&miro->aci_mutex)) | 223 | if (mutex_lock_interruptible(&aci->aci_mutex)) |
212 | return -EINTR; | 224 | return -EINTR; |
213 | 225 | ||
214 | for (i=0; i<3; i++) { | 226 | for (i=0; i<3; i++) { |
215 | if (write[i]< 0 || write[i] > 255) | 227 | if (write[i]< 0 || write[i] > 255) |
216 | break; | 228 | break; |
217 | else { | 229 | else { |
218 | value = aci_write(miro, write[i]); | 230 | value = aci_write(aci, write[i]); |
219 | if (value < 0) | 231 | if (value < 0) |
220 | goto out; | 232 | goto out; |
221 | } | 233 | } |
222 | } | 234 | } |
223 | 235 | ||
224 | value = aci_read(miro); | 236 | value = aci_read(aci); |
225 | 237 | ||
226 | out: mutex_unlock(&miro->aci_mutex); | 238 | out: mutex_unlock(&aci->aci_mutex); |
227 | return value; | 239 | return value; |
228 | } | 240 | } |
241 | EXPORT_SYMBOL(snd_aci_cmd); | ||
242 | |||
243 | static int aci_getvalue(struct snd_miro_aci *aci, unsigned char index) | ||
244 | { | ||
245 | return snd_aci_cmd(aci, ACI_STATUS, index, -1); | ||
246 | } | ||
229 | 247 | ||
230 | static int aci_getvalue(struct snd_miro * miro, unsigned char index) | 248 | static int aci_setvalue(struct snd_miro_aci *aci, unsigned char index, |
249 | int value) | ||
231 | { | 250 | { |
232 | return aci_cmd(miro, ACI_STATUS, index, -1); | 251 | return snd_aci_cmd(aci, index, value, -1); |
233 | } | 252 | } |
234 | 253 | ||
235 | static int aci_setvalue(struct snd_miro * miro, unsigned char index, int value) | 254 | struct snd_miro_aci *snd_aci_get_aci(void) |
236 | { | 255 | { |
237 | return aci_cmd(miro, index, value, -1); | 256 | if (aci_device.aci_port == 0) |
257 | return NULL; | ||
258 | return &aci_device; | ||
238 | } | 259 | } |
260 | EXPORT_SYMBOL(snd_aci_get_aci); | ||
239 | 261 | ||
240 | /* | 262 | /* |
241 | * MIXER part | 263 | * MIXER part |
@@ -249,8 +271,10 @@ static int snd_miro_get_capture(struct snd_kcontrol *kcontrol, | |||
249 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 271 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
250 | int value; | 272 | int value; |
251 | 273 | ||
252 | if ((value = aci_getvalue(miro, ACI_S_GENERAL)) < 0) { | 274 | value = aci_getvalue(miro->aci, ACI_S_GENERAL); |
253 | snd_printk(KERN_ERR "snd_miro_get_capture() failed: %d\n", value); | 275 | if (value < 0) { |
276 | snd_printk(KERN_ERR "snd_miro_get_capture() failed: %d\n", | ||
277 | value); | ||
254 | return value; | 278 | return value; |
255 | } | 279 | } |
256 | 280 | ||
@@ -267,13 +291,15 @@ static int snd_miro_put_capture(struct snd_kcontrol *kcontrol, | |||
267 | 291 | ||
268 | value = !(ucontrol->value.integer.value[0]); | 292 | value = !(ucontrol->value.integer.value[0]); |
269 | 293 | ||
270 | if ((error = aci_setvalue(miro, ACI_SET_SOLOMODE, value)) < 0) { | 294 | error = aci_setvalue(miro->aci, ACI_SET_SOLOMODE, value); |
271 | snd_printk(KERN_ERR "snd_miro_put_capture() failed: %d\n", error); | 295 | if (error < 0) { |
296 | snd_printk(KERN_ERR "snd_miro_put_capture() failed: %d\n", | ||
297 | error); | ||
272 | return error; | 298 | return error; |
273 | } | 299 | } |
274 | 300 | ||
275 | change = (value != miro->aci_solomode); | 301 | change = (value != miro->aci->aci_solomode); |
276 | miro->aci_solomode = value; | 302 | miro->aci->aci_solomode = value; |
277 | 303 | ||
278 | return change; | 304 | return change; |
279 | } | 305 | } |
@@ -295,7 +321,7 @@ static int snd_miro_get_preamp(struct snd_kcontrol *kcontrol, | |||
295 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 321 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
296 | int value; | 322 | int value; |
297 | 323 | ||
298 | if (miro->aci_version <= 176) { | 324 | if (miro->aci->aci_version <= 176) { |
299 | 325 | ||
300 | /* | 326 | /* |
301 | OSS says it's not readable with versions < 176. | 327 | OSS says it's not readable with versions < 176. |
@@ -303,12 +329,14 @@ static int snd_miro_get_preamp(struct snd_kcontrol *kcontrol, | |||
303 | which is a PCM12 with aci_version = 176. | 329 | which is a PCM12 with aci_version = 176. |
304 | */ | 330 | */ |
305 | 331 | ||
306 | ucontrol->value.integer.value[0] = miro->aci_preamp; | 332 | ucontrol->value.integer.value[0] = miro->aci->aci_preamp; |
307 | return 0; | 333 | return 0; |
308 | } | 334 | } |
309 | 335 | ||
310 | if ((value = aci_getvalue(miro, ACI_GET_PREAMP)) < 0) { | 336 | value = aci_getvalue(miro->aci, ACI_GET_PREAMP); |
311 | snd_printk(KERN_ERR "snd_miro_get_preamp() failed: %d\n", value); | 337 | if (value < 0) { |
338 | snd_printk(KERN_ERR "snd_miro_get_preamp() failed: %d\n", | ||
339 | value); | ||
312 | return value; | 340 | return value; |
313 | } | 341 | } |
314 | 342 | ||
@@ -325,13 +353,15 @@ static int snd_miro_put_preamp(struct snd_kcontrol *kcontrol, | |||
325 | 353 | ||
326 | value = ucontrol->value.integer.value[0]; | 354 | value = ucontrol->value.integer.value[0]; |
327 | 355 | ||
328 | if ((error = aci_setvalue(miro, ACI_SET_PREAMP, value)) < 0) { | 356 | error = aci_setvalue(miro->aci, ACI_SET_PREAMP, value); |
329 | snd_printk(KERN_ERR "snd_miro_put_preamp() failed: %d\n", error); | 357 | if (error < 0) { |
358 | snd_printk(KERN_ERR "snd_miro_put_preamp() failed: %d\n", | ||
359 | error); | ||
330 | return error; | 360 | return error; |
331 | } | 361 | } |
332 | 362 | ||
333 | change = (value != miro->aci_preamp); | 363 | change = (value != miro->aci->aci_preamp); |
334 | miro->aci_preamp = value; | 364 | miro->aci->aci_preamp = value; |
335 | 365 | ||
336 | return change; | 366 | return change; |
337 | } | 367 | } |
@@ -342,7 +372,7 @@ static int snd_miro_get_amp(struct snd_kcontrol *kcontrol, | |||
342 | struct snd_ctl_elem_value *ucontrol) | 372 | struct snd_ctl_elem_value *ucontrol) |
343 | { | 373 | { |
344 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 374 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
345 | ucontrol->value.integer.value[0] = miro->aci_amp; | 375 | ucontrol->value.integer.value[0] = miro->aci->aci_amp; |
346 | 376 | ||
347 | return 0; | 377 | return 0; |
348 | } | 378 | } |
@@ -355,13 +385,14 @@ static int snd_miro_put_amp(struct snd_kcontrol *kcontrol, | |||
355 | 385 | ||
356 | value = ucontrol->value.integer.value[0]; | 386 | value = ucontrol->value.integer.value[0]; |
357 | 387 | ||
358 | if ((error = aci_setvalue(miro, ACI_SET_POWERAMP, value)) < 0) { | 388 | error = aci_setvalue(miro->aci, ACI_SET_POWERAMP, value); |
389 | if (error < 0) { | ||
359 | snd_printk(KERN_ERR "snd_miro_put_amp() to %d failed: %d\n", value, error); | 390 | snd_printk(KERN_ERR "snd_miro_put_amp() to %d failed: %d\n", value, error); |
360 | return error; | 391 | return error; |
361 | } | 392 | } |
362 | 393 | ||
363 | change = (value != miro->aci_amp); | 394 | change = (value != miro->aci->aci_amp); |
364 | miro->aci_amp = value; | 395 | miro->aci->aci_amp = value; |
365 | 396 | ||
366 | return change; | 397 | return change; |
367 | } | 398 | } |
@@ -410,12 +441,14 @@ static int snd_miro_get_double(struct snd_kcontrol *kcontrol, | |||
410 | int right_reg = kcontrol->private_value & 0xff; | 441 | int right_reg = kcontrol->private_value & 0xff; |
411 | int left_reg = right_reg + 1; | 442 | int left_reg = right_reg + 1; |
412 | 443 | ||
413 | if ((right_val = aci_getvalue(miro, right_reg)) < 0) { | 444 | right_val = aci_getvalue(miro->aci, right_reg); |
445 | if (right_val < 0) { | ||
414 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", right_reg, right_val); | 446 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", right_reg, right_val); |
415 | return right_val; | 447 | return right_val; |
416 | } | 448 | } |
417 | 449 | ||
418 | if ((left_val = aci_getvalue(miro, left_reg)) < 0) { | 450 | left_val = aci_getvalue(miro->aci, left_reg); |
451 | if (left_val < 0) { | ||
419 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", left_reg, left_val); | 452 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", left_reg, left_val); |
420 | return left_val; | 453 | return left_val; |
421 | } | 454 | } |
@@ -451,6 +484,7 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
451 | struct snd_ctl_elem_value *ucontrol) | 484 | struct snd_ctl_elem_value *ucontrol) |
452 | { | 485 | { |
453 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); | 486 | struct snd_miro *miro = snd_kcontrol_chip(kcontrol); |
487 | struct snd_miro_aci *aci = miro->aci; | ||
454 | int left, right, left_old, right_old; | 488 | int left, right, left_old, right_old; |
455 | int setreg_left, setreg_right, getreg_left, getreg_right; | 489 | int setreg_left, setreg_right, getreg_left, getreg_right; |
456 | int change, error; | 490 | int change, error; |
@@ -459,21 +493,21 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
459 | right = ucontrol->value.integer.value[1]; | 493 | right = ucontrol->value.integer.value[1]; |
460 | 494 | ||
461 | setreg_right = (kcontrol->private_value >> 8) & 0xff; | 495 | setreg_right = (kcontrol->private_value >> 8) & 0xff; |
462 | if (setreg_right == ACI_SET_MASTER) { | 496 | setreg_left = setreg_right + 8; |
463 | setreg_left = setreg_right + 1; | 497 | if (setreg_right == ACI_SET_MASTER) |
464 | } else { | 498 | setreg_left -= 7; |
465 | setreg_left = setreg_right + 8; | ||
466 | } | ||
467 | 499 | ||
468 | getreg_right = kcontrol->private_value & 0xff; | 500 | getreg_right = kcontrol->private_value & 0xff; |
469 | getreg_left = getreg_right + 1; | 501 | getreg_left = getreg_right + 1; |
470 | 502 | ||
471 | if ((left_old = aci_getvalue(miro, getreg_left)) < 0) { | 503 | left_old = aci_getvalue(aci, getreg_left); |
504 | if (left_old < 0) { | ||
472 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_left, left_old); | 505 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_left, left_old); |
473 | return left_old; | 506 | return left_old; |
474 | } | 507 | } |
475 | 508 | ||
476 | if ((right_old = aci_getvalue(miro, getreg_right)) < 0) { | 509 | right_old = aci_getvalue(aci, getreg_right); |
510 | if (right_old < 0) { | ||
477 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_right, right_old); | 511 | snd_printk(KERN_ERR "aci_getvalue(%d) failed: %d\n", getreg_right, right_old); |
478 | return right_old; | 512 | return right_old; |
479 | } | 513 | } |
@@ -492,13 +526,15 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
492 | right_old = 0x80 - right_old; | 526 | right_old = 0x80 - right_old; |
493 | 527 | ||
494 | if (left >= 0) { | 528 | if (left >= 0) { |
495 | if ((error = aci_setvalue(miro, setreg_left, left)) < 0) { | 529 | error = aci_setvalue(aci, setreg_left, left); |
530 | if (error < 0) { | ||
496 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 531 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
497 | left, error); | 532 | left, error); |
498 | return error; | 533 | return error; |
499 | } | 534 | } |
500 | } else { | 535 | } else { |
501 | if ((error = aci_setvalue(miro, setreg_left, 0x80 - left)) < 0) { | 536 | error = aci_setvalue(aci, setreg_left, 0x80 - left); |
537 | if (error < 0) { | ||
502 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 538 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
503 | 0x80 - left, error); | 539 | 0x80 - left, error); |
504 | return error; | 540 | return error; |
@@ -506,13 +542,15 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
506 | } | 542 | } |
507 | 543 | ||
508 | if (right >= 0) { | 544 | if (right >= 0) { |
509 | if ((error = aci_setvalue(miro, setreg_right, right)) < 0) { | 545 | error = aci_setvalue(aci, setreg_right, right); |
546 | if (error < 0) { | ||
510 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 547 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
511 | right, error); | 548 | right, error); |
512 | return error; | 549 | return error; |
513 | } | 550 | } |
514 | } else { | 551 | } else { |
515 | if ((error = aci_setvalue(miro, setreg_right, 0x80 - right)) < 0) { | 552 | error = aci_setvalue(aci, setreg_right, 0x80 - right); |
553 | if (error < 0) { | ||
516 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 554 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
517 | 0x80 - right, error); | 555 | 0x80 - right, error); |
518 | return error; | 556 | return error; |
@@ -530,12 +568,14 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol, | |||
530 | left_old = 0x20 - left_old; | 568 | left_old = 0x20 - left_old; |
531 | right_old = 0x20 - right_old; | 569 | right_old = 0x20 - right_old; |
532 | 570 | ||
533 | if ((error = aci_setvalue(miro, setreg_left, 0x20 - left)) < 0) { | 571 | error = aci_setvalue(aci, setreg_left, 0x20 - left); |
572 | if (error < 0) { | ||
534 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 573 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
535 | 0x20 - left, error); | 574 | 0x20 - left, error); |
536 | return error; | 575 | return error; |
537 | } | 576 | } |
538 | if ((error = aci_setvalue(miro, setreg_right, 0x20 - right)) < 0) { | 577 | error = aci_setvalue(aci, setreg_right, 0x20 - right); |
578 | if (error < 0) { | ||
539 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 579 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
540 | 0x20 - right, error); | 580 | 0x20 - right, error); |
541 | return error; | 581 | return error; |
@@ -633,11 +673,13 @@ static unsigned char aci_init_values[][2] __devinitdata = { | |||
633 | static int __devinit snd_set_aci_init_values(struct snd_miro *miro) | 673 | static int __devinit snd_set_aci_init_values(struct snd_miro *miro) |
634 | { | 674 | { |
635 | int idx, error; | 675 | int idx, error; |
676 | struct snd_miro_aci *aci = miro->aci; | ||
636 | 677 | ||
637 | /* enable WSS on PCM1 */ | 678 | /* enable WSS on PCM1 */ |
638 | 679 | ||
639 | if ((miro->aci_product == 'A') && wss) { | 680 | if ((aci->aci_product == 'A') && wss) { |
640 | if ((error = aci_setvalue(miro, ACI_SET_WSS, wss)) < 0) { | 681 | error = aci_setvalue(aci, ACI_SET_WSS, wss); |
682 | if (error < 0) { | ||
641 | snd_printk(KERN_ERR "enabling WSS mode failed\n"); | 683 | snd_printk(KERN_ERR "enabling WSS mode failed\n"); |
642 | return error; | 684 | return error; |
643 | } | 685 | } |
@@ -646,7 +688,8 @@ static int __devinit snd_set_aci_init_values(struct snd_miro *miro) | |||
646 | /* enable IDE port */ | 688 | /* enable IDE port */ |
647 | 689 | ||
648 | if (ide) { | 690 | if (ide) { |
649 | if ((error = aci_setvalue(miro, ACI_SET_IDE, ide)) < 0) { | 691 | error = aci_setvalue(aci, ACI_SET_IDE, ide); |
692 | if (error < 0) { | ||
650 | snd_printk(KERN_ERR "enabling IDE port failed\n"); | 693 | snd_printk(KERN_ERR "enabling IDE port failed\n"); |
651 | return error; | 694 | return error; |
652 | } | 695 | } |
@@ -654,32 +697,31 @@ static int __devinit snd_set_aci_init_values(struct snd_miro *miro) | |||
654 | 697 | ||
655 | /* set common aci values */ | 698 | /* set common aci values */ |
656 | 699 | ||
657 | for (idx = 0; idx < ARRAY_SIZE(aci_init_values); idx++) | 700 | for (idx = 0; idx < ARRAY_SIZE(aci_init_values); idx++) { |
658 | if ((error = aci_setvalue(miro, aci_init_values[idx][0], | 701 | error = aci_setvalue(aci, aci_init_values[idx][0], |
659 | aci_init_values[idx][1])) < 0) { | 702 | aci_init_values[idx][1]); |
703 | if (error < 0) { | ||
660 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", | 704 | snd_printk(KERN_ERR "aci_setvalue(%d) failed: %d\n", |
661 | aci_init_values[idx][0], error); | 705 | aci_init_values[idx][0], error); |
662 | return error; | 706 | return error; |
663 | } | 707 | } |
664 | 708 | } | |
665 | miro->aci_amp = 0; | 709 | aci->aci_amp = 0; |
666 | miro->aci_preamp = 0; | 710 | aci->aci_preamp = 0; |
667 | miro->aci_solomode = 1; | 711 | aci->aci_solomode = 1; |
668 | 712 | ||
669 | return 0; | 713 | return 0; |
670 | } | 714 | } |
671 | 715 | ||
672 | static int __devinit snd_miro_mixer(struct snd_miro *miro) | 716 | static int __devinit snd_miro_mixer(struct snd_card *card, |
717 | struct snd_miro *miro) | ||
673 | { | 718 | { |
674 | struct snd_card *card; | ||
675 | unsigned int idx; | 719 | unsigned int idx; |
676 | int err; | 720 | int err; |
677 | 721 | ||
678 | if (snd_BUG_ON(!miro || !miro->card)) | 722 | if (snd_BUG_ON(!miro || !card)) |
679 | return -EINVAL; | 723 | return -EINVAL; |
680 | 724 | ||
681 | card = miro->card; | ||
682 | |||
683 | switch (miro->hardware) { | 725 | switch (miro->hardware) { |
684 | case OPTi9XX_HW_82C924: | 726 | case OPTi9XX_HW_82C924: |
685 | strcpy(card->mixername, "ACI & OPTi924"); | 727 | strcpy(card->mixername, "ACI & OPTi924"); |
@@ -697,7 +739,8 @@ static int __devinit snd_miro_mixer(struct snd_miro *miro) | |||
697 | return err; | 739 | return err; |
698 | } | 740 | } |
699 | 741 | ||
700 | if ((miro->aci_product == 'A') || (miro->aci_product == 'B')) { | 742 | if ((miro->aci->aci_product == 'A') || |
743 | (miro->aci->aci_product == 'B')) { | ||
701 | /* PCM1/PCM12 with power-amp and Line 2 */ | 744 | /* 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) | 745 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_line_control[0], miro))) < 0) |
703 | return err; | 746 | return err; |
@@ -705,16 +748,17 @@ static int __devinit snd_miro_mixer(struct snd_miro *miro) | |||
705 | return err; | 748 | return err; |
706 | } | 749 | } |
707 | 750 | ||
708 | if ((miro->aci_product == 'B') || (miro->aci_product == 'C')) { | 751 | if ((miro->aci->aci_product == 'B') || |
752 | (miro->aci->aci_product == 'C')) { | ||
709 | /* PCM12/PCM20 with mic-preamp */ | 753 | /* PCM12/PCM20 with mic-preamp */ |
710 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_preamp_control[0], miro))) < 0) | 754 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_preamp_control[0], miro))) < 0) |
711 | return err; | 755 | return err; |
712 | if (miro->aci_version >= 176) | 756 | if (miro->aci->aci_version >= 176) |
713 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_capture_control[0], miro))) < 0) | 757 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_capture_control[0], miro))) < 0) |
714 | return err; | 758 | return err; |
715 | } | 759 | } |
716 | 760 | ||
717 | if (miro->aci_product == 'C') { | 761 | if (miro->aci->aci_product == 'C') { |
718 | /* PCM20 with radio and 7 band equalizer */ | 762 | /* PCM20 with radio and 7 band equalizer */ |
719 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_radio_control[0], miro))) < 0) | 763 | if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_miro_radio_control[0], miro))) < 0) |
720 | return err; | 764 | return err; |
@@ -757,21 +801,26 @@ static int __devinit snd_miro_init(struct snd_miro *chip, | |||
757 | chip->irq = -1; | 801 | chip->irq = -1; |
758 | chip->dma1 = -1; | 802 | chip->dma1 = -1; |
759 | chip->dma2 = -1; | 803 | chip->dma2 = -1; |
760 | chip->fm_port = -1; | ||
761 | chip->mpu_port = -1; | 804 | chip->mpu_port = -1; |
762 | chip->mpu_irq = -1; | 805 | chip->mpu_irq = -1; |
763 | 806 | ||
807 | chip->pwd_reg = 3; | ||
808 | |||
809 | #ifdef CONFIG_PNP | ||
810 | if (isapnp && chip->mc_base) | ||
811 | /* PnP resource gives the least 10 bits */ | ||
812 | chip->mc_base |= 0xc00; | ||
813 | else | ||
814 | #endif | ||
815 | chip->mc_base = 0xf8c; | ||
816 | |||
764 | switch (hardware) { | 817 | switch (hardware) { |
765 | case OPTi9XX_HW_82C929: | 818 | case OPTi9XX_HW_82C929: |
766 | chip->mc_base = 0xf8c; | ||
767 | chip->password = 0xe3; | 819 | chip->password = 0xe3; |
768 | chip->pwd_reg = 3; | ||
769 | break; | 820 | break; |
770 | 821 | ||
771 | case OPTi9XX_HW_82C924: | 822 | case OPTi9XX_HW_82C924: |
772 | chip->mc_base = 0xf8c; | ||
773 | chip->password = 0xe5; | 823 | chip->password = 0xe5; |
774 | chip->pwd_reg = 3; | ||
775 | break; | 824 | break; |
776 | 825 | ||
777 | default: | 826 | default: |
@@ -853,14 +902,15 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
853 | struct snd_info_buffer *buffer) | 902 | struct snd_info_buffer *buffer) |
854 | { | 903 | { |
855 | struct snd_miro *miro = (struct snd_miro *) entry->private_data; | 904 | struct snd_miro *miro = (struct snd_miro *) entry->private_data; |
905 | struct snd_miro_aci *aci = miro->aci; | ||
856 | char* model = "unknown"; | 906 | char* model = "unknown"; |
857 | 907 | ||
858 | /* miroSOUND PCM1 pro, early PCM12 */ | 908 | /* miroSOUND PCM1 pro, early PCM12 */ |
859 | 909 | ||
860 | if ((miro->hardware == OPTi9XX_HW_82C929) && | 910 | if ((miro->hardware == OPTi9XX_HW_82C929) && |
861 | (miro->aci_vendor == 'm') && | 911 | (aci->aci_vendor == 'm') && |
862 | (miro->aci_product == 'A')) { | 912 | (aci->aci_product == 'A')) { |
863 | switch(miro->aci_version) { | 913 | switch (aci->aci_version) { |
864 | case 3: | 914 | case 3: |
865 | model = "miroSOUND PCM1 pro"; | 915 | model = "miroSOUND PCM1 pro"; |
866 | break; | 916 | break; |
@@ -873,9 +923,9 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
873 | /* miroSOUND PCM12, PCM12 (Rev. E), PCM12 pnp */ | 923 | /* miroSOUND PCM12, PCM12 (Rev. E), PCM12 pnp */ |
874 | 924 | ||
875 | if ((miro->hardware == OPTi9XX_HW_82C924) && | 925 | if ((miro->hardware == OPTi9XX_HW_82C924) && |
876 | (miro->aci_vendor == 'm') && | 926 | (aci->aci_vendor == 'm') && |
877 | (miro->aci_product == 'B')) { | 927 | (aci->aci_product == 'B')) { |
878 | switch(miro->aci_version) { | 928 | switch (aci->aci_version) { |
879 | case 4: | 929 | case 4: |
880 | model = "miroSOUND PCM12"; | 930 | model = "miroSOUND PCM12"; |
881 | break; | 931 | break; |
@@ -891,9 +941,9 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
891 | /* miroSOUND PCM20 radio */ | 941 | /* miroSOUND PCM20 radio */ |
892 | 942 | ||
893 | if ((miro->hardware == OPTi9XX_HW_82C924) && | 943 | if ((miro->hardware == OPTi9XX_HW_82C924) && |
894 | (miro->aci_vendor == 'm') && | 944 | (aci->aci_vendor == 'm') && |
895 | (miro->aci_product == 'C')) { | 945 | (aci->aci_product == 'C')) { |
896 | switch(miro->aci_version) { | 946 | switch (aci->aci_version) { |
897 | case 7: | 947 | case 7: |
898 | model = "miroSOUND PCM20 radio (Rev. E)"; | 948 | model = "miroSOUND PCM20 radio (Rev. E)"; |
899 | break; | 949 | break; |
@@ -917,17 +967,17 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
917 | 967 | ||
918 | snd_iprintf(buffer, "ACI information:\n"); | 968 | snd_iprintf(buffer, "ACI information:\n"); |
919 | snd_iprintf(buffer, " vendor : "); | 969 | snd_iprintf(buffer, " vendor : "); |
920 | switch(miro->aci_vendor) { | 970 | switch (aci->aci_vendor) { |
921 | case 'm': | 971 | case 'm': |
922 | snd_iprintf(buffer, "Miro\n"); | 972 | snd_iprintf(buffer, "Miro\n"); |
923 | break; | 973 | break; |
924 | default: | 974 | default: |
925 | snd_iprintf(buffer, "unknown (0x%x)\n", miro->aci_vendor); | 975 | snd_iprintf(buffer, "unknown (0x%x)\n", aci->aci_vendor); |
926 | break; | 976 | break; |
927 | } | 977 | } |
928 | 978 | ||
929 | snd_iprintf(buffer, " product : "); | 979 | snd_iprintf(buffer, " product : "); |
930 | switch(miro->aci_product) { | 980 | switch (aci->aci_product) { |
931 | case 'A': | 981 | case 'A': |
932 | snd_iprintf(buffer, "miroSOUND PCM1 pro / (early) PCM12\n"); | 982 | snd_iprintf(buffer, "miroSOUND PCM1 pro / (early) PCM12\n"); |
933 | break; | 983 | break; |
@@ -938,26 +988,27 @@ static void snd_miro_proc_read(struct snd_info_entry * entry, | |||
938 | snd_iprintf(buffer, "miroSOUND PCM20 radio\n"); | 988 | snd_iprintf(buffer, "miroSOUND PCM20 radio\n"); |
939 | break; | 989 | break; |
940 | default: | 990 | default: |
941 | snd_iprintf(buffer, "unknown (0x%x)\n", miro->aci_product); | 991 | snd_iprintf(buffer, "unknown (0x%x)\n", aci->aci_product); |
942 | break; | 992 | break; |
943 | } | 993 | } |
944 | 994 | ||
945 | snd_iprintf(buffer, " firmware: %d (0x%x)\n", | 995 | snd_iprintf(buffer, " firmware: %d (0x%x)\n", |
946 | miro->aci_version, miro->aci_version); | 996 | aci->aci_version, aci->aci_version); |
947 | snd_iprintf(buffer, " port : 0x%lx-0x%lx\n", | 997 | snd_iprintf(buffer, " port : 0x%lx-0x%lx\n", |
948 | miro->aci_port, miro->aci_port+2); | 998 | aci->aci_port, aci->aci_port+2); |
949 | snd_iprintf(buffer, " wss : 0x%x\n", wss); | 999 | snd_iprintf(buffer, " wss : 0x%x\n", wss); |
950 | snd_iprintf(buffer, " ide : 0x%x\n", ide); | 1000 | snd_iprintf(buffer, " ide : 0x%x\n", ide); |
951 | snd_iprintf(buffer, " solomode: 0x%x\n", miro->aci_solomode); | 1001 | snd_iprintf(buffer, " solomode: 0x%x\n", aci->aci_solomode); |
952 | snd_iprintf(buffer, " amp : 0x%x\n", miro->aci_amp); | 1002 | snd_iprintf(buffer, " amp : 0x%x\n", aci->aci_amp); |
953 | snd_iprintf(buffer, " preamp : 0x%x\n", miro->aci_preamp); | 1003 | snd_iprintf(buffer, " preamp : 0x%x\n", aci->aci_preamp); |
954 | } | 1004 | } |
955 | 1005 | ||
956 | static void __devinit snd_miro_proc_init(struct snd_miro * miro) | 1006 | static void __devinit snd_miro_proc_init(struct snd_card *card, |
1007 | struct snd_miro *miro) | ||
957 | { | 1008 | { |
958 | struct snd_info_entry *entry; | 1009 | struct snd_info_entry *entry; |
959 | 1010 | ||
960 | if (! snd_card_proc_new(miro->card, "miro", &entry)) | 1011 | if (!snd_card_proc_new(card, "miro", &entry)) |
961 | snd_info_set_text_ops(entry, miro, snd_miro_proc_read); | 1012 | snd_info_set_text_ops(entry, miro, snd_miro_proc_read); |
962 | } | 1013 | } |
963 | 1014 | ||
@@ -974,37 +1025,40 @@ static int __devinit snd_miro_configure(struct snd_miro *chip) | |||
974 | unsigned char mpu_irq_bits; | 1025 | unsigned char mpu_irq_bits; |
975 | unsigned long flags; | 1026 | unsigned long flags; |
976 | 1027 | ||
1028 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80); | ||
1029 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(2), 0x20, 0x20); /* OPL4 */ | ||
1030 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02); | ||
1031 | |||
977 | switch (chip->hardware) { | 1032 | switch (chip->hardware) { |
978 | case OPTi9XX_HW_82C924: | 1033 | case OPTi9XX_HW_82C924: |
979 | snd_miro_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02); | 1034 | 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); | 1035 | 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; | 1036 | break; |
985 | case OPTi9XX_HW_82C929: | 1037 | case OPTi9XX_HW_82C929: |
986 | /* untested init commands for OPTi929 */ | 1038 | /* 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); | 1039 | 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; | 1040 | break; |
992 | default: | 1041 | default: |
993 | snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); | 1042 | snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); |
994 | return -EINVAL; | 1043 | return -EINVAL; |
995 | } | 1044 | } |
996 | 1045 | ||
997 | switch (chip->wss_base) { | 1046 | /* PnP resource says it decodes only 10 bits of address */ |
998 | case 0x530: | 1047 | switch (chip->wss_base & 0x3ff) { |
1048 | case 0x130: | ||
1049 | chip->wss_base = 0x530; | ||
999 | wss_base_bits = 0x00; | 1050 | wss_base_bits = 0x00; |
1000 | break; | 1051 | break; |
1001 | case 0x604: | 1052 | case 0x204: |
1053 | chip->wss_base = 0x604; | ||
1002 | wss_base_bits = 0x03; | 1054 | wss_base_bits = 0x03; |
1003 | break; | 1055 | break; |
1004 | case 0xe80: | 1056 | case 0x280: |
1057 | chip->wss_base = 0xe80; | ||
1005 | wss_base_bits = 0x01; | 1058 | wss_base_bits = 0x01; |
1006 | break; | 1059 | break; |
1007 | case 0xf40: | 1060 | case 0x340: |
1061 | chip->wss_base = 0xf40; | ||
1008 | wss_base_bits = 0x02; | 1062 | wss_base_bits = 0x02; |
1009 | break; | 1063 | break; |
1010 | default: | 1064 | default: |
@@ -1122,75 +1176,92 @@ __skip_mpu: | |||
1122 | return 0; | 1176 | return 0; |
1123 | } | 1177 | } |
1124 | 1178 | ||
1179 | static int __devinit snd_miro_opti_check(struct snd_miro *chip) | ||
1180 | { | ||
1181 | unsigned char value; | ||
1182 | |||
1183 | chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, | ||
1184 | "OPTi9xx MC"); | ||
1185 | if (chip->res_mc_base == NULL) | ||
1186 | return -ENOMEM; | ||
1187 | |||
1188 | value = snd_miro_read(chip, OPTi9XX_MC_REG(1)); | ||
1189 | if (value != 0xff && value != inb(chip->mc_base + OPTi9XX_MC_REG(1))) | ||
1190 | if (value == snd_miro_read(chip, OPTi9XX_MC_REG(1))) | ||
1191 | return 0; | ||
1192 | |||
1193 | release_and_free_resource(chip->res_mc_base); | ||
1194 | chip->res_mc_base = NULL; | ||
1195 | |||
1196 | return -ENODEV; | ||
1197 | } | ||
1198 | |||
1125 | static int __devinit snd_card_miro_detect(struct snd_card *card, | 1199 | static int __devinit snd_card_miro_detect(struct snd_card *card, |
1126 | struct snd_miro *chip) | 1200 | struct snd_miro *chip) |
1127 | { | 1201 | { |
1128 | int i, err; | 1202 | int i, err; |
1129 | unsigned char value; | ||
1130 | 1203 | ||
1131 | for (i = OPTi9XX_HW_82C929; i <= OPTi9XX_HW_82C924; i++) { | 1204 | for (i = OPTi9XX_HW_82C929; i <= OPTi9XX_HW_82C924; i++) { |
1132 | 1205 | ||
1133 | if ((err = snd_miro_init(chip, i)) < 0) | 1206 | if ((err = snd_miro_init(chip, i)) < 0) |
1134 | return err; | 1207 | return err; |
1135 | 1208 | ||
1136 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) | 1209 | err = snd_miro_opti_check(chip); |
1137 | continue; | 1210 | if (err == 0) |
1138 | 1211 | 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 | } | 1212 | } |
1148 | 1213 | ||
1149 | return -ENODEV; | 1214 | return -ENODEV; |
1150 | } | 1215 | } |
1151 | 1216 | ||
1152 | static int __devinit snd_card_miro_aci_detect(struct snd_card *card, | 1217 | static int __devinit snd_card_miro_aci_detect(struct snd_card *card, |
1153 | struct snd_miro * miro) | 1218 | struct snd_miro *miro) |
1154 | { | 1219 | { |
1155 | unsigned char regval; | 1220 | unsigned char regval; |
1156 | int i; | 1221 | int i; |
1222 | struct snd_miro_aci *aci = &aci_device; | ||
1223 | |||
1224 | miro->aci = aci; | ||
1157 | 1225 | ||
1158 | mutex_init(&miro->aci_mutex); | 1226 | mutex_init(&aci->aci_mutex); |
1159 | 1227 | ||
1160 | /* get ACI port from OPTi9xx MC 4 */ | 1228 | /* get ACI port from OPTi9xx MC 4 */ |
1161 | 1229 | ||
1162 | miro->mc_base = 0xf8c; | ||
1163 | regval=inb(miro->mc_base + 4); | 1230 | regval=inb(miro->mc_base + 4); |
1164 | miro->aci_port = (regval & 0x10) ? 0x344: 0x354; | 1231 | aci->aci_port = (regval & 0x10) ? 0x344 : 0x354; |
1165 | 1232 | ||
1166 | if ((miro->res_aci_port = request_region(miro->aci_port, 3, "miro aci")) == NULL) { | 1233 | miro->res_aci_port = request_region(aci->aci_port, 3, "miro aci"); |
1234 | if (miro->res_aci_port == NULL) { | ||
1167 | snd_printk(KERN_ERR "aci i/o area 0x%lx-0x%lx already used.\n", | 1235 | snd_printk(KERN_ERR "aci i/o area 0x%lx-0x%lx already used.\n", |
1168 | miro->aci_port, miro->aci_port+2); | 1236 | aci->aci_port, aci->aci_port+2); |
1169 | return -ENOMEM; | 1237 | return -ENOMEM; |
1170 | } | 1238 | } |
1171 | 1239 | ||
1172 | /* force ACI into a known state */ | 1240 | /* force ACI into a known state */ |
1173 | for (i = 0; i < 3; i++) | 1241 | for (i = 0; i < 3; i++) |
1174 | if (aci_cmd(miro, ACI_ERROR_OP, -1, -1) < 0) { | 1242 | if (snd_aci_cmd(aci, ACI_ERROR_OP, -1, -1) < 0) { |
1175 | snd_printk(KERN_ERR "can't force aci into known state.\n"); | 1243 | snd_printk(KERN_ERR "can't force aci into known state.\n"); |
1176 | return -ENXIO; | 1244 | return -ENXIO; |
1177 | } | 1245 | } |
1178 | 1246 | ||
1179 | if ((miro->aci_vendor=aci_cmd(miro, ACI_READ_IDCODE, -1, -1)) < 0 || | 1247 | 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) { | 1248 | 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); | 1249 | if (aci->aci_vendor < 0 || aci->aci_product < 0) { |
1250 | snd_printk(KERN_ERR "can't read aci id on 0x%lx.\n", | ||
1251 | aci->aci_port); | ||
1182 | return -ENXIO; | 1252 | return -ENXIO; |
1183 | } | 1253 | } |
1184 | 1254 | ||
1185 | if ((miro->aci_version=aci_cmd(miro, ACI_READ_VERSION, -1, -1)) < 0) { | 1255 | aci->aci_version = snd_aci_cmd(aci, ACI_READ_VERSION, -1, -1); |
1256 | if (aci->aci_version < 0) { | ||
1186 | snd_printk(KERN_ERR "can't read aci version on 0x%lx.\n", | 1257 | snd_printk(KERN_ERR "can't read aci version on 0x%lx.\n", |
1187 | miro->aci_port); | 1258 | aci->aci_port); |
1188 | return -ENXIO; | 1259 | return -ENXIO; |
1189 | } | 1260 | } |
1190 | 1261 | ||
1191 | if (aci_cmd(miro, ACI_INIT, -1, -1) < 0 || | 1262 | if (snd_aci_cmd(aci, ACI_INIT, -1, -1) < 0 || |
1192 | 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 || |
1193 | aci_cmd(miro, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0) { | 1264 | snd_aci_cmd(aci, ACI_ERROR_OP, ACI_ERROR_OP, ACI_ERROR_OP) < 0) { |
1194 | snd_printk(KERN_ERR "can't initialize aci.\n"); | 1265 | snd_printk(KERN_ERR "can't initialize aci.\n"); |
1195 | return -ENXIO; | 1266 | return -ENXIO; |
1196 | } | 1267 | } |
@@ -1201,157 +1272,80 @@ static int __devinit snd_card_miro_aci_detect(struct snd_card *card, | |||
1201 | static void snd_card_miro_free(struct snd_card *card) | 1272 | static void snd_card_miro_free(struct snd_card *card) |
1202 | { | 1273 | { |
1203 | struct snd_miro *miro = card->private_data; | 1274 | struct snd_miro *miro = card->private_data; |
1204 | 1275 | ||
1205 | release_and_free_resource(miro->res_aci_port); | 1276 | release_and_free_resource(miro->res_aci_port); |
1277 | if (miro->aci) | ||
1278 | miro->aci->aci_port = 0; | ||
1206 | release_and_free_resource(miro->res_mc_base); | 1279 | release_and_free_resource(miro->res_mc_base); |
1207 | } | 1280 | } |
1208 | 1281 | ||
1209 | static int __devinit snd_miro_match(struct device *devptr, unsigned int n) | 1282 | 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 | { | 1283 | { |
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; | 1284 | int error; |
1224 | struct snd_miro *miro; | 1285 | struct snd_miro *miro = card->private_data; |
1225 | struct snd_wss *codec; | 1286 | struct snd_wss *codec; |
1226 | struct snd_timer *timer; | 1287 | struct snd_timer *timer; |
1227 | struct snd_card *card; | ||
1228 | struct snd_pcm *pcm; | 1288 | struct snd_pcm *pcm; |
1229 | struct snd_rawmidi *rmidi; | 1289 | struct snd_rawmidi *rmidi; |
1230 | 1290 | ||
1231 | error = snd_card_create(index, id, THIS_MODULE, | 1291 | if (!miro->res_mc_base) { |
1232 | sizeof(struct snd_miro), &card); | 1292 | miro->res_mc_base = request_region(miro->mc_base, |
1233 | if (error < 0) | 1293 | miro->mc_base_size, |
1234 | return error; | 1294 | "miro (OPTi9xx MC)"); |
1235 | 1295 | if (miro->res_mc_base == NULL) { | |
1236 | card->private_free = snd_card_miro_free; | 1296 | snd_printk(KERN_ERR "request for OPTI9xx MC failed\n"); |
1237 | miro = card->private_data; | 1297 | return -ENOMEM; |
1238 | miro->card = card; | 1298 | } |
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 | } | 1299 | } |
1245 | 1300 | ||
1246 | /* init proc interface */ | 1301 | error = snd_card_miro_aci_detect(card, miro); |
1247 | snd_miro_proc_init(miro); | 1302 | if (error < 0) { |
1248 | |||
1249 | if ((error = snd_card_miro_detect(card, miro)) < 0) { | ||
1250 | snd_card_free(card); | 1303 | snd_card_free(card); |
1251 | snd_printk(KERN_ERR "unable to detect OPTi9xx chip\n"); | 1304 | snd_printk(KERN_ERR "unable to detect aci chip\n"); |
1252 | return -ENODEV; | 1305 | return -ENODEV; |
1253 | } | 1306 | } |
1254 | 1307 | ||
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; | 1308 | miro->wss_base = port; |
1264 | miro->fm_port = fm_port; | ||
1265 | miro->mpu_port = mpu_port; | 1309 | miro->mpu_port = mpu_port; |
1266 | miro->irq = irq; | 1310 | miro->irq = irq; |
1267 | miro->mpu_irq = mpu_irq; | 1311 | miro->mpu_irq = mpu_irq; |
1268 | miro->dma1 = dma1; | 1312 | miro->dma1 = dma1; |
1269 | miro->dma2 = dma2; | 1313 | miro->dma2 = dma2; |
1270 | 1314 | ||
1271 | if (miro->wss_base == SNDRV_AUTO_PORT) { | 1315 | /* init proc interface */ |
1272 | if ((miro->wss_base = snd_legacy_find_free_ioport(possible_ports, 4)) < 0) { | 1316 | 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 | 1317 | ||
1315 | error = snd_miro_configure(miro); | 1318 | error = snd_miro_configure(miro); |
1316 | if (error) { | 1319 | if (error) |
1317 | snd_card_free(card); | ||
1318 | return error; | 1320 | return error; |
1319 | } | ||
1320 | 1321 | ||
1321 | error = snd_wss_create(card, miro->wss_base + 4, -1, | 1322 | error = snd_wss_create(card, miro->wss_base + 4, -1, |
1322 | miro->irq, miro->dma1, miro->dma2, | 1323 | miro->irq, miro->dma1, miro->dma2, |
1323 | WSS_HW_AD1845, 0, &codec); | 1324 | WSS_HW_DETECT, 0, &codec); |
1324 | if (error < 0) { | 1325 | if (error < 0) |
1325 | snd_card_free(card); | ||
1326 | return error; | 1326 | return error; |
1327 | } | ||
1328 | 1327 | ||
1329 | error = snd_wss_pcm(codec, 0, &pcm); | 1328 | error = snd_wss_pcm(codec, 0, &pcm); |
1330 | if (error < 0) { | 1329 | if (error < 0) |
1331 | snd_card_free(card); | ||
1332 | return error; | 1330 | return error; |
1333 | } | 1331 | |
1334 | error = snd_wss_mixer(codec); | 1332 | error = snd_wss_mixer(codec); |
1335 | if (error < 0) { | 1333 | if (error < 0) |
1336 | snd_card_free(card); | ||
1337 | return error; | 1334 | return error; |
1338 | } | 1335 | |
1339 | error = snd_wss_timer(codec, 0, &timer); | 1336 | error = snd_wss_timer(codec, 0, &timer); |
1340 | if (error < 0) { | 1337 | if (error < 0) |
1341 | snd_card_free(card); | ||
1342 | return error; | 1338 | return error; |
1343 | } | ||
1344 | 1339 | ||
1345 | miro->pcm = pcm; | 1340 | miro->pcm = pcm; |
1346 | 1341 | ||
1347 | if ((error = snd_miro_mixer(miro)) < 0) { | 1342 | error = snd_miro_mixer(card, miro); |
1348 | snd_card_free(card); | 1343 | if (error < 0) |
1349 | return error; | 1344 | return error; |
1350 | } | ||
1351 | 1345 | ||
1352 | if (miro->aci_vendor == 'm') { | 1346 | if (miro->aci->aci_vendor == 'm') { |
1353 | /* It looks like a miro sound card. */ | 1347 | /* It looks like a miro sound card. */ |
1354 | switch (miro->aci_product) { | 1348 | switch (miro->aci->aci_product) { |
1355 | case 'A': | 1349 | case 'A': |
1356 | sprintf(card->shortname, | 1350 | sprintf(card->shortname, |
1357 | "miroSOUND PCM1 pro / PCM12"); | 1351 | "miroSOUND PCM1 pro / PCM12"); |
@@ -1380,30 +1374,131 @@ static int __devinit snd_miro_probe(struct device *devptr, unsigned int n) | |||
1380 | card->shortname, miro->name, pcm->name, miro->wss_base + 4, | 1374 | card->shortname, miro->name, pcm->name, miro->wss_base + 4, |
1381 | miro->irq, miro->dma1, miro->dma2); | 1375 | miro->irq, miro->dma1, miro->dma2); |
1382 | 1376 | ||
1383 | if (miro->mpu_port <= 0 || miro->mpu_port == SNDRV_AUTO_PORT) | 1377 | if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) |
1384 | rmidi = NULL; | 1378 | rmidi = NULL; |
1385 | else | 1379 | else { |
1386 | if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, | 1380 | error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, |
1387 | miro->mpu_port, 0, miro->mpu_irq, IRQF_DISABLED, | 1381 | mpu_port, 0, miro->mpu_irq, IRQF_DISABLED, |
1388 | &rmidi))) | 1382 | &rmidi); |
1389 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", miro->mpu_port); | 1383 | if (error < 0) |
1384 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", | ||
1385 | mpu_port); | ||
1386 | } | ||
1390 | 1387 | ||
1391 | if (miro->fm_port > 0 && miro->fm_port != SNDRV_AUTO_PORT) { | 1388 | if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) { |
1392 | struct snd_opl3 *opl3 = NULL; | 1389 | struct snd_opl3 *opl3 = NULL; |
1393 | struct snd_opl4 *opl4; | 1390 | struct snd_opl4 *opl4; |
1394 | if (snd_opl4_create(card, miro->fm_port, miro->fm_port - 8, | 1391 | |
1392 | if (snd_opl4_create(card, fm_port, fm_port - 8, | ||
1395 | 2, &opl3, &opl4) < 0) | 1393 | 2, &opl3, &opl4) < 0) |
1396 | snd_printk(KERN_WARNING "no OPL4 device at 0x%lx\n", miro->fm_port); | 1394 | snd_printk(KERN_WARNING "no OPL4 device at 0x%lx\n", |
1395 | fm_port); | ||
1397 | } | 1396 | } |
1398 | 1397 | ||
1399 | if ((error = snd_set_aci_init_values(miro)) < 0) { | 1398 | error = snd_set_aci_init_values(miro); |
1400 | snd_card_free(card); | 1399 | if (error < 0) |
1401 | return error; | 1400 | return error; |
1401 | |||
1402 | return snd_card_register(card); | ||
1403 | } | ||
1404 | |||
1405 | static int __devinit snd_miro_isa_match(struct device *devptr, unsigned int n) | ||
1406 | { | ||
1407 | #ifdef CONFIG_PNP | ||
1408 | if (snd_miro_pnp_is_probed) | ||
1409 | return 0; | ||
1410 | if (isapnp) | ||
1411 | return 0; | ||
1412 | #endif | ||
1413 | return 1; | ||
1414 | } | ||
1415 | |||
1416 | static int __devinit snd_miro_isa_probe(struct device *devptr, unsigned int n) | ||
1417 | { | ||
1418 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; | ||
1419 | static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1}; | ||
1420 | static int possible_irqs[] = {11, 9, 10, 7, -1}; | ||
1421 | static int possible_mpu_irqs[] = {10, 5, 9, 7, -1}; | ||
1422 | static int possible_dma1s[] = {3, 1, 0, -1}; | ||
1423 | static int possible_dma2s[][2] = { {1, -1}, {0, -1}, {-1, -1}, | ||
1424 | {0, -1} }; | ||
1425 | |||
1426 | int error; | ||
1427 | struct snd_miro *miro; | ||
1428 | struct snd_card *card; | ||
1429 | |||
1430 | error = snd_card_create(index, id, THIS_MODULE, | ||
1431 | sizeof(struct snd_miro), &card); | ||
1432 | if (error < 0) | ||
1433 | return error; | ||
1434 | |||
1435 | card->private_free = snd_card_miro_free; | ||
1436 | miro = card->private_data; | ||
1437 | |||
1438 | error = snd_card_miro_detect(card, miro); | ||
1439 | if (error < 0) { | ||
1440 | snd_card_free(card); | ||
1441 | snd_printk(KERN_ERR "unable to detect OPTi9xx chip\n"); | ||
1442 | return -ENODEV; | ||
1443 | } | ||
1444 | |||
1445 | if (port == SNDRV_AUTO_PORT) { | ||
1446 | port = snd_legacy_find_free_ioport(possible_ports, 4); | ||
1447 | if (port < 0) { | ||
1448 | snd_card_free(card); | ||
1449 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); | ||
1450 | return -EBUSY; | ||
1451 | } | ||
1452 | } | ||
1453 | |||
1454 | if (mpu_port == SNDRV_AUTO_PORT) { | ||
1455 | mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2); | ||
1456 | if (mpu_port < 0) { | ||
1457 | snd_card_free(card); | ||
1458 | snd_printk(KERN_ERR | ||
1459 | "unable to find a free MPU401 port\n"); | ||
1460 | return -EBUSY; | ||
1461 | } | ||
1462 | } | ||
1463 | |||
1464 | if (irq == SNDRV_AUTO_IRQ) { | ||
1465 | irq = snd_legacy_find_free_irq(possible_irqs); | ||
1466 | if (irq < 0) { | ||
1467 | snd_card_free(card); | ||
1468 | snd_printk(KERN_ERR "unable to find a free IRQ\n"); | ||
1469 | return -EBUSY; | ||
1470 | } | ||
1471 | } | ||
1472 | if (mpu_irq == SNDRV_AUTO_IRQ) { | ||
1473 | mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs); | ||
1474 | if (mpu_irq < 0) { | ||
1475 | snd_card_free(card); | ||
1476 | snd_printk(KERN_ERR | ||
1477 | "unable to find a free MPU401 IRQ\n"); | ||
1478 | return -EBUSY; | ||
1479 | } | ||
1480 | } | ||
1481 | if (dma1 == SNDRV_AUTO_DMA) { | ||
1482 | dma1 = snd_legacy_find_free_dma(possible_dma1s); | ||
1483 | if (dma1 < 0) { | ||
1484 | snd_card_free(card); | ||
1485 | snd_printk(KERN_ERR "unable to find a free DMA1\n"); | ||
1486 | return -EBUSY; | ||
1487 | } | ||
1488 | } | ||
1489 | if (dma2 == SNDRV_AUTO_DMA) { | ||
1490 | dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4]); | ||
1491 | if (dma2 < 0) { | ||
1492 | snd_card_free(card); | ||
1493 | snd_printk(KERN_ERR "unable to find a free DMA2\n"); | ||
1494 | return -EBUSY; | ||
1495 | } | ||
1402 | } | 1496 | } |
1403 | 1497 | ||
1404 | snd_card_set_dev(card, devptr); | 1498 | snd_card_set_dev(card, devptr); |
1405 | 1499 | ||
1406 | if ((error = snd_card_register(card))) { | 1500 | error = snd_miro_probe(card); |
1501 | if (error < 0) { | ||
1407 | snd_card_free(card); | 1502 | snd_card_free(card); |
1408 | return error; | 1503 | return error; |
1409 | } | 1504 | } |
@@ -1412,7 +1507,8 @@ static int __devinit snd_miro_probe(struct device *devptr, unsigned int n) | |||
1412 | return 0; | 1507 | return 0; |
1413 | } | 1508 | } |
1414 | 1509 | ||
1415 | static int __devexit snd_miro_remove(struct device *devptr, unsigned int dev) | 1510 | static int __devexit snd_miro_isa_remove(struct device *devptr, |
1511 | unsigned int dev) | ||
1416 | { | 1512 | { |
1417 | snd_card_free(dev_get_drvdata(devptr)); | 1513 | snd_card_free(dev_get_drvdata(devptr)); |
1418 | dev_set_drvdata(devptr, NULL); | 1514 | dev_set_drvdata(devptr, NULL); |
@@ -1422,23 +1518,164 @@ static int __devexit snd_miro_remove(struct device *devptr, unsigned int dev) | |||
1422 | #define DEV_NAME "miro" | 1518 | #define DEV_NAME "miro" |
1423 | 1519 | ||
1424 | static struct isa_driver snd_miro_driver = { | 1520 | static struct isa_driver snd_miro_driver = { |
1425 | .match = snd_miro_match, | 1521 | .match = snd_miro_isa_match, |
1426 | .probe = snd_miro_probe, | 1522 | .probe = snd_miro_isa_probe, |
1427 | .remove = __devexit_p(snd_miro_remove), | 1523 | .remove = __devexit_p(snd_miro_isa_remove), |
1428 | /* FIXME: suspend/resume */ | 1524 | /* FIXME: suspend/resume */ |
1429 | .driver = { | 1525 | .driver = { |
1430 | .name = DEV_NAME | 1526 | .name = DEV_NAME |
1431 | }, | 1527 | }, |
1432 | }; | 1528 | }; |
1433 | 1529 | ||
1530 | #ifdef CONFIG_PNP | ||
1531 | |||
1532 | static int __devinit snd_card_miro_pnp(struct snd_miro *chip, | ||
1533 | struct pnp_card_link *card, | ||
1534 | const struct pnp_card_device_id *pid) | ||
1535 | { | ||
1536 | struct pnp_dev *pdev; | ||
1537 | int err; | ||
1538 | struct pnp_dev *devmpu; | ||
1539 | struct pnp_dev *devmc; | ||
1540 | |||
1541 | pdev = pnp_request_card_device(card, pid->devs[0].id, NULL); | ||
1542 | if (pdev == NULL) | ||
1543 | return -EBUSY; | ||
1544 | |||
1545 | devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL); | ||
1546 | if (devmpu == NULL) | ||
1547 | return -EBUSY; | ||
1548 | |||
1549 | devmc = pnp_request_card_device(card, pid->devs[2].id, NULL); | ||
1550 | if (devmc == NULL) | ||
1551 | return -EBUSY; | ||
1552 | |||
1553 | err = pnp_activate_dev(pdev); | ||
1554 | if (err < 0) { | ||
1555 | snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err); | ||
1556 | return err; | ||
1557 | } | ||
1558 | |||
1559 | err = pnp_activate_dev(devmc); | ||
1560 | if (err < 0) { | ||
1561 | snd_printk(KERN_ERR "OPL syntg pnp configure failure: %d\n", | ||
1562 | err); | ||
1563 | return err; | ||
1564 | } | ||
1565 | |||
1566 | port = pnp_port_start(pdev, 1); | ||
1567 | fm_port = pnp_port_start(pdev, 2) + 8; | ||
1568 | |||
1569 | /* | ||
1570 | * The MC(0) is never accessed and the miroSOUND PCM20 card does not | ||
1571 | * include it in the PnP resource range. OPTI93x include it. | ||
1572 | */ | ||
1573 | chip->mc_base = pnp_port_start(devmc, 0) - 1; | ||
1574 | chip->mc_base_size = pnp_port_len(devmc, 0) + 1; | ||
1575 | |||
1576 | irq = pnp_irq(pdev, 0); | ||
1577 | dma1 = pnp_dma(pdev, 0); | ||
1578 | dma2 = pnp_dma(pdev, 1); | ||
1579 | |||
1580 | if (mpu_port > 0) { | ||
1581 | err = pnp_activate_dev(devmpu); | ||
1582 | if (err < 0) { | ||
1583 | snd_printk(KERN_ERR "MPU401 pnp configure failure\n"); | ||
1584 | mpu_port = -1; | ||
1585 | return err; | ||
1586 | } | ||
1587 | mpu_port = pnp_port_start(devmpu, 0); | ||
1588 | mpu_irq = pnp_irq(devmpu, 0); | ||
1589 | } | ||
1590 | return 0; | ||
1591 | } | ||
1592 | |||
1593 | static int __devinit snd_miro_pnp_probe(struct pnp_card_link *pcard, | ||
1594 | const struct pnp_card_device_id *pid) | ||
1595 | { | ||
1596 | struct snd_card *card; | ||
1597 | int err; | ||
1598 | struct snd_miro *miro; | ||
1599 | |||
1600 | if (snd_miro_pnp_is_probed) | ||
1601 | return -EBUSY; | ||
1602 | if (!isapnp) | ||
1603 | return -ENODEV; | ||
1604 | err = snd_card_create(index, id, THIS_MODULE, | ||
1605 | sizeof(struct snd_miro), &card); | ||
1606 | if (err < 0) | ||
1607 | return err; | ||
1608 | |||
1609 | card->private_free = snd_card_miro_free; | ||
1610 | miro = card->private_data; | ||
1611 | |||
1612 | err = snd_card_miro_pnp(miro, pcard, pid); | ||
1613 | if (err) { | ||
1614 | snd_card_free(card); | ||
1615 | return err; | ||
1616 | } | ||
1617 | |||
1618 | /* only miroSOUND PCM20 and PCM12 == OPTi924 */ | ||
1619 | err = snd_miro_init(miro, OPTi9XX_HW_82C924); | ||
1620 | if (err) { | ||
1621 | snd_card_free(card); | ||
1622 | return err; | ||
1623 | } | ||
1624 | |||
1625 | err = snd_miro_opti_check(miro); | ||
1626 | if (err) { | ||
1627 | snd_printk(KERN_ERR "OPTI chip not found\n"); | ||
1628 | snd_card_free(card); | ||
1629 | return err; | ||
1630 | } | ||
1631 | |||
1632 | snd_card_set_dev(card, &pcard->card->dev); | ||
1633 | err = snd_miro_probe(card); | ||
1634 | if (err < 0) { | ||
1635 | snd_card_free(card); | ||
1636 | return err; | ||
1637 | } | ||
1638 | pnp_set_card_drvdata(pcard, card); | ||
1639 | snd_miro_pnp_is_probed = 1; | ||
1640 | return 0; | ||
1641 | } | ||
1642 | |||
1643 | static void __devexit snd_miro_pnp_remove(struct pnp_card_link * pcard) | ||
1644 | { | ||
1645 | snd_card_free(pnp_get_card_drvdata(pcard)); | ||
1646 | pnp_set_card_drvdata(pcard, NULL); | ||
1647 | snd_miro_pnp_is_probed = 0; | ||
1648 | } | ||
1649 | |||
1650 | static struct pnp_card_driver miro_pnpc_driver = { | ||
1651 | .flags = PNP_DRIVER_RES_DISABLE, | ||
1652 | .name = "miro", | ||
1653 | .id_table = snd_miro_pnpids, | ||
1654 | .probe = snd_miro_pnp_probe, | ||
1655 | .remove = __devexit_p(snd_miro_pnp_remove), | ||
1656 | }; | ||
1657 | #endif | ||
1658 | |||
1434 | static int __init alsa_card_miro_init(void) | 1659 | static int __init alsa_card_miro_init(void) |
1435 | { | 1660 | { |
1661 | #ifdef CONFIG_PNP | ||
1662 | pnp_register_card_driver(&miro_pnpc_driver); | ||
1663 | if (snd_miro_pnp_is_probed) | ||
1664 | return 0; | ||
1665 | pnp_unregister_card_driver(&miro_pnpc_driver); | ||
1666 | #endif | ||
1436 | return isa_register_driver(&snd_miro_driver, 1); | 1667 | return isa_register_driver(&snd_miro_driver, 1); |
1437 | } | 1668 | } |
1438 | 1669 | ||
1439 | static void __exit alsa_card_miro_exit(void) | 1670 | static void __exit alsa_card_miro_exit(void) |
1440 | { | 1671 | { |
1441 | isa_unregister_driver(&snd_miro_driver); | 1672 | if (!snd_miro_pnp_is_probed) { |
1673 | isa_unregister_driver(&snd_miro_driver); | ||
1674 | return; | ||
1675 | } | ||
1676 | #ifdef CONFIG_PNP | ||
1677 | pnp_unregister_card_driver(&miro_pnpc_driver); | ||
1678 | #endif | ||
1442 | } | 1679 | } |
1443 | 1680 | ||
1444 | module_init(alsa_card_miro_init) | 1681 | 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..c8a8da0d4036 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c | |||
@@ -135,21 +135,15 @@ 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; |
141 | 143 | ||
142 | spinlock_t lock; | 144 | spinlock_t lock; |
143 | 145 | ||
144 | long wss_base; | ||
145 | int irq; | 146 | int irq; |
146 | int dma1; | ||
147 | int dma2; | ||
148 | |||
149 | long fm_port; | ||
150 | |||
151 | long mpu_port; | ||
152 | int mpu_irq; | ||
153 | 147 | ||
154 | #ifdef CONFIG_PNP | 148 | #ifdef CONFIG_PNP |
155 | struct pnp_dev *dev; | 149 | struct pnp_dev *dev; |
@@ -185,7 +179,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids); | |||
185 | #endif | 179 | #endif |
186 | 180 | ||
187 | static char * snd_opti9xx_names[] = { | 181 | static char * snd_opti9xx_names[] = { |
188 | "unkown", | 182 | "unknown", |
189 | "82C928", "82C929", | 183 | "82C928", "82C929", |
190 | "82C924", "82C925", | 184 | "82C924", "82C925", |
191 | "82C930", "82C931", "82C933" | 185 | "82C930", "82C931", "82C933" |
@@ -216,13 +210,7 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, | |||
216 | 210 | ||
217 | spin_lock_init(&chip->lock); | 211 | spin_lock_init(&chip->lock); |
218 | 212 | ||
219 | chip->wss_base = -1; | ||
220 | chip->irq = -1; | 213 | chip->irq = -1; |
221 | chip->dma1 = -1; | ||
222 | chip->dma2 = -1; | ||
223 | chip->fm_port = -1; | ||
224 | chip->mpu_port = -1; | ||
225 | chip->mpu_irq = -1; | ||
226 | 214 | ||
227 | switch (hardware) { | 215 | switch (hardware) { |
228 | #ifndef OPTi93X | 216 | #ifndef OPTi93X |
@@ -245,7 +233,10 @@ static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, | |||
245 | case OPTi9XX_HW_82C931: | 233 | case OPTi9XX_HW_82C931: |
246 | case OPTi9XX_HW_82C933: | 234 | case OPTi9XX_HW_82C933: |
247 | chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d; | 235 | chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d; |
248 | chip->mc_indir_index = 0xe0e; | 236 | if (!chip->mc_indir_index) { |
237 | chip->mc_indir_index = 0xe0e; | ||
238 | chip->mc_indir_size = 2; | ||
239 | } | ||
249 | chip->password = 0xe4; | 240 | chip->password = 0xe4; |
250 | chip->pwd_reg = 0; | 241 | chip->pwd_reg = 0; |
251 | break; | 242 | break; |
@@ -348,7 +339,10 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, | |||
348 | (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) | 339 | (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) |
349 | 340 | ||
350 | 341 | ||
351 | static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) | 342 | static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip, |
343 | long wss_base, | ||
344 | int irq, int dma1, int dma2, | ||
345 | long mpu_port, int mpu_irq) | ||
352 | { | 346 | { |
353 | unsigned char wss_base_bits; | 347 | unsigned char wss_base_bits; |
354 | unsigned char irq_bits; | 348 | unsigned char irq_bits; |
@@ -416,7 +410,7 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) | |||
416 | return -EINVAL; | 410 | return -EINVAL; |
417 | } | 411 | } |
418 | 412 | ||
419 | switch (chip->wss_base) { | 413 | switch (wss_base) { |
420 | case 0x530: | 414 | case 0x530: |
421 | wss_base_bits = 0x00; | 415 | wss_base_bits = 0x00; |
422 | break; | 416 | break; |
@@ -430,14 +424,13 @@ static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) | |||
430 | wss_base_bits = 0x02; | 424 | wss_base_bits = 0x02; |
431 | break; | 425 | break; |
432 | default: | 426 | default: |
433 | snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", | 427 | snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", wss_base); |
434 | chip->wss_base); | ||
435 | goto __skip_base; | 428 | goto __skip_base; |
436 | } | 429 | } |
437 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); | 430 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30); |
438 | 431 | ||
439 | __skip_base: | 432 | __skip_base: |
440 | switch (chip->irq) { | 433 | switch (irq) { |
441 | //#ifdef OPTi93X | 434 | //#ifdef OPTi93X |
442 | case 5: | 435 | case 5: |
443 | irq_bits = 0x05; | 436 | irq_bits = 0x05; |
@@ -456,11 +449,11 @@ __skip_base: | |||
456 | irq_bits = 0x04; | 449 | irq_bits = 0x04; |
457 | break; | 450 | break; |
458 | default: | 451 | default: |
459 | snd_printk(KERN_WARNING "WSS irq # %d not valid\n", chip->irq); | 452 | snd_printk(KERN_WARNING "WSS irq # %d not valid\n", irq); |
460 | goto __skip_resources; | 453 | goto __skip_resources; |
461 | } | 454 | } |
462 | 455 | ||
463 | switch (chip->dma1) { | 456 | switch (dma1) { |
464 | case 0: | 457 | case 0: |
465 | dma_bits = 0x01; | 458 | dma_bits = 0x01; |
466 | break; | 459 | break; |
@@ -471,38 +464,36 @@ __skip_base: | |||
471 | dma_bits = 0x03; | 464 | dma_bits = 0x03; |
472 | break; | 465 | break; |
473 | default: | 466 | default: |
474 | snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", | 467 | snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", dma1); |
475 | chip->dma1); | ||
476 | goto __skip_resources; | 468 | goto __skip_resources; |
477 | } | 469 | } |
478 | 470 | ||
479 | #if defined(CS4231) || defined(OPTi93X) | 471 | #if defined(CS4231) || defined(OPTi93X) |
480 | if (chip->dma1 == chip->dma2) { | 472 | if (dma1 == dma2) { |
481 | snd_printk(KERN_ERR "don't want to share dmas\n"); | 473 | snd_printk(KERN_ERR "don't want to share dmas\n"); |
482 | return -EBUSY; | 474 | return -EBUSY; |
483 | } | 475 | } |
484 | 476 | ||
485 | switch (chip->dma2) { | 477 | switch (dma2) { |
486 | case 0: | 478 | case 0: |
487 | case 1: | 479 | case 1: |
488 | break; | 480 | break; |
489 | default: | 481 | default: |
490 | snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", | 482 | snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", dma2); |
491 | chip->dma2); | ||
492 | goto __skip_resources; | 483 | goto __skip_resources; |
493 | } | 484 | } |
494 | dma_bits |= 0x04; | 485 | dma_bits |= 0x04; |
495 | #endif /* CS4231 || OPTi93X */ | 486 | #endif /* CS4231 || OPTi93X */ |
496 | 487 | ||
497 | #ifndef OPTi93X | 488 | #ifndef OPTi93X |
498 | outb(irq_bits << 3 | dma_bits, chip->wss_base); | 489 | outb(irq_bits << 3 | dma_bits, wss_base); |
499 | #else /* OPTi93X */ | 490 | #else /* OPTi93X */ |
500 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits)); | 491 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits)); |
501 | #endif /* OPTi93X */ | 492 | #endif /* OPTi93X */ |
502 | 493 | ||
503 | __skip_resources: | 494 | __skip_resources: |
504 | if (chip->hardware > OPTi9XX_HW_82C928) { | 495 | if (chip->hardware > OPTi9XX_HW_82C928) { |
505 | switch (chip->mpu_port) { | 496 | switch (mpu_port) { |
506 | case 0: | 497 | case 0: |
507 | case -1: | 498 | case -1: |
508 | break; | 499 | break; |
@@ -520,12 +511,11 @@ __skip_resources: | |||
520 | break; | 511 | break; |
521 | default: | 512 | default: |
522 | snd_printk(KERN_WARNING | 513 | snd_printk(KERN_WARNING |
523 | "MPU-401 port 0x%lx not valid\n", | 514 | "MPU-401 port 0x%lx not valid\n", mpu_port); |
524 | chip->mpu_port); | ||
525 | goto __skip_mpu; | 515 | goto __skip_mpu; |
526 | } | 516 | } |
527 | 517 | ||
528 | switch (chip->mpu_irq) { | 518 | switch (mpu_irq) { |
529 | case 5: | 519 | case 5: |
530 | mpu_irq_bits = 0x02; | 520 | mpu_irq_bits = 0x02; |
531 | break; | 521 | break; |
@@ -540,12 +530,12 @@ __skip_resources: | |||
540 | break; | 530 | break; |
541 | default: | 531 | default: |
542 | snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n", | 532 | snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n", |
543 | chip->mpu_irq); | 533 | mpu_irq); |
544 | goto __skip_mpu; | 534 | goto __skip_mpu; |
545 | } | 535 | } |
546 | 536 | ||
547 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), | 537 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), |
548 | (chip->mpu_port <= 0) ? 0x00 : | 538 | (mpu_port <= 0) ? 0x00 : |
549 | 0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3, | 539 | 0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3, |
550 | 0xf8); | 540 | 0xf8); |
551 | } | 541 | } |
@@ -558,10 +548,13 @@ __skip_mpu: | |||
558 | 548 | ||
559 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) | 549 | static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) |
560 | { | 550 | { |
561 | struct snd_wss *codec = dev_id; | 551 | struct snd_opti9xx *chip = dev_id; |
562 | struct snd_opti9xx *chip = codec->card->private_data; | 552 | struct snd_wss *codec = chip->codec; |
563 | unsigned char status; | 553 | unsigned char status; |
564 | 554 | ||
555 | if (!codec) | ||
556 | return IRQ_HANDLED; | ||
557 | |||
565 | status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11)); | 558 | status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11)); |
566 | if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream) | 559 | if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream) |
567 | snd_pcm_period_elapsed(codec->playback_substream); | 560 | snd_pcm_period_elapsed(codec->playback_substream); |
@@ -575,57 +568,69 @@ static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id) | |||
575 | 568 | ||
576 | #endif /* OPTi93X */ | 569 | #endif /* OPTi93X */ |
577 | 570 | ||
578 | static int __devinit snd_card_opti9xx_detect(struct snd_card *card, | 571 | static int __devinit snd_opti9xx_read_check(struct snd_opti9xx *chip) |
579 | struct snd_opti9xx *chip) | ||
580 | { | 572 | { |
581 | int i, err; | 573 | unsigned char value; |
574 | #ifdef OPTi93X | ||
575 | unsigned long flags; | ||
576 | #endif | ||
582 | 577 | ||
578 | chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, | ||
579 | "OPTi9xx MC"); | ||
580 | if (chip->res_mc_base == NULL) | ||
581 | return -EBUSY; | ||
583 | #ifndef OPTi93X | 582 | #ifndef OPTi93X |
584 | for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) { | 583 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)); |
585 | unsigned char value; | 584 | if (value != 0xff && value != inb(chip->mc_base + OPTi9XX_MC_REG(1))) |
585 | if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) | ||
586 | return 0; | ||
587 | #else /* OPTi93X */ | ||
588 | chip->res_mc_indir = request_region(chip->mc_indir_index, | ||
589 | chip->mc_indir_size, | ||
590 | "OPTi93x MC"); | ||
591 | if (chip->res_mc_indir == NULL) | ||
592 | return -EBUSY; | ||
586 | 593 | ||
587 | if ((err = snd_opti9xx_init(chip, i)) < 0) | 594 | spin_lock_irqsave(&chip->lock, flags); |
588 | return err; | 595 | outb(chip->password, chip->mc_base + chip->pwd_reg); |
596 | outb(((chip->mc_indir_index & 0x1f0) >> 4), chip->mc_base); | ||
597 | spin_unlock_irqrestore(&chip->lock, flags); | ||
589 | 598 | ||
590 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) | 599 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)); |
591 | continue; | 600 | snd_opti9xx_write(chip, OPTi9XX_MC_REG(7), 0xff - value); |
601 | if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value) | ||
602 | return 0; | ||
592 | 603 | ||
593 | value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)); | 604 | release_and_free_resource(chip->res_mc_indir); |
594 | if ((value != 0xff) && (value != inb(chip->mc_base + 1))) | 605 | chip->res_mc_indir = NULL; |
595 | if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) | 606 | #endif /* OPTi93X */ |
596 | return 1; | 607 | release_and_free_resource(chip->res_mc_base); |
608 | chip->res_mc_base = NULL; | ||
597 | 609 | ||
598 | release_and_free_resource(chip->res_mc_base); | 610 | return -ENODEV; |
599 | chip->res_mc_base = NULL; | 611 | } |
600 | 612 | ||
601 | } | 613 | static int __devinit snd_card_opti9xx_detect(struct snd_card *card, |
602 | #else /* OPTi93X */ | 614 | struct snd_opti9xx *chip) |
603 | for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) { | 615 | { |
604 | unsigned long flags; | 616 | int i, err; |
605 | unsigned char value; | ||
606 | 617 | ||
607 | if ((err = snd_opti9xx_init(chip, i)) < 0) | 618 | #ifndef OPTi93X |
619 | for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) { | ||
620 | #else | ||
621 | for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) { | ||
622 | #endif | ||
623 | err = snd_opti9xx_init(chip, i); | ||
624 | if (err < 0) | ||
608 | return err; | 625 | return err; |
609 | 626 | ||
610 | if ((chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) | 627 | err = snd_opti9xx_read_check(chip); |
611 | continue; | 628 | 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; | 629 | return 1; |
623 | 630 | #ifdef OPTi93X | |
624 | release_and_free_resource(chip->res_mc_base); | 631 | chip->mc_indir_index = 0; |
625 | chip->res_mc_base = NULL; | 632 | #endif |
626 | } | 633 | } |
627 | #endif /* OPTi93X */ | ||
628 | |||
629 | return -ENODEV; | 634 | return -ENODEV; |
630 | } | 635 | } |
631 | 636 | ||
@@ -654,6 +659,8 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
654 | #ifdef OPTi93X | 659 | #ifdef OPTi93X |
655 | port = pnp_port_start(pdev, 0) - 4; | 660 | port = pnp_port_start(pdev, 0) - 4; |
656 | fm_port = pnp_port_start(pdev, 1) + 8; | 661 | fm_port = pnp_port_start(pdev, 1) + 8; |
662 | chip->mc_indir_index = pnp_port_start(pdev, 3) + 2; | ||
663 | chip->mc_indir_size = pnp_port_len(pdev, 3) - 2; | ||
657 | #else | 664 | #else |
658 | if (pid->driver_data != 0x0924) | 665 | if (pid->driver_data != 0x0924) |
659 | port = pnp_port_start(pdev, 1); | 666 | port = pnp_port_start(pdev, 1); |
@@ -684,14 +691,14 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, | |||
684 | static void snd_card_opti9xx_free(struct snd_card *card) | 691 | static void snd_card_opti9xx_free(struct snd_card *card) |
685 | { | 692 | { |
686 | struct snd_opti9xx *chip = card->private_data; | 693 | struct snd_opti9xx *chip = card->private_data; |
687 | 694 | ||
688 | if (chip) { | 695 | if (chip) { |
689 | #ifdef OPTi93X | 696 | #ifdef OPTi93X |
690 | struct snd_wss *codec = chip->codec; | 697 | if (chip->irq > 0) { |
691 | if (codec && codec->irq > 0) { | 698 | disable_irq(chip->irq); |
692 | disable_irq(codec->irq); | 699 | free_irq(chip->irq, chip); |
693 | free_irq(codec->irq, codec); | ||
694 | } | 700 | } |
701 | release_and_free_resource(chip->res_mc_indir); | ||
695 | #endif | 702 | #endif |
696 | release_and_free_resource(chip->res_mc_base); | 703 | release_and_free_resource(chip->res_mc_base); |
697 | } | 704 | } |
@@ -701,6 +708,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
701 | { | 708 | { |
702 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; | 709 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; |
703 | int error; | 710 | int error; |
711 | int xdma2; | ||
704 | struct snd_opti9xx *chip = card->private_data; | 712 | struct snd_opti9xx *chip = card->private_data; |
705 | struct snd_wss *codec; | 713 | struct snd_wss *codec; |
706 | #ifdef CS4231 | 714 | #ifdef CS4231 |
@@ -710,36 +718,25 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
710 | struct snd_rawmidi *rmidi; | 718 | struct snd_rawmidi *rmidi; |
711 | struct snd_hwdep *synth; | 719 | struct snd_hwdep *synth; |
712 | 720 | ||
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) | 721 | #if defined(CS4231) || defined(OPTi93X) |
725 | chip->dma2 = dma2; | 722 | xdma2 = dma2; |
726 | #else | 723 | #else |
727 | chip->dma2 = -1; | 724 | xdma2 = -1; |
728 | #endif | 725 | #endif |
729 | 726 | ||
730 | if (chip->wss_base == SNDRV_AUTO_PORT) { | 727 | if (port == SNDRV_AUTO_PORT) { |
731 | chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4); | 728 | port = snd_legacy_find_free_ioport(possible_ports, 4); |
732 | if (chip->wss_base < 0) { | 729 | if (port < 0) { |
733 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); | 730 | snd_printk(KERN_ERR "unable to find a free WSS port\n"); |
734 | return -EBUSY; | 731 | return -EBUSY; |
735 | } | 732 | } |
736 | } | 733 | } |
737 | error = snd_opti9xx_configure(chip); | 734 | error = snd_opti9xx_configure(chip, port, irq, dma1, xdma2, |
735 | mpu_port, mpu_irq); | ||
738 | if (error) | 736 | if (error) |
739 | return error; | 737 | return error; |
740 | 738 | ||
741 | error = snd_wss_create(card, chip->wss_base + 4, -1, | 739 | error = snd_wss_create(card, port + 4, -1, irq, dma1, xdma2, |
742 | chip->irq, chip->dma1, chip->dma2, | ||
743 | #ifdef OPTi93X | 740 | #ifdef OPTi93X |
744 | WSS_HW_OPTI93X, WSS_HWSHARE_IRQ, | 741 | WSS_HW_OPTI93X, WSS_HWSHARE_IRQ, |
745 | #else | 742 | #else |
@@ -763,35 +760,35 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
763 | return error; | 760 | return error; |
764 | #endif | 761 | #endif |
765 | #ifdef OPTi93X | 762 | #ifdef OPTi93X |
766 | error = request_irq(chip->irq, snd_opti93x_interrupt, | 763 | error = request_irq(irq, snd_opti93x_interrupt, |
767 | IRQF_DISABLED, DEV_NAME" - WSS", codec); | 764 | IRQF_DISABLED, DEV_NAME" - WSS", chip); |
768 | if (error < 0) { | 765 | if (error < 0) { |
769 | snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq); | 766 | snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", irq); |
770 | return error; | 767 | return error; |
771 | } | 768 | } |
772 | #endif | 769 | #endif |
770 | chip->irq = irq; | ||
773 | strcpy(card->driver, chip->name); | 771 | strcpy(card->driver, chip->name); |
774 | sprintf(card->shortname, "OPTi %s", card->driver); | 772 | sprintf(card->shortname, "OPTi %s", card->driver); |
775 | #if defined(CS4231) || defined(OPTi93X) | 773 | #if defined(CS4231) || defined(OPTi93X) |
776 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", | 774 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", |
777 | card->shortname, pcm->name, chip->wss_base + 4, | 775 | card->shortname, pcm->name, port + 4, irq, dma1, xdma2); |
778 | chip->irq, chip->dma1, chip->dma2); | ||
779 | #else | 776 | #else |
780 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", | 777 | sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", |
781 | card->shortname, pcm->name, chip->wss_base + 4, | 778 | card->shortname, pcm->name, port + 4, irq, dma1); |
782 | chip->irq, chip->dma1); | ||
783 | #endif /* CS4231 || OPTi93X */ | 779 | #endif /* CS4231 || OPTi93X */ |
784 | 780 | ||
785 | if (chip->mpu_port <= 0 || chip->mpu_port == SNDRV_AUTO_PORT) | 781 | if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT) |
786 | rmidi = NULL; | 782 | rmidi = NULL; |
787 | else | 783 | else { |
788 | if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, | 784 | error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, |
789 | chip->mpu_port, 0, chip->mpu_irq, IRQF_DISABLED, | 785 | mpu_port, 0, mpu_irq, IRQF_DISABLED, &rmidi); |
790 | &rmidi))) | 786 | if (error) |
791 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", | 787 | snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", |
792 | chip->mpu_port); | 788 | mpu_port); |
789 | } | ||
793 | 790 | ||
794 | if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) { | 791 | if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) { |
795 | struct snd_opl3 *opl3 = NULL; | 792 | struct snd_opl3 *opl3 = NULL; |
796 | #ifndef OPTi93X | 793 | #ifndef OPTi93X |
797 | if (chip->hardware == OPTi9XX_HW_82C928 || | 794 | if (chip->hardware == OPTi9XX_HW_82C928 || |
@@ -801,9 +798,7 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
801 | /* assume we have an OPL4 */ | 798 | /* assume we have an OPL4 */ |
802 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), | 799 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), |
803 | 0x20, 0x20); | 800 | 0x20, 0x20); |
804 | if (snd_opl4_create(card, | 801 | if (snd_opl4_create(card, fm_port, fm_port - 8, |
805 | chip->fm_port, | ||
806 | chip->fm_port - 8, | ||
807 | 2, &opl3, &opl4) < 0) { | 802 | 2, &opl3, &opl4) < 0) { |
808 | /* no luck, use OPL3 instead */ | 803 | /* no luck, use OPL3 instead */ |
809 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), | 804 | snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), |
@@ -811,12 +806,10 @@ static int __devinit snd_opti9xx_probe(struct snd_card *card) | |||
811 | } | 806 | } |
812 | } | 807 | } |
813 | #endif /* !OPTi93X */ | 808 | #endif /* !OPTi93X */ |
814 | if (!opl3 && snd_opl3_create(card, | 809 | 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) { | 810 | OPL3_HW_AUTO, 0, &opl3) < 0) { |
818 | snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", | 811 | snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", |
819 | chip->fm_port, chip->fm_port + 4 - 1); | 812 | fm_port, fm_port + 4 - 1); |
820 | } | 813 | } |
821 | if (opl3) { | 814 | if (opl3) { |
822 | error = snd_opl3_hwdep_new(opl3, 0, 1, &synth); | 815 | error = snd_opl3_hwdep_new(opl3, 0, 1, &synth); |
@@ -978,6 +971,13 @@ static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, | |||
978 | } | 971 | } |
979 | if (hw <= OPTi9XX_HW_82C930) | 972 | if (hw <= OPTi9XX_HW_82C930) |
980 | chip->mc_base -= 0x80; | 973 | chip->mc_base -= 0x80; |
974 | |||
975 | error = snd_opti9xx_read_check(chip); | ||
976 | if (error) { | ||
977 | snd_printk(KERN_ERR "OPTI chip not found\n"); | ||
978 | snd_card_free(card); | ||
979 | return error; | ||
980 | } | ||
981 | snd_card_set_dev(card, &pcard->card->dev); | 981 | snd_card_set_dev(card, &pcard->card->dev); |
982 | if ((error = snd_opti9xx_probe(card)) < 0) { | 982 | if ((error = snd_opti9xx_probe(card)) < 0) { |
983 | snd_card_free(card); | 983 | snd_card_free(card); |
diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 96678d5d3834..751762f1c59a 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c | |||
@@ -393,8 +393,6 @@ size_dram(struct snd_emu8000 *emu) | |||
393 | 393 | ||
394 | while (size < EMU8000_MAX_DRAM) { | 394 | while (size < EMU8000_MAX_DRAM) { |
395 | 395 | ||
396 | size += 512 * 1024; /* increment 512kbytes */ | ||
397 | |||
398 | /* Write a unique data on the test address. | 396 | /* Write a unique data on the test address. |
399 | * if the address is out of range, the data is written on | 397 | * if the address is out of range, the data is written on |
400 | * 0x200000(=EMU8000_DRAM_OFFSET). Then the id word is | 398 | * 0x200000(=EMU8000_DRAM_OFFSET). Then the id word is |
@@ -414,7 +412,9 @@ size_dram(struct snd_emu8000 *emu) | |||
414 | /*snd_emu8000_read_wait(emu);*/ | 412 | /*snd_emu8000_read_wait(emu);*/ |
415 | EMU8000_SMLD_READ(emu); /* discard stale data */ | 413 | EMU8000_SMLD_READ(emu); /* discard stale data */ |
416 | if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2) | 414 | if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2) |
417 | break; /* we must have wrapped around */ | 415 | break; /* no memory at this address */ |
416 | |||
417 | size += 512 * 1024; /* increment 512kbytes */ | ||
418 | 418 | ||
419 | snd_emu8000_read_wait(emu); | 419 | snd_emu8000_read_wait(emu); |
420 | 420 | ||
diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 475220bbcc96..318ff0c823e7 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c | |||
@@ -631,7 +631,7 @@ static struct sbmix_elem snd_sb16_ctl_mic_play_switch = | |||
631 | static struct sbmix_elem snd_sb16_ctl_mic_play_vol = | 631 | static struct sbmix_elem snd_sb16_ctl_mic_play_vol = |
632 | SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31); | 632 | SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31); |
633 | static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol = | 633 | static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol = |
634 | SB_SINGLE("PC Speaker Volume", SB_DSP4_SPEAKER_DEV, 6, 3); | 634 | SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3); |
635 | static struct sbmix_elem snd_sb16_ctl_capture_vol = | 635 | static struct sbmix_elem snd_sb16_ctl_capture_vol = |
636 | SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3); | 636 | SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3); |
637 | static struct sbmix_elem snd_sb16_ctl_play_vol = | 637 | static struct sbmix_elem snd_sb16_ctl_play_vol = |
@@ -689,7 +689,7 @@ static struct sbmix_elem snd_dt019x_ctl_cd_play_vol = | |||
689 | static struct sbmix_elem snd_dt019x_ctl_mic_play_vol = | 689 | static struct sbmix_elem snd_dt019x_ctl_mic_play_vol = |
690 | SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7); | 690 | SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7); |
691 | static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol = | 691 | static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol = |
692 | SB_SINGLE("PC Speaker Volume", SB_DT019X_SPKR_DEV, 0, 7); | 692 | SB_SINGLE("Beep Volume", SB_DT019X_SPKR_DEV, 0, 7); |
693 | static struct sbmix_elem snd_dt019x_ctl_line_play_vol = | 693 | static struct sbmix_elem snd_dt019x_ctl_line_play_vol = |
694 | SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15); | 694 | SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15); |
695 | static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch = | 695 | static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch = |
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/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index 5d2ba1b749ab..5b9d6c18bc45 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 | { |
@@ -2198,84 +2197,61 @@ EXPORT_SYMBOL(snd_wss_put_double); | |||
2198 | static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); | 2197 | 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); | 2198 | 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); | 2199 | static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); |
2200 | static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0); | ||
2201 | 2201 | ||
2202 | static struct snd_kcontrol_new snd_ad1848_controls[] = { | 2202 | static struct snd_kcontrol_new snd_wss_controls[] = { |
2203 | WSS_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, | 2203 | WSS_DOUBLE("PCM Playback Switch", 0, |
2204 | 7, 7, 1, 1), | 2204 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
2205 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, | 2205 | WSS_DOUBLE_TLV("PCM Playback Volume", 0, |
2206 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, | 2206 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, |
2207 | db_scale_6bit), | 2207 | db_scale_6bit), |
2208 | WSS_DOUBLE("Aux Playback Switch", 0, | 2208 | WSS_DOUBLE("Aux Playback Switch", 0, |
2209 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 2209 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), |
2210 | WSS_DOUBLE_TLV("Aux Playback Volume", 0, | 2210 | WSS_DOUBLE_TLV("Aux Playback Volume", 0, |
2211 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, | 2211 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, |
2212 | db_scale_5bit_12db_max), | 2212 | db_scale_5bit_12db_max), |
2213 | WSS_DOUBLE("Aux Playback Switch", 1, | 2213 | WSS_DOUBLE("Aux Playback Switch", 1, |
2214 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | 2214 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), |
2215 | WSS_DOUBLE_TLV("Aux Playback Volume", 1, | 2215 | WSS_DOUBLE_TLV("Aux Playback Volume", 1, |
2216 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, | 2216 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, |
2217 | db_scale_5bit_12db_max), | 2217 | db_scale_5bit_12db_max), |
2218 | WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, | 2218 | WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, |
2219 | 0, 0, 15, 0, db_scale_rec_gain), | 2219 | 0, 0, 15, 0, db_scale_rec_gain), |
2220 | { | 2220 | { |
2221 | .name = "Capture Source", | ||
2222 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2221 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
2222 | .name = "Capture Source", | ||
2223 | .info = snd_wss_info_mux, | 2223 | .info = snd_wss_info_mux, |
2224 | .get = snd_wss_get_mux, | 2224 | .get = snd_wss_get_mux, |
2225 | .put = snd_wss_put_mux, | 2225 | .put = snd_wss_put_mux, |
2226 | }, | 2226 | }, |
2227 | WSS_SINGLE("Loopback Capture Switch", 0, CS4231_LOOPBACK, 0, 1, 0), | 2227 | WSS_DOUBLE("Mic Boost (+20dB)", 0, |
2228 | WSS_SINGLE_TLV("Loopback Capture Volume", 0, CS4231_LOOPBACK, 1, 63, 0, | 2228 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), |
2229 | db_scale_6bit), | 2229 | WSS_SINGLE("Loopback Capture Switch", 0, |
2230 | }; | 2230 | CS4231_LOOPBACK, 0, 1, 0), |
2231 | 2231 | WSS_SINGLE_TLV("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1, | |
2232 | static struct snd_kcontrol_new snd_wss_controls[] = { | 2232 | db_scale_6bit), |
2233 | WSS_DOUBLE("PCM Playback Switch", 0, | ||
2234 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | ||
2235 | WSS_DOUBLE("PCM Playback Volume", 0, | ||
2236 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), | ||
2237 | WSS_DOUBLE("Line Playback Switch", 0, | 2233 | WSS_DOUBLE("Line Playback Switch", 0, |
2238 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), | 2234 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), |
2239 | WSS_DOUBLE("Line Playback Volume", 0, | 2235 | WSS_DOUBLE_TLV("Line Playback Volume", 0, |
2240 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), | 2236 | CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1, |
2241 | WSS_DOUBLE("Aux Playback Switch", 0, | 2237 | db_scale_5bit_12db_max), |
2242 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), | 2238 | WSS_SINGLE("Beep Playback Switch", 0, |
2243 | WSS_DOUBLE("Aux Playback Volume", 0, | ||
2244 | CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1), | ||
2245 | WSS_DOUBLE("Aux Playback Switch", 1, | ||
2246 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), | ||
2247 | WSS_DOUBLE("Aux Playback Volume", 1, | ||
2248 | CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1), | ||
2249 | WSS_SINGLE("Mono Playback Switch", 0, | ||
2250 | CS4231_MONO_CTRL, 7, 1, 1), | 2239 | CS4231_MONO_CTRL, 7, 1, 1), |
2251 | WSS_SINGLE("Mono Playback Volume", 0, | 2240 | WSS_SINGLE_TLV("Beep Playback Volume", 0, |
2252 | CS4231_MONO_CTRL, 0, 15, 1), | 2241 | CS4231_MONO_CTRL, 0, 15, 1, |
2242 | db_scale_4bit), | ||
2253 | WSS_SINGLE("Mono Output Playback Switch", 0, | 2243 | WSS_SINGLE("Mono Output Playback Switch", 0, |
2254 | CS4231_MONO_CTRL, 6, 1, 1), | 2244 | CS4231_MONO_CTRL, 6, 1, 1), |
2255 | WSS_SINGLE("Mono Output Playback Bypass", 0, | 2245 | WSS_SINGLE("Beep Bypass Playback Switch", 0, |
2256 | CS4231_MONO_CTRL, 5, 1, 0), | 2246 | CS4231_MONO_CTRL, 5, 1, 0), |
2257 | WSS_DOUBLE("Capture Volume", 0, | ||
2258 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0), | ||
2259 | { | ||
2260 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
2261 | .name = "Capture Source", | ||
2262 | .info = snd_wss_info_mux, | ||
2263 | .get = snd_wss_get_mux, | ||
2264 | .put = snd_wss_put_mux, | ||
2265 | }, | ||
2266 | WSS_DOUBLE("Mic Boost", 0, | ||
2267 | CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0), | ||
2268 | WSS_SINGLE("Loopback Capture Switch", 0, | ||
2269 | CS4231_LOOPBACK, 0, 1, 0), | ||
2270 | WSS_SINGLE("Loopback Capture Volume", 0, | ||
2271 | CS4231_LOOPBACK, 2, 63, 1) | ||
2272 | }; | 2247 | }; |
2273 | 2248 | ||
2274 | static struct snd_kcontrol_new snd_opti93x_controls[] = { | 2249 | static struct snd_kcontrol_new snd_opti93x_controls[] = { |
2275 | WSS_DOUBLE("Master Playback Switch", 0, | 2250 | WSS_DOUBLE("Master Playback Switch", 0, |
2276 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), | 2251 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), |
2277 | WSS_DOUBLE("Master Playback Volume", 0, | 2252 | WSS_DOUBLE_TLV("Master Playback Volume", 0, |
2278 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), | 2253 | OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1, |
2254 | db_scale_6bit), | ||
2279 | WSS_DOUBLE("PCM Playback Switch", 0, | 2255 | WSS_DOUBLE("PCM Playback Switch", 0, |
2280 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), | 2256 | CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), |
2281 | WSS_DOUBLE("PCM Playback Volume", 0, | 2257 | WSS_DOUBLE("PCM Playback Volume", 0, |
@@ -2334,22 +2310,21 @@ int snd_wss_mixer(struct snd_wss *chip) | |||
2334 | if (err < 0) | 2310 | if (err < 0) |
2335 | return err; | 2311 | return err; |
2336 | } | 2312 | } |
2337 | else if (chip->hardware & WSS_HW_AD1848_MASK) | 2313 | else { |
2338 | for (idx = 0; idx < ARRAY_SIZE(snd_ad1848_controls); idx++) { | 2314 | int count = ARRAY_SIZE(snd_wss_controls); |
2339 | err = snd_ctl_add(card, | 2315 | |
2340 | snd_ctl_new1(&snd_ad1848_controls[idx], | 2316 | /* Use only the first 11 entries on AD1848 */ |
2341 | chip)); | 2317 | if (chip->hardware & WSS_HW_AD1848_MASK) |
2342 | if (err < 0) | 2318 | count = 11; |
2343 | return err; | 2319 | |
2344 | } | 2320 | for (idx = 0; idx < count; idx++) { |
2345 | else | ||
2346 | for (idx = 0; idx < ARRAY_SIZE(snd_wss_controls); idx++) { | ||
2347 | err = snd_ctl_add(card, | 2321 | err = snd_ctl_add(card, |
2348 | snd_ctl_new1(&snd_wss_controls[idx], | 2322 | snd_ctl_new1(&snd_wss_controls[idx], |
2349 | chip)); | 2323 | chip)); |
2350 | if (err < 0) | 2324 | if (err < 0) |
2351 | return err; | 2325 | return err; |
2352 | } | 2326 | } |
2327 | } | ||
2353 | return 0; | 2328 | return 0; |
2354 | } | 2329 | } |
2355 | EXPORT_SYMBOL(snd_wss_mixer); | 2330 | EXPORT_SYMBOL(snd_wss_mixer); |