ak4xxx-adda.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef __SOUND_AK4XXX_ADDA_H
  2. #define __SOUND_AK4XXX_ADDA_H
  3. /*
  4. * ALSA driver for AK4524 / AK4528 / AK4529 / AK4355 / AK4381
  5. * AD and DA converters
  6. *
  7. * Copyright (c) 2000 Jaroslav Kysela <perex@suse.cz>
  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. #ifndef AK4XXX_MAX_CHIPS
  25. #define AK4XXX_MAX_CHIPS 4
  26. #endif
  27. struct snd_akm4xxx;
  28. struct snd_ak4xxx_ops {
  29. void (*lock)(struct snd_akm4xxx *ak, int chip);
  30. void (*unlock)(struct snd_akm4xxx *ak, int chip);
  31. void (*write)(struct snd_akm4xxx *ak, int chip, unsigned char reg,
  32. unsigned char val);
  33. void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate);
  34. };
  35. #define AK4XXX_IMAGE_SIZE (AK4XXX_MAX_CHIPS * 16) /* 64 bytes */
  36. /* DAC label and channels */
  37. struct snd_akm4xxx_dac_channel {
  38. char *name; /* mixer volume name */
  39. unsigned int num_channels;
  40. char *switch_name; /* mixer switch*/
  41. };
  42. /* ADC labels and channels */
  43. struct snd_akm4xxx_adc_channel {
  44. char *name; /* capture gain volume label */
  45. char *switch_name; /* capture switch */
  46. unsigned int num_channels;
  47. char *selector_name; /* capture source select label */
  48. const char **input_names; /* capture source names (NULL terminated) */
  49. };
  50. struct snd_akm4xxx {
  51. struct snd_card *card;
  52. unsigned int num_adcs; /* AK4524 or AK4528 ADCs */
  53. unsigned int num_dacs; /* AK4524 or AK4528 DACs */
  54. unsigned char images[AK4XXX_IMAGE_SIZE]; /* saved register image */
  55. unsigned char volumes[AK4XXX_IMAGE_SIZE]; /* saved volume values */
  56. unsigned long private_value[AK4XXX_MAX_CHIPS]; /* helper for driver */
  57. void *private_data[AK4XXX_MAX_CHIPS]; /* helper for driver */
  58. /* template should fill the following fields */
  59. unsigned int idx_offset; /* control index offset */
  60. enum {
  61. SND_AK4524, SND_AK4528, SND_AK4529,
  62. SND_AK4355, SND_AK4358, SND_AK4381,
  63. SND_AK5365
  64. } type;
  65. /* (array) information of combined codecs */
  66. const struct snd_akm4xxx_dac_channel *dac_info;
  67. const struct snd_akm4xxx_adc_channel *adc_info;
  68. struct snd_ak4xxx_ops ops;
  69. };
  70. void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg,
  71. unsigned char val);
  72. void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state);
  73. void snd_akm4xxx_init(struct snd_akm4xxx *ak);
  74. int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak);
  75. #define snd_akm4xxx_get(ak,chip,reg) \
  76. (ak)->images[(chip) * 16 + (reg)]
  77. #define snd_akm4xxx_set(ak,chip,reg,val) \
  78. ((ak)->images[(chip) * 16 + (reg)] = (val))
  79. #define snd_akm4xxx_get_vol(ak,chip,reg) \
  80. (ak)->volumes[(chip) * 16 + (reg)]
  81. #define snd_akm4xxx_set_vol(ak,chip,reg,val) \
  82. ((ak)->volumes[(chip) * 16 + (reg)] = (val))
  83. #endif /* __SOUND_AK4XXX_ADDA_H */