0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __PMAC_H
0010 #define __PMAC_H
0011
0012 #include <sound/control.h>
0013 #include <sound/pcm.h>
0014 #include "awacs.h"
0015
0016 #include <linux/adb.h>
0017 #ifdef CONFIG_ADB_CUDA
0018 #include <linux/cuda.h>
0019 #endif
0020 #ifdef CONFIG_ADB_PMU
0021 #include <linux/pmu.h>
0022 #endif
0023 #include <linux/nvram.h>
0024 #include <linux/tty.h>
0025 #include <linux/vt_kern.h>
0026 #include <asm/dbdma.h>
0027 #include <asm/prom.h>
0028 #include <asm/machdep.h>
0029 #include <asm/pmac_feature.h>
0030
0031
0032 #define PMAC_MAX_FRAGS 32
0033
0034
0035 #define PMAC_SUPPORT_AUTOMUTE
0036
0037
0038
0039
0040 struct pmac_dbdma {
0041 dma_addr_t dma_base;
0042 dma_addr_t addr;
0043 struct dbdma_cmd __iomem *cmds;
0044 void *space;
0045 int size;
0046 };
0047
0048
0049
0050
0051 struct pmac_stream {
0052 int running;
0053
0054 int stream;
0055
0056 int dma_size;
0057 int period_size;
0058 int buffer_size;
0059 int nperiods, cur_period;
0060
0061 struct pmac_dbdma cmd;
0062 volatile struct dbdma_regs __iomem *dma;
0063
0064 struct snd_pcm_substream *substream;
0065
0066 unsigned int cur_freqs;
0067 unsigned int cur_formats;
0068 };
0069
0070
0071
0072
0073
0074 enum snd_pmac_model {
0075 PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER,
0076 PMAC_SNAPPER
0077 };
0078
0079 struct snd_pmac {
0080 struct snd_card *card;
0081
0082
0083 struct device_node *node;
0084 struct pci_dev *pdev;
0085 unsigned int revision;
0086 unsigned int manufacturer;
0087 unsigned int subframe;
0088 unsigned int device_id;
0089 enum snd_pmac_model model;
0090
0091 unsigned int has_iic : 1;
0092 unsigned int is_pbook_3400 : 1;
0093 unsigned int is_pbook_G3 : 1;
0094 unsigned int is_k2 : 1;
0095
0096 unsigned int can_byte_swap : 1;
0097 unsigned int can_duplex : 1;
0098 unsigned int can_capture : 1;
0099
0100 unsigned int auto_mute : 1;
0101 unsigned int initialized : 1;
0102 unsigned int feature_is_set : 1;
0103
0104 unsigned int requested;
0105 struct resource rsrc[3];
0106
0107 int num_freqs;
0108 const int *freq_table;
0109 unsigned int freqs_ok;
0110 unsigned int formats_ok;
0111 int active;
0112 int rate_index;
0113 int format;
0114
0115 spinlock_t reg_lock;
0116 volatile struct awacs_regs __iomem *awacs;
0117 int awacs_reg[8];
0118 unsigned int hp_stat_mask;
0119
0120 unsigned char __iomem *latch_base;
0121 unsigned char __iomem *macio_base;
0122
0123 struct pmac_stream playback;
0124 struct pmac_stream capture;
0125
0126 struct pmac_dbdma extra_dma;
0127
0128 int irq, tx_irq, rx_irq;
0129
0130 struct snd_pcm *pcm;
0131
0132 struct pmac_beep *beep;
0133
0134 unsigned int control_mask;
0135
0136
0137 void *mixer_data;
0138 void (*mixer_free)(struct snd_pmac *);
0139 struct snd_kcontrol *master_sw_ctl;
0140 struct snd_kcontrol *speaker_sw_ctl;
0141 struct snd_kcontrol *drc_sw_ctl;
0142 struct snd_kcontrol *hp_detect_ctl;
0143 struct snd_kcontrol *lineout_sw_ctl;
0144
0145
0146 void (*set_format)(struct snd_pmac *chip);
0147 void (*update_automute)(struct snd_pmac *chip, int do_notify);
0148 int (*detect_headphone)(struct snd_pmac *chip);
0149 #ifdef CONFIG_PM
0150 void (*suspend)(struct snd_pmac *chip);
0151 void (*resume)(struct snd_pmac *chip);
0152 #endif
0153
0154 };
0155
0156
0157
0158 int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return);
0159 int snd_pmac_pcm_new(struct snd_pmac *chip);
0160 int snd_pmac_attach_beep(struct snd_pmac *chip);
0161 void snd_pmac_detach_beep(struct snd_pmac *chip);
0162 void snd_pmac_beep_stop(struct snd_pmac *chip);
0163 unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate);
0164
0165 void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed);
0166 void snd_pmac_beep_dma_stop(struct snd_pmac *chip);
0167
0168 #ifdef CONFIG_PM
0169 void snd_pmac_suspend(struct snd_pmac *chip);
0170 void snd_pmac_resume(struct snd_pmac *chip);
0171 #endif
0172
0173
0174 int snd_pmac_awacs_init(struct snd_pmac *chip);
0175 int snd_pmac_burgundy_init(struct snd_pmac *chip);
0176 int snd_pmac_daca_init(struct snd_pmac *chip);
0177 int snd_pmac_tumbler_init(struct snd_pmac *chip);
0178 int snd_pmac_tumbler_post_init(void);
0179
0180
0181 struct pmac_keywest {
0182 int addr;
0183 struct i2c_client *client;
0184 int id;
0185 int (*init_client)(struct pmac_keywest *i2c);
0186 char *name;
0187 };
0188
0189 int snd_pmac_keywest_init(struct pmac_keywest *i2c);
0190 void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c);
0191
0192
0193 #define snd_pmac_boolean_stereo_info snd_ctl_boolean_stereo_info
0194 #define snd_pmac_boolean_mono_info snd_ctl_boolean_mono_info
0195
0196 int snd_pmac_add_automute(struct snd_pmac *chip);
0197
0198 #endif