1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __SOUND_SND_WAVEFRONT_H__ 3 #define __SOUND_SND_WAVEFRONT_H__ 4 5 #include <sound/mpu401.h> 6 #include <sound/hwdep.h> 7 #include <sound/rawmidi.h> 8 #include <sound/wavefront.h> /* generic OSS/ALSA/user-level wavefront header */ 9 10 /* MIDI interface */ 11 12 struct _snd_wavefront_midi; 13 struct _snd_wavefront_card; 14 struct _snd_wavefront; 15 struct snd_wss; 16 17 typedef struct _snd_wavefront_midi snd_wavefront_midi_t; 18 typedef struct _snd_wavefront_card snd_wavefront_card_t; 19 typedef struct _snd_wavefront snd_wavefront_t; 20 21 typedef enum { internal_mpu = 0, external_mpu = 1 } snd_wavefront_mpu_id; 22 23 struct _snd_wavefront_midi { 24 unsigned long base; /* I/O port address */ 25 char isvirtual; /* doing virtual MIDI stuff ? */ 26 char istimer; /* timer is used */ 27 snd_wavefront_mpu_id output_mpu; /* most-recently-used */ 28 snd_wavefront_mpu_id input_mpu; /* most-recently-used */ 29 unsigned int mode[2]; /* MPU401_MODE_XXX */ 30 struct snd_rawmidi_substream *substream_output[2]; 31 struct snd_rawmidi_substream *substream_input[2]; 32 struct timer_list timer; 33 snd_wavefront_card_t *timer_card; 34 spinlock_t open; 35 spinlock_t virtual; /* protects isvirtual */ 36 }; 37 38 #define OUTPUT_READY 0x40 39 #define INPUT_AVAIL 0x80 40 #define MPU_ACK 0xFE 41 #define UART_MODE_ON 0x3F 42 43 extern const struct snd_rawmidi_ops snd_wavefront_midi_output; 44 extern const struct snd_rawmidi_ops snd_wavefront_midi_input; 45 46 extern void snd_wavefront_midi_enable_virtual (snd_wavefront_card_t *); 47 extern void snd_wavefront_midi_disable_virtual (snd_wavefront_card_t *); 48 extern void snd_wavefront_midi_interrupt (snd_wavefront_card_t *); 49 extern int snd_wavefront_midi_start (snd_wavefront_card_t *); 50 void snd_wavefront_midi_suspend(snd_wavefront_card_t *card); 51 void snd_wavefront_midi_resume(snd_wavefront_card_t *card); 52 53 struct _snd_wavefront { 54 unsigned long irq; /* "you were one, one of the few ..." */ 55 unsigned long base; /* low i/o port address */ 56 struct resource *res_base; /* i/o port resource allocation */ 57 58 #define mpu_data_port base 59 #define mpu_command_port base + 1 /* write semantics */ 60 #define mpu_status_port base + 1 /* read semantics */ 61 #define data_port base + 2 62 #define status_port base + 3 /* read semantics */ 63 #define control_port base + 3 /* write semantics */ 64 #define block_port base + 4 /* 16 bit, writeonly */ 65 #define last_block_port base + 6 /* 16 bit, writeonly */ 66 67 /* FX ports. These are mapped through the ICS2115 to the YS225. 68 The ICS2115 takes care of flipping the relevant pins on the 69 YS225 so that access to each of these ports does the right 70 thing. Note: these are NOT documented by Turtle Beach. 71 */ 72 73 #define fx_status base + 8 74 #define fx_op base + 8 75 #define fx_lcr base + 9 76 #define fx_dsp_addr base + 0xa 77 #define fx_dsp_page base + 0xb 78 #define fx_dsp_lsb base + 0xc 79 #define fx_dsp_msb base + 0xd 80 #define fx_mod_addr base + 0xe 81 #define fx_mod_data base + 0xf 82 83 volatile int irq_ok; /* set by interrupt handler */ 84 volatile int irq_cnt; /* ditto */ 85 char debug; /* debugging flags */ 86 int freemem; /* installed RAM, in bytes */ 87 88 char fw_version[2]; /* major = [0], minor = [1] */ 89 char hw_version[2]; /* major = [0], minor = [1] */ 90 char israw; /* needs Motorola microcode */ 91 char has_fx; /* has FX processor (Tropez+) */ 92 char fx_initialized; /* FX's register pages initialized */ 93 char prog_status[WF_MAX_PROGRAM]; /* WF_SLOT_* */ 94 char patch_status[WF_MAX_PATCH]; /* WF_SLOT_* */ 95 char sample_status[WF_MAX_SAMPLE]; /* WF_ST_* | WF_SLOT_* */ 96 int samples_used; /* how many */ 97 char interrupts_are_midi; /* h/w MPU interrupts enabled ? */ 98 char rom_samples_rdonly; /* can we write on ROM samples */ 99 char midi_in_to_synth; /* route external MIDI to synth */ 100 spinlock_t irq_lock; 101 wait_queue_head_t interrupt_sleeper; 102 snd_wavefront_midi_t midi; /* ICS2115 MIDI interface */ 103 struct snd_card *card; 104 }; 105 106 struct _snd_wavefront_card { 107 snd_wavefront_t wavefront; 108 struct snd_wss *chip; 109 #ifdef CONFIG_PNP 110 struct pnp_dev *wss; 111 struct pnp_dev *ctrl; 112 struct pnp_dev *mpu; 113 struct pnp_dev *synth; 114 #endif /* CONFIG_PNP */ 115 }; 116 117 extern void snd_wavefront_internal_interrupt (snd_wavefront_card_t *card); 118 void snd_wavefront_cache_firmware(snd_wavefront_t *dev); 119 extern int snd_wavefront_start (snd_wavefront_t *dev); 120 extern int snd_wavefront_detect (snd_wavefront_card_t *card); 121 int snd_wavefront_resume_synth(snd_wavefront_card_t *card); 122 extern int snd_wavefront_cmd (snd_wavefront_t *, int, unsigned char *, 123 unsigned char *); 124 125 extern int snd_wavefront_synth_ioctl (struct snd_hwdep *, 126 struct file *, 127 unsigned int cmd, 128 unsigned long arg); 129 extern int snd_wavefront_synth_open (struct snd_hwdep *, struct file *); 130 extern int snd_wavefront_synth_release (struct snd_hwdep *, struct file *); 131 132 /* FX processor - see also yss225.[ch] */ 133 134 extern int snd_wavefront_fx_start (snd_wavefront_t *); 135 extern int snd_wavefront_fx_detect (snd_wavefront_t *); 136 extern int snd_wavefront_fx_ioctl (struct snd_hwdep *, 137 struct file *, 138 unsigned int cmd, 139 unsigned long arg); 140 extern int snd_wavefront_fx_open (struct snd_hwdep *, struct file *); 141 extern int snd_wavefront_fx_release (struct snd_hwdep *, struct file *); 142 143 #endif /* __SOUND_SND_WAVEFRONT_H__ */ 144