ac97_local.h 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
  3. * Universal interface for Audio Codec '97
  4. *
  5. * For more details look to AC '97 component specification revision 2.2
  6. * by Intel Corporation (http://developer.intel.com).
  7. *
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #define AC97_SINGLE_VALUE(reg,shift,mask,invert) ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | ((invert) << 24))
  25. #define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26))
  26. #define AC97_SINGLE(xname, reg, shift, mask, invert) \
  27. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_volsw, \
  28. .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
  29. .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) }
  30. #define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \
  31. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_volsw, \
  32. .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
  33. .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) }
  34. #define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
  35. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .info = snd_ac97_info_volsw, \
  36. .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
  37. .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
  38. /* enum control */
  39. struct ac97_enum {
  40. unsigned char reg;
  41. unsigned char shift_l;
  42. unsigned char shift_r;
  43. unsigned short mask;
  44. const char **texts;
  45. };
  46. #define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
  47. { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
  48. .mask = xmask, .texts = xtexts }
  49. #define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
  50. AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
  51. #define AC97_ENUM(xname, xenum) \
  52. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_enum_double, \
  53. .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
  54. .private_value = (unsigned long)&xenum }
  55. /* ac97_codec.c */
  56. extern const struct snd_kcontrol_new snd_ac97_controls_3d[];
  57. extern const struct snd_kcontrol_new snd_ac97_controls_spdif[];
  58. struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97);
  59. void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, int modem);
  60. int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
  61. int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
  62. int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
  63. int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit);
  64. int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix);
  65. int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix);
  66. int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix);
  67. void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst);
  68. void snd_ac97_restore_status(struct snd_ac97 *ac97);
  69. void snd_ac97_restore_iec958(struct snd_ac97 *ac97);
  70. int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
  71. int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
  72. int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
  73. int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg,
  74. unsigned short mask, unsigned short value);
  75. /* ac97_proc.c */
  76. #ifdef CONFIG_PROC_FS
  77. void snd_ac97_bus_proc_init(struct snd_ac97_bus * ac97);
  78. void snd_ac97_bus_proc_done(struct snd_ac97_bus * ac97);
  79. void snd_ac97_proc_init(struct snd_ac97 * ac97);
  80. void snd_ac97_proc_done(struct snd_ac97 * ac97);
  81. #else
  82. #define snd_ac97_bus_proc_init(ac97_bus_t) do { } while (0)
  83. #define snd_ac97_bus_proc_done(ac97_bus_t) do { } while (0)
  84. #define snd_ac97_proc_init(ac97_t) do { } while (0)
  85. #define snd_ac97_proc_done(ac97_t) do { } while (0)
  86. #endif