linux/include/sound/gus.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef __SOUND_GUS_H
#define __SOUND_GUS_H

/*
 *  Global structures used for GUS part of ALSA driver
 *  Copyright (c) by Jaroslav Kysela <[email protected]>
 */

#include <sound/pcm.h>
#include <sound/rawmidi.h>
#include <sound/timer.h>
#include <sound/seq_midi_emul.h>
#include <sound/seq_device.h>
#include <linux/io.h>

/* IO ports */

#define GUSP(gus, x)

#define SNDRV_g_u_s_MIDICTRL
#define SNDRV_g_u_s_MIDISTAT
#define SNDRV_g_u_s_MIDIDATA

#define SNDRV_g_u_s_GF1PAGE
#define SNDRV_g_u_s_GF1REGSEL
#define SNDRV_g_u_s_GF1DATALOW
#define SNDRV_g_u_s_GF1DATAHIGH
#define SNDRV_g_u_s_IRQSTAT
#define SNDRV_g_u_s_TIMERCNTRL
#define SNDRV_g_u_s_TIMERDATA
#define SNDRV_g_u_s_DRAM
#define SNDRV_g_u_s_MIXCNTRLREG
#define SNDRV_g_u_s_IRQDMACNTRLREG
#define SNDRV_g_u_s_REGCNTRLS
#define SNDRV_g_u_s_BOARDVERSION
#define SNDRV_g_u_s_MIXCNTRLPORT
#define SNDRV_g_u_s_IVER
#define SNDRV_g_u_s_MIXDATAPORT
#define SNDRV_g_u_s_MAXCNTRLPORT

/* GF1 registers */

/* global registers */
#define SNDRV_GF1_GB_ACTIVE_VOICES
#define SNDRV_GF1_GB_VOICES_IRQ
#define SNDRV_GF1_GB_GLOBAL_MODE
#define SNDRV_GF1_GW_LFO_BASE
#define SNDRV_GF1_GB_VOICES_IRQ_READ
#define SNDRV_GF1_GB_DRAM_DMA_CONTROL
#define SNDRV_GF1_GW_DRAM_DMA_LOW
#define SNDRV_GF1_GW_DRAM_IO_LOW
#define SNDRV_GF1_GB_DRAM_IO_HIGH
#define SNDRV_GF1_GB_SOUND_BLASTER_CONTROL
#define SNDRV_GF1_GB_ADLIB_TIMER_1
#define SNDRV_GF1_GB_ADLIB_TIMER_2
#define SNDRV_GF1_GB_RECORD_RATE
#define SNDRV_GF1_GB_REC_DMA_CONTROL
#define SNDRV_GF1_GB_JOYSTICK_DAC_LEVEL
#define SNDRV_GF1_GB_RESET
#define SNDRV_GF1_GB_DRAM_DMA_HIGH
#define SNDRV_GF1_GW_DRAM_IO16
#define SNDRV_GF1_GW_MEMORY_CONFIG
#define SNDRV_GF1_GB_MEMORY_CONTROL
#define SNDRV_GF1_GW_FIFO_RECORD_BASE_ADDR
#define SNDRV_GF1_GW_FIFO_PLAY_BASE_ADDR
#define SNDRV_GF1_GW_FIFO_SIZE
#define SNDRV_GF1_GW_INTERLEAVE
#define SNDRV_GF1_GB_COMPATIBILITY
#define SNDRV_GF1_GB_DECODE_CONTROL
#define SNDRV_GF1_GB_VERSION_NUMBER
#define SNDRV_GF1_GB_MPU401_CONTROL_A
#define SNDRV_GF1_GB_MPU401_CONTROL_B
#define SNDRV_GF1_GB_EMULATION_IRQ
/* voice specific registers */
#define SNDRV_GF1_VB_ADDRESS_CONTROL
#define SNDRV_GF1_VW_FREQUENCY
#define SNDRV_GF1_VW_START_HIGH
#define SNDRV_GF1_VW_START_LOW
#define SNDRV_GF1_VA_START
#define SNDRV_GF1_VW_END_HIGH
#define SNDRV_GF1_VW_END_LOW
#define SNDRV_GF1_VA_END
#define SNDRV_GF1_VB_VOLUME_RATE
#define SNDRV_GF1_VB_VOLUME_START
#define SNDRV_GF1_VB_VOLUME_END
#define SNDRV_GF1_VW_VOLUME
#define SNDRV_GF1_VW_CURRENT_HIGH
#define SNDRV_GF1_VW_CURRENT_LOW
#define SNDRV_GF1_VA_CURRENT
#define SNDRV_GF1_VB_PAN
#define SNDRV_GF1_VW_OFFSET_RIGHT
#define SNDRV_GF1_VB_VOLUME_CONTROL
#define SNDRV_GF1_VB_UPPER_ADDRESS
#define SNDRV_GF1_VW_EFFECT_HIGH
#define SNDRV_GF1_VW_EFFECT_LOW
#define SNDRV_GF1_VA_EFFECT
#define SNDRV_GF1_VW_OFFSET_LEFT
#define SNDRV_GF1_VB_ACCUMULATOR
#define SNDRV_GF1_VB_MODE
#define SNDRV_GF1_VW_EFFECT_VOLUME
#define SNDRV_GF1_VB_FREQUENCY_LFO
#define SNDRV_GF1_VB_VOLUME_LFO
#define SNDRV_GF1_VW_OFFSET_RIGHT_FINAL
#define SNDRV_GF1_VW_OFFSET_LEFT_FINAL
#define SNDRV_GF1_VW_EFFECT_VOLUME_FINAL

