linux/sound/pci/ice1712/ice1724.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *   ALSA driver for VT1724 ICEnsemble ICE1724 / VIA VT1724 (Envy24HT)
 *                   VIA VT1720 (Envy24PT)
 *
 *	Copyright (c) 2000 Jaroslav Kysela <[email protected]>
 *                    2002 James Stafford <[email protected]>
 *                    2003 Takashi Iwai <[email protected]>
 */

#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <sound/core.h>
#include <sound/info.h>
#include <sound/rawmidi.h>
#include <sound/initval.h>

#include <sound/asoundef.h>

#include "ice1712.h"
#include "envy24ht.h"

/* lowlevel routines */
#include "amp.h"
#include "revo.h"
#include "aureon.h"
#include "vt1720_mobo.h"
#include "pontis.h"
#include "prodigy192.h"
#include "prodigy_hifi.h"
#include "juli.h"
#include "maya44.h"
#include "phase.h"
#include "wtm.h"
#include "se.h"
#include "quartet.h"
#include "psc724.h"

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

static int index[SNDRV_CARDS] =;	/* Index 0-MAX */
static char *id[SNDRV_CARDS] =;	/* ID for this card */
static bool enable[SNDRV_CARDS] =;		/* Enable this card */
static char *model[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();


/* Both VT1720 and VT1724 have the same PCI IDs */
static const struct pci_device_id snd_vt1724_ids[] =;

MODULE_DEVICE_TABLE(pci, snd_vt1724_ids);


static int PRO_RATE_LOCKED;
static int PRO_RATE_RESET =;
static unsigned int PRO_RATE_DEFAULT =;

static const char * const ext_clock_names[1] =;

/*
 *  Basic I/O
 */

/*
 *  default rates, default clock routines
 */

/* check whether the clock mode is spdif-in */
static inline int stdclock_is_spdif_master(struct snd_ice1712 *ice)
{}

/*
 * locking rate makes sense only for internal clock mode
 */
static inline int is_pro_rate_locked(struct snd_ice1712 *ice)
{}

/*
 * ac97 section
 */

static unsigned char snd_vt1724_ac97_ready(struct snd_ice1712 *ice)
{}

static int snd_vt1724_ac97_wait_bit(struct snd_ice1712 *ice, unsigned char bit)
{}

static void snd_vt1724_ac97_write(struct snd_ac97 *ac97,
				  unsigned short reg,
				  unsigned short val)
{}

static unsigned short snd_vt1724_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
{}


/*
 * GPIO operations
 */

/* set gpio direction 0 = read, 1 = write */
static void snd_vt1724_set_gpio_dir(struct snd_ice1712 *ice, unsigned int data)
{}

/* get gpio direction 0 = read, 1 = write */
static unsigned int snd_vt1724_get_gpio_dir(struct snd_ice1712 *ice)
{}

/* set the gpio mask (0 = writable) */
static void snd_vt1724_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data)
{}

static unsigned int snd_vt1724_get_gpio_mask(struct snd_ice1712 *ice)
{}

static void snd_vt1724_set_gpio_data(struct snd_ice1712 *ice, unsigned int data)
{}

static unsigned int snd_vt1724_get_gpio_data(struct snd_ice1712 *ice)
{}

/*
 * MIDI
 */

static void vt1724_midi_clear_rx(struct snd_ice1712 *ice)
{}

static inline struct snd_rawmidi_substream *
get_rawmidi_substream(struct snd_ice1712 *ice, unsigned int stream)
{}

static void enable_midi_irq(struct snd_ice1712 *ice, u8 flag, int enable);

static void vt1724_midi_write(struct snd_ice1712 *ice)
{}

static void vt1724_midi_read(struct snd_ice1712 *ice)
{}

/* call with ice->reg_lock */
static void enable_midi_irq(struct snd_ice1712 *ice, u8 flag, int enable)
{}

static void vt1724_enable_midi_irq(struct snd_rawmidi_substream *substream,
				   u8 flag, int enable)
{}

static int vt1724_midi_output_open(struct snd_rawmidi_substream *s)
{}

static int vt1724_midi_output_close(struct snd_rawmidi_substream *s)
{}

static void vt1724_midi_output_trigger(struct snd_rawmidi_substream *s, int up)
{}

