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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | */
|
---|
20 |
|
---|
21 |
|
---|
22 | #ifndef __PMAC_H
|
---|
23 | #define __PMAC_H
|
---|
24 |
|
---|
25 | #include "control.h"
|
---|
26 | #include "pcm.h"
|
---|
27 | #include "awacs.h"
|
---|
28 |
|
---|
29 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
|
---|
30 | #include <asm/adb.h>
|
---|
31 | #include <asm/cuda.h>
|
---|
32 | #include <asm/pmu.h>
|
---|
33 | #else /* 2.4.0 kernel */
|
---|
34 | #include <linux/adb.h>
|
---|
35 | #ifdef CONFIG_ADB_CUDA
|
---|
36 | #include <linux/cuda.h>
|
---|
37 | #endif
|
---|
38 | #ifdef CONFIG_ADB_PMU
|
---|
39 | #include <linux/pmu.h>
|
---|
40 | #endif
|
---|
41 | #endif
|
---|
42 | #include <linux/nvram.h>
|
---|
43 | #include <linux/vt_kern.h>
|
---|
44 | #include <asm/dbdma.h>
|
---|
45 | #include <asm/prom.h>
|
---|
46 | #include <asm/machdep.h>
|
---|
47 | #include <asm/feature.h>
|
---|
48 |
|
---|
49 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
|
---|
50 | #define pmu_suspend() /**/
|
---|
51 | #define pmu_resume() /**/
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) || defined(CONFIG_ADB_CUDA)
|
---|
55 | #define PMAC_AMP_AVAIL
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | /* maximum number of fragments */
|
---|
59 | #define PMAC_MAX_FRAGS 32
|
---|
60 |
|
---|
61 |
|
---|
62 | /*
|
---|
63 | * typedefs
|
---|
64 | */
|
---|
65 | typedef struct snd_pmac pmac_t;
|
---|
66 | typedef struct snd_pmac_stream pmac_stream_t;
|
---|
67 | typedef struct snd_pmac_beep pmac_beep_t;
|
---|
68 | typedef struct snd_pmac_dbdma pmac_dbdma_t;
|
---|
69 |
|
---|
70 |
|
---|
71 | /*
|
---|
72 | * DBDMA space
|
---|
73 | */
|
---|
74 | struct snd_pmac_dbdma {
|
---|
75 | unsigned long addr;
|
---|
76 | struct dbdma_cmd *cmds;
|
---|
77 | void *space;
|
---|
78 | int size;
|
---|
79 | };
|
---|
80 |
|
---|
81 | /*
|
---|
82 | * playback/capture stream
|
---|
83 | */
|
---|
84 | struct snd_pmac_stream {
|
---|
85 | int running; /* boolean */
|
---|
86 |
|
---|
87 | int stream; /* PLAYBACK/CAPTURE */
|
---|
88 |
|
---|
89 | int dma_size; /* in bytes */
|
---|
90 | int period_size; /* in bytes */
|
---|
91 | int buffer_size; /* in kbytes */
|
---|
92 | int nperiods, cur_period;
|
---|
93 |
|
---|
94 | pmac_dbdma_t cmd;
|
---|
95 | volatile struct dbdma_regs *dma;
|
---|
96 |
|
---|
97 | snd_pcm_substream_t *substream;
|
---|
98 |
|
---|
99 | unsigned int cur_freqs; /* currently available frequences */
|
---|
100 | unsigned int cur_formats; /* currently available formats */
|
---|
101 | };
|
---|
102 |
|
---|
103 |
|
---|
104 | /*
|
---|
105 | * beep using pcm
|
---|
106 | */
|
---|
107 | struct snd_pmac_beep {
|
---|
108 | int running; /* boolean */
|
---|
109 | int volume; /* mixer volume: 0-100 */
|
---|
110 | int volume_play; /* currently playing volume */
|
---|
111 | int hz;
|
---|
112 | int nsamples;
|
---|
113 | short *buf; /* allocated wave buffer */
|
---|
114 | unsigned long addr; /* physical address of buffer */
|
---|
115 | struct timer_list timer; /* timer list for stopping beep */
|
---|
116 | void (*orig_mksound)(unsigned int, unsigned int);
|
---|
117 | /* pointer to restore */
|
---|
118 | snd_kcontrol_t *control; /* mixer element */
|
---|
119 | };
|
---|
120 |
|
---|
121 |
|
---|
122 | /*
|
---|
123 | */
|
---|
124 | struct snd_pmac {
|
---|
125 | snd_card_t *card;
|
---|
126 |
|
---|
127 | /* h/w info */
|
---|
128 | struct device_node *node;
|
---|
129 | unsigned int revision;
|
---|
130 | unsigned int subframe;
|
---|
131 | unsigned int device_id;
|
---|
132 | unsigned int has_iic : 1;
|
---|
133 |
|
---|
134 | unsigned int is_burgundy : 1;
|
---|
135 | unsigned int is_daca : 1;
|
---|
136 | unsigned int is_pbook_3400 : 1;
|
---|
137 | unsigned int is_pbook_G3 : 1;
|
---|
138 | unsigned int is_screamer : 1;
|
---|
139 |
|
---|
140 | unsigned int can_byte_swap : 1;
|
---|
141 | unsigned int can_duplex : 1;
|
---|
142 | unsigned int can_capture : 1;
|
---|
143 |
|
---|
144 | #ifdef PMAC_AMP_AVAIL
|
---|
145 | unsigned int amp_only;
|
---|
146 | int amp_vol[2];
|
---|
147 | #endif
|
---|
148 |
|
---|
149 | unsigned int initialized : 1;
|
---|
150 | unsigned int feature_is_set : 1;
|
---|
151 |
|
---|
152 | unsigned int freqs_ok; /* bit flags */
|
---|
153 | unsigned int formats_ok; /* pcm hwinfo */
|
---|
154 | int active;
|
---|
155 | int rate_index;
|
---|
156 | int format; /* current format */
|
---|
157 |
|
---|
158 | spinlock_t reg_lock;
|
---|
159 | volatile struct awacs_regs *awacs;
|
---|
160 | int awacs_reg[8]; /* register cache */
|
---|
161 |
|
---|
162 | unsigned char *latch_base;
|
---|
163 | unsigned char *macio_base;
|
---|
164 |
|
---|
165 | pmac_stream_t playback;
|
---|
166 | pmac_stream_t capture;
|
---|
167 |
|
---|
168 | pmac_dbdma_t extra_dma;
|
---|
169 |
|
---|
170 | int irq, tx_irq, rx_irq;
|
---|
171 |
|
---|
172 | snd_pcm_t *pcm;
|
---|
173 |
|
---|
174 | pmac_beep_t *beep;
|
---|
175 |
|
---|
176 | unsigned int control_mask; /* control mask */
|
---|
177 |
|
---|
178 | /* lowlevel callbacks */
|
---|
179 | void (*set_format)(pmac_t *chip);
|
---|
180 | void (*port_change)(pmac_t *chip);
|
---|
181 | #ifdef CONFIG_PMAC_PBOOK
|
---|
182 | unsigned int sleep_registered : 1;
|
---|
183 | void (*suspend)(pmac_t *chip);
|
---|
184 | void (*resume)(pmac_t *chip);
|
---|
185 | #endif
|
---|
186 |
|
---|
187 | };
|
---|
188 |
|
---|
189 |
|
---|
190 | /* exported functions */
|
---|
191 | int snd_pmac_new(snd_card_t *card, pmac_t **chip_return);
|
---|
192 | int snd_pmac_pcm_new(pmac_t *chip);
|
---|
193 | int snd_pmac_attach_beep(pmac_t *chip);
|
---|
194 | #ifdef CONFIG_PMAC_PBOOK
|
---|
195 | int snd_pmac_register_sleep_notifier(pmac_t *chip);
|
---|
196 | int snd_pmac_unregister_sleep_notifier(pmac_t *chip);
|
---|
197 | #endif
|
---|
198 |
|
---|
199 | /* initialize mixer */
|
---|
200 | int snd_pmac_awacs_init(pmac_t *chip);
|
---|
201 | int snd_pmac_burgundy_init(pmac_t *chip);
|
---|
202 |
|
---|
203 | #endif /* __PMAC_H */
|
---|