162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci#ifndef __SOUND_VT1724_H
362306a36Sopenharmony_ci#define __SOUND_VT1724_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci/*
662306a36Sopenharmony_ci *   ALSA driver for ICEnsemble VT1724 (Envy24)
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci *	Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
962306a36Sopenharmony_ci */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <sound/control.h>
1262306a36Sopenharmony_ci#include <sound/ac97_codec.h>
1362306a36Sopenharmony_ci#include <sound/rawmidi.h>
1462306a36Sopenharmony_ci#include <sound/i2c.h>
1562306a36Sopenharmony_ci#include <sound/pcm.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#include "ice1712.h"
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_cienum {
2062306a36Sopenharmony_ci	ICE_EEP2_SYSCONF = 0,	/* 06 */
2162306a36Sopenharmony_ci	ICE_EEP2_ACLINK,	/* 07 */
2262306a36Sopenharmony_ci	ICE_EEP2_I2S,		/* 08 */
2362306a36Sopenharmony_ci	ICE_EEP2_SPDIF,		/* 09 */
2462306a36Sopenharmony_ci	ICE_EEP2_GPIO_DIR,	/* 0a */
2562306a36Sopenharmony_ci	ICE_EEP2_GPIO_DIR1,	/* 0b */
2662306a36Sopenharmony_ci	ICE_EEP2_GPIO_DIR2,	/* 0c */
2762306a36Sopenharmony_ci	ICE_EEP2_GPIO_MASK,	/* 0d */
2862306a36Sopenharmony_ci	ICE_EEP2_GPIO_MASK1,	/* 0e */
2962306a36Sopenharmony_ci	ICE_EEP2_GPIO_MASK2,	/* 0f */
3062306a36Sopenharmony_ci	ICE_EEP2_GPIO_STATE,	/* 10 */
3162306a36Sopenharmony_ci	ICE_EEP2_GPIO_STATE1,	/* 11 */
3262306a36Sopenharmony_ci	ICE_EEP2_GPIO_STATE2	/* 12 */
3362306a36Sopenharmony_ci};
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/*
3662306a36Sopenharmony_ci *  Direct registers
3762306a36Sopenharmony_ci */
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#define ICEREG1724(ice, x) ((ice)->port + VT1724_REG_##x)
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define VT1724_REG_CONTROL		0x00	/* byte */
4262306a36Sopenharmony_ci#define   VT1724_RESET			0x80	/* reset whole chip */
4362306a36Sopenharmony_ci#define VT1724_REG_IRQMASK		0x01	/* byte */
4462306a36Sopenharmony_ci#define   VT1724_IRQ_MPU_RX		0x80
4562306a36Sopenharmony_ci#define   VT1724_IRQ_MPU_TX		0x20
4662306a36Sopenharmony_ci#define   VT1724_IRQ_MTPCM		0x10
4762306a36Sopenharmony_ci#define VT1724_REG_IRQSTAT		0x02	/* byte */
4862306a36Sopenharmony_ci/* look to VT1724_IRQ_* */
4962306a36Sopenharmony_ci#define VT1724_REG_SYS_CFG		0x04	/* byte - system configuration PCI60 on Envy24*/
5062306a36Sopenharmony_ci#define   VT1724_CFG_CLOCK	0xc0
5162306a36Sopenharmony_ci#define     VT1724_CFG_CLOCK512	0x00	/* 22.5692Mhz, 44.1kHz*512 */
5262306a36Sopenharmony_ci#define     VT1724_CFG_CLOCK384  0x40	/* 16.9344Mhz, 44.1kHz*384 */
5362306a36Sopenharmony_ci#define   VT1724_CFG_MPU401	0x20		/* MPU401 UARTs */
5462306a36Sopenharmony_ci#define   VT1724_CFG_ADC_MASK	0x0c	/* one, two or one and S/PDIF, stereo ADCs */
5562306a36Sopenharmony_ci#define   VT1724_CFG_ADC_NONE	0x0c	/* no ADCs */
5662306a36Sopenharmony_ci#define   VT1724_CFG_DAC_MASK	0x03	/* one, two, three, four stereo DACs */
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci#define VT1724_REG_AC97_CFG		0x05	/* byte */
5962306a36Sopenharmony_ci#define   VT1724_CFG_PRO_I2S	0x80	/* multitrack converter: I2S or AC'97 */
6062306a36Sopenharmony_ci#define   VT1724_CFG_AC97_PACKED	0x01	/* split or packed mode - AC'97 */
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci#define VT1724_REG_I2S_FEATURES		0x06	/* byte */
6362306a36Sopenharmony_ci#define   VT1724_CFG_I2S_VOLUME	0x80	/* volume/mute capability */
6462306a36Sopenharmony_ci#define   VT1724_CFG_I2S_96KHZ	0x40	/* supports 96kHz sampling */
6562306a36Sopenharmony_ci#define   VT1724_CFG_I2S_RESMASK	0x30	/* resolution mask, 16,18,20,24-bit */
6662306a36Sopenharmony_ci#define   VT1724_CFG_I2S_192KHZ	0x08	/* supports 192kHz sampling */
6762306a36Sopenharmony_ci#define   VT1724_CFG_I2S_OTHER	0x07	/* other I2S IDs */
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#define VT1724_REG_SPDIF_CFG		0x07	/* byte */
7062306a36Sopenharmony_ci#define   VT1724_CFG_SPDIF_OUT_EN	0x80	/*Internal S/PDIF output is enabled*/
7162306a36Sopenharmony_ci#define   VT1724_CFG_SPDIF_OUT_INT	0x40	/*Internal S/PDIF output is implemented*/
7262306a36Sopenharmony_ci#define   VT1724_CFG_I2S_CHIPID	0x3c	/* I2S chip ID */
7362306a36Sopenharmony_ci#define   VT1724_CFG_SPDIF_IN	0x02	/* S/PDIF input is present */
7462306a36Sopenharmony_ci#define   VT1724_CFG_SPDIF_OUT	0x01	/* External S/PDIF output is present */
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/*there is no consumer AC97 codec with the VT1724*/
7762306a36Sopenharmony_ci//#define VT1724_REG_AC97_INDEX		0x08	/* byte */
7862306a36Sopenharmony_ci//#define VT1724_REG_AC97_CMD		0x09	/* byte */
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci#define VT1724_REG_MPU_TXFIFO		0x0a	/*byte ro. number of bytes in TX fifo*/
8162306a36Sopenharmony_ci#define VT1724_REG_MPU_RXFIFO		0x0b	/*byte ro. number of bytes in RX fifo*/
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci#define VT1724_REG_MPU_DATA		0x0c	/* byte */
8462306a36Sopenharmony_ci#define VT1724_REG_MPU_CTRL		0x0d	/* byte */
8562306a36Sopenharmony_ci#define   VT1724_MPU_UART	0x01
8662306a36Sopenharmony_ci#define   VT1724_MPU_TX_EMPTY	0x02
8762306a36Sopenharmony_ci#define   VT1724_MPU_TX_FULL	0x04
8862306a36Sopenharmony_ci#define   VT1724_MPU_RX_EMPTY	0x08
8962306a36Sopenharmony_ci#define   VT1724_MPU_RX_FULL	0x10
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci#define VT1724_REG_MPU_FIFO_WM	0x0e	/*byte set the high/low watermarks for RX/TX fifos*/
9262306a36Sopenharmony_ci#define   VT1724_MPU_RX_FIFO	0x20	//1=rx fifo watermark 0=tx fifo watermark
9362306a36Sopenharmony_ci#define   VT1724_MPU_FIFO_MASK	0x1f
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#define VT1724_REG_I2C_DEV_ADDR	0x10	/* byte */
9662306a36Sopenharmony_ci#define   VT1724_I2C_WRITE		0x01	/* write direction */
9762306a36Sopenharmony_ci#define VT1724_REG_I2C_BYTE_ADDR	0x11	/* byte */
9862306a36Sopenharmony_ci#define VT1724_REG_I2C_DATA		0x12	/* byte */
9962306a36Sopenharmony_ci#define VT1724_REG_I2C_CTRL		0x13	/* byte */
10062306a36Sopenharmony_ci#define   VT1724_I2C_EEPROM		0x80	/* 1 = EEPROM exists */
10162306a36Sopenharmony_ci#define   VT1724_I2C_BUSY		0x01	/* busy bit */
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci#define VT1724_REG_GPIO_DATA	0x14	/* word */
10462306a36Sopenharmony_ci#define VT1724_REG_GPIO_WRITE_MASK	0x16 /* word */
10562306a36Sopenharmony_ci#define VT1724_REG_GPIO_DIRECTION	0x18 /* dword? (3 bytes) 0=input 1=output.
10662306a36Sopenharmony_ci						bit3 - during reset used for Eeprom power-on strapping
10762306a36Sopenharmony_ci						if TESTEN# pin active, bit 2 always input*/
10862306a36Sopenharmony_ci#define VT1724_REG_POWERDOWN	0x1c
10962306a36Sopenharmony_ci#define VT1724_REG_GPIO_DATA_22	0x1e /* byte direction for GPIO 16:22 */
11062306a36Sopenharmony_ci#define VT1724_REG_GPIO_WRITE_MASK_22	0x1f /* byte write mask for GPIO 16:22 */
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci/*
11462306a36Sopenharmony_ci *  Professional multi-track direct control registers
11562306a36Sopenharmony_ci */
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci#define ICEMT1724(ice, x) ((ice)->profi_port + VT1724_MT_##x)
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci#define VT1724_MT_IRQ			0x00	/* byte - interrupt mask */
12062306a36Sopenharmony_ci#define   VT1724_MULTI_PDMA4	0x80	/* SPDIF Out / PDMA4 */
12162306a36Sopenharmony_ci#define	  VT1724_MULTI_PDMA3	0x40	/* PDMA3 */
12262306a36Sopenharmony_ci#define   VT1724_MULTI_PDMA2	0x20	/* PDMA2 */
12362306a36Sopenharmony_ci#define   VT1724_MULTI_PDMA1	0x10	/* PDMA1 */
12462306a36Sopenharmony_ci#define   VT1724_MULTI_FIFO_ERR 0x08	/* DMA FIFO underrun/overrun. */
12562306a36Sopenharmony_ci#define   VT1724_MULTI_RDMA1	0x04	/* RDMA1 (S/PDIF input) */
12662306a36Sopenharmony_ci#define   VT1724_MULTI_RDMA0	0x02	/* RMDA0 */
12762306a36Sopenharmony_ci#define   VT1724_MULTI_PDMA0	0x01	/* MC Interleave/PDMA0 */
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci#define VT1724_MT_RATE			0x01	/* byte - sampling rate select */
13062306a36Sopenharmony_ci#define   VT1724_SPDIF_MASTER		0x10	/* S/PDIF input is master clock */
13162306a36Sopenharmony_ci#define VT1724_MT_I2S_FORMAT		0x02	/* byte - I2S data format */
13262306a36Sopenharmony_ci#define   VT1724_MT_I2S_MCLK_128X	0x08
13362306a36Sopenharmony_ci#define   VT1724_MT_I2S_FORMAT_MASK	0x03
13462306a36Sopenharmony_ci#define   VT1724_MT_I2S_FORMAT_I2S	0x00
13562306a36Sopenharmony_ci#define VT1724_MT_DMA_INT_MASK		0x03	/* byte -DMA Interrupt Mask */
13662306a36Sopenharmony_ci/* lool to VT1724_MULTI_* */
13762306a36Sopenharmony_ci#define VT1724_MT_AC97_INDEX		0x04	/* byte - AC'97 index */
13862306a36Sopenharmony_ci#define VT1724_MT_AC97_CMD		0x05	/* byte - AC'97 command & status */
13962306a36Sopenharmony_ci#define   VT1724_AC97_COLD	0x80	/* cold reset */
14062306a36Sopenharmony_ci#define   VT1724_AC97_WARM	0x40	/* warm reset */
14162306a36Sopenharmony_ci#define   VT1724_AC97_WRITE	0x20	/* W: write, R: write in progress */
14262306a36Sopenharmony_ci#define   VT1724_AC97_READ	0x10	/* W: read, R: read in progress */
14362306a36Sopenharmony_ci#define   VT1724_AC97_READY	0x08	/* codec ready status bit */
14462306a36Sopenharmony_ci#define   VT1724_AC97_ID_MASK	0x03	/* codec id mask */
14562306a36Sopenharmony_ci#define VT1724_MT_AC97_DATA		0x06	/* word - AC'97 data */
14662306a36Sopenharmony_ci#define VT1724_MT_PLAYBACK_ADDR		0x10	/* dword - playback address */
14762306a36Sopenharmony_ci#define VT1724_MT_PLAYBACK_SIZE		0x14	/* dword - playback size */
14862306a36Sopenharmony_ci#define VT1724_MT_DMA_CONTROL		0x18	/* byte - control */
14962306a36Sopenharmony_ci#define   VT1724_PDMA4_START	0x80	/* SPDIF out / PDMA4 start */
15062306a36Sopenharmony_ci#define   VT1724_PDMA3_START	0x40	/* PDMA3 start */
15162306a36Sopenharmony_ci#define   VT1724_PDMA2_START	0x20	/* PDMA2 start */
15262306a36Sopenharmony_ci#define   VT1724_PDMA1_START	0x10	/* PDMA1 start */
15362306a36Sopenharmony_ci#define   VT1724_RDMA1_START	0x04	/* RDMA1 start */
15462306a36Sopenharmony_ci#define   VT1724_RDMA0_START	0x02	/* RMDA0 start */
15562306a36Sopenharmony_ci#define   VT1724_PDMA0_START	0x01	/* MC Interleave / PDMA0 start */
15662306a36Sopenharmony_ci#define VT1724_MT_BURST			0x19	/* Interleaved playback DMA Active streams / PCI burst size */
15762306a36Sopenharmony_ci#define VT1724_MT_DMA_FIFO_ERR		0x1a	/*Global playback and record DMA FIFO Underrun/Overrun */
15862306a36Sopenharmony_ci#define   VT1724_PDMA4_UNDERRUN		0x80
15962306a36Sopenharmony_ci#define   VT1724_PDMA2_UNDERRUN		0x40
16062306a36Sopenharmony_ci#define   VT1724_PDMA3_UNDERRUN		0x20
16162306a36Sopenharmony_ci#define   VT1724_PDMA1_UNDERRUN		0x10
16262306a36Sopenharmony_ci#define   VT1724_RDMA1_UNDERRUN		0x04
16362306a36Sopenharmony_ci#define   VT1724_RDMA0_UNDERRUN		0x02
16462306a36Sopenharmony_ci#define   VT1724_PDMA0_UNDERRUN		0x01
16562306a36Sopenharmony_ci#define VT1724_MT_DMA_PAUSE		0x1b	/*Global playback and record DMA FIFO pause/resume */
16662306a36Sopenharmony_ci#define	  VT1724_PDMA4_PAUSE	0x80
16762306a36Sopenharmony_ci#define	  VT1724_PDMA3_PAUSE	0x40
16862306a36Sopenharmony_ci#define	  VT1724_PDMA2_PAUSE	0x20
16962306a36Sopenharmony_ci#define	  VT1724_PDMA1_PAUSE	0x10
17062306a36Sopenharmony_ci#define	  VT1724_RDMA1_PAUSE	0x04
17162306a36Sopenharmony_ci#define	  VT1724_RDMA0_PAUSE	0x02
17262306a36Sopenharmony_ci#define	  VT1724_PDMA0_PAUSE	0x01
17362306a36Sopenharmony_ci#define VT1724_MT_PLAYBACK_COUNT	0x1c	/* word - playback count */
17462306a36Sopenharmony_ci#define VT1724_MT_CAPTURE_ADDR		0x20	/* dword - capture address */
17562306a36Sopenharmony_ci#define VT1724_MT_CAPTURE_SIZE		0x24	/* word - capture size */
17662306a36Sopenharmony_ci#define VT1724_MT_CAPTURE_COUNT		0x26	/* word - capture count */
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci#define VT1724_MT_ROUTE_PLAYBACK	0x2c	/* word */
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_ci#define VT1724_MT_RDMA1_ADDR		0x30	/* dword - RDMA1 capture address */
18162306a36Sopenharmony_ci#define VT1724_MT_RDMA1_SIZE		0x34	/* word - RDMA1 capture size */
18262306a36Sopenharmony_ci#define VT1724_MT_RDMA1_COUNT		0x36	/* word - RDMA1 capture count */
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci#define VT1724_MT_SPDIF_CTRL		0x3c	/* word */
18562306a36Sopenharmony_ci#define VT1724_MT_MONITOR_PEAKINDEX	0x3e	/* byte */
18662306a36Sopenharmony_ci#define VT1724_MT_MONITOR_PEAKDATA	0x3f	/* byte */
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci/* concurrent stereo channels */
18962306a36Sopenharmony_ci#define VT1724_MT_PDMA4_ADDR		0x40	/* dword */
19062306a36Sopenharmony_ci#define VT1724_MT_PDMA4_SIZE		0x44	/* word */
19162306a36Sopenharmony_ci#define VT1724_MT_PDMA4_COUNT		0x46	/* word */
19262306a36Sopenharmony_ci#define VT1724_MT_PDMA3_ADDR		0x50	/* dword */
19362306a36Sopenharmony_ci#define VT1724_MT_PDMA3_SIZE		0x54	/* word */
19462306a36Sopenharmony_ci#define VT1724_MT_PDMA3_COUNT		0x56	/* word */
19562306a36Sopenharmony_ci#define VT1724_MT_PDMA2_ADDR		0x60	/* dword */
19662306a36Sopenharmony_ci#define VT1724_MT_PDMA2_SIZE		0x64	/* word */
19762306a36Sopenharmony_ci#define VT1724_MT_PDMA2_COUNT		0x66	/* word */
19862306a36Sopenharmony_ci#define VT1724_MT_PDMA1_ADDR		0x70	/* dword */
19962306a36Sopenharmony_ci#define VT1724_MT_PDMA1_SIZE		0x74	/* word */
20062306a36Sopenharmony_ci#define VT1724_MT_PDMA1_COUNT		0x76	/* word */
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ciunsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice, unsigned char dev, unsigned char addr);
20462306a36Sopenharmony_civoid snd_vt1724_write_i2c(struct snd_ice1712 *ice, unsigned char dev, unsigned char addr, unsigned char data);
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci#endif /* __SOUND_VT1724_H */
207