static void vt1724_midi_output_drain(struct snd_rawmidi_substream *s)
{}

static const struct snd_rawmidi_ops vt1724_midi_output_ops =;

static int vt1724_midi_input_open(struct snd_rawmidi_substream *s)
{}

static int vt1724_midi_input_close(struct snd_rawmidi_substream *s)
{}

static void vt1724_midi_input_trigger(struct snd_rawmidi_substream *s, int up)
{}

static const struct snd_rawmidi_ops vt1724_midi_input_ops =;


/*
 *  Interrupt handler
 */

static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
{}

/*
 *  PCM code - professional part (multitrack)
 */

static const unsigned int rates[] =;

static const struct snd_pcm_hw_constraint_list hw_constraints_rates_96 =;

static const struct snd_pcm_hw_constraint_list hw_constraints_rates_48 =;

static const struct snd_pcm_hw_constraint_list hw_constraints_rates_192 =;

struct vt1724_pcm_reg {};

static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{}

/*
 */

#define DMA_STARTS
#define DMA_PAUSES

static const unsigned int stdclock_rate_list[16] =;

static unsigned int stdclock_get_rate(struct snd_ice1712 *ice)
{}

static void stdclock_set_rate(struct snd_ice1712 *ice, unsigned int rate)
{}

static unsigned char stdclock_set_mclk(struct snd_ice1712 *ice,
				       unsigned int rate)
{}

static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
				    int force)
{}

static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
				    struct snd_pcm_hw_params *hw_params)
{}

static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream *substream)
{}

static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_pcm_prepare(struct snd_pcm_substream *substream)
{}

static snd_pcm_uframes_t snd_vt1724_pcm_pointer(struct snd_pcm_substream *substream)
{}

static const struct vt1724_pcm_reg vt1724_pdma0_reg =;

static const struct vt1724_pcm_reg vt1724_pdma4_reg =;

static const struct vt1724_pcm_reg vt1724_rdma0_reg =;

static const struct vt1724_pcm_reg vt1724_rdma1_reg =;

#define vt1724_playback_pro_reg
#define vt1724_playback_spdif_reg
#define vt1724_capture_pro_reg
#define vt1724_capture_spdif_reg

static const struct snd_pcm_hardware snd_vt1724_playback_pro =;

static const struct snd_pcm_hardware snd_vt1724_spdif =;

static const struct snd_pcm_hardware snd_vt1724_2ch_stereo =;

/*
 * set rate constraints
 */
static void set_std_hw_rates(struct snd_ice1712 *ice)
{}

static int set_rate_constraints(struct snd_ice1712 *ice,
				struct snd_pcm_substream *substream)
{}

/* if the card has the internal rate locked (is_pro_locked), limit runtime
   hw rates to the current internal rate only.
*/
static void constrain_rate_if_locked(struct snd_pcm_substream *substream)
{}


/* multi-channel playback needs alignment 8x32bit regardless of the channels
 * actually used
 */
#define VT1724_BUFFER_ALIGN

