#ifndef AUDIGYLS_H
#define AUDIGYLS_H
#define AUDIGYLS_NAME "audiols"
#define AUDIGYLS_NUM_PORT 2
#define AUDIGYLS_PLAY_PORT 0
#define AUDIGYLS_REC_PORT 1
#define PCI_VENDOR_ID_CREATIVE 0x1102
#define PCI_DEVICE_ID_CREATIVE_AUDIGYLS 0x0007
#define PR 0x00
#define DR 0x04
#define IPR 0x08
#define IER 0x0C
#define INTR_PCI (1 << 0)
#define INTR_TXA (1 << 1)
#define INTR_RXA (1 << 2)
#define INTR_IT2 (1 << 3)
#define INTR_IT1 (1 << 4)
#define INTR_SS_ (1 << 5)
#define INTR_SRT (1 << 6)
#define INTR_GP (1 << 7)
#define INTR_AI (1 << 8)
#define INTR_I2CDAC (1 << 9)
#define INTR_I2CEE (1 << 10)
#define INTR_SPI (1 << 11)
#define INTR_SPF (1 << 12)
#define INTR_SUO (1 << 13)
#define INTR_SUI (1 << 14)
#define INTR_TXB (1 << 16)
#define INTR_RXB (1 << 17)
#define HC 0x14
#define HC_PF (1 << 11)
#define HC_RF (1 << 10)
#define HC_AC97 (1 << 3)
#define HC_AEN (1 << 0)
#define GPIO 0x18
#define AC97D 0x1C
#define AC97A 0x1E
#define PTBA 0x000
#define PTBS 0x001
#define PTCA 0x002
#define PFBA 0x004
#define PFBS 0x005
#define CPFA 0x006
#define PFEA 0x007
#define CPCAV 0x008
#define RFBA 0x010
#define RFBS 0x011
#define CRFA 0x012
#define CRCAV 0x013
#define CDL 0x020
#define SA 0x040
#define SCS3 0x041
#define SCS0 0x042
#define SCS1 0x043
#define SCS2 0x044
#define SPC 0x045
#define WMARK 0x046
#define SPSC 0x049
#define RCD 0x050
#define P17RECSEL 0x060
#define P17RECVOLL 0x061
#define P17RECVOLH 0x062
#define HMIXMAP_SPDIF 0x063
#define SMIXMAP_SPDIF 0x064
#define MIXCTL_SPDIF 0x065
#define MIXVOL_SPDIF 0x066
#define HMIXMAP_I2S 0x067
#define SMIXMAP_I2S 0x068
#define MIXCTL_I2S 0x069
#define MIXVOL_I2S 0x06a
#define MUDATA 0x06c
#define MUCMDA 0x06d
#define MUDATB 0x06e
#define MUCMDB 0x06f
#define SRT 0x070
#define SRCTL 0x071
#define AUDCTL 0x072
#define CHIP_ID 0x074
#define AIE 0x075
#define AIP 0x076
#define WALL192 0x077
#define WALL441 0x078
#define IT 0x079
#define SPI 0x07a
#define I2C_A 0x07b
#define I2C_0 0x07c
#define I2C_1 0x07d
#define AI_PFH 0x00000001
#define AI_PFF 0x00000010
#define AI_TFH 0x00000100
#define AI_TFF 0x00001000
#define AI_RFH 0x00010000
#define AI_RFF 0x00100000
#define AI_EAI 0x01000000
#define SA_48K 0
#define SA_44K 1
#define SA_96K 2
#define SA_192K 3
#define SA_MIX_OUT_EN(ch) (1 << ((ch) + 28))
#define SA_MIX_IN_EN(ch) (1 << ((ch) + 24))
#define SA_PLAY_RATE(ch, rate) ((rate) << (((ch) * 2) + 16))
#define SA_PLAY_START(ch) (1 << (ch))
#define SA_RECORD_START(ch) (1 << ((ch) + 8))
#define SA_SPA(ch) (1U << (ch))
#define SA_SRA(ch) (1U << ((ch) + 8))
#define RECSEL_SPDIFOUT 0
#define RECSEL_I2SOUT 1
#define RECSEL_SPDIFIN 2
#define RECSEL_I2SIN 3
#define RECSEL_AC97 4
#define RECSEL_SRC 5
typedef struct _audigyls_dev_t audigyls_dev_t;
typedef struct _audigyls_port_t audigyls_port_t;
typedef enum {
CTL_FRONT = 0,
CTL_SURROUND,
CTL_CENTER,
CTL_LFE,
CTL_RECORDVOL,
CTL_MONGAIN,
CTL_RECSRC,
CTL_SPREAD,
CTL_LOOP,
CTL_NUM
} audigyls_ctrl_num_t;
typedef struct audigyls_ctrl
{
audigyls_dev_t *dev;
audio_ctrl_t *ctrl;
audigyls_ctrl_num_t num;
uint64_t val;
} audigyls_ctrl_t;
struct _audigyls_port_t
{
audigyls_dev_t *dev;
audio_engine_t *engine;
int direction;
unsigned nchan;
ddi_dma_handle_t buf_dmah;
ddi_acc_handle_t buf_acch;
uint32_t buf_paddr;
caddr_t buf_kaddr;
uint32_t buf_size;
uint32_t buf_frames;
uint32_t offset;
int syncdir;
uint64_t count;
};
struct _audigyls_dev_t
{
dev_info_t *dip;
audio_dev_t *adev;
ac97_t *ac97;
int nactive;
char digital_enable;
ddi_acc_handle_t pcih;
ddi_acc_handle_t regsh;
caddr_t base;
kmutex_t mutex;
kmutex_t low_mutex;
audigyls_port_t *port[AUDIGYLS_NUM_PORT];
audigyls_ctrl_t controls[CTL_NUM];
ac97_ctrl_t *ac97_recgain;
ac97_ctrl_t *ac97_recsrc;
uint64_t recmask;
};
#define INB(dev, reg) \
ddi_get8(dev->regsh, (void *)(dev->base + reg))
#define OUTB(dev, reg, val) \
ddi_put8(dev->regsh, (void *)(dev->base + reg), (val))
#define INW(dev, reg) \
ddi_get16(dev->regsh, (void *)(dev->base + reg))
#define OUTW(dev, reg, val) \
ddi_put16(dev->regsh, (void *)(dev->base + reg), (val))
#define INL(dev, reg) \
ddi_get32(dev->regsh, (void *)(dev->base + reg))
#define OUTL(dev, reg, val) \
ddi_put32(dev->regsh, (void *)(dev->base + reg), (val))
#endif