2 * Driver for PowerMac onboard soundchips
3 * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
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
25 #include <linux/version.h>
26 #include <sound/control.h>
27 #include <sound/pcm.h>
30 #include <linux/adb.h>
31 #ifdef CONFIG_ADB_CUDA
32 #include <linux/cuda.h>
35 #include <linux/pmu.h>
37 #include <linux/nvram.h>
38 #include <linux/tty.h>
39 #include <linux/vt_kern.h>
40 #include <asm/dbdma.h>
42 #include <asm/machdep.h>
44 /* maximum number of fragments */
45 #define PMAC_MAX_FRAGS 32
48 #define PMAC_SUPPORT_AUTOMUTE
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;
62 struct snd_pmac_dbdma {
64 struct dbdma_cmd *cmds;
70 * playback/capture stream
72 struct snd_pmac_stream {
73 int running; /* boolean */
75 int stream; /* PLAYBACK/CAPTURE */
77 int dma_size; /* in bytes */
78 int period_size; /* in bytes */
79 int buffer_size; /* in kbytes */
80 int nperiods, cur_period;
83 volatile struct dbdma_regs *dma;
85 snd_pcm_substream_t *substream;
87 unsigned int cur_freqs; /* currently available frequences */
88 unsigned int cur_formats; /* currently available formats */
96 PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER, PMAC_SNAPPER
103 struct device_node *node;
104 unsigned int revision;
105 unsigned int manufacturer;
106 unsigned int subframe;
107 unsigned int device_id;
108 enum snd_pmac_model model;
110 unsigned int has_iic : 1;
111 unsigned int is_pbook_3400 : 1;
112 unsigned int is_pbook_G3 : 1;
114 unsigned int can_byte_swap : 1;
115 unsigned int can_duplex : 1;
116 unsigned int can_capture : 1;
118 unsigned int auto_mute : 1;
119 unsigned int initialized : 1;
120 unsigned int feature_is_set : 1;
122 unsigned int of_requested;
126 unsigned int freqs_ok; /* bit flags */
127 unsigned int formats_ok; /* pcm hwinfo */
130 int format; /* current format */
133 volatile struct awacs_regs *awacs;
134 int awacs_reg[8]; /* register cache */
135 unsigned int hp_stat_mask;
137 unsigned char *latch_base;
138 unsigned char *macio_base;
140 pmac_stream_t playback;
141 pmac_stream_t capture;
143 pmac_dbdma_t extra_dma;
145 int irq, tx_irq, rx_irq;
151 unsigned int control_mask; /* control mask */
155 void (*mixer_free)(pmac_t *);
156 snd_kcontrol_t *master_sw_ctl;
157 snd_kcontrol_t *speaker_sw_ctl;
158 snd_kcontrol_t *hp_detect_ctl;
160 /* lowlevel callbacks */
161 void (*set_format)(pmac_t *chip);
162 void (*update_automute)(pmac_t *chip, int do_notify);
163 int (*detect_headphone)(pmac_t *chip);
164 #ifdef CONFIG_PMAC_PBOOK
165 void (*suspend)(pmac_t *chip);
166 void (*resume)(pmac_t *chip);
172 /* exported functions */
173 int snd_pmac_new(snd_card_t *card, pmac_t **chip_return);
174 int snd_pmac_pcm_new(pmac_t *chip);
175 int snd_pmac_attach_beep(pmac_t *chip);
177 /* initialize mixer */
178 int snd_pmac_awacs_init(pmac_t *chip);
179 int snd_pmac_burgundy_init(pmac_t *chip);
180 int snd_pmac_daca_init(pmac_t *chip);
181 int snd_pmac_tumbler_init(pmac_t *chip);
182 int snd_pmac_tumbler_post_init(void);
185 typedef struct snd_pmac_keywest {
187 struct i2c_client *client;
189 int (*init_client)(struct snd_pmac_keywest *i2c);
193 int snd_pmac_keywest_init(pmac_keywest_t *i2c);
194 void snd_pmac_keywest_cleanup(pmac_keywest_t *i2c);
195 #define snd_pmac_keywest_write(i2c,cmd,len,data) i2c_smbus_write_block_data((i2c)->client, cmd, len, data)
196 #define snd_pmac_keywest_write_byte(i2c,cmd,data) i2c_smbus_write_byte_data((i2c)->client, cmd, data)
199 int snd_pmac_boolean_stereo_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo);
200 int snd_pmac_boolean_mono_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo);
202 int snd_pmac_add_automute(pmac_t *chip);
204 #define big_mdelay(msec) do {\
205 set_current_state(TASK_UNINTERRUPTIBLE);\
206 schedule_timeout(((msec) * HZ + 999) / 1000);\
209 #ifndef PMAC_SUPPORT_PCM_BEEP
210 #define snd_pmac_attach_beep(chip) 0
211 #define snd_pmac_beep_stop(chip) /**/
214 #endif /* __PMAC_H */