From d1a93d8a0c508adce8cf12cec823b675260f2896 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Tue, 28 Mar 2006 20:36:59 +0000 Subject: Simplification and correction of the TLV320 driver git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9326 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/tlv320.c | 74 ++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 52 deletions(-) (limited to 'firmware/drivers') diff --git a/firmware/drivers/tlv320.c b/firmware/drivers/tlv320.c index da64c0e69e..bae1f59f95 100644 --- a/firmware/drivers/tlv320.c +++ b/firmware/drivers/tlv320.c @@ -41,21 +41,7 @@ struct tlv320_info 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 */ -}; +/* Shadow registers */ unsigned tlv320_regs[0xf]; void tlv320_write_reg(unsigned reg, unsigned value) @@ -63,7 +49,8 @@ void tlv320_write_reg(unsigned reg, unsigned value) unsigned char data[3]; data[0] = TLV320_ADDR; - data[1] = reg << 1; + /* The register address is the high 7 bits and the data the low 9 bits */ + data[1] = (reg << 1) | ((value >> 8) & 1); data[2] = value & 0xff; if (i2c_write(1, data, 3) != 3) @@ -75,22 +62,6 @@ void tlv320_write_reg(unsigned reg, unsigned value) tlv320_regs[reg] = value; } -/* Returns 0 if successful or -1 if some register failed */ -void tlv320_set_regs(void) -{ - int i; - memset(tlv320_regs, 0, sizeof(tlv320_regs)); - - /* Initialize all registers */ - for (i=0; i