/* ICS registers */

#define SNDRV_ICS_MIC_DEV
#define SNDRV_ICS_LINE_DEV
#define SNDRV_ICS_CD_DEV
#define SNDRV_ICS_GF1_DEV
#define SNDRV_ICS_NONE_DEV
#define SNDRV_ICS_MASTER_DEV

/* LFO */

#define SNDRV_LFO_TREMOLO
#define SNDRV_LFO_VIBRATO

/* misc */

#define SNDRV_GF1_DMA_UNSIGNED
#define SNDRV_GF1_DMA_16BIT
#define SNDRV_GF1_DMA_IRQ
#define SNDRV_GF1_DMA_WIDTH16
#define SNDRV_GF1_DMA_READ
#define SNDRV_GF1_DMA_ENABLE

/* ramp ranges */

#define SNDRV_GF1_ATTEN(x)
#define SNDRV_GF1_MIN_VOLUME
#define SNDRV_GF1_MAX_VOLUME
#define SNDRV_GF1_MIN_OFFSET
#define SNDRV_GF1_MAX_OFFSET
#define SNDRV_GF1_MAX_TDEPTH

/* defines for memory manager */

#define SNDRV_GF1_MEM_BLOCK_16BIT

#define SNDRV_GF1_MEM_OWNER_DRIVER
#define SNDRV_GF1_MEM_OWNER_WAVE_SIMPLE
#define SNDRV_GF1_MEM_OWNER_WAVE_GF1
#define SNDRV_GF1_MEM_OWNER_WAVE_IWFFFF

/* constants for interrupt handlers */

#define SNDRV_GF1_HANDLER_MIDI_OUT
#define SNDRV_GF1_HANDLER_MIDI_IN
#define SNDRV_GF1_HANDLER_TIMER1
#define SNDRV_GF1_HANDLER_TIMER2
#define SNDRV_GF1_HANDLER_VOICE
#define SNDRV_GF1_HANDLER_DMA_WRITE
#define SNDRV_GF1_HANDLER_DMA_READ
#define SNDRV_GF1_HANDLER_ALL

/* constants for DMA flags */

#define SNDRV_GF1_DMA_TRIGGER

/* --- */

struct snd_gus_card;

/* GF1 specific structure */

struct snd_gf1_bank_info {};

struct snd_gf1_mem_block {};

