11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * Driver for PowerMac onboard soundchips 31da177e4SLinus Torvalds * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de> 41da177e4SLinus Torvalds * based on dmasound.c. 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 71da177e4SLinus Torvalds * it under the terms of the GNU General Public License as published by 81da177e4SLinus Torvalds * the Free Software Foundation; either version 2 of the License, or 91da177e4SLinus Torvalds * (at your option) any later version. 101da177e4SLinus Torvalds * 111da177e4SLinus Torvalds * This program is distributed in the hope that it will be useful, 121da177e4SLinus Torvalds * but WITHOUT ANY WARRANTY; without even the implied warranty of 131da177e4SLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 141da177e4SLinus Torvalds * GNU General Public License for more details. 151da177e4SLinus Torvalds * 161da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License 171da177e4SLinus Torvalds * along with this program; if not, write to the Free Software 181da177e4SLinus Torvalds * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 191da177e4SLinus Torvalds */ 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds 221da177e4SLinus Torvalds #ifndef __PMAC_H 231da177e4SLinus Torvalds #define __PMAC_H 241da177e4SLinus Torvalds 251da177e4SLinus Torvalds #include <sound/control.h> 261da177e4SLinus Torvalds #include <sound/pcm.h> 271da177e4SLinus Torvalds #include "awacs.h" 281da177e4SLinus Torvalds 291da177e4SLinus Torvalds #include <linux/adb.h> 301da177e4SLinus Torvalds #ifdef CONFIG_ADB_CUDA 311da177e4SLinus Torvalds #include <linux/cuda.h> 321da177e4SLinus Torvalds #endif 331da177e4SLinus Torvalds #ifdef CONFIG_ADB_PMU 341da177e4SLinus Torvalds #include <linux/pmu.h> 351da177e4SLinus Torvalds #endif 361da177e4SLinus Torvalds #include <linux/nvram.h> 371da177e4SLinus Torvalds #include <linux/tty.h> 381da177e4SLinus Torvalds #include <linux/vt_kern.h> 391da177e4SLinus Torvalds #include <asm/dbdma.h> 401da177e4SLinus Torvalds #include <asm/prom.h> 411da177e4SLinus Torvalds #include <asm/machdep.h> 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds /* maximum number of fragments */ 441da177e4SLinus Torvalds #define PMAC_MAX_FRAGS 32 451da177e4SLinus Torvalds 461da177e4SLinus Torvalds 471da177e4SLinus Torvalds #define PMAC_SUPPORT_AUTOMUTE 481da177e4SLinus Torvalds 491da177e4SLinus Torvalds /* 501da177e4SLinus Torvalds * DBDMA space 511da177e4SLinus Torvalds */ 5265b29f50STakashi Iwai struct pmac_dbdma { 537bbd8277SBenjamin Herrenschmidt dma_addr_t dma_base; 547bbd8277SBenjamin Herrenschmidt dma_addr_t addr; 551da177e4SLinus Torvalds struct dbdma_cmd __iomem *cmds; 561da177e4SLinus Torvalds void *space; 571da177e4SLinus Torvalds int size; 581da177e4SLinus Torvalds }; 591da177e4SLinus Torvalds 601da177e4SLinus Torvalds /* 611da177e4SLinus Torvalds * playback/capture stream 621da177e4SLinus Torvalds */ 6365b29f50STakashi Iwai struct pmac_stream { 641da177e4SLinus Torvalds int running; /* boolean */ 651da177e4SLinus Torvalds 661da177e4SLinus Torvalds int stream; /* PLAYBACK/CAPTURE */ 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds int dma_size; /* in bytes */ 691da177e4SLinus Torvalds int period_size; /* in bytes */ 701da177e4SLinus Torvalds int buffer_size; /* in kbytes */ 711da177e4SLinus Torvalds int nperiods, cur_period; 721da177e4SLinus Torvalds 7365b29f50STakashi Iwai struct pmac_dbdma cmd; 741da177e4SLinus Torvalds volatile struct dbdma_regs __iomem *dma; 751da177e4SLinus Torvalds 7665b29f50STakashi Iwai struct snd_pcm_substream *substream; 771da177e4SLinus Torvalds 781da177e4SLinus Torvalds unsigned int cur_freqs; /* currently available frequencies */ 791da177e4SLinus Torvalds unsigned int cur_formats; /* currently available formats */ 801da177e4SLinus Torvalds }; 811da177e4SLinus Torvalds 821da177e4SLinus Torvalds 831da177e4SLinus Torvalds /* 841da177e4SLinus Torvalds */ 851da177e4SLinus Torvalds 861da177e4SLinus Torvalds enum snd_pmac_model { 871f7b49d0SBenjamin Herrenschmidt PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER, 8855c385adSJohannes Berg PMAC_SNAPPER 891da177e4SLinus Torvalds }; 901da177e4SLinus Torvalds 911da177e4SLinus Torvalds struct snd_pmac { 9265b29f50STakashi Iwai struct snd_card *card; 931da177e4SLinus Torvalds 941da177e4SLinus Torvalds /* h/w info */ 951da177e4SLinus Torvalds struct device_node *node; 967bbd8277SBenjamin Herrenschmidt struct pci_dev *pdev; 971da177e4SLinus Torvalds unsigned int revision; 981da177e4SLinus Torvalds unsigned int manufacturer; 991da177e4SLinus Torvalds unsigned int subframe; 1001da177e4SLinus Torvalds unsigned int device_id; 1011da177e4SLinus Torvalds enum snd_pmac_model model; 1021da177e4SLinus Torvalds 1031da177e4SLinus Torvalds unsigned int has_iic : 1; 1041da177e4SLinus Torvalds unsigned int is_pbook_3400 : 1; 1051da177e4SLinus Torvalds unsigned int is_pbook_G3 : 1; 1067bbd8277SBenjamin Herrenschmidt unsigned int is_k2 : 1; 1071da177e4SLinus Torvalds 1081da177e4SLinus Torvalds unsigned int can_byte_swap : 1; 1091da177e4SLinus Torvalds unsigned int can_duplex : 1; 1101da177e4SLinus Torvalds unsigned int can_capture : 1; 1111da177e4SLinus Torvalds 1121da177e4SLinus Torvalds unsigned int auto_mute : 1; 1131da177e4SLinus Torvalds unsigned int initialized : 1; 1141da177e4SLinus Torvalds unsigned int feature_is_set : 1; 1151da177e4SLinus Torvalds 116cc5d0189SBenjamin Herrenschmidt unsigned int requested; 117cc5d0189SBenjamin Herrenschmidt struct resource rsrc[3]; 1181da177e4SLinus Torvalds 1191da177e4SLinus Torvalds int num_freqs; 1201da177e4SLinus Torvalds int *freq_table; 1211da177e4SLinus Torvalds unsigned int freqs_ok; /* bit flags */ 1221da177e4SLinus Torvalds unsigned int formats_ok; /* pcm hwinfo */ 1231da177e4SLinus Torvalds int active; 1241da177e4SLinus Torvalds int rate_index; 1251da177e4SLinus Torvalds int format; /* current format */ 1261da177e4SLinus Torvalds 1271da177e4SLinus Torvalds spinlock_t reg_lock; 1281da177e4SLinus Torvalds volatile struct awacs_regs __iomem *awacs; 1291da177e4SLinus Torvalds int awacs_reg[8]; /* register cache */ 1301da177e4SLinus Torvalds unsigned int hp_stat_mask; 1311da177e4SLinus Torvalds 1321da177e4SLinus Torvalds unsigned char __iomem *latch_base; 1331da177e4SLinus Torvalds unsigned char __iomem *macio_base; 1341da177e4SLinus Torvalds 13565b29f50STakashi Iwai struct pmac_stream playback; 13665b29f50STakashi Iwai struct pmac_stream capture; 1371da177e4SLinus Torvalds 13865b29f50STakashi Iwai struct pmac_dbdma extra_dma; 1391da177e4SLinus Torvalds 1401da177e4SLinus Torvalds int irq, tx_irq, rx_irq; 1411da177e4SLinus Torvalds 14265b29f50STakashi Iwai struct snd_pcm *pcm; 1431da177e4SLinus Torvalds 14465b29f50STakashi Iwai struct pmac_beep *beep; 1451da177e4SLinus Torvalds 1461da177e4SLinus Torvalds unsigned int control_mask; /* control mask */ 1471da177e4SLinus Torvalds 1481da177e4SLinus Torvalds /* mixer stuffs */ 1491da177e4SLinus Torvalds void *mixer_data; 15065b29f50STakashi Iwai void (*mixer_free)(struct snd_pmac *); 15165b29f50STakashi Iwai struct snd_kcontrol *master_sw_ctl; 15265b29f50STakashi Iwai struct snd_kcontrol *speaker_sw_ctl; 15365b29f50STakashi Iwai struct snd_kcontrol *drc_sw_ctl; /* only used for tumbler -ReneR */ 15465b29f50STakashi Iwai struct snd_kcontrol *hp_detect_ctl; 15565b29f50STakashi Iwai struct snd_kcontrol *lineout_sw_ctl; 1561da177e4SLinus Torvalds 1571da177e4SLinus Torvalds /* lowlevel callbacks */ 15865b29f50STakashi Iwai void (*set_format)(struct snd_pmac *chip); 15965b29f50STakashi Iwai void (*update_automute)(struct snd_pmac *chip, int do_notify); 16065b29f50STakashi Iwai int (*detect_headphone)(struct snd_pmac *chip); 1618c870933SBenjamin Herrenschmidt #ifdef CONFIG_PM 16265b29f50STakashi Iwai void (*suspend)(struct snd_pmac *chip); 16365b29f50STakashi Iwai void (*resume)(struct snd_pmac *chip); 1641da177e4SLinus Torvalds #endif 1651da177e4SLinus Torvalds 1661da177e4SLinus Torvalds }; 1671da177e4SLinus Torvalds 1681da177e4SLinus Torvalds 1691da177e4SLinus Torvalds /* exported functions */ 17065b29f50STakashi Iwai int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return); 17165b29f50STakashi Iwai int snd_pmac_pcm_new(struct snd_pmac *chip); 17265b29f50STakashi Iwai int snd_pmac_attach_beep(struct snd_pmac *chip); 17365b29f50STakashi Iwai void snd_pmac_detach_beep(struct snd_pmac *chip); 17465b29f50STakashi Iwai void snd_pmac_beep_stop(struct snd_pmac *chip); 17565b29f50STakashi Iwai unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate); 1761da177e4SLinus Torvalds 17765b29f50STakashi Iwai void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed); 17865b29f50STakashi Iwai void snd_pmac_beep_dma_stop(struct snd_pmac *chip); 1791da177e4SLinus Torvalds 1805e12bea0STakashi Iwai #ifdef CONFIG_PM 1815e12bea0STakashi Iwai void snd_pmac_suspend(struct snd_pmac *chip); 1825e12bea0STakashi Iwai void snd_pmac_resume(struct snd_pmac *chip); 1835e12bea0STakashi Iwai #endif 1845e12bea0STakashi Iwai 1851da177e4SLinus Torvalds /* initialize mixer */ 18665b29f50STakashi Iwai int snd_pmac_awacs_init(struct snd_pmac *chip); 18765b29f50STakashi Iwai int snd_pmac_burgundy_init(struct snd_pmac *chip); 18865b29f50STakashi Iwai int snd_pmac_daca_init(struct snd_pmac *chip); 18965b29f50STakashi Iwai int snd_pmac_tumbler_init(struct snd_pmac *chip); 1901da177e4SLinus Torvalds int snd_pmac_tumbler_post_init(void); 1911da177e4SLinus Torvalds 1921da177e4SLinus Torvalds /* i2c functions */ 19365b29f50STakashi Iwai struct pmac_keywest { 1941da177e4SLinus Torvalds int addr; 1951da177e4SLinus Torvalds struct i2c_client *client; 1961da177e4SLinus Torvalds int id; 19765b29f50STakashi Iwai int (*init_client)(struct pmac_keywest *i2c); 1981da177e4SLinus Torvalds char *name; 19965b29f50STakashi Iwai }; 2001da177e4SLinus Torvalds 20165b29f50STakashi Iwai int snd_pmac_keywest_init(struct pmac_keywest *i2c); 20265b29f50STakashi Iwai void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c); 2031da177e4SLinus Torvalds 2041da177e4SLinus Torvalds /* misc */ 205*a5ce8890STakashi Iwai #define snd_pmac_boolean_stereo_info snd_ctl_boolean_stereo_info 206*a5ce8890STakashi Iwai #define snd_pmac_boolean_mono_info snd_ctl_boolean_mono_info 2071da177e4SLinus Torvalds 20865b29f50STakashi Iwai int snd_pmac_add_automute(struct snd_pmac *chip); 2091da177e4SLinus Torvalds 2101da177e4SLinus Torvalds #endif /* __PMAC_H */ 211