aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/revo.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/ice1712/revo.c')
-rw-r--r--sound/pci/ice1712/revo.c372
1 files changed, 348 insertions, 24 deletions
diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index bf98ea34feb0..025a7e8497c3 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -84,38 +84,142 @@ static void revo_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
84} 84}
85 85
86/* 86/*
87 * I2C access to the PT2258 volume controller on GPIO 6/7 (Revolution 5.1)
88 */
89
90static void revo_i2c_start(struct snd_i2c_bus *bus)
91{
92 struct snd_ice1712 *ice = bus->private_data;
93 snd_ice1712_save_gpio_status(ice);
94}
95
96static void revo_i2c_stop(struct snd_i2c_bus *bus)
97{
98 struct snd_ice1712 *ice = bus->private_data;
99 snd_ice1712_restore_gpio_status(ice);
100}
101
102static void revo_i2c_direction(struct snd_i2c_bus *bus, int clock, int data)
103{
104 struct snd_ice1712 *ice = bus->private_data;
105 unsigned int mask, val;
106
107 val = 0;
108 if (clock)
109 val |= VT1724_REVO_I2C_CLOCK; /* write SCL */
110 if (data)
111 val |= VT1724_REVO_I2C_DATA; /* write SDA */
112 mask = VT1724_REVO_I2C_CLOCK | VT1724_REVO_I2C_DATA;
113 ice->gpio.direction &= ~mask;
114 ice->gpio.direction |= val;
115 snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
116 snd_ice1712_gpio_set_mask(ice, ~mask);
117}
118
119static void revo_i2c_setlines(struct snd_i2c_bus *bus, int clk, int data)
120{
121 struct snd_ice1712 *ice = bus->private_data;
122 unsigned int val = 0;
123
124 if (clk)
125 val |= VT1724_REVO_I2C_CLOCK;
126 if (data)
127 val |= VT1724_REVO_I2C_DATA;
128 snd_ice1712_gpio_write_bits(ice,
129 VT1724_REVO_I2C_DATA |
130 VT1724_REVO_I2C_CLOCK, val);
131 udelay(5);
132}
133
134static int revo_i2c_getdata(struct snd_i2c_bus *bus, int ack)
135{
136 struct snd_ice1712 *ice = bus->private_data;
137 int bit;
138
139 if (ack)
140 udelay(5);
141 bit = snd_ice1712_gpio_read_bits(ice, VT1724_REVO_I2C_DATA) ? 1 : 0;
142 return bit;
143}
144
145static struct snd_i2c_bit_ops revo51_bit_ops = {
146 .start = revo_i2c_start,
147 .stop = revo_i2c_stop,
148 .direction = revo_i2c_direction,
149 .setlines = revo_i2c_setlines,
150 .getdata = revo_i2c_getdata,
151};
152
153static int revo51_i2c_init(struct snd_ice1712 *ice,
154 struct snd_pt2258 *pt)
155{
156 int err;
157
158 /* create the I2C bus */
159 err = snd_i2c_bus_create(ice->card, "ICE1724 GPIO6", NULL, &ice->i2c);
160 if (err < 0)
161 return err;
162
163 ice->i2c->private_data = ice;
164 ice->i2c->hw_ops.bit = &revo51_bit_ops;
165
166 /* create the I2C device */
167 err = snd_i2c_device_create(ice->i2c, "PT2258", 0x40,
168 &ice->spec.revo51.dev);
169 if (err < 0)
170 return err;
171
172 pt->card = ice->card;
173 pt->i2c_bus = ice->i2c;
174 pt->i2c_dev = ice->spec.revo51.dev;
175 ice->spec.revo51.pt2258 = pt;
176
177 snd_pt2258_reset(pt);
178
179 return 0;
180}
181
182/*
87 * initialize the chips on M-Audio Revolution cards 183 * initialize the chips on M-Audio Revolution cards
88 */ 184 */
89 185
90#define AK_DAC(xname,xch) { .name = xname, .num_channels = xch } 186#define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
91 187
92static struct snd_akm4xxx_dac_channel revo71_front[] = { 188static const struct snd_akm4xxx_dac_channel revo71_front[] = {
93 AK_DAC("PCM Playback Volume", 2) 189 AK_DAC("PCM Playback Volume", 2)
94}; 190};
95 191
96static struct snd_akm4xxx_dac_channel revo71_surround[] = { 192static const struct snd_akm4xxx_dac_channel revo71_surround[] = {
97 AK_DAC("PCM Center Playback Volume", 1), 193 AK_DAC("PCM Center Playback Volume", 1),
98 AK_DAC("PCM LFE Playback Volume", 1), 194 AK_DAC("PCM LFE Playback Volume", 1),
99 AK_DAC("PCM Side Playback Volume", 2), 195 AK_DAC("PCM Side Playback Volume", 2),
100 AK_DAC("PCM Rear Playback Volume", 2), 196 AK_DAC("PCM Rear Playback Volume", 2),
101}; 197};
102 198
103static struct snd_akm4xxx_dac_channel revo51_dac[] = { 199static const struct snd_akm4xxx_dac_channel revo51_dac[] = {
104 AK_DAC("PCM Playback Volume", 2), 200 AK_DAC("PCM Playback Volume", 2),
105 AK_DAC("PCM Center Playback Volume", 1), 201 AK_DAC("PCM Center Playback Volume", 1),
106 AK_DAC("PCM LFE Playback Volume", 1), 202 AK_DAC("PCM LFE Playback Volume", 1),
107 AK_DAC("PCM Rear Playback Volume", 2), 203 AK_DAC("PCM Rear Playback Volume", 2),
108}; 204};
109 205
110static struct snd_akm4xxx_adc_channel revo51_adc[] = { 206static const char *revo51_adc_input_names[] = {
207 "Mic",
208 "Line",
209 "CD",
210 NULL
211};
212
213static const struct snd_akm4xxx_adc_channel revo51_adc[] = {
111 { 214 {
112 .name = "PCM Capture Volume", 215 .name = "PCM Capture Volume",
113 .switch_name = "PCM Capture Switch", 216 .switch_name = "PCM Capture Switch",
114 .num_channels = 2 217 .num_channels = 2,
218 .input_names = revo51_adc_input_names
115 }, 219 },
116}; 220};
117 221
118static struct snd_akm4xxx akm_revo_front __devinitdata = { 222static const struct snd_akm4xxx akm_revo_front __devinitdata = {
119 .type = SND_AK4381, 223 .type = SND_AK4381,
120 .num_dacs = 2, 224 .num_dacs = 2,
121 .ops = { 225 .ops = {
@@ -124,7 +228,7 @@ static struct snd_akm4xxx akm_revo_front __devinitdata = {
124 .dac_info = revo71_front, 228 .dac_info = revo71_front,
125}; 229};
126 230
127static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = { 231static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
128 .caddr = 1, 232 .caddr = 1,
129 .cif = 0, 233 .cif = 0,
130 .data_mask = VT1724_REVO_CDOUT, 234 .data_mask = VT1724_REVO_CDOUT,
@@ -136,7 +240,7 @@ static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
136 .mask_flags = 0, 240 .mask_flags = 0,
137}; 241};
138 242
139static struct snd_akm4xxx akm_revo_surround __devinitdata = { 243static const struct snd_akm4xxx akm_revo_surround __devinitdata = {
140 .type = SND_AK4355, 244 .type = SND_AK4355,
141 .idx_offset = 1, 245 .idx_offset = 1,
142 .num_dacs = 6, 246 .num_dacs = 6,
@@ -146,7 +250,7 @@ static struct snd_akm4xxx akm_revo_surround __devinitdata = {
146 .dac_info = revo71_surround, 250 .dac_info = revo71_surround,
147}; 251};
148 252
149static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = { 253static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
150 .caddr = 3, 254 .caddr = 3,
151 .cif = 0, 255 .cif = 0,
152 .data_mask = VT1724_REVO_CDOUT, 256 .data_mask = VT1724_REVO_CDOUT,
@@ -158,7 +262,7 @@ static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
158 .mask_flags = 0, 262 .mask_flags = 0,
159}; 263};
160 264
161static struct snd_akm4xxx akm_revo51 __devinitdata = { 265static const struct snd_akm4xxx akm_revo51 __devinitdata = {
162 .type = SND_AK4358, 266 .type = SND_AK4358,
163 .num_dacs = 6, 267 .num_dacs = 6,
164 .ops = { 268 .ops = {
@@ -167,36 +271,213 @@ static struct snd_akm4xxx akm_revo51 __devinitdata = {
167 .dac_info = revo51_dac, 271 .dac_info = revo51_dac,
168}; 272};
169 273
170static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = { 274static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
171 .caddr = 2, 275 .caddr = 2,
172 .cif = 0, 276 .cif = 0,
173 .data_mask = VT1724_REVO_CDOUT, 277 .data_mask = VT1724_REVO_CDOUT,
174 .clk_mask = VT1724_REVO_CCLK, 278 .clk_mask = VT1724_REVO_CCLK,
175 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2, 279 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1,
176 .cs_addr = VT1724_REVO_CS1 | VT1724_REVO_CS2, 280 .cs_addr = VT1724_REVO_CS1,
177 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2, 281 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1,
178 .add_flags = VT1724_REVO_CCLK, /* high at init */ 282 .add_flags = VT1724_REVO_CCLK, /* high at init */
179 .mask_flags = 0, 283 .mask_flags = 0,
180}; 284};
181 285
182static struct snd_akm4xxx akm_revo51_adc __devinitdata = { 286static const struct snd_akm4xxx akm_revo51_adc __devinitdata = {
183 .type = SND_AK5365, 287 .type = SND_AK5365,
184 .num_adcs = 2, 288 .num_adcs = 2,
185 .adc_info = revo51_adc, 289 .adc_info = revo51_adc,
186}; 290};
187 291
188static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = { 292static const struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
189 .caddr = 2, 293 .caddr = 2,
190 .cif = 0, 294 .cif = 0,
191 .data_mask = VT1724_REVO_CDOUT, 295 .data_mask = VT1724_REVO_CDOUT,
192 .clk_mask = VT1724_REVO_CCLK, 296 .clk_mask = VT1724_REVO_CCLK,
193 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2, 297 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1,
194 .cs_addr = VT1724_REVO_CS0 | VT1724_REVO_CS2, 298 .cs_addr = VT1724_REVO_CS0,
195 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2, 299 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1,
300 .add_flags = VT1724_REVO_CCLK, /* high at init */
301 .mask_flags = 0,
302};
303
304static struct snd_pt2258 ptc_revo51_volume;
305
306/* AK4358 for AP192 DAC, AK5385A for ADC */
307static void ap192_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
308{
309 struct snd_ice1712 *ice = ak->private_data[0];
310
311 revo_set_rate_val(ak, rate);
312
313#if 1 /* FIXME: do we need this procedure? */
314 /* reset DFS pin of AK5385A for ADC, too */
315 /* DFS0 (pin 18) -- GPIO10 pin 77 */
316 snd_ice1712_save_gpio_status(ice);
317 snd_ice1712_gpio_write_bits(ice, 1 << 10,
318 rate > 48000 ? (1 << 10) : 0);
319 snd_ice1712_restore_gpio_status(ice);
320#endif
321}
322
323static const struct snd_akm4xxx_dac_channel ap192_dac[] = {
324 AK_DAC("PCM Playback Volume", 2)
325};
326
327static const struct snd_akm4xxx akm_ap192 __devinitdata = {
328 .type = SND_AK4358,
329 .num_dacs = 2,
330 .ops = {
331 .set_rate_val = ap192_set_rate_val
332 },
333 .dac_info = ap192_dac,
334};
335
336static const struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
337 .caddr = 2,
338 .cif = 0,
339 .data_mask = VT1724_REVO_CDOUT,
340 .clk_mask = VT1724_REVO_CCLK,
341 .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS3,
342 .cs_addr = VT1724_REVO_CS3,
343 .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS3,
196 .add_flags = VT1724_REVO_CCLK, /* high at init */ 344 .add_flags = VT1724_REVO_CCLK, /* high at init */
197 .mask_flags = 0, 345 .mask_flags = 0,
198}; 346};
199 347
348#if 0
349/* FIXME: ak4114 makes the sound much lower due to some confliction,
350 * so let's disable it right now...
351 */
352#define BUILD_AK4114_AP192
353#endif
354
355#ifdef BUILD_AK4114_AP192
356/* AK4114 support on Audiophile 192 */
357/* CDTO (pin 32) -- GPIO2 pin 52
358 * CDTI (pin 33) -- GPIO3 pin 53 (shared with AK4358)
359 * CCLK (pin 34) -- GPIO1 pin 51 (shared with AK4358)
360 * CSN (pin 35) -- GPIO7 pin 59
361 */
362#define AK4114_ADDR 0x00
363
364static void write_data(struct snd_ice1712 *ice, unsigned int gpio,
365 unsigned int data, int idx)
366{
367 for (; idx >= 0; idx--) {
368 /* drop clock */
369 gpio &= ~VT1724_REVO_CCLK;
370 snd_ice1712_gpio_write(ice, gpio);
371 udelay(1);
372 /* set data */
373 if (data & (1 << idx))
374 gpio |= VT1724_REVO_CDOUT;
375 else
376 gpio &= ~VT1724_REVO_CDOUT;
377 snd_ice1712_gpio_write(ice, gpio);
378 udelay(1);
379 /* raise clock */
380 gpio |= VT1724_REVO_CCLK;
381 snd_ice1712_gpio_write(ice, gpio);
382 udelay(1);
383 }
384}
385
386static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
387 int idx)
388{
389 unsigned char data = 0;
390
391 for (; idx >= 0; idx--) {
392 /* drop clock */
393 gpio &= ~VT1724_REVO_CCLK;
394 snd_ice1712_gpio_write(ice, gpio);
395 udelay(1);
396 /* read data */
397 if (snd_ice1712_gpio_read(ice) & VT1724_REVO_CDIN)
398 data |= (1 << idx);
399 udelay(1);
400 /* raise clock */
401 gpio |= VT1724_REVO_CCLK;
402 snd_ice1712_gpio_write(ice, gpio);
403 udelay(1);
404 }
405 return data;
406}
407
408static unsigned char ap192_4wire_start(struct snd_ice1712 *ice)
409{
410 unsigned int tmp;
411
412 snd_ice1712_save_gpio_status(ice);
413 tmp = snd_ice1712_gpio_read(ice);
414 tmp |= VT1724_REVO_CCLK; /* high at init */
415 tmp |= VT1724_REVO_CS0;
416 tmp &= ~VT1724_REVO_CS3;
417 snd_ice1712_gpio_write(ice, tmp);
418 udelay(1);
419 return tmp;
420}
421
422static void ap192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp)
423{
424 tmp |= VT1724_REVO_CS3;
425 tmp |= VT1724_REVO_CS0;
426 snd_ice1712_gpio_write(ice, tmp);
427 udelay(1);
428 snd_ice1712_restore_gpio_status(ice);
429}
430
431static void ap192_ak4114_write(void *private_data, unsigned char addr,
432 unsigned char data)
433{
434 struct snd_ice1712 *ice = private_data;
435 unsigned int tmp, addrdata;
436
437 tmp = ap192_4wire_start(ice);
438 addrdata = (AK4114_ADDR << 6) | 0x20 | (addr & 0x1f);
439 addrdata = (addrdata << 8) | data;
440 write_data(ice, tmp, addrdata, 15);
441 ap192_4wire_finish(ice, tmp);
442}
443
444static unsigned char ap192_ak4114_read(void *private_data, unsigned char addr)
445{
446 struct snd_ice1712 *ice = private_data;
447 unsigned int tmp;
448 unsigned char data;
449
450 tmp = ap192_4wire_start(ice);
451 write_data(ice, tmp, (AK4114_ADDR << 6) | (addr & 0x1f), 7);
452 data = read_data(ice, tmp, 7);
453 ap192_4wire_finish(ice, tmp);
454 return data;
455}
456
457static int ap192_ak4114_init(struct snd_ice1712 *ice)
458{
459 static const unsigned char ak4114_init_vals[] = {
460 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
461 AK4114_DIF_I24I2S,
462 AK4114_TX1E,
463 AK4114_EFH_1024 | AK4114_DIT | AK4114_IPS(1),
464 0,
465 0
466 };
467 static const unsigned char ak4114_init_txcsb[] = {
468 0x41, 0x02, 0x2c, 0x00, 0x00
469 };
470 struct ak4114 *ak;
471 int err;
472
473 return snd_ak4114_create(ice->card,
474 ap192_ak4114_read,
475 ap192_ak4114_write,
476 ak4114_init_vals, ak4114_init_txcsb,
477 ice, &ak);
478}
479#endif /* BUILD_AK4114_AP192 */
480
200static int __devinit revo_init(struct snd_ice1712 *ice) 481static int __devinit revo_init(struct snd_ice1712 *ice)
201{ 482{
202 struct snd_akm4xxx *ak; 483 struct snd_akm4xxx *ak;
@@ -213,6 +494,10 @@ static int __devinit revo_init(struct snd_ice1712 *ice)
213 ice->num_total_dacs = 6; 494 ice->num_total_dacs = 6;
214 ice->num_total_adcs = 2; 495 ice->num_total_adcs = 2;
215 break; 496 break;
497 case VT1724_SUBDEVICE_AUDIOPHILE192:
498 ice->num_total_dacs = 2;
499 ice->num_total_adcs = 2;
500 break;
216 default: 501 default:
217 snd_BUG(); 502 snd_BUG();
218 return -EINVAL; 503 return -EINVAL;
@@ -235,14 +520,28 @@ static int __devinit revo_init(struct snd_ice1712 *ice)
235 break; 520 break;
236 case VT1724_SUBDEVICE_REVOLUTION51: 521 case VT1724_SUBDEVICE_REVOLUTION51:
237 ice->akm_codecs = 2; 522 ice->akm_codecs = 2;
238 if ((err = snd_ice1712_akm4xxx_init(ak, &akm_revo51, &akm_revo51_priv, ice)) < 0) 523 err = snd_ice1712_akm4xxx_init(ak, &akm_revo51,
524 &akm_revo51_priv, ice);
525 if (err < 0)
239 return err; 526 return err;
240 err = snd_ice1712_akm4xxx_init(ak + 1, &akm_revo51_adc, 527 err = snd_ice1712_akm4xxx_init(ak+1, &akm_revo51_adc,
241 &akm_revo51_adc_priv, ice); 528 &akm_revo51_adc_priv, ice);
242 if (err < 0) 529 if (err < 0)
243 return err; 530 return err;
244 /* unmute all codecs - needed! */ 531 err = revo51_i2c_init(ice, &ptc_revo51_volume);
245 snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE, VT1724_REVO_MUTE); 532 if (err < 0)
533 return err;
534 /* unmute all codecs */
535 snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE,
536 VT1724_REVO_MUTE);
537 break;
538 case VT1724_SUBDEVICE_AUDIOPHILE192:
539 ice->akm_codecs = 1;
540 err = snd_ice1712_akm4xxx_init(ak, &akm_ap192, &akm_ap192_priv,
541 ice);
542 if (err < 0)
543 return err;
544
246 break; 545 break;
247 } 546 }
248 547
@@ -256,16 +555,34 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice)
256 555
257 switch (ice->eeprom.subvendor) { 556 switch (ice->eeprom.subvendor) {
258 case VT1724_SUBDEVICE_REVOLUTION71: 557 case VT1724_SUBDEVICE_REVOLUTION71:
558 err = snd_ice1712_akm4xxx_build_controls(ice);
559 if (err < 0)
560 return err;
561 break;
259 case VT1724_SUBDEVICE_REVOLUTION51: 562 case VT1724_SUBDEVICE_REVOLUTION51:
260 err = snd_ice1712_akm4xxx_build_controls(ice); 563 err = snd_ice1712_akm4xxx_build_controls(ice);
261 if (err < 0) 564 if (err < 0)
262 return err; 565 return err;
566 err = snd_pt2258_build_controls(ice->spec.revo51.pt2258);
567 if (err < 0)
568 return err;
569 break;
570 case VT1724_SUBDEVICE_AUDIOPHILE192:
571 err = snd_ice1712_akm4xxx_build_controls(ice);
572 if (err < 0)
573 return err;
574#ifdef BUILD_AK4114_AP192
575 err = ap192_ak4114_init(ice);
576 if (err < 0)
577 return err;
578#endif
579 break;
263 } 580 }
264 return 0; 581 return 0;
265} 582}
266 583
267/* entry point */ 584/* entry point */
268struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = { 585const struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
269 { 586 {
270 .subvendor = VT1724_SUBDEVICE_REVOLUTION71, 587 .subvendor = VT1724_SUBDEVICE_REVOLUTION71,
271 .name = "M Audio Revolution-7.1", 588 .name = "M Audio Revolution-7.1",
@@ -280,5 +597,12 @@ struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
280 .chip_init = revo_init, 597 .chip_init = revo_init,
281 .build_controls = revo_add_controls, 598 .build_controls = revo_add_controls,
282 }, 599 },
600 {
601 .subvendor = VT1724_SUBDEVICE_AUDIOPHILE192,
602 .name = "M Audio Audiophile192",
603 .model = "ap192",
604 .chip_init = revo_init,
605 .build_controls = revo_add_controls,
606 },
283 { } /* terminator */ 607 { } /* terminator */
284}; 608};