aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen/oxygen.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-01-21 02:50:19 -0500
committerJaroslav Kysela <perex@perex.cz>2008-01-31 11:30:07 -0500
commit878ac3ee76a5abb4952396570207f6ebe0597e52 (patch)
tree9c5dea50a61302f3b4533314091b8cb9c02f4170 /sound/pci/oxygen/oxygen.c
parent44fb7aae82b37f5bb66cb1423e2babb11d90969e (diff)
[ALSA] oxygen: add more symbols
Add symbol definitions for the various codecs and GPIO pins. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/oxygen/oxygen.c')
-rw-r--r--sound/pci/oxygen/oxygen.c138
1 files changed, 105 insertions, 33 deletions
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index b11341f01c1d..78aa96917626 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -70,30 +70,92 @@ static struct pci_device_id oxygen_ids[] __devinitdata = {
70}; 70};
71MODULE_DEVICE_TABLE(pci, oxygen_ids); 71MODULE_DEVICE_TABLE(pci, oxygen_ids);
72 72
73
74#define GPIO_AK5385_DFS_MASK 0x0003
75#define GPIO_AK5385_DFS_NORMAL 0x0000
76#define GPIO_AK5385_DFS_DOUBLE 0x0001
77#define GPIO_AK5385_DFS_QUAD 0x0002
78
73#define AK4396_WRITE 0x2000 79#define AK4396_WRITE 0x2000
74 80
75/* register 0 */ 81#define AK4396_CONTROL_1 0
82#define AK4396_CONTROL_2 1
83#define AK4396_CONTROL_3 2
84#define AK4396_LCH_ATT 3
85#define AK4396_RCH_ATT 4
86
87/* control 1 */
76#define AK4396_RSTN 0x01 88#define AK4396_RSTN 0x01
89#define AK4396_DIF_MASK 0x0e
90#define AK4396_DIF_16_LSB 0x00
91#define AK4396_DIF_20_LSB 0x02
77#define AK4396_DIF_24_MSB 0x04 92#define AK4396_DIF_24_MSB 0x04
78/* register 1 */ 93#define AK4396_DIF_24_I2S 0x06
94#define AK4396_DIF_24_LSB 0x08
95#define AK4396_ACKS 0x80
96/* control 2 */
79#define AK4396_SMUTE 0x01 97#define AK4396_SMUTE 0x01
98#define AK4396_DEM_MASK 0x06
99#define AK4396_DEM_441 0x00
80#define AK4396_DEM_OFF 0x02 100#define AK4396_DEM_OFF 0x02
101#define AK4396_DEM_48 0x04
102#define AK4396_DEM_32 0x06
81#define AK4396_DFS_MASK 0x18 103#define AK4396_DFS_MASK 0x18
82#define AK4396_DFS_NORMAL 0x00 104#define AK4396_DFS_NORMAL 0x00
83#define AK4396_DFS_DOUBLE 0x08 105#define AK4396_DFS_DOUBLE 0x08
84#define AK4396_DFS_QUAD 0x10 106#define AK4396_DFS_QUAD 0x10
85 107#define AK4396_SLOW 0x20
86/* register 0 */ 108#define AK4396_DZFM 0x40
109#define AK4396_DZFE 0x80
110/* control 3 */
111#define AK4396_DZFB 0x04
112#define AK4396_DCKB 0x10
113#define AK4396_DCKS 0x20
114#define AK4396_DSDM 0x40
115#define AK4396_D_P_MASK 0x80
116#define AK4396_PCM 0x00
117#define AK4396_DSD 0x80
118
119#define WM8785_R0 0
120#define WM8785_R1 1
121#define WM8785_R2 2
122#define WM8785_R7 7
123
124/* R0 */
125#define WM8785_MCR_MASK 0x007
126#define WM8785_MCR_SLAVE 0x000
127#define WM8785_MCR_MASTER_128 0x001
128#define WM8785_MCR_MASTER_192 0x002
129#define WM8785_MCR_MASTER_256 0x003
130#define WM8785_MCR_MASTER_384 0x004
131#define WM8785_MCR_MASTER_512 0x005
132#define WM8785_MCR_MASTER_768 0x006
133#define WM8785_OSR_MASK 0x018
87#define WM8785_OSR_SINGLE 0x000 134#define WM8785_OSR_SINGLE 0x000
88#define WM8785_OSR_DOUBLE 0x008 135#define WM8785_OSR_DOUBLE 0x008
89#define WM8785_OSR_QUAD 0x010 136#define WM8785_OSR_QUAD 0x010
137#define WM8785_FORMAT_MASK 0x060
138#define WM8785_FORMAT_RJUST 0x000
90#define WM8785_FORMAT_LJUST 0x020 139#define WM8785_FORMAT_LJUST 0x020
91#define WM8785_FORMAT_I2S 0x040 140#define WM8785_FORMAT_I2S 0x040
92/* register 1 */ 141#define WM8785_FORMAT_DSP 0x060
142/* R1 */
143#define WM8785_WL_MASK 0x003
93#define WM8785_WL_16 0x000 144#define WM8785_WL_16 0x000
94#define WM8785_WL_20 0x001 145#define WM8785_WL_20 0x001
95#define WM8785_WL_24 0x002 146#define WM8785_WL_24 0x002
96#define WM8785_WL_32 0x003 147#define WM8785_WL_32 0x003
148#define WM8785_LRP 0x004
149#define WM8785_BCLKINV 0x008
150#define WM8785_LRSWAP 0x010
151#define WM8785_DEVNO_MASK 0x0e0
152/* R2 */
153#define WM8785_HPFR 0x001
154#define WM8785_HPFL 0x002
155#define WM8785_SDODIS 0x004
156#define WM8785_PWRDNR 0x008
157#define WM8785_PWRDNL 0x010
158#define WM8785_TDM_MASK 0x1c0
97 159
98static void ak4396_write(struct oxygen *chip, unsigned int codec, 160static void ak4396_write(struct oxygen *chip, unsigned int codec,
99 u8 reg, u8 value) 161 u8 reg, u8 value)
@@ -124,29 +186,33 @@ static void ak4396_init(struct oxygen *chip)
124{ 186{
125 unsigned int i; 187 unsigned int i;
126 188
127 chip->ak4396_reg1 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; 189 chip->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL;
128 for (i = 0; i < 4; ++i) { 190 for (i = 0; i < 4; ++i) {
129 ak4396_write(chip, i, 0, AK4396_DIF_24_MSB | AK4396_RSTN); 191 ak4396_write(chip, i,
130 ak4396_write(chip, i, 1, chip->ak4396_reg1); 192 AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
131 ak4396_write(chip, i, 2, 0); 193 ak4396_write(chip, i,
132 ak4396_write(chip, i, 3, 0xff); 194 AK4396_CONTROL_2, chip->ak4396_ctl2);
133 ak4396_write(chip, i, 4, 0xff); 195 ak4396_write(chip, i,
196 AK4396_CONTROL_3, AK4396_PCM);
197 ak4396_write(chip, i, AK4396_LCH_ATT, 0xff);
198 ak4396_write(chip, i, AK4396_RCH_ATT, 0xff);
134 } 199 }
135 snd_component_add(chip->card, "AK4396"); 200 snd_component_add(chip->card, "AK4396");
136} 201}
137 202
138static void ak5385_init(struct oxygen *chip) 203static void ak5385_init(struct oxygen *chip)
139{ 204{
140 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 0x0003); 205 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_AK5385_DFS_MASK);
141 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, 0x0003); 206 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_AK5385_DFS_MASK);
142 snd_component_add(chip->card, "AK5385"); 207 snd_component_add(chip->card, "AK5385");
143} 208}
144 209
145static void wm8785_init(struct oxygen *chip) 210static void wm8785_init(struct oxygen *chip)
146{ 211{
147 wm8785_write(chip, 7, 0); 212 wm8785_write(chip, WM8785_R7, 0);
148 wm8785_write(chip, 0, WM8785_FORMAT_LJUST | WM8785_OSR_SINGLE); 213 wm8785_write(chip, WM8785_R0, WM8785_MCR_SLAVE |
149 wm8785_write(chip, 1, WM8785_WL_24); 214 WM8785_OSR_SINGLE | WM8785_FORMAT_LJUST);
215 wm8785_write(chip, WM8785_R1, WM8785_WL_24);
150 snd_component_add(chip->card, "WM8785"); 216 snd_component_add(chip->card, "WM8785");
151} 217}
152 218
@@ -184,18 +250,21 @@ static void set_ak4396_params(struct oxygen *chip,
184 unsigned int i; 250 unsigned int i;
185 u8 value; 251 u8 value;
186 252
187 value = chip->ak4396_reg1 & ~AK4396_DFS_MASK; 253 value = chip->ak4396_ctl2 & ~AK4396_DFS_MASK;
188 if (params_rate(params) <= 54000) 254 if (params_rate(params) <= 54000)
189 value |= AK4396_DFS_NORMAL; 255 value |= AK4396_DFS_NORMAL;
190 else if (params_rate(params) < 120000) 256 else if (params_rate(params) < 120000)
191 value |= AK4396_DFS_DOUBLE; 257 value |= AK4396_DFS_DOUBLE;
192 else 258 else
193 value |= AK4396_DFS_QUAD; 259 value |= AK4396_DFS_QUAD;
194 chip->ak4396_reg1 = value; 260 chip->ak4396_ctl2 = value;
195 for (i = 0; i < 4; ++i) { 261 for (i = 0; i < 4; ++i) {
196 ak4396_write(chip, i, 0, AK4396_DIF_24_MSB); 262 ak4396_write(chip, i,
197 ak4396_write(chip, i, 1, value); 263 AK4396_CONTROL_1, AK4396_DIF_24_MSB);
198 ak4396_write(chip, i, 0, AK4396_DIF_24_MSB | AK4396_RSTN); 264 ak4396_write(chip, i,
265 AK4396_CONTROL_2, value);
266 ak4396_write(chip, i,
267 AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
199 } 268 }
200} 269}
201 270
@@ -204,8 +273,10 @@ static void update_ak4396_volume(struct oxygen *chip)
204 unsigned int i; 273 unsigned int i;
205 274
206 for (i = 0; i < 4; ++i) { 275 for (i = 0; i < 4; ++i) {
207 ak4396_write(chip, i, 3, chip->dac_volume[i * 2]); 276 ak4396_write(chip, i,
208 ak4396_write(chip, i, 4, chip->dac_volume[i * 2 + 1]); 277 AK4396_LCH_ATT, chip->dac_volume[i * 2]);
278 ak4396_write(chip, i,
279 AK4396_RCH_ATT, chip->dac_volume[i * 2 + 1]);
209 } 280 }
210} 281}
211 282
@@ -214,11 +285,11 @@ static void update_ak4396_mute(struct oxygen *chip)
214 unsigned int i; 285 unsigned int i;
215 u8 value; 286 u8 value;
216 287
217 value = chip->ak4396_reg1 & ~AK4396_SMUTE; 288 value = chip->ak4396_ctl2 & ~AK4396_SMUTE;
218 if (chip->dac_mute) 289 if (chip->dac_mute)
219 value |= AK4396_SMUTE; 290 value |= AK4396_SMUTE;
220 for (i = 0; i < 4; ++i) 291 for (i = 0; i < 4; ++i)
221 ak4396_write(chip, i, 1, value); 292 ak4396_write(chip, i, AK4396_CONTROL_2, value);
222} 293}
223 294
224static void set_wm8785_params(struct oxygen *chip, 295static void set_wm8785_params(struct oxygen *chip,
@@ -226,22 +297,22 @@ static void set_wm8785_params(struct oxygen *chip,
226{ 297{
227 unsigned int value; 298 unsigned int value;
228 299
229 wm8785_write(chip, 7, 0); 300 wm8785_write(chip, WM8785_R7, 0);
230 301
231 value = WM8785_FORMAT_LJUST; 302 value = WM8785_MCR_SLAVE | WM8785_FORMAT_LJUST;
232 if (params_rate(params) == 96000) 303 if (params_rate(params) == 96000)
233 value |= WM8785_OSR_DOUBLE; 304 value |= WM8785_OSR_DOUBLE;
234 else if (params_rate(params) == 192000) 305 else if (params_rate(params) == 192000)
235 value |= WM8785_OSR_QUAD; 306 value |= WM8785_OSR_QUAD;
236 else 307 else
237 value |= WM8785_OSR_SINGLE; 308 value |= WM8785_OSR_SINGLE;
238 wm8785_write(chip, 0, value); 309 wm8785_write(chip, WM8785_R0, value);
239 310
240 if (snd_pcm_format_width(params_format(params)) <= 16) 311 if (snd_pcm_format_width(params_format(params)) <= 16)
241 value = WM8785_WL_16; 312 value = WM8785_WL_16;
242 else 313 else
243 value = WM8785_WL_24; 314 value = WM8785_WL_24;
244 wm8785_write(chip, 1, value); 315 wm8785_write(chip, WM8785_R1, value);
245} 316}
246 317
247static void set_ak5385_params(struct oxygen *chip, 318static void set_ak5385_params(struct oxygen *chip,
@@ -250,12 +321,13 @@ static void set_ak5385_params(struct oxygen *chip,
250 unsigned int value; 321 unsigned int value;
251 322
252 if (params_rate(params) <= 54000) 323 if (params_rate(params) <= 54000)
253 value = 0; 324 value = GPIO_AK5385_DFS_NORMAL;
254 else if (params_rate(params) <= 108000) 325 else if (params_rate(params) <= 108000)
255 value = 1; 326 value = GPIO_AK5385_DFS_DOUBLE;
256 else 327 else
257 value = 2; 328 value = GPIO_AK5385_DFS_QUAD;
258 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, value, 0x0003); 329 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
330 value, GPIO_AK5385_DFS_MASK);
259} 331}
260 332
261static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); 333static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0);