pmac.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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 <linux/version.h>
  23. #include <sound/control.h>
  24. #include <sound/pcm.h>
  25. #include "awacs.h"
  26. #include <linux/adb.h>
  27. #ifdef CONFIG_ADB_CUDA
  28. #include <linux/cuda.h>
  29. #endif
  30. #ifdef CONFIG_ADB_PMU
  31. #include <linux/pmu.h>
  32. #endif
  33. #include <linux/nvram.h>
  34. #include <linux/tty.h>
  35. #include <linux/vt_kern.h>
  36. #include <asm/dbdma.h>
  37. #include <asm/prom.h>
  38. #include <asm/machdep.h>
  39. /* maximum number of fragments */
  40. #define PMAC_MAX_FRAGS 32
  41. #define PMAC_SUPPORT_AUTOMUTE
  42. /*
  43. * typedefs
  44. */
  45. typedef struct snd_pmac pmac_t;
  46. typedef struct snd_pmac_stream pmac_stream_t;
  47. typedef struct snd_pmac_beep pmac_beep_t;
  48. typedef struct snd_pmac_dbdma pmac_dbdma_t;
  49. /*
  50. * DBDMA space
  51. */
  52. struct snd_pmac_dbdma {
  53. dma_addr_t dma_base;
  54. dma_addr_t addr;
  55. struct dbdma_cmd __iomem *cmds;
  56. void *space;
  57. int size;
  58. };
  59. /*
  60. * playback/capture stream
  61. */
  62. struct snd_pmac_stream {
  63. int running; /* boolean */
  64. int stream; /* PLAYBACK/CAPTURE */
  65. int dma_size; /* in bytes */
  66. int period_size; /* in bytes */
  67. int buffer_size; /* in kbytes */
  68. int nperiods, cur_period;
  69. pmac_dbdma_t cmd;
  70. volatile struct dbdma_regs __iomem *dma;
  71. snd_pcm_substream_t *substream;
  72. unsigned int cur_freqs; /* currently available frequencies */
  73. unsigned int cur_formats; /* currently available formats */
  74. };
  75. /*
  76. */
  77. enum snd_pmac_model {
  78. PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER,
  79. PMAC_SNAPPER, PMAC_TOONIE
  80. };
  81. struct snd_pmac {
  82. snd_card_t *card;
  83. /* h/w info */
  84. struct device_node *node;
  85. struct pci_dev *pdev;
  86. unsigned int revision;
  87. unsigned int manufacturer;
  88. unsigned int subframe;
  89. unsigned int device_id;
  90. enum snd_pmac_model model;
  91. unsigned int has_iic : 1;
  92. unsigned int is_pbook_3400 : 1;
  93. unsigned int is_pbook_G3 : 1;
  94. unsigned int is_k2 : 1;
  95. unsigned int can_byte_swap : 1;
  96. unsigned int can_duplex : 1;
  97. unsigned int can_capture : 1;
  98. unsigned int auto_mute : 1;
  99. unsigned int initialized : 1;
  100. unsigned int feature_is_set : 1;
  101. unsigned int of_requested;
  102. int num_freqs;
  103. int *freq_table;
  104. unsigned int freqs_ok; /* bit flags */
  105. unsigned int formats_ok; /* pcm hwinfo */
  106. int active;
  107. int rate_index;
  108. int format; /* current format */
  109. spinlock_t reg_lock;
  110. volatile struct awacs_regs __iomem *awacs;
  111. int awacs_reg[8]; /* register cache */
  112. unsigned int hp_stat_mask;
  113. unsigned char __iomem *latch_base;
  114. unsigned char __iomem *macio_base;
  115. pmac_stream_t playback;
  116. pmac_stream_t capture;
  117. pmac_dbdma_t extra_dma;
  118. int irq, tx_irq, rx_irq;
  119. snd_pcm_t *pcm;
  120. pmac_beep_t *beep;
  121. unsigned int control_mask; /* control mask */
  122. /* mixer stuffs */
  123. void *mixer_data;
  124. void (*mixer_free)(pmac_t *);
  125. snd_kcontrol_t *master_sw_ctl;
  126. snd_kcontrol_t *speaker_sw_ctl;
  127. snd_kcontrol_t *drc_sw_ctl; /* only used for tumbler -ReneR */
  128. snd_kcontrol_t *hp_detect_ctl;
  129. snd_kcontrol_t *lineout_sw_ctl;
  130. /* lowlevel callbacks */
  131. void (*set_format)(pmac_t *chip);
  132. void (*update_automute)(pmac_t *chip, int do_notify);
  133. int (*detect_headphone)(pmac_t *chip);
  134. #ifdef CONFIG_PM
  135. void (*suspend)(pmac_t *chip);
  136. void (*resume)(pmac_t *chip);
  137. #endif
  138. };
  139. /* exported functions */
  140. int snd_pmac_new(snd_card_t *card, pmac_t **chip_return);
  141. int snd_pmac_pcm_new(pmac_t *chip);
  142. int snd_pmac_attach_beep(pmac_t *chip);
  143. void snd_pmac_detach_beep(pmac_t *chip);
  144. void snd_pmac_beep_stop(pmac_t *chip);
  145. unsigned int snd_pmac_rate_index(pmac_t *chip, pmac_stream_t *rec, unsigned int rate);
  146. void snd_pmac_beep_dma_start(pmac_t *chip, int bytes, unsigned long addr, int speed);
  147. void snd_pmac_beep_dma_stop(pmac_t *chip);
  148. /* initialize mixer */
  149. int snd_pmac_awacs_init(pmac_t *chip);
  150. int snd_pmac_burgundy_init(pmac_t *chip);
  151. int snd_pmac_daca_init(pmac_t *chip);
  152. int snd_pmac_tumbler_init(pmac_t *chip);
  153. int snd_pmac_tumbler_post_init(void);
  154. int snd_pmac_toonie_init(pmac_t *chip);
  155. /* i2c functions */
  156. typedef struct snd_pmac_keywest {
  157. int addr;
  158. struct i2c_client *client;
  159. int id;
  160. int (*init_client)(struct snd_pmac_keywest *i2c);
  161. char *name;
  162. } pmac_keywest_t;
  163. int snd_pmac_keywest_init(pmac_keywest_t *i2c);
  164. void snd_pmac_keywest_cleanup(pmac_keywest_t *i2c);
  165. /* misc */
  166. int snd_pmac_boolean_stereo_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo);
  167. int snd_pmac_boolean_mono_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo);
  168. int snd_pmac_add_automute(pmac_t *chip);
  169. #endif /* __PMAC_H */