linux/include/sound/ac97_codec.h

/* SPDX-License-Identifier: GPL-2.0+
 *
 *  Copyright (c) by Jaroslav Kysela <[email protected]>
 *  Universal interface for Audio Codec '97
 *
 *  For more details look to AC '97 component specification revision 2.1
 *  by Intel Corporation (http://developer.intel.com).
 */

#ifndef __SOUND_AC97_CODEC_H
#define __SOUND_AC97_CODEC_H

#include <linux/bitops.h>
#include <linux/device.h>
#include <linux/workqueue.h>
#include <sound/ac97/regs.h>
#include <sound/pcm.h>
#include <sound/control.h>
#include <sound/info.h>

/* maximum number of devices on the AC97 bus */
#define AC97_BUS_MAX_DEVICES

/* specific - SigmaTel */
#define AC97_SIGMATEL_OUTSEL
#define AC97_SIGMATEL_INSEL
#define AC97_SIGMATEL_IOMISC
#define AC97_SIGMATEL_ANALOG
#define AC97_SIGMATEL_DAC2INVERT
#define AC97_SIGMATEL_BIAS1
#define AC97_SIGMATEL_BIAS2
#define AC97_SIGMATEL_VARIOUS
#define AC97_SIGMATEL_MULTICHN
#define AC97_SIGMATEL_CIC1
#define AC97_SIGMATEL_CIC2

/* specific - Analog Devices */
#define AC97_AD_TEST
#define AC97_AD_TEST2
#define AC97_AD_HPFD_SHIFT
#define AC97_AD_CODEC_CFG
#define AC97_AD_JACK_SPDIF
#define AC97_AD_SERIAL_CFG
#define AC97_AD_MISC
#define AC97_AD_VREFD_SHIFT

/* specific - Cirrus Logic */
#define AC97_CSR_ACMODE
#define AC97_CSR_MISC_CRYSTAL
#define AC97_CSR_SPDIF
#define AC97_CSR_SERIAL
#define AC97_CSR_SPECF_ADDR
#define AC97_CSR_SPECF_DATA
#define AC97_CSR_BDI_STATUS

/* specific - Conexant */
#define AC97_CXR_AUDIO_MISC
#define AC97_CXR_SPDIFEN
#define AC97_CXR_COPYRGT
#define AC97_CXR_SPDIF_MASK
#define AC97_CXR_SPDIF_PCM
#define AC97_CXR_SPDIF_AC3

/* specific - ALC */
#define AC97_ALC650_SPDIF_INPUT_STATUS1
/* S/PDIF input status 1 bit defines */
#define AC97_ALC650_PRO
#define AC97_ALC650_NAUDIO
#define AC97_ALC650_COPY
#define AC97_ALC650_PRE
#define AC97_ALC650_PRE_SHIFT
#define AC97_ALC650_MODE
#define AC97_ALC650_MODE_SHIFT
#define AC97_ALC650_CC_MASK
#define AC97_ALC650_CC_SHIFT
#define AC97_ALC650_L

#define AC97_ALC650_SPDIF_INPUT_STATUS2
/* S/PDIF input status 2 bit defines */
#define AC97_ALC650_SOUCE_MASK
#define AC97_ALC650_CHANNEL_MASK
#define AC97_ALC650_CHANNEL_SHIFT 
#define AC97_ALC650_SPSR_MASK
#define AC97_ALC650_SPSR_SHIFT
#define AC97_ALC650_SPSR_44K
#define AC97_ALC650_SPSR_48K
#define AC97_ALC650_SPSR_32K
#define AC97_ALC650_CLOCK_ACCURACY
#define AC97_ALC650_CLOCK_SHIFT
#define AC97_ALC650_CLOCK_LOCK
#define AC97_ALC650_V

#define AC97_ALC650_SURR_DAC_VOL
#define AC97_ALC650_LFE_DAC_VOL
#define AC97_ALC650_UNKNOWN1
#define AC97_ALC650_MULTICH
#define AC97_ALC650_UNKNOWN2
#define AC97_ALC650_REVISION
#define AC97_ALC650_UNKNOWN3
#define AC97_ALC650_UNKNOWN4
#define AC97_ALC650_MISC
#define AC97_ALC650_GPIO_SETUP
#define AC97_ALC650_GPIO_STATUS
#define AC97_ALC650_CLOCK

/* specific - Yamaha YMF7x3 */
#define AC97_YMF7X3_DIT_CTRL
#define AC97_YMF7X3_3D_MODE_SEL

/* specific - C-Media */
#define AC97_CM9738_VENDOR_CTRL
#define AC97_CM9739_MULTI_CHAN
#define AC97_CM9739_SPDIF_IN_STATUS
#define AC97_CM9739_SPDIF_CTRL

/* specific - wolfson */
#define AC97_WM97XX_FMIXER_VOL
#define AC97_WM9704_RMIXER_VOL
#define AC97_WM9704_TEST
#define AC97_WM9704_RPCM_VOL
#define AC97_WM9711_OUT3VOL


