ac97_patch.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  4. * Universal interface for Audio Codec '97
  5. *
  6. * For more details look to AC '97 component specification revision 2.2
  7. * by Intel Corporation (http://developer.intel.com).
  8. */
  9. #define AC97_SINGLE_VALUE(reg,shift,mask,invert) \
  10. ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | \
  11. ((invert) << 24))
  12. #define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) \
  13. (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26))
  14. #define AC97_SINGLE(xname, reg, shift, mask, invert) \
  15. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  16. .info = snd_ac97_info_volsw, \
  17. .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
  18. .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) }
  19. #define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \
  20. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  21. .info = snd_ac97_info_volsw, \
  22. .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
  23. .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) }
  24. #define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
  25. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  26. .info = snd_ac97_info_volsw, \
  27. .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
  28. .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
  29. /* enum control */
  30. struct ac97_enum {
  31. unsigned char reg;
  32. unsigned char shift_l;
  33. unsigned char shift_r;
  34. unsigned short mask;
  35. const char * const *texts;
  36. };
  37. #define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
  38. { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
  39. .mask = xmask, .texts = xtexts }
  40. #define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
  41. AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
  42. #define AC97_ENUM(xname, xenum) \
  43. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  44. .info = snd_ac97_info_enum_double, \
  45. .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
  46. .private_value = (unsigned long)&xenum }
  47. /* ac97_codec.c */
  48. static const struct snd_kcontrol_new snd_ac97_controls_3d[];
  49. static const struct snd_kcontrol_new snd_ac97_controls_spdif[];
  50. static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template,
  51. struct snd_ac97 * ac97);
  52. static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol,
  53. struct snd_ctl_elem_info *uinfo);
  54. static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol,
  55. struct snd_ctl_elem_value *ucontrol);
  56. static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol,
  57. struct snd_ctl_elem_value *ucontrol);
  58. static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit);
  59. static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name,
  60. const char *suffix);
  61. static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src,
  62. const char *dst, const char *suffix);
  63. static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1,
  64. const char *s2, const char *suffix);
  65. static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src,
  66. const char *dst);
  67. #ifdef CONFIG_PM
  68. static void snd_ac97_restore_status(struct snd_ac97 *ac97);
  69. static void snd_ac97_restore_iec958(struct snd_ac97 *ac97);
  70. #endif
  71. static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol,
  72. struct snd_ctl_elem_info *uinfo);
  73. static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol,
  74. struct snd_ctl_elem_value *ucontrol);
  75. static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol,
  76. struct snd_ctl_elem_value *ucontrol);