/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id$ * * Copyright (C) 2005 by Christian Gmeiner * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ****************************************************************************/ #include "lcd.h" #include "cpu.h" #include "kernel.h" #include "thread.h" #include "power.h" #include "debug.h" #include "system.h" #include "sprintf.h" #include "button.h" #include "string.h" #include "file.h" #include "buffer.h" #include "i2c-coldfire.h" #include "tlv320.h" /* local functions and definations */ #define TLV320_ADDR 0x34 struct tlv320_info { int vol_l; int vol_r; } tlv320; /* Definition of a playback configuration to start with */ #define NUM_DEFAULT_REGS 10 unsigned tlv320_defaults[2*NUM_DEFAULT_REGS] = { REG_PC, PC_ON | PC_OSC | PC_CLK | PC_DAC | ~PC_OUT, /* do we need to enable osciliator and clock? */ REG_LLIV, LLIV_LIM, /* mute adc input */ REG_RLIV, RLIV_RIM, /* mute adc input */ REG_LHV, LHV_LHV(HEADPHONE_MUTE), /* mute headphone */ REG_RHV, RHV_RHV(HEADPHONE_MUTE), /* mute headphone */ REG_AAP, AAP_MICM, /* mute microphone */ REG_DAP, DAP_DEEMP_DIS, /* de-emphasis control: disabled */ REG_DAIF, DAIF_FOR_I2S | DAIF_IWL_24 | ~DAIF_MS, /* i2s with 24 bit data len and slave mode */ REG_SRC, 0, /* ToDo */ REG_DIA, DIA_ACT, /* activate digital interface */ }; unsigned tlv320_regs[0xf]; void tlv320_write_reg(unsigned reg, unsigned value) { unsigned data[3]; data[0] = TLV320_ADDR; data[1] = reg << 1; data[2] = value & 0xff; if (i2c_write(1, data, 3) != 3) { DEBUGF("tlv320 error reg=0x%x", reg); return; } tlv320_regs[reg] = value; } /* Returns 0 if successful or -1 if some register failed */ void tlv320_set_regs() { int i; memset(tlv320_regs, 0, sizeof(tlv320_regs)); /* Initialize all registers */ for (i=0; i