xref: /freebsd/sys/dev/sound/pci/envy24ht.h (revision d4eeb02986980bf33dd56c41ceb9fc5f180c0d47)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2006 Konstantin Dimitrov <kosio.dimitrov@gmail.com>
5  * Copyright (c) 2001 Katsurajima Naoto <raven@katsurajima.seya.yokohama.jp>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  */
31 
32 /* -------------------------------------------------------------------- */
33 
34 /* PCI device ID */
35 #define PCIV_ENVY24 0x1412
36 #define PCID_ENVY24HT 0x1724
37 
38 #define PCIR_CCS		0x10 /* Controller I/O Base Address */
39 #define ENVY24HT_PCIR_MT   	0x14 /* Multi-Track I/O Base Address */
40 
41 /* Controller Registers */
42 
43 #define ENVY24HT_CCS_CTL      0x00 /* Control/Status Register */
44 #define ENVY24HT_CCS_CTL_RESET   0x80 /* Entire Chip soft reset */
45 
46 #define ENVY24HT_CCS_IMASK    0x01 /* Interrupt Mask Register */
47 #define ENVY24HT_CCS_IMASK_PMT   0x10 /* Professional Multi-track */
48 
49 #define ENVY24HT_CCS_I2CDEV   0x10 /* I2C Port Device Address Register */
50 #define ENVY24HT_CCS_I2CDEV_ADDR 0xfe /* I2C device address */
51 #define ENVY24HT_CCS_I2CDEV_ROM  0xa0 /* reserved for the external I2C E2PROM */
52 #define ENVY24HT_CCS_I2CDEV_WR   0x01 /* write */
53 #define ENVY24HT_CCS_I2CDEV_RD   0x00 /* read */
54 
55 #define ENVY24HT_CCS_I2CADDR  0x11 /* I2C Port Byte Address Register */
56 #define ENVY24HT_CCS_I2CDATA  0x12 /* I2C Port Read/Write Data Register */
57 
58 #define ENVY24HT_CCS_I2CSTAT  0x13 /* I2C Port Control and Status Register */
59 #define ENVY24HT_CCS_I2CSTAT_ROM 0x80 /* external E2PROM exists */
60 #define ENVY24HT_CCS_I2CSTAT_BSY 0x01 /* I2C port read/write status busy */
61 
62 #define ENVY24HT_CCS_SCFG  0x04 /* System Configuration Register */
63 #define ENVY24HT_CCSM_SCFG_XIN2      0xc0 /* XIN2 Clock Source Configuration */
64                                  	  /* 00: 24.576MHz(96kHz*256) */
65                                  	  /* 01: 49.152MHz(192kHz*256) */
66                                  	  /* 1x: Reserved */
67 #define ENVY24HT_CCSM_SCFG_MPU       0x20 /* 0(not implemented)/1(1) MPU-401 UART */
68 #define ENVY24HT_CCSM_SCFG_ADC       0x0c /* 1-2 stereo ADC connected, S/PDIF receiver connected */
69 #define ENVY24HT_CCSM_SCFG_DAC       0x03 /* 1-4 stereo DAC connected */
70 
71 #define ENVY24HT_CCS_ACL   0x05 /* AC-Link Configuration Register */
72 #define ENVY24HT_CCSM_ACL_MTC        0x80 /* Multi-track converter type: 0:AC'97 1:I2S */
73 #define ENVY24HT_CCSM_ACL_OMODE      0x02 /* AC 97 codec SDATA_OUT 0:split 1:packed */
74 
75 #define ENVY24HT_CCS_I2S   0x06 /* I2S Converters Features Register */
76 #define ENVY24HT_CCSM_I2S_VOL        0x80 /* I2S codec Volume and mute */
77 #define ENVY24HT_CCSM_I2S_96KHZ      0x40 /* I2S converter 96kHz sampling rate support */
78 #define ENVY24HT_CCSM_I2S_192KHZ     0x08 /* I2S converter 192kHz sampling rate support */
79 #define ENVY24HT_CCSM_I2S_RES        0x30 /* Converter resolution */
80 #define ENVY24HT_CCSM_I2S_16BIT      0x00 /* 16bit */
81 #define ENVY24HT_CCSM_I2S_18BIT      0x10 /* 18bit */
82 #define ENVY24HT_CCSM_I2S_20BIT      0x20 /* 20bit */
83 #define ENVY24HT_CCSM_I2S_24BIT      0x30 /* 24bit */
84 #define ENVY24HT_CCSM_I2S_ID         0x07 /* Other I2S IDs */
85 
86 #define ENVY24HT_CCS_SPDIF 0x07 /* S/PDIF Configuration Register */
87 #define ENVY24HT_CCSM_SPDIF_INT_EN   0x80 /* Enable integrated S/PDIF transmitter */
88 #define ENVY24HT_CCSM_SPDIF_INT_OUT  0x40 /* Internal S/PDIF Out implemented */
89 #define ENVY24HT_CCSM_SPDIF_ID       0x3c /* S/PDIF chip ID */
90 #define ENVY24HT_CCSM_SPDIF_IN       0x02 /* S/PDIF Stereo In is present */
91 #define ENVY24HT_CCSM_SPDIF_OUT      0x01 /* External S/PDIF Out implemented */
92 
93 /* Professional Multi-Track Control Registers */
94 
95 #define ENVY24HT_MT_INT_STAT    0x00 /* DMA Interrupt Mask and Status Register */
96 #define ENVY24HT_MT_INT_RSTAT   0x02 /* Multi-track record interrupt status */
97 #define ENVY24HT_MT_INT_PSTAT   0x01 /* Multi-track playback interrupt status */
98 #define ENVY24HT_MT_INT_MASK	0x03
99 #define ENVY24HT_MT_INT_RMASK   0x02 /* Multi-track record interrupt mask */
100 #define ENVY24HT_MT_INT_PMASK   0x01 /* Multi-track playback interrupt mask */
101 
102 #define ENVY24HT_MT_RATE     0x01 /* Sampling Rate Select Register */
103 #define ENVY24HT_MT_RATE_SPDIF  0x10 /* S/PDIF input clock as the master */
104 #define ENVY24HT_MT_RATE_48000  0x00
105 #define ENVY24HT_MT_RATE_24000  0x01
106 #define ENVY24HT_MT_RATE_12000  0x02
107 #define ENVY24HT_MT_RATE_9600   0x03
108 #define ENVY24HT_MT_RATE_32000  0x04
109 #define ENVY24HT_MT_RATE_16000  0x05
110 #define ENVY24HT_MT_RATE_8000   0x06
111 #define ENVY24HT_MT_RATE_96000  0x07
112 #define ENVY24HT_MT_RATE_192000 0x0e
113 #define ENVY24HT_MT_RATE_64000  0x0f
114 #define ENVY24HT_MT_RATE_44100  0x08
115 #define ENVY24HT_MT_RATE_22050  0x09
116 #define ENVY24HT_MT_RATE_11025  0x0a
117 #define ENVY24HT_MT_RATE_88200  0x0b
118 #define ENVY24HT_MT_RATE_176400 0x0c
119 #define ENVY24HT_MT_RATE_MASK   0x0f
120 
121 #define ENVY24HT_MT_I2S      0x02 /* I2S Data Format Register */
122 #define ENVY24HT_MT_I2S_MLR128  0x08 /* MCLK/LRCLK ratio 128x (or 256x) */
123 
124 #define ENVY24HT_MT_PADDR    0x10 /* Playback DMA Current/Base Address Register */
125 #define ENVY24HT_MT_PCNT     0x14 /* Playback DMA Current/Base Count Register */
126 #define ENVY24HT_MT_PTERM    0x1C /* Playback Current/Base Terminal Count Register */
127 
128 #define ENVY24HT_MT_PCTL     0x18 /* Global Playback and Record DMA Start/Stop Register */
129 #define ENVY24HT_MT_PCTL_RSTART 0x02 /* 1: Record start; 0: Record stop */
130 #define ENVY24HT_MT_PCTL_PSTART 0x01 /* 1: Playback start; 0: Playback stop */
131 
132 #define ENVY24HT_MT_RADDR    0x20 /* Record DMA Current/Base Address Register */
133 #define ENVY24HT_MT_RCNT     0x24 /* Record DMA Current/Base Count Register */
134 #define ENVY24HT_MT_RTERM    0x26 /* Record Current/Base Terminal Count Register */
135 
136 /*
137   These map values are refferd from ALSA sound driver.
138 */
139 /* ENVY24 configuration E2PROM map */
140 #define ENVY24HT_E2PROM_SUBVENDOR  0x02
141 #define ENVY24HT_E2PROM_SUBDEVICE  0x00
142 #define ENVY24HT_E2PROM_SIZE       0x04
143 #define ENVY24HT_E2PROM_VERSION    0x05
144 #define ENVY24HT_E2PROM_SCFG       0x06
145 #define ENVY24HT_E2PROM_ACL        0x07
146 #define ENVY24HT_E2PROM_I2S        0x08
147 #define ENVY24HT_E2PROM_SPDIF      0x09
148 #define ENVY24HT_E2PROM_GPIOMASK   0x0d
149 #define ENVY24HT_E2PROM_GPIOSTATE  0x10
150 #define ENVY24HT_E2PROM_GPIODIR    0x0a
151 
152 /* ENVY24 mixer channel defines */
153 /*
154   ENVY24 mixer has original line matrix. So, general mixer command is not
155   able to use for this. If system has consumer AC'97 output, AC'97 line is
156   used as master mixer, and it is able to control.
157 */
158 #define ENVY24HT_CHAN_NUM  11 /* Play * 5 + Record * 5 + Mix * 1 */
159 
160 #define ENVY24HT_CHAN_PLAY_DAC1  0
161 #define ENVY24HT_CHAN_PLAY_DAC2  1
162 #define ENVY24HT_CHAN_PLAY_DAC3  2
163 #define ENVY24HT_CHAN_PLAY_DAC4  3
164 #define ENVY24HT_CHAN_PLAY_SPDIF 4
165 #define ENVY24HT_CHAN_REC_ADC1   5
166 #define ENVY24HT_CHAN_REC_ADC2   6
167 #define ENVY24HT_CHAN_REC_ADC3   7
168 #define ENVY24HT_CHAN_REC_ADC4   8
169 #define ENVY24HT_CHAN_REC_SPDIF  9
170 #define ENVY24HT_CHAN_REC_MIX   10
171 
172 #define ENVY24HT_MIX_MASK     0x3fd
173 #define ENVY24HT_MIX_REC_MASK 0x3e0
174 
175 /* volume value constants */
176 #define ENVY24HT_VOL_MAX    0 /* 0db(negate) */
177 #define ENVY24HT_VOL_MIN   96 /* -144db(negate) */
178 #define ENVY24HT_VOL_MUTE 127 /* mute */
179 
180 #define BUS_SPACE_MAXSIZE_ENVY24 0x3fffc /* 64k x 4byte(1dword) */
181 
182 #define ENVY24HT_CCS_GPIO_HDATA 0x1E
183 #define ENVY24HT_CCS_GPIO_LDATA 0x14
184 #define ENVY24HT_CCS_GPIO_LMASK 0x16
185 #define ENVY24HT_CCS_GPIO_HMASK 0x1F
186 #define ENVY24HT_CCS_GPIO_CTLDIR 0x18
187