aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorPavel Hofman <dustin@seznam.cz>2007-04-10 05:39:58 -0400
committerJaroslav Kysela <perex@suse.cz>2007-05-11 10:55:58 -0400
commit7d4b4380d37025f0b13ae951e0cb2ff7184dc5bb (patch)
treed5681ff78c23376cec9263748ce565453f59e3cb /sound/pci
parentf06934bd3cf773c297683d1345bf61c7807d7e75 (diff)
[ALSA] ice1724 - Functioning support for Prodigy 192
Fixes: -------- * correct card specific ice1724 initialization * working IEC958 output of the card * renamed capture controls New features: ------------------ * analog input switch (line-in/mic) * optional ak4114 based MI/ODI/O card detection & support: IEC958 input, digital input switch (toslink/coax) Unresolved issues ----------------------- * Analog and digital input enums are listed on playback panel of alsamixer, I do not know how to push them onto the capture one. Signed-off-by: Pavel Hofman <dustin@seznam.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/ice1712/ice1712.h3
-rw-r--r--sound/pci/ice1712/prodigy192.c344
-rw-r--r--sound/pci/ice1712/prodigy192.h8
3 files changed, 349 insertions, 6 deletions
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
index c3d9feaaf57d..6ac486d9c138 100644
--- a/sound/pci/ice1712/ice1712.h
+++ b/sound/pci/ice1712/ice1712.h
@@ -397,6 +397,9 @@ struct snd_ice1712 {
397 struct ak4114 *ak4114; 397 struct ak4114 *ak4114;
398 unsigned int analog: 1; 398 unsigned int analog: 1;
399 } juli; 399 } juli;
400 struct {
401 struct ak4114 *ak4114;
402 } prodigy192;
400 } spec; 403 } spec;
401 404
402}; 405};
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index 9aad6b38e2b2..ae08a079a413 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -2,6 +2,30 @@
2 * ALSA driver for ICEnsemble VT1724 (Envy24HT) 2 * ALSA driver for ICEnsemble VT1724 (Envy24HT)
3 * 3 *
4 * Lowlevel functions for AudioTrak Prodigy 192 cards 4 * Lowlevel functions for AudioTrak Prodigy 192 cards
5 * Supported IEC958 input from optional MI/ODI/O add-on card.
6 *
7 * Specifics (SW, HW):
8 * -------------------
9 * * 49.5MHz crystal
10 * * SPDIF-OUT on the card:
11 * - coax (through isolation transformer)/toslink supplied by
12 * 74HC04 gates - 3 in parallel
13 * - output switched between on-board CD drive dig-out connector
14 * and ice1724 SPDTX pin, using 74HC02 NOR gates, controlled
15 * by GPIO20 (0 = CD dig-out, 1 = SPDTX)
16 * * SPDTX goes straight to MI/ODI/O card's SPDIF-OUT coax
17 *
18 * * MI/ODI/O card: AK4114 based, used for iec958 input only
19 * - toslink input -> RX0
20 * - coax input -> RX1
21 * - 4wire protocol:
22 * AK4114 ICE1724
23 * ------------------------------
24 * CDTO (pin 32) -- GPIO11 pin 86
25 * CDTI (pin 33) -- GPIO10 pin 77
26 * CCLK (pin 34) -- GPIO9 pin 76
27 * CSN (pin 35) -- GPIO8 pin 75
28 * - output data Mode 7 (24bit, I2S, slave)
5 * 29 *
6 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de> 30 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
7 * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca> 31 * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca>
@@ -356,6 +380,47 @@ static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl
356 return 0; 380 return 0;
357} 381}
358#endif 382#endif
383static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo)
385{
386 static char *texts[2] = { "Line In", "Mic" };
387
388 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
389 uinfo->count = 1;
390 uinfo->value.enumerated.items = 2;
391
392 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
393 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
394 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
395
396 return 0;
397}
398
399
400static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol,
401 struct snd_ctl_elem_value *ucontrol)
402{
403 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
404 unsigned char val;
405
406 val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
407 ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1;
408 return 0;
409}
410
411static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
412 struct snd_ctl_elem_value *ucontrol)
413{
414 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
415 unsigned char new, old;
416 int change;
417 old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
418 new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80);
419 change = (new != old);
420 if (change)
421 stac9460_put(ice, STAC946X_GENERAL_PURPOSE, new);
422 return change;
423}
359 424
360static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0); 425static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0);
361static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0); 426static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
@@ -406,7 +471,7 @@ static struct snd_kcontrol_new stac_controls[] __devinitdata = {
406 }, 471 },
407 { 472 {
408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
409 .name = "ADC Switch", 474 .name = "ADC Capture Switch",
410 .count = 1, 475 .count = 1,
411 .info = stac9460_adc_mute_info, 476 .info = stac9460_adc_mute_info,
412 .get = stac9460_adc_mute_get, 477 .get = stac9460_adc_mute_get,
@@ -417,13 +482,21 @@ static struct snd_kcontrol_new stac_controls[] __devinitdata = {
417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 482 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
418 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 483 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
419 SNDRV_CTL_ELEM_ACCESS_TLV_READ), 484 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
420 .name = "ADC Volume", 485 .name = "ADC Capture Volume",
421 .count = 1, 486 .count = 1,
422 .info = stac9460_adc_vol_info, 487 .info = stac9460_adc_vol_info,
423 .get = stac9460_adc_vol_get, 488 .get = stac9460_adc_vol_get,
424 .put = stac9460_adc_vol_put, 489 .put = stac9460_adc_vol_put,
425 .tlv = { .p = db_scale_adc } 490 .tlv = { .p = db_scale_adc }
426 }, 491 },
492 {
493 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
494 .name = "Analog Capture Input",
495 .info = stac9460_mic_sw_info,
496 .get = stac9460_mic_sw_get,
497 .put = stac9460_mic_sw_put,
498
499 },
427#if 0 500#if 0
428 { 501 {
429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -456,19 +529,258 @@ static struct snd_kcontrol_new stac_controls[] __devinitdata = {
456#endif 529#endif
457}; 530};
458 531
532
533/* AK4114 - ICE1724 connections on Prodigy192 + MI/ODI/O */
534/* CDTO (pin 32) -- GPIO11 pin 86
535 * CDTI (pin 33) -- GPIO10 pin 77
536 * CCLK (pin 34) -- GPIO9 pin 76
537 * CSN (pin 35) -- GPIO8 pin 75
538 */
539#define AK4114_ADDR 0x00 /* C1-C0: Chip Address
540 * (According to datasheet fixed to “00”)
541 */
542
543/*
544 * 4wire ak4114 protocol - writing data
545 */
546static void write_data(struct snd_ice1712 *ice, unsigned int gpio,
547 unsigned int data, int idx)
548{
549 for (; idx >= 0; idx--) {
550 /* drop clock */
551 gpio &= ~VT1724_PRODIGY192_CCLK;
552 snd_ice1712_gpio_write(ice, gpio);
553 udelay(1);
554 /* set data */
555 if (data & (1 << idx))
556 gpio |= VT1724_PRODIGY192_CDOUT;
557 else
558 gpio &= ~VT1724_PRODIGY192_CDOUT;
559 snd_ice1712_gpio_write(ice, gpio);
560 udelay(1);
561 /* raise clock */
562 gpio |= VT1724_PRODIGY192_CCLK;
563 snd_ice1712_gpio_write(ice, gpio);
564 udelay(1);
565 }
566}
567
568/*
569 * 4wire ak4114 protocol - reading data
570 */
571static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
572 int idx)
573{
574 unsigned char data = 0;
575
576 for (; idx >= 0; idx--) {
577 /* drop clock */
578 gpio &= ~VT1724_PRODIGY192_CCLK;
579 snd_ice1712_gpio_write(ice, gpio);
580 udelay(1);
581 /* read data */
582 if (snd_ice1712_gpio_read(ice) & VT1724_PRODIGY192_CDIN)
583 data |= (1 << idx);
584 udelay(1);
585 /* raise clock */
586 gpio |= VT1724_PRODIGY192_CCLK;
587 snd_ice1712_gpio_write(ice, gpio);
588 udelay(1);
589 }
590 return data;
591}
592/*
593 * 4wire ak4114 protocol - starting sequence
594 */
595static unsigned int prodigy192_4wire_start(struct snd_ice1712 *ice)
596{
597 unsigned int tmp;
598
599 snd_ice1712_save_gpio_status(ice);
600 tmp = snd_ice1712_gpio_read(ice);
601
602 tmp |= VT1724_PRODIGY192_CCLK; /* high at init */
603 tmp &= ~VT1724_PRODIGY192_CS; /* drop chip select */
604 snd_ice1712_gpio_write(ice, tmp);
605 udelay(1);
606 return tmp;
607}
608
609/*
610 * 4wire ak4114 protocol - final sequence
611 */
612static void prodigy192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp)
613{
614 tmp |= VT1724_PRODIGY192_CS; /* raise chip select */
615 snd_ice1712_gpio_write(ice, tmp);
616 udelay(1);
617 snd_ice1712_restore_gpio_status(ice);
618}
619
620/*
621 * Write data to addr register of ak4114
622 */
623static void prodigy192_ak4114_write(void *private_data, unsigned char addr,
624 unsigned char data)
625{
626 struct snd_ice1712 *ice = private_data;
627 unsigned int tmp, addrdata;
628 tmp = prodigy192_4wire_start(ice);
629 addrdata = (AK4114_ADDR << 6) | 0x20 | (addr & 0x1f);
630 addrdata = (addrdata << 8) | data;
631 write_data(ice, tmp, addrdata, 15);
632 prodigy192_4wire_finish(ice, tmp);
633}
634
635/*
636 * Read data from addr register of ak4114
637 */
638static unsigned char prodigy192_ak4114_read(void *private_data,
639 unsigned char addr)
640{
641 struct snd_ice1712 *ice = private_data;
642 unsigned int tmp;
643 unsigned char data;
644
645 tmp = prodigy192_4wire_start(ice);
646 write_data(ice, tmp, (AK4114_ADDR << 6) | (addr & 0x1f), 7);
647 data = read_data(ice, tmp, 7);
648 prodigy192_4wire_finish(ice, tmp);
649 return data;
650}
651
652
653static int ak4114_input_sw_info(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_info *uinfo)
655{
656 static char *texts[2] = { "Toslink", "Coax" };
657
658 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
659 uinfo->count = 1;
660 uinfo->value.enumerated.items = 2;
661 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
662 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
663 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
664 return 0;
665}
666
667
668static int ak4114_input_sw_get(struct snd_kcontrol *kcontrol,
669 struct snd_ctl_elem_value *ucontrol)
670{
671 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
672 unsigned char val;
673
674 val = prodigy192_ak4114_read(ice, AK4114_REG_IO1);
675 /* AK4114_IPS0 bit = 0 -> RX0 = Toslink
676 * AK4114_IPS0 bit = 1 -> RX1 = Coax
677 */
678 ucontrol->value.enumerated.item[0] = (val & AK4114_IPS0) ? 1 : 0;
679 return 0;
680}
681
682static int ak4114_input_sw_put(struct snd_kcontrol *kcontrol,
683 struct snd_ctl_elem_value *ucontrol)
684{
685 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
686 unsigned char new, old, itemvalue;
687 int change;
688
689 old = prodigy192_ak4114_read(ice, AK4114_REG_IO1);
690 /* AK4114_IPS0 could be any bit */
691 itemvalue = (ucontrol->value.enumerated.item[0]) ? 0xff : 0x00;
692
693 new = (itemvalue & AK4114_IPS0) | (old & ~AK4114_IPS0);
694 change = (new != old);
695 if (change)
696 prodigy192_ak4114_write(ice, AK4114_REG_IO1, new);
697 return change;
698}
699
700
701static const struct snd_kcontrol_new ak4114_controls[] __devinitdata = {
702 {
703 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
704 .name = "MIODIO IEC958 Capture Input",
705 .info = ak4114_input_sw_info,
706 .get = ak4114_input_sw_get,
707 .put = ak4114_input_sw_put,
708
709 }
710};
711
712
713static int prodigy192_ak4114_init(struct snd_ice1712 *ice)
714{
715 static const unsigned char ak4114_init_vals[] = {
716 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
717 AK4114_DIF_I24I2S, /* ice1724 expects I2S and provides clock */
718 AK4114_TX1E,
719 AK4114_EFH_1024 | AK4114_DIT, /* default input RX0 */
720 0,
721 0
722 };
723 static const unsigned char ak4114_init_txcsb[] = {
724 0x41, 0x02, 0x2c, 0x00, 0x00
725 };
726
727 return snd_ak4114_create(ice->card,
728 prodigy192_ak4114_read,
729 prodigy192_ak4114_write,
730 ak4114_init_vals, ak4114_init_txcsb,
731 ice, &ice->spec.prodigy192.ak4114);
732}
733
459static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice) 734static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice)
460{ 735{
461 unsigned int i; 736 unsigned int i;
462 int err; 737 int err;
463 738
464 for (i = 0; i < ARRAY_SIZE(stac_controls); i++) { 739 for (i = 0; i < ARRAY_SIZE(stac_controls); i++) {
465 err = snd_ctl_add(ice->card, snd_ctl_new1(&stac_controls[i], ice)); 740 err = snd_ctl_add(ice->card,
741 snd_ctl_new1(&stac_controls[i], ice));
742 if (err < 0)
743 return err;
744 }
745 if (ice->spec.prodigy192.ak4114) {
746 /* ak4114 is connected */
747 for (i = 0; i < ARRAY_SIZE(ak4114_controls); i++) {
748 err = snd_ctl_add(ice->card,
749 snd_ctl_new1(&ak4114_controls[i],
750 ice));
751 if (err < 0)
752 return err;
753 }
754 err = snd_ak4114_build(ice->spec.prodigy192.ak4114,
755 NULL, /* ak4114 in MIO/DI/O handles no IEC958 output */
756 ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
466 if (err < 0) 757 if (err < 0)
467 return err; 758 return err;
468 } 759 }
469 return 0; 760 return 0;
470} 761}
471 762
763/*
764 * check for presence of MI/ODI/O add-on card with digital inputs
765 */
766static int prodigy192_miodio_exists(struct snd_ice1712 *ice)
767{
768
769 unsigned char orig_value;
770 const unsigned char test_data = 0xd1; /* random value */
771 unsigned char addr = AK4114_REG_INT0_MASK; /* random SAFE address */
772 int exists = 0;
773
774 orig_value = prodigy192_ak4114_read(ice, addr);
775 prodigy192_ak4114_write(ice, addr, test_data);
776 if (prodigy192_ak4114_read(ice, addr) == test_data) {
777 /* ak4114 seems to communicate, apparently exists */
778 /* writing back original value */
779 prodigy192_ak4114_write(ice, addr, orig_value);
780 exists = 1;
781 }
782 return exists;
783}
472 784
473/* 785/*
474 * initialize the chip 786 * initialize the chip
@@ -487,16 +799,30 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
487 (unsigned short)-1 799 (unsigned short)-1
488 }; 800 };
489 const unsigned short *p; 801 const unsigned short *p;
802 int err = 0;
490 803
491 /* prodigy 192 */ 804 /* prodigy 192 */
492 ice->num_total_dacs = 6; 805 ice->num_total_dacs = 6;
493 ice->num_total_adcs = 2; 806 ice->num_total_adcs = 2;
807 ice->vt1720 = 0; /* ice1724, e.g. 23 GPIOs */
494 808
495 /* initialize codec */ 809 /* initialize codec */
496 p = stac_inits_prodigy; 810 p = stac_inits_prodigy;
497 for (; *p != (unsigned short)-1; p += 2) 811 for (; *p != (unsigned short)-1; p += 2)
498 stac9460_put(ice, p[0], p[1]); 812 stac9460_put(ice, p[0], p[1]);
499 813
814 /* MI/ODI/O add on card with AK4114 */
815 if (prodigy192_miodio_exists(ice)) {
816 err = prodigy192_ak4114_init(ice);
817 /* from this moment if err = 0 then
818 * ice->spec.prodigy192.ak4114 should not be null
819 */
820 snd_printdd("AK4114 initialized with status %d\n", err);
821 } else
822 snd_printdd("AK4114 not found\n");
823 if (err < 0)
824 return err;
825
500 return 0; 826 return 0;
501} 827}
502 828
@@ -507,19 +833,25 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
507 */ 833 */
508 834
509static unsigned char prodigy71_eeprom[] __devinitdata = { 835static unsigned char prodigy71_eeprom[] __devinitdata = {
510 [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, spdif-in/ADC, 4DACs */ 836 [ICE_EEP2_SYSCONF] = 0x6a, /* 49MHz crystal, mpu401,
837 * spdif-in+ 1 stereo ADC,
838 * 3 stereo DACs
839 */
511 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 840 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
512 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 841 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
513 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */ 842 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
514 [ICE_EEP2_GPIO_DIR] = 0xff, 843 [ICE_EEP2_GPIO_DIR] = 0xff,
515 [ICE_EEP2_GPIO_DIR1] = 0xff, 844 [ICE_EEP2_GPIO_DIR1] = ~(VT1724_PRODIGY192_CDIN >> 8) ,
516 [ICE_EEP2_GPIO_DIR2] = 0xbf, 845 [ICE_EEP2_GPIO_DIR2] = 0xbf,
517 [ICE_EEP2_GPIO_MASK] = 0x00, 846 [ICE_EEP2_GPIO_MASK] = 0x00,
518 [ICE_EEP2_GPIO_MASK1] = 0x00, 847 [ICE_EEP2_GPIO_MASK1] = 0x00,
519 [ICE_EEP2_GPIO_MASK2] = 0x00, 848 [ICE_EEP2_GPIO_MASK2] = 0x00,
520 [ICE_EEP2_GPIO_STATE] = 0x00, 849 [ICE_EEP2_GPIO_STATE] = 0x00,
521 [ICE_EEP2_GPIO_STATE1] = 0x00, 850 [ICE_EEP2_GPIO_STATE1] = 0x00,
522 [ICE_EEP2_GPIO_STATE2] = 0x00, 851 [ICE_EEP2_GPIO_STATE2] = 0x10, /* GPIO20: 0 = CD drive dig. input
852 * passthrough,
853 * 1 = SPDIF-OUT from ice1724
854 */
523}; 855};
524 856
525 857
diff --git a/sound/pci/ice1712/prodigy192.h b/sound/pci/ice1712/prodigy192.h
index 94c824e24e06..16a53b459c72 100644
--- a/sound/pci/ice1712/prodigy192.h
+++ b/sound/pci/ice1712/prodigy192.h
@@ -5,6 +5,14 @@
5#define PRODIGY192_STAC9460_ADDR 0x54 5#define PRODIGY192_STAC9460_ADDR 0x54
6 6
7#define VT1724_SUBDEVICE_PRODIGY192VE 0x34495345 /* PRODIGY 192 VE */ 7#define VT1724_SUBDEVICE_PRODIGY192VE 0x34495345 /* PRODIGY 192 VE */
8/*
9 * AudioTrak Prodigy192 GPIO definitions for MI/ODI/O card with
10 * AK4114 (SPDIF-IN)
11 */
12#define VT1724_PRODIGY192_CS (1 << 8) /* GPIO8, pin 75 */
13#define VT1724_PRODIGY192_CCLK (1 << 9) /* GPIO9, pin 76 */
14#define VT1724_PRODIGY192_CDOUT (1 << 10) /* GPIO10, pin 77 */
15#define VT1724_PRODIGY192_CDIN (1 << 11) /* GPIO11, pin 86 */
8 16
9extern struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[]; 17extern struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[];
10 18