struct snd_gf1_mem {};

struct snd_gf1_dma_block {};

struct snd_gus_port {};

struct snd_gus_voice;

#define SNDRV_GF1_VOICE_TYPE_PCM
#define SNDRV_GF1_VOICE_TYPE_SYNTH
#define SNDRV_GF1_VOICE_TYPE_MIDI

#define SNDRV_GF1_VFLG_RUNNING
#define SNDRV_GF1_VFLG_EFFECT_TIMER1
#define SNDRV_GF1_VFLG_PAN

enum snd_gus_volume_state {};

struct snd_gus_voice {};

struct snd_gf1 {};

/* main structure for GUS card */

struct snd_gus_card {};

/* I/O functions for GF1/InterWave chip - gus_io.c */

static inline void snd_gf1_select_voice(struct snd_gus_card * gus, int voice)
{}

static inline void snd_gf1_uart_cmd(struct snd_gus_card * gus, unsigned char b)
{}

static inline unsigned char snd_gf1_uart_stat(struct snd_gus_card * gus)
{}

static inline void snd_gf1_uart_put(struct snd_gus_card * gus, unsigned char b)
{}

static inline unsigned char snd_gf1_uart_get(struct snd_gus_card * gus)
{}

extern void snd_gf1_delay(struct snd_gus_card * gus);

extern void snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg);

extern void snd_gf1_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
extern unsigned char snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg);
static inline unsigned char snd_gf1_read8(struct snd_gus_card * gus, unsigned char reg)
{}
extern void snd_gf1_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data);
extern unsigned short snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg);
static inline unsigned short snd_gf1_read16(struct snd_gus_card * gus, unsigned char reg)
{}
extern void snd_gf1_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
extern void snd_gf1_dram_addr(struct snd_gus_card * gus, unsigned int addr);
extern void snd_gf1_poke(struct snd_gus_card * gus, unsigned int addr, unsigned char data);
extern unsigned char snd_gf1_peek(struct snd_gus_card * gus, unsigned int addr);
extern void snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, short w_16bit);
extern unsigned int snd_gf1_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit);
extern void snd_gf1_i_ctrl_stop(struct snd_gus_card * gus, unsigned char reg);
extern void snd_gf1_i_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
extern unsigned char snd_gf1_i_look8(struct snd_gus_card * gus, unsigned char reg);
extern void snd_gf1_i_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data);
static inline unsigned char snd_gf1_i_read8(struct snd_gus_card * gus, unsigned char reg)
{}
extern unsigned short snd_gf1_i_look16(struct snd_gus_card * gus, unsigned char reg);
static inline unsigned short snd_gf1_i_read16(struct snd_gus_card * gus, unsigned char reg)
{}

extern void snd_gf1_select_active_voices(struct snd_gus_card * gus);

/* gus_lfo.c */

struct _SND_IW_LFO_PROGRAM {};

#if 0
extern irqreturn_t snd_gf1_lfo_effect_interrupt(struct snd_gus_card * gus, snd_gf1_voice_t * voice);
#endif
extern void snd_gf1_lfo_init(struct snd_gus_card * gus);
extern void snd_gf1_lfo_done(struct snd_gus_card * gus);
extern void snd_gf1_lfo_program(struct snd_gus_card * gus, int voice, int lfo_type, struct _SND_IW_LFO_PROGRAM *program);
extern void snd_gf1_lfo_enable(struct snd_gus_card * gus, int voice, int lfo_type);
extern void snd_gf1_lfo_disable(struct snd_gus_card * gus, int voice, int lfo_type);
extern void snd_gf1_lfo_change_freq(struct snd_gus_card * gus, int voice, int lfo_type, int freq);
extern void snd_gf1_lfo_change_depth(struct snd_gus_card * gus, int voice, int lfo_type, int depth);
extern void snd_gf1_lfo_setup(struct snd_gus_card * gus, int voice, int lfo_type, int freq, int current_depth, int depth, int sweep, int shape);
extern void snd_gf1_lfo_shutdown(struct snd_gus_card * gus, int voice, int lfo_type);
#if 0
extern void snd_gf1_lfo_command(struct snd_gus_card * gus, int voice, unsigned char *command);
#endif

