#include <linux/io.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/gameport.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/input.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/mpu401.h>
#include <sound/ac97_codec.h>
#include <sound/initval.h>
#ifdef CONFIG_SND_ES1968_RADIO
#include <media/drv-intf/tea575x.h>
#endif
#define CARD_NAME …
#define DRIVER_NAME …
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
#if IS_REACHABLE(CONFIG_GAMEPORT)
#define SUPPORT_JOYSTICK …
#endif
static int index[SNDRV_CARDS] = …;
static char *id[SNDRV_CARDS] = …;
static bool enable[SNDRV_CARDS] = …;
static int total_bufsize[SNDRV_CARDS] = …;
static int pcm_substreams_p[SNDRV_CARDS] = …;
static int pcm_substreams_c[SNDRV_CARDS] = …;
static int clock[SNDRV_CARDS];
static int use_pm[SNDRV_CARDS] = …;
static int enable_mpu[SNDRV_CARDS] = …;
#ifdef SUPPORT_JOYSTICK
static bool joystick[SNDRV_CARDS];
#endif
static int radio_nr[SNDRV_CARDS] = …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
module_param_array(…);
MODULE_PARM_DESC(…) …;
#ifdef SUPPORT_JOYSTICK
module_param_array(…);
MODULE_PARM_DESC(…) …;
#endif
module_param_array(…);
MODULE_PARM_DESC(…) …;
#define NR_APUS …
#define NR_APU_REGS …
#define NEC_VERSA_SUBID1 …
#define NEC_VERSA_SUBID2 …
#define ESS_FMT_STEREO …
#define ESS_FMT_16BIT …
#define DAC_RUNNING …
#define ADC_RUNNING …
#define ESS_DISABLE_AUDIO …
#define ESS_ENABLE_SERIAL_IRQ …
#define IO_ADRESS_ALIAS …
#define MPU401_IRQ_ENABLE …
#define MPU401_IO_ENABLE …
#define GAME_IO_ENABLE …
#define FM_IO_ENABLE …
#define SB_IO_ENABLE …
#define PIC_SNOOP1 …
#define PIC_SNOOP2 …
#define SAFEGUARD …
#define DMA_CLEAR …
#define DMA_DDMA …
#define DMA_TDMA …
#define DMA_PCPCI …
#define POST_WRITE …
#define PCI_TIMING …
#define SWAP_LR …
#define SUBTR_DECODE …
#define SPDIF_CONFB …
#define HWV_CONFB …
#define DEBOUNCE …
#define GPIO_CONFB …
#define CHI_CONFB …
#define IDMA_CONFB …
#define MIDI_FIX …
#define IRQ_TO_ISA …
#define RINGB_2CODEC_ID_MASK …
#define RINGB_DIS_VALIDATION …
#define RINGB_EN_SPDIF …
#define RINGB_EN_2CODEC …
#define RINGB_SING_BIT_DUAL …
#define ESM_INDEX …
#define ESM_DATA …
#define ESM_AC97_INDEX …
#define ESM_AC97_DATA …
#define ESM_RING_BUS_DEST …
#define ESM_RING_BUS_CONTR_A …
#define ESM_RING_BUS_CONTR_B …
#define ESM_RING_BUS_SDO …
#define WC_INDEX …
#define WC_DATA …
#define WC_CONTROL …
#define ASSP_INDEX …
#define ASSP_MEMORY …
#define ASSP_DATA …
#define ASSP_CONTROL_A …
#define ASSP_CONTROL_B …
#define ASSP_CONTROL_C …
#define ASSP_HOSTW_INDEX …
#define ASSP_HOSTW_DATA …
#define ASSP_HOSTW_IRQ …
#define ESM_MPU401_PORT …
#define ESM_PORT_HOST_IRQ …
#define IDR0_DATA_PORT …
#define IDR1_CRAM_POINTER …
#define IDR2_CRAM_DATA …
#define IDR3_WAVE_DATA …
#define IDR4_WAVE_PTR_LOW …
#define IDR5_WAVE_PTR_HI …
#define IDR6_TIMER_CTRL …
#define IDR7_WAVE_ROMRAM …
#define WRITEABLE_MAP …
#define READABLE_MAP …
#define ESM_LEGACY_AUDIO_CONTROL …
#define ESM_ACPI_COMMAND …
#define ESM_CONFIG_A …
#define ESM_CONFIG_B …
#define ESM_DDMA …
#define ESM_BOB_ENABLE …
#define ESM_BOB_START …
#define ESM_RESET_MAESTRO …
#define ESM_RESET_DIRECTSOUND …
#define ESM_HIRQ_ClkRun …
#define ESM_HIRQ_HW_VOLUME …
#define ESM_HIRQ_HARPO …
#define ESM_HIRQ_ASSP …
#define ESM_HIRQ_DSIE …
#define ESM_HIRQ_MPU401 …
#define ESM_HIRQ_SB …
#define ESM_MPU401_IRQ …
#define ESM_SB_IRQ …
#define ESM_SOUND_IRQ …
#define ESM_ASSP_IRQ …
#define ESM_HWVOL_IRQ …
#define ESS_SYSCLK …
#define ESM_BOB_FREQ …
#define ESM_BOB_FREQ_MAX …
#define ESM_FREQ_ESM1 …
#define ESM_FREQ_ESM2 …
#define ESM_APU_MODE_SHIFT …
#define ESM_APU_MODE_MASK …
#define ESM_APU_OFF …
#define ESM_APU_16BITLINEAR …
#define ESM_APU_16BITSTEREO …
#define ESM_APU_8BITLINEAR …
#define ESM_APU_8BITSTEREO …
#define ESM_APU_8BITDIFF …
#define ESM_APU_DIGITALDELAY …
#define ESM_APU_DUALTAP …
#define ESM_APU_CORRELATOR …
#define ESM_APU_INPUTMIXER …
#define ESM_APU_WAVETABLE …
#define ESM_APU_SRCONVERTOR …
#define ESM_APU_16BITPINGPONG …
#define ESM_APU_RESERVED1 …
#define ESM_APU_RESERVED2 …
#define ESM_APU_RESERVED3 …
#define ESM_APU_FILTER_Q_SHIFT …
#define ESM_APU_FILTER_Q_MASK …
#define ESM_APU_FILTER_LESSQ …
#define ESM_APU_FILTER_MOREQ …
#define ESM_APU_FILTER_TYPE_SHIFT …
#define ESM_APU_FILTER_TYPE_MASK …
#define ESM_APU_ENV_TYPE_SHIFT …
#define ESM_APU_ENV_TYPE_MASK …
#define ESM_APU_ENV_STATE_SHIFT …
#define ESM_APU_ENV_STATE_MASK …
#define ESM_APU_END_CURVE …
#define ESM_APU_INT_ON_LOOP …
#define ESM_APU_DMA_ENABLE …
#define ESM_APU_SUBMIX_GROUP_SHIRT …
#define ESM_APU_SUBMIX_GROUP_MASK …
#define ESM_APU_SUBMIX_MODE …
#define ESM_APU_6dB …
#define ESM_APU_DUAL_EFFECT …
#define ESM_APU_EFFECT_CHANNELS_SHIFT …
#define ESM_APU_EFFECT_CHANNELS_MASK …
#define ESM_APU_STEP_SIZE_MASK …
#define ESM_APU_PHASE_SHIFT …
#define ESM_APU_PHASE_MASK …
#define ESM_APU_WAVE64K_PAGE_SHIFT …
#define ESM_APU_WAVE64K_PAGE_MASK …
#define ESM_APU_EFFECT_GAIN_SHIFT …
#define ESM_APU_EFFECT_GAIN_MASK …
#define ESM_APU_TREMOLO_DEPTH_SHIFT …
#define ESM_APU_TREMOLO_DEPTH_MASK …
#define ESM_APU_TREMOLO_RATE_SHIFT …
#define ESM_APU_TREMOLO_RATE_MASK …
#define ESM_APU_AMPLITUDE_NOW_SHIFT …
#define ESM_APU_AMPLITUDE_NOW_MASK …
#define ESM_APU_POLAR_PAN_SHIFT …
#define ESM_APU_POLAR_PAN_MASK …
#define ESM_APU_PAN_CENTER_CIRCLE …
#define ESM_APU_PAN_MIDDLE_RADIUS …
#define ESM_APU_PAN_OUTSIDE_RADIUS …
#define ESM_APU_FILTER_TUNING_SHIFT …
#define ESM_APU_FILTER_TUNING_MASK …
#define ESM_APU_DATA_SRC_A_SHIFT …
#define ESM_APU_DATA_SRC_A_MASK …
#define ESM_APU_INV_POL_A …
#define ESM_APU_DATA_SRC_B_SHIFT …
#define ESM_APU_DATA_SRC_B_MASK …
#define ESM_APU_INV_POL_B …
#define ESM_APU_VIBRATO_RATE_SHIFT …
#define ESM_APU_VIBRATO_RATE_MASK …
#define ESM_APU_VIBRATO_DEPTH_SHIFT …
#define ESM_APU_VIBRATO_DEPTH_MASK …
#define ESM_APU_VIBRATO_PHASE_SHIFT …
#define ESM_APU_VIBRATO_PHASE_MASK …
#define ESM_APU_RADIUS_SELECT …
#define ESM_APU_FILTER_2POLE_LOPASS …
#define ESM_APU_FILTER_2POLE_BANDPASS …
#define ESM_APU_FILTER_2POLE_HIPASS …
#define ESM_APU_FILTER_1POLE_LOPASS …
#define ESM_APU_FILTER_1POLE_HIPASS …
#define ESM_APU_FILTER_OFF …
#define ESM_APU_ATFP_AMPLITUDE …
#define ESM_APU_ATFP_TREMELO …
#define ESM_APU_ATFP_FILTER …
#define ESM_APU_ATFP_PAN …
#define ESM_APU_ATFP_FLG_OFF …
#define ESM_APU_ATFP_FLG_WAIT …
#define ESM_APU_ATFP_FLG_DONE …
#define ESM_APU_ATFP_FLG_INPROCESS …
#define ESM_MEM_ALIGN …
#define ESM_MIXBUF_SIZE …
#define ESM_MODE_PLAY …
#define ESM_MODE_CAPTURE …
enum snd_enum_apu_type { … };
enum { … };
struct esm_memory { … };
struct esschan { … };
struct es1968 { … };
static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id);
static const struct pci_device_id snd_es1968_ids[] = …;
MODULE_DEVICE_TABLE(pci, snd_es1968_ids);
static void __maestro_write(struct es1968 *chip, u16 reg, u16 data)
{ … }
static inline void maestro_write(struct es1968 *chip, u16 reg, u16 data)
{ … }
static u16 __maestro_read(struct es1968 *chip, u16 reg)
{ … }
static inline u16 maestro_read(struct es1968 *chip, u16 reg)
{ … }
static int snd_es1968_ac97_wait(struct es1968 *chip)
{ … }
static int snd_es1968_ac97_wait_poll(struct es1968 *chip)
{ … }
static void snd_es1968_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val)
{ … }
static unsigned short snd_es1968_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
{ … }
static void apu_index_set(struct es1968 *chip, u16 index)
{ … }
static void apu_data_set(struct es1968 *chip, u16 data)
{ … }
static void __apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data)
{ … }
static void apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data)
{ … }
static u16 __apu_get_register(struct es1968 *chip, u16 channel, u8 reg)
{ … }
static u16 apu_get_register(struct es1968 *chip, u16 channel, u8 reg)
{ … }
#if 0
static void assp_set_register(struct es1968 *chip, u32 reg, u32 value)
{
unsigned long flags;
spin_lock_irqsave(&chip->reg_lock, flags);
outl(reg, chip->io_port + ASSP_INDEX);
outl(value, chip->io_port + ASSP_DATA);
spin_unlock_irqrestore(&chip->reg_lock, flags);
}
static u32 assp_get_register(struct es1968 *chip, u32 reg)
{
unsigned long flags;
u32 value;
spin_lock_irqsave(&chip->reg_lock, flags);
outl(reg, chip->io_port + ASSP_INDEX);
value = inl(chip->io_port + ASSP_DATA);
spin_unlock_irqrestore(&chip->reg_lock, flags);
return value;
}
#endif
static void wave_set_register(struct es1968 *chip, u16 reg, u16 value)
{ … }
static u16 wave_get_register(struct es1968 *chip, u16 reg)
{ … }
static void snd_es1968_bob_stop(struct es1968 *chip)
{ … }
static void snd_es1968_bob_start(struct es1968 *chip)
{ … }
static void snd_es1968_bob_inc(struct es1968 *chip, int freq)
{ … }
static void snd_es1968_bob_dec(struct es1968 *chip)
{ … }
static int
snd_es1968_calc_bob_rate(struct es1968 *chip, struct esschan *es,
struct snd_pcm_runtime *runtime)
{ … }
static u32 snd_es1968_compute_rate(struct es1968 *chip, u32 freq)
{ … }
static inline unsigned int
snd_es1968_get_dma_ptr(struct es1968 *chip, struct esschan *es)
{ … }
static void snd_es1968_apu_set_freq(struct es1968 *chip, int apu, int freq)
{ … }
static inline void snd_es1968_trigger_apu(struct es1968 *esm, int apu, int mode)
{ … }
static void snd_es1968_pcm_start(struct es1968 *chip, struct esschan *es)
{ … }
static void snd_es1968_pcm_stop(struct es1968 *chip, struct esschan *es)
{ … }
static void snd_es1968_program_wavecache(struct es1968 *chip, struct esschan *es,
int channel, u32 addr, int capture)
{ … }
static void snd_es1968_playback_setup(struct es1968 *chip, struct esschan *es,
struct snd_pcm_runtime *runtime)
{ … }
static void init_capture_apu(struct es1968 *chip, struct esschan *es, int channel,
unsigned int pa, unsigned int bsize,
int mode, int route)
{ … }
static void snd_es1968_capture_setup(struct es1968 *chip, struct esschan *es,
struct snd_pcm_runtime *runtime)
{ … }
static int snd_es1968_pcm_prepare(struct snd_pcm_substream *substream)
{ … }
static int snd_es1968_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{ … }
static snd_pcm_uframes_t snd_es1968_pcm_pointer(struct snd_pcm_substream *substream)
{ … }
static const struct snd_pcm_hardware snd_es1968_playback = …;
static const struct snd_pcm_hardware snd_es1968_capture = …;
static int calc_available_memory_size(struct es1968 *chip)
{ … }
static struct esm_memory *snd_es1968_new_memory(struct es1968 *chip, int size)
{ … }
static void snd_es1968_free_memory(struct es1968 *chip, struct esm_memory *buf)
{ … }
static void snd_es1968_free_dmabuf(struct es1968 *chip)
{ … }
static int
snd_es1968_init_dmabuf(struct es1968 *chip)
{ … }
static int snd_es1968_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params)
{ … }
static int snd_es1968_hw_free(struct snd_pcm_substream *substream)
{ … }
static int snd_es1968_alloc_apu_pair(struct es1968 *chip, int type)
{ … }
static void snd_es1968_free_apu_pair(struct es1968 *chip, int apu)
{ … }
static int snd_es1968_playback_open(struct snd_pcm_substream *substream)
{ … }
static int snd_es1968_capture_open(struct snd_pcm_substream *substream)
{ … }
static int snd_es1968_playback_close(struct snd_pcm_substream *substream)
{ … }
static int snd_es1968_capture_close(struct snd_pcm_substream *substream)
{ … }
static const struct snd_pcm_ops snd_es1968_playback_ops = …;
static const struct snd_pcm_ops snd_es1968_capture_ops = …;
#define CLOCK_MEASURE_BUFSIZE …
static void es1968_measure_clock(struct es1968 *chip)
{ … }
static void snd_es1968_pcm_free(struct snd_pcm *pcm)
{ … }
static int
snd_es1968_pcm(struct es1968 *chip, int device)
{ … }
static void snd_es1968_suppress_jitter(struct es1968 *chip, struct esschan *es)
{ … }
static void snd_es1968_update_pcm(struct es1968 *chip, struct esschan *es)
{ … }
static void es1968_update_hw_volume(struct work_struct *work)
{ … }
static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id)
{ … }
static int
snd_es1968_mixer(struct es1968 *chip)
{ … }
static void snd_es1968_ac97_reset(struct es1968 *chip)
{ … }
static void snd_es1968_reset(struct es1968 *chip)
{ … }
static void snd_es1968_chip_init(struct es1968 *chip)
{ … }
static void snd_es1968_start_irq(struct es1968 *chip)
{ … }
static int es1968_suspend(struct device *dev)
{ … }
static int es1968_resume(struct device *dev)
{ … }
static DEFINE_SIMPLE_DEV_PM_OPS(es1968_pm, es1968_suspend, es1968_resume);
#ifdef SUPPORT_JOYSTICK
#define JOYSTICK_ADDR …
static int snd_es1968_create_gameport(struct es1968 *chip, int dev)
{ … }
static void snd_es1968_free_gameport(struct es1968 *chip)
{ … }
#else
static inline int snd_es1968_create_gameport(struct es1968 *chip, int dev) { return -ENOSYS; }
static inline void snd_es1968_free_gameport(struct es1968 *chip) { }
#endif
#ifdef CONFIG_SND_ES1968_INPUT
static int snd_es1968_input_register(struct es1968 *chip)
{ … }
#endif
#ifdef CONFIG_SND_ES1968_RADIO
#define GPIO_DATA …
#define IO_MASK …
#define IO_DIR …
struct snd_es1968_tea575x_gpio { … };
static const struct snd_es1968_tea575x_gpio snd_es1968_tea575x_gpios[] = …;
#define get_tea575x_gpio(chip) …
static void snd_es1968_tea575x_set_pins(struct snd_tea575x *tea, u8 pins)
{ … }
static u8 snd_es1968_tea575x_get_pins(struct snd_tea575x *tea)
{ … }
static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool output)
{ … }
static const struct snd_tea575x_ops snd_es1968_tea_ops = …;
#endif
static void snd_es1968_free(struct snd_card *card)
{ … }
struct ess_device_list { … };
static const struct ess_device_list pm_allowlist[] = …;
static const struct ess_device_list mpu_denylist[] = …;
static int snd_es1968_create(struct snd_card *card,
struct pci_dev *pci,
int total_bufsize,
int play_streams,
int capt_streams,
int chip_type,
int do_pm,
int radio_nr)
{ … }
static int __snd_es1968_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
{ … }
static int snd_es1968_probe(struct pci_dev *pci,
const struct pci_device_id *pci_id)
{ … }
static struct pci_driver es1968_driver = …;
module_pci_driver(…) …;