blob: 55053557c898ef5efe13c6bd59ff25b0f5452eab [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __SOUND_SND_WAVEFRONT_H__
3#define __SOUND_SND_WAVEFRONT_H__
4
David Howellsa1ce3922012-10-02 18:01:25 +01005#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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10/* MIDI interface */
11
12struct _snd_wavefront_midi;
13struct _snd_wavefront_card;
14struct _snd_wavefront;
15
16typedef struct _snd_wavefront_midi snd_wavefront_midi_t;
17typedef struct _snd_wavefront_card snd_wavefront_card_t;
18typedef struct _snd_wavefront snd_wavefront_t;
19
20typedef enum { internal_mpu = 0, external_mpu = 1 } snd_wavefront_mpu_id;
21
22struct _snd_wavefront_midi {
23 unsigned long base; /* I/O port address */
24 char isvirtual; /* doing virtual MIDI stuff ? */
25 char istimer; /* timer is used */
26 snd_wavefront_mpu_id output_mpu; /* most-recently-used */
27 snd_wavefront_mpu_id input_mpu; /* most-recently-used */
28 unsigned int mode[2]; /* MPU401_MODE_XXX */
Takashi Iwai542172f2005-11-17 14:39:06 +010029 struct snd_rawmidi_substream *substream_output[2];
30 struct snd_rawmidi_substream *substream_input[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 struct timer_list timer;
Kees Cook57e69e22017-10-24 08:35:09 -070032 snd_wavefront_card_t *timer_card;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 spinlock_t open;
34 spinlock_t virtual; /* protects isvirtual */
35};
36
37#define OUTPUT_READY 0x40
38#define INPUT_AVAIL 0x80
39#define MPU_ACK 0xFE
40#define UART_MODE_ON 0x3F
41
Takashi Iwai9021b2b2017-01-05 17:29:07 +010042extern const struct snd_rawmidi_ops snd_wavefront_midi_output;
43extern const struct snd_rawmidi_ops snd_wavefront_midi_input;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45extern void snd_wavefront_midi_enable_virtual (snd_wavefront_card_t *);
46extern void snd_wavefront_midi_disable_virtual (snd_wavefront_card_t *);
47extern void snd_wavefront_midi_interrupt (snd_wavefront_card_t *);
48extern int snd_wavefront_midi_start (snd_wavefront_card_t *);
49
50struct _snd_wavefront {
51 unsigned long irq; /* "you were one, one of the few ..." */
52 unsigned long base; /* low i/o port address */
53 struct resource *res_base; /* i/o port resource allocation */
54
55#define mpu_data_port base
56#define mpu_command_port base + 1 /* write semantics */
57#define mpu_status_port base + 1 /* read semantics */
58#define data_port base + 2
59#define status_port base + 3 /* read semantics */
60#define control_port base + 3 /* write semantics */
61#define block_port base + 4 /* 16 bit, writeonly */
62#define last_block_port base + 6 /* 16 bit, writeonly */
63
64 /* FX ports. These are mapped through the ICS2115 to the YS225.
65 The ICS2115 takes care of flipping the relevant pins on the
66 YS225 so that access to each of these ports does the right
67 thing. Note: these are NOT documented by Turtle Beach.
68 */
69
70#define fx_status base + 8
71#define fx_op base + 8
72#define fx_lcr base + 9
73#define fx_dsp_addr base + 0xa
74#define fx_dsp_page base + 0xb
75#define fx_dsp_lsb base + 0xc
76#define fx_dsp_msb base + 0xd
77#define fx_mod_addr base + 0xe
78#define fx_mod_data base + 0xf
79
80 volatile int irq_ok; /* set by interrupt handler */
81 volatile int irq_cnt; /* ditto */
82 char debug; /* debugging flags */
83 int freemem; /* installed RAM, in bytes */
84
85 char fw_version[2]; /* major = [0], minor = [1] */
86 char hw_version[2]; /* major = [0], minor = [1] */
87 char israw; /* needs Motorola microcode */
88 char has_fx; /* has FX processor (Tropez+) */
Clemens Ladisch59540fe2006-11-06 09:20:04 +010089 char fx_initialized; /* FX's register pages initialized */
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 char prog_status[WF_MAX_PROGRAM]; /* WF_SLOT_* */
91 char patch_status[WF_MAX_PATCH]; /* WF_SLOT_* */
92 char sample_status[WF_MAX_SAMPLE]; /* WF_ST_* | WF_SLOT_* */
93 int samples_used; /* how many */
94 char interrupts_are_midi; /* h/w MPU interrupts enabled ? */
95 char rom_samples_rdonly; /* can we write on ROM samples */
96 spinlock_t irq_lock;
97 wait_queue_head_t interrupt_sleeper;
98 snd_wavefront_midi_t midi; /* ICS2115 MIDI interface */
Clemens Ladisch59540fe2006-11-06 09:20:04 +010099 struct snd_card *card;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100};
101
102struct _snd_wavefront_card {
103 snd_wavefront_t wavefront;
104#ifdef CONFIG_PNP
105 struct pnp_dev *wss;
106 struct pnp_dev *ctrl;
107 struct pnp_dev *mpu;
108 struct pnp_dev *synth;
109#endif /* CONFIG_PNP */
110};
111
112extern void snd_wavefront_internal_interrupt (snd_wavefront_card_t *card);
113extern int snd_wavefront_detect_irq (snd_wavefront_t *dev) ;
114extern int snd_wavefront_check_irq (snd_wavefront_t *dev, int irq);
115extern int snd_wavefront_restart (snd_wavefront_t *dev);
116extern int snd_wavefront_start (snd_wavefront_t *dev);
117extern int snd_wavefront_detect (snd_wavefront_card_t *card);
118extern int snd_wavefront_config_midi (snd_wavefront_t *dev) ;
119extern int snd_wavefront_cmd (snd_wavefront_t *, int, unsigned char *,
120 unsigned char *);
121
Takashi Iwai542172f2005-11-17 14:39:06 +0100122extern int snd_wavefront_synth_ioctl (struct snd_hwdep *,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 struct file *,
124 unsigned int cmd,
125 unsigned long arg);
Takashi Iwai542172f2005-11-17 14:39:06 +0100126extern int snd_wavefront_synth_open (struct snd_hwdep *, struct file *);
127extern int snd_wavefront_synth_release (struct snd_hwdep *, struct file *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129/* FX processor - see also yss225.[ch] */
130
131extern int snd_wavefront_fx_start (snd_wavefront_t *);
132extern int snd_wavefront_fx_detect (snd_wavefront_t *);
Takashi Iwai542172f2005-11-17 14:39:06 +0100133extern int snd_wavefront_fx_ioctl (struct snd_hwdep *,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 struct file *,
135 unsigned int cmd,
136 unsigned long arg);
Takashi Iwai542172f2005-11-17 14:39:06 +0100137extern int snd_wavefront_fx_open (struct snd_hwdep *, struct file *);
138extern int snd_wavefront_fx_release (struct snd_hwdep *, struct file *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
140/* prefix in all snd_printk() delivered messages */
141
142#define LOGNAME "WaveFront: "
143
144#endif /* __SOUND_SND_WAVEFRONT_H__ */