/* gus_mem.c */

void snd_gf1_mem_lock(struct snd_gf1_mem * alloc, int xup);
int snd_gf1_mem_xfree(struct snd_gf1_mem * alloc, struct snd_gf1_mem_block * block);
struct snd_gf1_mem_block *snd_gf1_mem_alloc(struct snd_gf1_mem * alloc, int owner,
				       char *name, int size, int w_16,
				       int align, unsigned int *share_id);
int snd_gf1_mem_free(struct snd_gf1_mem * alloc, unsigned int address);
int snd_gf1_mem_free_owner(struct snd_gf1_mem * alloc, int owner);
int snd_gf1_mem_init(struct snd_gus_card * gus);
int snd_gf1_mem_done(struct snd_gus_card * gus);

/* gus_mem_proc.c */

int snd_gf1_mem_proc_init(struct snd_gus_card * gus);

/* gus_dma.c */

int snd_gf1_dma_init(struct snd_gus_card * gus);
int snd_gf1_dma_done(struct snd_gus_card * gus);
int snd_gf1_dma_transfer_block(struct snd_gus_card * gus,
			       struct snd_gf1_dma_block * block,
			       int atomic,
			       int synth);

/* gus_volume.c */

unsigned short snd_gf1_lvol_to_gvol_raw(unsigned int vol);
unsigned short snd_gf1_translate_freq(struct snd_gus_card * gus, unsigned int freq2);

/* gus_reset.c */

void snd_gf1_set_default_handlers(struct snd_gus_card * gus, unsigned int what);
void snd_gf1_smart_stop_voice(struct snd_gus_card * gus, unsigned short voice);
void snd_gf1_stop_voice(struct snd_gus_card * gus, unsigned short voice);
void snd_gf1_stop_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max);
struct snd_gus_voice *snd_gf1_alloc_voice(struct snd_gus_card * gus, int type, int client, int port);
void snd_gf1_free_voice(struct snd_gus_card * gus, struct snd_gus_voice *voice);
int snd_gf1_start(struct snd_gus_card * gus);
int snd_gf1_stop(struct snd_gus_card * gus);

/* gus_mixer.c */

int snd_gf1_new_mixer(struct snd_gus_card * gus);

/* gus_pcm.c */

int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index);

#ifdef CONFIG_SND_DEBUG
extern void snd_gf1_print_voice_registers(struct snd_gus_card * gus);
#endif

/* gus.c */

int snd_gus_use_inc(struct snd_gus_card * gus);
void snd_gus_use_dec(struct snd_gus_card * gus);
int snd_gus_create(struct snd_card *card,
		   unsigned long port,
		   int irq, int dma1, int dma2,
		   int timer_dev,
		   int voices,
		   int pcm_channels,
		   int effect,
		   struct snd_gus_card ** rgus);
int snd_gus_initialize(struct snd_gus_card * gus);

/* gus_irq.c */

irqreturn_t snd_gus_interrupt(int irq, void *dev_id);
#ifdef CONFIG_SND_DEBUG
void snd_gus_irq_profile_init(struct snd_gus_card *gus);
#endif

/* gus_uart.c */

int snd_gf1_rawmidi_new(struct snd_gus_card *gus, int device);

/* gus_dram.c */
int snd_gus_dram_write(struct snd_gus_card *gus, char __user *ptr,
		       unsigned int addr, unsigned int size);
int snd_gus_dram_read(struct snd_gus_card *gus, char __user *ptr,
		      unsigned int addr, unsigned int size, int rom);

/* gus_timer.c */
void snd_gf1_timers_init(struct snd_gus_card *gus);
void snd_gf1_timers_done(struct snd_gus_card *gus);

#endif /* __SOUND_GUS_H */