162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef __SOUND_SND_WAVEFRONT_H__
362306a36Sopenharmony_ci#define __SOUND_SND_WAVEFRONT_H__
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <sound/mpu401.h>
662306a36Sopenharmony_ci#include <sound/hwdep.h>
762306a36Sopenharmony_ci#include <sound/rawmidi.h>
862306a36Sopenharmony_ci#include <sound/wavefront.h>  /* generic OSS/ALSA/user-level wavefront header */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/* MIDI interface */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cistruct _snd_wavefront_midi;
1362306a36Sopenharmony_cistruct _snd_wavefront_card;
1462306a36Sopenharmony_cistruct _snd_wavefront;
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_citypedef struct _snd_wavefront_midi snd_wavefront_midi_t;
1762306a36Sopenharmony_citypedef struct _snd_wavefront_card snd_wavefront_card_t;
1862306a36Sopenharmony_citypedef struct _snd_wavefront snd_wavefront_t;
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_citypedef enum { internal_mpu = 0, external_mpu = 1 } snd_wavefront_mpu_id;
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_cistruct _snd_wavefront_midi {
2362306a36Sopenharmony_ci        unsigned long            base;        /* I/O port address */
2462306a36Sopenharmony_ci	char                     isvirtual;   /* doing virtual MIDI stuff ? */
2562306a36Sopenharmony_ci	char			 istimer;     /* timer is used */
2662306a36Sopenharmony_ci        snd_wavefront_mpu_id     output_mpu;  /* most-recently-used */
2762306a36Sopenharmony_ci        snd_wavefront_mpu_id     input_mpu;   /* most-recently-used */
2862306a36Sopenharmony_ci        unsigned int             mode[2];     /* MPU401_MODE_XXX */
2962306a36Sopenharmony_ci	struct snd_rawmidi_substream	 *substream_output[2];
3062306a36Sopenharmony_ci	struct snd_rawmidi_substream	 *substream_input[2];
3162306a36Sopenharmony_ci	struct timer_list	 timer;
3262306a36Sopenharmony_ci	snd_wavefront_card_t	 *timer_card;
3362306a36Sopenharmony_ci        spinlock_t               open;
3462306a36Sopenharmony_ci        spinlock_t               virtual;     /* protects isvirtual */
3562306a36Sopenharmony_ci};
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define	OUTPUT_READY	0x40
3862306a36Sopenharmony_ci#define	INPUT_AVAIL	0x80
3962306a36Sopenharmony_ci#define	MPU_ACK		0xFE
4062306a36Sopenharmony_ci#define	UART_MODE_ON	0x3F
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciextern const struct snd_rawmidi_ops snd_wavefront_midi_output;
4362306a36Sopenharmony_ciextern const struct snd_rawmidi_ops snd_wavefront_midi_input;
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciextern void   snd_wavefront_midi_enable_virtual (snd_wavefront_card_t *);
4662306a36Sopenharmony_ciextern void   snd_wavefront_midi_disable_virtual (snd_wavefront_card_t *);
4762306a36Sopenharmony_ciextern void   snd_wavefront_midi_interrupt (snd_wavefront_card_t *);
4862306a36Sopenharmony_ciextern int    snd_wavefront_midi_start (snd_wavefront_card_t *);
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_cistruct _snd_wavefront {
5162306a36Sopenharmony_ci	unsigned long    irq;   /* "you were one, one of the few ..." */
5262306a36Sopenharmony_ci	unsigned long    base;  /* low i/o port address */
5362306a36Sopenharmony_ci	struct resource	 *res_base; /* i/o port resource allocation */
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#define mpu_data_port    base
5662306a36Sopenharmony_ci#define mpu_command_port base + 1 /* write semantics */
5762306a36Sopenharmony_ci#define mpu_status_port  base + 1 /* read semantics */
5862306a36Sopenharmony_ci#define data_port        base + 2
5962306a36Sopenharmony_ci#define status_port      base + 3 /* read semantics */
6062306a36Sopenharmony_ci#define control_port     base + 3 /* write semantics  */
6162306a36Sopenharmony_ci#define block_port       base + 4 /* 16 bit, writeonly */
6262306a36Sopenharmony_ci#define last_block_port  base + 6 /* 16 bit, writeonly */
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci	/* FX ports. These are mapped through the ICS2115 to the YS225.
6562306a36Sopenharmony_ci	   The ICS2115 takes care of flipping the relevant pins on the
6662306a36Sopenharmony_ci	   YS225 so that access to each of these ports does the right
6762306a36Sopenharmony_ci	   thing. Note: these are NOT documented by Turtle Beach.
6862306a36Sopenharmony_ci	*/
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci#define fx_status       base + 8
7162306a36Sopenharmony_ci#define fx_op           base + 8
7262306a36Sopenharmony_ci#define fx_lcr          base + 9
7362306a36Sopenharmony_ci#define fx_dsp_addr     base + 0xa
7462306a36Sopenharmony_ci#define fx_dsp_page     base + 0xb
7562306a36Sopenharmony_ci#define fx_dsp_lsb      base + 0xc
7662306a36Sopenharmony_ci#define fx_dsp_msb      base + 0xd
7762306a36Sopenharmony_ci#define fx_mod_addr     base + 0xe
7862306a36Sopenharmony_ci#define fx_mod_data     base + 0xf
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci	volatile int irq_ok;               /* set by interrupt handler */
8162306a36Sopenharmony_ci        volatile int irq_cnt;              /* ditto */
8262306a36Sopenharmony_ci	char debug;                        /* debugging flags */
8362306a36Sopenharmony_ci	int freemem;                       /* installed RAM, in bytes */
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci	char fw_version[2];                /* major = [0], minor = [1] */
8662306a36Sopenharmony_ci	char hw_version[2];                /* major = [0], minor = [1] */
8762306a36Sopenharmony_ci	char israw;                        /* needs Motorola microcode */
8862306a36Sopenharmony_ci	char has_fx;                       /* has FX processor (Tropez+) */
8962306a36Sopenharmony_ci	char fx_initialized;               /* FX's register pages initialized */
9062306a36Sopenharmony_ci	char prog_status[WF_MAX_PROGRAM];  /* WF_SLOT_* */
9162306a36Sopenharmony_ci	char patch_status[WF_MAX_PATCH];   /* WF_SLOT_* */
9262306a36Sopenharmony_ci	char sample_status[WF_MAX_SAMPLE]; /* WF_ST_* | WF_SLOT_* */
9362306a36Sopenharmony_ci	int samples_used;                  /* how many */
9462306a36Sopenharmony_ci	char interrupts_are_midi;          /* h/w MPU interrupts enabled ? */
9562306a36Sopenharmony_ci	char rom_samples_rdonly;           /* can we write on ROM samples */
9662306a36Sopenharmony_ci	spinlock_t irq_lock;
9762306a36Sopenharmony_ci	wait_queue_head_t interrupt_sleeper;
9862306a36Sopenharmony_ci	snd_wavefront_midi_t midi;         /* ICS2115 MIDI interface */
9962306a36Sopenharmony_ci	struct snd_card *card;
10062306a36Sopenharmony_ci};
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_cistruct _snd_wavefront_card {
10362306a36Sopenharmony_ci	snd_wavefront_t wavefront;
10462306a36Sopenharmony_ci#ifdef CONFIG_PNP
10562306a36Sopenharmony_ci	struct pnp_dev *wss;
10662306a36Sopenharmony_ci	struct pnp_dev *ctrl;
10762306a36Sopenharmony_ci	struct pnp_dev *mpu;
10862306a36Sopenharmony_ci	struct pnp_dev *synth;
10962306a36Sopenharmony_ci#endif /* CONFIG_PNP */
11062306a36Sopenharmony_ci};
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ciextern void snd_wavefront_internal_interrupt (snd_wavefront_card_t *card);
11362306a36Sopenharmony_ciextern int  snd_wavefront_detect_irq (snd_wavefront_t *dev) ;
11462306a36Sopenharmony_ciextern int  snd_wavefront_check_irq (snd_wavefront_t *dev, int irq);
11562306a36Sopenharmony_ciextern int  snd_wavefront_restart (snd_wavefront_t *dev);
11662306a36Sopenharmony_ciextern int  snd_wavefront_start (snd_wavefront_t *dev);
11762306a36Sopenharmony_ciextern int  snd_wavefront_detect (snd_wavefront_card_t *card);
11862306a36Sopenharmony_ciextern int  snd_wavefront_config_midi (snd_wavefront_t *dev) ;
11962306a36Sopenharmony_ciextern int  snd_wavefront_cmd (snd_wavefront_t *, int, unsigned char *,
12062306a36Sopenharmony_ci			       unsigned char *);
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ciextern int snd_wavefront_synth_ioctl   (struct snd_hwdep *,
12362306a36Sopenharmony_ci					struct file *,
12462306a36Sopenharmony_ci					unsigned int cmd,
12562306a36Sopenharmony_ci					unsigned long arg);
12662306a36Sopenharmony_ciextern int  snd_wavefront_synth_open    (struct snd_hwdep *, struct file *);
12762306a36Sopenharmony_ciextern int  snd_wavefront_synth_release (struct snd_hwdep *, struct file *);
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci/* FX processor - see also yss225.[ch] */
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ciextern int  snd_wavefront_fx_start  (snd_wavefront_t *);
13262306a36Sopenharmony_ciextern int  snd_wavefront_fx_detect (snd_wavefront_t *);
13362306a36Sopenharmony_ciextern int  snd_wavefront_fx_ioctl  (struct snd_hwdep *,
13462306a36Sopenharmony_ci				     struct file *,
13562306a36Sopenharmony_ci				     unsigned int cmd,
13662306a36Sopenharmony_ci				     unsigned long arg);
13762306a36Sopenharmony_ciextern int snd_wavefront_fx_open    (struct snd_hwdep *, struct file *);
13862306a36Sopenharmony_ciextern int snd_wavefront_fx_release (struct snd_hwdep *, struct file *);
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci/* prefix in all snd_printk() delivered messages */
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#define LOGNAME "WaveFront: "
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci#endif  /* __SOUND_SND_WAVEFRONT_H__ */
145