[TG3]: Add tagged status support.
[linux-2.6/verdex.git] / sound / ppc / pmac.h
blob0a84c05f714b2c27ff40b3e3f02ed61c925a94b2
1 /*
2 * Driver for PowerMac onboard soundchips
3 * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
4 * based on dmasound.c.
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.
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.
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
22 #ifndef __PMAC_H
23 #define __PMAC_H
25 #include <linux/version.h>
26 #include <sound/control.h>
27 #include <sound/pcm.h>
28 #include "awacs.h"
30 #include <linux/adb.h>
31 #ifdef CONFIG_ADB_CUDA
32 #include <linux/cuda.h>
33 #endif
34 #ifdef CONFIG_ADB_PMU
35 #include <linux/pmu.h>
36 #endif
37 #include <linux/nvram.h>
38 #include <linux/tty.h>
39 #include <linux/vt_kern.h>
40 #include <asm/dbdma.h>
41 #include <asm/prom.h>
42 #include <asm/machdep.h>
44 /* maximum number of fragments */
45 #define PMAC_MAX_FRAGS 32
48 #define PMAC_SUPPORT_AUTOMUTE
51 * typedefs
53 typedef struct snd_pmac pmac_t;
54 typedef struct snd_pmac_stream pmac_stream_t;
55 typedef struct snd_pmac_beep pmac_beep_t;
56 typedef struct snd_pmac_dbdma pmac_dbdma_t;
60 * DBDMA space
62 struct snd_pmac_dbdma {
63 dma_addr_t dma_base;
64 dma_addr_t addr;
65 struct dbdma_cmd __iomem *cmds;
66 void *space;
67 int size;
71 * playback/capture stream
73 struct snd_pmac_stream {
74 int running; /* boolean */
76 int stream; /* PLAYBACK/CAPTURE */
78 int dma_size; /* in bytes */
79 int period_size; /* in bytes */
80 int buffer_size; /* in kbytes */
81 int nperiods, cur_period;
83 pmac_dbdma_t cmd;
84 volatile struct dbdma_regs __iomem *dma;
86 snd_pcm_substream_t *substream;
88 unsigned int cur_freqs; /* currently available frequencies */
89 unsigned int cur_formats; /* currently available formats */
96 enum snd_pmac_model {
97 PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER,
98 PMAC_SNAPPER, PMAC_TOONIE
101 struct snd_pmac {
102 snd_card_t *card;
104 /* h/w info */
105 struct device_node *node;
106 struct pci_dev *pdev;
107 unsigned int revision;
108 unsigned int manufacturer;
109 unsigned int subframe;
110 unsigned int device_id;
111 enum snd_pmac_model model;
113 unsigned int has_iic : 1;
114 unsigned int is_pbook_3400 : 1;
115 unsigned int is_pbook_G3 : 1;
116 unsigned int is_k2 : 1;
118 unsigned int can_byte_swap : 1;
119 unsigned int can_duplex : 1;
120 unsigned int can_capture : 1;
122 unsigned int auto_mute : 1;
123 unsigned int initialized : 1;
124 unsigned int feature_is_set : 1;
126 unsigned int of_requested;
128 int num_freqs;
129 int *freq_table;
130 unsigned int freqs_ok; /* bit flags */
131 unsigned int formats_ok; /* pcm hwinfo */
132 int active;
133 int rate_index;
134 int format; /* current format */
136 spinlock_t reg_lock;
137 volatile struct awacs_regs __iomem *awacs;
138 int awacs_reg[8]; /* register cache */
139 unsigned int hp_stat_mask;
141 unsigned char __iomem *latch_base;
142 unsigned char __iomem *macio_base;
144 pmac_stream_t playback;
145 pmac_stream_t capture;
147 pmac_dbdma_t extra_dma;
149 int irq, tx_irq, rx_irq;
151 snd_pcm_t *pcm;
153 pmac_beep_t *beep;
155 unsigned int control_mask; /* control mask */
157 /* mixer stuffs */
158 void *mixer_data;
159 void (*mixer_free)(pmac_t *);
160 snd_kcontrol_t *master_sw_ctl;
161 snd_kcontrol_t *speaker_sw_ctl;
162 snd_kcontrol_t *drc_sw_ctl; /* only used for tumbler -ReneR */
163 snd_kcontrol_t *hp_detect_ctl;
164 snd_kcontrol_t *lineout_sw_ctl;
166 /* lowlevel callbacks */
167 void (*set_format)(pmac_t *chip);
168 void (*update_automute)(pmac_t *chip, int do_notify);
169 int (*detect_headphone)(pmac_t *chip);
170 #ifdef CONFIG_PMAC_PBOOK
171 void (*suspend)(pmac_t *chip);
172 void (*resume)(pmac_t *chip);
173 #endif
178 /* exported functions */
179 int snd_pmac_new(snd_card_t *card, pmac_t **chip_return);
180 int snd_pmac_pcm_new(pmac_t *chip);
181 int snd_pmac_attach_beep(pmac_t *chip);
182 void snd_pmac_detach_beep(pmac_t *chip);
183 void snd_pmac_beep_stop(pmac_t *chip);
184 unsigned int snd_pmac_rate_index(pmac_t *chip, pmac_stream_t *rec, unsigned int rate);
186 void snd_pmac_beep_dma_start(pmac_t *chip, int bytes, unsigned long addr, int speed);
187 void snd_pmac_beep_dma_stop(pmac_t *chip);
189 /* initialize mixer */
190 int snd_pmac_awacs_init(pmac_t *chip);
191 int snd_pmac_burgundy_init(pmac_t *chip);
192 int snd_pmac_daca_init(pmac_t *chip);
193 int snd_pmac_tumbler_init(pmac_t *chip);
194 int snd_pmac_tumbler_post_init(void);
195 int snd_pmac_toonie_init(pmac_t *chip);
197 /* i2c functions */
198 typedef struct snd_pmac_keywest {
199 int addr;
200 struct i2c_client *client;
201 int id;
202 int (*init_client)(struct snd_pmac_keywest *i2c);
203 char *name;
204 } pmac_keywest_t;
206 int snd_pmac_keywest_init(pmac_keywest_t *i2c);
207 void snd_pmac_keywest_cleanup(pmac_keywest_t *i2c);
209 /* misc */
210 int snd_pmac_boolean_stereo_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo);
211 int snd_pmac_boolean_mono_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo);
213 int snd_pmac_add_automute(pmac_t *chip);
215 #define big_mdelay(msec) do {\
216 set_current_state(TASK_UNINTERRUPTIBLE);\
217 schedule_timeout(((msec) * HZ + 999) / 1000);\
218 } while (0)
220 #endif /* __PMAC_H */