static int snd_vt1724_playback_pro_open(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_capture_pro_open(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_playback_pro_close(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_capture_pro_close(struct snd_pcm_substream *substream)
{}

static const struct snd_pcm_ops snd_vt1724_playback_pro_ops =;

static const struct snd_pcm_ops snd_vt1724_capture_pro_ops =;

static int snd_vt1724_pcm_profi(struct snd_ice1712 *ice, int device)
{}


/*
 * SPDIF PCM
 */

/* update spdif control bits; call with reg_lock */
static void update_spdif_bits(struct snd_ice1712 *ice, unsigned int val)
{}

/* update SPDIF control bits according to the given rate */
static void update_spdif_rate(struct snd_ice1712 *ice, unsigned int rate)
{}

static int snd_vt1724_playback_spdif_prepare(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_playback_spdif_open(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_playback_spdif_close(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_capture_spdif_open(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_capture_spdif_close(struct snd_pcm_substream *substream)
{}

static const struct snd_pcm_ops snd_vt1724_playback_spdif_ops =;

static const struct snd_pcm_ops snd_vt1724_capture_spdif_ops =;


static int snd_vt1724_pcm_spdif(struct snd_ice1712 *ice, int device)
{}


/*
 * independent surround PCMs
 */

static const struct vt1724_pcm_reg vt1724_playback_dma_regs[3] =;

static int snd_vt1724_playback_indep_prepare(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_playback_indep_open(struct snd_pcm_substream *substream)
{}

static int snd_vt1724_playback_indep_close(struct snd_pcm_substream *substream)
{}

static const struct snd_pcm_ops snd_vt1724_playback_indep_ops =;


static int snd_vt1724_pcm_indep(struct snd_ice1712 *ice, int device)
{}


/*
 *  Mixer section
 */

static int snd_vt1724_ac97_mixer(struct snd_ice1712 *ice)
{}

/*
 *
 */

static inline unsigned int eeprom_triple(struct snd_ice1712 *ice, int idx)
{}

static void snd_vt1724_proc_read(struct snd_info_entry *entry,
				 struct snd_info_buffer *buffer)
{}

static void snd_vt1724_proc_init(struct snd_ice1712 *ice)
{}

/*
 *
 */

static int snd_vt1724_eeprom_info(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_info *uinfo)
{}

static int snd_vt1724_eeprom_get(struct snd_kcontrol *kcontrol,
				 struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new snd_vt1724_eeprom =;

/*
 */
static int snd_vt1724_spdif_info(struct snd_kcontrol *kcontrol,
				 struct snd_ctl_elem_info *uinfo)
{}

static unsigned int encode_spdif_bits(struct snd_aes_iec958 *diga)
{}

static void decode_spdif_bits(struct snd_aes_iec958 *diga, unsigned int val)
{}

static int snd_vt1724_spdif_default_get(struct snd_kcontrol *kcontrol,
					struct snd_ctl_elem_value *ucontrol)
{}

static int snd_vt1724_spdif_default_put(struct snd_kcontrol *kcontrol,
					 struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new snd_vt1724_spdif_default =;

static int snd_vt1724_spdif_maskc_get(struct snd_kcontrol *kcontrol,
				       struct snd_ctl_elem_value *ucontrol)
{}

static int snd_vt1724_spdif_maskp_get(struct snd_kcontrol *kcontrol,
				       struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new snd_vt1724_spdif_maskc =;

static const struct snd_kcontrol_new snd_vt1724_spdif_maskp =;

#define snd_vt1724_spdif_sw_info

static int snd_vt1724_spdif_sw_get(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)
{}

static int snd_vt1724_spdif_sw_put(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new snd_vt1724_spdif_switch =;


#if 0 /* NOT USED YET */
/*
 * GPIO access from extern
 */

#define snd_vt1724_gpio_info

int snd_vt1724_gpio_get(struct snd_kcontrol *kcontrol,
			struct snd_ctl_elem_value *ucontrol)
{
	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
	int shift = kcontrol->private_value & 0xff;
	int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0;

	snd_ice1712_save_gpio_status(ice);
	ucontrol->value.integer.value[0] =
		(snd_ice1712_gpio_read(ice) & (1 << shift) ? 1 : 0) ^ invert;
	snd_ice1712_restore_gpio_status(ice);
	return 0;
}

int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol,
			 struct snd_ctl_elem_value *ucontrol)
{
	struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
	int shift = kcontrol->private_value & 0xff;
	int invert = (kcontrol->private_value & (1<<24)) ? mask : 0;
	unsigned int val, nval;

	if (kcontrol->private_value & (1 << 31))
		return -EPERM;
	nval = (ucontrol->value.integer.value[0] ? (1 << shift) : 0) ^ invert;
	snd_ice1712_save_gpio_status(ice);
	val = snd_ice1712_gpio_read(ice);
	nval |= val & ~(1 << shift);
	if (val != nval)
		snd_ice1712_gpio_write(ice, nval);
	snd_ice1712_restore_gpio_status(ice);
	return val != nval;
}
#endif /* NOT USED YET */

/*
 *  rate
 */
static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol,
					      struct snd_ctl_elem_info *uinfo)
{}

static int snd_vt1724_pro_internal_clock_get(struct snd_kcontrol *kcontrol,
					     struct snd_ctl_elem_value *ucontrol)
{}

static int stdclock_get_spdif_master_type(struct snd_ice1712 *ice)
{}

/* setting clock to external - SPDIF */
static int stdclock_set_spdif_clock(struct snd_ice1712 *ice, int type)
{}


static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
					     struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new snd_vt1724_pro_internal_clock =;

#define snd_vt1724_pro_rate_locking_info

static int snd_vt1724_pro_rate_locking_get(struct snd_kcontrol *kcontrol,
					   struct snd_ctl_elem_value *ucontrol)
{}

static int snd_vt1724_pro_rate_locking_put(struct snd_kcontrol *kcontrol,
					   struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new snd_vt1724_pro_rate_locking =;

#define snd_vt1724_pro_rate_reset_info

static int snd_vt1724_pro_rate_reset_get(struct snd_kcontrol *kcontrol,
					 struct snd_ctl_elem_value *ucontrol)
{}

static int snd_vt1724_pro_rate_reset_put(struct snd_kcontrol *kcontrol,
					 struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new snd_vt1724_pro_rate_reset =;


/*
 * routing
 */
static int snd_vt1724_pro_route_info(struct snd_kcontrol *kcontrol,
				     struct snd_ctl_elem_info *uinfo)
{}

static inline int analog_route_shift(int idx)
{}

static inline int digital_route_shift(int idx)
{}

int snd_ice1724_get_route_val(struct snd_ice1712 *ice, int shift)
{}

int snd_ice1724_put_route_val(struct snd_ice1712 *ice, unsigned int val,
								int shift)
{}

static int snd_vt1724_pro_route_analog_get(struct snd_kcontrol *kcontrol,
					   struct snd_ctl_elem_value *ucontrol)
{}

static int snd_vt1724_pro_route_analog_put(struct snd_kcontrol *kcontrol,
					   struct snd_ctl_elem_value *ucontrol)
{}

static int snd_vt1724_pro_route_spdif_get(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *ucontrol)
{}

static int snd_vt1724_pro_route_spdif_put(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route =;

static const struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route =;


static int snd_vt1724_pro_peak_info(struct snd_kcontrol *kcontrol,
				    struct snd_ctl_elem_info *uinfo)
{}

static int snd_vt1724_pro_peak_get(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)
{}

static const struct snd_kcontrol_new snd_vt1724_mixer_pro_peak =;

/*
  ooAoo cards with no controls
*/
static const unsigned char ooaoo_sq210_eeprom[] =;


static const struct snd_ice1712_card_info snd_vt1724_ooaoo_cards[] =;

static const struct snd_ice1712_card_info *card_tables[] =;


/*
 */

static void wait_i2c_busy(struct snd_ice1712 *ice)
{}

unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
				  unsigned char dev, unsigned char addr)
{}

void snd_vt1724_write_i2c(struct snd_ice1712 *ice,
			  unsigned char dev, unsigned char addr, unsigned char data)
{}

static int snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
				  const char *modelname)
{}



static void snd_vt1724_chip_reset(struct snd_ice1712 *ice)
{}

static int snd_vt1724_chip_init(struct snd_ice1712 *ice)
{}

static int snd_vt1724_spdif_build_controls(struct snd_ice1712 *ice)
{}


static int snd_vt1724_build_controls(struct snd_ice1712 *ice)
{}

static void snd_vt1724_free(struct snd_card *card)
{}

static int snd_vt1724_create(struct snd_card *card,
			     struct pci_dev *pci,
			     const char *modelname)
{}


/*
 *
 * Registration
 *
 */

static int __snd_vt1724_probe(struct pci_dev *pci,
			      const struct pci_device_id *pci_id)
{}

static int snd_vt1724_probe(struct pci_dev *pci,
			    const struct pci_device_id *pci_id)
{}

#ifdef CONFIG_PM_SLEEP
static int snd_vt1724_suspend(struct device *dev)
{}

static int snd_vt1724_resume(struct device *dev)
{}

static SIMPLE_DEV_PM_OPS(snd_vt1724_pm, snd_vt1724_suspend, snd_vt1724_resume);
#define SND_VT1724_PM_OPS
#else
#define SND_VT1724_PM_OPS
#endif /* CONFIG_PM_SLEEP */

static struct pci_driver vt1724_driver =;

module_pci_driver();