From fc37449f7959aeedc2d38b183468ae73c9166fb6 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Thu, 18 Oct 2007 03:06:12 -0700 Subject: The next round of scheduled OSS code removal This patch contains the next round of scheduled OSS code removal. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- sound/oss/Makefile | 1 - sound/oss/dmasound/Makefile | 6 - sound/oss/dmasound/awacs_defs.h | 251 --- sound/oss/dmasound/dac3550a.c | 209 --- sound/oss/dmasound/dmasound.h | 13 - sound/oss/dmasound/dmasound_awacs.c | 3215 ---------------------------------- sound/oss/dmasound/dmasound_core.c | 287 --- sound/oss/dmasound/tas3001c.c | 849 --------- sound/oss/dmasound/tas3001c.h | 64 - sound/oss/dmasound/tas3001c_tables.c | 375 ---- sound/oss/dmasound/tas3004.c | 1138 ------------ sound/oss/dmasound/tas3004.h | 77 - sound/oss/dmasound/tas3004_tables.c | 301 ---- sound/oss/dmasound/tas_common.c | 214 --- sound/oss/dmasound/tas_common.h | 284 --- sound/oss/dmasound/tas_eq_prefs.h | 24 - sound/oss/dmasound/tas_ioctl.h | 23 - sound/oss/dmasound/trans_16.c | 898 ---------- sound/oss/es1371.c | 3131 --------------------------------- 19 files changed, 11360 deletions(-) delete mode 100644 sound/oss/dmasound/awacs_defs.h delete mode 100644 sound/oss/dmasound/dac3550a.c delete mode 100644 sound/oss/dmasound/dmasound_awacs.c delete mode 100644 sound/oss/dmasound/tas3001c.c delete mode 100644 sound/oss/dmasound/tas3001c.h delete mode 100644 sound/oss/dmasound/tas3001c_tables.c delete mode 100644 sound/oss/dmasound/tas3004.c delete mode 100644 sound/oss/dmasound/tas3004.h delete mode 100644 sound/oss/dmasound/tas3004_tables.c delete mode 100644 sound/oss/dmasound/tas_common.c delete mode 100644 sound/oss/dmasound/tas_common.h delete mode 100644 sound/oss/dmasound/tas_eq_prefs.h delete mode 100644 sound/oss/dmasound/tas_ioctl.h delete mode 100644 sound/oss/dmasound/trans_16.c delete mode 100644 sound/oss/es1371.c (limited to 'sound') diff --git a/sound/oss/Makefile b/sound/oss/Makefile index 1200670017bd..f883c4b676ab 100644 --- a/sound/oss/Makefile +++ b/sound/oss/Makefile @@ -36,7 +36,6 @@ obj-$(CONFIG_SOUND_MSNDCLAS) += msnd.o msnd_classic.o obj-$(CONFIG_SOUND_MSNDPIN) += msnd.o msnd_pinnacle.o obj-$(CONFIG_SOUND_VWSND) += vwsnd.o obj-$(CONFIG_SOUND_ICH) += i810_audio.o ac97_codec.o -obj-$(CONFIG_SOUND_ES1371) += es1371.o ac97_codec.o obj-$(CONFIG_SOUND_AU1550_AC97) += au1550_ac97.o ac97_codec.o obj-$(CONFIG_SOUND_TRIDENT) += trident.o ac97_codec.o obj-$(CONFIG_SOUND_BCM_CS4297A) += swarm_cs4297a.o diff --git a/sound/oss/dmasound/Makefile b/sound/oss/dmasound/Makefile index 4611636b1a81..3c1531652d11 100644 --- a/sound/oss/dmasound/Makefile +++ b/sound/oss/dmasound/Makefile @@ -2,12 +2,6 @@ # Makefile for the DMA sound driver # -dmasound_pmac-y += dmasound_awacs.o \ - trans_16.o dac3550a.o tas_common.o \ - tas3001c.o tas3001c_tables.o \ - tas3004.o tas3004_tables.o - obj-$(CONFIG_DMASOUND_ATARI) += dmasound_core.o dmasound_atari.o -obj-$(CONFIG_DMASOUND_PMAC) += dmasound_core.o dmasound_pmac.o obj-$(CONFIG_DMASOUND_PAULA) += dmasound_core.o dmasound_paula.o obj-$(CONFIG_DMASOUND_Q40) += dmasound_core.o dmasound_q40.o diff --git a/sound/oss/dmasound/awacs_defs.h b/sound/oss/dmasound/awacs_defs.h deleted file mode 100644 index 2194f46b046c..000000000000 --- a/sound/oss/dmasound/awacs_defs.h +++ /dev/null @@ -1,251 +0,0 @@ -/*********************************************************/ -/* This file was written by someone, somewhere, sometime */ -/* And is released into the Public Domain */ -/*********************************************************/ - -#ifndef _AWACS_DEFS_H_ -#define _AWACS_DEFS_H_ - -/*******************************/ -/* AWACs Audio Register Layout */ -/*******************************/ - -struct awacs_regs { - unsigned control; /* Audio control register */ - unsigned pad0[3]; - unsigned codec_ctrl; /* Codec control register */ - unsigned pad1[3]; - unsigned codec_stat; /* Codec status register */ - unsigned pad2[3]; - unsigned clip_count; /* Clipping count register */ - unsigned pad3[3]; - unsigned byteswap; /* Data is little-endian if 1 */ -}; - -/*******************/ -/* Audio Bit Masks */ -/*******************/ - -/* Audio Control Reg Bit Masks */ -/* ----- ------- --- --- ----- */ -#define MASK_ISFSEL (0xf) /* Input SubFrame Select */ -#define MASK_OSFSEL (0xf << 4) /* Output SubFrame Select */ -#define MASK_RATE (0x7 << 8) /* Sound Rate */ -#define MASK_CNTLERR (0x1 << 11) /* Error */ -#define MASK_PORTCHG (0x1 << 12) /* Port Change */ -#define MASK_IEE (0x1 << 13) /* Enable Interrupt on Error */ -#define MASK_IEPC (0x1 << 14) /* Enable Interrupt on Port Change */ -#define MASK_SSFSEL (0x3 << 15) /* Status SubFrame Select */ - -/* Audio Codec Control Reg Bit Masks */ -/* ----- ----- ------- --- --- ----- */ -#define MASK_NEWECMD (0x1 << 24) /* Lock: don't write to reg when 1 */ -#define MASK_EMODESEL (0x3 << 22) /* Send info out on which frame? */ -#define MASK_EXMODEADDR (0x3ff << 12) /* Extended Mode Address -- 10 bits */ -#define MASK_EXMODEDATA (0xfff) /* Extended Mode Data -- 12 bits */ - -/* Audio Codec Control Address Values / Masks */ -/* ----- ----- ------- ------- ------ - ----- */ -#define MASK_ADDR0 (0x0 << 12) /* Expanded Data Mode Address 0 */ -#define MASK_ADDR_MUX MASK_ADDR0 /* Mux Control */ -#define MASK_ADDR_GAIN MASK_ADDR0 - -#define MASK_ADDR1 (0x1 << 12) /* Expanded Data Mode Address 1 */ -#define MASK_ADDR_MUTE MASK_ADDR1 -#define MASK_ADDR_RATE MASK_ADDR1 - -#define MASK_ADDR2 (0x2 << 12) /* Expanded Data Mode Address 2 */ -#define MASK_ADDR_VOLA MASK_ADDR2 /* Volume Control A -- Headphones */ -#define MASK_ADDR_VOLHD MASK_ADDR2 - -#define MASK_ADDR4 (0x4 << 12) /* Expanded Data Mode Address 4 */ -#define MASK_ADDR_VOLC MASK_ADDR4 /* Volume Control C -- Speaker */ -#define MASK_ADDR_VOLSPK MASK_ADDR4 - -/* additional registers of screamer */ -#define MASK_ADDR5 (0x5 << 12) /* Expanded Data Mode Address 5 */ -#define MASK_ADDR6 (0x6 << 12) /* Expanded Data Mode Address 6 */ -#define MASK_ADDR7 (0x7 << 12) /* Expanded Data Mode Address 7 */ - -/* Address 0 Bit Masks & Macros */ -/* ------- - --- ----- - ------ */ -#define MASK_GAINRIGHT (0xf) /* Gain Right Mask */ -#define MASK_GAINLEFT (0xf << 4) /* Gain Left Mask */ -#define MASK_GAINLINE (0x1 << 8) /* Disable Mic preamp */ -#define MASK_GAINMIC (0x0 << 8) /* Enable Mic preamp */ - -#define MASK_MUX_CD (0x1 << 9) /* Select CD in MUX */ -#define MASK_MUX_MIC (0x1 << 10) /* Select Mic in MUX */ -#define MASK_MUX_AUDIN (0x1 << 11) /* Select Audio In in MUX */ -#define MASK_MUX_LINE MASK_MUX_AUDIN - -#define GAINRIGHT(x) ((x) & MASK_GAINRIGHT) -#define GAINLEFT(x) (((x) << 4) & MASK_GAINLEFT) - -#define DEF_CD_GAIN 0x00bb -#define DEF_MIC_GAIN 0x00cc - -/* Address 1 Bit Masks */ -/* ------- - --- ----- */ -#define MASK_ADDR1RES1 (0x3) /* Reserved */ -#define MASK_RECALIBRATE (0x1 << 2) /* Recalibrate */ -#define MASK_SAMPLERATE (0x7 << 3) /* Sample Rate: */ -#define MASK_LOOPTHRU (0x1 << 6) /* Loopthrough Enable */ -#define MASK_CMUTE (0x1 << 7) /* Output C (Speaker) Mute when 1 */ -#define MASK_SPKMUTE MASK_CMUTE -#define MASK_ADDR1RES2 (0x1 << 8) /* Reserved */ -#define MASK_AMUTE (0x1 << 9) /* Output A (Headphone) Mute when 1 */ -#define MASK_HDMUTE MASK_AMUTE -#define MASK_PAROUT0 (0x1 << 10) /* Parallel Output 0 */ -#define MASK_PAROUT1 (0x2 << 10) /* Parallel Output 1 */ - -#define MASK_MIC_BOOST (0x4) /* screamer mic boost */ - -#define SAMPLERATE_48000 (0x0 << 3) /* 48 or 44.1 kHz */ -#define SAMPLERATE_32000 (0x1 << 3) /* 32 or 29.4 kHz */ -#define SAMPLERATE_24000 (0x2 << 3) /* 24 or 22.05 kHz */ -#define SAMPLERATE_19200 (0x3 << 3) /* 19.2 or 17.64 kHz */ -#define SAMPLERATE_16000 (0x4 << 3) /* 16 or 14.7 kHz */ -#define SAMPLERATE_12000 (0x5 << 3) /* 12 or 11.025 kHz */ -#define SAMPLERATE_9600 (0x6 << 3) /* 9.6 or 8.82 kHz */ -#define SAMPLERATE_8000 (0x7 << 3) /* 8 or 7.35 kHz */ - -/* Address 2 & 4 Bit Masks & Macros */ -/* ------- - - - --- ----- - ------ */ -#define MASK_OUTVOLRIGHT (0xf) /* Output Right Volume */ -#define MASK_ADDR2RES1 (0x2 << 4) /* Reserved */ -#define MASK_ADDR4RES1 MASK_ADDR2RES1 -#define MASK_OUTVOLLEFT (0xf << 6) /* Output Left Volume */ -#define MASK_ADDR2RES2 (0x2 << 10) /* Reserved */ -#define MASK_ADDR4RES2 MASK_ADDR2RES2 - -#define VOLRIGHT(x) (((~(x)) & MASK_OUTVOLRIGHT)) -#define VOLLEFT(x) (((~(x)) << 6) & MASK_OUTVOLLEFT) - -/* Audio Codec Status Reg Bit Masks */ -/* ----- ----- ------ --- --- ----- */ -#define MASK_EXTEND (0x1 << 23) /* Extend */ -#define MASK_VALID (0x1 << 22) /* Valid Data? */ -#define MASK_OFLEFT (0x1 << 21) /* Overflow Left */ -#define MASK_OFRIGHT (0x1 << 20) /* Overflow Right */ -#define MASK_ERRCODE (0xf << 16) /* Error Code */ -#define MASK_REVISION (0xf << 12) /* Revision Number */ -#define MASK_MFGID (0xf << 8) /* Mfg. ID */ -#define MASK_CODSTATRES (0xf << 4) /* bits 4 - 7 reserved */ -#define MASK_INPPORT (0xf) /* Input Port */ -#define MASK_HDPCONN 8 /* headphone plugged in */ - -/* Clipping Count Reg Bit Masks */ -/* -------- ----- --- --- ----- */ -#define MASK_CLIPLEFT (0xff << 7) /* Clipping Count, Left Channel */ -#define MASK_CLIPRIGHT (0xff) /* Clipping Count, Right Channel */ - -/* DBDMA ChannelStatus Bit Masks */ -/* ----- ------------- --- ----- */ -#define MASK_CSERR (0x1 << 7) /* Error */ -#define MASK_EOI (0x1 << 6) /* End of Input -- only for Input Channel */ -#define MASK_CSUNUSED (0x1f << 1) /* bits 1-5 not used */ -#define MASK_WAIT (0x1) /* Wait */ - -/* Various Rates */ -/* ------- ----- */ -#define RATE_48000 (0x0 << 8) /* 48 kHz */ -#define RATE_44100 (0x0 << 8) /* 44.1 kHz */ -#define RATE_32000 (0x1 << 8) /* 32 kHz */ -#define RATE_29400 (0x1 << 8) /* 29.4 kHz */ -#define RATE_24000 (0x2 << 8) /* 24 kHz */ -#define RATE_22050 (0x2 << 8) /* 22.05 kHz */ -#define RATE_19200 (0x3 << 8) /* 19.2 kHz */ -#define RATE_17640 (0x3 << 8) /* 17.64 kHz */ -#define RATE_16000 (0x4 << 8) /* 16 kHz */ -#define RATE_14700 (0x4 << 8) /* 14.7 kHz */ -#define RATE_12000 (0x5 << 8) /* 12 kHz */ -#define RATE_11025 (0x5 << 8) /* 11.025 kHz */ -#define RATE_9600 (0x6 << 8) /* 9.6 kHz */ -#define RATE_8820 (0x6 << 8) /* 8.82 kHz */ -#define RATE_8000 (0x7 << 8) /* 8 kHz */ -#define RATE_7350 (0x7 << 8) /* 7.35 kHz */ - -#define RATE_LOW 1 /* HIGH = 48kHz, etc; LOW = 44.1kHz, etc. */ - -/*******************/ -/* Burgundy values */ -/*******************/ - -#define MASK_ADDR_BURGUNDY_INPSEL21 (0x11 << 12) -#define MASK_ADDR_BURGUNDY_INPSEL3 (0x12 << 12) - -#define MASK_ADDR_BURGUNDY_GAINCH1 (0x13 << 12) -#define MASK_ADDR_BURGUNDY_GAINCH2 (0x14 << 12) -#define MASK_ADDR_BURGUNDY_GAINCH3 (0x15 << 12) -#define MASK_ADDR_BURGUNDY_GAINCH4 (0x16 << 12) - -#define MASK_ADDR_BURGUNDY_VOLCH1 (0x20 << 12) -#define MASK_ADDR_BURGUNDY_VOLCH2 (0x21 << 12) -#define MASK_ADDR_BURGUNDY_VOLCH3 (0x22 << 12) -#define MASK_ADDR_BURGUNDY_VOLCH4 (0x23 << 12) - -#define MASK_ADDR_BURGUNDY_OUTPUTSELECTS (0x2B << 12) -#define MASK_ADDR_BURGUNDY_OUTPUTENABLES (0x2F << 12) - -#define MASK_ADDR_BURGUNDY_MASTER_VOLUME (0x30 << 12) - -#define MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES (0x60 << 12) - -#define MASK_ADDR_BURGUNDY_ATTENSPEAKER (0x62 << 12) -#define MASK_ADDR_BURGUNDY_ATTENLINEOUT (0x63 << 12) -#define MASK_ADDR_BURGUNDY_ATTENHP (0x64 << 12) - -#define MASK_ADDR_BURGUNDY_VOLCD (MASK_ADDR_BURGUNDY_VOLCH1) -#define MASK_ADDR_BURGUNDY_VOLLINE (MASK_ADDR_BURGUNDY_VOLCH2) -#define MASK_ADDR_BURGUNDY_VOLMIC (MASK_ADDR_BURGUNDY_VOLCH3) -#define MASK_ADDR_BURGUNDY_VOLMODEM (MASK_ADDR_BURGUNDY_VOLCH4) - -#define MASK_ADDR_BURGUNDY_GAINCD (MASK_ADDR_BURGUNDY_GAINCH1) -#define MASK_ADDR_BURGUNDY_GAINLINE (MASK_ADDR_BURGUNDY_GAINCH2) -#define MASK_ADDR_BURGUNDY_GAINMIC (MASK_ADDR_BURGUNDY_GAINCH3) -#define MASK_ADDR_BURGUNDY_GAINMODEM (MASK_ADDR_BURGUNDY_VOLCH4) - - -/* These are all default values for the burgundy */ -#define DEF_BURGUNDY_INPSEL21 (0xAA) -#define DEF_BURGUNDY_INPSEL3 (0x0A) - -#define DEF_BURGUNDY_GAINCD (0x33) -#define DEF_BURGUNDY_GAINLINE (0x44) -#define DEF_BURGUNDY_GAINMIC (0x44) -#define DEF_BURGUNDY_GAINMODEM (0x06) - -/* Remember: lowest volume here is 0x9b */ -#define DEF_BURGUNDY_VOLCD (0xCCCCCCCC) -#define DEF_BURGUNDY_VOLLINE (0x00000000) -#define DEF_BURGUNDY_VOLMIC (0x00000000) -#define DEF_BURGUNDY_VOLMODEM (0xCCCCCCCC) - -#define DEF_BURGUNDY_OUTPUTSELECTS (0x010f010f) -#define DEF_BURGUNDY_OUTPUTENABLES (0x0A) - -#define DEF_BURGUNDY_MASTER_VOLUME (0xFFFFFFFF) - -#define DEF_BURGUNDY_MORE_OUTPUTENABLES (0x7E) - -#define DEF_BURGUNDY_ATTENSPEAKER (0x44) -#define DEF_BURGUNDY_ATTENLINEOUT (0xCC) -#define DEF_BURGUNDY_ATTENHP (0xCC) - -/*********************/ -/* i2s layout values */ -/*********************/ - -#define I2S_REG_INT_CTL 0x00 -#define I2S_REG_SERIAL_FORMAT 0x10 -#define I2S_REG_CODEC_MSG_OUT 0x20 -#define I2S_REG_CODEC_MSG_IN 0x30 -#define I2S_REG_FRAME_COUNT 0x40 -#define I2S_REG_FRAME_MATCH 0x50 -#define I2S_REG_DATAWORD_SIZES 0x60 -#define I2S_REG_PEAKLEVEL_SEL 0x70 -#define I2S_REG_PEAKLEVEL_IN0 0x80 -#define I2S_REG_PEAKLEVEL_IN1 0x90 - -#endif /* _AWACS_DEFS_H_ */ diff --git a/sound/oss/dmasound/dac3550a.c b/sound/oss/dmasound/dac3550a.c deleted file mode 100644 index 0f0d03a55dab..000000000000 --- a/sound/oss/dmasound/dac3550a.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Driver for the i2c/i2s based DAC3550a sound chip used - * on some Apple iBooks. Also known as "DACA". - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of this archive - * for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dmasound.h" - -/* FYI: This code was derived from the tas3001c.c Texas/Tumbler mixer - * control code, as well as info derived from the AppleDACAAudio driver - * from Darwin CVS (main thing I derived being register numbers and - * values, as well as when to make the calls). */ - -#define I2C_DRIVERID_DACA (0xFDCB) - -#define DACA_VERSION "0.1" -#define DACA_DATE "20010930" - -static int cur_left_vol; -static int cur_right_vol; -static struct i2c_client *daca_client; - -static int daca_attach_adapter(struct i2c_adapter *adapter); -static int daca_detect_client(struct i2c_adapter *adapter, int address); -static int daca_detach_client(struct i2c_client *client); - -struct i2c_driver daca_driver = { - .driver = { - .name = "DAC3550A driver V " DACA_VERSION, - }, - .id = I2C_DRIVERID_DACA, - .attach_adapter = daca_attach_adapter, - .detach_client = daca_detach_client, -}; - -#define VOL_MAX ((1<<20) - 1) - -void daca_get_volume(uint * left_vol, uint *right_vol) -{ - *left_vol = cur_left_vol >> 5; - *right_vol = cur_right_vol >> 5; -} - -int daca_set_volume(uint left_vol, uint right_vol) -{ - unsigned short voldata; - - if (!daca_client) - return -1; - - /* Derived from experience, not from any specific values */ - left_vol <<= 5; - right_vol <<= 5; - - if (left_vol > VOL_MAX) - left_vol = VOL_MAX; - if (right_vol > VOL_MAX) - right_vol = VOL_MAX; - - voldata = ((left_vol >> 14) & 0x3f) << 8; - voldata |= (right_vol >> 14) & 0x3f; - - if (i2c_smbus_write_word_data(daca_client, 2, voldata) < 0) { - printk("daca: failed to set volume \n"); - return -1; - } - - cur_left_vol = left_vol; - cur_right_vol = right_vol; - - return 0; -} - -int daca_leave_sleep(void) -{ - if (!daca_client) - return -1; - - /* Do a short sleep, just to make sure I2C bus is awake and paying - * attention to us - */ - msleep(20); - /* Write the sample rate reg the value it needs */ - i2c_smbus_write_byte_data(daca_client, 1, 8); - daca_set_volume(cur_left_vol >> 5, cur_right_vol >> 5); - /* Another short delay, just to make sure the other I2C bus writes - * have taken... - */ - msleep(20); - /* Write the global config reg - invert right power amp, - * DAC on, use 5-volt mode */ - i2c_smbus_write_byte_data(daca_client, 3, 0x45); - - return 0; -} - -int daca_enter_sleep(void) -{ - if (!daca_client) - return -1; - - i2c_smbus_write_byte_data(daca_client, 1, 8); - daca_set_volume(cur_left_vol >> 5, cur_right_vol >> 5); - - /* Write the global config reg - invert right power amp, - * DAC on, enter low-power mode, use 5-volt mode - */ - i2c_smbus_write_byte_data(daca_client, 3, 0x65); - - return 0; -} - -static int daca_attach_adapter(struct i2c_adapter *adapter) -{ - if (!strncmp(adapter->name, "mac-io", 6)) - daca_detect_client(adapter, 0x4d); - return 0; -} - -static int daca_init_client(struct i2c_client * new_client) -{ - /* - * Probe is not working with the current i2c-keywest - * driver. We try to use addr 0x4d on each adapters - * instead, by setting the format register. - * - * FIXME: I'm sure that can be obtained from the - * device-tree. --BenH. - */ - - /* Write the global config reg - invert right power amp, - * DAC on, use 5-volt mode - */ - if (i2c_smbus_write_byte_data(new_client, 3, 0x45)) - return -1; - - i2c_smbus_write_byte_data(new_client, 1, 8); - daca_client = new_client; - daca_set_volume(15000, 15000); - - return 0; -} - -static int daca_detect_client(struct i2c_adapter *adapter, int address) -{ - const char *client_name = "DAC 3550A Digital Equalizer"; - struct i2c_client *new_client; - int rc = -ENODEV; - - new_client = kzalloc(sizeof(*new_client), GFP_KERNEL); - if (!new_client) - return -ENOMEM; - - new_client->addr = address; - new_client->adapter = adapter; - new_client->driver = &daca_driver; - new_client->flags = 0; - strcpy(new_client->name, client_name); - - if (daca_init_client(new_client)) - goto bail; - - /* Tell the i2c layer a new client has arrived */ - if (i2c_attach_client(new_client)) - goto bail; - - return 0; - bail: - kfree(new_client); - return rc; -} - - -static int daca_detach_client(struct i2c_client *client) -{ - if (client == daca_client) - daca_client = NULL; - - i2c_detach_client(client); - kfree(client); - return 0; -} - -void daca_cleanup(void) -{ - i2c_del_driver(&daca_driver); -} - -int daca_init(void) -{ - printk("dac3550a driver version %s (%s)\n",DACA_VERSION,DACA_DATE); - return i2c_add_driver(&daca_driver); -} diff --git a/sound/oss/dmasound/dmasound.h b/sound/oss/dmasound/dmasound.h index 25dd5a318eb4..d978b0096564 100644 --- a/sound/oss/dmasound/dmasound.h +++ b/sound/oss/dmasound/dmasound.h @@ -59,7 +59,6 @@ static inline int ioctl_return(int __user *addr, int value) */ #undef HAS_8BIT_TABLES -#undef HAS_RECORD #if defined(CONFIG_DMASOUND_ATARI) || defined(CONFIG_DMASOUND_ATARI_MODULE) ||\ defined(CONFIG_DMASOUND_PAULA) || defined(CONFIG_DMASOUND_PAULA_MODULE) ||\ @@ -83,10 +82,6 @@ static inline int ioctl_return(int __user *addr, int value) #define DEFAULT_N_BUFFERS 4 #define DEFAULT_BUFF_SIZE (1<<15) -#if defined(CONFIG_DMASOUND_PMAC) || defined(CONFIG_DMASOUND_PMAC_MODULE) -#define HAS_RECORD -#endif - /* * Initialization */ @@ -168,9 +163,6 @@ struct sound_settings { SETTINGS soft; /* software settings */ SETTINGS dsp; /* /dev/dsp default settings */ TRANS *trans_write; /* supported translations */ -#ifdef HAS_RECORD - TRANS *trans_read; /* supported translations */ -#endif int volume_left; /* volume (range is machine dependent) */ int volume_right; int bass; /* tone (range is machine dependent) */ @@ -253,11 +245,6 @@ struct sound_queue { extern struct sound_queue dmasound_write_sq; #define write_sq dmasound_write_sq -#ifdef HAS_RECORD -extern struct sound_queue dmasound_read_sq; -#define read_sq dmasound_read_sq -#endif - extern int dmasound_catchRadius; #define catchRadius dmasound_catchRadius diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c deleted file mode 100644 index 8f6388004f44..000000000000 --- a/sound/oss/dmasound/dmasound_awacs.c +++ /dev/null @@ -1,3215 +0,0 @@ -/* - * linux/sound/oss/dmasound/dmasound_awacs.c - * - * PowerMac `AWACS' and `Burgundy' DMA Sound Driver - * with some limited support for DACA & Tumbler - * - * See linux/sound/oss/dmasound/dmasound_core.c for copyright and - * history prior to 2001/01/26. - * - * 26/01/2001 ed 0.1 Iain Sandoe - * - added version info. - * - moved dbdma command buffer allocation to PMacXXXSqSetup() - * - fixed up beep dbdma cmd buffers - * - * 08/02/2001 [0.2] - * - make SNDCTL_DSP_GETFMTS return the correct info for the h/w - * - move soft format translations to a separate file - * - [0.3] make SNDCTL_DSP_GETCAPS return correct info. - * - [0.4] more informative machine name strings. - * - [0.5] - * - record changes. - * - made the default_hard/soft entries. - * 04/04/2001 [0.6] - * - minor correction to bit assignments in awacs_defs.h - * - incorporate mixer changes from 2.2.x back-port. - * - take out passthru as a rec input (it isn't). - * - make Input Gain slider work the 'right way up'. - * - try to make the mixer sliders more logical - so now the - * input selectors are just two-state (>50% == ON) and the - * Input Gain slider handles the rest of the gain issues. - * - try to pick slider representations that most closely match - * the actual use - e.g. IGain for input gain... - * - first stab at over/under-run detection. - * - minor cosmetic changes to IRQ identification. - * - fix bug where rates > max would be reported as supported. - * - first stab at over/under-run detection. - * - make use of i2c for mixer settings conditional on perch - * rather than cuda (some machines without perch have cuda). - * - fix bug where TX stops when dbdma status comes up "DEAD" - * so far only reported on PowerComputing clones ... but. - * - put in AWACS/Screamer register write timeouts. - * - part way to partitioning the init() stuff - * - first pass at 'tumbler' stuff (not support - just an attempt - * to allow the driver to load on new G4s). - * 01/02/2002 [0.7] - BenH - * - all sort of minor bits went in since the latest update, I - * bumped the version number for that reason - * - * 07/26/2002 [0.8] - BenH - * - More minor bits since last changelog (I should be more careful - * with those) - * - Support for snapper & better tumbler integration by Toby Sargeant - * - Headphone detect for scremer by Julien Blache - * - More tumbler fixed by Andreas Schwab - * 11/29/2003 [0.8.1] - Renzo Davoli (King Enzo) - * - Support for Snapper line in - * - snapper input resampling (for rates < 44100) - * - software line gain control - */ - -/* GENERAL FIXME/TODO: check that the assumptions about what is written to - mac-io is valid for DACA & Tumbler. - - This driver is in bad need of a rewrite. The dbdma code has to be split, - some proper device-tree parsing code has to be written, etc... -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_ADB_CUDA -#include -#endif -#ifdef CONFIG_ADB_PMU -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "awacs_defs.h" -#include "dmasound.h" -#include "tas3001c.h" -#include "tas3004.h" -#include "tas_common.h" - -#define DMASOUND_AWACS_REVISION 0 -#define DMASOUND_AWACS_EDITION 7 - -#define AWACS_SNAPPER 110 /* fake revision # for snapper */ -#define AWACS_BURGUNDY 100 /* fake revision # for burgundy */ -#define AWACS_TUMBLER 90 /* fake revision # for tumbler */ -#define AWACS_DACA 80 /* fake revision # for daca (ibook) */ -#define AWACS_AWACS 2 /* holding revision for AWACS */ -#define AWACS_SCREAMER 3 /* holding revision for Screamer */ -/* - * Interrupt numbers and addresses, & info obtained from the device tree. - */ -static int awacs_irq, awacs_tx_irq, awacs_rx_irq; -static volatile struct awacs_regs __iomem *awacs; -static volatile u32 __iomem *i2s; -static volatile struct dbdma_regs __iomem *awacs_txdma, *awacs_rxdma; -static int awacs_rate_index; -static int awacs_subframe; -static struct device_node* awacs_node; -static struct device_node* i2s_node; -static struct resource awacs_rsrc[3]; - -static char awacs_name[64]; -static int awacs_revision; -static int awacs_sleeping; -static DEFINE_MUTEX(dmasound_mutex); - -static int sound_device_id; /* exists after iMac revA */ -static int hw_can_byteswap = 1 ; /* most pmac sound h/w can */ - -/* model info */ -/* To be replaced with better interaction with pmac_feature.c */ -static int is_pbook_3X00; -static int is_pbook_g3; - -/* expansion info */ -static int has_perch; -static int has_ziva; - -/* for earlier powerbooks which need fiddling with mac-io to enable - * cd etc. -*/ -static unsigned char __iomem *latch_base; -static unsigned char __iomem *macio_base; - -/* - * Space for the DBDMA command blocks. - */ -static void *awacs_tx_cmd_space; -static volatile struct dbdma_cmd *awacs_tx_cmds; -static int number_of_tx_cmd_buffers; - -static void *awacs_rx_cmd_space; -static volatile struct dbdma_cmd *awacs_rx_cmds; -static int number_of_rx_cmd_buffers; - -/* - * Cached values of AWACS registers (we can't read them). - * Except on the burgundy (and screamer). XXX - */ - -int awacs_reg[8]; -int awacs_reg1_save; - -/* tracking values for the mixer contents -*/ - -static int spk_vol; -static int line_vol; -static int passthru_vol; - -static int ip_gain; /* mic preamp settings */ -static int rec_lev = 0x4545 ; /* default CD gain 69 % */ -static int mic_lev; -static int cd_lev = 0x6363 ; /* 99 % */ -static int line_lev; - -static int hdp_connected; - -/* - * Stuff for outputting a beep. The values range from -327 to +327 - * so we can multiply by an amplitude in the range 0..100 to get a - * signed short value to put in the output buffer. - */ -static short beep_wform[256] = { - 0, 40, 79, 117, 153, 187, 218, 245, - 269, 288, 304, 316, 323, 327, 327, 324, - 318, 310, 299, 288, 275, 262, 249, 236, - 224, 213, 204, 196, 190, 186, 183, 182, - 182, 183, 186, 189, 192, 196, 200, 203, - 206, 208, 209, 209, 209, 207, 204, 201, - 197, 193, 188, 183, 179, 174, 170, 166, - 163, 161, 160, 159, 159, 160, 161, 162, - 164, 166, 168, 169, 171, 171, 171, 170, - 169, 167, 163, 159, 155, 150, 144, 139, - 133, 128, 122, 117, 113, 110, 107, 105, - 103, 103, 103, 103, 104, 104, 105, 105, - 105, 103, 101, 97, 92, 86, 78, 68, - 58, 45, 32, 18, 3, -11, -26, -41, - -55, -68, -79, -88, -95, -100, -102, -102, - -99, -93, -85, -75, -62, -48, -33, -16, - 0, 16, 33, 48, 62, 75, 85, 93, - 99, 102, 102, 100, 95, 88, 79, 68, - 55, 41, 26, 11, -3, -18, -32, -45, - -58, -68, -78, -86, -92, -97, -101, -103, - -105, -105, -105, -104, -104, -103, -103, -103, - -103, -105, -107, -110, -113, -117, -122, -128, - -133, -139, -144, -150, -155, -159, -163, -167, - -169, -170, -171, -171, -171, -169, -168, -166, - -164, -162, -161, -160, -159, -159, -160, -161, - -163, -166, -170, -174, -179, -183, -188, -193, - -197, -201, -204, -207, -209, -209, -209, -208, - -206, -203, -200, -196, -192, -189, -186, -183, - -182, -182, -183, -186, -190, -196, -204, -213, - -224, -236, -249, -262, -275, -288, -299, -310, - -318, -324, -327, -327, -323, -316, -304, -288, - -269, -245, -218, -187, -153, -117, -79, -40, -}; - -/* beep support */ -#define BEEP_SRATE 22050 /* 22050 Hz sample rate */ -#define BEEP_BUFLEN 512 -#define BEEP_VOLUME 15 /* 0 - 100 */ - -static int beep_vol = BEEP_VOLUME; -static int beep_playing; -static int awacs_beep_state; -static short *beep_buf; -static void *beep_dbdma_cmd_space; -static volatile struct dbdma_cmd *beep_dbdma_cmd; - -/* Burgundy functions */ -static void awacs_burgundy_wcw(unsigned addr,unsigned newval); -static unsigned awacs_burgundy_rcw(unsigned addr); -static void awacs_burgundy_write_volume(unsigned address, int volume); -static int awacs_burgundy_read_volume(unsigned address); -static void awacs_burgundy_write_mvolume(unsigned address, int volume); -static int awacs_burgundy_read_mvolume(unsigned address); - -/* we will allocate a single 'emergency' dbdma cmd block to use if the - tx status comes up "DEAD". This happens on some PowerComputing Pmac - clones, either owing to a bug in dbdma or some interaction between - IDE and sound. However, this measure would deal with DEAD status if - if appeared elsewhere. - - for the sake of memory efficiency we'll allocate this cmd as part of - the beep cmd stuff. -*/ - -static volatile struct dbdma_cmd *emergency_dbdma_cmd; - -#ifdef CONFIG_PM -/* - * Stuff for restoring after a sleep. - */ -static void awacs_sleep_notify(struct pmu_sleep_notifier *self, int when); -struct pmu_sleep_notifier awacs_sleep_notifier = { - awacs_sleep_notify, SLEEP_LEVEL_SOUND, -}; -#endif /* CONFIG_PM */ - -/* for (soft) sample rate translations */ -int expand_bal; /* Balance factor for expanding (not volume!) */ -int expand_read_bal; /* Balance factor for expanding reads (not volume!) */ - -/*** Low level stuff *********************************************************/ - -static void *PMacAlloc(unsigned int size, gfp_t flags); -static void PMacFree(void *ptr, unsigned int size); -static int PMacIrqInit(void); -#ifdef MODULE -static void PMacIrqCleanup(void); -#endif -static void PMacSilence(void); -static void PMacInit(void); -static int PMacSetFormat(int format); -static int PMacSetVolume(int volume); -static void PMacPlay(void); -static void PMacRecord(void); -static irqreturn_t pmac_awacs_tx_intr(int irq, void *devid); -static irqreturn_t pmac_awacs_rx_intr(int irq, void *devid); -static irqreturn_t pmac_awacs_intr(int irq, void *devid); -static void awacs_write(int val); -static int awacs_get_volume(int reg, int lshift); -static int awacs_volume_setter(int volume, int n, int mute, int lshift); - - -/*** Mid level stuff **********************************************************/ - -static int PMacMixerIoctl(u_int cmd, u_long arg); -static int PMacWriteSqSetup(void); -static int PMacReadSqSetup(void); -static void PMacAbortRead(void); - -extern TRANS transAwacsNormal ; -extern TRANS transAwacsExpand ; -extern TRANS transAwacsNormalRead ; -extern TRANS transAwacsExpandRead ; - -extern int daca_init(void); -extern void daca_cleanup(void); -extern int daca_set_volume(uint left_vol, uint right_vol); -extern void daca_get_volume(uint * left_vol, uint *right_vol); -extern int daca_enter_sleep(void); -extern int daca_leave_sleep(void); - -#define TRY_LOCK() \ - if ((rc = mutex_lock_interruptible(&dmasound_mutex)) != 0) \ - return rc; -#define LOCK() mutex_lock(&dmasound_mutex); - -#define UNLOCK() mutex_unlock(&dmasound_mutex); - -/* We use different versions that the ones provided in dmasound.h - * - * FIXME: Use different names ;) - */ -#undef IOCTL_IN -#undef IOCTL_OUT - -#define IOCTL_IN(arg, ret) \ - rc = get_user(ret, (int __user *)(arg)); \ - if (rc) break; -#define IOCTL_OUT(arg, ret) \ - ioctl_return2((int __user *)(arg), ret) - -static inline int ioctl_return2(int __user *addr, int value) -{ - return value < 0 ? value : put_user(value, addr); -} - - -/*** AE - TUMBLER / SNAPPER START ************************************************/ - - -int gpio_audio_reset, gpio_audio_reset_pol; -int gpio_amp_mute, gpio_amp_mute_pol; -int gpio_headphone_mute, gpio_headphone_mute_pol; -int gpio_headphone_detect, gpio_headphone_detect_pol; -int gpio_headphone_irq; - -int -setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int* gpio_pol) -{ - struct device_node *gpiop; - struct device_node *np; - const u32* pp; - int ret = -ENODEV; - - gpiop = of_find_node_by_name(NULL, "gpio"); - if (!gpiop) - goto done; - - np = of_get_next_child(gpiop, NULL); - while(np != 0) { - if (name) { - const char *property = - of_get_property(np,"audio-gpio",NULL); - if (property != 0 && strcmp(property,name) == 0) - break; - } else if (compatible && of_device_is_compatible(np, compatible)) - break; - np = of_get_next_child(gpiop, np); - } - if (!np) - goto done; - pp = of_get_property(np, "AAPL,address", NULL); - if (!pp) - goto done; - *gpio_addr = (*pp) & 0x0000ffff; - pp = of_get_property(np, "audio-gpio-active-state", NULL); - if (pp) - *gpio_pol = *pp; - else - *gpio_pol = 1; - ret = irq_of_parse_and_map(np, 0); -done: - of_node_put(np); - of_node_put(gpiop); - return ret; -} - -static inline void -write_audio_gpio(int gpio_addr, int data) -{ - if (!gpio_addr) - return; - pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, gpio_addr, data ? 0x05 : 0x04); -} - -static inline int -read_audio_gpio(int gpio_addr) -{ - if (!gpio_addr) - return 0; - return ((pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio_addr, 0) & 0x02) !=0); -} - -/* - * Headphone interrupt via GPIO (Tumbler, Snapper, DACA) - */ -static irqreturn_t -headphone_intr(int irq, void *devid) -{ - unsigned long flags; - - spin_lock_irqsave(&dmasound.lock, flags); - if (read_audio_gpio(gpio_headphone_detect) == gpio_headphone_detect_pol) { - printk(KERN_INFO "Audio jack plugged, muting speakers.\n"); - write_audio_gpio(gpio_headphone_mute, !gpio_headphone_mute_pol); - write_audio_gpio(gpio_amp_mute, gpio_amp_mute_pol); - tas_output_device_change(sound_device_id,TAS_OUTPUT_HEADPHONES,0); - } else { - printk(KERN_INFO "Audio jack unplugged, enabling speakers.\n"); - write_audio_gpio(gpio_amp_mute, !gpio_amp_mute_pol); - write_audio_gpio(gpio_headphone_mute, gpio_headphone_mute_pol); - tas_output_device_change(sound_device_id,TAS_OUTPUT_INTERNAL_SPKR,0); - } - spin_unlock_irqrestore(&dmasound.lock, flags); - return IRQ_HANDLED; -} - - -/* Initialize tumbler */ - -static int -tas_dmasound_init(void) -{ - setup_audio_gpio( - "audio-hw-reset", - NULL, - &gpio_audio_reset, - &gpio_audio_reset_pol); - setup_audio_gpio( - "amp-mute", - NULL, - &gpio_amp_mute, - &gpio_amp_mute_pol); - setup_audio_gpio("headphone-mute", - NULL, - &gpio_headphone_mute, - &gpio_headphone_mute_pol); - gpio_headphone_irq = setup_audio_gpio( - "headphone-detect", - NULL, - &gpio_headphone_detect, - &gpio_headphone_detect_pol); - /* Fix some broken OF entries in desktop machines */ - if (!gpio_headphone_irq) - gpio_headphone_irq = setup_audio_gpio( - NULL, - "keywest-gpio15", - &gpio_headphone_detect, - &gpio_headphone_detect_pol); - - write_audio_gpio(gpio_audio_reset, gpio_audio_reset_pol); - msleep(100); - write_audio_gpio(gpio_audio_reset, !gpio_audio_reset_pol); - msleep(100); - if (gpio_headphone_irq) { - if (request_irq(gpio_headphone_irq,headphone_intr,0,"Headphone detect",NULL) < 0) { - printk(KERN_ERR "tumbler: Can't request headphone interrupt\n"); - gpio_headphone_irq = 0; - } else { - u8 val; - /* Activate headphone status interrupts */ - val = pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, gpio_headphone_detect, 0); - pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, gpio_headphone_detect, val | 0x80); - /* Trigger it */ - headphone_intr(0, NULL); - } - } - if (!gpio_headphone_irq) { - /* Some machine enter this case ? */ - printk(KERN_WARNING "tumbler: Headphone detect IRQ not found, enabling all outputs !\n"); - write_audio_gpio(gpio_amp_mute, !gpio_amp_mute_pol); - write_audio_gpio(gpio_headphone_mute, !gpio_headphone_mute_pol); - } - return 0; -} - - -static int -tas_dmasound_cleanup(void) -{ - if (gpio_headphone_irq) - free_irq(gpio_headphone_irq, NULL); - return 0; -} - -/* We don't support 48k yet */ -static int tas_freqs[1] = { 44100 } ; -static int tas_freqs_ok[1] = { 1 } ; - -/* don't know what to do really - just have to leave it where - * OF left things -*/ - -static int -tas_set_frame_rate(void) -{ - if (i2s) { - out_le32(i2s + (I2S_REG_SERIAL_FORMAT >> 2), 0x41190000); - out_le32(i2s + (I2S_REG_DATAWORD_SIZES >> 2), 0x02000200); - } - dmasound.hard.speed = 44100 ; - awacs_rate_index = 0 ; - return 44100 ; -} - -static int -tas_mixer_ioctl(u_int cmd, u_long arg) -{ - int __user *argp = (int __user *)arg; - int data; - int rc; - - rc=tas_device_ioctl(cmd, arg); - if (rc != -EINVAL) { - return rc; - } - - if ((cmd & ~0xff) == MIXER_WRITE(0) && - tas_supported_mixers() & (1<<(cmd & 0xff))) { - rc = get_user(data, argp); - if (rc<0) return rc; - tas_set_mixer_level(cmd & 0xff, data); - tas_get_mixer_level(cmd & 0xff, &data); - return ioctl_return2(argp, data); - } - if ((cmd & ~0xff) == MIXER_READ(0) && - tas_supported_mixers() & (1<<(cmd & 0xff))) { - tas_get_mixer_level(cmd & 0xff, &data); - return ioctl_return2(argp, data); - } - - switch(cmd) { - case SOUND_MIXER_READ_DEVMASK: - data = tas_supported_mixers() | SOUND_MASK_SPEAKER; - rc = IOCTL_OUT(arg, data); - break; - case SOUND_MIXER_READ_STEREODEVS: - data = tas_stereo_mixers(); - rc = IOCTL_OUT(arg, data); - break; - case SOUND_MIXER_READ_CAPS: - rc = IOCTL_OUT(arg, 0); - break; - case SOUND_MIXER_READ_RECMASK: - // XXX FIXME: find a way to check what is really available */ - data = SOUND_MASK_LINE | SOUND_MASK_MIC; - rc = IOCTL_OUT(arg, data); - break; - case SOUND_MIXER_READ_RECSRC: - if (awacs_reg[0] & MASK_MUX_AUDIN) - data |= SOUND_MASK_LINE; - if (awacs_reg[0] & MASK_MUX_MIC) - data |= SOUND_MASK_MIC; - rc = IOCTL_OUT(arg, data); - break; - case SOUND_MIXER_WRITE_RECSRC: - IOCTL_IN(arg, data); - data =0; - rc = IOCTL_OUT(arg, data); - break; - case SOUND_MIXER_WRITE_SPEAKER: /* really bell volume */ - IOCTL_IN(arg, data); - beep_vol = data & 0xff; - /* fall through */ - case SOUND_MIXER_READ_SPEAKER: - rc = IOCTL_OUT(arg, (beep_vol<<8) | beep_vol); - break; - case SOUND_MIXER_OUTMASK: - case SOUND_MIXER_OUTSRC: - default: - rc = -EINVAL; - } - - return rc; -} - -static void __init -tas_init_frame_rates(const unsigned int *prop, unsigned int l) -{ - int i ; - if (prop) { - for (i=0; i<1; i++) - tas_freqs_ok[i] = 0; - for (l /= sizeof(int); l > 0; --l) { - unsigned int r = *prop++; - /* Apple 'Fixed' format */ - if (r >= 0x10000) - r >>= 16; - for (i = 0; i < 1; ++i) { - if (r == tas_freqs[i]) { - tas_freqs_ok[i] = 1; - break; - } - } - } - } - /* else we assume that all the rates are available */ -} - - -/*** AE - TUMBLER / SNAPPER END ************************************************/ - - - -/*** Low level stuff *********************************************************/ - -/* - * PCI PowerMac, with AWACS, Screamer, Burgundy, DACA or Tumbler and DBDMA. - */ -static void *PMacAlloc(unsigned int size, gfp_t flags) -{ - return kmalloc(size, flags); -} - -static void PMacFree(void *ptr, unsigned int size) -{ - kfree(ptr); -} - -static int __init PMacIrqInit(void) -{ - if (awacs) - if (request_irq(awacs_irq, pmac_awacs_intr, 0, "Built-in Sound misc", NULL)) - return 0; - if (request_irq(awacs_tx_irq, pmac_awacs_tx_intr, 0, "Built-in Sound out", NULL) - || request_irq(awacs_rx_irq, pmac_awacs_rx_intr, 0, "Built-in Sound in", NULL)) - return 0; - return 1; -} - -#ifdef MODULE -static void PMacIrqCleanup(void) -{ - /* turn off input & output dma */ - DBDMA_DO_STOP(awacs_txdma); - DBDMA_DO_STOP(awacs_rxdma); - - if (awacs) - /* disable interrupts from awacs interface */ - out_le32(&awacs->control, in_le32(&awacs->control) & 0xfff); - - /* Switch off the sound clock */ - pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 0); - /* Make sure proper bits are set on pismo & tipb */ - if ((machine_is_compatible("PowerBook3,1") || - machine_is_compatible("PowerBook3,2")) && awacs) { - awacs_reg[1] |= MASK_PAROUT0 | MASK_PAROUT1; - awacs_write(MASK_ADDR1 | awacs_reg[1]); - msleep(200); - } - if (awacs) - free_irq(awacs_irq, NULL); - free_irq(awacs_tx_irq, NULL); - free_irq(awacs_rx_irq, NULL); - - if (awacs) - iounmap(awacs); - if (i2s) - iounmap(i2s); - iounmap(awacs_txdma); - iounmap(awacs_rxdma); - - release_mem_region(awacs_rsrc[0].start, - awacs_rsrc[0].end - awacs_rsrc[0].start + 1); - release_mem_region(awacs_rsrc[1].start, - awacs_rsrc[1].end - awacs_rsrc[1].start + 1); - release_mem_region(awacs_rsrc[2].start, - awacs_rsrc[2].end - awacs_rsrc[2].start + 1); - - kfree(awacs_tx_cmd_space); - kfree(awacs_rx_cmd_space); - kfree(beep_dbdma_cmd_space); - kfree(beep_buf); -#ifdef CONFIG_PM - pmu_unregister_sleep_notifier(&awacs_sleep_notifier); -#endif -} -#endif /* MODULE */ - -static void PMacSilence(void) -{ - /* turn off output dma */ - DBDMA_DO_STOP(awacs_txdma); -} - -/* don't know what to do really - just have to leave it where - * OF left things -*/ - -static int daca_set_frame_rate(void) -{ - if (i2s) { - out_le32(i2s + (I2S_REG_SERIAL_FORMAT >> 2), 0x41190000); - out_le32(i2s + (I2S_REG_DATAWORD_SIZES >> 2), 0x02000200); - } - dmasound.hard.speed = 44100 ; - awacs_rate_index = 0 ; - return 44100 ; -} - -static int awacs_freqs[8] = { - 44100, 29400, 22050, 17640, 14700, 11025, 8820, 7350 -}; -static int awacs_freqs_ok[8] = { 1, 1, 1, 1, 1, 1, 1, 1 }; - -static int -awacs_set_frame_rate(int desired, int catch_r) -{ - int tolerance, i = 8 ; - /* - * If we have a sample rate which is within catchRadius percent - * of the requested value, we don't have to expand the samples. - * Otherwise choose the next higher rate. - * N.B.: burgundy awacs only works at 44100 Hz. - */ - do { - tolerance = catch_r * awacs_freqs[--i] / 100; - if (awacs_freqs_ok[i] - && dmasound.soft.speed <= awacs_freqs[i] + tolerance) - break; - } while (i > 0); - dmasound.hard.speed = awacs_freqs[i]; - awacs_rate_index = i; - - out_le32(&awacs->control, MASK_IEPC | (i << 8) | 0x11 ); - awacs_reg[1] = (awacs_reg[1] & ~MASK_SAMPLERATE) | (i << 3); - awacs_write(awacs_reg[1] | MASK_ADDR1); - return dmasound.hard.speed; -} - -static int -burgundy_set_frame_rate(void) -{ - awacs_rate_index = 0 ; - awacs_reg[1] = (awacs_reg[1] & ~MASK_SAMPLERATE) ; - /* XXX disable error interrupt on burgundy for now */ - out_le32(&awacs->control, MASK_IEPC | 0 | 0x11 | MASK_IEE); - return 44100 ; -} - -static int -set_frame_rate(int desired, int catch_r) -{ - switch (awacs_revision) { - case AWACS_BURGUNDY: - dmasound.hard.speed = burgundy_set_frame_rate(); - break ; - case AWACS_TUMBLER: - case AWACS_SNAPPER: - dmasound.hard.speed = tas_set_frame_rate(); - break ; - case AWACS_DACA: - dmasound.hard.speed = - daca_set_frame_rate(); - break ; - default: - dmasound.hard.speed = awacs_set_frame_rate(desired, - catch_r); - break ; - } - return dmasound.hard.speed ; -} - -static void -awacs_recalibrate(void) -{ - /* Sorry for the horrible delays... I hope to get that improved - * by making the whole PM process asynchronous in a future version - */ - msleep(750); - awacs_reg[1] |= MASK_CMUTE | MASK_AMUTE; - awacs_write(awacs_reg[1] | MASK_RECALIBRATE | MASK_ADDR1); - msleep(1000); - awacs_write(awacs_reg[1] | MASK_ADDR1); -} - -static void PMacInit(void) -{ - int tolerance; - - switch (dmasound.soft.format) { - case AFMT_S16_LE: - case AFMT_U16_LE: - if (hw_can_byteswap) - dmasound.hard.format = AFMT_S16_LE; - else - dmasound.hard.format = AFMT_S16_BE; - break; - default: - dmasound.hard.format = AFMT_S16_BE; - break; - } - dmasound.hard.stereo = 1; - dmasound.hard.size = 16; - - /* set dmasound.hard.speed - on the basis of what we want (soft) - * and the tolerance we'll allow. - */ - set_frame_rate(dmasound.soft.speed, catchRadius) ; - - tolerance = (catchRadius * dmasound.hard.speed) / 100; - if (dmasound.soft.speed >= dmasound.hard.speed - tolerance) { - dmasound.trans_write = &transAwacsNormal; - dmasound.trans_read = &transAwacsNormalRead; - } else { - dmasound.trans_write = &transAwacsExpand; - dmasound.trans_read = &transAwacsExpandRead; - } - - if (awacs) { - if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE)) - out_le32(&awacs->byteswap, BS_VAL); - else - out_le32(&awacs->byteswap, 0); - } - - expand_bal = -dmasound.soft.speed; - expand_read_bal = -dmasound.soft.speed; -} - -static int PMacSetFormat(int format) -{ - int size; - int req_format = format; - - switch (format) { - case AFMT_QUERY: - return dmasound.soft.format; - case AFMT_MU_LAW: - case AFMT_A_LAW: - case AFMT_U8: - case AFMT_S8: - size = 8; - break; - case AFMT_S16_LE: - if(!hw_can_byteswap) - format = AFMT_S16_BE; - case AFMT_S16_BE: - size = 16; - break; - case AFMT_U16_LE: - if(!hw_can_byteswap) - format = AFMT_U16_BE; - case AFMT_U16_BE: - size = 16; - break; - default: /* :-) */ - printk(KERN_ERR "dmasound: unknown format 0x%x, using AFMT_U8\n", - format); - size = 8; - format = AFMT_U8; - } - - if (req_format == format) { - dmasound.soft.format = format; - dmasound.soft.size = size; - if (dmasound.minDev == SND_DEV_DSP) { - dmasound.dsp.format = format; - dmasound.dsp.size = size; - } - } - - return format; -} - -#define AWACS_VOLUME_TO_MASK(x) (15 - ((((x) - 1) * 15) / 99)) -#define AWACS_MASK_TO_VOLUME(y) (100 - ((y) * 99 / 15)) - -static int awacs_get_volume(int reg, int lshift) -{ - int volume; - - volume = AWACS_MASK_TO_VOLUME((reg >> lshift) & 0xf); - volume |= AWACS_MASK_TO_VOLUME(reg & 0xf) << 8; - return volume; -} - -static int awacs_volume_setter(int volume, int n, int mute, int lshift) -{ - int r1, rn; - - if (mute && volume == 0) { - r1 = awacs_reg[1] | mute; - } else { - r1 = awacs_reg[1] & ~mute; - rn = awacs_reg[n] & ~(0xf | (0xf << lshift)); - rn |= ((AWACS_VOLUME_TO_MASK(volume & 0xff) & 0xf) << lshift); - rn |= AWACS_VOLUME_TO_MASK((volume >> 8) & 0xff) & 0xf; - awacs_reg[n] = rn; - awacs_write((n << 12) | rn); - volume = awacs_get_volume(rn, lshift); - } - if (r1 != awacs_reg[1]) { - awacs_reg[1] = r1; - awacs_write(r1 | MASK_ADDR1); - } - return volume; -} - -static int PMacSetVolume(int volume) -{ - printk(KERN_WARNING "Bogus call to PMacSetVolume !\n"); - return 0; -} - -static void awacs_setup_for_beep(int speed) -{ - out_le32(&awacs->control, - (in_le32(&awacs->control) & ~0x1f00) - | ((speed > 0 ? speed : awacs_rate_index) << 8)); - - if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE) && speed == -1) - out_le32(&awacs->byteswap, BS_VAL); - else - out_le32(&awacs->byteswap, 0); -} - -/* CHECK: how much of this *really* needs IRQs masked? */ -static void __PMacPlay(void) -{ - volatile struct dbdma_cmd *cp; - int next_frg, count; - - count = 300 ; /* > two cycles at the lowest sample rate */ - - /* what we want to send next */ - next_frg = (write_sq.front + write_sq.active) % write_sq.max_count; - - if (awacs_beep_state) { - /* sound takes precedence over beeps */ - /* stop the dma channel */ - out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); - while ( (in_le32(&awacs_txdma->status) & RUN) && count--) - udelay(1); - if (awacs) - awacs_setup_for_beep(-1); - out_le32(&awacs_txdma->cmdptr, - virt_to_bus(&(awacs_tx_cmds[next_frg]))); - - beep_playing = 0; - awacs_beep_state = 0; - } - /* this won't allow more than two frags to be in the output queue at - once. (or one, if the max frags is 2 - because count can't exceed - 2 in that case) - */ - while (write_sq.active < 2 && write_sq.active < write_sq.count) { - count = (write_sq.count == write_sq.active + 1) ? - write_sq.rear_size:write_sq.block_size ; - if (count < write_sq.block_size) { - if (!write_sq.syncing) /* last block not yet filled,*/ - break; /* and we're not syncing or POST-ed */ - else { - /* pretend the block is full to force a new - block to be started on the next write */ - write_sq.rear_size = write_sq.block_size ; - write_sq.syncing &= ~2 ; /* clear POST */ - } - } - cp = &awacs_tx_cmds[next_frg]; - st_le16(&cp->req_count, count); - st_le16(&cp->xfer_status, 0); - st_le16(&cp->command, OUTPUT_MORE + INTR_ALWAYS); - /* put a STOP at the end of the queue - but only if we have - space for it. This means that, if we under-run and we only - have two fragments, we might re-play sound from an existing - queued frag. I guess the solution to that is not to set two - frags if you are likely to under-run... - */ - if (write_sq.count < write_sq.max_count) { - if (++next_frg >= write_sq.max_count) - next_frg = 0 ; /* wrap */ - /* if we get here then we've underrun so we will stop*/ - st_le16(&awacs_tx_cmds[next_frg].command, DBDMA_STOP); - } - /* set the dbdma controller going, if it is not already */ - if (write_sq.active == 0) - out_le32(&awacs_txdma->cmdptr, virt_to_bus(cp)); - (void)in_le32(&awacs_txdma->status); - out_le32(&awacs_txdma->control, ((RUN|WAKE) << 16) + (RUN|WAKE)); - ++write_sq.active; - } -} - -static void PMacPlay(void) -{ - LOCK(); - if (!awacs_sleeping) { - unsigned long flags; - - spin_lock_irqsave(&dmasound.lock, flags); - __PMacPlay(); - spin_unlock_irqrestore(&dmasound.lock, flags); - } - UNLOCK(); -} - -static void PMacRecord(void) -{ - unsigned long flags; - - if (read_sq.active) - return; - - spin_lock_irqsave(&dmasound.lock, flags); - - /* This is all we have to do......Just start it up. - */ - out_le32(&awacs_rxdma->control, ((RUN|WAKE) << 16) + (RUN|WAKE)); - read_sq.active = 1; - - spin_unlock_irqrestore(&dmasound.lock, flags); -} - -/* if the TX status comes up "DEAD" - reported on some Power Computing machines - we need to re-start the dbdma - but from a different physical start address - and with a different transfer length. It would get very messy to do this - with the normal dbdma_cmd blocks - we would have to re-write the buffer start - addresses each time. So, we will keep a single dbdma_cmd block which can be - fiddled with. - When DEAD status is first reported the content of the faulted dbdma block is - copied into the emergency buffer and we note that the buffer is in use. - we then bump the start physical address by the amount that was successfully - output before it died. - On any subsequent DEAD result we just do the bump-ups (we know that we are - already using the emergency dbdma_cmd). - CHECK: this just tries to "do it". It is possible that we should abandon - xfers when the number of residual bytes gets below a certain value - I can - see that this might cause a loop-forever if too small a transfer causes - DEAD status. However this is a TODO for now - we'll see what gets reported. - When we get a successful transfer result with the emergency buffer we just - pretend that it completed using the original dmdma_cmd and carry on. The - 'next_cmd' field will already point back to the original loop of blocks. -*/ - -static irqreturn_t -pmac_awacs_tx_intr(int irq, void *devid) -{ - int i = write_sq.front; - int stat; - int i_nowrap = write_sq.front; - volatile struct dbdma_cmd *cp; - /* != 0 when we are dealing with a DEAD xfer */ - static int emergency_in_use; - - spin_lock(&dmasound.lock); - while (write_sq.active > 0) { /* we expect to have done something*/ - if (emergency_in_use) /* we are dealing with DEAD xfer */ - cp = emergency_dbdma_cmd ; - else - cp = &awacs_tx_cmds[i]; - stat = ld_le16(&cp->xfer_status); - if (stat & DEAD) { - unsigned short req, res ; - unsigned int phy ; -#ifdef DEBUG_DMASOUND -printk("dmasound_pmac: tx-irq: xfer died - patching it up...\n") ; -#endif - /* to clear DEAD status we must first clear RUN - set it to quiescent to be on the safe side */ - (void)in_le32(&awacs_txdma->status); - out_le32(&awacs_txdma->control, - (RUN|PAUSE|FLUSH|WAKE) << 16); - write_sq.died++ ; - if (!emergency_in_use) { /* new problem */ - memcpy((void *)emergency_dbdma_cmd, (void *)cp, - sizeof(struct dbdma_cmd)); - emergency_in_use = 1; - cp = emergency_dbdma_cmd; - } - /* now bump the values to reflect the amount - we haven't yet shifted */ - req = ld_le16(&cp->req_count); - res = ld_le16(&cp->res_count); - phy = ld_le32(&cp->phy_addr); - phy += (req - res); - st_le16(&cp->req_count, res); - st_le16(&cp->res_count, 0); - st_le16(&cp->xfer_status, 0); - st_le32(&cp->phy_addr, phy); - st_le32(&cp->cmd_dep, virt_to_bus(&awacs_tx_cmds[(i+1)%write_sq.max_count])); - st_le16(&cp->command, OUTPUT_MORE | BR_ALWAYS | INTR_ALWAYS); - - /* point at our patched up command block */ - out_le32(&awacs_txdma->cmdptr, virt_to_bus(cp)); - /* we must re-start the controller */ - (void)in_le32(&awacs_txdma->status); - /* should complete clearing the DEAD status */ - out_le32(&awacs_txdma->control, - ((RUN|WAKE) << 16) + (RUN|WAKE)); - break; /* this block is still going */ - } - if ((stat & ACTIVE) == 0) - break; /* this frame is still going */ - if (emergency_in_use) - emergency_in_use = 0 ; /* done that */ - --write_sq.count; - --write_sq.active; - i_nowrap++; - if (++i >= write_sq.max_count) - i = 0; - } - - /* if we stopped and we were not sync-ing - then we under-ran */ - if( write_sq.syncing == 0 ){ - stat = in_le32(&awacs_txdma->status) ; - /* we hit the dbdma_stop */ - if( (stat & ACTIVE) == 0 ) write_sq.xruns++ ; - } - - /* if we used some data up then wake the writer to supply some more*/ - if (i_nowrap != write_sq.front) - WAKE_UP(write_sq.action_queue); - write_sq.front = i; - - /* but make sure we funnel what we've already got */\ - if (!awacs_sleeping) - __PMacPlay(); - - /* make the wake-on-empty conditional on syncing */ - if (!write_sq.active && (write_sq.syncing & 1)) - WAKE_UP(write_sq.sync_queue); /* any time we're empty */ - spin_unlock(&dmasound.lock); - return IRQ_HANDLED; -} - - -static irqreturn_t -pmac_awacs_rx_intr(int irq, void *devid) -{ - int stat ; - /* For some reason on my PowerBook G3, I get one interrupt - * when the interrupt vector is installed (like something is - * pending). This happens before the dbdma is initialized by - * us, so I just check the command pointer and if it is zero, - * just blow it off. - */ - if (in_le32(&awacs_rxdma->cmdptr) == 0) - return IRQ_HANDLED; - - /* We also want to blow 'em off when shutting down. - */ - if (read_sq.active == 0) - return IRQ_HANDLED; - - spin_lock(&dmasound.lock); - /* Check multiple buffers in case we were held off from - * interrupt processing for a long time. Geeze, I really hope - * this doesn't happen. - */ - while ((stat=awacs_rx_cmds[read_sq.rear].xfer_status)) { - - /* if we got a "DEAD" status then just log it for now. - and try to restart dma. - TODO: figure out how best to fix it up - */ - if (stat & DEAD){ -#ifdef DEBUG_DMASOUND -printk("dmasound_pmac: rx-irq: DIED - attempting resurection\n"); -#endif - /* to clear DEAD status we must first clear RUN - set it to quiescent to be on the safe side */ - (void)in_le32(&awacs_txdma->status); - out_le32(&awacs_txdma->control, - (RUN|PAUSE|FLUSH|WAKE) << 16); - awacs_rx_cmds[read_sq.rear].xfer_status = 0; - awacs_rx_cmds[read_sq.rear].res_count = 0; - read_sq.died++ ; - (void)in_le32(&awacs_txdma->status); - /* re-start the same block */ - out_le32(&awacs_rxdma->cmdptr, - virt_to_bus(&awacs_rx_cmds[read_sq.rear])); - /* we must re-start the controller */ - (void)in_le32(&awacs_rxdma->status); - /* should complete clearing the DEAD status */ - out_le32(&awacs_rxdma->control, - ((RUN|WAKE) << 16) + (RUN|WAKE)); - spin_unlock(&dmasound.lock); - return IRQ_HANDLED; /* try this block again */ - } - /* Clear status and move on to next buffer. - */ - awacs_rx_cmds[read_sq.rear].xfer_status = 0; - read_sq.rear++; - - /* Wrap the buffer ring. - */ - if (read_sq.rear >= read_sq.max_active) - read_sq.rear = 0; - - /* If we have caught up to the front buffer, bump it. - * This will cause weird (but not fatal) results if the - * read loop is currently using this buffer. The user is - * behind in this case anyway, so weird things are going - * to happen. - */ - if (read_sq.rear == read_sq.front) { - read_sq.front++; - read_sq.xruns++ ; /* we overan */ - if (read_sq.front >= read_sq.max_active) - read_sq.front = 0; - } - } - - WAKE_UP(read_sq.action_queue); - spin_unlock(&dmasound.lock); - return IRQ_HANDLED; -} - - -static irqreturn_t -pmac_awacs_intr(int irq, void *devid) -{ - int ctrl; - int status; - int r1; - - spin_lock(&dmasound.lock); - ctrl = in_le32(&awacs->control); - status = in_le32(&awacs->codec_stat); - - if (ctrl & MASK_PORTCHG) { - /* tested on Screamer, should work on others too */ - if (awacs_revision == AWACS_SCREAMER) { - if (((status & MASK_HDPCONN) >> 3) && (hdp_connected == 0)) { - hdp_connected = 1; - - r1 = awacs_reg[1] | MASK_SPKMUTE; - awacs_reg[1] = r1; - awacs_write(r1 | MASK_ADDR_MUTE); - } else if (((status & MASK_HDPCONN) >> 3 == 0) && (hdp_connected == 1)) { - hdp_connected = 0; - - r1 = awacs_reg[1] & ~MASK_SPKMUTE; - awacs_reg[1] = r1; - awacs_write(r1 | MASK_ADDR_MUTE); - } - } - } - if (ctrl & MASK_CNTLERR) { - int err = (in_le32(&awacs->codec_stat) & MASK_ERRCODE) >> 16; - /* CHECK: we just swallow burgundy errors at the moment..*/ - if (err != 0 && awacs_revision != AWACS_BURGUNDY) - printk(KERN_ERR "dmasound_pmac: error %x\n", err); - } - /* Writing 1s to the CNTLERR and PORTCHG bits clears them... */ - out_le32(&awacs->control, ctrl); - spin_unlock(&dmasound.lock); - return IRQ_HANDLED; -} - -static void -awacs_write(int val) -{ - int count = 300 ; - if (awacs_revision >= AWACS_DACA || !awacs) - return ; - - while ((in_le32(&awacs->codec_ctrl) & MASK_NEWECMD) && count--) - udelay(1) ; /* timeout is > 2 samples at lowest rate */ - out_le32(&awacs->codec_ctrl, val | (awacs_subframe << 22)); - (void)in_le32(&awacs->byteswap); -} - -/* this is called when the beep timer expires... it will be called even - if the beep has been overidden by other sound output. -*/ -static void awacs_nosound(unsigned long xx) -{ - unsigned long flags; - int count = 600 ; /* > four samples at lowest rate */ - - spin_lock_irqsave(&dmasound.lock, flags); - if (beep_playing) { - st_le16(&beep_dbdma_cmd->command, DBDMA_STOP); - out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16); - while ((in_le32(&awacs_txdma->status) & RUN) && count--) - udelay(1); - if (awacs) - awacs_setup_for_beep(-1); - beep_playing = 0; - } - spin_unlock_irqrestore(&dmasound.lock, flags); -} - -/* - * We generate the beep with a single dbdma command that loops a buffer - * forever - without generating interrupts. - * - * So, to stop it you have to stop dma output as per awacs_nosound. - */ -static int awacs_beep_event(struct input_dev *dev, unsigned int type, - unsigned int code, int hz) -{ - unsigned long flags; - int beep_speed = 0; - int srate; - int period, ncycles, nsamples; - int i, j, f; - short *p; - static int beep_hz_cache; - static int beep_nsamples_cache; - static int beep_volume_cache; - - if (type != EV_SND) - return -1; - switch (code) { - case SND_BELL: - if (hz) - hz = 1000; - break; - case SND_TONE: - break; - default: - return -1; - } - - if (beep_buf == NULL) - return -1; - - /* quick-hack fix for DACA, Burgundy & Tumbler */ - - if (awacs_revision >= AWACS_DACA){ - srate = 44100 ; - } else { - for (i = 0; i < 8 && awacs_freqs[i] >= BEEP_SRATE; ++i) - if (awacs_freqs_ok[i]) - beep_speed = i; - srate = awacs_freqs[beep_speed]; - } - - if (hz <= srate / BEEP_BUFLEN || hz > srate / 2) { - /* cancel beep currently playing */ - awacs_nosound(0); - return 0; - } - - spin_lock_irqsave(&dmasound.lock, flags); - if (beep_playing || write_sq.active || beep_buf == NULL) { - spin_unlock_irqrestore(&dmasound.lock, flags); - return -1; /* too hard, sorry :-( */ - } - beep_playing = 1; - st_le16(&beep_dbdma_cmd->command, OUTPUT_MORE + BR_ALWAYS); - spin_unlock_irqrestore(&dmasound.lock, flags); - - if (hz == beep_hz_cache && beep_vol == beep_volume_cache) { - nsamples = beep_nsamples_cache; - } else { - period = srate * 256 / hz; /* fixed point */ - ncycles = BEEP_BUFLEN * 256 / period; - nsamples = (period * ncycles) >> 8; - f = ncycles * 65536 / nsamples; - j = 0; - p = beep_buf; - for (i = 0; i < nsamples; ++i, p += 2) { - p[0] = p[1] = beep_wform[j >> 8] * beep_vol; - j = (j + f) & 0xffff; - } - beep_hz_cache = hz; - beep_volume_cache = beep_vol; - beep_nsamples_cache = nsamples; - } - - st_le16(&beep_dbdma_cmd->req_count, nsamples*4); - st_le16(&beep_dbdma_cmd->xfer_status, 0); - st_le32(&beep_dbdma_cmd->cmd_dep, virt_to_bus(beep_dbdma_cmd)); - st_le32(&beep_dbdma_cmd->phy_addr, virt_to_bus(beep_buf)); - awacs_beep_state = 1; - - spin_lock_irqsave(&dmasound.lock, flags); - if (beep_playing) { /* i.e. haven't been terminated already */ - int count = 300 ; - out_le32(&awacs_txdma->control, (RUN|WAKE|FLUSH|PAUSE) << 16); - while ((in_le32(&awacs_txdma->status) & RUN) && count--) - udelay(1); /* timeout > 2 samples at lowest rate*/ - if (awacs) - awacs_setup_for_beep(beep_speed); - out_le32(&awacs_txdma->cmdptr, virt_to_bus(beep_dbdma_cmd)); - (void)in_le32(&awacs_txdma->status); - out_le32(&awacs_txdma->control, RUN | (RUN << 16)); - } - spin_unlock_irqrestore(&dmasound.lock, flags); - - return 0; -} - -/* used in init and for wake-up */ - -static void -load_awacs(void) -{ - awacs_write(awacs_reg[0] + MASK_ADDR0); - awacs_write(awacs_reg[1] + MASK_ADDR1); - awacs_write(awacs_reg[2] + MASK_ADDR2); - awacs_write(awacs_reg[4] + MASK_ADDR4); - - if (awacs_revision == AWACS_SCREAMER) { - awacs_write(awacs_reg[5] + MASK_ADDR5); - msleep(100); - awacs_write(awacs_reg[6] + MASK_ADDR6); - msleep(2); - awacs_write(awacs_reg[1] + MASK_ADDR1); - awacs_write(awacs_reg[7] + MASK_ADDR7); - } - if (awacs) { - if (hw_can_byteswap && (dmasound.hard.format == AFMT_S16_LE)) - out_le32(&awacs->byteswap, BS_VAL); - else - out_le32(&awacs->byteswap, 0); - } -} - -#ifdef CONFIG_PM -/* - * Save state when going to sleep, restore it afterwards. - */ -/* FIXME: sort out disabling/re-enabling of read stuff as well */ -static void awacs_sleep_notify(struct pmu_sleep_notifier *self, int when) -{ - unsigned long flags; - - switch (when) { - case PBOOK_SLEEP_NOW: - LOCK(); - awacs_sleeping = 1; - /* Tell the rest of the driver we are now going to sleep */ - mb(); - if (awacs_revision == AWACS_SCREAMER || - awacs_revision == AWACS_AWACS) { - awacs_reg1_save = awacs_reg[1]; - awacs_reg[1] |= MASK_AMUTE | MASK_CMUTE; - awacs_write(MASK_ADDR1 | awacs_reg[1]); - } - - PMacSilence(); - /* stop rx - if going - a bit of a daft user... but */ - out_le32(&awacs_rxdma->control, (RUN|WAKE|FLUSH << 16)); - /* deny interrupts */ - if (awacs) - disable_irq(awacs_irq); - disable_irq(awacs_tx_irq); - disable_irq(awacs_rx_irq); - /* Chip specific sleep code */ - switch (awacs_revision) { - case AWACS_TUMBLER: - case AWACS_SNAPPER: - write_audio_gpio(gpio_headphone_mute, gpio_headphone_mute_pol); - write_audio_gpio(gpio_amp_mute, gpio_amp_mute_pol); - tas_enter_sleep(); - write_audio_gpio(gpio_audio_reset, gpio_audio_reset_pol); - break ; - case AWACS_DACA: - daca_enter_sleep(); - break ; - case AWACS_BURGUNDY: - break ; - case AWACS_SCREAMER: - case AWACS_AWACS: - default: - out_le32(&awacs->control, 0x11) ; - break ; - } - /* Disable sound clock */ - pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 0); - /* According to Darwin, we do that after turning off the sound - * chip clock. All this will have to be cleaned up once we properly - * parse the OF sound-objects - */ - if ((machine_is_compatible("PowerBook3,1") || - machine_is_compatible("PowerBook3,2")) && awacs) { - awacs_reg[1] |= MASK_PAROUT0 | MASK_PAROUT1; - awacs_write(MASK_ADDR1 | awacs_reg[1]); - msleep(200); - } - break; - case PBOOK_WAKE: - /* Enable sound clock */ - pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, awacs_node, 0, 1); - if ((machine_is_compatible("PowerBook3,1") || - machine_is_compatible("PowerBook3,2")) && awacs) { - msleep(100); - awacs_reg[1] &= ~(MASK_PAROUT0 | MASK_PAROUT1); - awacs_write(MASK_ADDR1 | awacs_reg[1]); - msleep(300); - } else - msleep(1000); - /* r