/* ac97->scaps */
#define AC97_SCAP_AUDIO
#define AC97_SCAP_MODEM
#define AC97_SCAP_SURROUND_DAC
#define AC97_SCAP_CENTER_LFE_DAC
#define AC97_SCAP_SKIP_AUDIO
#define AC97_SCAP_SKIP_MODEM
#define AC97_SCAP_INDEP_SDIN
#define AC97_SCAP_INV_EAPD
#define AC97_SCAP_DETECT_BY_VENDOR
#define AC97_SCAP_NO_SPDIF
#define AC97_SCAP_EAPD_LED
#define AC97_SCAP_POWER_SAVE

/* ac97->flags */
#define AC97_HAS_PC_BEEP
#define AC97_AD_MULTI
#define AC97_CS_SPDIF
#define AC97_CX_SPDIF
#define AC97_STEREO_MUTES
#define AC97_DOUBLE_RATE
#define AC97_HAS_NO_MASTER_VOL
#define AC97_HAS_NO_PCM_VOL
#define AC97_DEFAULT_POWER_OFF
#define AC97_MODEM_PATCH
#define AC97_HAS_NO_REC_GAIN
#define AC97_HAS_NO_PHONE
#define AC97_HAS_NO_PC_BEEP
#define AC97_HAS_NO_VIDEO
#define AC97_HAS_NO_CD
#define AC97_HAS_NO_MIC
#define AC97_HAS_NO_TONE
#define AC97_HAS_NO_STD_PCM
#define AC97_HAS_NO_AUX
#define AC97_HAS_8CH

/* rates indexes */
#define AC97_RATES_FRONT_DAC
#define AC97_RATES_SURR_DAC
#define AC97_RATES_LFE_DAC
#define AC97_RATES_ADC
#define AC97_RATES_MIC_ADC
#define AC97_RATES_SPDIF

#define AC97_NUM_GPIOS
/*
 *
 */

struct snd_ac97;
struct snd_ac97_gpio_priv;
struct snd_pcm_chmap;

struct snd_ac97_build_ops {};

struct snd_ac97_bus_ops {};

struct snd_ac97_bus {};

/* static resolution table */
struct snd_ac97_res_table {};

struct snd_ac97_template {};

struct snd_ac97 {};

#define to_ac97_t(d)

/* conditions */
static inline int ac97_is_audio(struct snd_ac97 * ac97)
{}
static inline int ac97_is_modem(struct snd_ac97 * ac97)
{}
static inline int ac97_is_rev22(struct snd_ac97 * ac97)
{}
static inline int ac97_can_amap(struct snd_ac97 * ac97)
{}
static inline int ac97_can_spdif(struct snd_ac97 * ac97)
{}

/* functions */
/* create new AC97 bus */
int snd_ac97_bus(struct snd_card *card, int num,
		 const struct snd_ac97_bus_ops *ops,
		 void *private_data, struct snd_ac97_bus **rbus);
/* create mixer controls */
int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
		   struct snd_ac97 **rac97);
const char *snd_ac97_get_short_name(struct snd_ac97 *ac97);

void snd_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short value);
unsigned short snd_ac97_read(struct snd_ac97 *ac97, unsigned short reg);
void snd_ac97_write_cache(struct snd_ac97 *ac97, unsigned short reg, unsigned short value);
int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short value);
int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value);
#ifdef CONFIG_SND_AC97_POWER_SAVE
int snd_ac97_update_power(struct snd_ac97 *ac97, int reg, int powerup);
#else
static inline int snd_ac97_update_power(struct snd_ac97 *ac97, int reg,
					int powerup)
{
	return 0;
}
#endif
#ifdef CONFIG_PM
void snd_ac97_suspend(struct snd_ac97 *ac97);
void snd_ac97_resume(struct snd_ac97 *ac97);
#else
static inline void snd_ac97_suspend(struct snd_ac97 *ac97) {}
static inline void snd_ac97_resume(struct snd_ac97 *ac97) {}
#endif
int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id,
	unsigned int id_mask);

/* quirk types */
enum {};

struct ac97_quirk {};

int snd_ac97_tune_hardware(struct snd_ac97 *ac97,
			   const struct ac97_quirk *quirk,
			   const char *override);
int snd_ac97_set_rate(struct snd_ac97 *ac97, int reg, unsigned int rate);

/*
 * PCM allocation
 */

enum ac97_pcm_cfg {};

struct ac97_pcm {};

int snd_ac97_pcm_assign(struct snd_ac97_bus *ac97,
			unsigned short pcms_count,
			const struct ac97_pcm *pcms);
int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
		      enum ac97_pcm_cfg cfg, unsigned short slots);
int snd_ac97_pcm_close(struct ac97_pcm *pcm);
int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);

/* ad hoc AC97 device driver access */
extern const struct bus_type ac97_bus_type;

/* AC97 platform_data adding function */
static inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
{}

#endif /* __SOUND_AC97_CODEC_H */