pmac.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * Driver for PowerMac onboard soundchips
  3. * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
  4. * based on dmasound.c.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #ifndef __PMAC_H
  21. #define __PMAC_H
  22. #include <sound/control.h>
  23. #include <sound/pcm.h>
  24. #include "awacs.h"
  25. #include <linux/adb.h>
  26. #ifdef CONFIG_ADB_CUDA
  27. #include <linux/cuda.h>
  28. #endif
  29. #ifdef CONFIG_ADB_PMU
  30. #include <linux/pmu.h>
  31. #endif
  32. #include <linux/nvram.h>
  33. #include <linux/tty.h>
  34. #include <linux/vt_kern.h>
  35. #include <asm/dbdma.h>
  36. #include <asm/prom.h>
  37. #include <asm/machdep.h>
  38. /* maximum number of fragments */
  39. #define PMAC_MAX_FRAGS 32
  40. #define PMAC_SUPPORT_AUTOMUTE
  41. /*
  42. * DBDMA space
  43. */
  44. struct pmac_dbdma {
  45. dma_addr_t dma_base;
  46. dma_addr_t addr;
  47. struct dbdma_cmd __iomem *cmds;
  48. void *space;
  49. int size;
  50. };
  51. /*
  52. * playback/capture stream
  53. */
  54. struct pmac_stream {
  55. int running; /* boolean */
  56. int stream; /* PLAYBACK/CAPTURE */
  57. int dma_size; /* in bytes */
  58. int period_size; /* in bytes */
  59. int buffer_size; /* in kbytes */
  60. int nperiods, cur_period;
  61. struct pmac_dbdma cmd;
  62. volatile struct dbdma_regs __iomem *dma;
  63. struct snd_pcm_substream *substream;
  64. unsigned int cur_freqs; /* currently available frequencies */
  65. unsigned int cur_formats; /* currently available formats */
  66. };
  67. /*
  68. */
  69. enum snd_pmac_model {
  70. PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER,
  71. PMAC_SNAPPER
  72. };
  73. struct snd_pmac {
  74. struct snd_card *card;
  75. /* h/w info */
  76. struct device_node *node;
  77. struct pci_dev *pdev;
  78. unsigned int revision;
  79. unsigned int manufacturer;
  80. unsigned int subframe;
  81. unsigned int device_id;
  82. enum snd_pmac_model model;
  83. unsigned int has_iic : 1;
  84. unsigned int is_pbook_3400 : 1;
  85. unsigned int is_pbook_G3 : 1;
  86. unsigned int is_k2 : 1;
  87. unsigned int can_byte_swap : 1;
  88. unsigned int can_duplex : 1;
  89. unsigned int can_capture : 1;
  90. unsigned int auto_mute : 1;
  91. unsigned int initialized : 1;
  92. unsigned int feature_is_set : 1;
  93. unsigned int requested;
  94. struct resource rsrc[3];
  95. int num_freqs;
  96. int *freq_table;
  97. unsigned int freqs_ok; /* bit flags */
  98. unsigned int formats_ok; /* pcm hwinfo */
  99. int active;
  100. int rate_index;
  101. int format; /* current format */
  102. spinlock_t reg_lock;
  103. volatile struct awacs_regs __iomem *awacs;
  104. int awacs_reg[8]; /* register cache */
  105. unsigned int hp_stat_mask;
  106. unsigned char __iomem *latch_base;
  107. unsigned char __iomem *macio_base;
  108. struct pmac_stream playback;
  109. struct pmac_stream capture;
  110. struct pmac_dbdma extra_dma;
  111. int irq, tx_irq, rx_irq;
  112. struct snd_pcm *pcm;
  113. struct pmac_beep *beep;
  114. unsigned int control_mask; /* control mask */
  115. /* mixer stuffs */
  116. void *mixer_data;
  117. void (*mixer_free)(struct snd_pmac *);
  118. struct snd_kcontrol *master_sw_ctl;
  119. struct snd_kcontrol *speaker_sw_ctl;
  120. struct snd_kcontrol *drc_sw_ctl; /* only used for tumbler -ReneR */
  121. struct snd_kcontrol *hp_detect_ctl;
  122. struct snd_kcontrol *lineout_sw_ctl;
  123. /* lowlevel callbacks */
  124. void (*set_format)(struct snd_pmac *chip);
  125. void (*update_automute)(struct snd_pmac *chip, int do_notify);
  126. int (*detect_headphone)(struct snd_pmac *chip);
  127. #ifdef CONFIG_PM
  128. void (*suspend)(struct snd_pmac *chip);
  129. void (*resume)(struct snd_pmac *chip);
  130. #endif
  131. };
  132. /* exported functions */
  133. int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return);
  134. int snd_pmac_pcm_new(struct snd_pmac *chip);
  135. int snd_pmac_attach_beep(struct snd_pmac *chip);
  136. void snd_pmac_detach_beep(struct snd_pmac *chip);
  137. void snd_pmac_beep_stop(struct snd_pmac *chip);
  138. unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate);
  139. void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed);
  140. void snd_pmac_beep_dma_stop(struct snd_pmac *chip);
  141. #ifdef CONFIG_PM
  142. void snd_pmac_suspend(struct snd_pmac *chip);
  143. void snd_pmac_resume(struct snd_pmac *chip);
  144. #endif
  145. /* initialize mixer */
  146. int snd_pmac_awacs_init(struct snd_pmac *chip);
  147. int snd_pmac_burgundy_init(struct snd_pmac *chip);
  148. int snd_pmac_daca_init(struct snd_pmac *chip);
  149. int snd_pmac_tumbler_init(struct snd_pmac *chip);
  150. int snd_pmac_tumbler_post_init(void);
  151. /* i2c functions */
  152. struct pmac_keywest {
  153. int addr;
  154. struct i2c_client *client;
  155. int id;
  156. int (*init_client)(struct pmac_keywest *i2c);
  157. char *name;
  158. };
  159. int snd_pmac_keywest_init(struct pmac_keywest *i2c);
  160. void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c);
  161. /* misc */
  162. int snd_pmac_boolean_stereo_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
  163. int snd_pmac_boolean_mono_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
  164. int snd_pmac_add_automute(struct snd_pmac *chip);
  165. #endif /* __PMAC_H */