1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Driver for PowerMac onboard soundchips
4 * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
12 #include <sound/control.h>
13 #include <sound/pcm.h>
16 #include <linux/adb.h>
17 #ifdef CONFIG_ADB_CUDA
18 #include <linux/cuda.h>
21 #include <linux/pmu.h>
23 #include <linux/nvram.h>
24 #include <linux/tty.h>
25 #include <linux/vt_kern.h>
26 #include <asm/dbdma.h>
28 #include <asm/machdep.h>
29 #include <asm/pmac_feature.h>
31 /* maximum number of fragments */
32 #define PMAC_MAX_FRAGS 32
35 #define PMAC_SUPPORT_AUTOMUTE
43 struct dbdma_cmd __iomem
*cmds
;
49 * playback/capture stream
52 int running
; /* boolean */
54 int stream
; /* PLAYBACK/CAPTURE */
56 int dma_size
; /* in bytes */
57 int period_size
; /* in bytes */
58 int buffer_size
; /* in kbytes */
59 int nperiods
, cur_period
;
61 struct pmac_dbdma cmd
;
62 volatile struct dbdma_regs __iomem
*dma
;
64 struct snd_pcm_substream
*substream
;
66 unsigned int cur_freqs
; /* currently available frequencies */
67 unsigned int cur_formats
; /* currently available formats */
75 PMAC_AWACS
, PMAC_SCREAMER
, PMAC_BURGUNDY
, PMAC_DACA
, PMAC_TUMBLER
,
80 struct snd_card
*card
;
83 struct device_node
*node
;
85 unsigned int revision
;
86 unsigned int manufacturer
;
87 unsigned int subframe
;
88 unsigned int device_id
;
89 enum snd_pmac_model model
;
91 unsigned int has_iic
: 1;
92 unsigned int is_pbook_3400
: 1;
93 unsigned int is_pbook_G3
: 1;
94 unsigned int is_k2
: 1;
96 unsigned int can_byte_swap
: 1;
97 unsigned int can_duplex
: 1;
98 unsigned int can_capture
: 1;
100 unsigned int auto_mute
: 1;
101 unsigned int initialized
: 1;
102 unsigned int feature_is_set
: 1;
104 unsigned int requested
;
105 struct resource rsrc
[3];
108 const int *freq_table
;
109 unsigned int freqs_ok
; /* bit flags */
110 unsigned int formats_ok
; /* pcm hwinfo */
113 int format
; /* current format */
116 volatile struct awacs_regs __iomem
*awacs
;
117 int awacs_reg
[8]; /* register cache */
118 unsigned int hp_stat_mask
;
120 unsigned char __iomem
*latch_base
;
121 unsigned char __iomem
*macio_base
;
123 struct pmac_stream playback
;
124 struct pmac_stream capture
;
126 struct pmac_dbdma extra_dma
;
128 int irq
, tx_irq
, rx_irq
;
132 struct pmac_beep
*beep
;
134 unsigned int control_mask
; /* control mask */
138 void (*mixer_free
)(struct snd_pmac
*);
139 struct snd_kcontrol
*master_sw_ctl
;
140 struct snd_kcontrol
*speaker_sw_ctl
;
141 struct snd_kcontrol
*drc_sw_ctl
; /* only used for tumbler -ReneR */
142 struct snd_kcontrol
*hp_detect_ctl
;
143 struct snd_kcontrol
*lineout_sw_ctl
;
145 /* lowlevel callbacks */
146 void (*set_format
)(struct snd_pmac
*chip
);
147 void (*update_automute
)(struct snd_pmac
*chip
, int do_notify
);
148 int (*detect_headphone
)(struct snd_pmac
*chip
);
150 void (*suspend
)(struct snd_pmac
*chip
);
151 void (*resume
)(struct snd_pmac
*chip
);
157 /* exported functions */
158 int snd_pmac_new(struct snd_card
*card
, struct snd_pmac
**chip_return
);
159 int snd_pmac_pcm_new(struct snd_pmac
*chip
);
160 int snd_pmac_attach_beep(struct snd_pmac
*chip
);
161 void snd_pmac_detach_beep(struct snd_pmac
*chip
);
162 void snd_pmac_beep_stop(struct snd_pmac
*chip
);
163 unsigned int snd_pmac_rate_index(struct snd_pmac
*chip
, struct pmac_stream
*rec
, unsigned int rate
);
165 void snd_pmac_beep_dma_start(struct snd_pmac
*chip
, int bytes
, unsigned long addr
, int speed
);
166 void snd_pmac_beep_dma_stop(struct snd_pmac
*chip
);
169 void snd_pmac_suspend(struct snd_pmac
*chip
);
170 void snd_pmac_resume(struct snd_pmac
*chip
);
173 /* initialize mixer */
174 int snd_pmac_awacs_init(struct snd_pmac
*chip
);
175 int snd_pmac_burgundy_init(struct snd_pmac
*chip
);
176 int snd_pmac_daca_init(struct snd_pmac
*chip
);
177 int snd_pmac_tumbler_init(struct snd_pmac
*chip
);
178 int snd_pmac_tumbler_post_init(void);
181 struct pmac_keywest
{
183 struct i2c_client
*client
;
185 int (*init_client
)(struct pmac_keywest
*i2c
);
189 int snd_pmac_keywest_init(struct pmac_keywest
*i2c
);
190 void snd_pmac_keywest_cleanup(struct pmac_keywest
*i2c
);
193 #define snd_pmac_boolean_stereo_info snd_ctl_boolean_stereo_info
194 #define snd_pmac_boolean_mono_info snd_ctl_boolean_mono_info
196 int snd_pmac_add_automute(struct snd_pmac
*chip
);
198 #endif /* __PMAC_H */