amp.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * ALSA driver for ICEnsemble VT1724 (Envy24HT)
  4. *
  5. * Lowlevel functions for Advanced Micro Peripherals Ltd AUDIO2000
  6. *
  7. * Copyright (c) 2000 Jaroslav Kysela <[email protected]>
  8. */
  9. #include <linux/delay.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/init.h>
  12. #include <sound/core.h>
  13. #include "ice1712.h"
  14. #include "envy24ht.h"
  15. #include "amp.h"
  16. static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val)
  17. {
  18. unsigned short cval;
  19. cval = (reg << 9) | val;
  20. snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff);
  21. }
  22. static int snd_vt1724_amp_init(struct snd_ice1712 *ice)
  23. {
  24. static const unsigned short wm_inits[] = {
  25. WM_ATTEN_L, 0x0000, /* 0 db */
  26. WM_ATTEN_R, 0x0000, /* 0 db */
  27. WM_DAC_CTRL, 0x0008, /* 24bit I2S */
  28. WM_INT_CTRL, 0x0001, /* 24bit I2S */
  29. };
  30. unsigned int i;
  31. /* only use basic functionality for now */
  32. /* VT1616 6ch codec connected to PSDOUT0 using packed mode */
  33. ice->num_total_dacs = 6;
  34. ice->num_total_adcs = 2;
  35. /* Chaintech AV-710 has another WM8728 codec connected to PSDOUT4
  36. (shared with the SPDIF output). Mixer control for this codec
  37. is not yet supported. */
  38. if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AV710) {
  39. for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2)
  40. wm_put(ice, wm_inits[i], wm_inits[i+1]);
  41. }
  42. return 0;
  43. }
  44. static int snd_vt1724_amp_add_controls(struct snd_ice1712 *ice)
  45. {
  46. if (ice->ac97)
  47. /* we use pins 39 and 41 of the VT1616 for left and right
  48. read outputs */
  49. snd_ac97_write_cache(ice->ac97, 0x5a,
  50. snd_ac97_read(ice->ac97, 0x5a) & ~0x8000);
  51. return 0;
  52. }
  53. /* entry point */
  54. struct snd_ice1712_card_info snd_vt1724_amp_cards[] = {
  55. {
  56. .subvendor = VT1724_SUBDEVICE_AV710,
  57. .name = "Chaintech AV-710",
  58. .model = "av710",
  59. .chip_init = snd_vt1724_amp_init,
  60. .build_controls = snd_vt1724_amp_add_controls,
  61. },
  62. {
  63. .subvendor = VT1724_SUBDEVICE_AUDIO2000,
  64. .name = "AMP Ltd AUDIO2000",
  65. .model = "amp2000",
  66. .chip_init = snd_vt1724_amp_init,
  67. .build_controls = snd_vt1724_amp_add_controls,
  68. },
  69. { } /* terminator */
  70. };