diff options
| author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-05-16 21:03:57 +0000 |
|---|---|---|
| committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-05-16 21:03:57 +0000 |
| commit | a2b049006067e47880fae51ff637d5c8021d1683 (patch) | |
| tree | 97a322bca0f6f0ee6dfcfaa822cc7443545aa8db | |
| parent | 97531e8f6c9cffbbc28d71e575a52c34773f691e (diff) | |
| download | rockbox-a2b049006067e47880fae51ff637d5c8021d1683.zip rockbox-a2b049006067e47880fae51ff637d5c8021d1683.tar.gz rockbox-a2b049006067e47880fae51ff637d5c8021d1683.tar.bz2 rockbox-a2b049006067e47880fae51ff637d5c8021d1683.tar.xz | |
First version
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@604 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/drivers/dac.c | 68 | ||||
| -rw-r--r-- | firmware/drivers/dac.h | 38 |
2 files changed, 106 insertions, 0 deletions
diff --git a/firmware/drivers/dac.c b/firmware/drivers/dac.c new file mode 100644 index 0000000..0ea47da --- /dev/null +++ b/firmware/drivers/dac.c @@ -0,0 +1,68 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Linus Nielsen Feltzing + * + * 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 "i2c.h" +#include "debug.h" +#include "dac.h" + +int dac_volume(unsigned int volume) +{ + int i; + unsigned char buf[16]; + + if(volume > 0x38) + volume = 0x38; + + i=0; + buf[i++] = DAC_REG_WRITE | DAC_AVOL; + buf[i++] = (volume & 0x3f) | 0x40; /* Deemphasis ON */ + buf[i++] = volume & 0x3f; + + /* send read command */ + if (i2c_write(DAC_DEV_WRITE,buf,i)) + { + return -1; + } + return 0; +} + +/*************************************************** +** Bit6: 0 = 3V, 1 = 5V +** Bit5: 0 = normal, 1 = low power +** Bit4: 0 = AUX2 off, 1 = AUX2 on +** Bit3: 0 = AUX1 off, 1 = AUX2 on +** Bit2: 0 = DAC off, 1 = DAC on +** Bit1: 0 = stereo, 1 = mono +** Bit0: 0 = normal right amp, 1 = inverted right amp +***************************************************/ +int dac_config(int value) +{ + int i; + unsigned char buf[16]; + + i=0; + buf[i++] = DAC_REG_WRITE | DAC_GCFG; + buf[i++] = value; + + /* send read command */ + if (i2c_write(DAC_DEV_WRITE,buf,i)) + { + return -1; + } + return 0; +} diff --git a/firmware/drivers/dac.h b/firmware/drivers/dac.h new file mode 100644 index 0000000..c860538 --- /dev/null +++ b/firmware/drivers/dac.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Linus Nielsen Feltzing + * + * 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. + * + ****************************************************************************/ +#ifndef _DAC_H_ +#define _DAC_H_ + +/* + DAC I2C defs +*/ +#define DAC_ADR 0x9a +#define DAC_DEV_WRITE (DAC_ADR | 0x00) + +#define DAC_REG_WRITE 0xc0 + +/* registers..*/ +#define DAC_SR_REG 1 +#define DAC_AVOL 2 +#define DAC_GCFG 3 + +extern int dac_volume(unsigned int volume); +extern int dac_config(int value); + +#endif |