pmac.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Driver for PowerMac onboard soundchips
  4. * Copyright (c) 2001 by Takashi Iwai <[email protected]>
  5. * based on dmasound.c.
  6. */
  7. #ifndef __PMAC_H
  8. #define __PMAC_H
  9. #include <sound/control.h>
  10. #include <sound/pcm.h>
  11. #include "awacs.h"
  12. #include <linux/adb.h>
  13. #ifdef CONFIG_ADB_CUDA
  14. #include <linux/cuda.h>
  15. #endif
  16. #ifdef CONFIG_ADB_PMU
  17. #include <linux/pmu.h>
  18. #endif
  19. #include <linux/nvram.h>
  20. #include <linux/tty.h>
  21. #include <linux/vt_kern.h>
  22. #include <asm/dbdma.h>
  23. #include <asm/prom.h>
  24. #include <asm/machdep.h>
  25. #include <asm/pmac_feature.h>
  26. /* maximum number of fragments */
  27. #define PMAC_MAX_FRAGS 32
  28. #define PMAC_SUPPORT_AUTOMUTE
  29. /*
  30. * DBDMA space
  31. */
  32. struct pmac_dbdma {
  33. dma_addr_t dma_base;
  34. dma_addr_t addr;
  35. struct dbdma_cmd __iomem *cmds;
  36. void *space;
  37. int size;
  38. };
  39. /*
  40. * playback/capture stream
  41. */
  42. struct pmac_stream {
  43. int running; /* boolean */
  44. int stream; /* PLAYBACK/CAPTURE */
  45. int dma_size; /* in bytes */
  46. int period_size; /* in bytes */
  47. int buffer_size; /* in kbytes */
  48. int nperiods, cur_period;
  49. struct pmac_dbdma cmd;
  50. volatile struct dbdma_regs __iomem *dma;
  51. struct snd_pcm_substream *substream;
  52. unsigned int cur_freqs; /* currently available frequencies */
  53. unsigned int cur_formats; /* currently available formats */
  54. };
  55. /*
  56. */
  57. enum snd_pmac_model {
  58. PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER,
  59. PMAC_SNAPPER
  60. };
  61. struct snd_pmac {
  62. struct snd_card *card;
  63. /* h/w info */
  64. struct device_node *node;
  65. struct pci_dev *pdev;
  66. unsigned int revision;
  67. unsigned int manufacturer;
  68. unsigned int subframe;
  69. unsigned int device_id;
  70. enum snd_pmac_model model;
  71. unsigned int has_iic : 1;
  72. unsigned int is_pbook_3400 : 1;
  73. unsigned int is_pbook_G3 : 1;
  74. unsigned int is_k2 : 1;
  75. unsigned int can_byte_swap : 1;
  76. unsigned int can_duplex : 1;
  77. unsigned int can_capture : 1;
  78. unsigned int auto_mute : 1;
  79. unsigned int initialized : 1;
  80. unsigned int feature_is_set : 1;
  81. unsigned int requested;
  82. struct resource rsrc[3];
  83. int num_freqs;
  84. const int *freq_table;
  85. unsigned int freqs_ok; /* bit flags */
  86. unsigned int formats_ok; /* pcm hwinfo */
  87. int active;
  88. int rate_index;
  89. int format; /* current format */
  90. spinlock_t reg_lock;
  91. volatile struct awacs_regs __iomem *awacs;
  92. int awacs_reg[8]; /* register cache */
  93. unsigned int hp_stat_mask;
  94. unsigned char __iomem *latch_base;
  95. unsigned char __iomem *macio_base;
  96. struct pmac_stream playback;
  97. struct pmac_stream capture;
  98. struct pmac_dbdma extra_dma;
  99. int irq, tx_irq, rx_irq;
  100. struct snd_pcm *pcm;
  101. struct pmac_beep *beep;
  102. unsigned int control_mask; /* control mask */
  103. /* mixer stuffs */
  104. void *mixer_data;
  105. void (*mixer_free)(struct snd_pmac *);
  106. struct snd_kcontrol *master_sw_ctl;
  107. struct snd_kcontrol *speaker_sw_ctl;
  108. struct snd_kcontrol *drc_sw_ctl; /* only used for tumbler -ReneR */
  109. struct snd_kcontrol *hp_detect_ctl;
  110. struct snd_kcontrol *lineout_sw_ctl;
  111. /* lowlevel callbacks */
  112. void (*set_format)(struct snd_pmac *chip);
  113. void (*update_automute)(struct snd_pmac *chip, int do_notify);
  114. int (*detect_headphone)(struct snd_pmac *chip);
  115. #ifdef CONFIG_PM
  116. void (*suspend)(struct snd_pmac *chip);
  117. void (*resume)(struct snd_pmac *chip);
  118. #endif
  119. };
  120. /* exported functions */
  121. int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return);
  122. int snd_pmac_pcm_new(struct snd_pmac *chip);
  123. int snd_pmac_attach_beep(struct snd_pmac *chip);
  124. void snd_pmac_detach_beep(struct snd_pmac *chip);
  125. void snd_pmac_beep_stop(struct snd_pmac *chip);
  126. unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate);
  127. void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed);
  128. void snd_pmac_beep_dma_stop(struct snd_pmac *chip);
  129. #ifdef CONFIG_PM
  130. void snd_pmac_suspend(struct snd_pmac *chip);
  131. void snd_pmac_resume(struct snd_pmac *chip);
  132. #endif
  133. /* initialize mixer */
  134. int snd_pmac_awacs_init(struct snd_pmac *chip);
  135. int snd_pmac_burgundy_init(struct snd_pmac *chip);
  136. int snd_pmac_daca_init(struct snd_pmac *chip);
  137. int snd_pmac_tumbler_init(struct snd_pmac *chip);
  138. int snd_pmac_tumbler_post_init(void);
  139. /* i2c functions */
  140. struct pmac_keywest {
  141. int addr;
  142. struct i2c_client *client;
  143. int id;
  144. int (*init_client)(struct pmac_keywest *i2c);
  145. char *name;
  146. };
  147. int snd_pmac_keywest_init(struct pmac_keywest *i2c);
  148. void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c);
  149. /* misc */
  150. #define snd_pmac_boolean_stereo_info snd_ctl_boolean_stereo_info
  151. #define snd_pmac_boolean_mono_info snd_ctl_boolean_mono_info
  152. int snd_pmac_add_automute(struct snd_pmac *chip);
  153. #endif /* __PMAC_H */