oxygen.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #ifndef OXYGEN_H_INCLUDED
  2. #define OXYGEN_H_INCLUDED
  3. #include <linux/mutex.h>
  4. #include <linux/spinlock.h>
  5. #include <linux/workqueue.h>
  6. #include "oxygen_regs.h"
  7. /* 1 << PCM_x == OXYGEN_CHANNEL_x */
  8. #define PCM_A 0
  9. #define PCM_B 1
  10. #define PCM_C 2
  11. #define PCM_SPDIF 3
  12. #define PCM_MULTICH 4
  13. #define PCM_AC97 5
  14. #define PCM_COUNT 6
  15. #define OXYGEN_PCI_SUBID(sv, sd) \
  16. .vendor = PCI_VENDOR_ID_CMEDIA, \
  17. .device = 0x8788, \
  18. .subvendor = sv, \
  19. .subdevice = sd
  20. struct pci_dev;
  21. struct snd_card;
  22. struct snd_pcm_substream;
  23. struct snd_pcm_hw_params;
  24. struct snd_rawmidi;
  25. struct oxygen_model;
  26. struct oxygen {
  27. unsigned long addr;
  28. spinlock_t reg_lock;
  29. struct mutex mutex;
  30. struct snd_card *card;
  31. struct pci_dev *pci;
  32. struct snd_rawmidi *midi;
  33. int irq;
  34. const struct oxygen_model *model;
  35. unsigned int interrupt_mask;
  36. u8 dac_volume[8];
  37. u8 dac_mute;
  38. u8 pcm_active;
  39. u8 pcm_running;
  40. u8 dac_routing;
  41. u8 spdif_playback_enable;
  42. u8 ak4396_reg1;
  43. u8 revision;
  44. u8 has_2nd_ac97_codec;
  45. u32 spdif_bits;
  46. u32 spdif_pcm_bits;
  47. struct snd_pcm_substream *streams[PCM_COUNT];
  48. struct snd_kcontrol *spdif_pcm_ctl;
  49. struct snd_kcontrol *spdif_input_bits_ctl;
  50. struct work_struct spdif_input_bits_work;
  51. };
  52. struct oxygen_model {
  53. const char *shortname;
  54. const char *longname;
  55. const char *chip;
  56. struct module *owner;
  57. void (*init)(struct oxygen *chip);
  58. int (*mixer_init)(struct oxygen *chip);
  59. void (*cleanup)(struct oxygen *chip);
  60. void (*set_dac_params)(struct oxygen *chip,
  61. struct snd_pcm_hw_params *params);
  62. void (*set_adc_params)(struct oxygen *chip,
  63. struct snd_pcm_hw_params *params);
  64. void (*update_dac_volume)(struct oxygen *chip);
  65. void (*update_dac_mute)(struct oxygen *chip);
  66. const unsigned int *dac_tlv;
  67. u8 record_from_dma_b;
  68. u8 cd_in_from_video_in;
  69. u8 dac_minimum_volume;
  70. };
  71. /* oxygen_lib.c */
  72. int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
  73. const struct oxygen_model *model);
  74. void oxygen_pci_remove(struct pci_dev *pci);
  75. /* oxygen_mixer.c */
  76. int oxygen_mixer_init(struct oxygen *chip);
  77. void oxygen_update_dac_routing(struct oxygen *chip);
  78. void oxygen_update_spdif_source(struct oxygen *chip);
  79. /* oxygen_pcm.c */
  80. int oxygen_pcm_init(struct oxygen *chip);
  81. /* oxygen_io.c */
  82. u8 oxygen_read8(struct oxygen *chip, unsigned int reg);
  83. u16 oxygen_read16(struct oxygen *chip, unsigned int reg);
  84. u32 oxygen_read32(struct oxygen *chip, unsigned int reg);
  85. void oxygen_write8(struct oxygen *chip, unsigned int reg, u8 value);
  86. void oxygen_write16(struct oxygen *chip, unsigned int reg, u16 value);
  87. void oxygen_write32(struct oxygen *chip, unsigned int reg, u32 value);
  88. void oxygen_write8_masked(struct oxygen *chip, unsigned int reg,
  89. u8 value, u8 mask);
  90. void oxygen_write16_masked(struct oxygen *chip, unsigned int reg,
  91. u16 value, u16 mask);
  92. void oxygen_write32_masked(struct oxygen *chip, unsigned int reg,
  93. u32 value, u32 mask);
  94. u16 oxygen_read_ac97(struct oxygen *chip, unsigned int codec,
  95. unsigned int index);
  96. void oxygen_write_ac97(struct oxygen *chip, unsigned int codec,
  97. unsigned int index, u16 data);
  98. void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec,
  99. unsigned int index, u16 data, u16 mask);
  100. void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data);
  101. static inline void oxygen_set_bits8(struct oxygen *chip,
  102. unsigned int reg, u8 value)
  103. {
  104. oxygen_write8_masked(chip, reg, value, value);
  105. }
  106. static inline void oxygen_set_bits16(struct oxygen *chip,
  107. unsigned int reg, u16 value)
  108. {
  109. oxygen_write16_masked(chip, reg, value, value);
  110. }
  111. static inline void oxygen_set_bits32(struct oxygen *chip,
  112. unsigned int reg, u32 value)
  113. {
  114. oxygen_write32_masked(chip, reg, value, value);
  115. }
  116. static inline void oxygen_clear_bits8(struct oxygen *chip,
  117. unsigned int reg, u8 value)
  118. {
  119. oxygen_write8_masked(chip, reg, 0, value);
  120. }
  121. static inline void oxygen_clear_bits16(struct oxygen *chip,
  122. unsigned int reg, u16 value)
  123. {
  124. oxygen_write16_masked(chip, reg, 0, value);
  125. }
  126. static inline void oxygen_clear_bits32(struct oxygen *chip,
  127. unsigned int reg, u32 value)
  128. {
  129. oxygen_write32_masked(chip, reg, 0, value);
  130. }
  131. static inline void oxygen_ac97_set_bits(struct oxygen *chip, unsigned int codec,
  132. unsigned int index, u16 value)
  133. {
  134. oxygen_write_ac97_masked(chip, codec, index, value, value);
  135. }
  136. static inline void oxygen_ac97_clear_bits(struct oxygen *chip,
  137. unsigned int codec,
  138. unsigned int index, u16 value)
  139. {
  140. oxygen_write_ac97_masked(chip, codec, index, 0, value);
  141. }
  142. #endif