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 */
v6.8
  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#include <asm/pmac_feature.h>
 30
 31/* maximum number of fragments */
 32#define PMAC_MAX_FRAGS		32
 33
 34
 35#define PMAC_SUPPORT_AUTOMUTE
 36
 37/*
 38 * DBDMA space
 39 */
 40struct pmac_dbdma {
 41	dma_addr_t dma_base;
 42	dma_addr_t addr;
 43	struct dbdma_cmd __iomem *cmds;
 44	void *space;
 45	int size;
 46};
 47
 48/*
 49 * playback/capture stream
 50 */
 51struct pmac_stream {
 52	int running;	/* boolean */
 53
 54	int stream;	/* PLAYBACK/CAPTURE */
 55
 56	int dma_size; /* in bytes */
 57	int period_size; /* in bytes */
 58	int buffer_size; /* in kbytes */
 59	int nperiods, cur_period;
 60
 61	struct pmac_dbdma cmd;
 62	volatile struct dbdma_regs __iomem *dma;
 63
 64	struct snd_pcm_substream *substream;
 65
 66	unsigned int cur_freqs;		/* currently available frequencies */
 67	unsigned int cur_formats;	/* currently available formats */
 68};
 69
 70
 71/*
 72 */
 73
 74enum snd_pmac_model {
 75	PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER,
 76	PMAC_SNAPPER
 77};
 78
 79struct snd_pmac {
 80	struct snd_card *card;
 81
 82	/* h/w info */
 83	struct device_node *node;
 84	struct pci_dev *pdev;
 85	unsigned int revision;
 86	unsigned int manufacturer;
 87	unsigned int subframe;
 88	unsigned int device_id;
 89	enum snd_pmac_model model;
 90
 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;
 95
 96	unsigned int can_byte_swap : 1;
 97	unsigned int can_duplex : 1;
 98	unsigned int can_capture : 1;
 99
100	unsigned int auto_mute : 1;
101	unsigned int initialized : 1;
102	unsigned int feature_is_set : 1;
103
104	unsigned int requested;
105	struct resource rsrc[3];
106
107	int num_freqs;
108	const int *freq_table;
109	unsigned int freqs_ok;		/* bit flags */
110	unsigned int formats_ok;	/* pcm hwinfo */
111	int active;
112	int rate_index;
113	int format;			/* current format */
114
115	spinlock_t reg_lock;
116	volatile struct awacs_regs __iomem *awacs;
117	int awacs_reg[8]; /* register cache */
118	unsigned int hp_stat_mask;
119
120	unsigned char __iomem *latch_base;
121	unsigned char __iomem *macio_base;
122
123	struct pmac_stream playback;
124	struct pmac_stream capture;
125
126	struct pmac_dbdma extra_dma;
127
128	int irq, tx_irq, rx_irq;
129
130	struct snd_pcm *pcm;
131
132	struct pmac_beep *beep;
133
134	unsigned int control_mask;	/* control mask */
135
136	/* mixer stuffs */
137	void *mixer_data;
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;
144
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);
149#ifdef CONFIG_PM
150	void (*suspend)(struct snd_pmac *chip);
151	void (*resume)(struct snd_pmac *chip);
152#endif
153
154};
155
156
157/* exported functions */
158int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return);
159int snd_pmac_pcm_new(struct snd_pmac *chip);
160int snd_pmac_attach_beep(struct snd_pmac *chip);
161void snd_pmac_detach_beep(struct snd_pmac *chip);
162void snd_pmac_beep_stop(struct snd_pmac *chip);
163unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate);
164
165void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed);
166void snd_pmac_beep_dma_stop(struct snd_pmac *chip);
167
168#ifdef CONFIG_PM
169void snd_pmac_suspend(struct snd_pmac *chip);
170void snd_pmac_resume(struct snd_pmac *chip);
171#endif
172
173/* initialize mixer */
174int snd_pmac_awacs_init(struct snd_pmac *chip);
175int snd_pmac_burgundy_init(struct snd_pmac *chip);
176int snd_pmac_daca_init(struct snd_pmac *chip);
177int snd_pmac_tumbler_init(struct snd_pmac *chip);
178int snd_pmac_tumbler_post_init(void);
179
180/* i2c functions */
181struct pmac_keywest {
182	int addr;
183	struct i2c_client *client;
184	int id;
185	int (*init_client)(struct pmac_keywest *i2c);
186	char *name;
187};
188
189int snd_pmac_keywest_init(struct pmac_keywest *i2c);
190void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c);
191
192/* misc */
193#define snd_pmac_boolean_stereo_info	snd_ctl_boolean_stereo_info
194#define snd_pmac_boolean_mono_info	snd_ctl_boolean_mono_info
195
196int snd_pmac_add_automute(struct snd_pmac *chip);
197
198#endif /* __PMAC_H */