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