linux/sound/pci/lola/lola.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 *  Support for Digigram Lola PCI-e boards
 *
 *  Copyright (c) 2011 Takashi Iwai <[email protected]>
 */

#ifndef _LOLA_H
#define _LOLA_H

#define DRVNAME
#define SFX

/*
 * Lola HD Audio Registers BAR0
 */
#define LOLA_BAR0_GCAP
#define LOLA_BAR0_VMIN
#define LOLA_BAR0_VMAJ
#define LOLA_BAR0_OUTPAY
#define LOLA_BAR0_INPAY
#define LOLA_BAR0_GCTL
#define LOLA_BAR0_WAKEEN
#define LOLA_BAR0_STATESTS
#define LOLA_BAR0_GSTS
#define LOLA_BAR0_OUTSTRMPAY
#define LOLA_BAR0_INSTRMPAY
#define LOLA_BAR0_INTCTL
#define LOLA_BAR0_INTSTS
#define LOLA_BAR0_WALCLK
#define LOLA_BAR0_SSYNC

#define LOLA_BAR0_CORBLBASE
#define LOLA_BAR0_CORBUBASE
#define LOLA_BAR0_CORBWP
#define LOLA_BAR0_CORBRP
#define LOLA_BAR0_CORBCTL
#define LOLA_BAR0_CORBSTS
#define LOLA_BAR0_CORBSIZE

#define LOLA_BAR0_RIRBLBASE
#define LOLA_BAR0_RIRBUBASE
#define LOLA_BAR0_RIRBWP
#define LOLA_BAR0_RINTCNT
#define LOLA_BAR0_RIRBCTL
#define LOLA_BAR0_RIRBSTS
#define LOLA_BAR0_RIRBSIZE

#define LOLA_BAR0_ICW
#define LOLA_BAR0_IRR
#define LOLA_BAR0_ICS
#define LOLA_BAR0_DPLBASE
#define LOLA_BAR0_DPUBASE

/* stream register offsets from stream base 0x80 */
#define LOLA_BAR0_SD0_OFFSET
#define LOLA_REG0_SD_CTL
#define LOLA_REG0_SD_STS
#define LOLA_REG0_SD_LPIB
#define LOLA_REG0_SD_CBL
#define LOLA_REG0_SD_LVI
#define LOLA_REG0_SD_FIFOW
#define LOLA_REG0_SD_FIFOSIZE
#define LOLA_REG0_SD_FORMAT
#define LOLA_REG0_SD_BDLPL
#define LOLA_REG0_SD_BDLPU

/*
 * Lola Digigram Registers BAR1
 */
#define LOLA_BAR1_FPGAVER
#define LOLA_BAR1_DEVER
#define LOLA_BAR1_UCBMV
#define LOLA_BAR1_JTAG
#define LOLA_BAR1_UARTRX
#define LOLA_BAR1_UARTTX
#define LOLA_BAR1_UARTCR
#define LOLA_BAR1_NVRAMVER
#define LOLA_BAR1_CTRLSPI
#define LOLA_BAR1_DSPI
#define LOLA_BAR1_AISPI
#define LOLA_BAR1_GRAN

#define LOLA_BAR1_DINTCTL
#define LOLA_BAR1_DIINTCTL
#define LOLA_BAR1_DOINTCTL
#define LOLA_BAR1_LRC
#define LOLA_BAR1_DINTSTS
#define LOLA_BAR1_DIINTSTS
#define LOLA_BAR1_DOINTSTS

#define LOLA_BAR1_DSD0_OFFSET
#define LOLA_BAR1_DSD_SIZE

#define LOLA_BAR1_DSDnSTS
#define LOLA_BAR1_DSDnLPIB
#define LOLA_BAR1_DSDnCTL
#define LOLA_BAR1_DSDnLVI
#define LOLA_BAR1_DSDnBDPL
#define LOLA_BAR1_DSDnBDPU

#define LOLA_BAR1_SSYNC

#define LOLA_BAR1_BOARD_CTRL
#define LOLA_BAR1_BOARD_MODE

#define LOLA_BAR1_SOURCE_GAIN_ENABLE
#define LOLA_BAR1_DEST00_MIX_GAIN_ENABLE
#define LOLA_BAR1_DEST31_MIX_GAIN_ENABLE
#define LOLA_BAR1_SOURCE00_01_GAIN
#define LOLA_BAR1_SOURCE30_31_GAIN
#define LOLA_BAR1_SOURCE_GAIN(src)
#define LOLA_BAR1_DEST00_MIX00_01_GAIN
#define LOLA_BAR1_DEST00_MIX30_31_GAIN
#define LOLA_BAR1_DEST01_MIX00_01_GAIN
#define LOLA_BAR1_DEST01_MIX30_31_GAIN
#define LOLA_BAR1_DEST31_MIX00_01_GAIN
#define LOLA_BAR1_DEST31_MIX30_31_GAIN
#define LOLA_BAR1_MIX_GAIN(dest, mix)
#define LOLA_BAR1_ANALOG_CLIP_IN
#define LOLA_BAR1_PEAKMETERS_SOURCE00_01
#define LOLA_BAR1_PEAKMETERS_SOURCE30_31
#define LOLA_BAR1_PEAKMETERS_SOURCE(src)
#define LOLA_BAR1_PEAKMETERS_DEST00_01
#define LOLA_BAR1_PEAKMETERS_DEST30_31
#define LOLA_BAR1_PEAKMETERS_DEST(dest)
#define LOLA_BAR1_PEAKMETERS_AGC00_01
#define LOLA_BAR1_PEAKMETERS_AGC14_15
#define LOLA_BAR1_PEAKMETERS_AGC(x)

