phase.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * ALSA driver for ICEnsemble ICE1724 (Envy24)
  3. *
  4. * Lowlevel functions for Terratec PHASE 22
  5. *
  6. * Copyright (c) 2005 Misha Zhilin <misha@epiphan.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. /* PHASE 22 overview:
  24. * Audio controller: VIA Envy24HT-S (slightly trimmed down version of Envy24HT)
  25. * Analog chip: AK4524 (partially via Philip's 74HCT125)
  26. * Digital receiver: CS8414-CS (not supported in this release)
  27. *
  28. * Envy connects to AK4524
  29. * - CS directly from GPIO 10
  30. * - CCLK via 74HCT125's gate #4 from GPIO 4
  31. * - CDTI via 74HCT125's gate #2 from GPIO 5
  32. * CDTI may be completely blocked by 74HCT125's gate #1 controlled by GPIO 3
  33. */
  34. #include <sound/driver.h>
  35. #include <asm/io.h>
  36. #include <linux/delay.h>
  37. #include <linux/interrupt.h>
  38. #include <linux/init.h>
  39. #include <linux/slab.h>
  40. #include <sound/core.h>
  41. #include "ice1712.h"
  42. #include "envy24ht.h"
  43. #include "phase.h"
  44. static akm4xxx_t akm_phase22 __devinitdata = {
  45. .type = SND_AK4524,
  46. .num_dacs = 2,
  47. .num_adcs = 2,
  48. };
  49. static struct snd_ak4xxx_private akm_phase22_priv __devinitdata = {
  50. .caddr = 2,
  51. .cif = 1,
  52. .data_mask = 1 << 4,
  53. .clk_mask = 1 << 5,
  54. .cs_mask = 1 << 10,
  55. .cs_addr = 1 << 10,
  56. .cs_none = 0,
  57. .add_flags = 1 << 3,
  58. .mask_flags = 0,
  59. };
  60. static int __devinit phase22_init(ice1712_t *ice)
  61. {
  62. akm4xxx_t *ak;
  63. int err;
  64. // Configure DAC/ADC description for generic part of ice1724
  65. switch (ice->eeprom.subvendor) {
  66. case VT1724_SUBDEVICE_PHASE22:
  67. ice->num_total_dacs = 2;
  68. ice->num_total_adcs = 2;
  69. ice->vt1720 = 1; // Envy24HT-S have 16 bit wide GPIO
  70. break;
  71. default:
  72. snd_BUG();
  73. return -EINVAL;
  74. }
  75. // Initialize analog chips
  76. ak = ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL);
  77. if (! ak)
  78. return -ENOMEM;
  79. ice->akm_codecs = 1;
  80. switch (ice->eeprom.subvendor) {
  81. case VT1724_SUBDEVICE_PHASE22:
  82. if ((err = snd_ice1712_akm4xxx_init(ak, &akm_phase22, &akm_phase22_priv, ice)) < 0)
  83. return err;
  84. break;
  85. }
  86. return 0;
  87. }
  88. static int __devinit phase22_add_controls(ice1712_t *ice)
  89. {
  90. int err = 0;
  91. switch (ice->eeprom.subvendor) {
  92. case VT1724_SUBDEVICE_PHASE22:
  93. err = snd_ice1712_akm4xxx_build_controls(ice);
  94. if (err < 0)
  95. return err;
  96. }
  97. return 0;
  98. }
  99. static unsigned char phase22_eeprom[] __devinitdata = {
  100. 0x00, /* SYSCONF: 1xADC, 1xDACs */
  101. 0x80, /* ACLINK: I2S */
  102. 0xf8, /* I2S: vol, 96k, 24bit*/
  103. 0xc3, /* SPDIF: out-en, out-int, spdif-in */
  104. 0xFF, /* GPIO_DIR */
  105. 0xFF, /* GPIO_DIR1 */
  106. 0xFF, /* GPIO_DIR2 */
  107. 0x00, /* GPIO_MASK */
  108. 0x00, /* GPIO_MASK1 */
  109. 0x00, /* GPIO_MASK2 */
  110. 0x00, /* GPIO_STATE: */
  111. 0x00, /* GPIO_STATE1: */
  112. 0x00, /* GPIO_STATE2 */
  113. };
  114. struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = {
  115. {
  116. .subvendor = VT1724_SUBDEVICE_PHASE22,
  117. .name = "Terratec PHASE 22",
  118. .model = "phase22",
  119. .chip_init = phase22_init,
  120. .build_controls = phase22_add_controls,
  121. .eeprom_size = sizeof(phase22_eeprom),
  122. .eeprom_data = phase22_eeprom,
  123. },
  124. { } /* terminator */
  125. };