ak4xxx-adda.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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, unsigned char val);
  32. // unsigned char (*read)(struct snd_akm4xxx *ak, int chip, unsigned char reg);
  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. struct snd_akm4xxx {
  37. struct snd_card *card;
  38. unsigned int num_adcs; /* AK4524 or AK4528 ADCs */
  39. unsigned int num_dacs; /* AK4524 or AK4528 DACs */
  40. unsigned char images[AK4XXX_IMAGE_SIZE]; /* saved register image */
  41. unsigned char ipga_gain[AK4XXX_MAX_CHIPS][2]; /* saved register image for IPGA (AK4528) */
  42. unsigned long private_value[AK4XXX_MAX_CHIPS]; /* helper for driver */
  43. void *private_data[AK4XXX_MAX_CHIPS]; /* helper for driver */
  44. /* template should fill the following fields */
  45. unsigned int idx_offset; /* control index offset */
  46. enum {
  47. SND_AK4524, SND_AK4528, SND_AK4529,
  48. SND_AK4355, SND_AK4358, SND_AK4381
  49. } type;
  50. struct snd_ak4xxx_ops ops;
  51. };
  52. void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg, unsigned char val);
  53. void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state);
  54. void snd_akm4xxx_init(struct snd_akm4xxx *ak);
  55. int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak);
  56. #define snd_akm4xxx_get(ak,chip,reg) (ak)->images[(chip) * 16 + (reg)]
  57. #define snd_akm4xxx_set(ak,chip,reg,val) ((ak)->images[(chip) * 16 + (reg)] = (val))
  58. #define snd_akm4xxx_get_ipga(ak,chip,reg) (ak)->ipga_gain[chip][(reg)-4]
  59. #define snd_akm4xxx_set_ipga(ak,chip,reg,val) ((ak)->ipga_gain[chip][(reg)-4] = (val))
  60. #endif /* __SOUND_AK4XXX_ADDA_H */