49 #include <linux/kernel.h>
50 #include <linux/module.h>
52 #include <linux/types.h>
75 # define LOGNAME "msnd_classic"
78 # define LOGNAME "snd_msnd_pinnacle"
93 switch (
HIBYTE(wMessage)) {
97 (
unsigned)jiffies,
LOBYTE(wMessage));
100 snd_printdd(
"chip.last_playbank == LOBYTE(wMessage)\n");
131 switch (
LOBYTE(wMessage)) {
149 ": DSP message %d 0x%02x\n",
179 snd_msnd_eval_dsp_msg(chip,
194 static int snd_msnd_reset_dsp(
long io,
unsigned char *
info)
206 while (timeout-- > 0) {
222 char *
pin =
"TB Pinnacle", *fiji =
"TB Fiji";
223 char *pinfiji =
"TB Pinnacle/Fiji";
231 if (snd_msnd_reset_dsp(chip->
io, &info) < 0) {
240 "I/O 0x%lx-0x%lx, IRQ %d, memory mapped to 0x%lX-0x%lX\n",
264 switch (info & 0x7) {
294 rev =
"A-B (Fiji) or A-E (Pinnacle)";
300 "I/O 0x%lx-0x%lx, IRQ %d, memory mapped to 0x%lX-0x%lX\n",
312 static int snd_msnd_init_sma(
struct snd_msnd *chip)
315 u16 mastVolLeft, mastVolRight;
329 mastVolLeft = mastVolRight = 0;
337 spin_unlock_irqrestore(&chip->
lock, flags);
381 static int upload_dsp_code(
struct snd_card *card)
417 static void reset_proteus(
struct snd_msnd *chip)
426 static int snd_msnd_initialize(
struct snd_card *card)
437 err = snd_msnd_init_sma(chip);
443 err = snd_msnd_reset_dsp(chip->
io,
NULL);
447 err = upload_dsp_code(card);
467 static int snd_msnd_dsp_full_reset(
struct snd_card *card)
478 rv = snd_msnd_initialize(card);
492 static int snd_msnd_send_dsp_cmd_chk(
struct snd_msnd *chip,
u8 cmd)
496 snd_msnd_dsp_full_reset(chip->
card);
502 snd_printdd(
"snd_msnd_calibrate_adc(%i)\n", srate);
522 static int snd_msnd_mpu401_open(
struct snd_mpu401 *mpu)
529 static void snd_msnd_mpu401_close(
struct snd_mpu401 *mpu)
543 .dev_free = snd_msnd_dev_free,
559 ": unable to grab memory region 0x%lx-0x%lx\n",
568 ": unable to map memory region 0x%lx-0x%lx\n",
571 goto err_release_region;
574 err = snd_msnd_dsp_full_reset(card);
576 goto err_release_region;
581 goto err_release_region;
586 goto err_release_region;
592 goto err_release_region;
607 ": error creating new Midi device\n");
608 goto err_release_region;
610 mpu = chip->
rmidi->private_data;
623 goto err_release_region;
655 outb(value, cfg + 1);
656 if (value !=
inb(cfg + 1)) {
663 static int __devinit snd_msnd_write_cfg_io0(
int cfg,
int num,
u16 io)
674 static int __devinit snd_msnd_write_cfg_io1(
int cfg,
int num,
u16 io)
685 static int __devinit snd_msnd_write_cfg_irq(
int cfg,
int num,
u16 irq)
696 static int __devinit snd_msnd_write_cfg_mem(
int cfg,
int num,
int mem)
701 wmem = (
u16)(mem & 0xfff);
714 static int __devinit snd_msnd_activate_logical(
int cfg,
int num)
723 static int __devinit snd_msnd_write_cfg_logical(
int cfg,
int num,
u16 io0,
724 u16 io1,
u16 irq,
int mem)
728 if (snd_msnd_write_cfg_io0(cfg, num, io0))
730 if (snd_msnd_write_cfg_io1(cfg, num, io1))
732 if (snd_msnd_write_cfg_irq(cfg, num, irq))
734 if (snd_msnd_write_cfg_mem(cfg, num, mem))
736 if (snd_msnd_activate_logical(cfg, num))
741 static int __devinit snd_msnd_pinnacle_cfg_reset(
int cfg)
747 for (i = 0; i < 4; ++
i)
748 if (snd_msnd_write_cfg_logical(cfg, i, 0, 0, 0, 0))
791 #define has_isapnp(x) isapnp[x]
793 #define has_isapnp(x) 0
821 static int __devinit snd_msnd_isa_match(
struct device *pdev,
unsigned int i)
832 if (!(io[i] == 0x290 ||
841 " to 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0x290, "
846 if (io[i] < 0x100 || io[i] > 0x3e0 || (io[i] % 0x10) != 0) {
848 ": \"io\" - DSP I/O base must within the range 0x100 "
849 "to 0x3E0 and must be evenly divisible by 0x10\n");
861 ": \"irq\" - must be set to 5, 7, 9, 10, 11 or 12\n");
865 if (!(mem[i] == 0xb0000 ||
870 mem[i] == 0xe8000)) {
872 "0xb0000, 0xc8000, 0xd0000, 0xd8000, 0xe0000 or "
880 }
else if (cfg[i] != 0x250 && cfg[i] != 0x260 && cfg[i] != 0x270) {
882 ": Config port must be 0x250, 0x260 or 0x270 "
883 "(or unspecified for PnP mode)\n");
946 printk(
KERN_INFO LOGNAME
": Non-PnP mode: configuring at port 0x%lx\n",
956 if (snd_msnd_pinnacle_cfg_reset(cfg[idx])) {
962 err = snd_msnd_write_cfg_logical(cfg[idx], 0,
975 ": Configuring MPU to I/O 0x%lx IRQ %d\n",
976 mpu_io[idx], mpu_irq[idx]);
977 err = snd_msnd_write_cfg_logical(cfg[idx], 1,
990 ": Configuring IDE to I/O 0x%lx, 0x%lx IRQ %d\n",
991 ide_io0[idx], ide_io1[idx], ide_irq[idx]);
992 err = snd_msnd_write_cfg_logical(cfg[idx], 2,
993 ide_io0[idx], ide_io1[idx],
1003 ": Configuring joystick to I/O 0x%lx\n",
1005 err = snd_msnd_write_cfg_logical(cfg[idx], 3,
1006 joystick_io[idx], 0,
1016 set_default_audio_parameters(chip);
1030 if (write_ndelay[idx])
1034 #ifndef MSND_CLASSIC
1039 err = snd_msnd_probe(card);
1046 err = snd_msnd_attach(card);
1056 #ifndef MSND_CLASSIC
1071 #define DEV_NAME "msnd-pinnacle"
1074 .match = snd_msnd_isa_match,
1075 .probe = snd_msnd_isa_probe,
1089 struct pnp_dev *mpu_dev;
1098 if (idx >= SNDRV_CARDS)
1138 io[
idx] = pnp_port_start(pnp_dev, 0);
1140 mem[
idx] = pnp_mem_start(pnp_dev, 0);
1141 mpu_io[
idx] = pnp_port_start(mpu_dev, 0);
1144 set_default_audio_parameters(chip);
1158 if (write_ndelay[idx])
1162 #ifndef MSND_CLASSIC
1167 ret = snd_msnd_probe(card);
1173 ret = snd_msnd_attach(card);
1179 pnp_set_card_drvdata(pcard, card);
1190 snd_msnd_unload(pnp_get_card_drvdata(pcard));
1191 pnp_set_card_drvdata(pcard,
NULL);
1194 static int isa_registered;
1195 static int pnp_registered;
1199 { .
id =
"BVJ0440", .devs = { {
"TBS0000" }, {
"TBS0001" } } },
1207 .name =
"msnd_pinnacle",
1208 .id_table = msnd_pnpids,
1209 .probe = snd_msnd_pnp_detect,
1214 static int __init snd_msnd_init(
void)
1233 static void __exit snd_msnd_exit(
void)