pmac.h 4.5 KB

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