1139749Simp/*-
272016Scg * Copyright (c) 2000 The NetBSD Foundation, Inc.
372016Scg * All rights reserved.
472016Scg *
572016Scg * This code is derived from software contributed to The NetBSD Foundation
672016Scg * by Takuya SHIOZAKI <AoiMoe@imou.to> .
772016Scg *
872016Scg * Redistribution and use in source and binary forms, with or without
972016Scg * modification, are permitted provided that the following conditions
1072016Scg * are met:
1172016Scg * 1. Redistributions of source code must retain the above copyright
1272016Scg *    notice, this list of conditions and the following disclaimer.
1372016Scg * 2. Redistributions in binary form must reproduce the above copyright
1472016Scg *    notice, this list of conditions and the following disclaimer in the
1572016Scg *    documentation and/or other materials provided with the distribution.
1672016Scg *
1772016Scg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1872016Scg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1972016Scg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2072016Scg * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2172016Scg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2272016Scg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2372016Scg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2472016Scg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2572016Scg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2672016Scg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2772016Scg * SUCH DAMAGE.
2872016Scg *
2972016Scg * $FreeBSD: releng/11.0/sys/dev/sound/pci/cmireg.h 139749 2005-01-06 01:43:34Z imp $
3072016Scg */
3172016Scg
3272016Scg/* C-Media CMI8x38 Audio Chip Support */
3372016Scg
3472016Scg#ifndef _DEV_PCI_CMPCIREG_H_
3572016Scg#define _DEV_PCI_CMPCIREG_H_ (1)
3672016Scg
3772016Scg/*
3872016Scg * PCI Configuration Registers
3972016Scg */
4072016Scg
4172016Scg#define CMPCI_PCI_IOBASEREG	(PCI_MAPREG_START)
4272016Scg
4372016Scg/*
4472016Scg * I/O Space
4572016Scg */
4672016Scg
4772016Scg#define CMPCI_REG_FUNC_0		0x00
4872016Scg#  define CMPCI_REG_CH0_DIR		0x00000001
4972016Scg#  define CMPCI_REG_CH1_DIR		0x00000002
5072016Scg#  define CMPCI_REG_CH0_PAUSE		0x00000004
5172016Scg#  define CMPCI_REG_CH1_PAUSE		0x00000008
5272016Scg#  define CMPCI_REG_CH0_ENABLE		0x00010000
5372016Scg#  define CMPCI_REG_CH1_ENABLE		0x00020000
5472016Scg#  define CMPCI_REG_CH0_RESET		0x00040000
5572016Scg#  define CMPCI_REG_CH1_RESET		0x00080000
5672016Scg
5772016Scg#define CMPCI_REG_FUNC_1		0x04
5872016Scg#  define CMPCI_REG_JOY_ENABLE		0x00000002
5972016Scg#  define CMPCI_REG_UART_ENABLE		0x00000004
6072016Scg#  define CMPCI_REG_LEGACY_ENABLE	0x00000008
6172016Scg#  define CMPCI_REG_BREQ		0x00000010
6272016Scg#  define CMPCI_REG_MCBINTR_ENABLE	0x00000020
6372016Scg#  define CMPCI_REG_SPDIFOUT_DAC	0x00000040
6472016Scg#  define CMPCI_REG_SPDIF_LOOP		0x00000080
6572016Scg#  define CMPCI_REG_SPDIF0_ENABLE	0x00000100
6672016Scg#  define CMPCI_REG_SPDIF1_ENABLE	0x00000200
6772016Scg#  define CMPCI_REG_DAC_FS_SHIFT	10
6872016Scg#  define CMPCI_REG_DAC_FS_MASK		0x00000007
6972016Scg#  define CMPCI_REG_ADC_FS_SHIFT	13
7072016Scg#  define CMPCI_REG_ADC_FS_MASK		0x00000007
7172016Scg
7272016Scg#define CMPCI_REG_CHANNEL_FORMAT	0x08
7372016Scg#  define CMPCI_REG_CH0_FORMAT_SHIFT	0
7472016Scg#  define CMPCI_REG_CH0_FORMAT_MASK	0x00000003
7572016Scg#  define CMPCI_REG_CH1_FORMAT_SHIFT	2
7672016Scg#  define CMPCI_REG_CH1_FORMAT_MASK	0x00000003
7772016Scg#  define CMPCI_REG_FORMAT_MONO		0x00000000
7872016Scg#  define CMPCI_REG_FORMAT_STEREO	0x00000001
7972016Scg#  define CMPCI_REG_FORMAT_8BIT		0x00000000
8072016Scg#  define CMPCI_REG_FORMAT_16BIT	0x00000002
8172016Scg
8272016Scg#define CMPCI_REG_INTR_CTRL		0x0c
8372016Scg#  define CMPCI_REG_CH0_INTR_ENABLE	0x00010000
8472016Scg#  define CMPCI_REG_CH1_INTR_ENABLE	0x00020000
8572016Scg#  define CMPCI_REG_TDMA_INTR_ENABLE	0x00040000
8672016Scg
8772016Scg#define CMPCI_REG_INTR_STATUS		0x10
8872016Scg#  define CMPCI_REG_CH0_INTR		0x00000001
8972016Scg#  define CMPCI_REG_CH1_INTR		0x00000002
9072016Scg#  define CMPCI_REG_CH0_BUSY		0x00000004
9172016Scg#  define CMPCI_REG_CH1_BUSY		0x00000008
9272016Scg#  define CMPCI_REG_LEGACY_STEREO	0x00000010
9372016Scg#  define CMPCI_REG_LEGACY_HDMA		0x00000020
9472016Scg#  define CMPCI_REG_DMASTAT		0x00000040
9572016Scg#  define CMPCI_REG_XDO46		0x00000080
9672016Scg#  define CMPCI_REG_HTDMA_INTR		0x00004000
9772016Scg#  define CMPCI_REG_LTDMA_INTR		0x00008000
9872016Scg#  define CMPCI_REG_UART_INTR		0x00010000
9972016Scg#  define CMPCI_REG_MCB_INTR		0x04000000
10072016Scg#  define CMPCI_REG_VCO			0x08000000
10172016Scg#  define CMPCI_REG_ANY_INTR		0x80000000
10272016Scg
10372016Scg#define CMPCI_REG_LEGACY_CTRL		0x14
10472016Scg#  define CMPCI_REG_LEGACY_SPDIF_ENABLE	0x00200000
10572016Scg#  define CMPCI_REG_SPDIF_COPYRIGHT	0x00400000
10672016Scg#  define CMPCI_REG_XSPDIF_ENABLE	0x00800000
10772016Scg#  define CMPCI_REG_FMSEL_SHIFT		24
10872016Scg#  define CMPCI_REG_FMSEL_MASK		0x00000003
10972016Scg#  define CMPCI_REG_VSBSEL_SHIFT	26
11072016Scg#  define CMPCI_REG_VSBSEL_MASK		0x00000003
11172016Scg#  define CMPCI_REG_VMPUSEL_SHIFT	29
11272016Scg#  define CMPCI_REG_VMPUSEL_MASK	0x00000003
11372016Scg
11472016Scg#define CMPCI_REG_MISC			0x18
11572016Scg#  define CMPCI_REG_POWER_DOWN		0x80000000
11672016Scg#  define CMPCI_REG_BUS_AND_DSP_RESET	0x40000000
11774994Sorion#  define CMPCI_REG_N4SPK3D		0x04000000
11872016Scg#  define CMPCI_REG_W_SPDIF_48L		0x01000000
11974994Sorion#  define CMPCI_REG_XCHGDAC		0x00400000
12074994Sorion#  define CMPCI_REG_FM_ENABLE		0x00080000
12172016Scg#  define CMPCI_REG_SPDIF_48K		0x00008000
12272016Scg
12372016Scg#define CMPCI_REG_SBDATA		0x22
12472016Scg#define CMPCI_REG_SBADDR		0x23
12572016Scg#  define CMPCI_SB16_MIXER_RESET	0x00
12672016Scg#  define CMPCI_SB16_MIXER_MASTER_L	0x30
12772016Scg#  define CMPCI_SB16_MIXER_MASTER_R	0x31
12872016Scg#  define CMPCI_SB16_MIXER_VOICE_L	0x32
12972016Scg#  define CMPCI_SB16_MIXER_VOICE_R	0x33
13072016Scg#  define CMPCI_SB16_MIXER_FM_L		0x34
13172016Scg#  define CMPCI_SB16_MIXER_FM_R		0x35
13272016Scg#  define CMPCI_SB16_MIXER_CDDA_L	0x36
13372016Scg#  define CMPCI_SB16_MIXER_CDDA_R	0x37
13472016Scg#  define CMPCI_SB16_MIXER_LINE_L	0x38
13572016Scg#  define CMPCI_SB16_MIXER_LINE_R	0x39
13672016Scg#  define CMPCI_SB16_MIXER_MIC		0x3A
13772016Scg#  define CMPCI_SB16_MIXER_SPEAKER	0x3B
13872016Scg#  define CMPCI_SB16_MIXER_OUTMIX	0x3C
13972016Scg#    define CMPCI_SB16_SW_MIC		0x01
14072016Scg#    define CMPCI_SB16_SW_CD_R		0x02
14172016Scg#    define CMPCI_SB16_SW_CD_L		0x04
14272016Scg#    define CMPCI_SB16_SW_CD		(CMPCI_SB16_SW_CD_L|CMPCI_SB16_SW_CD_R)
14372016Scg#    define CMPCI_SB16_SW_LINE_R	0x08
14472016Scg#    define CMPCI_SB16_SW_LINE_L	0x10
14572016Scg#    define CMPCI_SB16_SW_LINE	(CMPCI_SB16_SW_LINE_L|CMPCI_SB16_SW_LINE_R)
14672016Scg#    define CMPCI_SB16_SW_FM_R		0x20
14772016Scg#    define CMPCI_SB16_SW_FM_L		0x40
14872016Scg#    define CMPCI_SB16_SW_FM		(CMPCI_SB16_SW_FM_L|CMPCI_SB16_SW_FM_R)
14972016Scg#  define CMPCI_SB16_MIXER_ADCMIX_L	0x3D
15072016Scg#  define CMPCI_SB16_MIXER_ADCMIX_R	0x3E
15172016Scg#    define CMPCI_SB16_MIXER_FM_SRC_R	0x20
15272016Scg#    define CMPCI_SB16_MIXER_LINE_SRC_R	0x08
15372016Scg#    define CMPCI_SB16_MIXER_CD_SRC_R	0x02
15472016Scg#    define CMPCI_SB16_MIXER_MIC_SRC	0x01
15572016Scg#    define CMPCI_SB16_MIXER_SRC_R_TO_L(v) ((v) << 1)
15672016Scg
15772016Scg#  define CMPCI_SB16_MIXER_INGAIN_L	0x3F
15872016Scg#  define CMPCI_SB16_MIXER_INGAIN_R	0x40
15972016Scg#  define CMPCI_SB16_MIXER_OUTGAIN_L	0x41
16072016Scg#  define CMPCI_SB16_MIXER_OUTGAIN_R	0x42
16172016Scg#  define CMPCI_SB16_MIXER_AGC		0x43
16272016Scg#  define CMPCI_SB16_MIXER_TREBLE_L	0x44
16372016Scg#  define CMPCI_SB16_MIXER_TREBLE_R	0x45
16472016Scg#  define CMPCI_SB16_MIXER_BASS_L	0x46
16572016Scg#  define CMPCI_SB16_MIXER_BASS_R	0x47
16672016Scg#  define CMPCI_SB16_MIXER_L_TO_R(addr) ((addr)+1)
16772016Scg
16872016Scg#  define CMPCI_ADJUST_MIC_GAIN(sc, x) cmpci_adjust((x), 0xf8)
16972016Scg#  define CMPCI_ADJUST_GAIN(sc, x)     cmpci_adjust((x), 0xf8)
17072016Scg#  define CMPCI_ADJUST_2_GAIN(sc, x)   cmpci_adjust((x), 0xc0)
17172016Scg
17274994Sorion#define CMPCI_REG_MIXER1		0x24
17374994Sorion#  define CMPCI_SPK4			0x20
17474994Sorion#  define CMPCI_REAR2FRONT		0x10
17574994Sorion#  define CMPCI_X3DEN			0x02
17674994Sorion
17772016Scg#define CMPCI_REG_MPU_BASE		0x40
17872016Scg#define CMPCI_REG_MPU_SIZE		0x10
17972016Scg#define CMPCI_REG_FM_BASE		0x50
18072016Scg#define CMPCI_REG_FM_SIZE		0x10
18172016Scg
18272016Scg#define CMPCI_REG_AUX_MIC		0x25
18372016Scg#  define CMPCI_AUX_SELECT_R		0x80
18472016Scg#  define CMPCI_AUX_SELECT_L		0x40
18572016Scg#  define CMPCI_AUX_MUTE_R		0x20
18672016Scg#  define CMPCI_AUX_MUTE_L		0x10
18772016Scg#  define CMPCI_VAD_MIC			0x0e
18872016Scg#  define CMPCI_MIC_QUIET		0x01
18972016Scg
19072016Scg#define CMPCI_REG_DMA0_BASE		0x80
19172016Scg#define CMPCI_REG_DMA0_BYTES		0x84
19272016Scg#define CMPCI_REG_DMA0_SAMPLES		0x86
19372016Scg#define CMPCI_REG_DMA1_BASE		0x88
19472016Scg#define CMPCI_REG_DMA1_BYTES		0x8C
19572016Scg#define CMPCI_REG_DMA1_SAMPLES		0x8E
19672016Scg
19772016Scg/* sample rate */
19872016Scg#define CMPCI_REG_RATE_5512		0
19972016Scg#define CMPCI_REG_RATE_11025		1
20072016Scg#define CMPCI_REG_RATE_22050		2
20172016Scg#define CMPCI_REG_RATE_44100		3
20272016Scg#define CMPCI_REG_RATE_8000		4
20372016Scg#define CMPCI_REG_RATE_16000		5
20472016Scg#define CMPCI_REG_RATE_32000		6
20572016Scg#define CMPCI_REG_RATE_48000		7
20672016Scg#define CMPCI_REG_NUMRATE		8
20772016Scg
20872016Scg#endif /* _DEV_PCI_CMPCIREG_H_ */
20972016Scg
21072016Scg/* end of file */
211