linux/sound/pci/au88x0/au88x0.h

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

#include <linux/pci.h>
#include <linux/io.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/rawmidi.h>
#include <sound/mpu401.h>
#include <sound/hwdep.h>
#include <sound/ac97_codec.h>
#include <sound/tlv.h>

#ifndef CHIP_AU8820
#include "au88x0_eq.h"
#include "au88x0_a3d.h"
#endif
#ifndef CHIP_AU8810
#include "au88x0_wt.h"
#endif

#define hwread(x,y)
#define hwwrite(x,y,z)

/* Vortex MPU401 defines. */
#define MIDI_CLOCK_DIV
/* Standart MPU401 defines. */
#define MPU401_RESET
#define MPU401_ENTER_UART
#define MPU401_ACK

// Get src register value to convert from x to y.
#define SRC_RATIO(x,y)

/* FIFO software state constants. */
#define FIFO_STOP
#define FIFO_START
#define FIFO_PAUSE

/* IRQ flags */
#define IRQ_ERR_MASK
#define IRQ_FATAL
#define IRQ_PARITY
#define IRQ_REG
#define IRQ_FIFO
#define IRQ_DMA
#define IRQ_PCMOUT
#define IRQ_TIMER
#define IRQ_MIDI
#define IRQ_MODEM

/* ADB Resource */
#define VORTEX_RESOURCE_DMA
#define VORTEX_RESOURCE_SRC
#define VORTEX_RESOURCE_MIXIN
#define VORTEX_RESOURCE_MIXOUT
#define VORTEX_RESOURCE_A3D
#define VORTEX_RESOURCE_LAST

/* codec io: VORTEX_CODEC_IO bits */
#define VORTEX_CODEC_ID_SHIFT
#define VORTEX_CODEC_WRITE
#define VORTEX_CODEC_ADDSHIFT
#define VORTEX_CODEC_ADDMASK
#define VORTEX_CODEC_DATSHIFT
#define VORTEX_CODEC_DATMASK

/* Check for SDAC bit in "Extended audio ID" AC97 register */
//#define VORTEX_IS_QUAD(x) (((x)->codec == NULL) ?  0 : ((x)->codec->ext_id&0x80))
#define VORTEX_IS_QUAD(x)
/* Check if chip has bug. */
#define IS_BAD_CHIP(x)


/* PCM devices */
#define VORTEX_PCM_ADB
#define VORTEX_PCM_SPDIF
#define VORTEX_PCM_A3D
#define VORTEX_PCM_WT
#define VORTEX_PCM_I2S
#define VORTEX_PCM_LAST

#define MIX_CAPT(x)
#define MIX_PLAYB(x)
#define MIX_SPDIF(x)

#define NR_WTPB
#define NR_PCM

struct pcm_vol {};

/* Structs */
stream_t;

vortex_t;
struct snd_vortex {};

/* Functions. */

/* SRC */
static void vortex_adb_setsrc(vortex_t * vortex, int adbdma,
			      unsigned int cvrt, int dir);

/* DMA Engines. */
static void vortex_adbdma_setbuffers(vortex_t * vortex, int adbdma,
				     int size, int count);
static void vortex_adbdma_setmode(vortex_t * vortex, int adbdma, int ie,
				  int dir, int fmt, int d,
				  u32 offset);
static void vortex_adbdma_setstartbuffer(vortex_t * vortex, int adbdma, int sb);
#ifndef CHIP_AU8810
static void vortex_wtdma_setbuffers(vortex_t * vortex, int wtdma,
				    int size, int count);
static void vortex_wtdma_setmode(vortex_t * vortex, int wtdma, int ie, int fmt, int d,	/*int e, */
				 u32 offset);
static void vortex_wtdma_setstartbuffer(vortex_t * vortex, int wtdma, int sb);
#endif

static void vortex_adbdma_startfifo(vortex_t * vortex, int adbdma);
//static void vortex_adbdma_stopfifo(vortex_t *vortex, int adbdma);
static void vortex_adbdma_pausefifo(vortex_t * vortex, int adbdma);
static void vortex_adbdma_resumefifo(vortex_t * vortex, int adbdma);
static inline int vortex_adbdma_getlinearpos(vortex_t * vortex, int adbdma);
static void vortex_adbdma_resetup(vortex_t *vortex, int adbdma);

#ifndef CHIP_AU8810
static void vortex_wtdma_startfifo(vortex_t * vortex, int wtdma);
static void vortex_wtdma_stopfifo(vortex_t * vortex, int wtdma);
static void vortex_wtdma_pausefifo(vortex_t * vortex, int wtdma);
static void vortex_wtdma_resumefifo(vortex_t * vortex, int wtdma);
static inline int vortex_wtdma_getlinearpos(vortex_t * vortex, int wtdma);
#endif

/* global stuff. */
static void vortex_codec_init(vortex_t * vortex);
static void vortex_codec_write(struct snd_ac97 * codec, unsigned short addr,
			       unsigned short data);
static unsigned short vortex_codec_read(struct snd_ac97 * codec, unsigned short addr);
static void vortex_spdif_init(vortex_t * vortex, int spdif_sr, int spdif_mode);

static int vortex_core_init(vortex_t * card);
static int vortex_core_shutdown(vortex_t * card);
static void vortex_enable_int(vortex_t * card);
static irqreturn_t vortex_interrupt(int irq, void *dev_id);
static int vortex_alsafmt_aspfmt(snd_pcm_format_t alsafmt, vortex_t *v);

/* Connection  stuff. */
static void vortex_connect_default(vortex_t * vortex, int en);
static int vortex_adb_allocroute(vortex_t * vortex, int dma, int nr_ch,
				 int dir, int type, int subdev);
static int vortex_adb_checkinout(vortex_t * vortex, int resmap[], int out,
				 int restype);
#ifndef CHIP_AU8810
static int vortex_wt_allocroute(vortex_t * vortex, int dma, int nr_ch);
static void vortex_wt_connect(vortex_t * vortex, int en);
static void vortex_wt_init(vortex_t * vortex);
#endif

static void vortex_route(vortex_t * vortex, int en, unsigned char channel,
			 unsigned char source, unsigned char dest);
#if 0
static void vortex_routes(vortex_t * vortex, int en, unsigned char channel,
			  unsigned char source, unsigned char dest0,
			  unsigned char dest1);
#endif
static void vortex_connection_mixin_mix(vortex_t * vortex, int en,
					unsigned char mixin,
					unsigned char mix, int a);
static void vortex_mix_setinputvolumebyte(vortex_t * vortex,
					  unsigned char mix, int mixin,
					  unsigned char vol);
static void vortex_mix_setvolumebyte(vortex_t * vortex, unsigned char mix,
				     unsigned char vol);

/* A3D functions. */
#ifndef CHIP_AU8820
static void vortex_Vort3D_enable(vortex_t * v);
static void vortex_Vort3D_disable(vortex_t * v);
static void vortex_Vort3D_connect(vortex_t * vortex, int en);
static void vortex_Vort3D_InitializeSource(a3dsrc_t *a, int en, vortex_t *v);
#endif

/* Driver stuff. */
static int vortex_gameport_register(vortex_t * card);
static void vortex_gameport_unregister(vortex_t * card);
#ifndef CHIP_AU8820
static int vortex_eq_init(vortex_t * vortex);
static int vortex_eq_free(vortex_t * vortex);
#endif
/* ALSA stuff. */
static int snd_vortex_new_pcm(vortex_t * vortex, int idx, int nr);
static int snd_vortex_mixer(vortex_t * vortex);
static int snd_vortex_midi(vortex_t * vortex);
#endif