/*
* PMac Tumbler/Snapper lowlevel functions
*
* Copyright (c) by Takashi Iwai <tiwai@suse.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Rene Rebe <rene.rebe@gmx.net>:
* * update from shadow registers on wakeup and headphone plug
* * automatically toggle DRC on headphone plug
*
*/
#include <sound/driver.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <sound/core.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/machdep.h>
#include <asm/pmac_feature.h>
#include "pmac.h"
#include "tumbler_volume.h"
#undef DEBUG
#ifdef DEBUG
#define DBG(fmt...) printk(fmt)
#else
#define DBG(fmt...)
#endif
/* i2c address for tumbler */
#define TAS_I2C_ADDR 0x34
/* registers */
#define TAS_REG_MCS 0x01 /* main control */
#define TAS_REG_DRC 0x02
#define TAS_REG_VOL 0x04
#define TAS_REG_TREBLE 0x05
#define TAS_REG_BASS 0x06
#define TAS_REG_INPUT1 0x07
#define TAS_REG_INPUT2 0x08
/* tas3001c */
#define TAS_REG_PCM TAS_REG_INPUT1
/* tas3004 */
#define TAS_REG_LMIX TAS_REG_INPUT1
#define TAS_REG_RMIX TAS_REG_INPUT2
#define TAS_REG_MCS2 0x43 /* main control 2 */
#define TAS_REG_ACS 0x40 /* analog control */
/* mono volumes for tas3001c/tas3004 */
enum {
VOL_IDX_PCM_MONO, /* tas3001c only */
VOL_IDX_BASS, VOL_IDX_TREBLE,
VOL_IDX_LAST_MONO
};
/* stereo volumes for tas3004 */
enum {
VOL_IDX_PCM, VOL_IDX_PCM2, VOL_IDX_ADC,
VOL_IDX_LAST_MIX
};
struct pmac_gpio {
unsigned int addr;
u8 active_val;
u8 inactive_val;
u8 active_state;
};
struct pmac_tumbler {
struct pmac_keywest i2c;
struct pmac_gpio audio_reset;