/* GCTL reset bit */
#define LOLA_GCTL_RESET
/* GCTL unsolicited response enable bit */
#define LOLA_GCTL_UREN

/* CORB/RIRB control, read/write pointer */
#define LOLA_RBCTL_DMA_EN
#define LOLA_RBCTL_IRQ_EN
#define LOLA_RBRWP_CLR

#define LOLA_RIRB_EX_UNSOL_EV
#define LOLA_RIRB_EX_ERROR

/* CORB int mask: CMEI[0] */
#define LOLA_CORB_INT_CMEI
#define LOLA_CORB_INT_MASK

/* RIRB int mask: overrun[2], response[0] */
#define LOLA_RIRB_INT_RESPONSE
#define LOLA_RIRB_INT_OVERRUN
#define LOLA_RIRB_INT_MASK

/* DINTCTL and DINTSTS */
#define LOLA_DINT_GLOBAL
#define LOLA_DINT_CTRL
#define LOLA_DINT_FIFOERR
#define LOLA_DINT_MUERR

/* DSDnCTL bits */
#define LOLA_DSD_CTL_SRST
#define LOLA_DSD_CTL_SRUN
#define LOLA_DSD_CTL_IOCE
#define LOLA_DSD_CTL_DEIE
#define LOLA_DSD_CTL_VLRCV
#define LOLA_LRC_MASK

/* DSDnSTS */
#define LOLA_DSD_STS_BCIS
#define LOLA_DSD_STS_DESE
#define LOLA_DSD_STS_FIFORDY

#define LOLA_CORB_ENTRIES

#define MAX_STREAM_IN_COUNT
#define MAX_STREAM_OUT_COUNT
#define MAX_STREAM_COUNT
#define MAX_PINS
#define MAX_STREAM_BUFFER_COUNT
#define MAX_AUDIO_INOUT_COUNT

#define LOLA_CLOCK_TYPE_INTERNAL
#define LOLA_CLOCK_TYPE_AES
#define LOLA_CLOCK_TYPE_AES_SYNC
#define LOLA_CLOCK_TYPE_WORDCLOCK
#define LOLA_CLOCK_TYPE_ETHERSOUND
#define LOLA_CLOCK_TYPE_VIDEO

#define LOLA_CLOCK_FORMAT_NONE
#define LOLA_CLOCK_FORMAT_NTSC
#define LOLA_CLOCK_FORMAT_PAL

#define MAX_SAMPLE_CLOCK_COUNT

/* parameters used with mixer widget's mixer capabilities */
#define LOLA_PEAK_METER_CAN_AGC_MASK
#define LOLA_PEAK_METER_CAN_ANALOG_CLIP_MASK

struct lola_bar {};

/* CORB/RIRB */
struct lola_rb {};

/* Pin widget setup */
struct lola_pin {};

struct lola_pin_array {};

/* Clock widget setup */
struct lola_sample_clock {};

struct lola_clock_widget {};

#define LOLA_MIXER_DIM
struct lola_mixer_array {};

/* Mixer widget setup */
struct lola_mixer_widget {};

/* Audio stream */
struct lola_stream {};

#define PLAY
#define CAPT

struct lola_pcm {};

/* card instance */
struct lola {};

#define BAR0
#define BAR1

/* Helper macros */
#define lola_readl(chip, idx, name)
#define lola_readw(chip, idx, name)
#define lola_readb(chip, idx, name)
#define lola_writel(chip, idx, name, val)
#define lola_writew(chip, idx, name, val)
#define lola_writeb(chip, idx, name, val)

#define lola_dsd_read(chip, dsd, name)
#define lola_dsd_write(chip, dsd, name, val)

/* GET verbs HDAudio */
#define LOLA_VERB_GET_STREAM_FORMAT
#define LOLA_VERB_GET_AMP_GAIN_MUTE
#define LOLA_VERB_PARAMETERS
#define LOLA_VERB_GET_POWER_STATE
#define LOLA_VERB_GET_CONV
#define LOLA_VERB_GET_UNSOLICITED_RESPONSE
#define LOLA_VERB_GET_DIGI_CONVERT_1
#define LOLA_VERB_GET_CONFIG_DEFAULT
#define LOLA_VERB_GET_SUBSYSTEM_ID
/* GET verbs Digigram */
#define LOLA_VERB_GET_FIXED_GAIN
#define LOLA_VERB_GET_GAIN_SELECT
#define LOLA_VERB_GET_MAX_LEVEL
#define LOLA_VERB_GET_CLOCK_LIST
#define LOLA_VERB_GET_CLOCK_SELECT
#define LOLA_VERB_GET_CLOCK_STATUS

