Linux Audio

Check our new training course

Loading...
v5.9
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 * Driver for PowerMac onboard soundchips
  4 * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
  5 *   based on dmasound.c.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  6 */
  7
  8
  9#ifndef __PMAC_H
 10#define __PMAC_H
 11
 12#include <sound/control.h>
 13#include <sound/pcm.h>
 14#include "awacs.h"
 15
 16#include <linux/adb.h>
 17#ifdef CONFIG_ADB_CUDA
 18#include <linux/cuda.h>
 19#endif
 20#ifdef CONFIG_ADB_PMU
 21#include <linux/pmu.h>
 22#endif
 23#include <linux/nvram.h>
 24#include <linux/tty.h>
 25#include <linux/vt_kern.h>
 26#include <asm/dbdma.h>
 27#include <asm/prom.h>
 28#include <asm/machdep.h>
 29
 30/* maximum number of fragments */
 31#define PMAC_MAX_FRAGS		32
 32
 33
 34#define PMAC_SUPPORT_AUTOMUTE
 35
 36/*
 37 * DBDMA space
 38 */
 39struct pmac_dbdma {
 40	dma_addr_t dma_base;
 41	dma_addr_t addr;
 42	struct dbdma_cmd __iomem *cmds;
 43	void *space;
 44	int size;
 45};
 46
 47/*
 48 * playback/capture stream
 49 */
 50struct pmac_stream {
 51	int running;	/* boolean */
 52
 53	int stream;	/* PLAYBACK/CAPTURE */
 54
 55	int dma_size; /* in bytes */
 56	int period_size; /* in bytes */
 57	int buffer_size; /* in kbytes */
 58	int nperiods, cur_period;
 59
 60	struct pmac_dbdma cmd;
 61	volatile struct dbdma_regs __iomem *dma;
 62
 63	struct snd_pcm_substream *substream;
 64
 65	unsigned int cur_freqs;		/* currently available frequencies */
 66	unsigned int cur_formats;	/* currently available formats */
 67};
 68
 69
 70/*
 71 */
 72
 73enum snd_pmac_model {
 74	PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER,
 75	PMAC_SNAPPER
 76};
 77
 78struct snd_pmac {
 79	struct snd_card *card;
 80
 81	/* h/w info */
 82	struct device_node *node;
 83	struct pci_dev *pdev;
 84	unsigned int revision;
 85	unsigned int manufacturer;
 86	unsigned int subframe;
 87	unsigned int device_id;
 88	enum snd_pmac_model model;
 89
 90	unsigned int has_iic : 1;
 91	unsigned int is_pbook_3400 : 1;
 92	unsigned int is_pbook_G3 : 1;
 93	unsigned int is_k2 : 1;
 94
 95	unsigned int can_byte_swap : 1;
 96	unsigned int can_duplex : 1;
 97	unsigned int can_capture : 1;
 98
 99	unsigned int auto_mute : 1;
100	unsigned int initialized : 1;
101	unsigned int feature_is_set : 1;
102
103	unsigned int requested;
104	struct resource rsrc[3];
105
106	int num_freqs;
107	const int *freq_table;
108	unsigned int freqs_ok;		/* bit flags */
109	unsigned int formats_ok;	/* pcm hwinfo */
110	int active;
111	int rate_index;
112	int format;			/* current format */
113
114	spinlock_t reg_lock;
115	volatile struct awacs_regs __iomem *awacs;
116	int awacs_reg[8]; /* register cache */
117	unsigned int hp_stat_mask;
118
119	unsigned char __iomem *latch_base;
120	unsigned char __iomem *macio_base;
121
122	struct pmac_stream playback;
123	struct pmac_stream capture;
124
125	struct pmac_dbdma extra_dma;
126
127	int irq, tx_irq, rx_irq;
128
129	struct snd_pcm *pcm;
130
131	struct pmac_beep *beep;
132
133	unsigned int control_mask;	/* control mask */
134
135	/* mixer stuffs */
136	void *mixer_data;
137	void (*mixer_free)(struct snd_pmac *);
138	struct snd_kcontrol *master_sw_ctl;
139	struct snd_kcontrol *speaker_sw_ctl;
140	struct snd_kcontrol *drc_sw_ctl;	/* only used for tumbler -ReneR */
141	struct snd_kcontrol *hp_detect_ctl;
142	struct snd_kcontrol *lineout_sw_ctl;
143
144	/* lowlevel callbacks */
145	void (*set_format)(struct snd_pmac *chip);
146	void (*update_automute)(struct snd_pmac *chip, int do_notify);
147	int (*detect_headphone)(struct snd_pmac *chip);
148#ifdef CONFIG_PM
149	void (*suspend)(struct snd_pmac *chip);
150	void (*resume)(struct snd_pmac *chip);
151#endif
152
153};
154
155
156/* exported functions */
157int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return);
158int snd_pmac_pcm_new(struct snd_pmac *chip);
159int snd_pmac_attach_beep(struct snd_pmac *chip);
160void snd_pmac_detach_beep(struct snd_pmac *chip);
161void snd_pmac_beep_stop(struct snd_pmac *chip);
162unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate);
163
164void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed);
165void snd_pmac_beep_dma_stop(struct snd_pmac *chip);
166
167#ifdef CONFIG_PM
168void snd_pmac_suspend(struct snd_pmac *chip);
169void snd_pmac_resume(struct snd_pmac *chip);
170#endif
171
172/* initialize mixer */
173int snd_pmac_awacs_init(struct snd_pmac *chip);
174int snd_pmac_burgundy_init(struct snd_pmac *chip);
175int snd_pmac_daca_init(struct snd_pmac *chip);
176int snd_pmac_tumbler_init(struct snd_pmac *chip);
177int snd_pmac_tumbler_post_init(void);
178
179/* i2c functions */
180struct pmac_keywest {
181	int addr;
182	struct i2c_client *client;
183	int id;
184	int (*init_client)(struct pmac_keywest *i2c);
185	char *name;
186};
187
188int snd_pmac_keywest_init(struct pmac_keywest *i2c);
189void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c);
190
191/* misc */
192#define snd_pmac_boolean_stereo_info	snd_ctl_boolean_stereo_info
193#define snd_pmac_boolean_mono_info	snd_ctl_boolean_mono_info
194
195int snd_pmac_add_automute(struct snd_pmac *chip);
196
197#endif /* __PMAC_H */
v4.17
 
  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 19 */
 20
 21
 22#ifndef __PMAC_H
 23#define __PMAC_H
 24
 25#include <sound/control.h>
 26#include <sound/pcm.h>
 27#include "awacs.h"
 28
 29#include <linux/adb.h>
 30#ifdef CONFIG_ADB_CUDA
 31#include <linux/cuda.h>
 32#endif
 33#ifdef CONFIG_ADB_PMU
 34#include <linux/pmu.h>
 35#endif
 36#include <linux/nvram.h>
 37#include <linux/tty.h>
 38#include <linux/vt_kern.h>
 39#include <asm/dbdma.h>
 40#include <asm/prom.h>
 41#include <asm/machdep.h>
 42
 43/* maximum number of fragments */
 44#define PMAC_MAX_FRAGS		32
 45
 46
 47#define PMAC_SUPPORT_AUTOMUTE
 48
 49/*
 50 * DBDMA space
 51 */
 52struct pmac_dbdma {
 53	dma_addr_t dma_base;
 54	dma_addr_t addr;
 55	struct dbdma_cmd __iomem *cmds;
 56	void *space;
 57	int size;
 58};
 59
 60/*
 61 * playback/capture stream
 62 */
 63struct pmac_stream {
 64	int running;	/* boolean */
 65
 66	int stream;	/* PLAYBACK/CAPTURE */
 67
 68	int dma_size; /* in bytes */
 69	int period_size; /* in bytes */
 70	int buffer_size; /* in kbytes */
 71	int nperiods, cur_period;
 72
 73	struct pmac_dbdma cmd;
 74	volatile struct dbdma_regs __iomem *dma;
 75
 76	struct snd_pcm_substream *substream;
 77
 78	unsigned int cur_freqs;		/* currently available frequencies */
 79	unsigned int cur_formats;	/* currently available formats */
 80};
 81
 82
 83/*
 84 */
 85
 86enum snd_pmac_model {
 87	PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER,
 88	PMAC_SNAPPER
 89};
 90
 91struct snd_pmac {
 92	struct snd_card *card;
 93
 94	/* h/w info */
 95	struct device_node *node;
 96	struct pci_dev *pdev;
 97	unsigned int revision;
 98	unsigned int manufacturer;
 99	unsigned int subframe;
100	unsigned int device_id;
101	enum snd_pmac_model model;
102
103	unsigned int has_iic : 1;
104	unsigned int is_pbook_3400 : 1;
105	unsigned int is_pbook_G3 : 1;
106	unsigned int is_k2 : 1;
107
108	unsigned int can_byte_swap : 1;
109	unsigned int can_duplex : 1;
110	unsigned int can_capture : 1;
111
112	unsigned int auto_mute : 1;
113	unsigned int initialized : 1;
114	unsigned int feature_is_set : 1;
115
116	unsigned int requested;
117	struct resource rsrc[3];
118
119	int num_freqs;
120	int *freq_table;
121	unsigned int freqs_ok;		/* bit flags */
122	unsigned int formats_ok;	/* pcm hwinfo */
123	int active;
124	int rate_index;
125	int format;			/* current format */
126
127	spinlock_t reg_lock;
128	volatile struct awacs_regs __iomem *awacs;
129	int awacs_reg[8]; /* register cache */
130	unsigned int hp_stat_mask;
131
132	unsigned char __iomem *latch_base;
133	unsigned char __iomem *macio_base;
134
135	struct pmac_stream playback;
136	struct pmac_stream capture;
137
138	struct pmac_dbdma extra_dma;
139
140	int irq, tx_irq, rx_irq;
141
142	struct snd_pcm *pcm;
143
144	struct pmac_beep *beep;
145
146	unsigned int control_mask;	/* control mask */
147
148	/* mixer stuffs */
149	void *mixer_data;
150	void (*mixer_free)(struct snd_pmac *);
151	struct snd_kcontrol *master_sw_ctl;
152	struct snd_kcontrol *speaker_sw_ctl;
153	struct snd_kcontrol *drc_sw_ctl;	/* only used for tumbler -ReneR */
154	struct snd_kcontrol *hp_detect_ctl;
155	struct snd_kcontrol *lineout_sw_ctl;
156
157	/* lowlevel callbacks */
158	void (*set_format)(struct snd_pmac *chip);
159	void (*update_automute)(struct snd_pmac *chip, int do_notify);
160	int (*detect_headphone)(struct snd_pmac *chip);
161#ifdef CONFIG_PM
162	void (*suspend)(struct snd_pmac *chip);
163	void (*resume)(struct snd_pmac *chip);
164#endif
165
166};
167
168
169/* exported functions */
170int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return);
171int snd_pmac_pcm_new(struct snd_pmac *chip);
172int snd_pmac_attach_beep(struct snd_pmac *chip);
173void snd_pmac_detach_beep(struct snd_pmac *chip);
174void snd_pmac_beep_stop(struct snd_pmac *chip);
175unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate);
176
177void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed);
178void snd_pmac_beep_dma_stop(struct snd_pmac *chip);
179
180#ifdef CONFIG_PM
181void snd_pmac_suspend(struct snd_pmac *chip);
182void snd_pmac_resume(struct snd_pmac *chip);
183#endif
184
185/* initialize mixer */
186int snd_pmac_awacs_init(struct snd_pmac *chip);
187int snd_pmac_burgundy_init(struct snd_pmac *chip);
188int snd_pmac_daca_init(struct snd_pmac *chip);
189int snd_pmac_tumbler_init(struct snd_pmac *chip);
190int snd_pmac_tumbler_post_init(void);
191
192/* i2c functions */
193struct pmac_keywest {
194	int addr;
195	struct i2c_client *client;
196	int id;
197	int (*init_client)(struct pmac_keywest *i2c);
198	char *name;
199};
200
201int snd_pmac_keywest_init(struct pmac_keywest *i2c);
202void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c);
203
204/* misc */
205#define snd_pmac_boolean_stereo_info	snd_ctl_boolean_stereo_info
206#define snd_pmac_boolean_mono_info	snd_ctl_boolean_mono_info
207
208int snd_pmac_add_automute(struct snd_pmac *chip);
209
210#endif /* __PMAC_H */