Lines Matching +full:always +full:- +full:wait +full:- +full:for +full:- +full:ack

1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (C) by Paul Barton-Davis 1998-1999
5 * copyright (C) by Hannu Savolainen 1993-1996
9 * An ALSA lowlevel driver for Turtle Beach ICS2115 wavetable synth
14 * of GUS patches during loading, and full user-level access to all
15 * WaveFront commands. It tries to provide semi-intelligent patch and
25 #include <linux/wait.h>
35 static int wf_raw = 0; /* we normally check for "raw state" to firmware
36 loading. if non-zero, then during driver loading, the
44 associated coefficients to set it up for "default"
63 get a number that causes us to just busy wait
64 for as many WaveFront commands as possible, without
75 static int reset_time = 2; /* hundreths of a second we wait after a HW
76 reset for the expected interrupt.
79 static int ramcheck_time = 20; /* time in seconds to wait while ROM code
80 checks on-board RAM.
83 static int osrun_time = 10; /* time in seconds we wait for the OS to
87 MODULE_PARM_DESC(wf_raw, "if non-zero, assume that we need to boot the OS");
89 MODULE_PARM_DESC(fx_raw, "if non-zero, assume that the FX process needs help");
91 MODULE_PARM_DESC(debug_default, "debug parameters for card initialization");
93 MODULE_PARM_DESC(wait_usecs, "how long to wait without sleeping, usecs");
95 MODULE_PARM_DESC(sleep_interval, "how long to sleep when waiting for reply");
97 MODULE_PARM_DESC(sleep_tries, "how many times to try sleeping during a wait");
101 MODULE_PARM_DESC(reset_time, "how long to wait for a reset to take effect");
103 MODULE_PARM_DESC(ramcheck_time, "how many seconds to wait for the RAM test");
105 MODULE_PARM_DESC(osrun_time, "how many seconds to wait for the ICS2115 OS");
107 /* if WF_DEBUG not defined, no run-time debugging messages will
118 if ((dev->debug & (cond)) == (cond)) { \
127 /* bitmasks for WaveFront status port value */
175 { WFC_MISYNTH_OFF, "disable midi-in to synth", 0, 0, NEEDS_ACK },
176 { WFC_MISYNTH_ON, "enable midi-in to synth", 0, 0, NEEDS_ACK },
201 response, don't fetch an ACK, and leave the rest to the
225 { WFC_NOOP, "the no-op command", 0, 0, NEEDS_ACK },
235 for (i = 0; wavefront_errors[i].errstr; i++) { in wavefront_errorstr()
250 for (i = 0; wavefront_commands[i].cmd != 0; i++) { in wavefront_get_command()
263 return inb (dev->status_port); in wavefront_status()
281 /* Spin for a short period of time, because >99% of all in wavefront_wait()
285 for (i = 0; i < wait_usecs; i += 5) { in wavefront_wait()
292 for (i = 0; i < sleep_tries; i++) { in wavefront_wait()
311 return inb (dev->data_port); in wavefront_read()
315 return -1; in wavefront_read()
323 outb (data, dev->data_port); in wavefront_write()
329 return -1; in wavefront_write()
337 int ack; in snd_wavefront_cmd() local
349 /* Hack to handle the one variable-size write command. See in snd_wavefront_cmd()
350 wavefront_send_multisample() for the other half of this in snd_wavefront_cmd()
355 wfcmd->write_cnt = (unsigned long) rbuf; in snd_wavefront_cmd()
360 cmd, wfcmd->action, wfcmd->read_cnt, in snd_wavefront_cmd()
361 wfcmd->write_cnt, wfcmd->need_ack); in snd_wavefront_cmd()
366 cmd, wfcmd->action); in snd_wavefront_cmd()
370 if (wfcmd->write_cnt > 0) { in snd_wavefront_cmd()
372 "for 0x%x\n", in snd_wavefront_cmd()
373 wfcmd->write_cnt, cmd); in snd_wavefront_cmd()
375 for (i = 0; i < wfcmd->write_cnt; i++) { in snd_wavefront_cmd()
377 DPRINT (WF_DEBUG_IO, "bad write for byte " in snd_wavefront_cmd()
379 i, cmd, wfcmd->action); in snd_wavefront_cmd()
388 if (wfcmd->read_cnt > 0) { in snd_wavefront_cmd()
390 "for 0x%x\n", in snd_wavefront_cmd()
391 wfcmd->read_cnt, cmd); in snd_wavefront_cmd()
393 for (i = 0; i < wfcmd->read_cnt; i++) { in snd_wavefront_cmd()
396 if (c == -1) { in snd_wavefront_cmd()
397 DPRINT (WF_DEBUG_IO, "bad read for byte " in snd_wavefront_cmd()
399 i, cmd, wfcmd->action); in snd_wavefront_cmd()
407 if (c == -1) { in snd_wavefront_cmd()
408 DPRINT (WF_DEBUG_IO, "bad read for " in snd_wavefront_cmd()
413 wfcmd->action); in snd_wavefront_cmd()
420 wfcmd->cmd == WFC_IDENTIFY_SAMPLE_TYPE) { in snd_wavefront_cmd()
425 wfcmd->cmd == WFC_UPLOAD_PATCH) { in snd_wavefront_cmd()
430 wfcmd->cmd == WFC_UPLOAD_PROGRAM) { in snd_wavefront_cmd()
438 "read for byte " in snd_wavefront_cmd()
444 wfcmd->action); in snd_wavefront_cmd()
457 if ((wfcmd->read_cnt == 0 && wfcmd->write_cnt == 0) || wfcmd->need_ack) { in snd_wavefront_cmd()
459 DPRINT (WF_DEBUG_CMD, "reading ACK for 0x%x\n", cmd); in snd_wavefront_cmd()
461 /* Some commands need an ACK, but return zero instead in snd_wavefront_cmd()
465 ack = wavefront_read(dev); in snd_wavefront_cmd()
466 if (ack == 0) in snd_wavefront_cmd()
467 ack = WF_ACK; in snd_wavefront_cmd()
469 if (ack != WF_ACK) { in snd_wavefront_cmd()
470 if (ack == -1) { in snd_wavefront_cmd()
471 DPRINT (WF_DEBUG_IO, "cannot read ack for " in snd_wavefront_cmd()
473 cmd, wfcmd->action); in snd_wavefront_cmd()
477 int err = -1; /* something unknown */ in snd_wavefront_cmd()
479 if (ack == 0xff) { /* explicit error */ in snd_wavefront_cmd()
482 if (err == -1) { in snd_wavefront_cmd()
485 "for 0x%x [%s].\n", in snd_wavefront_cmd()
486 cmd, wfcmd->action); in snd_wavefront_cmd()
492 cmd, wfcmd->action, ack, err, in snd_wavefront_cmd()
495 return -err; in snd_wavefront_cmd()
499 DPRINT (WF_DEBUG_DATA, "ack received " in snd_wavefront_cmd()
500 "for 0x%x [%s]\n", in snd_wavefront_cmd()
501 cmd, wfcmd->action); in snd_wavefront_cmd()
505 "ACK (%d,%d,%d)\n", in snd_wavefront_cmd()
506 cmd, wfcmd->action, wfcmd->read_cnt, in snd_wavefront_cmd()
507 wfcmd->write_cnt, wfcmd->need_ack); in snd_wavefront_cmd()
522 the x86 side as 8-32 bit values. Sometimes, we need to munge data
525 different functions for munging and 2 for de-munging. This avoids
526 weird casting and worrying about bit-level offsets.
537 for (i = 0; i < dst_size; i++) { in munge_int32()
554 for (i = src_size - 1; i >= 0; i--) { in demunge_int32()
569 for (i = 0; i < last; i++) { in munge_buf()
586 for (i = 0; src != end; i++) { in demunge_buf()
610 dev->sample_status[sample_num] = WF_ST_EMPTY; in wavefront_delete_sample()
627 return -1; in wavefront_get_sample_status()
630 sc_real = sc_alias = sc_multi = dev->samples_used = 0; in wavefront_get_sample_status()
632 for (i = 0; i < WF_MAX_SAMPLE; i++) { in wavefront_get_sample_status()
640 dev->sample_status[i] = WF_ST_EMPTY; in wavefront_get_sample_status()
644 dev->sample_status[i] = (WF_SLOT_FILLED|rbuf[0]); in wavefront_get_sample_status()
647 dev->sample_status[i] |= WF_SLOT_ROM; in wavefront_get_sample_status()
664 snd_printk ("unknown sample type for " in wavefront_get_sample_status()
670 dev->samples_used++; in wavefront_get_sample_status()
675 "%d empty\n", dev->samples_used, sc_real, sc_alias, sc_multi, in wavefront_get_sample_status()
676 WF_MAX_SAMPLE - dev->samples_used); in wavefront_get_sample_status()
692 for (i = 0; i < WF_MAX_PATCH; i++) { in wavefront_get_patch_status()
700 dev->patch_status[i] |= WF_SLOT_FILLED; in wavefront_get_patch_status()
702 dev->sample_status in wavefront_get_patch_status()
703 [p->sample_number|(p->sample_msb<<7)] |= in wavefront_get_patch_status()
707 dev->patch_status[i] = 0; in wavefront_get_patch_status()
711 dev->patch_status[i] = 0; in wavefront_get_patch_status()
718 for (i = 0, cnt = 0, cnt2 = 0; i < WF_MAX_PATCH; i++) { in wavefront_get_patch_status()
719 if (dev->patch_status[i] & WF_SLOT_FILLED) { in wavefront_get_patch_status()
722 if (dev->patch_status[i] & WF_SLOT_USED) { in wavefront_get_patch_status()
741 for (i = 0; i < WF_MAX_PROGRAM; i++) { in wavefront_get_program_status()
748 dev->prog_status[i] |= WF_SLOT_USED; in wavefront_get_program_status()
753 for (l = 0; l < WF_NUM_LAYERS; l++) { in wavefront_get_program_status()
755 dev->patch_status in wavefront_get_program_status()
761 dev->prog_status[i] = 0; in wavefront_get_program_status()
765 dev->prog_status[i] = 0; in wavefront_get_program_status()
769 for (i = 0, cnt = 0; i < WF_MAX_PROGRAM; i++) { in wavefront_get_program_status()
770 if (dev->prog_status[i]) { in wavefront_get_program_status()
788 header->number); in wavefront_send_patch()
790 if (header->number >= ARRAY_SIZE(dev->patch_status)) in wavefront_send_patch()
791 return -EINVAL; in wavefront_send_patch()
793 dev->patch_status[header->number] |= WF_SLOT_FILLED; in wavefront_send_patch()
795 bptr = munge_int32 (header->number, buf, 2); in wavefront_send_patch()
796 munge_buf ((unsigned char *)&header->hdr.p, bptr, WF_PATCH_BYTES); in wavefront_send_patch()
800 return -EIO; in wavefront_send_patch()
814 header->number); in wavefront_send_program()
816 if (header->number >= ARRAY_SIZE(dev->prog_status)) in wavefront_send_program()
817 return -EINVAL; in wavefront_send_program()
819 dev->prog_status[header->number] = WF_SLOT_USED; in wavefront_send_program()
821 /* XXX need to zero existing SLOT_USED bit for program_status[i] in wavefront_send_program()
825 for (i = 0; i < WF_NUM_LAYERS; i++) { in wavefront_send_program()
826 if (header->hdr.pr.layer[i].mute) { in wavefront_send_program()
827 dev->patch_status[header->hdr.pr.layer[i].patch_number] |= in wavefront_send_program()
830 /* XXX need to mark SLOT_USED for sample used by in wavefront_send_program()
836 buf[0] = header->number; in wavefront_send_program()
837 munge_buf ((unsigned char *)&header->hdr.pr, &buf[1], WF_PROGRAM_BYTES); in wavefront_send_program()
841 return -EIO; in wavefront_send_program()
855 return -1; in wavefront_freemem()
868 /* samples are downloaded via a 16-bit wide i/o port in wavefront_send_sample()
869 (you could think of it as 2 adjacent 8-bit wide ports in wavefront_send_sample()
873 which are given in 8-bit units (bytes), need to be in wavefront_send_sample()
891 DPRINT (WF_DEBUG_LOAD_PATCH, "sample %sdownload for slot %d, " in wavefront_send_sample()
893 header->size ? "" : "header ", in wavefront_send_sample()
894 header->number, header->subkey, in wavefront_send_sample()
895 header->size, in wavefront_send_sample()
896 (unsigned long) header->dataptr); in wavefront_send_sample()
898 if (header->number == WAVEFRONT_FIND_FREE_SAMPLE_SLOT) { in wavefront_send_sample()
903 return -ENOMEM; in wavefront_send_sample()
905 header->number = x; in wavefront_send_sample()
908 if (header->number >= WF_MAX_SAMPLE) in wavefront_send_sample()
909 return -EINVAL; in wavefront_send_sample()
911 if (header->size) { in wavefront_send_sample()
915 the sample header. For now, it only covers the sample data, in wavefront_send_sample()
918 My reason for this is that we have the sample headers in wavefront_send_sample()
919 available in the WFB file for General MIDI, and so these in wavefront_send_sample()
920 can always be reset if needed. The sample data, however, in wavefront_send_sample()
936 if (dev->rom_samples_rdonly) { in wavefront_send_sample()
937 if (dev->sample_status[header->number] & WF_SLOT_ROM) { in wavefront_send_sample()
940 header->number); in wavefront_send_sample()
941 return -EACCES; in wavefront_send_sample()
945 wavefront_delete_sample (dev, header->number); in wavefront_send_sample()
948 if (header->size) { in wavefront_send_sample()
949 dev->freemem = wavefront_freemem (dev); in wavefront_send_sample()
951 if (dev->freemem < (int)header->size) { in wavefront_send_sample()
954 header->size); in wavefront_send_sample()
955 return -ENOMEM; in wavefront_send_sample()
960 skip = WF_GET_CHANNEL(&header->hdr.s); in wavefront_send_sample()
962 if (skip > 0 && header->hdr.s.SampleResolution != LINEAR_16BIT) { in wavefront_send_sample()
964 "possible on 16-bit samples"); in wavefront_send_sample()
965 return -EINVAL; in wavefront_send_sample()
1001 WF_GET_CHANNEL (&header->hdr.s), in wavefront_send_sample()
1006 WF_SET_CHANNEL(&header->hdr.s, 0); in wavefront_send_sample()
1008 /* adjust size for 16 bit samples by dividing by two. We always in wavefront_send_sample()
1009 send 16 bits per write, even for 8 bit samples, so the length in wavefront_send_sample()
1010 is always half the size of the sample data in bytes. in wavefront_send_sample()
1013 length = header->size / 2; in wavefront_send_sample()
1022 shptr = munge_int32 (header->number, shptr, 2); in wavefront_send_sample()
1024 if (header->size) { in wavefront_send_sample()
1032 shptr = munge_int32 (*((u32 *) &header->hdr.s.sampleStartOffset), in wavefront_send_sample()
1034 shptr = munge_int32 (*((u32 *) &header->hdr.s.loopStartOffset), in wavefront_send_sample()
1036 shptr = munge_int32 (*((u32 *) &header->hdr.s.loopEndOffset), in wavefront_send_sample()
1038 shptr = munge_int32 (*((u32 *) &header->hdr.s.sampleEndOffset), in wavefront_send_sample()
1046 shptr = munge_int32 (header->hdr.s.FrequencyBias, shptr, 3); in wavefront_send_sample()
1048 /* Why is this nybblified, when the MSB is *always* zero ? in wavefront_send_sample()
1050 good-faith guess at where it starts. in wavefront_send_sample()
1053 shptr = munge_int32 (*(&header->hdr.s.FrequencyBias+1), in wavefront_send_sample()
1057 header->size ? in wavefront_send_sample()
1061 header->size ? "" : "header "); in wavefront_send_sample()
1062 return -EIO; in wavefront_send_sample()
1065 if (header->size == 0) { in wavefront_send_sample()
1075 for (written = 0, blocknum = 0; in wavefront_send_sample()
1078 if ((length - written) > max_blksize) { in wavefront_send_sample()
1081 /* round to nearest 16-byte value */ in wavefront_send_sample()
1082 blocksize = ALIGN(length - written, 8); in wavefront_send_sample()
1088 return -EIO; in wavefront_send_sample()
1091 for (i = 0; i < blocksize; i++) { in wavefront_send_sample()
1096 return -EFAULT; in wavefront_send_sample()
1101 if (WF_SAMPLE_IS_8BIT(&header->hdr.s)) { in wavefront_send_sample()
1134 if (i < blocksize - 1) { in wavefront_send_sample()
1135 outw (sample_short, dev->block_port); in wavefront_send_sample()
1137 outw (sample_short, dev->last_block_port); in wavefront_send_sample()
1147 if (dma_ack == -1) { in wavefront_send_sample()
1149 "DMA ack timeout\n"); in wavefront_send_sample()
1150 return -EIO; in wavefront_send_sample()
1153 "DMA ack error 0x%x\n", in wavefront_send_sample()
1155 return -EIO; in wavefront_send_sample()
1160 dev->sample_status[header->number] = (WF_SLOT_FILLED|WF_ST_SAMPLE); in wavefront_send_sample()
1177 "alias for %d\n", in wavefront_send_alias()
1178 header->number, in wavefront_send_alias()
1179 header->hdr.a.OriginalSample); in wavefront_send_alias()
1181 if (header->number >= WF_MAX_SAMPLE) in wavefront_send_alias()
1182 return -EINVAL; in wavefront_send_alias()
1184 munge_int32 (header->number, &alias_hdr[0], 2); in wavefront_send_alias()
1185 munge_int32 (header->hdr.a.OriginalSample, &alias_hdr[2], 2); in wavefront_send_alias()
1186 munge_int32 (*((unsigned int *)&header->hdr.a.sampleStartOffset), in wavefront_send_alias()
1188 munge_int32 (*((unsigned int *)&header->hdr.a.loopStartOffset), in wavefront_send_alias()
1190 munge_int32 (*((unsigned int *)&header->hdr.a.loopEndOffset), in wavefront_send_alias()
1192 munge_int32 (*((unsigned int *)&header->hdr.a.sampleEndOffset), in wavefront_send_alias()
1194 munge_int32 (header->hdr.a.FrequencyBias, &alias_hdr[20], 3); in wavefront_send_alias()
1195 munge_int32 (*(&header->hdr.a.FrequencyBias+1), &alias_hdr[23], 2); in wavefront_send_alias()
1199 return -EIO; in wavefront_send_alias()
1202 dev->sample_status[header->number] = (WF_SLOT_FILLED|WF_ST_ALIAS); in wavefront_send_alias()
1214 if (header->number >= WF_MAX_SAMPLE) in wavefront_send_multisample()
1215 return -EINVAL; in wavefront_send_multisample()
1219 return -ENOMEM; in wavefront_send_multisample()
1221 munge_int32 (header->number, &msample_hdr[0], 2); in wavefront_send_multisample()
1228 num_samples = (1<<(header->hdr.ms.NumberOfSamples&7)); in wavefront_send_multisample()
1229 msample_hdr[2] = (unsigned char) header->hdr.ms.NumberOfSamples; in wavefront_send_multisample()
1232 header->number, in wavefront_send_multisample()
1233 header->hdr.ms.NumberOfSamples, in wavefront_send_multisample()
1236 for (i = 0; i < num_samples; i++) { in wavefront_send_multisample()
1238 i, header->hdr.ms.SampleNumber[i]); in wavefront_send_multisample()
1239 munge_int32 (header->hdr.ms.SampleNumber[i], in wavefront_send_multisample()
1253 return -EIO; in wavefront_send_multisample()
1256 dev->sample_status[header->number] = (WF_SLOT_FILLED|WF_ST_MULTISAMPLE); in wavefront_send_multisample()
1271 munge_int32 (header->number, number, 2); in wavefront_fetch_multisample()
1275 return -EIO; in wavefront_fetch_multisample()
1279 header->number, log_ns[0]); in wavefront_fetch_multisample()
1281 header->hdr.ms.NumberOfSamples = log_ns[0]; in wavefront_fetch_multisample()
1287 for (i = 0; i < num_samples; i++) { in wavefront_fetch_multisample()
1292 if (val == -1) { in wavefront_fetch_multisample()
1295 return -EIO; in wavefront_fetch_multisample()
1300 if (val == -1) { in wavefront_fetch_multisample()
1303 return -EIO; in wavefront_fetch_multisample()
1307 header->hdr.ms.SampleNumber[i] = in wavefront_fetch_multisample()
1311 i, header->hdr.ms.SampleNumber[i]); in wavefront_fetch_multisample()
1323 wavefront_drum *drum = &header->hdr.d; in wavefront_send_drum()
1326 DPRINT (WF_DEBUG_LOAD_PATCH, "downloading edrum for MIDI " in wavefront_send_drum()
1328 header->number, drum->PatchNumber); in wavefront_send_drum()
1330 drumbuf[0] = header->number & 0x7f; in wavefront_send_drum()
1332 for (i = 0; i < 4; i++) { in wavefront_send_drum()
1338 return -EIO; in wavefront_send_drum()
1350 for (i = 0; i < WF_MAX_SAMPLE; i++) { in wavefront_find_free_sample()
1351 if (!(dev->sample_status[i] & WF_SLOT_FILLED)) { in wavefront_find_free_sample()
1356 return -1; in wavefront_find_free_sample()
1366 for (i = 0; i < WF_MAX_PATCH; i++) {
1367 if (!(dev->patch_status[i] & WF_SLOT_FILLED)) {
1372 return -1;
1384 return -ENOMEM; in wavefront_load_patch()
1386 if (copy_from_user (header, addr, sizeof(wavefront_patch_info) - in wavefront_load_patch()
1388 snd_printk ("bad address for load patch.\n"); in wavefront_load_patch()
1389 err = -EFAULT; in wavefront_load_patch()
1397 header->subkey, in wavefront_load_patch()
1398 header->number, in wavefront_load_patch()
1399 header->size); in wavefront_load_patch()
1401 switch (header->subkey) { in wavefront_load_patch()
1402 case WF_ST_SAMPLE: /* sample or sample_header, based on patch->size */ in wavefront_load_patch()
1404 if (copy_from_user (&header->hdr.s, header->hdrptr, in wavefront_load_patch()
1406 err = -EFAULT; in wavefront_load_patch()
1410 err = wavefront_send_sample (dev, header, header->dataptr, 0); in wavefront_load_patch()
1415 if (copy_from_user (&header->hdr.s, header->hdrptr, in wavefront_load_patch()
1417 err = -EFAULT; in wavefront_load_patch()
1426 if (copy_from_user (&header->hdr.a, header->hdrptr, in wavefront_load_patch()
1428 err = -EFAULT; in wavefront_load_patch()
1436 if (copy_from_user (&header->hdr.d, header->hdrptr, in wavefront_load_patch()
1438 err = -EFAULT; in wavefront_load_patch()
1446 if (copy_from_user (&header->hdr.p, header->hdrptr, in wavefront_load_patch()
1448 err = -EFAULT; in wavefront_load_patch()
1456 if (copy_from_user (&header->hdr.pr, header->hdrptr, in wavefront_load_patch()
1458 err = -EFAULT; in wavefront_load_patch()
1467 header->subkey); in wavefront_load_patch()
1468 err = -EINVAL; in wavefront_load_patch()
1478 WaveFront: hardware-dependent interface
1518 snd_wavefront_t *dev = &acard->wavefront; in wavefront_synth_control()
1523 "cmd 0x%x\n", wc->cmd); in wavefront_synth_control()
1525 /* Pre-handling of or for various commands */ in wavefront_synth_control()
1527 switch (wc->cmd) { in wavefront_synth_control()
1531 outb (0x80|0x20, dev->control_port); in wavefront_synth_control()
1532 dev->interrupts_are_midi = 1; in wavefront_synth_control()
1537 outb (0x80|0x40|0x20, dev->control_port); in wavefront_synth_control()
1538 dev->interrupts_are_midi = 1; in wavefront_synth_control()
1542 wc->rbuf[0] = dev->interrupts_are_midi; in wavefront_synth_control()
1546 dev->rom_samples_rdonly = wc->wbuf[0]; in wavefront_synth_control()
1547 wc->status = 0; in wavefront_synth_control()
1551 i = wc->wbuf[0] | (wc->wbuf[1] << 7); in wavefront_synth_control()
1555 wc->status = EINVAL; in wavefront_synth_control()
1556 return -EINVAL; in wavefront_synth_control()
1558 wc->rbuf[0] = dev->sample_status[i]; in wavefront_synth_control()
1559 wc->status = 0; in wavefront_synth_control()
1563 dev->debug = wc->wbuf[0]; in wavefront_synth_control()
1564 snd_printk ("debug = 0x%x\n", dev->debug); in wavefront_synth_control()
1568 munge_int32 (*((u32 *) wc->wbuf), patchnumbuf, 2); in wavefront_synth_control()
1569 memcpy (wc->wbuf, patchnumbuf, 2); in wavefront_synth_control()
1576 wc->status = wavefront_fetch_multisample in wavefront_synth_control()
1577 (dev, (wavefront_patch_info *) wc->rbuf); in wavefront_synth_control()
1581 snd_printk ("support for sample alias upload " in wavefront_synth_control()
1583 wc->status = EINVAL; in wavefront_synth_control()
1584 return -EINVAL; in wavefront_synth_control()
1587 wc->status = snd_wavefront_cmd (dev, wc->cmd, wc->rbuf, wc->wbuf); in wavefront_synth_control()
1589 /* Post-handling of certain commands. in wavefront_synth_control()
1592 so that the user-level doesn't have to think about it. in wavefront_synth_control()
1595 if (wc->status == 0) { in wavefront_synth_control()
1596 switch (wc->cmd) { in wavefront_synth_control()
1598 we are always current with the user-level view in wavefront_synth_control()
1603 dev->freemem = demunge_int32 (wc->rbuf, 4); in wavefront_synth_control()
1607 demunge_buf (wc->rbuf, wc->rbuf, WF_PATCH_BYTES); in wavefront_synth_control()
1611 demunge_buf (wc->rbuf, wc->rbuf, WF_PROGRAM_BYTES); in wavefront_synth_control()
1615 demunge_buf (wc->rbuf, wc->rbuf, WF_DRUM_BYTES - 1); in wavefront_synth_control()
1619 process_sample_hdr (wc->rbuf); in wavefront_synth_control()
1623 snd_printk ("support for " in wavefront_synth_control()
1645 if (!try_module_get(hw->card->module)) in snd_wavefront_synth_open()
1646 return -EFAULT; in snd_wavefront_synth_open()
1647 file->private_data = hw; in snd_wavefront_synth_open()
1655 module_put(hw->card->module); in snd_wavefront_synth_release()
1671 card = (struct snd_card *) hw->card; in snd_wavefront_synth_ioctl()
1674 return -ENODEV; in snd_wavefront_synth_ioctl()
1675 if (snd_BUG_ON(!card->private_data)) in snd_wavefront_synth_ioctl()
1676 return -ENODEV; in snd_wavefront_synth_ioctl()
1678 acard = card->private_data; in snd_wavefront_synth_ioctl()
1679 dev = &acard->wavefront; in snd_wavefront_synth_ioctl()
1684 return -EIO; in snd_wavefront_synth_ioctl()
1694 err = -EIO; in snd_wavefront_synth_ioctl()
1696 err = -EFAULT; in snd_wavefront_synth_ioctl()
1703 return -EINVAL; in snd_wavefront_synth_ioctl()
1711 /* WaveFront: interface for card-level wavefront module */
1717 snd_wavefront_t *dev = &card->wavefront; in snd_wavefront_internal_interrupt()
1722 doing busy and/or sleep-waiting. Alas, it appears that once in snd_wavefront_internal_interrupt()
1736 firmware prevents RX-ready interrupts. in snd_wavefront_internal_interrupt()
1743 spin_lock(&dev->irq_lock); in snd_wavefront_internal_interrupt()
1744 dev->irq_ok = 1; in snd_wavefront_internal_interrupt()
1745 dev->irq_cnt++; in snd_wavefront_internal_interrupt()
1746 spin_unlock(&dev->irq_lock); in snd_wavefront_internal_interrupt()
1747 wake_up(&dev->interrupt_sleeper); in snd_wavefront_internal_interrupt()
1784 bits = -1; in snd_wavefront_interrupt_bits()
1795 wait_queue_entry_t wait; in wavefront_should_cause_interrupt() local
1797 init_waitqueue_entry(&wait, current); in wavefront_should_cause_interrupt()
1798 spin_lock_irq(&dev->irq_lock); in wavefront_should_cause_interrupt()
1799 add_wait_queue(&dev->interrupt_sleeper, &wait); in wavefront_should_cause_interrupt()
1800 dev->irq_ok = 0; in wavefront_should_cause_interrupt()
1802 spin_unlock_irq(&dev->irq_lock); in wavefront_should_cause_interrupt()
1803 while (!dev->irq_ok && time_before(jiffies, timeout)) { in wavefront_should_cause_interrupt()
1818 bits = snd_wavefront_interrupt_bits (dev->irq); in wavefront_reset_to_cleanliness()
1822 outb (0x0, dev->control_port); in wavefront_reset_to_cleanliness()
1827 Bit 7 - Enable IRQ Driver in wavefront_reset_to_cleanliness()
1828 0 - Tri-state the Wave-Board drivers for the PC Bus IRQs in wavefront_reset_to_cleanliness()
1829 1 - Enable IRQ selected by bits 5:3 to be driven onto the PC Bus. in wavefront_reset_to_cleanliness()
1831 Bit 6 - MIDI Interface Select in wavefront_reset_to_cleanliness()
1833 0 - Use the MIDI Input from the 26-pin WaveBlaster in wavefront_reset_to_cleanliness()
1835 1 - Use the MIDI Input from the 9-pin D connector as the in wavefront_reset_to_cleanliness()
1838 Bits 5:3 - IRQ Selection in wavefront_reset_to_cleanliness()
1839 0 0 0 - IRQ 2/9 in wavefront_reset_to_cleanliness()
1840 0 0 1 - IRQ 5 in wavefront_reset_to_cleanliness()
1841 0 1 0 - IRQ 12 in wavefront_reset_to_cleanliness()
1842 0 1 1 - IRQ 15 in wavefront_reset_to_cleanliness()
1843 1 0 0 - Reserved in wavefront_reset_to_cleanliness()
1844 1 0 1 - Reserved in wavefront_reset_to_cleanliness()
1845 1 1 0 - Reserved in wavefront_reset_to_cleanliness()
1846 1 1 1 - Reserved in wavefront_reset_to_cleanliness()
1848 Bits 2:1 - Reserved in wavefront_reset_to_cleanliness()
1849 Bit 0 - Disable Boot ROM in wavefront_reset_to_cleanliness()
1850 0 - memory accesses to 03FC30-03FFFFH utilize the internal Boot ROM in wavefront_reset_to_cleanliness()
1851 1 - memory accesses to 03FC30-03FFFFH are directed to external in wavefront_reset_to_cleanliness()
1857 plus external 9-pin MIDI interface selected in wavefront_reset_to_cleanliness()
1860 outb (0x80 | 0x40 | bits, dev->data_port); in wavefront_reset_to_cleanliness()
1880 dev->control_port, in wavefront_reset_to_cleanliness()
1887 if (!dev->irq_ok) { in wavefront_reset_to_cleanliness()
1888 snd_printk ("intr not received after h/w un-reset.\n"); in wavefront_reset_to_cleanliness()
1896 will work. So, issue one of them, and wait for TX in wavefront_reset_to_cleanliness()
1899 seconds - with 12MB of RAM on a Tropez+, it takes a lot in wavefront_reset_to_cleanliness()
1909 dev->data_port, ramcheck_time*HZ); in wavefront_reset_to_cleanliness()
1911 if (!dev->irq_ok) { in wavefront_reset_to_cleanliness()
1912 snd_printk ("post-RAM-check interrupt not received.\n"); in wavefront_reset_to_cleanliness()
1922 if (hwv[0] == -1) { in wavefront_reset_to_cleanliness()
1934 if (hwv[0] == -1) { in wavefront_reset_to_cleanliness()
1935 snd_printk ("on-board RAM test failed " in wavefront_reset_to_cleanliness()
1938 snd_printk ("on-board RAM test failed " in wavefront_reset_to_cleanliness()
1948 if (hwv[1] == -1) { in wavefront_reset_to_cleanliness()
1972 err = request_firmware(&firmware, path, dev->card->dev); in wavefront_download_firmware()
1979 buf = firmware->data; in wavefront_download_firmware()
1980 for (;;) { in wavefront_download_firmware()
1993 if (firmware->size < len + section_length) { in wavefront_download_firmware()
2002 for (; section_length; section_length--) { in wavefront_download_firmware()
2009 /* get ACK */ in wavefront_download_firmware()
2011 snd_printk(KERN_ERR "time out for firmware ACK.\n"); in wavefront_download_firmware()
2014 err = inb(dev->data_port); in wavefront_download_firmware()
2018 "acknowledged, ack = 0x%x\n", in wavefront_download_firmware()
2047 if (dev->israw) { in wavefront_do_reset()
2052 dev->israw = 0; in wavefront_do_reset()
2054 /* Wait for the OS to get running. The protocol for in wavefront_do_reset()
2055 this is non-obvious, and was determined by in wavefront_do_reset()
2056 using port-IO tracing in DOSemu and some in wavefront_do_reset()
2063 dev->data_port, in wavefront_do_reset()
2066 if (!dev->irq_ok) { in wavefront_do_reset()
2067 snd_printk ("no post-OS interrupt.\n"); in wavefront_do_reset()
2074 dev->data_port, (10*HZ)); in wavefront_do_reset()
2076 if (!dev->irq_ok) { in wavefront_do_reset()
2077 snd_printk ("no post-OS interrupt(2).\n"); in wavefront_do_reset()
2085 outb (0x80|0x40, dev->control_port); in wavefront_do_reset()
2088 /* SETUPSND.EXE asks for sample memory config here, but since i in wavefront_do_reset()
2093 dev->freemem = wavefront_freemem(dev); in wavefront_do_reset()
2094 if (dev->freemem < 0) in wavefront_do_reset()
2097 snd_printk ("available DRAM %dk\n", dev->freemem / 1024); in wavefront_do_reset()
2102 dev->debug = 0; in wavefront_do_reset()
2120 outb (0x0, dev->control_port); in wavefront_do_reset()
2121 dev->interrupts_are_midi = 0; in wavefront_do_reset()
2135 if (dev->israw) { in snd_wavefront_start()
2138 /* XXX is this always true ? */ in snd_wavefront_start()
2142 if (dev->israw || fx_raw) { in snd_wavefront_start()
2144 return -1; in snd_wavefront_start()
2147 /* Check for FX device, present only on Tropez+ */ in snd_wavefront_start()
2149 dev->has_fx = (snd_wavefront_fx_detect (dev) == 0); in snd_wavefront_start()
2151 if (dev->has_fx && fx_raw) { in snd_wavefront_start()
2162 outb (0x80|0x40|0x20, dev->control_port); in snd_wavefront_start()
2172 snd_wavefront_t *dev = &card->wavefront; in snd_wavefront_detect()
2178 dev->israw = 0; in snd_wavefront_detect()
2179 dev->has_fx = 0; in snd_wavefront_detect()
2180 dev->debug = debug_default; in snd_wavefront_detect()
2181 dev->interrupts_are_midi = 0; in snd_wavefront_detect()
2182 dev->irq_cnt = 0; in snd_wavefront_detect()
2183 dev->rom_samples_rdonly = 1; in snd_wavefront_detect()
2187 dev->fw_version[0] = rbuf[0]; in snd_wavefront_detect()
2188 dev->fw_version[1] = rbuf[1]; in snd_wavefront_detect()
2197 dev->hw_version[0] = rbuf[0]; in snd_wavefront_detect()
2198 dev->hw_version[1] = rbuf[1]; in snd_wavefront_detect()
2202 return -1; in snd_wavefront_detect()
2209 dev->israw = 1; in snd_wavefront_detect()
2214 dev->israw = 1; in snd_wavefront_detect()