/* SET verbs HDAudio */
#define LOLA_VERB_SET_STREAM_FORMAT
#define LOLA_VERB_SET_AMP_GAIN_MUTE
#define LOLA_VERB_SET_POWER_STATE
#define LOLA_VERB_SET_CHANNEL_STREAMID
#define LOLA_VERB_SET_UNSOLICITED_ENABLE
#define LOLA_VERB_SET_DIGI_CONVERT_1
/* SET verbs Digigram */
#define LOLA_VERB_SET_GAIN_SELECT
#define LOLA_VERB_SET_CLOCK_SELECT
#define LOLA_VERB_SET_GRANULARITY_STEPS
#define LOLA_VERB_SET_SOURCE_GAIN
#define LOLA_VERB_SET_MIX_GAIN
#define LOLA_VERB_SET_DESTINATION_GAIN
#define LOLA_VERB_SET_SRC

/* Parameter IDs used with LOLA_VERB_PARAMETERS */
#define LOLA_PAR_VENDOR_ID
#define LOLA_PAR_FUNCTION_TYPE
#define LOLA_PAR_AUDIO_WIDGET_CAP
#define LOLA_PAR_PCM
#define LOLA_PAR_STREAM_FORMATS
#define LOLA_PAR_PIN_CAP
#define LOLA_PAR_AMP_IN_CAP
#define LOLA_PAR_CONNLIST_LEN
#define LOLA_PAR_POWER_STATE
#define LOLA_PAR_GPIO_CAP
#define LOLA_PAR_AMP_OUT_CAP
#define LOLA_PAR_SPECIFIC_CAPS
#define LOLA_PAR_FIXED_GAIN_LIST

/* extract results of LOLA_PAR_SPECIFIC_CAPS */
#define LOLA_AFG_MIXER_WIDGET_PRESENT(res)
#define LOLA_AFG_CLOCK_WIDGET_PRESENT(res)
#define LOLA_AFG_INPUT_PIN_COUNT(res)
#define LOLA_AFG_OUTPUT_PIN_COUNT(res)

/* extract results of LOLA_PAR_AMP_IN_CAP / LOLA_PAR_AMP_OUT_CAP */
#define LOLA_AMP_MUTE_CAPABLE(res)
#define LOLA_AMP_STEP_SIZE(res)
#define LOLA_AMP_NUM_STEPS(res)
#define LOLA_AMP_OFFSET(res)

#define LOLA_GRANULARITY_MIN
#define LOLA_GRANULARITY_MAX
#define LOLA_GRANULARITY_STEP

/* parameters used with unsolicited command/response */
#define LOLA_UNSOLICITED_TAG_MASK
#define LOLA_UNSOLICITED_TAG
#define LOLA_UNSOLICITED_ENABLE
#define LOLA_UNSOL_RESP_TAG_OFFSET

/* count values in the Vendor Specific Mixer Widget's Audio Widget Capabilities */
#define LOLA_MIXER_SRC_INPUT_PLAY_SEPARATION(res)
#define LOLA_MIXER_DEST_REC_OUTPUT_SEPARATION(res)

int lola_codec_write(struct lola *chip, unsigned int nid, unsigned int verb,
		     unsigned int data, unsigned int extdata);
int lola_codec_read(struct lola *chip, unsigned int nid, unsigned int verb,
		    unsigned int data, unsigned int extdata,
		    unsigned int *val, unsigned int *extval);
int lola_codec_flush(struct lola *chip);
#define lola_read_param(chip, nid, param, val)

/* PCM */
int lola_create_pcm(struct lola *chip);
int lola_init_pcm(struct lola *chip, int dir, int *nidp);
void lola_pcm_update(struct lola *chip, struct lola_pcm *pcm, unsigned int bits);

/* clock */
int lola_init_clock_widget(struct lola *chip, int nid);
int lola_set_granularity(struct lola *chip, unsigned int val, bool force);
int lola_enable_clock_events(struct lola *chip);
int lola_set_clock_index(struct lola *chip, unsigned int idx);
int lola_set_clock(struct lola *chip, int idx);
int lola_set_sample_rate(struct lola *chip, int rate);
bool lola_update_ext_clock_freq(struct lola *chip, unsigned int val);
unsigned int lola_sample_rate_convert(unsigned int coded);

/* mixer */
int lola_init_pins(struct lola *chip, int dir, int *nidp);
int lola_init_mixer_widget(struct lola *chip, int nid);
void lola_free_mixer(struct lola *chip);
int lola_create_mixer(struct lola *chip);
int lola_setup_all_analog_gains(struct lola *chip, int dir, bool mute);
void lola_save_mixer(struct lola *chip);
void lola_restore_mixer(struct lola *chip);
int lola_set_src_config(struct lola *chip, unsigned int src_mask, bool update);

/* proc */
#ifdef CONFIG_SND_DEBUG
void lola_proc_debug_new(struct lola *chip);
#else
#define lola_proc_debug_new
#endif

#endif /* _LOLA_H */